this.pageflow = this.pageflow || {}; this.pageflow._editorGlobalInterop = (function (exports, Backbone, _$1, Marionette, $, I18n$1, ChildViewContainer, IScroll, jquery_minicolors, wysihtml5, Cocktail) { 'use strict'; Backbone = Backbone && Backbone.hasOwnProperty('default') ? Backbone['default'] : Backbone; _$1 = _$1 && _$1.hasOwnProperty('default') ? _$1['default'] : _$1; Marionette = Marionette && Marionette.hasOwnProperty('default') ? Marionette['default'] : Marionette; $ = $ && $.hasOwnProperty('default') ? $['default'] : $; I18n$1 = I18n$1 && I18n$1.hasOwnProperty('default') ? I18n$1['default'] : I18n$1; ChildViewContainer = ChildViewContainer && ChildViewContainer.hasOwnProperty('default') ? ChildViewContainer['default'] : ChildViewContainer; IScroll = IScroll && IScroll.hasOwnProperty('default') ? IScroll['default'] : IScroll; wysihtml5 = wysihtml5 && wysihtml5.hasOwnProperty('default') ? wysihtml5['default'] : wysihtml5; Cocktail = Cocktail && Cocktail.hasOwnProperty('default') ? Cocktail['default'] : Cocktail; (function () { var sync = Backbone.sync; Backbone.sync = function (method, model, options) { if (model.paramRoot && !options.attrs) { options.attrs = options.queryParams || {}; options.attrs[model.paramRoot] = model.toJSON(options); } return sync(method, model, options); }; })(); function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /*global JST*/ Marionette.Renderer.render = function (template, data) { if (_$1.isFunction(template)) { return template(data); } if (template.indexOf('templates/') === 0) { template = 'pageflow/editor/' + template; } if (!JST[template]) { throw "Template '" + template + "' not found!"; } return JST[template](data); }; /** * Returns an array of translation keys based on the `prefixes` * option and the given `keyName`. * * @param {string} keyName * Suffix to append to prefixes. * * @param {string[]} [options.prefixes] * Array of translation key prefixes. * * @param {string} [options.fallbackPrefix] * Optional additional prefix to form a model based translation * key of the form * `prefix.fallbackModelI18nKey.propertyName.keyName`. * * @param {string} [options.fallbackModelI18nKey] * Required if `fallbackPrefix` option is present. * * @return {string[]} * @memberof i18nUtils * @since 12.0 */ function attributeTranslationKeys(attributeName, keyName, options) { var result = []; if (options.prefixes) { result = result.concat(_$1(options.prefixes).map(function (prefix) { return prefix + '.' + attributeName + '.' + keyName; }, this)); } if (options && options.fallbackPrefix) { result.push(options.fallbackPrefix + '.' + options.fallbackModelI18nKey + '.' + attributeName); } return result; } /** * Takes the same parameters as {@link * #i18nutilsattributetranslationkeys attributeTranslationKeys}, but returns the first existing * translation. * * @return {string} * @memberof i18nUtils * @since 12.0 */ function attributeTranslation(attributeName, keyName, options) { return findTranslation(attributeTranslationKeys(attributeName, keyName, options)); } /** * Find the first key for which a translation exists and return the * translation. * * @param {string[]} keys * Translation key candidates. * * @param {string} [options.defaultValue] * Value to return if none of the keys has a translation. Is * treated like an HTML translation if html flag is set. * * @param {boolean} [options.html] * If true, also search for keys ending in '_html' and HTML-escape * keys that do not end in 'html' * * @memberof i18nUtils * @return {string} */ function findTranslation(keys, options) { options = options || {}; if (options.html) { keys = translationKeysWithSuffix(keys, 'html'); } return _$1.chain(keys).reverse().reduce(function (result, key) { var unescapedTranslation = I18n$1.t(key, _$1.extend({}, options, { defaultValue: result })); if (!options.html || key.match(/_html$/) || result == unescapedTranslation) { return unescapedTranslation; } else { return $('
').text(unescapedTranslation).html(); } }, options.defaultValue).value(); } /** * Return the first key for which a translation exists. Returns the * first if non of the keys has a translation. * * @param {string[]} keys * Translation key candidates. * * @memberof i18nUtils * @return {string} */ function findKeyWithTranslation(keys) { var missing = '_not_translated'; return _$1(keys).detect(function (key) { return I18n$1.t(key, { defaultValue: missing }) !== missing; }) || _$1.first(keys); } function translationKeysWithSuffix(keys, suffix) { return _$1.chain(keys).map(function (key) { return [key + '_' + suffix, key]; }).flatten().value(); } var i18nUtils = /*#__PURE__*/ Object.freeze({ __proto__: null, attributeTranslationKeys: attributeTranslationKeys, attributeTranslation: attributeTranslation, findTranslation: findTranslation, findKeyWithTranslation: findKeyWithTranslation, translationKeysWithSuffix: translationKeysWithSuffix }); function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } /** * Create object that can be passed to Marionette ui property from CSS * module object. * * @param {Object} styles * Class name mapping imported from `.module.css` file. * * @param {...string} classNames * Keys from the styles object that shall be used in the ui object. * * @return {Object} * * @example * * // MyView.module.css * * .container {} * * // MyView.js * * import Marionette from 'marionette'; * import {cssModulesUtils} from 'pageflow/ui'; * * import styles from './MyView.module.css'; * * export const MyView = Marionette.ItemView({ * template: () => ` * * `, * * ui: cssModulesUtils.ui(styles, 'container'), * * onRender() { * this.ui.container // => JQuery wrapper for container element * } * }); * * @memberof cssModulesUtils */ function ui(styles) { for (var _len = arguments.length, classNames = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { classNames[_key - 1] = arguments[_key]; } return classNames.reduce(function (result, className) { result[className] = selector(styles, className); return result; }, {}); } /** * Create object that can be passed to Marionette events property from CSS * module object. * * @param {Object} styles * Class name mapping imported from `.module.css` file. * * @param {Object} mapping * Events mapping using keys from the `styles` instead of CSS class names. * * @return {Object} * * @example * * // MyView.module.css * * .addButton {} * * // MyView.js * * import Marionette from 'marionette'; * import {cssModulesUtils} from 'pageflow/ui'; * * import styles from './MyView.module.css'; * * export const MyView = Marionette.ItemView({ * template: () => ` * * `, * * events: cssModulesUtils.ui(styles, { * 'click addButton': () => console.log('clicked add button'); * }) * }); * * @memberof cssModulesUtils */ function events(styles, mapping) { return Object.keys(mapping).reduce(function (result, key) { var _key$split = key.split(' '), _key$split2 = _slicedToArray(_key$split, 2), event = _key$split2[0], className = _key$split2[1]; result["".concat(event, " ").concat(selector(styles, className))] = mapping[key]; return result; }, {}); } /** * Generates a CSS selector from a CSS module rule. * * @param {Object} styles * Class name mapping imported from `.module.css` file. * * @param {String} className * Key from the `styles` object. * * @return {String} CSS Selector * @memberof cssModulesUtils */ function selector(styles, className) { var classNames = styles[className]; if (!classNames) { throw new Error("Unknown class name ".concat(className, " in mapping. Knwon names: ").concat(Object.keys(styles).join(', '), ".")); } return ".".concat(classNames.replace(/ /g, '.')); } var cssModulesUtils = /*#__PURE__*/ Object.freeze({ __proto__: null, ui: ui, events: events, selector: selector }); // https://github.com/jashkenas/backbone/issues/2601 function BaseObject(options) { this.initialize.apply(this, arguments); } _$1.extend(BaseObject.prototype, Backbone.Events, { initialize: function initialize(options) {} }); // The self-propagating extend function that Backbone classes use. BaseObject.extend = Backbone.Model.extend; var CollectionView = Marionette.View.extend({ initialize: function initialize() { this.rendered = false; this.itemViews = new ChildViewContainer(); this.collection.map(this.addItem, this); this.listenTo(this.collection, 'add', this.addItem); this.listenTo(this.collection, 'remove', this.removeItem); this.listenTo(this.collection, 'sort', this.sort); if (this.options.loadingViewConstructor) { this.listenTo(this.collection, 'request', function () { this.loading = true; this.togglePlaceHolder(); }); this.listenTo(this.collection, 'sync', function () { this.loading = false; this.togglePlaceHolder(); }); } }, render: function render() { if (!this.rendered) { this.$el.append(this.itemViews.map(function (itemView) { itemView.$el.data('view', itemView); return itemView.render().el; })); this.togglePlaceHolder(); this.rendered = true; } return this; }, onClose: function onClose() { this.itemViews.call('close'); this.closePlaceHolderView(); }, addItem: function addItem(item) { var view = new this.options.itemViewConstructor(_$1.extend({ model: item }, this.getItemViewOptions(item))); this.itemViews.add(view); if (this.rendered) { var index = this.collection.indexOf(item); view.render(); view.$el.data('view', view); if (index > 0) { this.$el.children().eq(index - 1).after(view.el); } else { this.$el.prepend(view.el); } this.togglePlaceHolder(); } }, removeItem: function removeItem(item) { var view = this.itemViews.findByModel(item); if (view) { this.itemViews.remove(view); view.close(); this.togglePlaceHolder(); } }, sort: function sort() { var last = null; this.collection.each(function (item) { var itemView = this.itemViews.findByModel(item); var element; if (!itemView) { return; } element = itemView.$el; if (last) { last.after(element); } else { this.$el.prepend(element); } last = element; }, this); }, getItemViewOptions: function getItemViewOptions(item) { if (typeof this.options.itemViewOptions === 'function') { return this.options.itemViewOptions(item); } else { return this.options.itemViewOptions || {}; } }, closePlaceHolderView: function closePlaceHolderView() { if (this.placeHolderView) { this.placeHolderView.close(); this.placeHolderView = null; } }, togglePlaceHolder: function togglePlaceHolder() { var lastPlaceholderConstructor = this.placeHolderConstructor; this.placeHolderConstructor = this.getPlaceHolderConstructor(); if (this.itemViews.length || !this.placeHolderConstructor) { this.closePlaceHolderView(); } else if (!this.placeHolderView || lastPlaceholderConstructor !== this.placeHolderConstructor) { this.closePlaceHolderView(); this.placeHolderView = new this.placeHolderConstructor(); this.$el.append(this.placeHolderView.render().el); } }, getPlaceHolderConstructor: function getPlaceHolderConstructor() { if (this.loading && this.options.loadingViewConstructor) { return this.options.loadingViewConstructor; } else if (this.options.blankSlateViewConstructor) { return this.options.blankSlateViewConstructor; } } }); var SortableCollectionView = CollectionView.extend({ render: function render() { CollectionView.prototype.render.call(this); this.$el.sortable({ connectWith: this.options.connectWith, placeholder: 'sortable-placeholder', forcePlaceholderSize: true, delay: 200, update: _$1.bind(function (event, ui) { if (ui.item.parent().is(this.el)) { this.updateOrder(); } }, this), receive: _$1.bind(function (event, ui) { var view = ui.item.data('view'); this.reindexPositions(); this.itemViews.add(view); this.collection.add(view.model); }, this), remove: _$1.bind(function (event, ui) { var view = ui.item.data('view'); this.itemViews.remove(view); this.collection.remove(view.model); }, this) }); return this; }, addItem: function addItem(item) { if (!this.itemViews.findByModel(item)) { CollectionView.prototype.addItem.call(this, item); } }, removeItem: function removeItem(item) { if (this.itemViews.findByModel(item)) { CollectionView.prototype.removeItem.call(this, item); } }, updateOrder: function updateOrder() { this.reindexPositions(); this.collection.sort(); this.collection.saveOrder(); }, reindexPositions: function reindexPositions() { this.$el.children().each(function (index) { $(this).data('view').model.set('position', index); }); } }); var ConfigurationEditorTabView = Marionette.View.extend({ className: 'configuration_editor_tab', initialize: function initialize() { this.inputs = new ChildViewContainer(); this.groups = this.options.groups || ConfigurationEditorTabView.groups; }, input: function input(propertyName, view, options) { this.view(view, _$1.extend({ placeholderModel: this.options.placeholderModel, propertyName: propertyName, attributeTranslationKeyPrefixes: this.options.attributeTranslationKeyPrefixes }, options || {})); }, view: function view(_view, options) { this.inputs.add(new _view(_$1.extend({ model: this.model, parentTab: this.options.tab }, options || {}))); }, group: function group(name, options) { this.groups.apply(name, this, options); }, render: function render() { this.inputs.each(function (input) { this.$el.append(input.render().el); }, this); return this; }, onClose: function onClose() { if (this.inputs) { this.inputs.call('close'); } } }); ConfigurationEditorTabView.Groups = function () { var groups = {}; this.define = function (name, fn) { if (typeof fn !== 'function') { throw 'Group has to be function.'; } groups[name] = fn; }; this.apply = function (name, context, options) { if (!(name in groups)) { throw 'Undefined group named "' + name + '".'; } groups[name].call(context, options || {}); }; }; ConfigurationEditorTabView.groups = new ConfigurationEditorTabView.Groups(); function template(data) { var __p = ''; __p += '', { text: item.label, "class": 'item-text' }).appendTo(container); $('
', {
text: options.descriptions[index],
"class": 'item-description'
}).appendTo(container);
if (options.helpLinkClicked) {
$('', {
href: '#',
title: I18n$1.t('pageflow.ui.views.extended_select_input_view.display_help')
}).on('click', function () {
widget.close();
options.helpLinkClicked(item.value);
return false;
}).appendTo(li);
}
return li.appendTo(ul);
},
_resizeMenu: function _resizeMenu() {
this.menuWrap.addClass('extended_select_input_menu');
var menuHeight = this.menu.height(),
menuOffset = this.button.offset().top + this.button.outerHeight(),
bodyHeight = $('body').height();
if (menuHeight + menuOffset > bodyHeight) {
this.menuWrap.outerHeight(bodyHeight - menuOffset - 5).css({
'overflow-y': 'scroll'
});
} else {
this.menuWrap.css({
height: 'initial',
'overflow-y': 'initial'
});
}
}
});
this.ui.select.extendedselectmenu({
select: view.select.bind(view),
width: '100%',
position: {
my: 'right top',
at: 'right bottom'
}
});
},
select: function select(event, ui) {
this.ui.select.val(ui.item.value);
this.save();
}
});
function template$8(data) {
var __t,
__p = '';
__p += '\n\n\n\n\n \n ' +
((__t = ( I18n.t('pageflow.editor.templates.confirm_encoding.all_released') )) == null ? '' : __t) +
'\n \n ' +
((__t = ( I18n.t('pageflow.editor.templates.confirm_encoding.link_to_progress', {
link: ''+I18n.t('pageflow.editor.templates.confirm_encoding.manage_files')+''})
)) == null ? '' : __t) +
'\n ' +
((__t = ( I18n.t('pageflow.editor.templates.edit_chapter.save_error') )) == null ? '' : __t) +
' ' +
((__t = ( I18n.t('pageflow.editor.templates.background_positioning.help') )) == null ? '' : __t) +
' ' +
((__t = ( I18n.t('pageflow.editor.templates.edit_meta_data.save_error') )) == null ? '' : __t) +
' ' +
((__t = ( I18n.t('pageflow.editor.templates.edit_page.save_error') )) == null ? '' : __t) +
' ' +
((__t = ( I18n.t('pageflow.editor.templates.edit_storyline.save_error') )) == null ? '' : __t) +
' ' +
((__t = ( I18n.t('pageflow.editor.templates.confirm_upload.hint') )) == null ? '' : __t) +
' ' +
((__t = ( I18n.t('pageflow.editor.templates.publish_entry.files_pending_notice') )) == null ? '' : __t) +
' ' +
((__t = ( I18n.t('pageflow.editor.templates.publish_entry.published_notice') )) == null ? '' : __t) +
' \n ' +
((__t = ( I18n.t('pageflow.editor.templates.publish_entry.already_published_with_password_help') )) == null ? '' : __t) +
'\n \n ' +
((__t = ( I18n.t('pageflow.editor.templates.publish_entry.previously_published_with_password_help') )) == null ? '' : __t) +
'\n \n ' +
((__t = ( I18n.t('pageflow.editor.templates.publish_entry.already_published_without_password_help') )) == null ? '' : __t) +
'\n ' +
((__t = ( I18n.t('pageflow.editor.templates.publish_entry.publish_success') )) == null ? '' : __t) +
' ' +
((__t = ( I18n.t('pageflow.editor.templates.publish_entry.published_url_hint') )) == null ? '' : __t) +
' ' +
((__t = ( I18n.t('pageflow.editor.templates.locked.loading') )) == null ? '' : __t) +
' ").concat(t('save_error'), "' +
((__t = ( I18n.t('pageflow.editor.templates.confirm_encoding.videos_tab') )) == null ? '' : __t) +
'
\n' +
((__t = ( I18n.t('pageflow.editor.templates.confirm_encoding.audios_tab') )) == null ? '' : __t) +
'
\n' +
((__t = ( I18n.t('pageflow.editor.templates.background_positioning.title') )) == null ? '' : __t) +
'
\n ' +
((__t = ( I18n.t('pageflow.editor.templates.background_positioning.preview_title') )) == null ? '' : __t) +
'
\n ' +
((__t = ( I18n.t('pageflow.editor.templates.change_theme_dialog.header') )) == null ? '' : __t) +
'
\n ' +
((__t = ( I18n.t('pageflow.editor.templates.change_theme_dialog.preview_header_prefix') )) == null ? '' : __t) +
'\n ' +
((__t = ( I18n.t('pageflow.editor.templates.change_theme_dialog.preview_header_suffix') )) == null ? '' : __t) +
'\n
\n ' +
((__t = ( I18n.t('pageflow.editor.templates.files_explorer.reuse_files') )) == null ? '' : __t) +
'
\n\n \n
\n\n \n ';
return __p
}
var FileMetaDataItemView = Marionette.ItemView.extend({
tagName: 'tr',
template: template$J,
ui: {
label: 'th',
value: 'td'
},
onRender: function onRender() {
this.subview(new this.options.valueView(_$1.extend({
el: this.ui.value,
model: this.model,
name: this.options.name
}, this.options.valueViewOptions || {})));
this.ui.label.text(this.labelText());
},
labelText: function labelText() {
return i18nUtils.attributeTranslation(this.options.name, 'label', {
prefixes: ['pageflow.editor.files.attributes.' + this.model.fileType().collectionName, 'pageflow.editor.files.common_attributes'],
fallbackPrefix: 'activerecord.attributes',
fallbackModelI18nKey: this.model.i18nKey
});
}
});
function template$K(data) {
var __p = '';
__p += '\n\n';
return __p
}
var FileStageItemView = Marionette.ItemView.extend({
tagName: 'li',
className: 'file_stage_item',
template: template$K,
ui: {
description: '.description',
percent: '.percent',
errorMessage: '.error_message'
},
modelEvents: {
'change': 'update'
},
onRender: function onRender() {
this.update();
this.$el.addClass(this.model.get('name'));
if (this.options.standAlone) {
this.$el.addClass('stand_alone');
} else {
this.$el.addClass('indented');
}
},
update: function update() {
this.ui.description.text(this.model.localizedDescription());
if (typeof this.model.get('progress') === 'number' && this.model.get('active')) {
this.ui.percent.text(this.model.get('progress') + '%');
} else {
this.ui.percent.text('');
}
this.ui.errorMessage.toggle(!!this.model.get('error_message')).text(this._translatedErrorMessage());
this.$el.toggleClass('active', this.model.get('active'));
this.$el.toggleClass('finished', this.model.get('finished'));
this.$el.toggleClass('failed', this.model.get('failed'));
this.$el.toggleClass('action_required', this.model.get('action_required'));
},
_translatedErrorMessage: function _translatedErrorMessage() {
return this.model.get('error_message') && I18n$1.t(this.model.get('error_message'), {
defaultValue: this.model.get('error_message')
});
}
});
function template$L(data) {
var __t, __p = '';
__p += '\n\n\n' +
((__t = ( I18n.t('pageflow.editor.templates.file_item.select') )) == null ? '' : __t) +
'\n\n\n\n \n\n \n
' +
((__t = ( I18n.t('pageflow.editor.views.files_view.importer.heading') )) == null ? '' : __t) +
'
\n\n \n
\n ' +
((__t = ( I18n.t('pageflow.editor.file_importers.'+data.importerKey+'.dialog_label') )) == null ? '' : __t) +
'
\n\n ' +
((__t = ( I18n.t('pageflow.editor.templates.confirm_upload.header') )) == null ? '' : __t) +
'
\n ' +
((__t = ( I18n.t('pageflow.editor.templates.confirm_upload.edit_file_header') )) == null ? '' : __t) +
'
\n ' +
((__t = ( I18n.t('pageflow.editor.templates.publish_entry.publish_current') )) == null ? '' : __t) +
'
\n\n ' +
((__t = ( I18n.t('pageflow.editor.templates.help.title') )) == null ? '' : __t) +
'
\n\n \n\n \n\n\n' +
((__t = ( I18n.t('pageflow.editor.templates.page_links.add') )) == null ? '' : __t) +
'\n';
return __p
}
var PageLinksView = Marionette.ItemView.extend({
template: template$Y,
className: 'page_links',
ui: {
links: 'ul.links',
addButton: '.add_link'
},
events: {
'click .add_link': function clickAdd_link() {
var view = this;
editor$1.selectPage().then(function (page) {
view.model.pageLinks().addLink(page.get('perma_id'));
});
return false;
}
},
onRender: function onRender() {
var pageLinks = this.model.pageLinks();
var collectionViewConstructor = pageLinks.saveOrder ? SortableCollectionView : CollectionView;
this.subview(new collectionViewConstructor({
el: this.ui.links,
collection: pageLinks,
itemViewConstructor: PageLinkItemView,
itemViewOptions: {
pageLinks: pageLinks
}
}));
this.listenTo(pageLinks, 'add remove', function () {
this.updateAddButton(pageLinks);
});
this.updateAddButton(pageLinks);
},
updateAddButton: function updateAddButton(pageLinks) {
this.ui.addButton.css('display', pageLinks.canAddLink() ? 'inline-block' : 'none');
}
});
function template$Z(data) {
var __t, __p = '';
__p += ' \n \n \n';
return __p
}
var EmulationModeButtonView = Marionette.ItemView.extend({
template: template$Z,
className: 'emulation_mode_button',
ui: {
phoneItem: '.emulation_mode_button-phone',
desktopItem: '.emulation_mode_button-desktop',
phoneDisplay: '.emulation_mode_button-display.emulation_mode_button-phone',
desktopDisplay: '.emulation_mode_button-display.emulation_mode_button-desktop'
},
events: {
'click .emulation_mode_button-desktop a': function clickEmulation_mode_buttonDesktopA() {
this.model.unset('emulation_mode');
},
'click .emulation_mode_button-phone a': function clickEmulation_mode_buttonPhoneA() {
if (!this.model.get('current_page_supports_emulation_mode')) {
return;
}
this.model.set('emulation_mode', 'phone');
}
},
modelEvents: {
'change:emulation_mode change:current_page_supports_emulation_mode': 'update'
},
onRender: function onRender() {
this.update();
},
update: function update() {
this.ui.phoneItem.toggleClass('disabled', !this.model.get('current_page_supports_emulation_mode'));
this.ui.phoneItem.toggleClass('active', this.model.has('emulation_mode'));
this.ui.desktopItem.toggleClass('active', !this.model.has('emulation_mode'));
this.ui.phoneDisplay.toggleClass('active', this.model.has('emulation_mode'));
this.ui.desktopDisplay.toggleClass('active', !this.model.has('emulation_mode'));
}
});
function template$_(data) {
var __t, __p = '';
__p +=
((__t = ( I18n.t('pageflow.editor.templates.help_button.open_help') )) == null ? '' : __t);
return __p
}
var HelpButtonView = Marionette.ItemView.extend({
template: template$_,
className: 'help_button',
events: {
'click': function click() {
app.trigger('toggle-help');
}
}
});
var SidebarFooterView = Marionette.View.extend({
className: 'sidebar_footer',
render: function render() {
if (pageflow.features.isEnabled('editor_emulation_mode')) {
this.appendSubview(new EmulationModeButtonView({
model: this.model
}));
}
this.appendSubview(new HelpButtonView());
return this;
}
});
var HelpImageView = Marionette.View.extend({
tagName: 'img',
className: 'help_image',
render: function render() {
this.$el.attr('src', state.editorAssetUrls.help[this.options.imageName]);
return this;
}
});
var InfoBoxView = Marionette.View.extend({
className: 'info_box',
render: function render() {
this.$el.html(this.options.text);
return this;
}
});
function template$$(data) {
var __t, __p = '';
__p += '\n\n\n\n\n\n\n \n';
return __p
}
var ListItemView = Marionette.ItemView.extend({
template: template$$,
tagName: 'li',
className: 'list_item',
ui: {
thumbnail: '.list_item_thumbnail',
typePictogram: '.list_item_type_pictogram',
title: '.list_item_title',
description: '.list_item_description',
editButton: '.list_item_edit_button',
removeButton: '.list_item_remove_button'
},
events: {
'click .list_item_edit_button': function clickList_item_edit_button() {
this.options.onEdit(this.model);
return false;
},
'click .list_item_remove_button': function clickList_item_remove_button() {
this.options.onRemove(this.model);
return false;
},
'mouseenter': function mouseenter() {
if (this.options.highlight) {
this.model.highlight();
}
},
'mouseleave': function mouseleave() {
if (this.options.highlight) {
this.model.resetHighlight();
}
}
},
modelEvents: {
'change': 'update'
},
onRender: function onRender() {
this.subview(new ModelThumbnailView({
el: this.ui.thumbnail,
model: this.model
}));
if (this.options.typeName) {
this.$el.addClass(this.typeName());
}
this.ui.editButton.toggleClass('is_available', !!this.options.onEdit);
this.ui.removeButton.toggleClass('is_available', !!this.options.onRemove);
this.update();
},
update: function update() {
this.ui.typePictogram.attr('title', this.typeDescription());
this.ui.title.text(this.model.title() || I18n$1.t('pageflow.editor.views.page_link_item_view.unnamed'));
this.ui.description.text(this.description());
this.ui.description.toggle(!!this.description());
this.$el.toggleClass('is_invalid', !!this.getOptionResult('isInvalid'));
},
onClose: function onClose() {
if (this.options.highlight) {
this.model.resetHighlight();
}
},
description: function description() {
return this.getOptionResult('description');
},
typeName: function typeName() {
return this.getOptionResult('typeName');
},
typeDescription: function typeDescription() {
return this.getOptionResult('typeDescription');
},
getOptionResult: function getOptionResult(name) {
return typeof this.options[name] === 'function' ? this.options[name](this.model) : this.options[name];
}
});
function template$10(data) {
var __t, __p = '';
__p += '
' +
((__t = ( I18n.t('pageflow.editor.templates.text_tracks.edit_file_header') )) == null ? '' : __t) +
'
\n \n';
return __p
}
function blankSlateTemplate$2(data) {
var __t, __p = '';
__p +=
((__t = ( I18n.t('pageflow.editor.templates.list_blank_slate.text') )) == null ? '' : __t) +
'\n';
return __p
}
/**
* A generic list view with items consisting of a thumbnail, text and
* possibly some buttons or a navigation arrow.
*
* Models inside the collection must implement the following methods:
*
* @param {Backbone.Collection} options.collection
*
* @param {Object} options
*
* @param {string} options.label
* Text of the label to display above the list.
*
* @param {boolean} [options.highlight=false]
*
* @param {boolean} [options.sortable=false]
*
* @param {string|function} [options.itemDescription]
*
* @param {string|function} [options.itemTypeName]
*
* @param {string|function} [options.itemTypeDescription]
*
* @param {string|function} [options.itemIsInvalid]
*
* @param {function} [options.onEdit]
*
* @param {function} [options.onRemove]
*
* @class
*/
var ListView = Marionette.ItemView.extend({
template: template$14,
className: 'list',
ui: {
label: '.list_label',
items: '.list_items'
},
onRender: function onRender() {
var collectionViewConstructor = this.options.sortable ? SortableCollectionView : CollectionView;
this.subview(new collectionViewConstructor({
el: this.ui.items,
collection: this.collection,
itemViewConstructor: ListItemView,
itemViewOptions: _$1.extend({
description: this.options.itemDescription,
typeName: this.options.itemTypeName,
typeDescription: this.options.itemTypeDescription,
isInvalid: this.options.itemIsInvalid
}, _$1(this.options).pick('onEdit', 'onDelete', 'highlight')),
blankSlateViewConstructor: Marionette.ItemView.extend({
tagName: 'li',
className: 'list_blank_slate',
template: blankSlateTemplate$2
})
}));
this.ui.label.text(this.options.label);
this.$el.toggleClass('with_type_pictogram', !!this.options.itemTypeName);
}
});
var ConfirmUploadView = Marionette.Layout.extend({
template: template$Q,
className: 'confirm_upload editor dialog',
mixins: [dialogView],
regions: {
selectedFileRegion: '.selected_file_region'
},
ui: {
filesPanel: '.files_panel'
},
events: {
'click .upload': function clickUpload() {
this.options.fileUploader.submit();
this.close();
}
},
initialize: function initialize() {
this.selection = new Backbone.Model();
this.listenTo(this.selection, 'change', this.update);
},
onRender: function onRender() {
this.options.fileTypes.each(function (fileType) {
this.ui.filesPanel.append(this.subview(new UploadableFilesView({
collection: this.options.files[fileType.collectionName],
fileType: fileType,
selection: this.selection
})).el);
}, this);
this.update();
},
onClose: function onClose() {
this.options.fileUploader.abort();
},
update: function update() {
var file = this.selection.get('file');
if (file) {
this.selectedFileRegion.show(new EditFileView({
model: file
}));
} else {
this.selectedFileRegion.close();
}
}
});
ConfirmUploadView.watch = function (fileUploader, fileTypes, files) {
fileUploader.on('new:batch', function () {
ConfirmUploadView.open({
fileUploader: fileUploader,
fileTypes: fileTypes,
files: files
});
});
};
ConfirmUploadView.open = function (options) {
app.dialogRegion.show(new ConfirmUploadView(options));
};
/**
* Base view to edit configuration container models. Extend and
* override the `configure` method which receives a {@link
* ConfigurationEditorView} to define the tabs and inputs that shall
* be displayed.
*
* Add a `translationKeyPrefix` property to the prototype and define
* the following translations:
*
* * `