-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #519 from magento-vanilla/MAGETWO-34004
[Sky EPAM] Inline JS Elimination from Storefront
- Loading branch information
Showing
16 changed files
with
422 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
app/code/Magento/DesignEditor/view/frontend/web/add-class.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
define(['jquery'], function ($) { | ||
'use strict'; | ||
|
||
return function (config, element) { | ||
|
||
if (config.config) { | ||
$(element).addClass(config.class); | ||
} | ||
|
||
$('body').attr('data-container', 'body'); | ||
}; | ||
}); |
34 changes: 34 additions & 0 deletions
34
app/code/Magento/DesignEditor/view/frontend/web/translations-click.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
define([ | ||
'jquery', | ||
'mageUtils', | ||
'mage/translate-inline', | ||
'mage/translate-inline-vde' | ||
], function ($, utils) { | ||
'use strict'; | ||
|
||
return function (config, element) { | ||
|
||
return utils.extend(config, { | ||
|
||
/** | ||
* Extended handler for | ||
* @param {jQuery.Event} event | ||
* @param {Object} widget | ||
*/ | ||
onClick: function (event, widget) { | ||
$('body').removeClass('trnslate-inline-' + widget.options.translateMode + '-area'); | ||
$(element)[config.translation]('hide'); | ||
$('#translate-dialog').translateInlineDialogVde( | ||
'openWithWidget', | ||
event, | ||
widget, | ||
$.proxy(widget.replaceText, widget) | ||
); | ||
} | ||
}); | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
app/code/Magento/Review/view/frontend/web/js/error-placement.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
define([ | ||
'jquery', | ||
'mage/mage' | ||
], function ($, mage) { | ||
'use strict'; | ||
|
||
return function (config, element) { | ||
$(element).mage('validation', { | ||
errorPlacement: function (error, element) { | ||
|
||
if (element.parents('#product-review-table').length) { | ||
$('#product-review-table').siblings(this.errorElement + '.' + this.errorClass).remove(); | ||
$('#product-review-table').after(error); | ||
} else { | ||
element.after(error); | ||
} | ||
} | ||
}); | ||
}; | ||
}); |
48 changes: 48 additions & 0 deletions
48
app/code/Magento/Review/view/frontend/web/js/process-reviews.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
define([ | ||
'jquery' | ||
], function ($) { | ||
'use strict'; | ||
|
||
function processReviews(url, fromPages) { | ||
$.ajax({ | ||
url: url, | ||
dataType: 'html' | ||
}).done(function (data) { | ||
$('#product-review-container').html(data); | ||
$('[data-role="product-review"] .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); | ||
} | ||
}); | ||
} | ||
|
||
return function (config, element) { | ||
processReviews(config.productReviewUrl); | ||
$(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); | ||
} | ||
}); | ||
}); | ||
}); | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
app/code/Magento/SendFriend/view/frontend/web/back-event.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
define([ | ||
'jquery' | ||
], function ($) { | ||
'use strict'; | ||
|
||
return function (config, element) { | ||
$(element).on('click', function() { | ||
history.back(); | ||
return false; | ||
}); | ||
}; | ||
}); |
Oops, something went wrong.