Skip to content

Commit

Permalink
MAGETWO-32494: Remove jQuery JS library from main page header in the …
Browse files Browse the repository at this point in the history
…frontend

- Move jquery.js to lib/web root folder
- Remove from a page header on frontend area
- Add missing dependencies to jQuery library
  • Loading branch information
Denys Rul committed Jan 13, 2015
1 parent 1d3e0c8 commit 98214d7
Show file tree
Hide file tree
Showing 26 changed files with 78 additions and 77 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/view/adminhtml/layout/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<css src="mage/calendar.css"/>
<link src="requirejs/require.js"/>
<link src="mage/requirejs/resolver.js"/>
<link src="jquery/jquery.js"/>
<link src="jquery.js"/>
<css src="extjs/resources/css/ext-all.css"/>
<css src="extjs/resources/css/ytheme-magento.css"/>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ require([
'Magento_Ui/js/lib/registry/registry',
'jquery/file-uploader',
'mage/mage',
'prototype',

'prototype'
], function(jQuery, registry){
registry.get('downloadable', function (Downloadable) {
var linkTemplate = '<tr>'+
Expand Down
79 changes: 41 additions & 38 deletions app/code/Magento/Review/view/frontend/templates/review.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,49 @@
<div id="product-review-container"></div>
<?php echo $this->getChildHtml(); ?>

<script type="text/javascript">
//<![CDATA[
function processReviews(url,fromPages) {
(function($) {
$.ajax({
url: url,
dataType: 'html'
}).done(function(data) {
$('#product-review-container').html(data);
$('.pages a').each(function(index, element) {
$(element).click(function(event) {
processReviews($(element).attr('href'), true);
event.preventDefault();
<script>
require([
'jquery'
], function ($) {

function processReviews(url, fromPages) {
$.ajax({
url: url,
dataType: 'html'
}).done(function (data) {
$('#product-review-container').html(data);
$('.pages a').each(function (index, element) {
$(element).click(function (event) {
processReviews($(element).attr('href'), true);
event.preventDefault();
});
});
}).complete(function () {
if (fromPages == true) {
$('html, body').animate({
scrollTop: $('#reviews').offset().top - 50
}, 300);
}
});
});
}).complete(function(){
if (fromPages == true) {
$('html, body').animate({
scrollTop: $('#reviews').offset().top - 50
}, 300);
}
});
})(jQuery);
}
processReviews('<?php echo $this->getProductReviewUrl();?>');

jQuery(function() {
jQuery('.product-info-main .reviews-actions a').click(function(event) {
event.preventDefault();
var acnchor = jQuery(this).attr('href').replace(/^.*?(#|$)/,'');
jQuery(".product.data.items [data-role='content']").each(function(index){
if(this.id == "reviews") {
jQuery(".product.data.items").tabs('activate',index);
jQuery('html, body').animate({
scrollTop: jQuery('#' + acnchor).offset().top - 50
}, 300);
}
})
})
});
processReviews('<?php echo $this->getProductReviewUrl();?>');

//]]>
$(function () {
$('.product-info-main .reviews-actions a').click(function (event) {
event.preventDefault();
var acnchor = $(this).attr('href').replace(/^.*?(#|$)/, '');
$('.product.data.items [data-role='
content ']').each(function (index) {
if (this.id == 'reviews') {
$('.product.data.items').tabs('activate', index);
$('html, body').animate({
scrollTop: $('#' + acnchor).offset().top - 50
}, 300);
}
});
});
});

});
</script>
3 changes: 1 addition & 2 deletions app/code/Magento/Theme/view/adminhtml/requirejs-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ var config = {
},
"deps": [
"js/theme",
"jquery/jquery-migrate",
"mage/dropdown_old",
"mage/backend/bootstrap"
],
Expand All @@ -42,6 +41,6 @@ var config = {
}
};

require(['jquery'], function(jQuery){
require(['jquery'], function (jQuery) {
jQuery.noConflict();
});
6 changes: 5 additions & 1 deletion app/code/Magento/Theme/view/base/requirejs-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
var config = {
"waitSeconds": "0",
"shim": {
"jquery/jquery-migrate": ["jquery"],
"jquery/jquery.hashchange": ["jquery"],
"jquery/jquery.mousewheel": ["jquery"],
"jquery/jquery.popups": ["jquery"],
Expand Down Expand Up @@ -37,5 +38,8 @@ var config = {
"text": "requirejs/text",
"domReady": "requirejs/domReady",
"ko": "ko/ko"
}
},
"deps": [
"jquery/jquery-migrate"
]
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"/>
<css src="mage/calendar.css"/>
<script src="requirejs/require.js"/>
<!-- /**
TODO: remove jQuery. jQuery could be loaded through RequireJS. But only in case ALL MODULES ARE AMD MODULES.
Detail: http://requirejs.org/docs/jquery.html#noconflictmap
*/ -->
<script src="jquery/jquery.js"/>
</head>
<body>
<referenceContainer name="after.body.start">
Expand Down
2 changes: 0 additions & 2 deletions app/code/Magento/Theme/view/frontend/requirejs-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ var config = {
"jquery/ui": "jquery/jquery-ui"
},
deps: [
"jquery",
"jquery/jquery-migrate",
"jquery/jquery.mobile.custom",
"js/responsive",
"mage/common",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<script src="<?php echo $this->getViewFileUrl('mage/captcha.js') ?>"></script>

<script src="<?php echo $this->getViewFileUrl('requirejs/require.js') ?>"></script>
<script src="<?php echo $this->getViewFileUrl('jquery/jquery.js') ?>"></script>
<script src="<?php echo $this->getViewFileUrl('jquery.js') ?>"></script>
<script src="<?php echo $this->getViewFileUrl('Magento_User::app-config.js') ?>"></script>
<?php echo $this->getChildHtml('requirejs-config');?>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<script src="<?php echo $this->getViewFileUrl('mage/captcha.js') ?>"></script>

<script src="<?php echo $this->getViewFileUrl('requirejs/require.js') ?>"></script>
<script src="<?php echo $this->getViewFileUrl('jquery/jquery.js') ?>"></script>
<script src="<?php echo $this->getViewFileUrl('jquery.js') ?>"></script>
<script src="<?php echo $this->getViewFileUrl('Magento_User::app-config.js') ?>"></script>
<?php echo $this->getChildHtml('requirejs-config');?>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@
</div>
<?php else: ?>
<script>
jQuery('#layered-filter-block').addClass('filter-no-options');
require([
'jquery'
], function ($) {
$('#layered-filter-block').addClass('filter-no-options');
});
</script>
<?php endif; ?>
</div>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
"linkorb/jsmin-php": "lib/internal/JSMin",
"phpseclib/phpseclib": "lib/internal/phpseclib",
"components/jquery": [
"lib/web/jquery/jquery.js",
"lib/web/jquery.js",
"lib/web/jquery/jquery.min.js",
"lib/web/jquery/jquery-migrate.js",
"lib/web/jquery/jquery-migrate.min.js"
Expand Down
2 changes: 1 addition & 1 deletion dev/tests/js/jsTestDriverOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @return array
*/
return [
'/lib/web/jquery/jquery.js',
'/lib/web/jquery.js',
'/lib/web/jquery/jquery-migrate.js',
'/lib/web/jquery/jquery-ui-1.9.2.js',
'/dev/tests/js/framework/requirejs-util.js',
Expand Down
2 changes: 1 addition & 1 deletion dev/tests/js/testsuite/lib/ko/datepicker/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<base href="../../../"/>
<link type="text/css" rel="stylesheet" href="framework/qunit/qunit-1.14.0.css"/>
<script type="text/javascript" src="framework/qunit/qunit-1.14.0.js"></script>
<script src="../../../pub/lib/jquery/jquery.js"></script>
<script src="../../../pub/lib/jquery.js"></script>
<script src="../../../pub/moment.js"></script>
<script src="../../../pub/lib/ko/ko.js"></script>
<script type="text/javascript" src="testsuite/lib/ko/datepicker/datepicker.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion dev/tests/js/testsuite/lib/storage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<base href="../../../"/>
<link type="text/css" rel="stylesheet" href="framework/qunit/qunit-1.14.0.css"/>
<script type="text/javascript" src="framework/qunit/qunit-1.14.0.js"></script>
<script src="../../../pub/lib/jquery/jquery.js"></script>
<script src="../../../pub/lib/jquery.js"></script>
<script src="../../../pub/lib/jquery/jquery-ui.js"></script>
<script src="../../../pub/lib/jquery/jquery.cookie.js"></script>
<script src="../../../pub/lib/lib/storage.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion dev/tests/js/testsuite/mage/accordion/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<title>Accordion Widget: QUnit Tests </title>
<base href="../../../"/>
<link type="text/css" rel="stylesheet" href="framework/qunit/qunit-1.14.0.css"/>
<script type="text/javascript" src="../../../pub/lib/jquery/jquery.js"></script>
<script type="text/javascript" src="../../../pub/lib/jquery.js"></script>
<script type="text/javascript" src="../../../pub/lib/jquery/jquery-ui.js"></script>
<script type="text/javascript" src="framework/qunit/qunit-1.14.0.js"></script>
<script type="text/javascript" src="../../../pub/lib/mage/mage.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion dev/tests/js/testsuite/mage/calendar/calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<title>Calendar Widget: QUnit Tests </title>
<base href="../../../"/>
<link type="text/css" rel="stylesheet" href="framework/qunit/qunit-1.14.0.css"/>
<script type="text/javascript" src="../../../lib/web/jquery/jquery.js"></script>
<script type="text/javascript" src="../../../lib/web/jquery.js"></script>
<script type="text/javascript" src="../../../lib/web/jquery/jquery-ui.js"></script>
<script type="text/javascript" src="../../../lib/web/jquery/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="framework/qunit/qunit-1.14.0.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion dev/tests/js/testsuite/mage/collapsible/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<base href="../../../"/>
<link type="text/css" rel="stylesheet" href="framework/qunit/qunit-1.14.0.css"/>
<script type="text/javascript" src="framework/qunit/qunit-1.14.0.js"></script>
<script src="../../../pub/lib/jquery/jquery.js"></script>
<script src="../../../pub/lib/jquery.js"></script>
<script src="../../../pub/lib/jquery/jquery-ui.js"></script>
<script type="text/javascript" src="../../../pub/lib/mage/mage.js"></script>
<script type="text/javascript" src="../../../pub/lib/mage/collapsible.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion dev/tests/js/testsuite/mage/dropdown/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<base href="../../../"/>
<link type="text/css" rel="stylesheet" href="framework/qunit/qunit-1.14.0.css"/>
<script type="text/javascript" src="framework/qunit/qunit-1.14.0.js"></script>
<script src="../../../lib/web/jquery/jquery.js"></script>
<script src="../../../lib/web/jquery.js"></script>
<script src="../../../lib/web/jquery/jquery-ui.js"></script>
<script type="text/javascript" src="../../../lib/web/mage/mage.js"></script>
<script type="text/javascript" src="../../../lib/web/mage/dropdown.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion dev/tests/js/testsuite/mage/list/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<base href="../../../"/>
<link type="text/css" rel="stylesheet" href="framework/qunit/qunit-1.14.0.css"/>
<script type="text/javascript" src="framework/qunit/qunit-1.14.0.js"></script>
<script src="../../../pub/lib/jquery/jquery.js"></script>
<script src="../../../pub/lib/jquery.js"></script>
<script src="../../../pub/lib/jquery/jquery-ui.js"></script>
<script type="text/javascript" src="../../../pub/lib/mage/mage.js"></script>
<script type="text/javascript" src="../../../pub/lib/jquery/handlebars/handlebars-v1.3.0.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion dev/tests/js/testsuite/mage/loader/loader.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<title>Unit test</title>
<base href="../../../"/>
<link type="text/css" rel="stylesheet" href="framework/qunit/qunit-1.14.0.css"/>
<script src="../../../lib/web/jquery/jquery.js"></script>
<script src="../../../lib/web/jquery.js"></script>
<script src="../../../lib/web/jquery/jquery-ui.js"></script>
<script type="text/javascript" src="framework/qunit/qunit-1.14.0.js"></script>
<script type="text/javascript" src="../../../lib/web/mage/mage.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion dev/tests/js/testsuite/mage/menu/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<base href="../../../"/>
<link type="text/css" rel="stylesheet" href="framework/qunit/qunit-1.14.0.css"/>
<script type="text/javascript" src="framework/qunit/qunit-1.14.0.js"></script>
<script src="../../../pub/lib/jquery/jquery.js"></script>
<script src="../../../pub/lib/jquery.js"></script>
<script src="../../../pub/lib/jquery/jquery-ui.js"></script>
<script type="text/javascript" src="../../../pub/lib/mage/mage.js"></script>
<script type="text/javascript" src="../../../pub/lib/mage/menu.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion dev/tests/js/testsuite/mage/tabs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<title>Tabs Widget: QUnit Tests </title>
<base href="../../../"/>
<link type="text/css" rel="stylesheet" href="framework/qunit/qunit-1.14.0.css"/>
<script type="text/javascript" src="../../../pub/lib/jquery/jquery.js"></script>
<script type="text/javascript" src="../../../pub/lib/jquery.js"></script>
<script type="text/javascript" src="../../../pub/lib/jquery/jquery-ui.js"></script>
<script type="text/javascript" src="framework/qunit/qunit-1.14.0.js"></script>
<script type="text/javascript" src="../../../pub/lib/mage/mage.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion dev/tests/js/testsuite/mage/validation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<base href="../../../"/>
<link type="text/css" rel="stylesheet" href="framework/qunit/qunit-1.14.0.css"/>
<script type="text/javascript" src="framework/qunit/qunit-1.14.0.js"></script>
<script src="../../../lib/web/jquery/jquery.js"></script>
<script src="../../../lib/web/jquery.js"></script>

<script src="../../../lib/web/jquery/jquery-ui.js"></script>
<script type="text/javascript" src="../../../lib/web/mage/mage.js"></script>
Expand Down
File renamed without changes.
4 changes: 0 additions & 4 deletions lib/web/jquery/jquery.min.js

This file was deleted.

15 changes: 9 additions & 6 deletions lib/web/mage/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
* See COPYING.txt for license details.
*/
/*jshint browser:true jquery:true*/
jQuery(function ($) {
$(document).ready(function(){
/* Form with auto submit feature */
$('form[data-auto-submit="true"]').submit();
});
});
define([
'jquery',
'domReady'
], function ($) {
'use strict';

/* Form with auto submit feature */
$('form[data-auto-submit="true"]').submit();
});

0 comments on commit 98214d7

Please sign in to comment.