diff --git a/app/assets/javascripts/app/controllers/translation.coffee b/app/assets/javascripts/app/controllers/translation.coffee index 30e86fd88..1d7ec1afb 100644 --- a/app/assets/javascripts/app/controllers/translation.coffee +++ b/app/assets/javascripts/app/controllers/translation.coffee @@ -180,8 +180,12 @@ class Index extends App.ControllerContent delete params.field if params.id - method = 'PUT' - url = "#{@apiPath}/translations/#{params.id}" + if params.target is '' + method = 'DELETE' + url = "#{@apiPath}/translations/#{params.id}" + else + method = 'PUT' + url = "#{@apiPath}/translations/#{params.id}" else method = 'POST' url = "#{@apiPath}/translations" diff --git a/app/assets/javascripts/app/controllers/widget/translation_inline.coffee b/app/assets/javascripts/app/controllers/widget/translation_inline.coffee index d131adb0d..ffca5ff16 100644 --- a/app/assets/javascripts/app/controllers/widget/translation_inline.coffee +++ b/app/assets/javascripts/app/controllers/widget/translation_inline.coffee @@ -1,22 +1,32 @@ class Widget extends App.Controller constructor: -> super + @rebind() + App.Event.bind('auth', => @rebind()) + App.Event.bind('i18n:inline_translation', => @toogle()) + + rebind: => + $(document).off('keydown.translation') # only admins can do this return if !@isRole('Admin') # bind on key down # if ctrl+alt+t is pressed, enable translation_inline and fire ui:rerender - $(document).on('keydown', (e) => + $(document).on('keydown.translation', (e) => if e.altKey && e.ctrlKey && e.keyCode is 84 - if @active - @disable() - @active = false - else - @enable() - @active = true + @toogle() ) + toogle: => + if @active + @disable() + @active = false + return + + @enable() + @active = true + enable: -> # load in collection if needed meta = App.i18n.meta() @@ -37,7 +47,6 @@ class Widget extends App.Controller element.data 'before', element.text() element .on 'blur.translation', '.translation', (e) -> - console.log('blur') element = $(e.target) source = element.attr('title') @@ -65,7 +74,7 @@ class Widget extends App.Controller locale: App.i18n.get() source: source target: translation_new - initial_target: '' + target_initial: '' ) translation.save() @@ -80,4 +89,4 @@ class Widget extends App.Controller # rerender controllers App.Event.trigger('ui:rerender') -App.Config.set( 'translation_inline', Widget, 'Widgets' ) \ No newline at end of file +App.Config.set('translation_inline', Widget, 'Widgets') diff --git a/app/assets/javascripts/app/lib/app_post/auth.coffee b/app/assets/javascripts/app/lib/app_post/auth.coffee index 1c08daa2a..72d401a6b 100644 --- a/app/assets/javascripts/app/lib/app_post/auth.coffee +++ b/app/assets/javascripts/app/lib/app_post/auth.coffee @@ -63,11 +63,11 @@ class App.Auth # update config for key, value of data.config - App.Config.set( key, value ) + App.Config.set(key, value) # refresh default collections if data.collections - App.Collection.resetCollections( data.collections ) + App.Collection.resetCollections(data.collections) # empty session App.Session.init() @@ -81,18 +81,18 @@ class App.Auth # set locale locale = window.navigator.userLanguage || window.navigator.language || 'en-us' - App.i18n.set( locale ) + App.i18n.set(locale) # rebuild navbar with new navbar items - App.Event.trigger( 'auth' ) - App.Event.trigger( 'auth:logout' ) - App.Event.trigger( 'ui:rerender' ) + App.Event.trigger('auth') + App.Event.trigger('auth:logout') + App.Event.trigger('ui:rerender') return false # clear local store if type isnt 'check' - App.Event.trigger( 'clearStore' ) + App.Event.trigger('clearStore') # update model definition if data.models @@ -103,33 +103,34 @@ class App.Auth # update config for key, value of data.config - App.Config.set( key, value ) + App.Config.set(key, value) # refresh default collections if data.collections - App.Collection.resetCollections( data.collections ) + App.Collection.resetCollections(data.collections) # load assets if data.assets - App.Collection.loadAssets( data.assets ) + App.Collection.loadAssets(data.assets) # store user data sessionUser = App.User.fullLocal(data.session.id) - App.Session.set( sessionUser ) + console.log('set', sessionUser) + App.Session.set(sessionUser) # trigger auth ok with new session data - App.Event.trigger( 'auth', data.session ) + App.Event.trigger('auth', data.session) # init of i18n - preferences = App.Session.get( 'preferences' ) + preferences = App.Session.get('preferences') if preferences && preferences.locale locale = preferences.locale if !locale locale = window.navigator.userLanguage || window.navigator.language || 'en-us' - App.i18n.set( locale ) + App.i18n.set(locale) - App.Event.trigger( 'auth:login', data.session ) - App.Event.trigger( 'ui:rerender' ) + App.Event.trigger('auth:login', data.session) + App.Event.trigger('ui:rerender') @_logout: (data) -> @@ -138,10 +139,10 @@ class App.Auth # empty session App.Session.init() - App.Event.trigger( 'auth' ) - App.Event.trigger( 'auth:logout' ) - App.Event.trigger( 'ui:rerender' ) - App.Event.trigger( 'clearStore' ) + App.Event.trigger('auth') + App.Event.trigger('auth:logout') + App.Event.trigger('ui:rerender') + App.Event.trigger('clearStore') @_loginError: -> App.Log.error 'Auth', '_loginError:error' @@ -150,7 +151,7 @@ class App.Auth App.Session.init() # rebuild navbar - App.Event.trigger( 'auth' ) - App.Event.trigger( 'auth:logout' ) - App.Event.trigger( 'ui:rerender' ) - App.Event.trigger( 'clearStore' ) + App.Event.trigger('auth') + App.Event.trigger('auth:logout') + App.Event.trigger('ui:rerender') + App.Event.trigger('clearStore') diff --git a/app/assets/javascripts/app/lib/app_post/i18n.coffee b/app/assets/javascripts/app/lib/app_post/i18n.coffee index aef9cef14..f0b1ba8c7 100644 --- a/app/assets/javascripts/app/lib/app_post/i18n.coffee +++ b/app/assets/javascripts/app/lib/app_post/i18n.coffee @@ -229,9 +229,15 @@ class _i18nSingleton extends Spine.Module setMap: (source, target, format = 'string') => if format is 'time' - @mapTime[source] = target + if target is '' + delete @mapTime[source] + else + @mapTime[source] = target else - @mapString[source] = target + if target is '' + delete @mapString[source] + else + @mapString[source] = target notTranslatedFeatureEnabled: (locale) -> if locale.substr(0,2) is 'en' diff --git a/app/assets/javascripts/app/lib/app_post/interface_handle.coffee b/app/assets/javascripts/app/lib/app_post/interface_handle.coffee index 0e7ce54fb..0679e76ed 100644 --- a/app/assets/javascripts/app/lib/app_post/interface_handle.coffee +++ b/app/assets/javascripts/app/lib/app_post/interface_handle.coffee @@ -28,13 +28,13 @@ class App.Run extends App.Controller @frontendTimeUpdate() # start navbars - @setupWidget( 'Navigations', 'nav', @el ) + @setupWidget('Navigations', 'nav', @el) # start widgets - @setupWidget( 'Widgets', 'widget', @el ) + @setupWidget('Widgets', 'widget', @el) # bind to fill selected text into - App.ClipBoard.bind( @el ) + App.ClipBoard.bind(@el) App.Event.trigger('app:ready') @@ -99,4 +99,4 @@ class App.Content extends App.ControllerWidgetPermanent Spine.Route.setup() -App.Config.set( 'content', App.Content, 'Widgets' ) +App.Config.set('content', App.Content, 'Widgets') diff --git a/app/assets/javascripts/app/views/translation/english.jst.eco b/app/assets/javascripts/app/views/translation/english.jst.eco deleted file mode 100644 index 28ab07823..000000000 --- a/app/assets/javascripts/app/views/translation/english.jst.eco +++ /dev/null @@ -1 +0,0 @@ -