${i18n.t("blocks:resources:panel:drag")}
`;
const panel = $(markup);
panel.find('[data-field="caption"]').val(data.caption);
panel.find('[data-field="link"]').val(data.link);
var context = this;
$('.remove a', panel).on('click', function(e) {
e.preventDefault();
$(this).closest('.field').remove();
context.afterPanelDelete();
});
this.afterPanelRender(data, panel);
return panel;
},
editorHTML: function() {
return `
`
},
altTextHTML: function(index, data) {
const { isDecorative, altText, altTextBackup, placeholderAttr, disabledAttr } = this._altTextData(data);
return `
`
},
zpr_key: 'zpr_link'
});
})();
(function() {
var BLOCK_REPLACER_CONTROL_TEMPLATE = function(block) {
var el = document.createElement('button');
el.className = "st-block-controls__button";
el.setAttribute('data-type', block.type);
el.type = "button";
var img = document.createElement('svg');
img.className = "st-icon";
img.setAttribute('role', 'img');
var use = document.createElement('use');
use.setAttributeNS('https://www.w3.org/1999/xlink', 'href', SirTrevor.config.defaults.iconUrl + "#" + block.icon_name);
img.appendChild(use);
el.appendChild(img);
el.appendChild(document.createTextNode(block.title()));
return el.outerHTML;
};
function generateBlocksHTML(Blocks, availableTypes) {
var groups = {};
for(var i in availableTypes) {
var type = availableTypes[i];
if (Blocks.hasOwnProperty(type) && Blocks[type].prototype.toolbarEnabled) {
var blockGroup;
if ($.isFunction(Blocks[type].prototype.blockGroup)) {
blockGroup = Blocks[type].prototype.blockGroup();
} else {
blockGroup = Blocks[type].prototype.blockGroup;
}
if (blockGroup == 'undefined' || blockGroup === undefined) {
blockGroup = i18n.t("blocks:group:undefined");
}
groups[blockGroup] = groups[blockGroup] || [];
groups[blockGroup].push(BLOCK_REPLACER_CONTROL_TEMPLATE(Blocks[type].prototype));
}
}
function generateBlock(groups, key) {
var group = groups[key];
var groupEl = $("
");
var buttons = group.reduce(function(memo, btn) {
return memo += btn;
}, "");
groupEl.append(buttons);
return groupEl[0].outerHTML;
}
var standardWidgets = generateBlock(groups, i18n.t("blocks:group:undefined"));
var exhibitWidgets = Object.keys(groups).map(function(key) {
if (key !== i18n.t("blocks:group:undefined")) {
return generateBlock(groups, key);
}
}).filter(function (element) {
return element != null;
});
var blocks = [standardWidgets].concat(exhibitWidgets).join("
");
return blocks;
}
function render(Blocks, availableTypes) {
var el = document.createElement('div');
el.className = "st-block-controls__buttons";
el.innerHTML = generateBlocksHTML.apply(null, arguments);
var elButtons = document.createElement('div');
elButtons.className = "spotlight-block-controls";
elButtons.appendChild(el);
return elButtons;
}
Spotlight$1.BlockControls = function() { };
Spotlight$1.BlockControls.create = function(editor) {
// REFACTOR - should probably not know about blockManager
var el = render(SirTrevor.Blocks, editor.blockManager.blockTypes);
function hide() {
var parent = el.parentNode;
if (!parent) { return; }
parent.removeChild(el);
parent.classList.remove("st-block--controls-active");
return parent;
}
function destroy() {
SirTrevor = null;
el = null;
}
function insert(e) {
e.stopPropagation();
var parent = this.parentNode;
if (!parent || hide() === parent) { return; }
$('.st-block__inner', parent).after(el);
parent.classList.add("st-block--controls-active");
}
$(editor.wrapper).delegate(".st-block-replacer", "click", insert);
$(editor.wrapper).delegate(".st-block-controls__button", "click", insert);
return {
el: el,
hide: hide,
destroy: destroy
};
};
})();
Spotlight$1.BlockLimits = function(editor) {
this.editor = editor;
};
Spotlight$1.BlockLimits.prototype.enforceLimits = function(editor) {
this.addEditorCallbacks(editor);
this.checkGlobalBlockTypeLimit()();
};
Spotlight$1.BlockLimits.prototype.addEditorCallbacks = function(editor) {
SirTrevor.EventBus.on('block:create:new', this.checkBlockTypeLimitOnAdd());
SirTrevor.EventBus.on('block:remove', this.checkGlobalBlockTypeLimit());
};
Spotlight$1.BlockLimits.prototype.checkBlockTypeLimitOnAdd = function() {
var editor = this.editor;
return function(block) {
var control = $(".st-block-controls__button[data-type='" + block.type + "']", editor.blockControls.el);
control.prop("disabled", !editor.blockManager.canCreateBlock(block.class()));
};
};
Spotlight$1.BlockLimits.prototype.checkGlobalBlockTypeLimit = function() {
// we don't know what type of block was created or removed.. So, try them all.
var editor = this.editor;
return function() {
$.each(editor.blockManager.blockTypes, function(i, type) {
var block_type = SirTrevor.Blocks[type].prototype;
var control = $(editor.blockControls.el).find(".st-block-controls__button[data-type='" + block_type.type + "']");
control.prop("disabled", !editor.blockManager.canCreateBlock(type));
});
};
};
SirTrevor.Locales.en.blocks = $.extend(SirTrevor.Locales.en.blocks, {
autocompleteable: {
placeholder: "Enter a title..."
},
browse: {
title: "Browse Categories",
description: "This widget highlights browse categories. Each highlighted category links to the corresponding browse category results page.",
item_counts: "Include item counts?"
},
browse_group_categories: {
autocomplete: "Enter a browse group title...",
title: "Browse Group Categories",
description: "This widget displays all browse categories associated with a selected browse group as a horizontally-scrolling row. Each selected browse group is displayed as a separate row. Each displayed category in a group links to the corresponding browse category results page.",
item_counts: "Include category item counts?"
},
link_to_search: {
title: "Saved Searches",
description: "This widget highlights saved searches. Each highlighted saved search links to the search results page generated by the saved search parameters. Any saved search listed on the Curation > Browse categories page, whether published or not, can be highlighted as a saved search.",
item_counts: "Include item counts?"
},
iframe: {
title: "IFrame",
description: "This widget embeds iframe-based embed code into pages",
placeholder: "Enter embed code here. It should begin with e.g. '