diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/title.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/title.coffee index 159362533..5c45aa4a0 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/title.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/title.coffee @@ -5,10 +5,10 @@ class App.TicketZoomTitle extends App.ObserverController title: true events: - 'blur .ticket-title-update': 'update' + 'blur .js-objectTitle': 'update' renderPost: (object) => - @$('.ticket-title-update').ce({ + @$('.js-objectTitle').ce({ mode: 'textonly' multiline: false maxlength: 250 diff --git a/app/assets/javascripts/app/controllers/widget/keyboard_shortcuts.coffee b/app/assets/javascripts/app/controllers/widget/keyboard_shortcuts.coffee index 670487219..2fb8ec3e9 100644 --- a/app/assets/javascripts/app/controllers/widget/keyboard_shortcuts.coffee +++ b/app/assets/javascripts/app/controllers/widget/keyboard_shortcuts.coffee @@ -24,6 +24,12 @@ class App.KeyboardShortcutWidget extends Spine.Module constructor: -> @observerKeys() + @lastKey = undefined + + $(document).keyup((e) => + return if e.keyCode isnt 27 + @lastKey = undefined + ) observerKeys: => navigationHotkeys = 'alt+ctrl' @@ -41,9 +47,17 @@ class App.KeyboardShortcutWidget extends Spine.Module modifier += shortcut.key if shortcut.callback @log 'debug', 'bind for', modifier - $(document).bind('keydown', modifier, (e) -> + $(document).bind('keydown', modifier, (e) => e.preventDefault() - shortcut.callback() + if @lastKey && @lastKey.modifier is modifier && @lastKey.time + 5500 > new Date().getTime() + @lastKey.count += 1 + @lastKey.time = new Date().getTime() + else + @lastKey = + modifier: modifier + count: 1 + time: new Date().getTime() + shortcut.callback(shortcut, @lastKey, modifier) ) App.Event.bind('global-shortcut', (e) -> @@ -51,7 +65,7 @@ class App.KeyboardShortcutWidget extends Spine.Module for item in area.content for shortcut in item.shortcuts if shortcut.globalEvent is e - shortcut.callback() + shortcut.callback(shortcut) ) App.Config.set('keyboard_shortcuts', App.KeyboardShortcutWidget, 'Widgets') @@ -247,10 +261,38 @@ App.Config.set( key: 'y' hotkeys: true description: 'Copy current object number (e. g. Ticket#) into clipboard' - callback: -> + callback: (shortcut, lastKey, modifier) -> App.Event.trigger('keyboard_shortcuts_close') - text = $('.active.content .js-objectNumber').data('number') || '' - clipboard.copy(text) + text = $('.active.content .js-objectNumber').first().data('number') || '' + if lastKey && lastKey.count is 1 + clipboard.copy(text) + return + + title = $('.active.content .js-objectTitle').first().text() + if lastKey && lastKey.count is 2 + if title + text += ": #{title}" + clipboard.copy(text) + return + + url = window.location.toString() + if lastKey && lastKey.count is 3 + clipboard.copy( + 'text/plain': "#{text}: #{title}\n#{url}", + 'text/html': "#{text}: #{title}" + ) + } + { + keyPrefix: '2x' + key: 'y' + hotkeys: true + description: '...add object title' + } + { + keyPrefix: '3x' + key: 'y' + hotkeys: true + description: '...add object link url' } ] } diff --git a/app/assets/javascripts/app/views/keyboard_shortcuts.jst.eco b/app/assets/javascripts/app/views/keyboard_shortcuts.jst.eco index 9fa3d9c27..b572d69ae 100644 --- a/app/assets/javascripts/app/views/keyboard_shortcuts.jst.eco +++ b/app/assets/javascripts/app/views/keyboard_shortcuts.jst.eco @@ -6,8 +6,16 @@ <% for item in area.content: %> <% if item.where: %>
<%- @T(item.where) %>
<% end %> <% for shortcut in item.shortcuts: %> - <% if shortcut.hotkeys: %>ctrl alt <% end %> - <% if _.isArray(shortcut.key): %><% for key in shortcut.key: %> <%- key %><% end %> + <% if shortcut.hotkeys: %> + ctrl alt + <% end %> + <% if shortcut.keyPrefix: %> + <%= shortcut.keyPrefix %> + <% end %> + <% if _.isArray(shortcut.key): %> + <% for key in shortcut.key: %> + <%- key %> + <% end %> <% else: %> <%- shortcut.key %> <% end %> @@ -24,8 +32,16 @@ <% for item in area.content: %> <% if item.where: %><%- @T(item.where) %>
<% end %> <% for shortcut in item.shortcuts: %> - <% if shortcut.hotkeys: %>ctrl alt <% end %> - <% if _.isArray(shortcut.key): %><% for key in shortcut.key: %> <%- key %><% end %> + <% if shortcut.hotkeys: %> + ctrl alt + <% end %> + <% if shortcut.keyPrefix: %> + <%= shortcut.keyPrefix %> + <% end %> + <% if _.isArray(shortcut.key): %> + <% for key in shortcut.key: %> + <%- key %> + <% end %> <% else: %> <%- shortcut.key %> <% end %> diff --git a/app/assets/javascripts/app/views/ticket_zoom/title.jst.eco b/app/assets/javascripts/app/views/ticket_zoom/title.jst.eco index e79d67457..c4d66f32c 100644 --- a/app/assets/javascripts/app/views/ticket_zoom/title.jst.eco +++ b/app/assets/javascripts/app/views/ticket_zoom/title.jst.eco @@ -1 +1 @@ -