11 <script
id=
"bundle-option-template" type=
"text/x-magento-template">
12 <div
id=
"<?= /* @escapeNotVerified */ $block->getFieldId() ?>_<%- data.index %>" class=
"option-box">
13 <div
class=
"fieldset-wrapper admin__collapsible-block-wrapper opened" id=
"<?= /* @escapeNotVerified */ $block->getFieldId() ?>_<%- data.index %>-wrapper">
14 <div
class=
"fieldset-wrapper-title">
15 <strong
class=
"admin__collapsible-title" data-toggle=
"collapse" data-target=
"#<?= /* @escapeNotVerified */ $block->getFieldId() ?>_<%- data.index %>-content">
16 <span><%- data.default_title %></span>
19 <?=
$block->getOptionDeleteButtonHtml() ?>
21 <div data-role=
"draggable-handle" class=
"draggable-handle"></div>
23 <div
class=
"fieldset-wrapper-content in collapse" id=
"<?= /* @escapeNotVerified */ $block->getFieldId() ?>_<%- data.index %>-content">
24 <fieldset
class=
"fieldset">
25 <fieldset
class=
"fieldset-alt">
26 <div
class=
"field field-option-title required">
27 <label
class=
"label" for=
"id_<?= /* @escapeNotVerified */ $block->getFieldName() ?>_<%- data.index %>_title">
28 <?=
__(
'Option Title') ?>
31 <?php
if (
$block->isDefaultStore()): ?>
32 <input
class=
"input-text required-entry" 34 name=
"<?= /* @escapeNotVerified */ $block->getFieldName() ?>[<%- data.index %>][title]" 35 id=
"id_<?= /* @escapeNotVerified */ $block->getFieldName() ?>_<%- data.index %>_title" 36 value=
"<%- data.title %>" 37 data-original-
value=
"<%- data.title %>" />
39 <input
class=
"input-text required-entry" 41 name=
"<?= /* @escapeNotVerified */ $block->getFieldName() ?>[<%- data.index %>][default_title]" 42 id=
"id_<?= /* @escapeNotVerified */ $block->getFieldName() ?>_<%- data.index %>_default_title" 43 value=
"<%- data.default_title %>" 44 data-original-
value=
"<%- data.default_title %>" />
47 id=
"<?= /* @escapeNotVerified */ $block->getFieldId() ?>_id_<%- data.index %>" 48 name=
"<?= /* @escapeNotVerified */ $block->getFieldName() ?>[<%- data.index %>][option_id]" 49 value=
"<%- data.option_id %>" />
51 name=
"<?= /* @escapeNotVerified */ $block->getFieldName() ?>[<%- data.index %>][delete]" 53 data-state=
"deleted" />
56 <?php
if (!
$block->isDefaultStore()): ?>
57 <div
class=
"field field-option-store-view required">
58 <label
class=
"label" for=
"id_<?= /* @escapeNotVerified */ $block->getFieldName() ?>_<%- data.index %>_title_store">
59 <?=
__(
'Store View Title') ?>
62 <input
class=
"input-text required-entry" type=
"text" 63 name=
"<?= /* @escapeNotVerified */ $block->getFieldName() ?>[<%- data.index %>][title]" 64 id=
"id_<?= /* @escapeNotVerified */ $block->getFieldName() ?>_<%- data.index %>_title_store" 65 value=
"<%- data.title %>" />
69 <div
class=
"field field-option-input-type required">
70 <label
class=
"label" for=
"<?= /* @escapeNotVerified */ $block->getFieldId() . '_<%- data.index %>_type' ?>">
71 <?=
__(
'Input Type') ?>
74 <?=
$block->getTypeSelectHtml() ?>
77 <div
class=
"field field-option-req">
79 <input type=
"checkbox" 82 id=
"field-option-req" />
83 <label
for=
"field-option-req">
86 <span style=
"display:none"><?=
$block->getRequireSelectHtml() ?></span>
89 <div
class=
"field field-option-position no-display">
90 <label
class=
"label" for=
"field-option-position">
94 <input
class=
"input-text validate-zero-or-greater" 96 name=
"<?= /* @escapeNotVerified */ $block->getFieldName() ?>[<%- data.index %>][position]" 97 value=
"<%- data.position %>" 98 id=
"field-option-position" />
103 <div
class=
"no-products-message">
104 <?=
__(
'There are no products in this option.') ?>
106 <?=
$block->getAddSelectionButtonHtml() ?>
110 <div
id=
"<?= /* @escapeNotVerified */ $block->getFieldId() ?>_search_<%- data.index %>" class=
"selection-search"></div>
114 <?=
$block->getSelectionHtml() ?>
120 'jquery/jquery.tabs',
122 'Magento_Bundle/js/bundle-product',
124 'mage/adminhtml/form' 125 ],
function(
jQuery, mageTemplate){
127 var optionTemplate =
jQuery(
'#bundle-option-template').html();
129 function changeInputType(oldObject, oType) {
130 var newObject = document.createElement(
'input');
131 newObject.type = oType;
132 if(oldObject.size) newObject.size = oldObject.size;
133 if(oldObject.value) newObject.value = oldObject.value;
134 if(oldObject.name) newObject.name = oldObject.name;
135 if(oldObject.id) newObject.id = oldObject.id;
136 if(oldObject.onclick) newObject.onclick = oldObject.onclick;
137 if(oldObject.className) newObject.className = oldObject.className;
138 oldObject.parentNode.replaceChild(newObject,oldObject);
142 Bundle.Option = Class.create();
143 Bundle.Option.prototype = {
144 idLabel :
'<?= /* @escapeNotVerified */ $block->getFieldId() ?>',
147 initialize :
function(
template) {
148 this.templateText =
template;
151 add :
function(data) {
153 data = <?= $this->helper(
'Magento\Framework\Json\Helper\Data')->jsonEncode([
'default_title' =>
__(
'New Option')]) ?>;
155 data.title = data.title.replace(/</g,
"<");
156 data.title = data.title.replace(/
"/g, "&
quot;
"); 157 data.default_title = data.title; 159 data.index = this.itemsCount++; 161 this.template = mageTemplate(this.templateText); 163 jQuery('#product_bundle_container') 164 .append(this.template({ 168 jQuery('.collapse', jQuery('#product_bundle_container')).collapsable(); 172 $A($(this.idLabel + '_'+data.index+'_type').options).each(function(option){ 173 if (option.value==data.type) option.selected = true; 177 //set selected is_require 179 $A($(this.idLabel + '_'+data.index+'_required').options).each(function(option){ 180 if (option.value==data.required) option.selected = true; 183 // rebind change notifications 184 varienWindowOnload(true); 186 if (jQuery && jQuery('#bundle_product_container').data('bundleProduct')) { 187 jQuery('#bundle_product_container').bundleProduct('refreshSortableElements'); 193 remove : function(event){ 194 var element = Event.findElement(event, 'div').up('.option-box'); 196 var idInput = Element.select(element, '[name$="[option_id]
"]')[0]; 197 if (idInput.value == '') { 200 Element.select(element, '[data-state="deleted
"]').each(function (elem) { 204 Element.select(element, ['input', 'select']).each(function (elem) { 209 Element.hide(element); 214 changeType : function(event) { 215 var element = Event.element(event); 216 parts = element.id.split('_'); 218 if (element.value == 'multi' || element.value == 'checkbox') { 219 inputs = $A($$('#' + bSelection.idLabel + '_box_' + i + ' tr.selection input.default')); 223 changeInputType(elem, 'checkbox'); 229 inputs = $A($$('#' + bSelection.idLabel + '_box_' + i + ' .qty-box')); 237 inputs = $A($$('#' + bSelection.idLabel + '_box_' + i + ' tr.selection input.default')); 239 for (j=0; j< inputs.length; j++) { 240 //inputs[j].type = "radio
"; 241 changeInputType(inputs[j], 'radio'); 242 if (inputs[j].checked && have) { 243 inputs[j].checked = false; 252 inputs = $A($$('#' + bSelection.idLabel + '_box_' + i + ' .qty-box')); 261 priceTypeFixed : function() { 262 inputs = $A($$('.price-type-box')); 270 priceTypeDynamic : function() { 271 inputs = $A($$('.price-type-box')); 281 bOption = new Bundle.Option(optionTemplate); 283 foreach ($block->getOptions() as $_option) { 285 /* @escapeNotVerified */ echo 'optionIndex = bOption.add(', $_option->toJson(), ');', PHP_EOL; 286 if ($_option->getSelections()) { 287 foreach ($_option->getSelections() as $_selection) { 289 $_selection->setName($block->escapeHtml($_selection->getName())); 290 /* @escapeNotVerified */ echo 'bSelection.addRow(optionIndex,', $_selection->toJson(), ');', PHP_EOL; 295 function togglePriceType() { 296 bOption['priceType' + ($('price_type').value == '1' ? 'Fixed' : 'Dynamic')](); 299 jQuery('#bundle_product_container').bundleProduct(); 300 jQuery('#product_bundle_container .collapse').collapse('hide'); 302 jQuery(window).on('load', function() { 304 Event.observe('price_type', 'change', togglePriceType); 309 <script type="text/x-magento-init
"> 312 "Magento_Bundle/js/bundle-type-handler
": {} $block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
if( $block->isDefaultStore())() ?>[<%- data.index %>][title]" id endif
jquery extjs ext tree checkbox
jQuery('.store-switcher .dropdown-menu li a').each(function()