Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
tracking.phtml
Go to the documentation of this file.
1 <?php
7 // @codingStandardsIgnoreFile
8 
9 ?>
10 <?php ?>
11 <script>
12 require(['prototype'], function(){
13 
14  //<![CDATA[
15  var trackingControl;
16  trackingControl = {
17  index : 0,
18  add : function () {
19  this.index++;
20  var data = {index:this.index};
21  Element.insert($('track_row_container'), {
22  bottom: this.template({
23  data: data
24  })
25  });
26  $('trackingC' + this.index).disabled = false;
27  $('trackingT' + this.index).disabled = false;
28  $('trackingN' + this.index).disabled = false;
29  this.bindCurrierOnchange();
30  },
31  deleteRow : function(event) {
32  var row = Event.findElement(event, 'tr');
33  if (row) {
34  row.parentNode.removeChild(row)
35  }
36  },
37  bindCurrierOnchange : function() {
38  var elems = $('tracking_numbers_table').select('.select');
39  elems.each(function (elem) {
40  if (!elem.onchangeBound) {
41  elem.onchangeBound = true;
42  elem.valueInput = $(elem.parentNode.parentNode).select('.number-title')[0];
43  elem.observe('change', this.currierOnchange);
44  }
45  }.bind(this));
46  },
47  currierOnchange : function(event) {
48  var elem = Event.element(event);
49  var option = elem.options[elem.selectedIndex];
50  if (option.value && option.value != 'custom') {
51  elem.valueInput.value = option.text;
52  }
53  else {
54  elem.valueInput.value = '';
55  }
56  }
57  };
58 
59  window.trackingControl = trackingControl;
60  //]]>
61 
62 });
63 </script>
64 <script id="track_row_template" type="text/x-magento-template">
65  <tr>
66  <td class="col-carrier">
67  <select name="tracking[<%- data.index %>][carrier_code]"
68  id="trackingC<%- data.index %>"
69  class="select admin__control-select carrier"
70  disabled="disabled">
71  <?php foreach ($block->getCarriers() as $_code => $_name): ?>
72  <option value="<?= /* @escapeNotVerified */ $_code ?>"><?= $block->escapeHtml($_name) ?></option>
73  <?php endforeach; ?>
74  </select>
75  </td>
76  <td class="col-title">
77  <input class="input-text admin__control-text number-title"
78  type="text"
79  name="tracking[<%- data.index %>][title]"
80  id="trackingT<%- data.index %>"
81  value=""
82  disabled="disabled" />
83  </td>
84  <td class="col-number">
85  <input class="input-text admin__control-text required-entry"
86  type="text"
87  name="tracking[<%- data.index %>][number]"
88  id="trackingN<%- data.index %>"
89  value=""
90  disabled="disabled" />
91  </td>
92  <td class="col-delete">
93  <button
94  type="button"
95  class="action-default action-delete"
96  onclick="trackingControl.deleteRow(event);return false">
97  <span><?= /* @escapeNotVerified */ __('Delete') ?></span>
98  </button>
99  </td>
100  </tr>
101 </script>
102 
103 <div class="admin__control-table-wrapper">
104  <table class="data-table admin__control-table" id="tracking_numbers_table">
105  <thead>
106  <tr class="headings">
107  <th class="col-carrier"><?= /* @escapeNotVerified */ __('Carrier') ?></th>
108  <th class="col-title"><?= /* @escapeNotVerified */ __('Title') ?></th>
109  <th class="col-number"><?= /* @escapeNotVerified */ __('Number') ?></th>
110  <th class="col-delete"><?= /* @escapeNotVerified */ __('Action') ?></th>
111  </tr>
112  </thead>
113  <tfoot>
114  <tr>
115  <td colspan="4" class="col-actions-add"><?= $block->getChildHtml('add_button') ?></td>
116  </tr>
117  </tfoot>
118  <tbody id="track_row_container">
119  </tbody>
120  </table>
121 </div>
122 <script>
123 require([
124  'mage/template',
125  'prototype'
126 ], function (mageTemplate) {
127 
128  //<![CDATA[
129  trackingControl.template = mageTemplate('#track_row_template');
130  //]]>
131 
132 });
133 </script>
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
Definition: block.php:9
foreach( $this->main as $item) endforeach
Definition: side-menu.phtml:10
__()
Definition: __.php:13
$_code
Definition: attribute.phtml:19
$block
Definition: block.php:8