fix issue #292
This commit is contained in:
parent
e9bf29f297
commit
a8d57794de
@ -48,6 +48,11 @@ class Locomotive.Views.ContentEntries.FormView extends Locomotive.Views.Shared.F
|
|||||||
enable_richtexteditor: ->
|
enable_richtexteditor: ->
|
||||||
_.each @$('li.input.rte textarea.html'), (textarea) =>
|
_.each @$('li.input.rte textarea.html'), (textarea) =>
|
||||||
settings = _.extend {}, @tinyMCE_settings(),
|
settings = _.extend {}, @tinyMCE_settings(),
|
||||||
|
oninit: ((editor) =>
|
||||||
|
$.cmd 'S', (() =>
|
||||||
|
$(textarea).val(editor.getBody().innerHTML).trigger('change')
|
||||||
|
@$('form').trigger('submit')
|
||||||
|
), [], ignoreCase: true, document: editor.dom.doc),
|
||||||
onchange_callback: (editor) =>
|
onchange_callback: (editor) =>
|
||||||
$(textarea).val(editor.getBody().innerHTML).trigger('change')
|
$(textarea).val(editor.getBody().innerHTML).trigger('change')
|
||||||
|
|
||||||
|
@ -13,6 +13,11 @@ class Locomotive.Views.EditableElements.ShortTextView extends Backbone.View
|
|||||||
|
|
||||||
after_render: ->
|
after_render: ->
|
||||||
settings = _.extend {}, @tinymce_settings(),
|
settings = _.extend {}, @tinymce_settings(),
|
||||||
|
oninit: ((editor) =>
|
||||||
|
$.cmd 'S', (() =>
|
||||||
|
@model.set(content: editor.getBody().innerHTML)
|
||||||
|
$(@el).parents('form').trigger('submit')
|
||||||
|
), [], ignoreCase: true, document: editor.dom.doc),
|
||||||
onchange_callback: (editor) =>
|
onchange_callback: (editor) =>
|
||||||
@model.set(content: editor.getBody().innerHTML)
|
@model.set(content: editor.getBody().innerHTML)
|
||||||
|
|
||||||
|
@ -13,6 +13,9 @@ class Locomotive.Views.Shared.FormView extends Backbone.View
|
|||||||
# make inputs foldable (if specified)
|
# make inputs foldable (if specified)
|
||||||
@make_inputs_foldable()
|
@make_inputs_foldable()
|
||||||
|
|
||||||
|
# allow users to save with CTRL+S or CMD+s
|
||||||
|
@enable_save_with_keys_combination()
|
||||||
|
|
||||||
return @
|
return @
|
||||||
|
|
||||||
save: (event) ->
|
save: (event) ->
|
||||||
@ -68,6 +71,9 @@ class Locomotive.Views.Shared.FormView extends Backbone.View
|
|||||||
else
|
else
|
||||||
content.slideUp 100, -> parent.addClass('folded')
|
content.slideUp 100, -> parent.addClass('folded')
|
||||||
|
|
||||||
|
enable_save_with_keys_combination: ->
|
||||||
|
$.cmd 'S', (() => @$('form').trigger('submit')), [], ignoreCase: true
|
||||||
|
|
||||||
after_inputs_fold: ->
|
after_inputs_fold: ->
|
||||||
# overide this method if necessary
|
# overide this method if necessary
|
||||||
|
|
||||||
|
31
vendor/assets/javascripts/locomotive/cmd.js
vendored
Normal file
31
vendor/assets/javascripts/locomotive/cmd.js
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* Version 0.0.1
|
||||||
|
* Catch the CTRL+S keys combination and trigger a callback
|
||||||
|
* Didier Lafforgue
|
||||||
|
*/
|
||||||
|
|
||||||
|
$.cmd = function(key, callback, args, options) {
|
||||||
|
var keyCode = key.charCodeAt(0);
|
||||||
|
var altKeyCode = keyCode + (32 * (keyCode < 97 ? 1 : -1));
|
||||||
|
|
||||||
|
options = (options || { ignoreCase: false });
|
||||||
|
|
||||||
|
if (!options.ignoreCase) altKeyCode = null;
|
||||||
|
|
||||||
|
doc = options.document || window.document;
|
||||||
|
|
||||||
|
$(doc).keydown(function(e) {
|
||||||
|
var isCtrl = false;
|
||||||
|
|
||||||
|
if (!args) args = []; // IE barks when args is null
|
||||||
|
|
||||||
|
if (e.ctrlKey || e.metaKey) isCtrl = true;
|
||||||
|
|
||||||
|
if ((keyCode == e.which || altKeyCode == e.which) && isCtrl) {
|
||||||
|
e.preventDefault();
|
||||||
|
callback.apply(this, args);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
@ -28,6 +28,6 @@ $.fn.toggleMe = function(settings) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return $(this).bind("click", toggle);
|
return $(this).bind('click', toggle);
|
||||||
|
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user