lib/assets/javascripts/scrivito_editing.js in scrivito_sdk-0.15.0 vs lib/assets/javascripts/scrivito_editing.js in scrivito_sdk-0.16.0
- old
+ new
@@ -9721,11 +9721,11 @@
(function() {
this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {});
this.ScrivitoHandlebarsTemplates["menu"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [3,'>= 1.0.0-rc.4'];
helpers = helpers || Handlebars.helpers; data = data || {};
- var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
+ var buffer = "", stack1, stack2, functionType="function", escapeExpression=this.escapeExpression, self=this;
function program1(depth0,data) {
var buffer = "", stack1;
buffer += "\n ";
@@ -9778,13 +9778,17 @@
if (stack1 = helpers.reason_for_being_disabled) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.reason_for_being_disabled; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
return escapeExpression(stack1);
}
- buffer += "<div class=\"scrivito_editing_marker_menu\">\n <ul class=\"scrivito_menu_box scrivito_right\">\n ";
- stack1 = helpers.each.call(depth0, depth0.commands, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
- if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "<div class=\"scrivito_editing_marker_menu\">\n <ul class=\"scrivito_menu_box scrivito_"
+ + escapeExpression(((stack1 = ((stack1 = depth0.options),stack1 == null || stack1 === false ? stack1 : stack1.align)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ + " "
+ + escapeExpression(((stack1 = ((stack1 = depth0.options),stack1 == null || stack1 === false ? stack1 : stack1.css_class)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ + "\">\n ";
+ stack2 = helpers.each.call(depth0, depth0.commands, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
+ if(stack2 || stack2 === 0) { buffer += stack2; }
buffer += "\n </ul>\n</div>\n";
return buffer;
});
return this.ScrivitoHandlebarsTemplates["menu"];
}).call(this);
@@ -9894,33 +9898,34 @@
(function() {
this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {});
this.ScrivitoHandlebarsTemplates["menu_bar_toggle"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [3,'>= 1.0.0-rc.4'];
helpers = helpers || Handlebars.helpers; data = data || {};
- var buffer = "", stack1, options, functionType="function", escapeExpression=this.escapeExpression, helperMissing=helpers.helperMissing;
+ var buffer = "", stack1, stack2, functionType="function", escapeExpression=this.escapeExpression;
buffer += "<div class=\"scrivito_viewmodes scrivito_viewmode_";
if (stack1 = helpers.mode) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.mode; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
- + "_active\">\n <span class=\"scrivito_viewmode_pill\"></span>\n\n <div class=\"scrivito_viewmode_view\">\n <span class=\"scrivito_viewmode_icon\"></span>\n <span class=\"scrivito_viewmode_label\">";
- options = {hash:{},data:data};
- buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "menu_bar_toggle.view", options) : helperMissing.call(depth0, "translate", "menu_bar_toggle.view", options)))
- + "</span>\n </div>\n\n <div class=\"scrivito_viewmode_editing\">\n <span class=\"scrivito_viewmode_icon\"></span>\n <span class=\"scrivito_viewmode_label\">";
- options = {hash:{},data:data};
- buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "menu_bar_toggle.editing", options) : helperMissing.call(depth0, "translate", "menu_bar_toggle.editing", options)))
- + "</span>\n </div>\n\n <div class=\"scrivito_viewmode_added\">\n <span class=\"scrivito_viewmode_icon\"></span>\n <span class=\"scrivito_viewmode_label\">";
- options = {hash:{},data:data};
- buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "menu_bar_toggle.added", options) : helperMissing.call(depth0, "translate", "menu_bar_toggle.added", options)))
- + "</span>\n </div>\n\n <div class=\"scrivito_viewmode_deleted\">\n <span class=\"scrivito_viewmode_icon\"></span>\n <span class=\"scrivito_viewmode_label\">";
- options = {hash:{},data:data};
- buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "menu_bar_toggle.deleted", options) : helperMissing.call(depth0, "translate", "menu_bar_toggle.deleted", options)))
- + "</span>\n </div>\n\n <div class=\"scrivito_viewmode_diff\">\n <span class=\"scrivito_viewmode_icon\"></span>\n <span class=\"scrivito_viewmode_label\">";
- options = {hash:{},data:data};
- buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "menu_bar_toggle.diff", options) : helperMissing.call(depth0, "translate", "menu_bar_toggle.diff", options)))
- + "</span>\n </div>\n</div>\n";
+ + "_active\">\n <span class=\"scrivito_viewmode_pill\"></span>\n\n <div class=\"scrivito_viewmode_view\">\n <span class=\"scrivito_viewmode_icon "
+ + escapeExpression(((stack1 = ((stack1 = depth0.switch_to_view_mode_command),stack1 == null || stack1 === false ? stack1 : stack1.id)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ + "\"></span>\n <span class=\"scrivito_viewmode_label\">"
+ + escapeExpression(((stack1 = ((stack1 = depth0.switch_to_view_mode_command),stack1 == null || stack1 === false ? stack1 : stack1.title)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ + "</span>\n </div>\n\n <div class=\"scrivito_viewmode_editing\">\n <span class=\"scrivito_viewmode_icon "
+ + escapeExpression(((stack1 = ((stack1 = depth0.switch_to_editing_mode_command),stack1 == null || stack1 === false ? stack1 : stack1.id)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ + "\"></span>\n <span class=\"scrivito_viewmode_label\">"
+ + escapeExpression(((stack1 = ((stack1 = depth0.switch_to_editing_mode_command),stack1 == null || stack1 === false ? stack1 : stack1.title)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ + "</span>\n </div>\n\n <div class=\"scrivito_viewmode_";
+ if (stack2 = helpers.comparing_mode) { stack2 = stack2.call(depth0, {hash:{},data:data}); }
+ else { stack2 = depth0.comparing_mode; stack2 = typeof stack2 === functionType ? stack2.apply(depth0) : stack2; }
+ buffer += escapeExpression(stack2)
+ + "\">\n <span class=\"scrivito_viewmode_icon "
+ + escapeExpression(((stack1 = ((stack1 = depth0.switch_to_comparing_mode_command),stack1 == null || stack1 === false ? stack1 : stack1.id)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ + "\"></span>\n <span class=\"scrivito_viewmode_label scrivito_comparing_mode_toggle\">\n "
+ + escapeExpression(((stack1 = ((stack1 = depth0.switch_to_comparing_mode_command),stack1 == null || stack1 === false ? stack1 : stack1.title)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ + " <i class=\"scrivito_icon\"></i>\n </span>\n </div>\n</div>\n";
return buffer;
});
return this.ScrivitoHandlebarsTemplates["menu_bar_toggle"];
}).call(this);
(function() {
@@ -10264,17 +10269,10 @@
'menu_bar.create_new_working_copy': 'Arbeitskopie anlegen',
'menu_bar.create_new_ws_confirmation': 'Arbeitskopie anlegen',
'menu_bar.create_new_ws_confirmation_desc': 'Bitte geben Sie den Titel der neuen Arbeitskopie ein.',
'menu_bar.create_new_ws_confirmation_placeholder': 'Neuer Titel',
- 'menu_bar_toggle.editing': 'Bearbeiten',
- 'menu_bar_toggle.added': 'Hinzugefügt',
- 'menu_bar_toggle.deleted': 'Gelöscht',
- 'menu_bar_toggle.diff': 'Vergleichen',
- 'menu_bar_toggle.view': 'Vorschau',
- 'menu_bar_toggle.hide': 'Ausblenden',
-
'saving_indicator_item.saving': 'Wird gespeichert...',
'saving_indicator_item.saved': 'Änderungen gespeichert',
'widget_menus.widget_is_new': 'Widget ist neu',
'widget_menus.widget_is_edited': 'Widget wurde geändert',
@@ -10355,10 +10353,17 @@
'commands.delete_widget.title': 'Widget löschen',
'commands.delete_widget.dialog.title': 'Wirklich dieses Widget löschen?',
'commands.delete_widget.dialog.description': 'Ein gelöschtes Widget kann nicht wiederhergestellt werden.',
'commands.delete_widget.dialog.confirm': 'Löschen',
+ 'commands.switch_mode.view': 'Vorschau',
+ 'commands.switch_mode.editing': 'Bearbeiten',
+ 'commands.switch_mode.diff': 'Vergleichen',
+ 'commands.switch_mode.added': 'Hinzugefügt',
+ 'commands.switch_mode.deleted': 'Gelöscht',
+ 'commands.switch_mode.disabled': 'Aktuell ausgewählter Anzeigemodus',
+
'image_upload.too_many_files': 'Nur eine Datei erlaubt.',
'warn_before_unloading': 'Sie haben nicht gespeicherte Änderungen! Sind Sie sicher, dass sie schließen wollen?'
}, 'de');
$.i18n().load({
@@ -10416,17 +10421,10 @@
'menu_bar.create_new_working_copy': 'Create working copy',
'menu_bar.create_new_ws_confirmation': 'Create a working copy',
'menu_bar.create_new_ws_confirmation_desc': 'Please enter the title of the new working copy.',
'menu_bar.create_new_ws_confirmation_placeholder': 'new title',
- 'menu_bar_toggle.editing': 'Edit',
- 'menu_bar_toggle.added': 'Added',
- 'menu_bar_toggle.deleted': 'Deleted',
- 'menu_bar_toggle.diff': 'Compare',
- 'menu_bar_toggle.view': 'Preview',
- 'menu_bar_toggle.hide': 'Hide',
-
'saving_indicator_item.saving': 'Saving...',
'saving_indicator_item.saved': 'Changes saved',
'widget_menus.widget_is_new': 'Widget is new',
'widget_menus.widget_is_edited': 'Widget has been modified',
@@ -10507,10 +10505,17 @@
'commands.delete_widget.title': 'Delete widget',
'commands.delete_widget.dialog.title': 'Really delete this widget?',
'commands.delete_widget.dialog.description': 'A deleted widget cannot be restored.',
'commands.delete_widget.dialog.confirm': 'Delete',
+ 'commands.switch_mode.view': 'Preview',
+ 'commands.switch_mode.editing': 'Edit',
+ 'commands.switch_mode.diff': 'All changes',
+ 'commands.switch_mode.added': 'Additions',
+ 'commands.switch_mode.deleted': 'Deletions',
+ 'commands.switch_mode.disabled': 'Currently selected display mode',
+
'image_upload.too_many_files': 'Only one file allowed.',
'warn_before_unloading': 'You have unsaved changes. Are you sure you want to quit?',
'test.two_arguments': '$1, $2',
@@ -10989,10 +10994,25 @@
}
},
write_cookie: function() {
$.cookie('scrivito_editing_context', serialize(), {path: '/'});
+ },
+
+ comparing_mode: function() {
+ var storage_key = 'editing_context.comparing_mode';
+ if (scrivito.editing_context.is_comparing_mode()) {
+ var mode = scrivito.editing_context.display_mode;
+ scrivito.storage.set(storage_key, mode);
+ return mode;
+ } else {
+ if (scrivito.storage.has_key(storage_key)) {
+ return scrivito.storage.get(storage_key);
+ } else {
+ return 'diff';
+ }
+ }
}
}
});
var serialize = function() {
@@ -11287,49 +11307,48 @@
(function() {
$.extend(scrivito, {
menu_bar_toggle: {
init: function() {
scrivito.menu_bar.register_item_renderer(function(menu_bar) {
+ var comparing_mode = scrivito.editing_context.comparing_mode();
+ var switch_to_view_mode_command = scrivito.switch_mode_command('view');
+ var switch_to_editing_mode_command = scrivito.switch_mode_command('editing');
+ var switch_to_comparing_mode_command = scrivito.switch_mode_command(comparing_mode);
+
var template = scrivito.template.render('menu_bar_toggle', {
- mode: scrivito.editing_context.display_mode
+ mode: scrivito.editing_context.display_mode,
+ comparing_mode: comparing_mode,
+ switch_to_view_mode_command: switch_to_view_mode_command,
+ switch_to_editing_mode_command: switch_to_editing_mode_command,
+ switch_to_comparing_mode_command: switch_to_comparing_mode_command
});
+
var menu_bar_toggle = menu_bar.find('#scrivito_menu_bar_toggle').html(template);
- change_mode_on_click(menu_bar_toggle, 'view');
- change_mode_on_click(menu_bar_toggle, 'editing');
- change_mode_on_click(menu_bar_toggle, 'added');
- change_mode_on_click(menu_bar_toggle, 'deleted');
- change_mode_on_click(menu_bar_toggle, 'diff');
+ _.each([
+ switch_to_view_mode_command,
+ switch_to_editing_mode_command,
+ switch_to_comparing_mode_command
+ ], function(command) {
+ menu_bar_toggle.find('.' + command.id()).on('click', function() {
+ command.execute();
+ return false;
+ });
+ });
+
+ menu_bar_toggle.find('.scrivito_comparing_mode_toggle').on('click', function() {
+ scrivito.menus.toggle($(this), [
+ scrivito.switch_mode_command('diff'),
+ scrivito.switch_mode_command('added'),
+ scrivito.switch_mode_command('deleted')
+ ], {align: 'left', css_class: 'scrivito_switch_mode_menu'});
+ return false;
+ });
});
}
}
});
-
- var change_mode_on_click = function(menu_bar_toggle, mode) {
- var new_class = 'scrivito_viewmode_' + mode + '_active';
- var view_modes = menu_bar_toggle.find('.scrivito_viewmodes');
-
- if (!view_modes.hasClass(new_class)) {
- menu_bar_toggle.find(".scrivito_viewmode_" + mode).click(function() {
- if (mode !== 'view' && !scrivito.editing_context.selected_workspace.is_editable()) {
- scrivito.workspace.all_editable().done(function(workspaces) {
- scrivito.editable_workspace_dialog.open(workspaces).done(function(workspace_id) {
- scrivito.with_saving_overlay(
- scrivito.redirect_to(
- "?_scrivito_display_mode=" + mode + "&_scrivito_workspace_id=" + workspace_id
- )
- );
- });
- });
- } else {
- scrivito.with_saving_overlay(
- scrivito.redirect_to("?_scrivito_display_mode=" + mode)
- );
- }
- });
- }
- };
}());
(function() {
$.extend(scrivito, {
menu_bar_dropdown: {
init: function() {
@@ -11469,11 +11488,15 @@
accept_button_text: t('menu_bar.create'),
accept_button_color: 'green'
}).done(function(title) {
scrivito.with_saving_overlay(
scrivito.workspace.create(title).then(function(new_workspace) {
- return scrivito.redirect_to('?_scrivito_workspace_id=' + new_workspace.id());
+ var path = '?_scrivito_workspace_id=' + new_workspace.id();
+ if (!scrivito.editing_context.selected_workspace.is_editable()) {
+ path += '&_scrivito_display_mode=editing';
+ }
+ return scrivito.redirect_to(path);
})
);
});
});
@@ -13472,14 +13495,17 @@
});
}());
(function() {
$.extend(scrivito, {
menus: {
- open: function(dom_element, commands) {
+ open: function(dom_element, commands, options) {
scrivito.menus.close_all();
- var menu = $(scrivito.template.render('menu', {commands: commands}));
+ var menu = $(scrivito.template.render('menu', {
+ commands: commands,
+ options: $.extend({align: 'right'}, options || {})
+ }));
menu.data('scrivito-private-menus-target', dom_element);
dom_element.data('scrivito-private-menus-menu', menu);
_.each(commands, function(command) {
@@ -13495,16 +13521,16 @@
menu.appendTo($('body'));
menu.offset(dom_element.offset()); // Bugfix IE: offset can not be set before append.
menu.find('.scrivito_menu_box').fadeIn(500);
},
- toggle: function(dom_element, commands) {
+ toggle: function(dom_element, commands, options) {
var menu = dom_element.data('scrivito-private-menus-menu');
if (menu) {
close(menu);
} else {
- scrivito.menus.open(dom_element, commands);
+ scrivito.menus.open(dom_element, commands, options);
}
},
close_all: function() {
each_menu(function(menu) {
@@ -13586,11 +13612,23 @@
marker.on('click', function() {
scrivito.menus.toggle(marker, cms_element.menu());
return false;
});
- marker.prependTo(cms_element.dom_element());
+ var marker_container = cms_element.dom_element();
+ marker.prependTo(marker_container);
+
+ var timer;
+ marker_container.on('mouseenter', function() {
+ marker_container.addClass('scrivito_entered');
+ timer = setTimeout(function() {
+ marker_container.removeClass('scrivito_entered');
+ }, 2000);
+ });
+ marker_container.on('mouseleave', function() {
+ clearTimeout(timer);
+ });
}
};
}());
(function() {
$.extend(scrivito, {
@@ -14120,10 +14158,60 @@
}
});
}());
(function() {
$.extend(scrivito, {
+ switch_mode_command: function(mode) {
+ var icon;
+ switch (mode) {
+ case 'diff':
+ icon = '';
+ break;
+ case 'added':
+ icon = '';
+ break;
+ case 'deleted':
+ icon = '';
+ break;
+ }
+
+ return scrivito.command.create_instance({
+ id: 'switch_to_' + mode + '_mode',
+ title: scrivito.i18n.translate('commands.switch_mode.' + mode),
+ icon: icon,
+
+ disabled: function() {
+ if (scrivito.editing_context.display_mode === mode) {
+ return scrivito.i18n.translate('commands.switch_mode.disabled');
+ }
+ },
+
+ execute: function() {
+ if (mode !== 'view' && !scrivito.editing_context.selected_workspace.is_editable()) {
+ scrivito.workspace.all_editable().done(function(workspaces) {
+ scrivito.editable_workspace_dialog.open(workspaces).done(function(workspace_id) {
+ redirect_to(mode, workspace_id);
+ });
+ });
+ } else {
+ redirect_to(mode);
+ }
+ }
+ });
+ }
+ });
+
+ var redirect_to = function(mode, workspace_id) {
+ var path = '?_scrivito_display_mode=' + mode;
+ if (workspace_id) {
+ path += '&_scrivito_workspace_id=' + workspace_id;
+ }
+ scrivito.with_saving_overlay(scrivito.redirect_to(path));
+ };
+}());
+(function() {
+ $.extend(scrivito, {
widget_details_command: function(widget_element) {
return scrivito.command.create_instance({
id: 'widget_details',
title: scrivito.i18n.translate('commands.widget_details.title'),
icon: '',
@@ -14295,18 +14383,19 @@
if (scrivito.in_editable_view()) {
create();
}
});
scrivito.on('content', function() {
- create();
+ if (scrivito.in_editable_view()) {
+ create();
+ }
});
},
start: function(event, ui) {
$('body').addClass('scrivito_widget_dragging_active');
- var marker = ui.item.find('.scrivito_editing_marker');
scrivito.menus.close_all();
var widget_element = scrivito.cms_element.from_dom_element(ui.item);
var widget_class_name = widget_element.widget().widget_class_name();
_.each(widget_field_elements, function(widget_field_element) {
@@ -14320,11 +14409,17 @@
}
});
$(event.target).sortable('refresh');
},
- stop: function() {
+ stop: function(event, ui) {
$('body').removeClass('scrivito_widget_dragging_active');
+
+ // Dragged the last widget of the widget field and dropped it back to same widget field.
+ if (ui.item.parent()[0] === ui.sender) {
+ var widget_field_element = scrivito.cms_element.from_dom_element(ui.item).widget_field();
+ scrivito.widget_sorting.update_placeholder(widget_field_element);
+ }
scrivito.inplace_marker.refresh();
_.each(widget_field_dom_elements, function(dom_element) {
dom_element.removeClass('scrivito_widget_drop_allowed');