18 <fieldset
class=
"admin__fieldset downloadable-form" data-
ui-
id=
"downloadable-samples">
19 <legend
class=
"admin__legend"><span><?=
__(
'Samples') ?></span></legend><br>
20 <p
class=
"note"><?=
__(
'Add product preview files here.') ?></p>
21 <div
class=
"admin__field"<?= !
$block->isSingleStoreMode() ?
' data-config-scope="' .
__(
'[STORE VIEW]') .
'"' :
'' ?>>
22 <label
class=
"admin__field-label" for=
"downloadable_samples_title"><span><?=
__(
'Title') ?></span></label>
23 <div
class=
"admin__field-control">
24 <input type=
"text" class=
"admin__control-text" id=
"downloadable_samples_title" name=
"product[samples_title]" value=
"<?= $block->escapeHtml($block->getSamplesTitle()) ?>" <?= (
$_product->getStoreId() &&
$block->getUsedDefault()) ?
'disabled="disabled"' :
'' ?>>
26 <div
class=
"admin__field admin__field-option">
27 <input
id=
"sample_title_default" class=
"admin__control-checkbox" type=
"checkbox" name=
"use_default[]" value=
"samples_title" onclick=
"toggleValueElements(this, this.parentNode.parentNode)" <?=
$block->getUsedDefault() ?
'checked="checked"' :
'' ?> />
28 <label
class=
"admin__field-label" for=
"sample_title_default"><span>Use Default Value</span></label>
33 <div
class=
"admin__field admin__field-wide">
34 <div
class=
"admin__field-control">
35 <div
class=
"admin__control-table-wrapper">
36 <table
class=
"admin__control-table">
39 <th
class=
"col-sort"><span><?=
__(
'Sort Order') ?></span></th>
40 <th
class=
"_required col-title"><span><?=
__(
'Title') ?></span></th>
41 <th
class=
"col-file"><span><?=
__(
'Attach File or Enter Link') ?></span></th>
42 <th
class=
"col-actions">&
nbsp;</th>
47 <td colspan=
"4" class=
"col-actions-add"><?=
$block->getAddButtonHtml() ?></td>
50 <tbody
id=
"sample_items_body">
54 <div
class=
"admin__field-note">
55 <?=
__(
'Alphanumeric, dash and underscore characters are recommended for filenames. Improper characters are replaced with \'_\'.') ?>
65 'jquery/file-uploader',
68 ],
function (
jQuery, registry, mageTemplate) {
69 registry.get(
'downloadable',
function (Downloadable) {
70 var sampleTemplate =
'<tr>'+
71 '<td class="col-sort" data-role="draggable-handle">' +
72 '<input data-container="link-order" type="hidden" name="downloadable[sample][<%- data.id %>][sort_order]" value="<%- data.sort_order %>" class="sort" />' +
73 '<span class="draggable-handle" title="<?= /* @escapeNotVerified */ $block->escapeHtml(__('Sort Variations
')) ?>"></span>' +
75 '<td class="col-title">'+
76 '<input type="hidden" class="__delete__" name="downloadable[sample][<%- data.id %>][is_delete]" value="" />'+
77 '<input type="hidden" name="downloadable[sample][<%- data.id %>][sample_id]" value="<%- data.sample_id %>" />'+
78 '<input type="text" class="required-entry input-text admin__control-text" name="downloadable[sample][<%- data.id %>][title]" value="<%- data.title %>" />'+
80 '<div class="admin__field admin__field-option">'+
81 '<input type="checkbox" id="downloadable_sample_<%- data.id %>_title" name="downloadable[sample][<%- data.id %>][use_default_title]" value="1" class="admin__control-checkbox" />'+
82 '<label for="downloadable_link_<%- data.id %>_price" class="admin__field-label"><span><?= /* @escapeNotVerified */ __('Use Default Value
') ?></span></label>'+
86 '<td class="col-file">'+
87 '<div class="admin__field admin__field-option">'+
88 '<input type="radio" class="admin__control-radio validate-one-required-by-name" id="downloadable_sample_<%- data.id %>_file_type" name="downloadable[sample][<%- data.id %>][type]" value="file"<%- data.file_checked %> />' +
89 '<label for="downloadable_sample_<%- data.id %>_file_type" class="admin__field-label"><span><?= /* @escapeNotVerified */ __('File
') ?>:</span></label>'+
90 '<input type="hidden" class="validate-downloadable-file" id="downloadable_sample_<%- data.id %>_file_save" name="downloadable[sample][<%- data.id %>][file]" value="<%- data.file_save %>" />'+
91 '<div id="downloadable_sample_<%- data.id %>_file" class="admin__field-uploader">'+
92 '<div id="downloadable_sample_<%- data.id %>_file-old" class="file-row-info"></div>'+
93 '<div id="downloadable_sample_<%- data.id %>_file-new" class="file-row-info new-file"></div>'+
94 '<div class="fileinput-button">'+
95 '<span><?= /* @noEscape */ __('Browse Files...
') ?></span>' +
96 '<input id="downloadable_sample_<%- data.id %>_file" type="file" name="<?= /* @noEscape */ $block->getConfig()->getFileField() ?>" data-url="<?= $block->escapeHtml($block->getConfig()->getUrl()) ?>">' +
99 'sampleUploader("#downloadable_sample_<%- data.id %>_file"); ' +
105 '<div class="admin__field admin__field-option admin__field-file-url">'+
106 '<input type="radio" class="admin__control-radio validate-one-required-by-name" id="downloadable_sample_<%- data.id %>_url_type" name="downloadable[sample][<%- data.id %>][type]" value="url"<%- data.url_checked %> />' +
107 '<label for="downloadable_sample_<%- data.id %>_url_type" class="admin__field-label"><span><?= /* @escapeNotVerified */ __('URL
') ?></span></label>' +
108 '<input type="text" class="validate-downloadable-url validate-url admin__control-text" name="downloadable[sample][<%- data.id %>][sample_url]" value="<%- data.sample_url %>" placeholder="<?= /* @escapeNotVerified */ __('URL
') ?>" />'+
111 '<span id="downloadable_sample_<%- data.id %>_container"></span>'+
114 '<td class="col-actions">'+
115 '<button type="button" class="action-delete" title="<?= /* @escapeNotVerified */ $block->escapeHtml(__('Delete
')) ?>"><span><?= /* @escapeNotVerified */ __('Delete
') ?></span></button>'+
119 tbody: $(
'sample_items_body'),
120 templateText: sampleTemplate,
122 add:
function(data) {
123 alertAlreadyDisplayed =
false;
124 this.
template = mageTemplate(this.templateText);
126 if(!data.sample_id) {
128 data.sample_type =
'file';
130 data.sort_order = this.itemCount + 1;
133 data.id = this.itemCount;
135 if (data.sample_type ==
'url') {
136 data.url_checked =
' checked="checked"';
137 }
else if (data.sample_type ==
'file') {
138 data.file_checked =
' checked="checked"';
141 Element.insert(this.tbody, {
142 'bottom': this.
template({
147 scopeTitle = $(
'downloadable_sample_'+data.id+
'_title');
149 Event.observe(scopeTitle,
'click',
function(event){
150 scopeElm = $(Event.findElement(event,
'input'));
151 titleField = scopeElm.up(0).down(
'input[type="text"]');
152 if (scopeElm.checked ==
true) {
153 titleField.disabled =
true;
155 titleField.disabled =
false;
159 if (!data.store_title && scopeTitle) {
160 scopeTitle.up(0).down(
'input[type="text"]').disabled =
true;
161 scopeTitle.checked =
true;
164 sampleUrl = $(
'downloadable_sample_'+data.id+
'_url_type');
166 if (!data.file_save) {
169 new Downloadable.FileUploader(
172 sampleUrl.up(
'td').down(
'div.admin__field-uploader'),
173 'downloadable[sample]['+data.id+
']',
175 'downloadable_sample_'+data.id+
'_file',
176 <?=
$block->getConfigJson() ?>
178 sampleUrl.advaiceContainer =
'downloadable_sample_'+data.id+
'_container';
179 sampleFile = $(
'downloadable_sample_'+data.id+
'_file_type');
180 sampleFile.advaiceContainer =
'downloadable_sample_'+data.id+
'_container';
181 $(
'downloadable_sample_'+data.id+
'_file_save').advaiceContainer =
'downloadable_sample_'+data.id+
'_container';
184 this.bindRemoveButtons();
186 sorting:
function () {
187 var list =
jQuery(this.tbody);
190 handle:
'[data-role=draggable-handle]',
192 update:
function (event, data) {
193 list.find(
'[data-container=link-order]').each(
function (i, el) {
200 remove:
function(event) {
201 var element = $(Event.findElement(event,
'tr'));
202 alertAlreadyDisplayed =
false;
204 element.down(
'input[type="hidden"].__delete__').value =
'1';
205 element.addClassName(
'no-display');
206 element.addClassName(
'ignore-validate');
210 bindRemoveButtons:
function() {
211 var buttons = $$(
'tbody#sample_items_body .action-delete');
212 for(var i=0;i<buttons.length;i++){
213 if(!$(buttons[i]).binded){
214 $(buttons[i]).binded =
true;
215 Event.observe(buttons[i],
'click', this.
remove.bind(
this));
221 sampleItems.sorting();
222 sampleItems.bindRemoveButtons();
224 sampleUploader =
function (id) {
228 url:
'<?= /* @noEscape */ $block->getConfig()->getUrl() ?>',
229 sequentialUploads:
true,
230 maxFileSize: 2000000,
231 add:
function (e, data) {
232 var progressTmpl = mageTemplate(
id +
'-template'),
236 $.each(data.files,
function (index, file) {
237 fileSize = typeof file.size ==
"undefined" ?
238 $.mage.__(
'We could not detect a size.') :
239 byteConvert(file.size);
241 data.fileId = Math.random().toString(36).substr(2, 9);
243 tmpl = progressTmpl({
251 $(tmpl).appendTo(
id);
254 $(
this).fileupload(
'process', data).done(
function () {
258 done:
function (e, data) {
259 var progressSelector =
'#' + data.fileId +
' .progressbar-container .progressbar';
260 $(progressSelector).css(
'width',
'100%');
261 if (data.result && !data.result.hasOwnProperty(
'errorcode')) {
262 $(progressSelector).removeClass(
'upload-progress').addClass(
'upload-success');
263 new Downloadable.FileList(
id.substr(1),
null).handleUploadComplete(data.result);
265 $(progressSelector).removeClass(
'upload-progress').addClass(
'upload-failure');
266 var errorMsg =
'<span class="file-info-error">' + data.result.error +
'</span>';
267 $(
'#' + data.fileId +
' .file-info').append(errorMsg);
270 progress:
function (e, data) {
271 var progress = parseInt(data.loaded / data.total * 100, 10);
272 var progressSelector =
'#' + data.fileId +
' .progressbar-container .progressbar';
273 $(progressSelector).css(
'width', progress +
'%');
275 fail:
function (e, data) {
276 var progressSelector =
'#' + data.fileId +
' .progressbar-container .progressbar';
277 $(progressSelector).removeClass(
'upload-progress').addClass(
'upload-failure');
278 if (data.result && data.result.hasOwnProperty(
'errorcode')) {
279 var errorMsg =
'<span class="file-info-error">' + data.result.error +
'</span>';
280 $(
'#' + data.fileId +
' .file-info').append(errorMsg);
287 if($(
'add_sample_item')){
288 Event.observe(
'add_sample_item',
'click', sampleItems.add.bind(sampleItems));
291 <?php
foreach (
$block->getSampleData() as
$item): ?>
292 sampleItems.add(<?=
$item->toJson() ?>);
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
$_count $_index $_prevOptionId if($block->getOrderOptions()|| $_item->getDescription()) foreach( $items as $_item)( $_item) ?><?php $attributes if( $_item->getOrderItem() ->getParentItem())($_prevOptionId !=$attributes['option_id'])</td >< td > & nbsp
if( $_product->getStoreId())(this, this.parentNode.parentNode)" <? endif
jQuery('.store-switcher .dropdown-menu li a').each(function()