Skip to content

Commit 78d0045

Browse files
author
Denys Rul
committed
MAGETWO-32814: Fix dependency in inline code
- Make a first step to remove prototype.js from a page header
1 parent 01cb488 commit 78d0045

File tree

31 files changed

+128
-123
lines changed

31 files changed

+128
-123
lines changed

app/code/Magento/Backend/Block/System/Config/Form/Fieldset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ protected function _getFooterHtml($element)
214214
protected function _getExtraJs($element)
215215
{
216216
$htmlId = $element->getHtmlId();
217-
$output = "Fieldset.applyCollapse('{$htmlId}');";
217+
$output = "require(['prototype'], function(){Fieldset.applyCollapse('{$htmlId}');});";
218218
return $this->_jsHelper->getScript($output);
219219
}
220220

app/code/Magento/Backend/view/adminhtml/layout/default.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
<referenceContainer name="after.body.start">
7676
<block class="Magento\RequireJs\Block\Html\Head\Config" name="requirejs-config"/>
7777
<block class="Magento\Translation\Block\Js" name="translate" template="Magento_Translation::translate.phtml"/>
78-
<block class="Magento\Framework\View\Element\Template" name="head.scripts" template="Magento_Backend::page/js/head_scripts.phtml"/>
7978
<block class="Magento\Framework\View\Element\Js\Components" name="head.components" as="components" template="Magento_Backend::page/js/components.phtml"/>
8079
<block class="Magento\Framework\View\Element\Html\Calendar" name="head.calendar" as="calendar" template="Magento_Backend::page/js/calendar.phtml"/>
8180
</referenceContainer>

app/code/Magento/Backend/view/adminhtml/templates/dashboard/index.phtml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
<?php if (is_array($this->getChildBlock('diagrams')->getTabsIds())) : ?>
99
<script>
10-
function changeDiagramsPeriod(periodObj) {
10+
require(['prototype'], function(){
11+
12+
window.changeDiagramsPeriod = function(periodObj) {
1113
periodParam = periodObj.value ? 'period/' + periodObj.value + '/' : '';
1214
<?php foreach ($this->getChildBlock('diagrams')->getTabsIds() as $tabId): ?>
1315
ajaxBlockParam = 'block/tab_<?php echo $tabId ?>/';
@@ -60,10 +62,7 @@ function changeDiagramsPeriod(periodObj) {
6062
});
6163
}
6264

63-
function toggleCal(id) {
64-
$('dashboard_'+id+'_cal_div').toggle();
65-
$('dashboard_'+id+'_range_div').toggle();
66-
}
65+
});
6766
</script>
6867
<?php endif; ?>
6968
<div class="dashboard-container">

app/code/Magento/Backend/view/adminhtml/templates/dashboard/store/switcher.phtml

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,29 @@
3232
</select>
3333
</p>
3434
<script>
35-
function switchStore(obj){
36-
if (obj.options[obj.selectedIndex].getAttribute('website') == 'true') {
37-
var selectionType = 'website';
38-
} else if (obj.options[obj.selectedIndex].getAttribute('group') == 'true') {
39-
var selectionType = 'group';
40-
} else {
41-
var selectionType = 'store';
35+
require([
36+
'prototype'
37+
], function () {
38+
39+
window.switchStore = function (obj) {
40+
if (obj.options[obj.selectedIndex].getAttribute('website') == 'true') {
41+
var selectionType = 'website';
42+
} else if (obj.options[obj.selectedIndex].getAttribute('group') == 'true') {
43+
var selectionType = 'group';
44+
} else {
45+
var selectionType = 'store';
46+
}
47+
var storeParam = obj.value ? selectionType + '/' + obj.value + '/' : '';
48+
if (obj.switchParams) {
49+
storeParam += obj.switchParams;
50+
}
51+
if ($('diagram_tab_orders_content').style.display != 'none') {
52+
var select = $('order_orders_period');
53+
} else if ($('diagram_tab_amounts_content').style.display != 'none') {
54+
var select = $('order_amounts_period');
55+
}
56+
var periodParam = select.value ? 'period/' + select.value + '/' : '';
57+
setLocation('<?php echo $this->getSwitchUrl() ?>' + storeParam + periodParam);
4258
}
43-
var storeParam = obj.value ? selectionType + '/' + obj.value + '/' : '';
44-
if(obj.switchParams){
45-
storeParam+= obj.switchParams;
46-
}
47-
if ($('diagram_tab_orders_content').style.display != 'none') {
48-
var select = $('order_orders_period');
49-
} else if ($('diagram_tab_amounts_content').style.display != 'none') {
50-
var select = $('order_amounts_period');
51-
}
52-
var periodParam = select.value ? 'period/'+select.value + '/' : '';
53-
setLocation('<?php echo $this->getSwitchUrl() ?>'+storeParam+periodParam);
54-
}
59+
});
5560
</script>

app/code/Magento/Backend/view/adminhtml/templates/menu.phtml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,3 @@
77
<nav data-mage-init='{"globalNavigation": {}}' class="navigation">
88
<?php echo $this->renderNavigation($this->getMenuModel(), 0, 12); ?>
99
</nav>
10-
11-
<?php /* @TODO: find the place for the help ?>
12-
<a id="page-help-link" href="<?php echo $this->helper('Magento\Backend\Helper\Data')->getPageHelpUrl() ?>"><?php echo __('Get help for this page') ?></a>
13-
<script>$('page-help-link').target = 'magento_page_help'</script>
14-
<?php */ ?>

app/code/Magento/Backend/view/adminhtml/templates/page/js/head_scripts.phtml

Lines changed: 0 additions & 10 deletions
This file was deleted.

app/code/Magento/Backend/view/adminhtml/templates/page/system/config/robots/reset.phtml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ $coreHelper = $this->helper('Magento\Core\Helper\Data');
1212
?>
1313

1414
<script>
15-
function resetRobotsToDefault()
16-
{
17-
$('design_search_engine_robots_custom_instructions').value = <?php
18-
echo $coreHelper->jsonEncode($this->getRobotsDefaultCustomInstructions())
19-
?>;
20-
}
15+
require([
16+
'prototype'
17+
], function () {
18+
window.resetRobotsToDefault = function(){
19+
$('design_search_engine_robots_custom_instructions').value = <?php
20+
echo $coreHelper->jsonEncode($this->getRobotsDefaultCustomInstructions())
21+
?>;
22+
}
23+
});
2124
</script>
2225

2326
<?php echo $this->getButtonHtml() ?>

app/code/Magento/Backend/view/adminhtml/templates/system/cache/edit.phtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
<?php echo $this->getBlockHtml('formkey')?>
1919

2020
<script>
21-
function setCacheAction(id, button) {
22-
$(id).value = button.id;
21+
window.setCacheAction = function(id, button) {
22+
document.getElementById(id).value = button.id;
23+
2324
configForm.submit();
2425
}
2526
</script>

app/code/Magento/Backend/view/adminhtml/templates/system/config/form/field/array.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ $_colspan = $this->isAddAfter() ? 2 : 1;
3434
<input type="hidden" name="<?php echo $this->getElement()->getName(); ?>[__empty]" value="" />
3535

3636
<script>
37-
37+
require(['prototype'], function(){
3838
// create row creator
3939
var arrayRow<?php echo $_htmlId ?> = {
4040

@@ -114,6 +114,6 @@ $_colspan = $this->isAddAfter() ? 2 : 1;
114114
<?php if ($this->getElement()->getDisabled()):?>
115115
toggleValueElements({checked: true}, $('grid<?php echo $_htmlId; ?>').parentNode);
116116
<?php endif;?>
117-
117+
});
118118
</script>
119119
</div>

app/code/Magento/Backend/view/adminhtml/templates/system/config/js.phtml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
*/
66
?>
77
<script>
8-
//<![CDATA[
8+
require([
9+
'prototype'
10+
], function () {
11+
912
var freeModel = Class.create();
1013
freeModel.prototype = {
1114
initialize : function()
@@ -233,8 +236,8 @@ function showHint() {
233236
});
234237
});
235238
}
236-
Event.observe(window, 'load', function(){
237-
showHint();
239+
240+
Event.observe(window, 'load', showHint);
241+
238242
});
239-
//]]>
240243
</script>

0 commit comments

Comments
 (0)