Skip to content

Commit

Permalink
MAGETWO-31195: Image compression and sizing
Browse files Browse the repository at this point in the history
- Merge remote-tracking branch 'magento2ce/develop' into develop
Conflicts:
	Gruntfile.js
	app/design/adminhtml/Magento/backend/Magento_Backend/layout/default.xml
	lib/web/jquery/farbtastic/images/marker.png
	lib/web/jquery/farbtastic/images/mask.png
	lib/web/jquery/farbtastic/images/wheel.png
  • Loading branch information
Natalia Momotenko committed Jan 28, 2015
2 parents 9276f80 + 9e8434e commit e297781
Show file tree
Hide file tree
Showing 953 changed files with 22,351 additions and 96,613 deletions.
56 changes: 46 additions & 10 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ module.exports = function (grunt) {
// Required plugins
// _____________________________________________

require('./dev/tools/grunt/tasks/mage-minify')(grunt);

// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);

Expand All @@ -37,6 +39,9 @@ module.exports = function (grunt) {
less: {
setup: 'setup/module/Magento/Setup/styles'
},
uglify: {
legacy: 'lib/web/legacy-build.min.js'
},
doc: 'lib/web/css/docs'
};

Expand Down Expand Up @@ -413,6 +418,29 @@ module.exports = function (grunt) {
}
},

'mage-minify': {
legacy: {
options: {
type: 'yui-js',
tempPath: 'var/cache/',
options: ['--nomunge=true']
},
files: {
'<%= config.path.uglify.legacy %>': [
'lib/web/prototype/prototype.js',
'lib/web/prototype/window.js',
'lib/web/scriptaculous/builder.js',
'lib/web/scriptaculous/effects.js',
'lib/web/lib/ccard.js',
'lib/web/prototype/validation.js',
'lib/web/varien/js.js',
'lib/web/mage/adminhtml/varienLoader.js',
'lib/web/mage/adminhtml/tools.js'
]
}
}
},

//

styledocco: {
Expand Down Expand Up @@ -442,16 +470,6 @@ module.exports = function (grunt) {
grunt.log.subhead('I\'m default task and at the moment I\'m empty, sorry :/');
});

// Documentation
// ---------------------------------------------

grunt.registerTask('documentation', [
'less:documentation',
'styledocco:documentation',
'clean:var',
'clean:pub'
]);

// Refresh magento frontend & backend
// ---------------------------------------------

Expand All @@ -462,6 +480,24 @@ module.exports = function (grunt) {
'less:backend'
]);

// Creates build of a legacy files.
// Mostly prototype dependant libraries.
// ---------------------------------------------

grunt.registerTask('legacy-build', [
'mage-minify:legacy'
]);

// Documentation
// ---------------------------------------------

grunt.registerTask('documentation', [
'less:documentation',
'styledocco:documentation',
'clean:var',
'clean:pub'
]);

// Production
// ---------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
var config = {
map: {
'*': {
systemMessageDialog: 'Magento_AdminNotification/system/notification'
systemMessageDialog: 'Magento_AdminNotification/system/notification',
toolbarEntry: 'Magento_AdminNotification/toolbar_entry'
}
},
deps: [
"Magento_AdminNotification/toolbar_entry"
]
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @see \Magento\AdminNotification\Block\Window
*/
?>
<div class="fade critical-notification">
<div data-mage-init='{"modalPopup": {}}' class="fade critical-notification">
<div class="popup popup-<?php echo preg_replace('#[^a-z0-9]+#', '-', strtolower($this->getSeverityText())) ?>">
<div class="popup-inner">
<header class="popup-header">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
?>
<?php /** @var $this \Magento\AdminNotification\Block\ToolbarEntry */ ?>
<?php $notificationCount = $this->getUnreadNotificationCount(); ?>
<div class="notifications-summary" data-notification-count="<?php echo $this->escapeHtml($notificationCount); ?>">
<div data-mage-init='{"toolbarEntry": {}}' class="notifications-summary" data-notification-count="<?php echo $this->escapeHtml($notificationCount); ?>">
<?php if ($notificationCount > 0) : ?>
<a href="<?php echo $this->getUrl('adminhtml/notification/index'); ?>" class="action notifications-action" data-mage-init='{"dropdown":{}}' title="<?php echo __('Notifications'); ?>" data-toggle="dropdown">
<span class="text"><?php echo __('Notifications'); ?></span>
Expand Down
181 changes: 90 additions & 91 deletions app/code/Magento/AdminNotification/view/adminhtml/web/toolbar_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,106 +4,105 @@
*/
define([
"jquery",
"jquery/ui"
"jquery/ui",
"domReady!"
], function($){
'use strict';

$(document).ready(function() {
// Mark notification as read via AJAX call
var markNotificationAsRead = function(notificationId) {
var requestUrl = $('.notifications-summary .dropdown-menu').attr('data-mark-as-read-url');
$.ajax({
url: requestUrl,
type: 'POST',
dataType: 'json',
data: {
id: notificationId
},
showLoader: false
});
};
var notificationCount = $('.notifications-summary').attr('data-notification-count');
// Remove notification from the list
var removeNotificationFromList = function(notificationEntry) {
notificationEntry.remove();
notificationCount--;
$('.notifications-summary').attr('data-notification-count', notificationCount);

if (notificationCount == 0) {
// Change appearance of the bubble and its behavior when the last notification is removed
$('.notifications-summary .dropdown-menu').remove();
var notificationIcon = $('.notifications-summary .notifications-icon');
notificationIcon.removeAttr('data-toggle');
notificationIcon.off('click.dropdown');
$('.notifications-action .counter').text('');
$('.notifications-action .counter').hide();
} else {
$('.notifications-action .counter').text(notificationCount);
// Modify caption of the 'See All' link
var actionElement = $('.notifications-summary .dropdown-menu .last .action-more');
actionElement.text(actionElement.text().replace(/\d+/, notificationCount));
}
};

// Show popup with notification details
var showNotificationDetails = function(notificationEntry) {
var popupElement = notificationEntry.find('.notifications-dialog-content').clone();
var notificationId = notificationEntry.attr('data-notification-id');
var dialogClassSeverity = 'notifications-entry-dialog';
if (notificationEntry.attr('data-notification-severity')) {
dialogClassSeverity = 'notifications-entry-dialog notifications-entry-dialog-critical';
}
popupElement.dialog({
title: popupElement.attr('data-title'),
minWidth: 500,
modal: true,
dialogClass: dialogClassSeverity,
buttons: [
{
text: popupElement.attr('data-acknowledge-caption'),
'class': 'action-acknowledge primary',
click: function(event) {
markNotificationAsRead(notificationId);
removeNotificationFromList(notificationEntry);
$(this).dialog('close');
}
},
{
text: popupElement.attr('data-cancel-caption'),
'class': 'action-cancel',
click: function(event) {
$(this).dialog('close');
}
}
]
});
popupElement.parent().attr('aria-live','assertive');
popupElement.dialog('open');
};

// Show notification description when corresponding item is clicked
$('.notifications-summary .dropdown-menu .notifications-entry').on('click.showNotification', function(event) {
// hide notification dropdown
$('.notifications-summary .notifications-icon').trigger('click.dropdown');
showNotificationDetails($(this));
event.stopPropagation();
});

// Remove corresponding notification from the list and mark it as read
$('.notifications-close').on('click.removeNotification', function(event) {
var notificationEntry = $(this).closest('.notifications-entry')
var notificationId = notificationEntry.attr('data-notification-id');
markNotificationAsRead(notificationId);
removeNotificationFromList(notificationEntry);
event.stopPropagation();
// Mark notification as read via AJAX call
var markNotificationAsRead = function(notificationId) {
var requestUrl = $('.notifications-summary .dropdown-menu').attr('data-mark-as-read-url');
$.ajax({
url: requestUrl,
type: 'POST',
dataType: 'json',
data: {
id: notificationId
},
showLoader: false
});
};
var notificationCount = $('.notifications-summary').attr('data-notification-count');
// Remove notification from the list
var removeNotificationFromList = function(notificationEntry) {
notificationEntry.remove();
notificationCount--;
$('.notifications-summary').attr('data-notification-count', notificationCount);

// Hide notifications bubble
if (notificationCount == 0) {
// Change appearance of the bubble and its behavior when the last notification is removed
$('.notifications-summary .dropdown-menu').remove();
var notificationIcon = $('.notifications-summary .notifications-icon');
notificationIcon.removeAttr('data-toggle');
notificationIcon.off('click.dropdown');
$('.notifications-action .counter').text('');
$('.notifications-action .counter').hide();
} else {
$('.notifications-action .counter').show();
$('.notifications-action .counter').text(notificationCount);
// Modify caption of the 'See All' link
var actionElement = $('.notifications-summary .dropdown-menu .last .action-more');
actionElement.text(actionElement.text().replace(/\d+/, notificationCount));
}
};

// Show popup with notification details
var showNotificationDetails = function(notificationEntry) {
var popupElement = notificationEntry.find('.notifications-dialog-content').clone();
var notificationId = notificationEntry.attr('data-notification-id');
var dialogClassSeverity = 'notifications-entry-dialog';
if (notificationEntry.attr('data-notification-severity')) {
dialogClassSeverity = 'notifications-entry-dialog notifications-entry-dialog-critical';
}
popupElement.dialog({
title: popupElement.attr('data-title'),
minWidth: 500,
modal: true,
dialogClass: dialogClassSeverity,
buttons: [
{
text: popupElement.attr('data-acknowledge-caption'),
'class': 'action-acknowledge primary',
click: function(event) {
markNotificationAsRead(notificationId);
removeNotificationFromList(notificationEntry);
$(this).dialog('close');
}
},
{
text: popupElement.attr('data-cancel-caption'),
'class': 'action-cancel',
click: function(event) {
$(this).dialog('close');
}
}
]
});
popupElement.parent().attr('aria-live','assertive');
popupElement.dialog('open');
};

// Show notification description when corresponding item is clicked
$('.notifications-summary .dropdown-menu .notifications-entry').on('click.showNotification', function(event) {
// hide notification dropdown
$('.notifications-summary .notifications-icon').trigger('click.dropdown');
showNotificationDetails($(this));
event.stopPropagation();
});

// Remove corresponding notification from the list and mark it as read
$('.notifications-close').on('click.removeNotification', function(event) {
var notificationEntry = $(this).closest('.notifications-entry')
var notificationId = notificationEntry.attr('data-notification-id');
markNotificationAsRead(notificationId);
removeNotificationFromList(notificationEntry);
event.stopPropagation();
});

// Hide notifications bubble
if (notificationCount == 0) {
$('.notifications-action .counter').hide();
} else {
$('.notifications-action .counter').show();
}

});
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ protected function _getFooterHtml($element)
protected function _getExtraJs($element)
{
$htmlId = $element->getHtmlId();
$output = "Fieldset.applyCollapse('{$htmlId}');";
$output = "require(['prototype'], function(){Fieldset.applyCollapse('{$htmlId}');});";
return $this->_jsHelper->getScript($output);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function getToggleAttributesHtml()
}

$attributes = ['title' => $title, 'class' => join(' ', $classes), 'disabled' => $disabled];
$this->_getDataAttributes(['toggle' => 'dropdown'], $attributes);
$this->_getDataAttributes(['mage-init' => '{"dropdown": {}}', 'toggle' => 'dropdown'], $attributes);

$html = $this->_getAttributesString($attributes);
$html .= $this->getUiId('dropdown');
Expand Down
21 changes: 3 additions & 18 deletions app/code/Magento/Backend/view/adminhtml/layout/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,10 @@
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<head>
<title>Magento Admin</title>
<link src="prototype/prototype.js"/>
<link src="prototype/window.js"/>
<link src="scriptaculous/builder.js"/>
<link src="scriptaculous/effects.js"/>
<link src="lib/ccard.js"/>
<link src="prototype/validation.js"/>
<link src="varien/js.js"/>
<link src="mage/adminhtml/varienLoader.js"/>
<link src="mage/adminhtml/tools.js"/>
<link src="lib/ds-sleight.js" ie_condition="lt IE 7" defer="defer"/>
<css src="mage/calendar.css"/>
<link src="legacy-build.min.js"/>
<link src="requirejs/require.js"/>
<link src="mage/requirejs/resolver.js"/>
<link src="jquery/jquery.js"/>
<link src="mage/jquery-no-conflict.js"/>
<link src="app-config.js"/>
<link src="extjs/ext-tree.js"/>
<link src="extjs/ext-tree-checkbox.js"/>
<link src="jquery.js"/>
<css src="mage/calendar.css"/>
<css src="extjs/resources/css/ext-all.css"/>
<css src="extjs/resources/css/ytheme-magento.css"/>
</head>
Expand Down Expand Up @@ -87,7 +73,6 @@
<referenceContainer name="after.body.start">
<block class="Magento\RequireJs\Block\Html\Head\Config" name="requirejs-config"/>
<block class="Magento\Translation\Block\Js" name="translate" template="Magento_Translation::translate.phtml"/>
<block class="Magento\Framework\View\Element\Template" name="head.scripts" template="Magento_Backend::page/js/head_scripts.phtml"/>
<block class="Magento\Framework\View\Element\Js\Components" name="head.components" as="components" template="Magento_Backend::page/js/components.phtml"/>
<block class="Magento\Framework\View\Element\Html\Calendar" name="head.calendar" as="calendar" template="Magento_Backend::page/js/calendar.phtml"/>
</referenceContainer>
Expand Down
Loading

0 comments on commit e297781

Please sign in to comment.