11 <script
id=
"bundle-option-selection-box-template" type=
"text/x-magento-template">
12 <table
class=
"admin__control-table">
15 <th
class=
"col-draggable"></th>
16 <th
class=
"col-default"><?=
__(
'Default') ?></th>
17 <th
class=
"col-name"><?=
__(
'Name') ?></th>
18 <th
class=
"col-sku"><?=
__(
'SKU') ?></th>
19 <?php
if (
$block->getCanReadPrice() !==
false): ?>
20 <th
class=
"col-price price-type-box"><?=
__(
'Price') ?></th>
21 <th
class=
"col-price price-type-box"><?=
__(
'Price Type') ?></th>
23 <th
class=
"col-qty"><?=
__(
'Default Quantity') ?></th>
24 <th
class=
"col-uqty qty-box"><?=
__(
'User Defined') ?></th>
25 <th
class=
"col-order type-order" style=
"display:none"><?=
__(
'Position') ?></th>
26 <th
class=
"col-actions"></th>
33 <script
id=
"bundle-option-selection-row-template" type=
"text/x-magento-template">
34 <td
class=
"col-draggable">
35 <span data-role=
"draggable-handle" class=
"draggable-handle"></span>
36 <input type=
"hidden" id=
"<?= /* @escapeNotVerified */ $block->getFieldId() ?>_id<%- data.index %>" 37 name=
"<?= /* @escapeNotVerified */ $block->getFieldName() ?>[<%- data.parentIndex %>][<%- data.index %>][selection_id]" 38 value=
"<%- data.selection_id %>"/>
39 <input type=
"hidden" name=
"<?= /* @escapeNotVerified */ $block->getFieldName() ?>[<%- data.parentIndex %>][<%- data.index %>][option_id]" 40 value=
"<%- data.option_id %>"/>
41 <input type=
"hidden" class=
"product" 42 name=
"<?= /* @escapeNotVerified */ $block->getFieldName() ?>[<%- data.parentIndex %>][<%- data.index %>][product_id]" 43 value=
"<%- data.product_id %>"/>
44 <input type=
"hidden" name=
"<?= /* @escapeNotVerified */ $block->getFieldName() ?>[<%- data.parentIndex %>][<%- data.index %>][delete]" 45 value=
"" class=
"delete"/>
47 <td
class=
"col-default">
48 <input onclick=
"bSelection.checkGroup(event)" type=
"<%- data.option_type %>" class=
"default" 49 name=
"<?= /* @escapeNotVerified */ $block->getFieldName() ?>[<%- data.parentIndex %>][<%- data.index %>][is_default]" 50 value=
"1" <%- data.checked %> />
52 <td
class=
"col-name"><%- data.name %></td>
53 <td
class=
"col-sku"><%- data.sku %></td>
54 <?php
if (
$block->getCanReadPrice() !==
false): ?>
55 <td
class=
"col-price price-type-box">
56 <input
id=
"<?= /* @escapeNotVerified */ $block->getFieldId() ?>_<%- data.index %>_price_value" 57 class=
"input-text required-entry validate-zero-or-greater" type=
"text" 58 name=
"<?= /* @escapeNotVerified */ $block->getFieldName() ?>[<%- data.parentIndex %>][<%- data.index %>][selection_price_value]" 59 value=
"<%- data.selection_price_value %>" 60 <?php
if (
$block->getCanEditPrice() ===
false): ?>
64 <td
class=
"col-price price-type-box">
65 <?=
$block->getPriceTypeSelectHtml() ?>
66 <div><?=
$block->getCheckboxScopeHtml() ?></div>
69 <input type=
"hidden" id=
"<?= /* @escapeNotVerified */ $block->getFieldId() ?>_<%- data.index %>_price_value" 70 name=
"<?= /* @escapeNotVerified */ $block->getFieldName() ?>[<%- data.parentIndex %>][<%- data.index %>][selection_price_value]" value=
"0" />
71 <input type=
"hidden" id=
"<?= /* @escapeNotVerified */ $block->getFieldId() ?>_<%- data.index %>_price_type" 72 name=
"<?= /* @escapeNotVerified */ $block->getFieldName() ?>[<%- data.parentIndex %>][<%- data.index %>][selection_price_type]" value=
"0" />
73 <?php
if (
$block->isUsedWebsitePrice()): ?>
74 <input type=
"hidden" id=
"<?= /* @escapeNotVerified */ $block->getFieldId() ?>_<%- data.index %>_price_scope" 75 name=
"<?= /* @escapeNotVerified */ $block->getFieldName() ?>[<%- data.parentIndex %>][<%- data.index %>][default_price_scope]" value=
"1" />
79 <input
class=
"input-text required-entry validate-greater-zero-based-on-option validate-zero-or-greater" type=
"text" 80 name=
"<?= /* @escapeNotVerified */ $block->getFieldName() ?>[<%- data.parentIndex %>][<%- data.index %>][selection_qty]" 81 value=
"<%- data.selection_qty %>" />
83 <td
class=
"col-uqty qty-box">
84 <input type=
"checkbox" class=
"is-user-defined-qty" checked=
"checked" />
85 <span style=
"display:none"><?=
$block->getQtyTypeSelectHtml() ?></span>
87 <td
class=
"col-order type-order" style=
"display:none">
88 <input
class=
"input-text required-entry validate-zero-or-greater" type=
"text" 89 name=
"<?= /* @escapeNotVerified */ $block->getFieldName() ?>[<%- data.parentIndex %>][<%- data.index %>][position]" 90 value=
"<%- data.position %>" />
92 <td
class=
"col-actions">
93 <span title=
"Delete Row">
94 <?=
$block->getSelectionDeleteButtonHtml() ?>
103 ],
function(
jQuery, mageTemplate){
104 var bundleTemplateBox =
jQuery(
'#bundle-option-selection-box-template').html(),
105 bundleTemplateRow =
jQuery(
'#bundle-option-selection-row-template').html();
107 Bundle.Selection = Class.create();
108 Bundle.Selection.prototype = {
109 idLabel :
'<?= /* @escapeNotVerified */ $block->getFieldId() ?>',
110 scopePrice : <?= (int)
$block->isUsedWebsitePrice() ?>,
115 gridSelection:
new Hash(),
116 gridRemoval:
new Hash(),
117 gridSelectedProductSkus: [],
118 selectionSearchUrl:
'<?= /* @escapeNotVerified */ $block->getSelectionSearchUrl() ?>',
120 initialize :
function() {
121 this.templateBox =
'<div class="tier form-list" id="' + this.idLabel +
'_box_<%- data.parentIndex %>">' + bundleTemplateBox +
'</div>';
123 this.templateRow =
'<tr class="selection" id="' + this.idLabel +
'_row_<%- data.index %>">' + bundleTemplateRow +
'</tr>';
126 gridUpdateCallback:
function () {
128 var $grid = $(
'table[id^=bundle_selection_search_grid_]:visible');
129 $grid.find(
'.checkbox').prop({checked:
false});
131 var checkRowBySku =
function (sku) {
133 $grid.find(
'.sku').filter(
function () {
134 return $.trim($(
this).text()) == sku;
135 }).closest(
'tr').find(
'.checkbox').prop({checked:
true});
137 $.each(bSelection.gridSelection.values().pop().toArray(),
function () {
138 checkRowBySku(this.pop().
get(
'sku'));
141 $.each(bSelection.gridSelectedProductSkus,
function () {
142 if (!bSelection.gridRemoval.get(
this)) {
149 addRow :
function (parentIndex, data) {
151 if (!(box = $(this.idLabel +
'_box_' + parentIndex))) {
152 this.addBox(parentIndex);
153 box = $(this.idLabel +
'_box_' + parentIndex);
158 var option_type = $(bOption.idLabel +
'_' + parentIndex +
'_type');
164 if (data.can_read_price != undefined && !data.can_read_price) {
165 data.selection_price_value =
'';
167 data.selection_price_value = Number(Math.round(data.selection_price_value +
"e+2") +
"e-2").toFixed(2);
170 data.index = this.itemsCount++;
171 data.parentIndex = parentIndex;
173 if (option_type.value ==
'multi' || option_type.value ==
'checkbox') {
174 data.option_type =
'checkbox';
176 data.option_type =
'radio';
179 if (data.is_default == 1) {
180 data.checked =
'checked="checked"';
183 this.
template = mageTemplate(this.templateRow);
184 var tbody = $$(
'#' + this.idLabel +
'_box_' + parentIndex +
' tbody');
187 var escapedHTML = this.
template({
189 }).replace(/<(\/?)script/g,
'<$1script');
191 Element.insert(tbody[0], {bottom: escapedHTML});
193 if (data.selection_price_type) {
194 $A($(this.idLabel +
'_'+data.index+
'_price_type').options).each(
function(option){
195 if (option.value==data.selection_price_type) option.selected =
true;
199 if (data.selection_price_type) {
200 $A($(this.idLabel +
'_'+data.index+
'_can_change_qty').options).each(
function(option){
201 if (option.value==data.selection_can_change_qty) option.selected =
true;
205 var
checkbox = $(this.idLabel +
'_'+data.index+
'_price_scope');
207 if (data.price_scope === undefined) {
209 }
else if(!data.price_scope) {
215 this.bindScopeCheckbox();
217 if (option_type.value ==
'multi' || option_type.value ==
'checkbox') {
221 inputs = $A($$(
'#' + this.idLabel +
'_box_' + data.parentIndex +
' .qty-box'));
229 if (!$(
'price_type') || $(
'price_type').
value !=
'1') {
233 inputs = $A($$(
'#' + this.idLabel +
'_box_' + data.parentIndex +
' .price-type-box'));
241 jQuery(
'#bundle_option_' + parentIndex +
' .no-products-message').hide();
244 bindScopeCheckbox :
function(){
245 var checkboxes = $$(
'.bundle-option-price-scope-checkbox');
246 for (var i=0;i<checkboxes.length;i++) {
247 if (!$(checkboxes[i]).binded) {
248 $(checkboxes[i]).binded =
true;
249 Event.observe(checkboxes[i],
'click', this.addScope.bind(
this));
254 addScope :
function(event, element){
255 if (element == undefined) {
256 element = $(Event.element(event));
258 var priceValue = $(element.id.sub(
'scope',
'value'));
259 var priceType = $(element.id.sub(
'scope',
'type'));
261 if (element.checked) {
262 priceValue.disable();
270 addBox :
function (parentIndex) {
271 var div = $(bOption.idLabel +
'_' + parentIndex).down(
'.fieldset-alt');
272 this.
template = mageTemplate(this.templateBox);
273 var data = {
'parentIndex' : parentIndex};
274 Element.insert(div, {
275 'after': this.
template({
281 remove :
function(event) {
282 var element = Event.findElement(event,
'tr');
283 var container = Event.findElement(event,
'div');
286 Element.select(element,
'.delete').each(
function(elem){elem.value=
'1'});
287 Element.select(element, [
'input',
'select']).each(
function(elem){elem.hide()});
288 Element.removeClassName(element,
'selection');
289 Element.hide(element);
291 var selection = $$(
'#' + container.id +
' tr.selection');
292 if (container && selection && !selection.length) {
294 jQuery(element).closest(
'.option-box').find(
'.no-products-message').show();
299 checkGroup :
function(event) {
300 var element = Event.element(event);
301 if (element.type ==
'radio') {
302 var box = element.up(
'div');
304 var inputs = $$(
'div#' + box.id +
' input.default');
306 for (i=0; i< inputs.length; i++) {
307 if (inputs[i].
name != element.name) {
308 inputs[i].checked =
false;
315 productGridRowInit :
function(grid, row){
316 var
checkbox = $(row).getElementsByClassName(
'checkbox')[0];
317 var inputs = $(row).getElementsByClassName(
'input-text');
318 for (var i = 0; i < inputs.length; i++) {
323 productGridCheckboxCheck :
function(grid, element, checked) {
324 var
id = element.up(
'table').id.split(
'_')[4];
325 if (element.value > 0) {
326 var tr = element.parentNode.parentNode,
327 sku =
jQuery.trim(tr.select(
'td.sku')[0].innerHTML);
328 if (element.checked) {
329 if (!this.gridSelection.get(
id)) {
330 this.gridSelection.set(
id, $H({}));
332 this.gridSelection.get(
id).set(element.value, $H({}));
333 this.gridSelection.get(
id).get(element.value).set(
'name', tr.select(
'td.name')[0].innerHTML);
334 this.gridSelection.get(
id).get(element.value).set(
'sku', sku);
335 this.gridRemoval.unset(sku);
337 this.gridSelection.get(
id).unset(element.value);
338 this.gridRemoval.set(sku, 1);
343 productGridRowClick :
function(grid, event) {
344 var trElement = Event.findElement(event,
'tr');
345 var isInput = Event.element(event).tagName ==
'INPUT';
347 var
checkbox = Element.select(trElement,
'input');
350 grid.setCheckboxChecked(
checkbox[0], checked);
356 bSelection =
new Bundle.Selection();
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
if( $block->getCanReadPrice() !==false)( 'Price') ?></th >< th class endif
jquery extjs ext tree checkbox
jQuery('.store-switcher .dropdown-menu li a').each(function()