Skip to content

Commit

Permalink
Update as of 9/27/2012
Browse files Browse the repository at this point in the history
* Refactoring Magento 2 to use jQuery instead of Prototype:
  * Implemented simple lazy-loading functionality
  * Converted decorator mechanism to jQuery
  * Moved Installation process to jQuery
  * Moved Home, Category and Simple Product View pages to jQuery
  * Moved all frontend libraries from `pub/js` directory to `pub/lib`
* Improved Javascript unit tests to be consistent with other test frameworks in Magento
* Added Javascript code analysis tests to the static tests suite
* Added jQuery file uploader for admin backend, cleaned out old deprecated uploaders
* Implemented fixture of 100k orders for the performance tests
* Fixes
  * Admin menu elements order differs for a cached page and non-cached one
  * Typos in System > Configuration > General Tab
  * Wrong elements positions on "View Order" page
  * Impossible to configure checkout on store scope
  * Warning message in `system.log` when using GD2 image adapter
  * "Preview" link is absent for managing CMS Pages in single store mode
  * "Promotions" tab is missing on Configuration page
  * Wrong format of performance tests config
  • Loading branch information
magento-team committed Sep 27, 2012
1 parent da072ba commit 215c077
Show file tree
Hide file tree
Showing 1,345 changed files with 104,772 additions and 94,780 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ atlassian*
dev/api-tests/config.php
dev/api-tests/integration/tmp/*
dev/api-tests/integration/framework/local-mysql.xml

22 changes: 22 additions & 0 deletions CHANGELOG.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
Update as of 9/27/2012
======================
* Refactoring Magento 2 to use jQuery instead of Prototype:
* Implemented simple lazy-loading functionality
* Converted decorator mechanism to jQuery
* Moved Installation process to jQuery
* Moved Home, Category and Simple Product View pages to jQuery
* Moved all frontend libraries from `pub/js` directory to `pub/lib`
* Improved Javascript unit tests to be consistent with other test frameworks in Magento
* Added Javascript code analysis tests to the static tests suite
* Added jQuery file uploader for admin backend, cleaned out old deprecated uploaders
* Implemented fixture of 100k orders for the performance tests
* Fixes
* Admin menu elements order differs for a cached page and non-cached one
* Typos in System > Configuration > General Tab
* Wrong elements positions on "View Order" page
* Impossible to configure checkout on store scope
* Warning message in `system.log` when using GD2 image adapter
* "Preview" link is absent for managing CMS Pages in single store mode
* "Promotions" tab is missing on Configuration page
* Wrong format of performance tests config

Update as of 9/13/2012
======================
* Implemented the option to enable the single store mode in the system configuration, which simplifies the back-end GUI:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery extends Varien_Da
public function getElementHtml()
{
$html = $this->getContentHtml();
//$html.= $this->getAfterElementHtml();
return $html;
}

Expand All @@ -54,8 +53,9 @@ public function getContentHtml()
$content = Mage::getSingleton('Mage_Core_Model_Layout')
->createBlock('Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery_Content');

$content->setId($this->getHtmlId() . '_content')
->setElement($this);
$content->setId($this->getHtmlId() . '_content')->setElement($this);
$galleryJs = $content->getJsObjectName();
$content->getUploader()->getConfig()->setMegiaGallery($galleryJs);
return $content->toHtml();
}

Expand Down
151 changes: 0 additions & 151 deletions app/code/core/Mage/Adminhtml/Block/Media/Editor.php

This file was deleted.

63 changes: 9 additions & 54 deletions app/code/core/Mage/Adminhtml/Block/Media/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,65 +60,20 @@ public function __construct()
));
}

/**
* Prepares layout and set element renderer
*
* @return Mage_Adminhtml_Block_Media_Uploader
*/
protected function _prepareLayout()
{
$this->setChild(
'browse_button',
$this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Button')
->addData(array(
'id' => $this->_getButtonId('browse'),
'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Browse Files...'),
'type' => 'button',
'onclick' => $this->getJsObjectName() . '.browse()'
))
);

$this->setChild(
'upload_button',
$this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Button')
->addData(array(
'id' => $this->_getButtonId('upload'),
'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Upload Files'),
'type' => 'button',
'onclick' => $this->getJsObjectName() . '.upload()'
))
);

$this->setChild(
'delete_button',
$this->getLayout()->createBlock('Mage_Adminhtml_Block_Widget_Button')
->addData(array(
'id' => '{{id}}-delete',
'class' => 'delete',
'type' => 'button',
'label' => Mage::helper('Mage_Adminhtml_Helper_Data')->__('Remove'),
'onclick' => $this->getJsObjectName() . '.removeFile(\'{{fileId}}\')'
))
);

$head = $this->getLayout()->getBlock('head');
if ($head) {
$head->addCss('Mage_Adminhtml::jquery/fileUploader/css/jquery.fileupload-ui.css');
}
return parent::_prepareLayout();
}

protected function _getButtonId($buttonName)
{
return $this->getHtmlId() . '-' . $buttonName;
}

public function getBrowseButtonHtml()
{
return $this->getChildHtml('browse_button');
}

public function getUploadButtonHtml()
{
return $this->getChildHtml('upload_button');
}

public function getDeleteButtonHtml()
{
return $this->getChildHtml('delete_button');
}

/**
* Retrive uploader js object name
*
Expand Down
27 changes: 27 additions & 0 deletions app/code/core/Mage/Adminhtml/view/adminhtml/catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@
<action method="addJs"><file>mage/jquery-no-conflict.js</file></action>
<action method="addJs"><file>jquery/jquery-ui-1.8.18.custom.min.js</file></action>
<action method="addCss"><file>Mage_Adminhtml::css/ui-lightness/jquery-ui-1.8.21.custom.css</file></action>

<action method="addCss"><file>Mage_Adminhtml::jquery/fileUploader/css/jquery.fileupload-ui.css</file></action>
<action method="addJs"><file>Mage_Adminhtml::jquery/fileUploader/vendor/jquery.ui.widget.js</file></action>
<action method="addJs"><file>Mage_Adminhtml::jquery/fileUploader/jquery.iframe-transport.js</file></action>
<action method="addJs"><file>Mage_Adminhtml::jquery/fileUploader/jquery.fileupload.js</file></action>
<action method="addJs"><file>Mage_Adminhtml::jquery/fileUploader/load-image.min.js</file></action>
<action method="addJs"><file>Mage_Adminhtml::jquery/fileUploader/canvas-to-blob.min.js</file></action>
<action method="addJs"><file>Mage_Adminhtml::jquery/fileUploader/jquery.fileupload-fp.js</file></action>
</reference>
<reference name="content">
<block type="Mage_Adminhtml_Block_Catalog_Product_Edit" name="product_edit"></block>
Expand All @@ -72,6 +80,14 @@
<action method="addJs"><file>mage/jquery-no-conflict.js</file></action>
<action method="addJs"><file>jquery/jquery-ui-1.8.18.custom.min.js</file></action>
<action method="addCss"><file>Mage_Adminhtml::css/ui-lightness/jquery-ui-1.8.21.custom.css</file></action>

<action method="addCss"><file>Mage_Adminhtml::jquery/fileUploader/css/jquery.fileupload-ui.css</file></action>
<action method="addJs"><file>Mage_Adminhtml::jquery/fileUploader/vendor/jquery.ui.widget.js</file></action>
<action method="addJs"><file>Mage_Adminhtml::jquery/fileUploader/jquery.iframe-transport.js</file></action>
<action method="addJs"><file>Mage_Adminhtml::jquery/fileUploader/jquery.fileupload.js</file></action>
<action method="addJs"><file>Mage_Adminhtml::jquery/fileUploader/load-image.min.js</file></action>
<action method="addJs"><file>Mage_Adminhtml::jquery/fileUploader/canvas-to-blob.min.js</file></action>
<action method="addJs"><file>Mage_Adminhtml::jquery/fileUploader/jquery.fileupload-fp.js</file></action>
</reference>
<reference name="content">
<block type="Mage_Adminhtml_Block_Catalog_Product_Edit" name="product_edit"></block>
Expand Down Expand Up @@ -288,6 +304,17 @@ Layout handle for configurable products

<adminhtml_catalog_category_edit>
<update handle="editor"/>
<reference name="head">
<action method="addCss"><file>Mage_Adminhtml::jquery/fileUploader/css/jquery.fileupload-ui.css</file></action>

<action method="addJs"><file>Mage_Adminhtml::jquery/fileUploader/vendor/jquery.ui.widget.js</file></action>
<action method="addJs"><file>Mage_Adminhtml::jquery/fileUploader/jquery.iframe-transport.js</file></action>
<action method="addJs"><file>Mage_Adminhtml::jquery/fileUploader/jquery.fileupload.js</file></action>

<action method="addJs"><file>Mage_Adminhtml::jquery/fileUploader/load-image.min.js</file></action>
<action method="addJs"><file>Mage_Adminhtml::jquery/fileUploader/canvas-to-blob.min.js</file></action>
<action method="addJs"><file>Mage_Adminhtml::jquery/fileUploader/jquery.fileupload-fp.js</file></action>
</reference>
<reference name="left">
<block name="category.tree" type="Mage_Adminhtml_Block_Catalog_Category_Tree" template="catalog/category/tree.phtml" />
</reference>
Expand Down
36 changes: 12 additions & 24 deletions app/code/core/Mage/Adminhtml/view/adminhtml/catalog/product.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,30 +91,18 @@ Product.Gallery.prototype = {
this.getElement('add_images_button').hide();
this.getElement('uploader').show();
},
handleUploadComplete : function(files) {
files.each( function(item) {
if (!item.response.isJSON()) {
try {
console.log(item.response);
} catch (e2) {
alert(item.response);
}
return;
}
var response = item.response.evalJSON();
if (response.error) {
return;
}
var newImage = {};
newImage.url = response.url;
newImage.file = response.file;
newImage.label = '';
newImage.position = this.getNextPosition();
newImage.disabled = 0;
newImage.removed = 0;
this.images.push(newImage);
this.uploader.removeFile(item.id);
}.bind(this));
handleUploadComplete : function(file) {
if (file.error) {
return;
}
var newImage = {};
newImage.url = file.url;
newImage.file = file.file;
newImage.label = '';
newImage.position = this.getNextPosition();
newImage.disabled = 0;
newImage.removed = 0;
this.images.push(newImage);
this.container.setHasChanges();
this.updateImages();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,6 @@ $_block = $this;
<input type="hidden" id="<?php echo $_block->getHtmlId() ?>_save_image" name="<?php echo $_block->getElement()->getName() ?>[values]" value="<?php echo $_block->escapeHtml($_block->getImagesValuesJson()) ?>" />
<script type="text/javascript">
//<![CDATA[
var <?php echo $_block->getJsObjectName(); ?> = new Product.Gallery('<?php echo $_block->getHtmlId() ?>', <?php if ($_block->getElement()->getReadonly()):?>null<?php else:?><?php echo $_block->getUploader()->getJsObjectName() ?><?php endif;?>, <?php echo $_block->getImageTypesJson() ?>);
var <?php echo $_block->getJsObjectName(); ?> = new Product.Gallery('<?php echo $_block->getHtmlId() ?>', null, <?php echo $_block->getImageTypesJson() ?>);
//]]>
</script>
Loading

0 comments on commit 215c077

Please sign in to comment.