From 16a12dc923c074ad25ac3375540004ab84bbdecc Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 27 Apr 2015 14:19:57 +0200 Subject: [PATCH] Example for Thorsten! :) --- .../widget/translation_inline.js.coffee | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 app/assets/javascripts/app/controllers/widget/translation_inline.js.coffee diff --git a/app/assets/javascripts/app/controllers/widget/translation_inline.js.coffee b/app/assets/javascripts/app/controllers/widget/translation_inline.js.coffee new file mode 100644 index 000000000..89c145ef3 --- /dev/null +++ b/app/assets/javascripts/app/controllers/widget/translation_inline.js.coffee @@ -0,0 +1,30 @@ +class Widget extends App.Controller + constructor: -> + super + + # bind on key down + # if ctrl+shift+t is pressed, enable translation_inline and fire ui:rerender + $(document).on('keydown', (e) => + if e.altKey && e.ctrlKey && e.keyCode is 84 + if @active + @disable() + @active = false + else + @enable() + @active = true + ) + + enable: -> + App.Config.set( 'translation_inline', true ) + App.Event.trigger('ui:rerender') + $(document).bind('click.block', (e) -> + e.preventDefault() + e.stopPropagation() + ) + + disable: -> + App.Config.set( 'translation_inline', false ) + App.Event.trigger('ui:rerender') + $(document).unbind('click.block') + +App.Config.set( 'translation_inline', Widget, 'Widgets' ) \ No newline at end of file