diff --git a/app/assets/javascripts/app/controllers/_application_controller/_base.coffee b/app/assets/javascripts/app/controllers/_application_controller/_base.coffee index c7a189014..153830caa 100644 --- a/app/assets/javascripts/app/controllers/_application_controller/_base.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller/_base.coffee @@ -77,8 +77,7 @@ class App.Controller extends Spine.Controller # release bindings if @el - @el.undelegate() - @el.unbind() + @el.off() @el.empty() # release spine bindings (see release() of spine.coffee) @@ -220,7 +219,7 @@ class App.Controller extends Spine.Controller userInfo: (data) -> el = data.el || $('[data-id="customer_info"]') - el.unbind() + el.off() # start customer info controller new App.WidgetUser( diff --git a/app/assets/javascripts/app/controllers/_application_controller/_modal.coffee b/app/assets/javascripts/app/controllers/_application_controller/_modal.coffee index d12ba79cf..28bbc692a 100644 --- a/app/assets/javascripts/app/controllers/_application_controller/_modal.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller/_modal.coffee @@ -181,7 +181,7 @@ class App.ControllerModal extends App.Controller form = @el # focus first input, select or textarea - form.find('input:not([disabled]):not([type="hidden"]):not(".btn"), select:not([disabled]), textarea:not([disabled])').first().focus() + form.find('input:not([disabled]):not([type="hidden"]):not(".btn"), select:not([disabled]), textarea:not([disabled])').first().trigger('focus') @initalFormParams = @formParams() diff --git a/app/assets/javascripts/app/controllers/_application_controller/_modal_generic_history.coffee b/app/assets/javascripts/app/controllers/_application_controller/_modal_generic_history.coffee index f603d77c6..228190c1f 100644 --- a/app/assets/javascripts/app/controllers/_application_controller/_modal_generic_history.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller/_modal_generic_history.coffee @@ -18,7 +18,7 @@ class App.GenericHistory extends App.ControllerModal content = $ App.view('generic/history')( items: localItem ) - content.find('a[data-type="sortorder"]').bind('click', (e) => + content.find('a[data-type="sortorder"]').on('click', (e) => e.preventDefault() @sortorder() ) diff --git a/app/assets/javascripts/app/controllers/_application_controller/form.coffee b/app/assets/javascripts/app/controllers/_application_controller/form.coffee index 01e1ec987..926ca719e 100644 --- a/app/assets/javascripts/app/controllers/_application_controller/form.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller/form.coffee @@ -34,11 +34,8 @@ class App.ControllerForm extends App.Controller @form.prepend('
') @form.prepend('') - # Fix for Issue #2510 - Zammad Customers shown as Agents in IE - # Previously the handlers are called directly, before the DOM elements are ready, thereby causing a race condition under IE11. - # Now we only dispatch the handlers after the DOM is ready. if @handlers.length - $(@dispatchHandlers) + @dispatchHandlers() # if element is given, prepend form to it if @el @@ -160,7 +157,7 @@ class App.ControllerForm extends App.Controller for eventSelector, callback of @events do (eventSelector, callback) -> evs = eventSelector.split(' ') - fieldset.find(evs[1]).bind(evs[0], (e) -> callback(e)) + fieldset.find(evs[1]).on(evs[0], (e) -> callback(e)) # bind tool tips fieldset.find('.js-helpMessage').tooltip() @@ -316,7 +313,7 @@ class App.ControllerForm extends App.Controller item_bind = item.find('.richtext-content') item_event = 'blur' - item_bind.bind(item_event, (e) => + item_bind.on(item_event, (e) => @lastChangedAttribute = attribute.name params = App.ControllerForm.params(@form) for handler in @handlers @@ -787,7 +784,7 @@ class App.ControllerForm extends App.Controller # set autofocus by delay to make validation testable App.Delay.set( -> - lookupForm.find('.has-error').find('input, textarea, select').first().focus() + lookupForm.find('.has-error').find('input, textarea, select').first().trigger('focus') 200 'validate' ) diff --git a/app/assets/javascripts/app/controllers/_application_controller/reorder_modal.coffee b/app/assets/javascripts/app/controllers/_application_controller/reorder_modal.coffee index 0419c69eb..e18ee2f25 100644 --- a/app/assets/javascripts/app/controllers/_application_controller/reorder_modal.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller/reorder_modal.coffee @@ -21,7 +21,7 @@ class App.ControllerReorderModal extends App.ControllerModal onShown: -> super - @$('.js-submit').focus() + @$('.js-submit').trigger('focus') save: -> ids = @$('tr.item').toArray().map (el) -> parseInt(el.dataset.id) diff --git a/app/assets/javascripts/app/controllers/_application_controller/table.coffee b/app/assets/javascripts/app/controllers/_application_controller/table.coffee index a1d9db8d7..6144ec66b 100644 --- a/app/assets/javascripts/app/controllers/_application_controller/table.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller/table.coffee @@ -406,7 +406,7 @@ class App.ControllerTable extends App.Controller if @bindCheckbox.events for event, callback of @bindCheckbox.events do (table, event, callback) -> - table.delegate('input[name="bulk"]', event, (e) -> + table.on(event, 'input[name="bulk"]', (e) -> e.stopPropagation() id = $(e.currentTarget).parents('tr').data('id') checked = $(e.currentTarget).prop('checked') @@ -424,12 +424,12 @@ class App.ControllerTable extends App.Controller if @checkbox # click first tr>td, catch click - table.delegate('tr > td:nth-child(1)', 'click', (e) -> + table.on('click', 'tr > td:nth-child(1)', (e) -> e.stopPropagation() ) # bind on full bulk click - table.delegate('input[name="bulk_all"]', 'change', (e) => + table.on('change', 'input[name="bulk_all"]', (e) => e.stopPropagation() clicks = [] if $(e.currentTarget).prop('checked') diff --git a/app/assets/javascripts/app/controllers/_application_controller/wizard_modal.coffee b/app/assets/javascripts/app/controllers/_application_controller/wizard_modal.coffee index 846f77c42..07dc8574f 100644 --- a/app/assets/javascripts/app/controllers/_application_controller/wizard_modal.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller/wizard_modal.coffee @@ -20,7 +20,7 @@ class App.ControllerWizardModal extends App.ControllerFullPage @hideAlert(name) @$('.setup.wizard').addClass('hide') @$(".setup.wizard.#{name}").removeClass('hide') - @$(".setup.wizard.#{name} input, .setup.wizard.#{name} select").first().focus() + @$(".setup.wizard.#{name} input, .setup.wizard.#{name} select").first().trigger('focus') showAlert: (screen, message) => @$(".#{screen}").find('.alert').first().removeClass('hide').text(App.i18n.translatePlain(message)) diff --git a/app/assets/javascripts/app/controllers/_channel/chat.coffee b/app/assets/javascripts/app/controllers/_channel/chat.coffee index 5c38a54d5..323faa559 100644 --- a/app/assets/javascripts/app/controllers/_channel/chat.coffee +++ b/app/assets/javascripts/app/controllers/_channel/chat.coffee @@ -204,7 +204,7 @@ class ChannelChat extends App.ControllerSubContent onUrlSubmit: (event) -> event.preventDefault() if event - @urlInput.focus() + @urlInput.trigger('focus') @changeDemoWebsite() changeDemoWebsite: -> diff --git a/app/assets/javascripts/app/controllers/_channel/email.coffee b/app/assets/javascripts/app/controllers/_channel/email.coffee index 995148038..a7ada3b61 100644 --- a/app/assets/javascripts/app/controllers/_channel/email.coffee +++ b/app/assets/javascripts/app/controllers/_channel/email.coffee @@ -610,11 +610,11 @@ class ChannelEmailAccountWizard extends App.ControllerWizardModal if !verify @$('.js-inbound-acknowledge .js-back').attr('data-slide', 'js-inbound') - @$('.js-inbound-acknowledge .js-next').unbind('click.verify') + @$('.js-inbound-acknowledge .js-next').off('click.verify') else @$('.js-inbound-acknowledge .js-back').attr('data-slide', 'js-intro') @$('.js-inbound-acknowledge .js-next').attr('data-slide', '') - @$('.js-inbound-acknowledge .js-next').unbind('click.verify').bind('click.verify', (e) => + @$('.js-inbound-acknowledge .js-next').off('click.verify').on('click.verify', (e) => e.preventDefault() @verify(@account) ) diff --git a/app/assets/javascripts/app/controllers/_channel/sms.coffee b/app/assets/javascripts/app/controllers/_channel/sms.coffee index 50b5364a4..6628ef3eb 100644 --- a/app/assets/javascripts/app/controllers/_channel/sms.coffee +++ b/app/assets/javascripts/app/controllers/_channel/sms.coffee @@ -170,7 +170,7 @@ class ChannelSmsAccount extends App.ControllerModal params: @channel ) @renderAdapterOptions(@channel.options?.adapter, el) - el.find('[name="options::adapter"]').bind('change', (e) => + el.find('[name="options::adapter"]').on('change', (e) => @renderAdapterOptions(e.target.value, el) ) el @@ -309,7 +309,7 @@ class ChannelSmsNotification extends App.ControllerModal params: @channel ) @renderAdapterOptions(@channel.options?.adapter, el) - el.find('[name="options::adapter"]').bind('change', (e) => + el.find('[name="options::adapter"]').on('change', (e) => @renderAdapterOptions(e.target.value, el) ) el diff --git a/app/assets/javascripts/app/controllers/_channel/twitter.coffee b/app/assets/javascripts/app/controllers/_channel/twitter.coffee index 756462846..f50141315 100644 --- a/app/assets/javascripts/app/controllers/_channel/twitter.coffee +++ b/app/assets/javascripts/app/controllers/_channel/twitter.coffee @@ -219,7 +219,7 @@ class AccountEdit extends App.ControllerModal term: '' group_id: '' renderSearchTerms() - content.find('.js-searchTermList [name="search::term"]').last().focus() + content.find('.js-searchTermList [name="search::term"]').last().trigger('focus') removeSearchTerm = (event) => index = $(event.currentTarget).attr('data-index') @@ -248,7 +248,7 @@ class AccountEdit extends App.ControllerModal renderSearchTerms() - content.find('.js-searchTermAdd').click(addSearchTerm) + content.find('.js-searchTermAdd').on('click', addSearchTerm) content.find('.js-searchTermList').on('click', '.js-searchTermRemove', removeSearchTerm) content.find('.js-mentionsGroup').replaceWith createGroupSelection(@channel.options.sync.mentions.group_id, 'mentions') diff --git a/app/assets/javascripts/app/controllers/_plugin/global_search.coffee b/app/assets/javascripts/app/controllers/_plugin/global_search.coffee index 655d39661..8fdb74b62 100644 --- a/app/assets/javascripts/app/controllers/_plugin/global_search.coffee +++ b/app/assets/javascripts/app/controllers/_plugin/global_search.coffee @@ -27,7 +27,7 @@ class App.GlobalSearchWidget extends App.Controller $('#global-search').val(currentValue) delay = -> - $('#global-search').focus() + $('#global-search').trigger('focus') App.Delay.set(delay, 20, 'global-search-delay') ) diff --git a/app/assets/javascripts/app/controllers/_plugin/keyboard_shortcuts.coffee b/app/assets/javascripts/app/controllers/_plugin/keyboard_shortcuts.coffee index 7dcf18c4a..022ae6a75 100644 --- a/app/assets/javascripts/app/controllers/_plugin/keyboard_shortcuts.coffee +++ b/app/assets/javascripts/app/controllers/_plugin/keyboard_shortcuts.coffee @@ -33,13 +33,13 @@ class App.KeyboardShortcutWidget extends App.Controller @observerKeys() @lastKey = undefined - $(document).keyup((e) => + $(document).on('keyup', (e) => return if e.keyCode isnt 27 @lastKey = undefined ) observerKeys: => - $(document).unbind('keydown.shortcuts') + $(document).off('keydown.shortcuts') navigationHotkeys = App.Browser.hotkeys() areas = App.Config.get('keyboard_shortcuts') @@ -56,7 +56,7 @@ class App.KeyboardShortcutWidget extends App.Controller modifier += shortcut.key if shortcut.callback @log 'debug', 'bind for', modifier - $(document).bind('keydown.shortcuts', modifier, (e) => + $(document).on('keydown.shortcuts', {keys: modifier}, (e) => e.preventDefault() if @lastKey && @lastKey.modifier is modifier && @lastKey.time + 5500 > new Date().getTime() @lastKey.count += 1 @@ -94,7 +94,7 @@ App.Config.set( description: __('Dashboard') globalEvent: 'dashboard' callback: -> - $('#global-search').blur() + $('#global-search').trigger('blur') App.Event.trigger('keyboard_shortcuts_close') window.location.hash = '#dashboard' } @@ -104,7 +104,7 @@ App.Config.set( description: __('Overviews') globalEvent: 'overview' callback: -> - $('#global-search').blur() + $('#global-search').trigger('blur') App.Event.trigger('keyboard_shortcuts_close') window.location.hash = '#ticket/view' } @@ -115,7 +115,7 @@ App.Config.set( globalEvent: 'search' callback: -> App.Event.trigger('keyboard_shortcuts_close') - $('#global-search').focus() + $('#global-search').trigger('focus') } { key: 'a' @@ -123,9 +123,9 @@ App.Config.set( description: __('Notifications') globalEvent: 'notification' callback: -> - $('#global-search').blur() + $('#global-search').trigger('blur') App.Event.trigger('keyboard_shortcuts_close') - $('#navigation .js-toggleNotifications').click() + $('#navigation .js-toggleNotifications').trigger('click') } { key: 'n' @@ -133,7 +133,7 @@ App.Config.set( description: __('New Ticket') globalEvent: 'new-ticket' callback: -> - $('#global-search').blur() + $('#global-search').trigger('blur') App.Event.trigger('keyboard_shortcuts_close') window.location.hash = '#ticket/create' } @@ -168,7 +168,7 @@ App.Config.set( globalEvent: 'close-current-tab' callback: -> App.Event.trigger('keyboard_shortcuts_close') - $('#navigation .tasks .is-active .js-close').click() + $('#navigation .tasks .is-active .js-close').trigger('click') } { key: 'tab' @@ -185,12 +185,12 @@ App.Config.set( if current.get(0) next = current.next() if next.get(0) - next.find('div').first().click() + next.find('div').first().trigger('click') scollIfNeeded(next) return prev = $('#navigation .tasks .task').first() if prev.get(0) - prev.find('div').first().click() + prev.find('div').first().trigger('click') scollIfNeeded(prev) } { @@ -208,12 +208,12 @@ App.Config.set( if current.get(0) prev = current.prev() if prev.get(0) - prev.find('div').first().click() + prev.find('div').first().trigger('click') scollIfNeeded(prev) return last = $('#navigation .tasks .task').last() if last.get(0) - last.find('div').first().click() + last.find('div').first().trigger('click') scollIfNeeded(last) } { @@ -227,24 +227,24 @@ App.Config.set( # check of primary modal exists dialog = $('body > div.modal') if dialog.get(0) - dialog.find('.js-submit').click() + dialog.find('.js-submit').trigger('click') return # check of local modal exists dialog = $('.active.content > div.modal') if dialog.get(0) - dialog.find('.js-submit').click() + dialog.find('.js-submit').trigger('click') return # check ticket edit dialog = $('.active.content .js-attributeBar .js-submit') if dialog.get(0) - dialog.first().click() + dialog.first().trigger('click') return dialog = $('.active.content .js-submit') if dialog.get(0) - dialog.first().click() + dialog.first().trigger('click') return } ] @@ -342,8 +342,8 @@ App.Config.set( globalEvent: 'article-note-open' callback: -> App.Event.trigger('keyboard_shortcuts_close') - $('.active.content .editControls .js-articleTypes [data-value="note"]').click() - $('.active.content .article-new .articleNewEdit-body').first().focus() + $('.active.content .editControls .js-articleTypes [data-value="note"]').trigger('click') + $('.active.content .article-new .articleNewEdit-body').first().trigger('focus') } { key: 'g' @@ -355,9 +355,9 @@ App.Config.set( lastArticleWithReply = $('.active.content .ticket-article .icon-reply').last() lastArticleWithReplyAll = lastArticleWithReply.parent().find('.icon-reply-all') if lastArticleWithReplyAll.get(0) - lastArticleWithReplyAll.click() + lastArticleWithReplyAll.trigger('click') return - lastArticleWithReply.click() + lastArticleWithReply.trigger('click') } { key: 'j' @@ -366,7 +366,7 @@ App.Config.set( globalEvent: 'article-internal-public' callback: -> App.Event.trigger('keyboard_shortcuts_close') - $('.active.content .editControls .js-selectInternalPublic').click() + $('.active.content .editControls .js-selectInternalPublic').trigger('click') } #{ # key: 'm' @@ -385,7 +385,7 @@ App.Config.set( App.Event.trigger('keyboard_shortcuts_close') return if !$('.active.content .edit').get(0) $('.active.content .edit [name="state_id"]').val(4) - $('.active.content .js-attributeBar .js-submit').first().click() + $('.active.content .js-attributeBar .js-submit').first().trigger('click') } { key: ['◀', '▶'] diff --git a/app/assets/javascripts/app/controllers/_plugin/navigation.coffee b/app/assets/javascripts/app/controllers/_plugin/navigation.coffee index 24f359acf..fbd75c22d 100644 --- a/app/assets/javascripts/app/controllers/_plugin/navigation.coffee +++ b/app/assets/javascripts/app/controllers/_plugin/navigation.coffee @@ -256,7 +256,7 @@ class Navigation extends App.Controller @nudge(e, 1) return else if e.keyCode is 13 # enter - @searchInput.blur() + @searchInput.trigger('blur') href = @$('.global-search-result .nav-tab.is-hover').attr('href') if href @navigate(href) diff --git a/app/assets/javascripts/app/controllers/_plugin/notify.coffee b/app/assets/javascripts/app/controllers/_plugin/notify.coffee index 3637edd7f..bdfe86deb 100644 --- a/app/assets/javascripts/app/controllers/_plugin/notify.coffee +++ b/app/assets/javascripts/app/controllers/_plugin/notify.coffee @@ -54,7 +54,8 @@ class App.Notify extends App.Controller if App.Session.get() isnt undefined && window.Notification window.Notification.requestPermission() - $(window).focus( + $(window).on( + 'focus', => for counter, notification of @desktopNotify notification.close() diff --git a/app/assets/javascripts/app/controllers/_ui_element/_application_selector.coffee b/app/assets/javascripts/app/controllers/_ui_element/_application_selector.coffee index b0cfa7f4d..e0b6d95e6 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/_application_selector.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/_application_selector.coffee @@ -162,7 +162,7 @@ class App.UiElement.ApplicationSelector item = $( App.view('generic/application_selector')(attribute: attribute) ) # add filter - item.delegate('.js-add', 'click', (e) => + item.on('click', '.js-add', (e) => element = $(e.target).closest('.js-filterElement') # add first available attribute @@ -191,7 +191,7 @@ class App.UiElement.ApplicationSelector ) # remove filter - item.delegate('.js-remove', 'click', (e) => + item.on('click', '.js-remove', (e) => return if $(e.currentTarget).hasClass('is-disabled') if @hasEmptySelectorAtStart() @@ -229,7 +229,7 @@ class App.UiElement.ApplicationSelector item.filter('.js-filter').append(row) # change attribute selector - item.delegate('.js-attributeSelector select', 'change', (e) => + item.on('change', '.js-attributeSelector select', (e) => elementRow = $(e.target).closest('.js-filterElement') groupAndAttribute = elementRow.find('.js-attributeSelector option:selected').attr('value') return if !groupAndAttribute @@ -238,7 +238,7 @@ class App.UiElement.ApplicationSelector ) # change operator selector - item.delegate('.js-operator select', 'change', (e) => + item.on('change', '.js-operator select', (e) => elementRow = $(e.target).closest('.js-filterElement') groupAndAttribute = elementRow.find('.js-attributeSelector option:selected').attr('value') return if !groupAndAttribute @@ -335,7 +335,7 @@ class App.UiElement.ApplicationSelector if !@hasDuplicateSelector() # enable all - elementFull.find('.js-attributeSelector select option').removeAttr('disabled') + elementFull.find('.js-attributeSelector select option').prop('disabled', false) # disable all used attributes elementFull.find('.js-attributeSelector select').each(-> @@ -460,7 +460,7 @@ class App.UiElement.ApplicationSelector elementRow.find('.js-preCondition').closest('.controls').removeClass('hide') elementRow.find('.js-preCondition select').replaceWith(selection) - elementRow.find('.js-preCondition select').bind('change', (e) -> + elementRow.find('.js-preCondition select').on('change', (e) -> toggleValue() ) diff --git a/app/assets/javascripts/app/controllers/_ui_element/basedate.coffee b/app/assets/javascripts/app/controllers/_ui_element/basedate.coffee index 5796a2345..9abbd84cd 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/basedate.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/basedate.coffee @@ -47,14 +47,14 @@ class App.UiElement.basedate @bindEvents: (item, attribute) -> item .find('input') - .bind('focus', (e) -> + .on('focus', (e) -> item.find('.js-datepicker').datepicker('rerender') - ).bind('keyup blur change', (e) => + ).on('keyup blur change', (e) => @setNewTime(item, attribute, 0) @validation(item, attribute, true) ) - item.bind('validate', (e) => + item.on('validate', (e) => @validation(item, attribute) ) diff --git a/app/assets/javascripts/app/controllers/_ui_element/holiday_selector.coffee b/app/assets/javascripts/app/controllers/_ui_element/holiday_selector.coffee index b2fcc24f3..9542abc8d 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/holiday_selector.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/holiday_selector.coffee @@ -24,7 +24,7 @@ class App.UiElement.holiday_selector item.find('.js-datePicker').html(datePicker) # set active/inactive of date - item.delegate('.js-active', 'click', (e) -> + item.on('click', '.js-active', (e) -> active = $(e.target).prop('checked') row = $(e.target).closest('tr') input = $(e.target).closest('tr').find('.js-summary') @@ -39,19 +39,19 @@ class App.UiElement.holiday_selector ) # remove date - item.delegate('.js-remove', 'click', (e) -> + item.on('click', '.js-remove', (e) -> $(e.target).closest('tr').remove() ) # catch enter / apply add - item.find('.js-summary').bind( 'keydown', (e) -> + item.find('.js-summary').on( 'keydown', (e) -> return if e.which isnt 13 e.preventDefault() - item.find('.js-add').click() + item.find('.js-add').trigger('click') ) # add date - item.find('.js-add').bind('click', (e) -> + item.find('.js-add').on('click', (e) -> date = $(e.target).closest('tr').find('[name="{date}public_holidays_date"]').val() return if !date summary = $(e.target).closest('tr').find('.js-summary').val() diff --git a/app/assets/javascripts/app/controllers/_ui_element/ical_feed.coffee b/app/assets/javascripts/app/controllers/_ui_element/ical_feed.coffee index 45ae04d2e..d1c527147 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/ical_feed.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/ical_feed.coffee @@ -34,16 +34,16 @@ class App.UiElement.ical_feed extends App.UiElement.ApplicationUiElement updateCheckManual() item.find('.js-manual').val(attribute.value) - item.find('.js-check').bind('change', -> + item.find('.js-check').on('change', -> updateShadow() ) - item.find('.js-list').bind('click change', -> + item.find('.js-list').on('click change', -> updateCheckList() updateShadow('list') ) - item.find('.js-manual').bind('keyup focus blur', -> + item.find('.js-manual').on('keyup focus blur', -> updateCheckManual() updateShadow('manual') ) diff --git a/app/assets/javascripts/app/controllers/_ui_element/permission.coffee b/app/assets/javascripts/app/controllers/_ui_element/permission.coffee index a268a9f65..95cdff830 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/permission.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/permission.coffee @@ -26,7 +26,7 @@ class App.UiElement.permission extends App.UiElement.ApplicationUiElement ) ) # show/hide trees - item.find('[name=permission_ids]').bind('change', (e) => + item.find('[name=permission_ids]').on('change', (e) => @checkUncheck($(e.currentTarget), permissions, item) ) item.find('[name=permission_ids]').trigger('change') diff --git a/app/assets/javascripts/app/controllers/_ui_element/postmaster_match.coffee b/app/assets/javascripts/app/controllers/_ui_element/postmaster_match.coffee index 00841ee91..c9763fde5 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/postmaster_match.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/postmaster_match.coffee @@ -146,7 +146,7 @@ class App.UiElement.postmaster_match item.find('.js-attributeSelector').prepend(selector) # add filter - item.find('.js-add').bind('click', (e) -> + item.find('.js-add').on('click', (e) -> element = $(e.target).closest('.js-filterElement') elementClone = element.clone(true) element.after(elementClone) @@ -154,14 +154,14 @@ class App.UiElement.postmaster_match ) # remove filter - item.find('.js-remove').bind('click', (e) => + item.find('.js-remove').on('click', (e) => return if $(e.currentTarget).hasClass('is-disabled') $(e.target).closest('.js-filterElement').remove() @rebuildAttributeSelectors(item) ) # change attribute selector - item.find('.js-attributeSelector select').bind('change', (e) => + item.find('.js-attributeSelector select').on('change', (e) => key = $(e.target).find('option:selected').attr('value') elementRow = $(e.target).closest('.js-filterElement') @rebuildAttributeSelectors(item, elementRow, key, attribute) @@ -170,7 +170,7 @@ class App.UiElement.postmaster_match ) # change operator - item.find('.js-operator select').bind('change', (e) => + item.find('.js-operator select').on('change', (e) => key = $(e.target).find('.js-attributeSelector option:selected').attr('value') operator = $(e.target).find('option:selected').attr('value') elementRow = $(e.target).closest('.js-filterElement') @@ -233,7 +233,7 @@ class App.UiElement.postmaster_match @rebuildAttributeSelectors: (elementFull, elementRow, key, attribute) -> # enable all - elementFull.find('.js-attributeSelector select option').removeAttr('disabled') + elementFull.find('.js-attributeSelector select option').prop('disabled', false) # disable all used attributes elementFull.find('.js-attributeSelector select').each(-> diff --git a/app/assets/javascripts/app/controllers/_ui_element/postmaster_set.coffee b/app/assets/javascripts/app/controllers/_ui_element/postmaster_set.coffee index fa58e019f..ccf44043a 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/postmaster_set.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/postmaster_set.coffee @@ -198,7 +198,10 @@ class App.UiElement.postmaster_set config['tag'] = 'input' config['type'] = 'text' config['name'] = name - config['value'] = value + if !value && attribute.value && attribute.value[key] + config['value'] = attribute.value[key].value + else + config['value'] = value item = App.UiElement[config.tag].render(config, {}) elementRow.find('.js-value').html(item) @@ -227,7 +230,7 @@ class App.UiElement.postmaster_set @rebuildAttributeSelectors: (elementFull, elementRow, key, attribute) -> # enable all - elementFull.find('.js-attributeSelector select option').removeAttr('disabled') + elementFull.find('.js-attributeSelector select option').prop('disabled', false) # disable all used attributes elementFull.find('.js-attributeSelector select').each(-> diff --git a/app/assets/javascripts/app/controllers/_ui_element/richtext.coffee b/app/assets/javascripts/app/controllers/_ui_element/richtext.coffee index 757ebaa03..aafeb949c 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/richtext.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/richtext.coffee @@ -12,7 +12,7 @@ class App.UiElement.richtext buttons: attribute.buttons ) - item.find('a.btn--action[data-action]').click (event) => @toolButtonClicked(event, form) + item.find('a.btn--action[data-action]').on 'click', (event) => @toolButtonClicked(event, form) if attribute.plugins for plugin in attribute.plugins diff --git a/app/assets/javascripts/app/controllers/_ui_element/select.coffee b/app/assets/javascripts/app/controllers/_ui_element/select.coffee index a7996c125..86d470416 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/select.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/select.coffee @@ -45,7 +45,7 @@ class App.UiElement.select extends App.UiElement.ApplicationUiElement @bindEventListeners: (item, attribute, params) -> if attribute.display_warn - item.bind('change', (e) => + item.on('change', (e) => @bindWarnDisplayListener(e.target.value, attribute, params, item) ) diff --git a/app/assets/javascripts/app/controllers/_ui_element/sla_times.coffee b/app/assets/javascripts/app/controllers/_ui_element/sla_times.coffee index 2bf72247d..77a8daa28 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/sla_times.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/sla_times.coffee @@ -23,7 +23,7 @@ class App.UiElement.sla_times ) # disable/enable rows - item.find('.js-activateRow').bind('change', (e) -> + item.find('.js-activateRow').on('change', (e) -> element = $(e.target) row = element.closest('tr') if element.prop('checked') @@ -43,7 +43,7 @@ class App.UiElement.sla_times ) # convert hours into minutes - item.find('.js-timeConvertFrom').bind('keyup focus blur', (e) => + item.find('.js-timeConvertFrom').on('keyup focus blur', (e) => element = $(e.target) inText = element.val() @@ -62,12 +62,12 @@ class App.UiElement.sla_times ) # toggle row on clicking name cell - item.find('.js-forward-click').bind('click', (e) -> - $(e.currentTarget).closest('tr').find('.checkbox-replacement').click() + item.find('.js-forward-click').on('click', (e) -> + $(e.currentTarget).closest('tr').find('.checkbox-replacement').trigger('click') ) # toggle update type on clicking around the element - item.find('.js-forward-radio').bind('click', (e) -> + item.find('.js-forward-radio').on('click', (e) -> elem = $(e.currentTarget).closest('p').find('.js-updateTypeSelector') elem.prop('checked', true) @@ -75,20 +75,20 @@ class App.UiElement.sla_times ) # focus time input on clicking surrounding cell - item.find('.js-focus-input').bind('click', (e) -> + item.find('.js-focus-input').on('click', (e) -> $(e.currentTarget) .find('.form-control:visible') - .focus() + .trigger('focus') ) # show placeholder instead of 00:00 - item.find('.js-timeConvertFrom').bind('changeTime.timepicker', (e) -> + item.find('.js-timeConvertFrom').on('changeTime.timepicker', (e) -> if $(e.currentTarget).val() == '00:00' $(e.currentTarget).val('') ) # switch update/response times when type is selected accordingly - item.find('.js-updateTypeSelector').bind('change', (e) -> + item.find('.js-updateTypeSelector').on('change', (e) -> element = $(e.target) row = element.closest('tr') row.find('.js-activateRow').prop('checked', true) diff --git a/app/assets/javascripts/app/controllers/_ui_element/textarea.coffee b/app/assets/javascripts/app/controllers/_ui_element/textarea.coffee index 4ed6e555f..eca0d9e69 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/textarea.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/textarea.coffee @@ -12,7 +12,7 @@ class App.UiElement.textarea $( item[0] ).on('focus', -> visible = $( item[0] ).is(':visible') if visible && !$( item[0] ).expanding('active') - $( item[0] ).expanding().focus() + $( item[0] ).expanding().trigger('focus') ) App.Delay.set(a, 80) diff --git a/app/assets/javascripts/app/controllers/_ui_element/ticket_perform_action.coffee b/app/assets/javascripts/app/controllers/_ui_element/ticket_perform_action.coffee index 341fcd5d7..93f185047 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/ticket_perform_action.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/ticket_perform_action.coffee @@ -163,7 +163,7 @@ class App.UiElement.ticket_perform_action @updateAttributeSelectors: (elementFull) -> # enable all - elementFull.find('.js-attributeSelector select option').removeAttr('disabled') + elementFull.find('.js-attributeSelector select option').prop('disabled', false) # disable all used attributes elementFull.find('.js-attributeSelector select').each(-> @@ -292,7 +292,7 @@ class App.UiElement.ticket_perform_action elementRow.find('.js-preCondition').closest('.controls').removeClass('hide') elementRow.find('.js-preCondition select').replaceWith(selection) - elementRow.find('.js-preCondition select').bind('change', (e) -> + elementRow.find('.js-preCondition select').on('change', (e) -> toggleValue() ) diff --git a/app/assets/javascripts/app/controllers/_ui_element/timer.coffee b/app/assets/javascripts/app/controllers/_ui_element/timer.coffee index 24971f15e..cc6a4a7e6 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/timer.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/timer.coffee @@ -81,7 +81,7 @@ class App.UiElement.timer timer = $( App.view('generic/timer')( attribute: attribute, days: days, hours: hours, minutes: minutes ) ) timer.find('.js-boolean').data('field-type', 'boolean') - timer.find('.select-value').bind('click', (e) => + timer.find('.select-value').on('click', (e) => @select(e) ) @createOutputString(timer) @@ -93,7 +93,7 @@ class App.UiElement.timer if target.hasClass('is-selected') # prevent zero selections - if target.siblings('.is-selected').size() > 0 + if target.siblings('.is-selected').length > 0 target.removeClass('is-selected') target.next().val('false') else diff --git a/app/assets/javascripts/app/controllers/_ui_element/user_permission.coffee b/app/assets/javascripts/app/controllers/_ui_element/user_permission.coffee index 877dce2db..16509e0d3 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/user_permission.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/user_permission.coffee @@ -88,7 +88,7 @@ class App.UiElement.user_permission item.on('click', '.checkbox-replacement', throttled) # if customer, remove admin and agent - item.find('[name=role_ids]').bind('change', (e) => + item.find('[name=role_ids]').on('change', (e) => @checkUncheck($(e.currentTarget), rolesWithGroupPlugin, item) ) item.find('[name=role_ids]').trigger('change') diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.coffee index ab954efdb..ecc02de68 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.coffee @@ -129,7 +129,7 @@ class App.TicketCreate extends App.Controller @$('[name="group_id"]').trigger('change') # add observer to change options - @$('[name="cc"], [name="group_id"], [name="customer_id"]').bind('change', => + @$('[name="cc"], [name="group_id"], [name="customer_id"]').on('change', => @updateSecurityOptions() ) @updateSecurityOptions() diff --git a/app/assets/javascripts/app/controllers/agent_ticket_merge.coffee b/app/assets/javascripts/app/controllers/agent_ticket_merge.coffee index e1d589779..e9d3fb63c 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_merge.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_merge.coffee @@ -49,11 +49,11 @@ class App.TicketMerge extends App.ControllerModal radio: true ) - content.delegate('[name="target_ticket_number"]', 'focus', (e) -> + content.on('focus', '[name="target_ticket_number"]', (e) -> $(e.target).parents().find('[name="radio"]').prop('checked', false) ) - content.delegate('[name="radio"]', 'click', (e) -> + content.on('click', '[name="radio"]', (e) -> if $(e.target).prop('checked') ticket_id = $(e.target).val() ticket = App.Ticket.fullLocal(ticket_id) diff --git a/app/assets/javascripts/app/controllers/chat.coffee b/app/assets/javascripts/app/controllers/chat.coffee index b334215ab..bf13e31df 100644 --- a/app/assets/javascripts/app/controllers/chat.coffee +++ b/app/assets/javascripts/app/controllers/chat.coffee @@ -508,7 +508,7 @@ class ChatWindow extends App.Controller ) @el.one('transitionend', @onTransitionend) - @scrollHolder.scroll(@detectScrolledtoBottom) + @scrollHolder.on('scroll', @detectScrolledtoBottom) # force repaint @el.prop('offsetHeight') @@ -568,7 +568,7 @@ class ChatWindow extends App.Controller ) focus: => - @input.focus() + @input.trigger('focus') onTransitionend: (event) => # chat window is done with animation - adjust scroll-bars @@ -628,7 +628,7 @@ class ChatWindow extends App.Controller switch event.keyCode when TABKEY allChatInputs = @input.not('[disabled="disabled"]') - chatCount = allChatInputs.size() + chatCount = allChatInputs.length index = allChatInputs.index(@input) if chatCount > 1 diff --git a/app/assets/javascripts/app/controllers/cti.coffee b/app/assets/javascripts/app/controllers/cti.coffee index 21d2af3de..d08a559d6 100644 --- a/app/assets/javascripts/app/controllers/cti.coffee +++ b/app/assets/javascripts/app/controllers/cti.coffee @@ -43,10 +43,10 @@ class App.CTI extends App.Controller item: @ringingCalls() ) $('.js-phoneMenuItem').after(localHtml) - $('.call-widget').find('.js-newUser').bind('click', (e) => + $('.call-widget').find('.js-newUser').on('click', (e) => @newUser(e) ) - $('.call-widget').find('.js-newTicket').bind('click', (e) => + $('.call-widget').find('.js-newTicket').on('click', (e) => user = undefined user_id = $(e.currentTarget).data('user-id') if user_id diff --git a/app/assets/javascripts/app/controllers/getting_started/base.coffee b/app/assets/javascripts/app/controllers/getting_started/base.coffee index 7737168ed..79088abfe 100644 --- a/app/assets/javascripts/app/controllers/getting_started/base.coffee +++ b/app/assets/javascripts/app/controllers/getting_started/base.coffee @@ -58,7 +58,7 @@ class GettingStartedBase extends App.ControllerWizardFullScreen logoUrl: @logoUrl() organization: organization ) - @$('input, select').first().focus() + @$('input, select').first().trigger('focus') onLogoPick: (event) => reader = new FileReader() diff --git a/app/assets/javascripts/app/controllers/getting_started/channel_email.coffee b/app/assets/javascripts/app/controllers/getting_started/channel_email.coffee index 98ff307fd..48548d553 100644 --- a/app/assets/javascripts/app/controllers/getting_started/channel_email.coffee +++ b/app/assets/javascripts/app/controllers/getting_started/channel_email.coffee @@ -243,11 +243,11 @@ class GettingStartedChannelEmail extends App.ControllerWizardFullScreen if !verify @$('.js-inbound-acknowledge .js-back').attr('data-slide', 'js-inbound') - @$('.js-inbound-acknowledge .js-next').unbind('click.verify') + @$('.js-inbound-acknowledge .js-next').off('click.verify') else @$('.js-inbound-acknowledge .js-back').attr('data-slide', 'js-intro') @$('.js-inbound-acknowledge .js-next').attr('data-slide', '') - @$('.js-inbound-acknowledge .js-next').unbind('click.verify').bind('click.verify', (e) => + @$('.js-inbound-acknowledge .js-next').off('click.verify').on('click.verify', (e) => e.preventDefault() @verify(@account) ) diff --git a/app/assets/javascripts/app/controllers/idoit_object_selector.coffee b/app/assets/javascripts/app/controllers/idoit_object_selector.coffee index 026e6cea2..4be75fa2a 100644 --- a/app/assets/javascripts/app/controllers/idoit_object_selector.coffee +++ b/app/assets/javascripts/app/controllers/idoit_object_selector.coffee @@ -31,7 +31,7 @@ class App.IdoitObjectSelector extends App.ControllerModal @search(params) ) @render() - @$('.js-input').focus() + @$('.js-input').trigger('focus') error: (xhr, status, error) => diff --git a/app/assets/javascripts/app/controllers/knowledge_base/reader_controller.coffee b/app/assets/javascripts/app/controllers/knowledge_base/reader_controller.coffee index c7d22496b..29134002f 100644 --- a/app/assets/javascripts/app/controllers/knowledge_base/reader_controller.coffee +++ b/app/assets/javascripts/app/controllers/knowledge_base/reader_controller.coffee @@ -96,7 +96,7 @@ class App.KnowledgeBaseReaderController extends App.Controller prepareLinks: (input) -> input = $($.parseHTML(input)) - for linkDom in input.find('a').andSelf('a').toArray() + for linkDom in input.find('a').addBack('a').toArray() switch $(linkDom).attr('data-target-type') when 'knowledge-base-answer' if object = App.KnowledgeBaseAnswerTranslation.find $(linkDom).attr('data-target-id') diff --git a/app/assets/javascripts/app/controllers/knowledge_base/search_field_widget.coffee b/app/assets/javascripts/app/controllers/knowledge_base/search_field_widget.coffee index dc97bffd8..1e10470fe 100644 --- a/app/assets/javascripts/app/controllers/knowledge_base/search_field_widget.coffee +++ b/app/assets/javascripts/app/controllers/knowledge_base/search_field_widget.coffee @@ -109,7 +109,7 @@ class App.KnowledgeBaseSearchFieldWidget extends App.Controller @renderResults?(data, originalQuery) focus: -> - @searchField.focus() + @searchField.trigger('focus') startSearch: (query) -> @searchField diff --git a/app/assets/javascripts/app/controllers/layout_ref.coffee b/app/assets/javascripts/app/controllers/layout_ref.coffee index 9c9995542..12a204fad 100644 --- a/app/assets/javascripts/app/controllers/layout_ref.coffee +++ b/app/assets/javascripts/app/controllers/layout_ref.coffee @@ -652,7 +652,7 @@ class ReferenceSetupWizard extends App.ControllerWizard } @agentEmail.add(@agentFirstName).add(@agentLastName).val('') - @agentFirstName.focus() + @agentFirstName.trigger('focus') App.Config.set( 'layout_ref/setup', ReferenceSetupWizard, 'Routes' ) @@ -709,7 +709,7 @@ class RichText extends App.ControllerAppContent App.Utils.htmlCleanup(textarea) # remove marker for cursor - textarea.find('[data-cursor=1]').focus() + textarea.find('[data-cursor=1]').trigger('focus') textarea.find('[data-cursor=1]').remove() @delay( execute, 1) @@ -953,11 +953,11 @@ class TicketZoomRef extends App.ControllerAppContent @closeDropdown() else @buttonDropdown.addClass 'is-open' - $(document).bind 'click.buttonDropdown', @closeDropdown + $(document).on 'click.buttonDropdown', @closeDropdown closeDropdown: => @buttonDropdown.removeClass 'is-open' - $(document).unbind 'click.buttonDropdown' + $(document).off 'click.buttonDropdown' performTicketMacro: (event) => console.log 'perform action', @$(event.currentTarget).text() @@ -1414,7 +1414,7 @@ class SchedulersRef extends App.ControllerAppContent if target.hasClass('is-selected') # prevent zero selections - if target.siblings('.is-selected').size() > 0 + if target.siblings('.is-selected').length > 0 target.removeClass('is-selected') else target.addClass('is-selected') @@ -2053,7 +2053,7 @@ class ChatWindowRef extends Spine.Controller switch event.keyCode when TABKEY allChatInputs = $('.js-customerChatInput').not('[disabled="disabled"]') - chatCount = allChatInputs.size() + chatCount = allChatInputs.length index = allChatInputs.index(@input) if chatCount > 1 @@ -2333,7 +2333,7 @@ class KnowledgeBaseAgentReaderRef extends App.ControllerAppContent if $(event.currentTarget).is('.btn--primary') @el.find('.main[data-level]').addClass('hidden') @el.find('[data-level~="search"]').removeClass('hidden') - @searchInput.focus() + @searchInput.trigger('focus') else @el.find("[data-level~=\"#{@currentLevel}\"]").removeClass('hidden') @el.find('[data-level~="search"]').addClass('hidden') diff --git a/app/assets/javascripts/app/controllers/login.coffee b/app/assets/javascripts/app/controllers/login.coffee index 633340e12..4d6021ed5 100644 --- a/app/assets/javascripts/app/controllers/login.coffee +++ b/app/assets/javascripts/app/controllers/login.coffee @@ -58,9 +58,9 @@ class Login extends App.ControllerFullPage # set focus to username or password if !@$('[name="username"]').val() - @$('[name="username"]').focus() + @$('[name="username"]').trigger('focus') else - @$('[name="password"]').focus() + @$('[name="password"]').trigger('focus') # scroll to top @scrollTo() diff --git a/app/assets/javascripts/app/controllers/report.coffee b/app/assets/javascripts/app/controllers/report.coffee index de1fe139e..fd9390e95 100644 --- a/app/assets/javascripts/app/controllers/report.coffee +++ b/app/assets/javascripts/app/controllers/report.coffee @@ -235,7 +235,7 @@ class Download extends App.Controller constructor: (data) -> # unbind existing click binds - data.el.unbind('click .js-dataDownloadBackendSelector') + data.el.off('click .js-dataDownloadBackendSelector') super @render() diff --git a/app/assets/javascripts/app/controllers/search.coffee b/app/assets/javascripts/app/controllers/search.coffee index ac17d6930..68056952a 100644 --- a/app/assets/javascripts/app/controllers/search.coffee +++ b/app/assets/javascripts/app/controllers/search.coffee @@ -245,7 +245,7 @@ class App.Search extends App.Controller @bulkForm.show() # show/hide bulk action - localElement.delegate('input[name="bulk"], input[name="bulk_all"]', 'change', (e) => + localElement.on('change', 'input[name="bulk"], input[name="bulk_all"]', (e) => if @shouldShowBulkForm() @bulkForm.show() else @@ -254,7 +254,7 @@ class App.Search extends App.Controller ) # deselect bulk_all if one item is uncheck observ - localElement.delegate('[name="bulk"]', 'change', (e) -> + localElement.on('change', '[name="bulk"]', (e) -> bulkAll = localElement.find('[name="bulk_all"]') checkedCount = localElement.find('input[name="bulk"]:checked').length checkboxCount = localElement.find('input[name="bulk"]').length diff --git a/app/assets/javascripts/app/controllers/ticket_link_add.coffee b/app/assets/javascripts/app/controllers/ticket_link_add.coffee index 15a380ae9..1ada76262 100644 --- a/app/assets/javascripts/app/controllers/ticket_link_add.coffee +++ b/app/assets/javascripts/app/controllers/ticket_link_add.coffee @@ -45,11 +45,11 @@ class App.TicketLinkAdd extends App.ControllerModal if @ticketIdsRecentViewed @buildContentTable(content, @ticketIdsRecentViewed, 'ticket-merge-recent-tickets') - content.delegate('[name="ticket_number"]', 'focus', (e) -> + content.on('focus', '[name="ticket_number"]', (e) -> $(e.target).parents().find('[name="radio"]').prop('checked', false) ) - content.delegate('[name="radio"]', 'click', (e) -> + content.on('click', '[name="radio"]', (e) -> if $(e.target).prop('checked') ticket_id = $(e.target).val() ticket = App.Ticket.fullLocal( ticket_id ) diff --git a/app/assets/javascripts/app/controllers/ticket_overview.coffee b/app/assets/javascripts/app/controllers/ticket_overview.coffee index a5d1beada..92098fe62 100644 --- a/app/assets/javascripts/app/controllers/ticket_overview.coffee +++ b/app/assets/javascripts/app/controllers/ticket_overview.coffee @@ -706,7 +706,7 @@ class App.TicketOverview extends App.Controller else if e.keyCode is 32 # space e.preventDefault() if @activeFocus is 'overview' - @$('.table-overview table tbody tr.is-hover td.js-checkbox-field label input').first().click() + @$('.table-overview table tbody tr.is-hover td.js-checkbox-field label input').first().trigger('click') else if e.keyCode is 9 # tab e.preventDefault() if @activeFocus is 'nav' @@ -726,18 +726,18 @@ class App.TicketOverview extends App.Controller items = @$('.table-overview table tbody') current = items.find('tr.is-hover') - if !current.size() + if !current.length items.find('tr').first().addClass('is-hover') return if position is 1 next = current.next('tr') - if next.size() + if next.length current.removeClass('is-hover') next.addClass('is-hover') else prev = current.prev('tr') - if prev.size() + if prev.length current.removeClass('is-hover') prev.addClass('is-hover') @@ -751,7 +751,7 @@ class App.TicketOverview extends App.Controller items = @$('.sidebar') current = items.find('li.active') - if !current.size() + if !current.length location = items.find('li a').first().attr('href') if location @navigate location @@ -759,11 +759,11 @@ class App.TicketOverview extends App.Controller if position is 1 next = current.next('li') - if next.size() + if next.length @navigate next.find('a').attr('href') else prev = current.prev('li') - if prev.size() + if prev.length @navigate prev.find('a').attr('href') if next @@ -831,7 +831,7 @@ class Navbar extends App.Controller # if all tabs are visible # remove dropdown and dropdown button - if @dropdownItem.not('.hide').size() is 0 + if @dropdownItem.not('.hide').length is 0 @dropdown.remove() @dropdownToggle.remove() @@ -1031,7 +1031,7 @@ class Table extends App.Controller checkbox: checkbox ) table = $(table) - table.delegate('[name="bulk_all"]', 'change', (e) -> + table.on('change', '[name="bulk_all"]', (e) -> if $(e.currentTarget).prop('checked') $(e.currentTarget).closest('table').find('[name="bulk"]').prop('checked', true) else @@ -1224,7 +1224,7 @@ class Table extends App.Controller @bulkForm.show() # show/hide bulk action - localElement.delegate('input[name="bulk"], input[name="bulk_all"]', 'change', (e) => + localElement.on('change', 'input[name="bulk"], input[name="bulk_all"]', (e) => if @shouldShowBulkForm() @bulkForm.show() else @@ -1233,7 +1233,7 @@ class Table extends App.Controller ) # deselect bulk_all if one item is uncheck observ - localElement.delegate('[name="bulk"]', 'change', (e) -> + localElement.on('change', '[name="bulk"]', (e) -> bulkAll = localElement.find('[name="bulk_all"]') checkedCount = localElement.find('input[name="bulk"]:checked').length checkboxCount = localElement.find('input[name="bulk"]').length diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.coffee index 362dc38d7..4e5312175 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.coffee @@ -359,16 +359,16 @@ class App.TicketZoom extends App.Controller article_id: undefined modifier = 'alt+ctrl+left' - $(document).bind("keydown.ticket_zoom#{@ticket_id}", modifier, (e) => + $(document).on("keydown.ticket_zoom#{@ticket_id}", modifier, (e) => @articleNavigate('up') ) modifier = 'alt+ctrl+right' - $(document).bind("keydown.ticket_zoom#{@ticket_id}", modifier, (e) => + $(document).on("keydown.ticket_zoom#{@ticket_id}", modifier, (e) => @articleNavigate('down') ) shortcutNavigationstop: => - $(document).unbind("keydown.ticket_zoom#{@ticket_id}") + $(document).off("keydown.ticket_zoom#{@ticket_id}") articleNavigate: (direction) => articleStates = [] @@ -404,13 +404,13 @@ class App.TicketZoom extends App.Controller @positionPageHeaderUpdate() # scroll is also fired on window resize, if element scroll is changed - @main.bind( + @main.on( 'scroll' @positionPageHeaderUpdate ) positionPageHeaderStop: => - @main.unbind('scroll', @positionPageHeaderUpdate) + @main.off('scroll', @positionPageHeaderUpdate) @scrollHeaderPos: undefined diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_image_view.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_image_view.coffee index 243a8d0b0..43932abff 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/article_image_view.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_image_view.coffee @@ -14,17 +14,17 @@ class App.TicketZoomArticleImageView extends App.ControllerModal constructor: -> super @unbindAll() - $(document).bind('keydown.image_preview', 'right', (e) => + $(document).on('keydown.image_preview', 'right', (e) => nextElement = @parentElement.closest('.attachment').next('.attachment.attachment--preview') return if nextElement.length is 0 @close() - nextElement.find('img').click() + nextElement.find('img').trigger('click') ) - $(document).bind('keydown.image_preview', 'left', (e) => + $(document).on('keydown.image_preview', 'left', (e) => prevElement = @parentElement.closest('.attachment').prev('.attachment.attachment--preview') return if prevElement.length is 0 @close() - prevElement.find('img').click() + prevElement.find('img').trigger('click') ) content: -> @@ -40,4 +40,4 @@ class App.TicketZoomArticleImageView extends App.ControllerModal @unbindAll() unbindAll: -> - $(document).unbind('keydown.image_preview') + $(document).off('keydown.image_preview') diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee index a05680034..d70d4b2a8 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee @@ -64,7 +64,7 @@ class App.TicketZoomArticleNew extends App.Controller # set focus into field if data.focus - @$("[name=\"#{data.focus}\"], [data-name=\"#{data.focus}\"]").focus().parent().find('.token-input').focus() + @$("[name=\"#{data.focus}\"], [data-name=\"#{data.focus}\"]").trigger('focus').parent().find('.token-input').trigger('focus') return # set focus at end of field @@ -422,7 +422,7 @@ class App.TicketZoomArticleNew extends App.Controller @securityOptionsShow() # add observer to change options - @$('.js-to, .js-cc').bind('change', => + @$('.js-to, .js-cc').on('change', => @updateSecurityOptions() ) @updateSecurityOptions() @@ -459,7 +459,7 @@ class App.TicketZoomArticleNew extends App.Controller propagateOpenTextarea: (event) -> event.stopPropagation() - @textarea.focus() + @textarea.trigger('focus') updateLetterCount: => return if !@maxTextLength @@ -505,7 +505,7 @@ class App.TicketZoomArticleNew extends App.Controller easing: 'easeOutQuad' complete: => $(window).on('click.ticket-zoom-textarea', @closeTextarea) - @textarea.focus() if focus + @textarea.trigger('focus') if focus @textBubble.velocity properties: diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/attribute_bar.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/attribute_bar.coffee index 0ccebd823..f2bc4ab0c 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/attribute_bar.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/attribute_bar.coffee @@ -96,11 +96,11 @@ class App.TicketZoomAttributeBar extends App.Controller openMacroMenu: => @buttonDropdown.addClass 'is-open' - $(document).bind 'click.buttonDropdown', @closeMacroMenu + $(document).on 'click.buttonDropdown', @closeMacroMenu closeMacroMenu: => @buttonDropdown.removeClass 'is-open' - $(document).unbind 'click.buttonDropdown' + $(document).off 'click.buttonDropdown' performTicketMacro: (e) => macroId = $(e.currentTarget).data('id') diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/form_handler_core_workflow.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/form_handler_core_workflow.coffee index 75c6768dc..6dbcbb007 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/form_handler_core_workflow.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/form_handler_core_workflow.coffee @@ -56,7 +56,7 @@ class App.FormHandlerCoreWorkflow if $(target).get(0).tagName == 'FORM' target = $(target).find('button[type=submit]').first() - $(target).click() + $(target).trigger('click') # checks if the controller has a running Core Workflow request @requestsRunning: (controllerForm) -> @@ -170,7 +170,7 @@ class App.FormHandlerCoreWorkflow eventToBind = event.type + '.' + event.namespace target = newElement.find("[name='" + target_name + "']") if target.length > 0 - target.bind(eventToBind, event.data, event.handler) + target.on(eventToBind, event.data, event.handler) ) ) ) diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/sidebar_article_attachments.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/sidebar_article_attachments.coffee index 409f8290d..728cc00fb 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/sidebar_article_attachments.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/sidebar_article_attachments.coffee @@ -24,7 +24,7 @@ class SidebarArticleAttachments extends App.Controller if !_.isEmpty(attachments) html += App.view('ticket_zoom/sidebar_article_attachment')(article: article, attachments: attachments) @el.html(html) - @el.delegate('.js-attachments img', 'click', (e) => + @el.on('click', '.js-attachments img', (e) => @imageView(e) ) diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/sidebar_git_issue.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/sidebar_git_issue.coffee index 46625cea3..5cbda7f3e 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/sidebar_git_issue.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/sidebar_git_issue.coffee @@ -105,7 +105,7 @@ class App.SidebarGitIssue extends App.Controller list = $(App.view('ticket_zoom/sidebar_git_issue')( issues: @issueLinkData )) - list.delegate('.js-delete', 'click', (e) => + list.on('click', '.js-delete', (e) => e.preventDefault() issueLink = $(e.currentTarget).attr 'data-issue-id' @deleteIssue(issueLink) diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/sidebar_idoit.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/sidebar_idoit.coffee index d2fca7b2e..8b05d7a64 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/sidebar_idoit.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/sidebar_idoit.coffee @@ -82,7 +82,7 @@ class SidebarIdoit extends App.Controller list = $(App.view('ticket_zoom/sidebar_idoit')( objects: objects )) - list.delegate('.js-delete', 'click', (e) => + list.on('click', '.js-delete', (e) => e.preventDefault() objectId = $(e.currentTarget).attr 'data-object-id' @delete(objectId) diff --git a/app/assets/javascripts/app/controllers/user.coffee b/app/assets/javascripts/app/controllers/user.coffee index abb83b9f3..54935948c 100644 --- a/app/assets/javascripts/app/controllers/user.coffee +++ b/app/assets/javascripts/app/controllers/user.coffee @@ -43,7 +43,7 @@ class User extends App.ControllerSubContent ) # start search - @searchInput.bind( 'keyup', (e) => + @searchInput.on( 'keyup', (e) => query = @searchInput.val().trim() return if query is @query @query = query diff --git a/app/assets/javascripts/app/controllers/widget/button_with_dropdown.coffee b/app/assets/javascripts/app/controllers/widget/button_with_dropdown.coffee index 0c1bc5e01..01a4c1039 100644 --- a/app/assets/javascripts/app/controllers/widget/button_with_dropdown.coffee +++ b/app/assets/javascripts/app/controllers/widget/button_with_dropdown.coffee @@ -28,4 +28,4 @@ class App.WidgetButtonWithDropdown extends App.Controller @preventDefaultAndStopPropagation(e) return - @accessoriesContainer.blur() + @accessoriesContainer.trigger('blur') diff --git a/app/assets/javascripts/app/controllers/widget/link/kb_answer.coffee b/app/assets/javascripts/app/controllers/widget/link/kb_answer.coffee index 2e4ffb346..be93dca6b 100644 --- a/app/assets/javascripts/app/controllers/widget/link/kb_answer.coffee +++ b/app/assets/javascripts/app/controllers/widget/link/kb_answer.coffee @@ -74,7 +74,7 @@ class App.WidgetLinkKbAnswer extends App.WidgetLink @inputField.attr('disabled', false).val('') @setInputVisible(true) - @inputField.focus() + @inputField.trigger('focus') setInputVisible: (setInputVisible) -> @searchableSelect.toggleClass('hidden', !setInputVisible) diff --git a/app/assets/javascripts/app/controllers/widget/online_notification.coffee b/app/assets/javascripts/app/controllers/widget/online_notification.coffee index d41337d8d..eeacf9f45 100644 --- a/app/assets/javascripts/app/controllers/widget/online_notification.coffee +++ b/app/assets/javascripts/app/controllers/widget/online_notification.coffee @@ -81,25 +81,25 @@ class App.OnlineNotificationWidget extends App.Controller @nudge(e, 1) return else if e.keyCode is 13 # enter - @$('.js-item').filter('.is-hover').find('.js-locationVerify').click() + @$('.js-item').filter('.is-hover').find('.js-locationVerify').trigger('click') nudge: (e, position) -> # get current items = @$('.js-item') current = items.filter('.is-hover') - if !current.size() + if !current.length items.first().addClass('is-hover') return if position is 1 next = current.next('.js-item') - if next.size() + if next.length current.removeClass('is-hover') next.addClass('is-hover') else prev = current.prev('.js-item') - if prev.size() + if prev.length current.removeClass('is-hover') prev.addClass('is-hover') diff --git a/app/assets/javascripts/app/controllers/widget/tag.coffee b/app/assets/javascripts/app/controllers/widget/tag.coffee index 128d9e37c..38d1f39d6 100644 --- a/app/assets/javascripts/app/controllers/widget/tag.coffee +++ b/app/assets/javascripts/app/controllers/widget/tag.coffee @@ -68,7 +68,7 @@ class App.WidgetTag extends App.Controller showInput: (e) => e.preventDefault() @newTagLabel.addClass('hide') - @newTagInput.removeClass('hide').focus() + @newTagInput.removeClass('hide').trigger('focus') @newTagInput.trigger(jQuery.Event('keydown')) @editMode = true diff --git a/app/assets/javascripts/app/controllers/widget/ticket_bulk_form.coffee b/app/assets/javascripts/app/controllers/widget/ticket_bulk_form.coffee index c46dc9d5f..04eba61f0 100644 --- a/app/assets/javascripts/app/controllers/widget/ticket_bulk_form.coffee +++ b/app/assets/javascripts/app/controllers/widget/ticket_bulk_form.coffee @@ -107,7 +107,7 @@ class App.TicketBulkForm extends App.Controller @makeSpaceForTableRows() # need a delay because of the click event - setTimeout ( => @$('.textarea.form-group textarea').focus() ), 0 + setTimeout ( => @$('.textarea.form-group textarea').trigger('focus') ), 0 reset: => @cancel() diff --git a/app/assets/javascripts/app/lib/app_init/track.coffee b/app/assets/javascripts/app/lib/app_init/track.coffee index e4434e9a9..b4cd19bd9 100644 --- a/app/assets/javascripts/app/lib/app_init/track.coffee +++ b/app/assets/javascripts/app/lib/app_init/track.coffee @@ -46,7 +46,7 @@ class _trackSingleton # log clicks if @logClick - $(document).bind( + $(document).on( 'click' (e) => w = window.screen.width @@ -70,7 +70,7 @@ class _trackSingleton # log ajax calls if @logAjax - $(document).bind( 'ajaxComplete', ( e, request, settings ) => + $(document).on( 'ajaxComplete', ( e, request, settings ) => # do not log ui requests if settings.url && settings.url.substr(settings.url.length-3,3) isnt '/ui' @@ -105,7 +105,7 @@ class _trackSingleton ) ) - $(window).bind( + $(window).on( 'beforeunload' => @log('good bye', 'notice', {}) diff --git a/app/assets/javascripts/app/lib/app_post/_object_organization_autocompletion.coffee b/app/assets/javascripts/app/lib/app_post/_object_organization_autocompletion.coffee index e7d424c52..8fa959087 100644 --- a/app/assets/javascripts/app/lib/app_post/_object_organization_autocompletion.coffee +++ b/app/assets/javascripts/app/lib/app_post/_object_organization_autocompletion.coffee @@ -76,7 +76,7 @@ class App.ObjectOrganizationAutocompletion extends App.Controller @open() focusInput: => - @objectSelect.focus() if not @formControl.hasClass('focus') + @objectSelect.trigger('focus') if not @formControl.hasClass('focus') onBlur: => selectObject = @objectSelect.val() @@ -141,7 +141,7 @@ class App.ObjectOrganizationAutocompletion extends App.Controller switch which when 'last' token = @$('.token').last() - return if not token.size() + return if not token.length else token = which diff --git a/app/assets/javascripts/app/lib/app_post/ajax.coffee b/app/assets/javascripts/app/lib/app_post/ajax.coffee index db117d066..61a5780ca 100644 --- a/app/assets/javascripts/app/lib/app_post/ajax.coffee +++ b/app/assets/javascripts/app/lib/app_post/ajax.coffee @@ -67,9 +67,9 @@ class _ajaxSingleton @runNextInQueue() # bindings - $(document).bind('ajaxSend', => + $(document).on('ajaxSend', => @_show_spinner() - ).bind('ajaxComplete', (request, xhr, settings) => + ).on('ajaxComplete', (request, xhr, settings) => @_hide_spinner() # remeber XSRF-TOKEN for later @@ -81,7 +81,7 @@ class _ajaxSingleton ) # show error messages - $(document).bind('ajaxError', (e, jqxhr, settings, exception) -> + $(document).on('ajaxError', (e, jqxhr, settings, exception) -> if settings.failResponseNoTrigger return diff --git a/app/assets/javascripts/app/lib/app_post/clipboard.coffee b/app/assets/javascripts/app/lib/app_post/clipboard.coffee index 004c37c4e..3d97b78b4 100644 --- a/app/assets/javascripts/app/lib/app_post/clipboard.coffee +++ b/app/assets/javascripts/app/lib/app_post/clipboard.coffee @@ -10,7 +10,7 @@ class App.ClipBoard if _instance == undefined _instance ?= new _Singleton _instance.manuallyUpdateSelection(type) - + @getSelected: (type) -> if _instance == undefined _instance ?= new _Singleton @@ -56,10 +56,10 @@ class _Singleton bind: (el) -> # check selection on mouse up - $(el).bind('mouseup', => + $(el).on('mouseup', => @_updateSelection() ) - $(el).bind('keyup', (e) => + $(el).on('keyup', (e) => # check selection on sonder key if e.keyCode == 91 @@ -90,7 +90,7 @@ class _Singleton sel = document.selection.createRange() text = sel.text if type is 'text' - return $.trim(text.toString()) if text + return (text.toString()).trim() if text return '' if sel && sel.rangeCount @@ -98,7 +98,7 @@ class _Singleton for i in [1..sel.rangeCount] container.appendChild(sel.getRangeAt(i-1).cloneContents()) html = container.innerHTML - + if type != 'sel' html else diff --git a/app/assets/javascripts/app/lib/app_post/column_select.coffee b/app/assets/javascripts/app/lib/app_post/column_select.coffee index 3cd4e1a2a..9970e3d01 100644 --- a/app/assets/javascripts/app/lib/app_post/column_select.coffee +++ b/app/assets/javascripts/app/lib/app_post/column_select.coffee @@ -100,7 +100,7 @@ class App.ColumnSelect extends Spine.Controller @placeholder.addClass('is-hidden') - if @search.val() and @poolOptions.not('.is-filtered').not('.is-hidden').size() is 0 + if @search.val() and @poolOptions.not('.is-filtered').not('.is-hidden').length is 0 @clear() onRemove: (event) -> diff --git a/app/assets/javascripts/app/lib/app_post/icon_picker.coffee b/app/assets/javascripts/app/lib/app_post/icon_picker.coffee index 20791ff84..be50c88b4 100644 --- a/app/assets/javascripts/app/lib/app_post/icon_picker.coffee +++ b/app/assets/javascripts/app/lib/app_post/icon_picker.coffee @@ -81,10 +81,10 @@ class App.IconPicker extends Spine.Controller # propergate focus to our visible input onShadowFocus: -> - @input.focus() + @input.trigger('focus') onPickerOpen: -> - @filter.focus() + @filter.trigger('focus') @isOpen = true onPickerClose: -> diff --git a/app/assets/javascripts/app/lib/app_post/popover_provider/_single_object_popover_provider.coffee b/app/assets/javascripts/app/lib/app_post/popover_provider/_single_object_popover_provider.coffee index b8df9112d..ca00166b3 100644 --- a/app/assets/javascripts/app/lib/app_post/popover_provider/_single_object_popover_provider.coffee +++ b/app/assets/javascripts/app/lib/app_post/popover_provider/_single_object_popover_provider.coffee @@ -8,7 +8,7 @@ class App.SingleObjectPopoverProvider extends App.PopoverProvider "div.#{@cssClass()}, span.#{@cssClass()}" bind: -> - @params.parentController.$(@fullCssSelector()).bind('click', (e) => + @params.parentController.$(@fullCssSelector()).on('click', (e) => id = @objectIdFor(e.target) return if !id object = @constructor.klass.find(id) diff --git a/app/assets/javascripts/app/lib/app_post/searchable_select.coffee b/app/assets/javascripts/app/lib/app_post/searchable_select.coffee index d4d54fa92..9307739d9 100644 --- a/app/assets/javascripts/app/lib/app_post/searchable_select.coffee +++ b/app/assets/javascripts/app/lib/app_post/searchable_select.coffee @@ -211,7 +211,7 @@ class App.SearchableSelect extends Spine.Controller currentPosition += direction return if currentPosition < 0 - return if currentPosition > visibleOptions.size() - 1 + return if currentPosition > visibleOptions.length - 1 @unhighlightCurrentItem() @currentItem = visibleOptions.eq(currentPosition) @@ -419,7 +419,7 @@ class App.SearchableSelect extends Spine.Controller # propergate focus to our visible input onShadowFocus: -> - @input.focus() + @input.trigger('focus') onShadowChange: -> value = @shadowInput.val() @@ -446,7 +446,7 @@ class App.SearchableSelect extends Spine.Controller switch which when 'last' token = @$('.token').last() - return if not token.size() + return if not token.length else token = which diff --git a/app/assets/javascripts/app/lib/app_post/utils.coffee b/app/assets/javascripts/app/lib/app_post/utils.coffee index 04a7fbac4..a5b953dd5 100644 --- a/app/assets/javascripts/app/lib/app_post/utils.coffee +++ b/app/assets/javascripts/app/lib/app_post/utils.coffee @@ -176,7 +176,9 @@ class App.Utils # textCleand = App.Utils.textCleanup(rawText) @textCleanup: (ascii) -> - $.trim( ascii ) + return '' if !ascii + + ascii.trim() .replace(/(\r\n|\n\r)/g, "\n") # cleanup .replace(/\r/g, "\n") # cleanup .replace(/[ ]\n/g, "\n") # remove tailing spaces @@ -274,7 +276,7 @@ class App.Utils @quote: (ascii, max = 82) -> ascii = @textCleanup(ascii) ascii = @wrap(ascii, max) - $.trim(ascii) + ascii.trim() .replace /^(.*)$/mg, (match) -> if match '> ' + match @@ -1008,7 +1010,7 @@ class App.Utils valueTmp = value.toString().toLowerCase() byNames.push valueTmp byNamesWithValue[valueTmp] = [i, value] - + # sort() by default doesn't compare non-ascii characters such as ['é', 'a', 'ú', 'c'] # hence using localecompare in sorting for translated strings byNames = byNames.sort((a, b) -> a.localeCompare(b)) diff --git a/app/assets/javascripts/app/lib/app_post/websocket.coffee b/app/assets/javascripts/app/lib/app_post/websocket.coffee index dabd316d1..87e72c37a 100644 --- a/app/assets/javascripts/app/lib/app_post/websocket.coffee +++ b/app/assets/javascripts/app/lib/app_post/websocket.coffee @@ -104,7 +104,7 @@ class _webSocketSingleton extends App.Controller @connect() # send ping after visibilitychange to check if connection is open again after wakeup - $(document).bind('visibilitychange', => + $(document).on('visibilitychange', => @log 'debug', 'visibilitychange' return if document.hidden return if !@connectionEstablished diff --git a/app/assets/javascripts/app/lib/base/bootstrap-tokenfield.js b/app/assets/javascripts/app/lib/base/bootstrap-tokenfield.js index 73d95b996..3549a701c 100644 --- a/app/assets/javascripts/app/lib/base/bootstrap-tokenfield.js +++ b/app/assets/javascripts/app/lib/base/bootstrap-tokenfield.js @@ -194,7 +194,7 @@ , defaults = { minLength: this.options.showAutocompleteOnFocus ? 0 : null } - , args = $.isArray( typeaheadOptions ) ? typeaheadOptions : [typeaheadOptions, typeaheadOptions] + , args = Array.isArray( typeaheadOptions ) ? typeaheadOptions : [typeaheadOptions, typeaheadOptions] args[0] = $.extend( {}, defaults, args[0] ) @@ -222,8 +222,8 @@ } // Normalize label and value - attrs.value = $.trim(attrs.value.toString()); - attrs.label = attrs.label && attrs.label.length ? $.trim(attrs.label) : attrs.value + attrs.value = (attrs.value.toString()).trim(); + attrs.label = attrs.label && attrs.label.length ? (attrs.label).trim() : attrs.value // Bail out if has no value or label, or label is too short if (!attrs.value.length || !attrs.label.length || attrs.label.length <= this.options.minLength) return @@ -310,11 +310,11 @@ } , updateTokensOnEditDiscard: function(triggerChange) { - // if the field is being edited, update original field's value + // if the field is being edited, update original field's value if(this.$input.data('edit') && triggerChange) { // Trigger change event on the original field this.$element.val( this.getTokensList() ).trigger( $.Event('change', { initiator: 'tokenfield' }) ) - } + } } , setTokens: function (tokens, add, triggerChange) { @@ -382,7 +382,7 @@ , getInput: function() { return this.$input.val() } - + , setInput: function (val) { if (this.$input.hasClass('tt-input')) { // Typeahead acts weird when simply setting input value to empty, @@ -897,7 +897,7 @@ else { //temporary reset width to minimal value to get proper results this.$input.width(this.options.minWidth); - + var w = (this.textDirection === 'rtl') ? this.$input.offset().left + this.$input.outerWidth() - this.$wrapper.offset().left - parseInt(this.$wrapper.css('padding-left'), 10) - inputPadding - 1 : this.$wrapper.offset().left + this.$wrapper.width() + parseInt(this.$wrapper.css('padding-left'), 10) - this.$input.offset().left - inputPadding; diff --git a/app/assets/javascripts/app/lib/base/cropper.js b/app/assets/javascripts/app/lib/base/cropper.js index 30b8e2f61..ac1593482 100644 --- a/app/assets/javascripts/app/lib/base/cropper.js +++ b/app/assets/javascripts/app/lib/base/cropper.js @@ -77,8 +77,13 @@ var ACTION_ZOOM = 'zoom'; var ACTION_NONE = 'none'; + // Function check + function _isFunction(obj){ + return ((typeof obj) === 'function') + } + // Supports - var SUPPORT_CANVAS = $.isFunction($('