X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/471df249233a0064cdd3c4efe890536d8b304037..d5dade3:/src/editor/plugins/core/switch.js diff --git a/src/editor/plugins/core/switch.js b/src/editor/plugins/core/switch.js index 9b34721..4587318 100644 --- a/src/editor/plugins/core/switch.js +++ b/src/editor/plugins/core/switch.js @@ -10,11 +10,11 @@ var createSwitchAction = function(createParams) { return { name: createParams.name, params: { - fragment: {type: 'context', name: 'fragment'}, + fragment: {type: 'context', name: 'fragment'} }, getState: function(params) { var state = { - label: this.config.label + label: createParams.to.name }, f = params.fragment, description; @@ -26,7 +26,7 @@ var createSwitchAction = function(createParams) { ) { return _.extend(state, { allowed: false, - description: 'wrong or no selection' + description: gettext('wrong or no selection') }); } @@ -39,9 +39,9 @@ var createSwitchAction = function(createParams) { toSwitch = toSwitch.getParent(createParams.from); } - description = 'Switch to ' + createParams.to.name; + description = gettext('Switch to') + ' ' + createParams.to.name; return _.extend(state, { - allowed: !!toSwitch, + allowed: !!toSwitch || alreadyInTarget, toggled: alreadyInTarget, description: description, execute: alreadyInTarget ? function() {} : function(callback) { @@ -55,7 +55,8 @@ var createSwitchAction = function(createParams) { return f.document.createFragment(f.CaretFragment, {node: f.document.getNodeByPath(textNodePath), offset: f.offset}); }, { metadata: { - description: description + description: description, + fragment: params.fragment }, success: callback }); @@ -66,12 +67,14 @@ var createSwitchAction = function(createParams) { }; var headerAction = createSwitchAction({name: 'switchToHeader', from: {tagName: 'div', klass: 'p'}, to: {tagName: 'header', klass: '', name: gettext('header')}}), - paragraphAction = createSwitchAction({name: 'switchToParagraph', from: {tagName: 'header'}, to: {tagName: 'div', klass: 'p', name: gettext('paragraf')}}); + paragraphAction = createSwitchAction({name: 'switchToParagraph', from: {tagName: 'header'}, to: {tagName: 'div', klass: 'p', name: gettext('paragraph')}}), + imageAction = createSwitchAction({name: 'switchToImage', from: {}, to: {tagName: 'div', klass: 'img', name: gettext('image')}}), + videoAction = createSwitchAction({name: 'switchToVideo', from: {}, to: {tagName: 'div', klass: 'video', name: gettext('video')}}); return { - actions: [headerAction, paragraphAction], + actions: [headerAction, paragraphAction, imageAction, videoAction], canvasActionHandler: { - handles: [headerAction, paragraphAction], + handles: [headerAction, paragraphAction, imageAction, videoAction] // handle: function(canvas, action, ret) { // var params = {}, // f;