Skip to content

Commit

Permalink
Merge pull request #62 from magento-vanilla/MAGETWO-31191
Browse files Browse the repository at this point in the history
[Vanilla] Sprint 10
  • Loading branch information
dvilchynskyi committed Jan 27, 2015
2 parents 8892e7b + 9d05b99 commit 8f09664
Show file tree
Hide file tree
Showing 324 changed files with 2,469 additions and 76,161 deletions.
41 changes: 38 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ module.exports = function (grunt) {
// Require
// --------------------------------------

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 @@ -33,7 +35,10 @@ module.exports = function (grunt) {
blank: 'app/design/frontend/Magento/blank',
luma: 'app/design/frontend/luma'
},
doc: 'lib/web/css/docs'
doc: 'lib/web/css/docs',
uglify: {
legacy: 'lib/web/legacy-build.min.js'
}
},
doc: {
styleName: 'docs'
Expand Down Expand Up @@ -110,7 +115,7 @@ module.exports = function (grunt) {
},
documentation: {
files: {
'<%= config.path.doc %>/<%= config.doc.styleName %>.css': "<%= config.path.doc %>/source/<%= config.doc.styleName %>.less"
'<%= config.path.doc %>/<%= config.doc.styleName %>.css': '<%= config.path.doc %>/source/<%= config.doc.styleName %>.less'
}
}
},
Expand All @@ -131,10 +136,40 @@ module.exports = function (grunt) {
'<%= config.path.doc %>': '<%= config.path.doc %>/source' // Todo UI: Check out JS for Styledocco
}
}
}
},

'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'
]
}
}
}
});

/**
* Creates build of a legacy files.
* Mostly prototype dependant libraries.
*/
grunt.registerTask('legacy-build', [
'mage-minify:legacy'
]);

// Default task
// --------------------------------------
grunt.registerTask('default', []); // ToDo UI: define default tasks
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
41 changes: 0 additions & 41 deletions app/code/Magento/Backend/view/adminhtml/requirejs-config.js

This file was deleted.

Loading

0 comments on commit 8f09664

Please sign in to comment.