var pageflow_paged = (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; /*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 }); /** * 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] = ".".concat(styles[className]); return result; }, {}); } var cssModulesUtils = /*#__PURE__*/ Object.freeze({ __proto__: null, ui: ui }); // 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.show_files')) == 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) + ' ' +
((__t = ( I18n.t('pageflow.editor.blank_entry.intro') )) == null ? '' : __t) +
' ' +
((__t = ( I18n.t('pageflow.editor.blank_entry.outro') )) == null ? '' : __t) +
'' + ((__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').attr('src', file.getBackgroundPositioningImageUrl());
this.ui.container.append(image);
this.ui.sliderVertical.slider({
orientation: 'vertical',
change: function change(event, ui) {
view.save('y', 100 - ui.value);
},
slide: function slide(event, ui) {
view.save('y', 100 - ui.value);
}
});
this.ui.sliderHorizontal.slider({
orientation: 'horizontal',
change: function change(event, ui) {
view.save('x', ui.value);
},
slide: function slide(event, ui) {
view.save('x', ui.value);
}
});
this.ui.inputVertical.on('change', function () {
view.save('y', $(this).val());
});
this.ui.inputHorizontal.on('change', function () {
view.save('x', $(this).val());
});
this.update();
},
update: function update() {
var x = this.model.getFilePosition(this.options.propertyName, 'x');
var y = this.model.getFilePosition(this.options.propertyName, 'y');
this.ui.sliderVertical.slider('value', 100 - y);
this.ui.sliderHorizontal.slider('value', x);
this.ui.inputVertical.val(y);
this.ui.inputHorizontal.val(x);
},
saveFromEvent: function saveFromEvent(event) {
var x = event.pageX - this.ui.container.offset().left;
var y = event.pageY - this.ui.container.offset().top;
this.save('x', Math.round(x / this.ui.container.width() * 100));
this.save('y', Math.round(y / this.ui.container.width() * 100));
},
save: function save(coord, value) {
this.model.setFilePosition(this.options.propertyName, coord, Math.min(100, Math.max(0, value)));
}
});
function template$c$1(data) {
var __t,
__p = '';
__p += '
' + ((__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 \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$v,
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$w(data) {
var __p = '';
__p += '\n\n';
return __p;
}
var FileStageItemView = Marionette.ItemView.extend({
tagName: 'li',
className: 'file_stage_item',
template: template$w,
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$x(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$K,
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$L(data) {
var __t,
__p = '';
__p += ' \n \n \n';
return __p;
}
var EmulationModeButtonView = Marionette.ItemView.extend({
template: template$L,
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$M(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$M,
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$N(data) {
var __t,
__p = '';
__p += '\n\n\n\n\n\n\n \n';
return __p;
}
var ListItemView = Marionette.ItemView.extend({
template: template$N,
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$O(data) {
var __t,
__p = '';
__p += '
' + ((__t = I18n.t('pageflow.editor.templates.text_tracks.edit_file_header')) == null ? '' : __t) + '
\n \n';
return __p;
}
function blankSlateTemplate$1$1(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$S,
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$1$1
})
}));
this.ui.label.text(this.options.label);
this.$el.toggleClass('with_type_pictogram', !!this.options.itemTypeName);
}
});
var ConfirmUploadView = Marionette.Layout.extend({
template: template$C,
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));
};
ConfigurationEditorView.register('audio', {
configure: function configure() {
this.tab('general', function () {
this.group('general', {
supportsTextPositionCenter: true
});
this.input('additional_title', TextInputView);
this.input('additional_description', TextAreaInputView, {
size: 'short'
});
});
this.tab('files', function () {
this.input('audio_file_id', FileInputView, {
collection: state.audioFiles,
defaultTextTrackFilePropertyName: 'default_text_track_file_id'
});
this.group('background');
this.input('thumbnail_image_id', FileInputView, {
collection: state.imageFiles,
positioning: false
});
});
this.tab('options', function () {
if (pageflow.features.isEnabled('waveform_player_controls')) {
this.input('audio_player_controls_variant', SelectInputView, {
values: ['default', 'waveform']
});
}
this.input('waveform_color', ColorInputView, {
visibleBinding: 'audio_player_controls_variant',
visibleBindingValue: 'waveform',
defaultValue: pageflow.theme.mainColor(),
swatches: usedWaveformColors()
});
this.input('autoplay', CheckBoxInputView);
this.group('options', {
canPauseAtmo: true
});
});
function usedWaveformColors() {
return _$1.chain(state.pages.map(function (page) {
return page.configuration.get('waveform_color');
})).uniq().compact().value();
}
}
});
ConfigurationEditorView.register('background_image', {
configure: function configure() {
this.tab('general', function () {
this.group('general', {
supportsTextPositionCenter: true
});
});
this.tab('files', function () {
this.group('background');
this.input('thumbnail_image_id', FileInputView, {
collection: state.imageFiles,
positioning: false
});
});
this.tab('options', function () {
this.group('options');
});
}
});
ConfigurationEditorView.register('video', {
configure: function configure() {
this.tab('general', function () {
this.group('general', {
supportsTextPositionCenter: true
});
this.input('additional_title', TextInputView);
this.input('additional_description', TextAreaInputView, {
size: 'short'
});
});
this.tab('files', function () {
this.input('video_file_id', FileInputView, {
collection: state.videoFiles,
positioning: false,
defaultTextTrackFilePropertyName: 'default_text_track_file_id'
});
this.input('poster_image_id', FileInputView, {
collection: state.imageFiles,
positioning: false
});
this.input('mobile_poster_image_id', FileInputView, {
collection: state.imageFiles,
positioning: true
});
this.input('thumbnail_image_id', FileInputView, {
collection: state.imageFiles,
positioning: false
});
});
this.tab('options', function () {
this.input('autoplay', CheckBoxInputView);
if (pageflow.features.isEnabled('auto_change_page')) {
this.input('auto_change_page_on_ended', CheckBoxInputView);
}
this.group('options', {
canPauseAtmo: true
});
});
}
});
ConfigurationEditorTabView.groups.define('background', function (options) {
options = options || {};
var prefix = options.propertyNamePrefix ? options.propertyNamePrefix + '_' : '';
var backgroundTypeProperty = prefix + 'background_type';
this.input(backgroundTypeProperty, SelectInputView, {
values: ['image', 'video'],
ensureValueDefined: true
});
this.input(prefix + 'background_image_id', FileInputView, {
collection: state.imageFiles,
visibleBinding: backgroundTypeProperty,
visibleBindingValue: 'image',
fileSelectionHandlerOptions: options
});
this.input(prefix + 'video_file_id', FileInputView, {
collection: state.videoFiles,
visibleBinding: backgroundTypeProperty,
visibleBindingValue: 'video',
fileSelectionHandlerOptions: options
});
this.input(prefix + 'poster_image_id', FileInputView, {
collection: state.imageFiles,
visibleBinding: backgroundTypeProperty,
visibleBindingValue: 'video',
fileSelectionHandlerOptions: options
});
this.input(prefix + 'mobile_poster_image_id', FileInputView, {
collection: state.imageFiles,
visibleBinding: backgroundTypeProperty,
visibleBindingValue: 'video',
fileSelectionHandlerOptions: options
});
});
ConfigurationEditorTabView.groups.define('general', function (options) {
this.input('title', TextInputView, {
required: true,
maxLength: 5000
});
this.input('hide_title', CheckBoxInputView);
this.input('tagline', TextInputView, {
maxLength: 5000
});
this.input('subtitle', TextInputView, {
maxLength: 5000
});
this.input('text', TextAreaInputView, {
fragmentLinkInputView: PageLinkInputView,
enableLists: true
});
this.input('text_position', SelectInputView, {
values: options.supportsTextPositionCenter ? Page.textPositions : Page.textPositionsWithoutCenterOption
});
this.input('gradient_opacity', SliderInputView);
this.input('invert', CheckBoxInputView);
});
ConfigurationEditorTabView.groups.define('page_link', function () {
this.input('label', TextInputView);
this.input('target_page_id', PageLinkInputView);
this.group('page_transitions', {
includeBlank: true
});
});
ConfigurationEditorTabView.groups.define('page_transitions', function (options) {
var inputOptions = {
translationKeyPrefix: 'pageflow.page_transitions',
blankTranslationKey: 'pageflow.page_transitions.default',
values: pageflow.pageTransitions.names()
};
if (pageflow.navigationDirection.isHorizontalOnPhone()) {
inputOptions.additionalInlineHelpText = I18n$1.t('pageflow.editor.phone_horizontal_slideshow_mode.page_transitions_inline_help');
}
this.input(options.propertyName || 'page_transition', SelectInputView, _$1.extend(inputOptions, options));
});
ConfigurationEditorTabView.groups.define('options', function (options) {
var theme = state.entry.getTheme();
this.input('display_in_navigation', CheckBoxInputView);
if (theme.supportsEmphasizedPages()) {
this.input('emphasize_in_navigation', CheckBoxInputView);
}
this.group('page_transitions', {
propertyName: 'transition'
});
if (pageflow.features.isEnabled('delayed_text_fade_in')) {
this.input('delayed_text_fade_in', SelectInputView, {
values: Page.delayedTextFadeIn
});
}
this.input('description', TextAreaInputView, {
size: 'short',
disableLinks: true
});
this.input('atmo_audio_file_id', FileInputView, {
collection: state.audioFiles
});
if (options.canPauseAtmo) {
this.input('atmo_during_playback', SelectInputView, {
values: pageflow.Atmo.duringPlaybackModes
});
}
if (theme.supportsScrollIndicatorModes()) {
this.input('scroll_indicator_mode', SelectInputView, {
values: Page.scrollIndicatorModes
});
this.input('scroll_indicator_orientation', SelectInputView, {
values: Page.scrollIndicatorOrientations
});
}
});
editor$1.widgetTypes.register('classic_loading_spinner', {
configurationEditorView: ConfigurationEditorView.extend({
configure: function configure() {
this.tab('loading_spinner', function () {
this.view(InfoBoxView, {
text: I18n$1.t('pageflow.editor.classic_loading_spinner.widget_type_info_box_text')
});
});
}
})
});
editor$1.widgetTypes.registerRole('cookie_notice', {
isOptional: true
});
editor$1.widgetTypes.register('cookie_notice_bar', {
configurationEditorView: ConfigurationEditorView.extend({
configure: function configure() {
this.tab('cookie_notice_bar', function () {
this.view(InfoBoxView, {
text: I18n$1.t('pageflow.editor.cookie_notice_bar.widget_type_info_box_text')
});
});
}
})
});
editor$1.widgetTypes.register('media_loading_spinner', {
configurationEditorView: ConfigurationEditorView.extend({
configure: function configure() {
this.tab('loading_spinner', function () {
this.view(InfoBoxView, {
text: I18n$1.t('pageflow.editor.media_loading_spinner.widget_type_info_box_text')
});
this.input('custom_background_image_id', FileInputView, {
collection: 'image_files',
fileSelectionHandler: 'widgetConfiguration'
});
this.input('invert', CheckBoxInputView);
this.input('remove_logo', CheckBoxInputView);
this.input('blur_strength', SliderInputView);
});
}
})
});
editor$1.widgetTypes.register('phone_horizontal_slideshow_mode', {
configurationEditorView: ConfigurationEditorView.extend({
configure: function configure() {
this.tab('phone_horizontal_slideshow_mode', function () {
this.view(InfoBoxView, {
text: I18n$1.t('pageflow.editor.phone_horizontal_slideshow_mode.widget_type_info_box_text')
});
this.view(HelpImageView, {
imageName: 'phone_horizontal_slideshow_mode'
});
});
}
})
});
editor$1.widgetTypes.register('title_loading_spinner', {
configurationEditorView: ConfigurationEditorView.extend({
configure: function configure() {
this.tab('loading_spinner', function () {
this.view(InfoBoxView, {
text: I18n$1.t('pageflow.editor.title_loading_spinner.widget_type_info_box_text')
});
this.input('title', TextInputView, {
placeholder: state.entry.metadata.get('title') || state.entry.get('entry_title')
});
this.input('subtitle', TextInputView);
this.input('custom_background_image_id', FileInputView, {
collection: 'image_files',
fileSelectionHandler: 'widgetConfiguration'
});
this.input('invert', CheckBoxInputView);
this.input('remove_logo', CheckBoxInputView);
this.input('blur_strength', SliderInputView);
});
}
})
});
app.addInitializer(function (options) {
state.config = options.config;
});
app.addInitializer(function (options) {
state.editorAssetUrls = options.asset_urls;
});
app.addInitializer(function (options) {
state.seed = options.common;
});
app.addInitializer(function (options) {
pageflow.features.enable('editor', options.entry.enabled_feature_names);
});
app.addInitializer(function (options) {
pageflow.Audio.setup({
getSources: function getSources(audioFileId) {
var file = state.audioFiles.getByPermaId(audioFileId);
return file ? file.getSources() : '';
}
});
});
app.addInitializer(function () {
Backbone.history.on('route', function () {
editor$1.applyDefaultHelpEntry();
});
});
app.addInitializer(function (options) {
var textTracksMetaDataAttribute = {
name: 'text_tracks',
valueView: TextTracksFileMetaDataItemValueView,
valueViewOptions: {
settingsDialogTabLink: 'text_tracks'
}
};
var textTracksSettingsDialogTab = {
name: 'text_tracks',
view: TextTracksView,
viewOptions: {
supersetCollection: function supersetCollection() {
return state.textTrackFiles;
}
}
};
var altMetaDataAttribute = {
name: 'alt',
valueView: TextFileMetaDataItemValueView,
valueViewOptions: {
fromConfiguration: true,
settingsDialogTabLink: 'general'
}
};
editor$1.fileTypes.register('image_files', {
model: ImageFile,
metaDataAttributes: ['dimensions', altMetaDataAttribute],
matchUpload: /^image/,
configurationEditorInputs: [{
name: 'alt',
inputView: TextInputView
}]
});
editor$1.fileTypes.register('video_files', {
model: VideoFile,
metaDataAttributes: ['format', 'dimensions', 'duration', textTracksMetaDataAttribute, altMetaDataAttribute],
matchUpload: /^video/,
configurationEditorInputs: [{
name: 'alt',
inputView: TextInputView
}],
settingsDialogTabs: [textTracksSettingsDialogTab]
});
editor$1.fileTypes.register('audio_files', {
model: AudioFile,
metaDataAttributes: ['format', 'duration', textTracksMetaDataAttribute, altMetaDataAttribute],
matchUpload: /^audio/,
configurationEditorInputs: [{
name: 'alt',
inputView: TextInputView
}],
settingsDialogTabs: [textTracksSettingsDialogTab]
});
editor$1.fileTypes.register('text_track_files', {
model: TextTrackFile,
matchUpload: function matchUpload(upload) {
return upload.name.match(/\.vtt$/) || upload.name.match(/\.srt$/);
},
skipUploadConfirmation: true,
configurationEditorInputs: [{
name: 'label',
inputView: TextInputView,
inputViewOptions: {
placeholder: function placeholder(configuration) {
var textTrackFile = configuration.parent;
return textTrackFile.inferredLabel();
},
placeholderBinding: TextTrackFile.displayLabelBinding
}
}, {
name: 'kind',
inputView: SelectInputView,
inputViewOptions: {
values: state.config.availableTextTrackKinds,
translationKeyPrefix: 'pageflow.config.text_track_kind'
}
}, {
name: 'srclang',
inputView: TextInputView,
inputViewOptions: {
required: true
}
}],
nestedFileTableColumns: [{
name: 'label',
cellView: TextTableCellView,
value: function value(textTrackFile) {
return textTrackFile.displayLabel();
},
contentBinding: TextTrackFile.displayLabelBinding
}, {
name: 'srclang',
cellView: TextTableCellView,
"default": I18n$1.t('pageflow.editor.text_track_files.srclang_missing')
}, {
name: 'kind',
cellView: IconTableCellView,
cellViewOptions: {
icons: state.config.availableTextTrackKinds
}
}],
nestedFilesOrder: {
comparator: function comparator(textTrackFile) {
return textTrackFile.displayLabel().toLowerCase();
},
binding: 'label'
}
});
editor$1.fileTypes.setup(options.config.fileTypes);
});
app.addInitializer(function (options) {
editor$1.widgetTypes.registerRole('navigation', {
isOptional: true
});
editor$1.widgetTypes.setup(options.widget_types);
});
app.addInitializer(function (options) {
state.files = FilesCollection.createForFileTypes(editor$1.fileTypes, options.files);
state.imageFiles = state.files.image_files;
state.videoFiles = state.files.video_files;
state.audioFiles = state.files.audio_files;
state.textTrackFiles = state.files.text_track_files;
var widgets = new WidgetsCollection(options.widgets, {
widgetTypes: editor$1.widgetTypes
});
state.themes = new ThemesCollection(options.themes);
state.pages = new PagesCollection(options.pages);
state.chapters = new ChaptersCollection(options.chapters);
state.storylines = new StorylinesCollection(options.storylines);
state.entry = editor$1.createEntryModel(options, {
widgets: widgets
});
state.theming = new Theming(options.theming);
state.account = new Backbone.Model(options.account);
widgets.subject = state.entry;
state.entryData = new PreviewEntryData({
entry: state.entry,
storylines: state.storylines,
chapters: state.chapters,
pages: state.pages
});
state.storylineOrdering = new StorylineOrdering(state.storylines, state.pages);
state.storylineOrdering.sort({
silent: true
});
state.storylineOrdering.watch();
state.pages.sort();
state.storylines.on('sort', _$1.debounce(function () {
state.storylines.saveOrder();
}, 100));
editor$1.failures.watch(state.entry);
editor$1.failures.watch(state.pages);
editor$1.failures.watch(state.chapters);
state.savingRecords = new SavingRecordsCollection();
state.savingRecords.watch(state.pages);
state.savingRecords.watch(state.chapters);
pageflow.events.trigger('seed:loaded');
});
app.addInitializer(function (options) {
state.fileUploader = new FileUploader({
entry: state.entry,
fileTypes: editor$1.fileTypes
});
ConfirmUploadView.watch(state.fileUploader, editor$1.fileTypes, state.files);
});
app.addInitializer(function (options) {
editor$1.pageTypes.setup(options.page_types);
});
app.addInitializer(function (options) {
var KEY_A = 65;
var KEY_X = 88;
$(document).on('keydown', function (event) {
if (event.altKey && event.which === KEY_A) {
if (pageflow.atmo.disabled) {
pageflow.atmo.enable();
} else {
pageflow.atmo.disable();
}
} else if (event.altKey && event.which === KEY_X) {
editor$1.navigate('pages/' + pageflow.slides.currentPage().data('id'), {
trigger: true
});
}
});
});
app.addInitializer(function (options) {
editor$1.fileImporters.setup(options.config.fileImporters);
});
app.addInitializer(function (options) {
state.editLock = new EditLockContainer();
state.editLock.watchForErrors();
state.editLock.acquire();
});
app.addInitializer(function (options) {
state.entry.pollForPendingFiles();
});
app.addInitializer(function (options) {
state.entry.on('change:pending_files_count', function (model, value) {
if (value < state.entry.previous('pending_files_count')) {
pageflow.stylesheet.reload('entry');
}
});
state.entry.on('use:files', function () {
pageflow.stylesheet.reload('entry');
});
state.entry.metadata.on('change:theme_name', function () {
var theme = state.entry.getTheme();
pageflow.stylesheet.update('theme', theme.get('stylesheet_path'));
});
});
app.addInitializer(function () {
_$1.each(editor$1.sideBarRoutings, function (options) {
new options.router({
controller: new options.controller({
region: app.sidebarRegion,
entry: state.entry
})
});
});
editor$1.router = new SidebarRouter({
controller: new SidebarController({
region: app.sidebarRegion,
entry: state.entry
})
});
window.editor = editor$1.router;
});
app.addInitializer(function () {
app.on('error', function (e) {
if (e.message) {
alert(e.message);
} else {
alert(I18n$1.t(e.name, {
scope: 'pageflow.editor.errors',
defaultValue: I18n$1.t('pageflow.editor.errors.unknown')
}));
}
});
});
app.addInitializer(function ()
/* args */
{
var context = this;
var args = arguments;
_$1.each(editor$1.initializers, function (fn) {
fn.call(context, args);
});
});
app.addInitializer(function (options) {
new EditorView({
el: $('body')
}).render();
new ScrollingView({
el: $('sidebar .scrolling'),
region: app.sidebarRegion
}).render();
app.previewRegion.show(new editor$1.entryType.previewView({
model: state.entry
}));
app.indicatorsRegion.show(new DisabledAtmoIndicatorView());
app.notificationsRegion.show(new NotificationsView());
app.sidebarFooterRegion.show(new SidebarFooterView({
model: state.entry
}));
Backbone.history.start({
root: options.root
});
});
app.addRegions({
previewRegion: '#entry_preview',
mainRegion: '#main_content',
indicatorsRegion: '#editor_indicators',
sidebarRegion: 'sidebar .container',
dialogRegion: '.dialog_container',
notificationsRegion: 'sidebar .notifications_container',
sidebarFooterRegion: 'sidebar .sidebar_footer_container'
});
var PagedEntry = Entry.extend();
function template$T(data) {
var __t, __p = '';
__p += '\n \n \n \n \n\n';
return __p
}
var PageItemView = Marionette.ItemView.extend({
tagName: 'li',
template: template$T,
ui: {
title: '.title',
pictogram: '.type_pictogram',
pageThumbnail: '.page_thumbnail'
},
modelEvents: {
'change:title': 'update',
'change:active': 'update'
},
onRender: function onRender() {
this.subview(new PageThumbnailView({
el: this.ui.pageThumbnail,
model: this.model
}));
this.update();
},
update: function update() {
this.$el.attr('data-id', this.model.id);
this.$el.attr('data-perma-id', this.model.get('perma_id'));
this.$el.toggleClass('active', this.model.get('active'));
this.$el.toggleClass('disabled', !!(this.options.isDisabled && this.options.isDisabled(this.model)));
this.$el.toggleClass('display_in_navigation', !!this.model.configuration.get('display_in_navigation'));
this.$el.removeClass(editor$1.pageTypes.pluck('name').join(' ')).addClass(this.model.get('template'));
this.ui.pictogram.attr('title', this._getPictogramTitle());
this.ui.title.text(this.model.title() || I18n$1.t('pageflow.editor.views.page_item_view.unnamed'));
},
_getPictogramTitle: function _getPictogramTitle() {
var result = I18n$1.t(this.model.pageType().translationKey());
result += ' Seite';
if (this.options.displayInNavigationHint && !this.model.configuration.get('display_in_navigation')) {
result += ' (nicht in Navigationsleiste)';
}
return result;
}
});
var NavigatablePageItemView = PageItemView.extend({
mixins: [loadable, failureIndicatingView],
className: 'draggable',
events: {
'click': function click() {
if (!this.model.isNew() && !this.model.isDestroying()) {
editor$1.navigate('/pages/' + this.model.get('id'), {
trigger: true
});
}
return false;
}
}
});
function template$U(data) {
var __t, __p = '';
__p += '\n \n \n \n \n\n\n
\n\n' +
((__t = ( I18n.t('pageflow.editor.templates.chapter_item.new_page') )) == null ? '' : __t) +
'\n';
return __p
}
var ChapterItemView = Marionette.ItemView.extend({
tagName: 'li',
template: template$U,
ui: {
title: '> a > .title',
number: '> a > .number',
pages: 'ul.pages'
},
modelEvents: {
change: 'update'
},
onRender: function onRender() {
var collectionView = this.options.sortable ? SortableCollectionView : CollectionView;
this.subview(new collectionView({
el: this.ui.pages,
collection: this.model.pages,
itemViewConstructor: this.options.pageItemView || NavigatablePageItemView,
itemViewOptions: this.options.pageItemViewOptions,
connectWith: 'ul.pages'
}));
this.update();
},
update: function update() {
this.ui.title.text(this.model.get('title') || I18n$1.t('pageflow.editor.views.chapter_item_view.unnamed'));
this.ui.number.text(I18n$1.t('pageflow.editor.views.chapter_item_view.chapter') + ' ' + (this.model.get('position') + 1));
}
});
var NavigatableChapterItemView = ChapterItemView.extend({
mixins: [loadable, failureIndicatingView],
events: {
'click a.add_page': function clickAAdd_page() {
this.model.addPage();
},
'click a.edit_chapter': function clickAEdit_chapter() {
if (!this.model.isNew() && !this.model.isDestroying()) {
editor$1.navigate('/chapters/' + this.model.get('id'), {
trigger: true
});
}
return false;
}
}
});
function template$V(data) {
var __t, __p = '';
__p += '
' +
((__t = ( I18n.t('pageflow.editor.templates.storyline_outline.header') )) == null ? '' : __t) +
'
\n\n\n' +
((__t = ( I18n.t('pageflow.editor.templates.storyline_outline.new_chapter') )) == null ? '' : __t) +
'\n';
return __p
}
var StorylineOutlineView = Marionette.Layout.extend({
template: template$V,
className: 'storyline_outline',
ui: {
chapters: 'ul.storyline_outline_chapters'
},
events: {
'click a.add_chapter': function clickAAdd_chapter() {
this.model.scaffoldChapter();
}
},
onRender: function onRender() {
this.ui.chapters.toggleClass('outline navigatable', !!this.options.navigatable);
var collectionView = this.options.sortable ? SortableCollectionView : CollectionView;
new collectionView({
el: this.ui.chapters,
collection: this.model.chapters,
itemViewConstructor: this.options.navigatable ? NavigatableChapterItemView : ChapterItemView,
itemViewOptions: {
sortable: this.options.sortable,
pageItemView: this.options.navigatable ? NavigatablePageItemView : PageItemView,
pageItemViewOptions: _$1.extend({
displayInNavigationHint: this.options.displayInNavigationHint
}, this.options.pageItemViewOptions || {})
}
}).render();
}
});
function template$W(data) {
var __t, __p = '';
__p += '\n\n\n';
return __p
}
var StorylinePickerView = Marionette.Layout.extend({
template: template$W,
className: 'storyline_picker',
regions: {
selectRegion: '.storyline_picker_select_region',
mainRegion: '.storyline_picker_main_region'
},
ui: {
storylines: '.storyline_picker_storylines'
},
events: {
'click .add_storyline': function clickAdd_storyline() {
var storyline = this.options.entry.scaffoldStoryline({
depth: 'page'
}).storyline;
this.listenToOnce(storyline, 'sync', function () {
this.updateSelect();
this.model.set('storyline_id', storyline.id);
});
return false;
},
'click .edit_storyline': function clickEdit_storyline() {
editor$1.navigate('storylines/' + this.model.get('storyline_id'), {
trigger: true
});
return false;
}
},
initialize: function initialize() {
this.model = new Backbone.Model({
storyline_id: this.defaultStorylineId()
});
this.listenTo(this.options.entry.storylines, 'add sort remove', this.updateSelect);
this.listenTo(this.model, 'change', this.load);
},
onRender: function onRender() {
this.$el.toggleClass('editable', !!this.options.editable);
this.ui.storylines.toggle(!!pageflow.features.isEnabled('storylines'));
this.updateSelect();
this.load();
},
updateSelect: function updateSelect() {
var storylines = this.options.entry.storylines;
this.selectRegion.show(new SelectInputView({
model: this.model,
label: I18n$1.t('pageflow.editor.views.storylines_picker_view.label'),
propertyName: 'storyline_id',
values: storylines.pluck('id'),
texts: storylines.map(function (storyline) {
return this.indentation(storyline) + storyline.displayTitle();
}, this),
groups: storylines.reduce(function (result, storyline) {
if (storyline.isMain() || storyline.parentPage()) {
result.push(_$1.last(result));
} else {
result.push(I18n$1.t('pageflow.editor.views.storylines_picker_view.without_parent_page'));
}
return result;
}, [])
}));
},
load: function load() {
var storyline = this.options.entry.storylines.get(this.model.get('storyline_id'));
this.saveRememberedStorylineId(storyline.id);
this.mainRegion.show(new StorylineOutlineView({
model: storyline,
navigatable: this.options.navigatable,
sortable: this.options.editable,
chapterItemView: this.options.chapterItemView,
pageItemView: this.options.pageItemView,
pageItemViewOptions: this.options.pageItemViewOptions,
displayInNavigationHint: this.options.displayInNavigationHint
}));
},
defaultStorylineId: function defaultStorylineId() {
var storyline = this.options.entry.storylines.get(this.options.storylineId) || this.options.entry.storylines.get(this.rememberedStorylineId()) || this.options.entry.storylines.first();
return storyline.id;
},
rememberedStorylineId: function rememberedStorylineId() {
if (this.options.rememberLastSelection) {
return StorylinePickerView._rememberedStorylineId;
}
},
saveRememberedStorylineId: function saveRememberedStorylineId(id) {
if (this.options.rememberLastSelection) {
StorylinePickerView._rememberedStorylineId = id;
}
},
indentation: function indentation(storyline) {
return _$1(storyline.get('level') || 0).times(function () {
return "\xA0\xA0\xA0";
}).join('');
}
});
var EntryOutlineView = function EntryOutlineView(options) {
return new StorylinePickerView(_.extend({
navigatable: true,
editable: true,
displayInNavigationHint: true,
rememberLastSelection: true
}, options));
};
function template$X(data) {
var __t, __p = '';
__p += '
' +
((__t = ( I18n.t('pageflow.editor.blank_entry.header') )) == null ? '' : __t) +
'
\n\n
\n' +
((__t = ( I18n.t('pageflow.editor.templates.page_selection.title') )) == null ? '' : __t) +
'
\n\n