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 @@ -
<%= @object.title %>
\ No newline at end of file +
<%= @object.title %>
\ No newline at end of file diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index a84f00b2e..c037cf41b 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -1808,28 +1808,28 @@ wait untill text in selector disabppears data = params[:data] if data[:title] - #element = instance.find_elements(:css => '.content.active .ticketZoom-header .ticket-title-update')[0] + #element = instance.find_elements(:css => '.content.active .ticketZoom-header .js-objectTitle')[0] #element.clear #sleep 0.5 - #element = instance.find_elements(:css => '.content.active .ticketZoom-header .ticket-title-update')[0] + #element = instance.find_elements(:css => '.content.active .ticketZoom-header .js-objectTitle')[0] #element.send_keys(data[:title]) #sleep 0.5 #element.send_keys(:tab) - instance.execute_script('$(".content.active .ticketZoom-header .ticket-title-update").focus()') - instance.execute_script('$(".content.active .ticketZoom-header .ticket-title-update").text("' + data[:title] + '")') - instance.execute_script('$(".content.active .ticketZoom-header .ticket-title-update").blur()') - instance.execute_script('$(".content.active .ticketZoom-header .ticket-title-update").trigger("blur")') + instance.execute_script('$(".content.active .ticketZoom-header .js-objectTitle").focus()') + instance.execute_script('$(".content.active .ticketZoom-header .js-objectTitle").text("' + data[:title] + '")') + instance.execute_script('$(".content.active .ticketZoom-header .js-objectTitle").blur()') + instance.execute_script('$(".content.active .ticketZoom-header .js-objectTitle").trigger("blur")') # { # :where => :instance2, # :execute => 'sendkey', - # :css => '.content.active .ticketZoom-header .ticket-title-update', + # :css => '.content.active .ticketZoom-header .js-objectTitle', # :value => 'TTT', # }, # { # :where => :instance2, # :execute => 'sendkey', - # :css => '.content.active .ticketZoom-header .ticket-title-update', + # :css => '.content.active .ticketZoom-header .js-objectTitle', # :value => :tab, # }, end @@ -2007,7 +2007,7 @@ wait untill text in selector disabppears data = params[:data] if data[:title] - title = instance.find_elements(css: '.content.active .ticketZoom-header .ticket-title-update')[0].text.strip + title = instance.find_elements(css: '.content.active .ticketZoom-header .js-objectTitle')[0].text.strip if title =~ /#{data[:title]}/i assert(true, "matching '#{data[:title]}' in title '#{title}'") else @@ -2136,7 +2136,7 @@ wait untill text in selector disabppears #instance.find_element(partial_link_text: params[:title] } ).click instance.execute_script("$(\"#global-search-result a:contains('#{params[:title]}') .nav-tab-icon\").click()") sleep 1 - title = instance.find_elements(css: '.active .ticketZoom-header .ticket-title-update')[0].text + title = instance.find_elements(css: '.active .ticketZoom-header .js-objectTitle')[0].text if title !~ /#{params[:title]}/ screenshot(browser: instance, comment: 'ticket_open_by_title_failed') raise "unable to search/find ticket #{params[:title]}!"