From d9ff47b011314902c4f30337013b6e4abe369a8e Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Tue, 13 Oct 2015 02:57:45 -0400 Subject: [PATCH] Don't use deprecated (soon) jQuery .bind() and .unbind() methods --- plugins/redundant_attachments/config.inc.php.dist | 2 skins/classic/splitter.js | 4 +- skins/classic/functions.js | 6 +- program/js/editor.js | 2 program/js/googiespell.js | 32 ++++++++-------- plugins/managesieve/managesieve.js | 12 +++--- plugins/userinfo/userinfo.js | 6 +- program/js/app.js | 31 ++++++++------- skins/larry/ui.js | 14 +++--- 9 files changed, 55 insertions(+), 54 deletions(-) diff --git a/plugins/managesieve/managesieve.js b/plugins/managesieve/managesieve.js index 1098b5b..b8af287 100644 --- a/plugins/managesieve/managesieve.js +++ b/plugins/managesieve/managesieve.js @@ -246,7 +246,7 @@ var rowid = this.id.substr(6); // remove all attached events - $(this).unbind(); + $(this).off(); // update row id if (rowid > id) { @@ -417,7 +417,7 @@ rcube_webmail.prototype.managesieve_fixdragend = function(elem) { var p = this; - $(elem).bind('mouseup' + ((bw.iphone || bw.ipad) ? ' touchend' : ''), function(e) { + $(elem).on('mouseup' + ((bw.iphone || bw.ipad) ? ' touchend' : ''), function(e) { if (p.drag_active) p.filters_list.drag_mouse_up(e); }); @@ -837,10 +837,11 @@ var n, framed = parent.rcmail, tip = framed ? parent.rcmail.env.ms_tip_layer : rcmail.env.ms_tip_layer; - for (var n in tips) { + for (n in tips) { $('#'+tips[n][0]) .data('tip', tips[n][1]) - .bind('mouseenter', function(e) { + .mouseleave(function(e) { tip.hide(); }) + .mouseenter(function(e) { var elem = $(this), offset = elem.offset(), left = offset.left, @@ -857,8 +858,7 @@ top -= tip.height(); tip.css({left: left, top: top, minWidth: (minwidth-2) + 'px'}).show(); - }) - .bind('mouseleave', function(e) { tip.hide(); }); + }); } }; diff --git a/plugins/redundant_attachments/config.inc.php.dist b/plugins/redundant_attachments/config.inc.php.dist index a6d1ad4..47e8401 100644 --- a/plugins/redundant_attachments/config.inc.php.dist +++ b/plugins/redundant_attachments/config.inc.php.dist @@ -6,7 +6,7 @@ // to use memcache as a fallback when write-master is unavailable. $config['redundant_attachments_memcache'] = false; -// Attachment data expires after specied TTL time in seconds (max.2592000). +// Attachment data expires after specified TTL time in seconds (max.2592000). // Default is 12 hours. $config['redundant_attachments_cache_ttl'] = 12 * 60 * 60; diff --git a/plugins/userinfo/userinfo.js b/plugins/userinfo/userinfo.js index 70a5085..1c0c513 100644 --- a/plugins/userinfo/userinfo.js +++ b/plugins/userinfo/userinfo.js @@ -4,10 +4,10 @@ rcmail.addEventListener('init', function(evt) { // <span id="settingstabdefault" class="tablink"><roundcube:button command="preferences" type="link" label="preferences" title="editpreferences" /></span> var tab = $('<span>').attr('id', 'settingstabpluginuserinfo').addClass('tablink'); - + var button = $('<a>').attr('href', rcmail.env.comm_path+'&_action=plugin.userinfo').html(rcmail.gettext('userinfo', 'userinfo')).appendTo(tab); - button.bind('click', function(e){ return rcmail.command('plugin.userinfo', this) }); - + button.click(function(e) { return rcmail.command('plugin.userinfo', this); }); + // add button and register command rcmail.add_element(tab, 'tabs'); rcmail.register_command('plugin.userinfo', function(){ rcmail.goto_url('plugin.userinfo') }, true); diff --git a/program/js/app.js b/program/js/app.js index b8713a7..e346356 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -77,7 +77,7 @@ }); // unload fix - $(window).bind('beforeunload', function() { ref.unload = true; }); + $(window).on('beforeunload', function() { ref.unload = true; }); // set environment variable(s) this.set_env = function(p, value) @@ -321,8 +321,8 @@ if (this.gui_objects.responseslist) { $('a.insertresponse', this.gui_objects.responseslist) .attr('unselectable', 'on') - .mousedown(function(e){ return rcube_event.cancel(e); }) - .bind('mouseup keypress', function(e){ + .mousedown(function(e) { return rcube_event.cancel(e); }) + .on('mouseup keypress', function(e) { if (e.type == 'mouseup' || rcube_event.get_keycode(e) == 13) { ref.command('insert-response', $(this).attr('rel')); $(document.body).trigger('mouseup'); // hides the menu @@ -535,7 +535,7 @@ input_user = $('#rcmloginuser'), input_tz = $('#rcmlogintz'); - input_user.bind('keyup', function(e) { return ref.login_user_keyup(e); }); + input_user.keyup(function(e) { return ref.login_user_keyup(e); }); if (input_user.val() == '') input_user.focus(); @@ -600,17 +600,17 @@ // activate html5 file drop feature (if browser supports it and if configured) if (this.gui_objects.filedrop && this.env.filedrop && ((window.XMLHttpRequest && XMLHttpRequest.prototype && XMLHttpRequest.prototype.sendAsBinary) || window.FormData)) { - $(document.body).bind('dragover dragleave drop', function(e){ return ref.document_drag_hover(e, e.type == 'dragover'); }); + $(document.body).on('dragover dragleave drop', function(e) { return ref.document_drag_hover(e, e.type == 'dragover'); }); $(this.gui_objects.filedrop).addClass('droptarget') - .bind('dragover dragleave', function(e){ return ref.file_drag_hover(e, e.type == 'dragover'); }) - .get(0).addEventListener('drop', function(e){ return ref.file_dropped(e); }, false); + .on('dragover dragleave', function(e) { return ref.file_drag_hover(e, e.type == 'dragover'); }) + .get(0).addEventListener('drop', function(e) { return ref.file_dropped(e); }, false); } // catch document (and iframe) mouse clicks var body_mouseup = function(e){ return ref.doc_mouse_up(e); }; $(document.body) - .bind('mouseup', body_mouseup) - .bind('keydown', function(e){ return ref.doc_keypress(e); }); + .mouseup(body_mouseup) + .keydown(function(e){ return ref.doc_keypress(e); }); $('iframe').on('load', function(e) { try { $(this.contentDocument || this.contentWindow).on('mouseup', body_mouseup); } @@ -2745,8 +2745,9 @@ $('#'+r.id+' .leaf:first') .attr('id', 'rcmexpando' + r.id) .attr('class', (r.obj.style.display != 'none' ? 'expanded' : 'collapsed')) - .bind('mousedown', {uid: r.uid}, - function(e) { return ref.expand_message_row(e, e.data.uid); }); + .mousedown({uid: r.uid}, function(e) { + return ref.expand_message_row(e, e.data.uid); + }); r.unread_children = 0; roots.push(r); @@ -4354,10 +4355,10 @@ .attr('tabindex', '0') .html(this.quote_html(response.name)) .appendTo(li) - .mousedown(function(e){ + .mousedown(function(e) { return rcube_event.cancel(e); }) - .bind('mouseup keypress', function(e){ + .on('mouseup keypress', function(e) { if (e.type == 'mouseup' || rcube_event.get_keycode(e) == 13) { ref.command('insert-response', $(this).attr('rel')); $(document.body).trigger('mouseup'); // hides the menu @@ -4455,7 +4456,7 @@ if (!this.local_save_timer && window.localStorage && this.env.save_localstorage) { // track typing activity and only save on changes this.compose_type_activity = this.compose_type_activity_last = 0; - $(document).bind('keypress', function(e){ ref.compose_type_activity++; }); + $(document).keypress(function(e) { ref.compose_type_activity++; }); this.local_save_timer = setInterval(function(){ if (ref.compose_type_activity > ref.compose_type_activity_last) { @@ -8386,7 +8387,7 @@ } // handle upload errors by parsing iframe content in onload - frame.bind('load', {ts:ts}, onload); + frame.on('load', {ts:ts}, onload); $(form).attr({ target: frame_name, diff --git a/program/js/editor.js b/program/js/editor.js index 019de3c..5193f8c 100644 --- a/program/js/editor.js +++ b/program/js/editor.js @@ -661,7 +661,7 @@ rcmail.gui_objects.filedrop = $('#image-selector-form'); rcmail.gui_objects.filedrop.addClass('droptarget') - .bind('dragover dragleave', function(e) { + .on('dragover dragleave', function(e) { e.preventDefault(); e.stopPropagation(); $(this)[(e.type == 'dragover' ? 'addClass' : 'removeClass')]('hover'); diff --git a/program/js/googiespell.js b/program/js/googiespell.js index 8c17508..bf0eede 100644 --- a/program/js/googiespell.js +++ b/program/js/googiespell.js @@ -106,11 +106,11 @@ this.cnt_errors_fixed = 0; // Set document's onclick to hide the language and error menu - $(document).bind('click', function(e) { + $(document).click(function(e) { var target = $(e.target); - if(target.attr('googie_action_btn') != '1' && ref.isLangWindowShown()) + if (target.attr('googie_action_btn') != '1' && ref.isLangWindowShown()) ref.hideLangWindow(); - if(target.attr('googie_action_btn') != '1' && ref.isErrorWindowShown()) + if (target.attr('googie_action_btn') != '1' && ref.isErrorWindowShown()) ref.hideErrorWindow(); }); @@ -331,7 +331,7 @@ catch (e) { } if (this.main_controller) - $(this.spell_span).unbind('click'); + $(this.spell_span).off('click'); this.orginal_text = area.val(); }; @@ -465,7 +465,7 @@ this.ignoreError = function(elm, id) { // @TODO: ignore all same words - $(elm).removeAttr('class').css('color', '').unbind(); + $(elm).removeAttr('class').css('color', '').off(); this.hideErrorWindow(); }; @@ -843,7 +843,7 @@ this.lang_elms.push(item); $(item).attr('googieId', this.langlist_codes[i]) - .bind('click', function(e) { + .click(function(e) { ref.deHighlightCurSel(); ref.setCurrentLanguage($(this).attr('googieId')); @@ -854,11 +854,11 @@ ref.highlightCurSel(); ref.hideLangWindow(); }) - .bind('mouseover', function(e) { + .mouseover(function(e) { if (this.className != "googie_list_selected") this.className = "googie_list_onhover"; }) - .bind('mouseout', function(e) { + .mouseout(function(e) { if (this.className != "googie_list_selected") this.className = "googie_list_onout"; }); @@ -941,7 +941,7 @@ $(switch_lan).addClass('googie_lang_3d_on') .append(img) - .bind('click', function(e) { + .click(function(e) { var elm = this.tagName.toLowerCase() == 'img' ? this.parentNode : this; if($(elm).hasClass('googie_lang_3d_click')) { elm.className = 'googie_lang_3d_on'; @@ -1009,8 +1009,8 @@ var ref = this; $(this.switch_lan_pic).hide(); - $(this.spell_span).empty().unbind().append(rsm) - .bind('click', function() { ref.resumeEditing() }) + $(this.spell_span).empty().off().append(rsm) + .click(function() { ref.resumeEditing(); }) .removeClass().addClass('googie_resume_editing'); } @@ -1032,9 +1032,9 @@ ref = this; if (this.custom_spellcheck_starter) - $(span_chck).bind('click', function(e) { ref.custom_spellcheck_starter() }); + $(span_chck).click(function(e) { ref.custom_spellcheck_starter(); }); else { - $(span_chck).bind('click', function(e) { ref.spellCheck() }); + $(span_chck).click(function(e) { ref.spellCheck(); }); } if (this.main_controller) { @@ -1090,9 +1090,9 @@ spn_btn = document.createTextNode(name); } - $(btn).bind('click', c_fn) - .bind('mouseover', this.item_onmouseover) - .bind('mouseout', this.item_onmouseout); + $(btn).click(c_fn) + .mouseover(this.item_onmouseover) + .mouseout(this.item_onmouseout); btn.appendChild(spn_btn); btn_row.appendChild(btn); diff --git a/skins/classic/functions.js b/skins/classic/functions.js index a23fd37..4e68e9e 100644 --- a/skins/classic/functions.js +++ b/skins/classic/functions.js @@ -401,11 +401,11 @@ { var id = elem.parentNode.id.replace(/^attach/, ''); - $('#attachmenuopen').unbind('click').attr('onclick', '').click(function(e) { + $('#attachmenuopen').off('click').attr('onclick', '').click(function(e) { return rcmail.command('open-attachment', id, this); }); - $('#attachmenudownload').unbind('click').attr('onclick', '').click(function() { + $('#attachmenudownload').off('click').attr('onclick', '').click(function() { rcmail.command('download-attachment', id, this); }); @@ -1050,7 +1050,7 @@ else if (rcmail.env.action == 'show' || rcmail.env.action == 'preview') { // add menu link for each attachment $('#attachment-list > li[id^="attach"]').each(function() { - $(this).append($('<a class="drop"></a>').bind('click keypress', function(e) { + $(this).append($('<a class="drop"></a>').on('click keypress', function(e) { if (e.type != 'keypress' || e.which == 13) { rcmail_ui.show_attachmentmenu(this, e); return false; diff --git a/skins/classic/splitter.js b/skins/classic/splitter.js index d509f3b..2498c0b 100644 --- a/skins/classic/splitter.js +++ b/skins/classic/splitter.js @@ -115,7 +115,7 @@ me.p2pos = me.relative ? $(me.p2).position() : $(me.p2).offset(); // start listening to mousemove events - $(document).bind('mousemove.'+me.id, onDrag).bind('mouseup.'+me.id, onDragStop); + $(document).on('mousemove.' + me.id, onDrag).on('mouseup.' + me.id, onDragStop); // enable dragging above iframes $('iframe').each(function() { @@ -181,7 +181,7 @@ document.body.style.webkitUserSelect = 'auto'; // cancel the listening for drag events - $(document).unbind('.' + me.id); + $(document).off('.' + me.id); // remove temp divs $('div.iframe-splitter-fix').remove(); diff --git a/skins/larry/ui.js b/skins/larry/ui.js index b3c6abd..8b58189 100644 --- a/skins/larry/ui.js +++ b/skins/larry/ui.js @@ -159,7 +159,7 @@ // add menu link for each attachment $('#attachment-list > li').each(function() { $(this).append($('<a class="drop" tabindex="0" aria-haspopup="true">Show options</a>') - .bind('click keypress', function(e) { + .on('click keypress', function(e) { if (e.type != 'keypress' || rcube_event.get_keycode(e) == 13) { attachmentmenu(this, e); return false; @@ -818,11 +818,11 @@ { var id = elem.parentNode.id.replace(/^attach/, ''); - $('#attachmenuopen').unbind('click').attr('onclick', '').click(function(e) { + $('#attachmenuopen').off('click').attr('onclick', '').click(function(e) { return rcmail.command('open-attachment', id, this); }); - $('#attachmenudownload').unbind('click').attr('onclick', '').click(function() { + $('#attachmenudownload').off('click').attr('onclick', '').click(function() { rcmail.command('download-attachment', id, this); }); @@ -843,7 +843,7 @@ li = $('<li role="menuitem">'); link = $('<a href="#'+k+'" tabindex="0"></a>').text(rcmail.env.spell_langs[k]) .addClass('active').data('lang', k) - .bind('click keypress', function(e) { + .on('click keypress', function(e) { if (e.type != 'keypress' || rcube_event.get_keycode(e) == 13) { rcmail.spellcheck_lang_set($(this).data('lang')); rcmail.hide_menu('spellmenu', e); @@ -1271,7 +1271,7 @@ .attr('role', 'presentation') .addClass('splitter ' + (this.horizontal ? 'splitter-h' : 'splitter-v')) .appendTo(this.parent) - .bind('mousedown', onDragStart); + .mousedown(onDragStart); if (this.horizontal) { var top = this.p1pos.top + this.p1.outerHeight(); @@ -1352,7 +1352,7 @@ me.drag_active = true; // start listening to mousemove events - $(document).bind('mousemove.'+this.id, onDrag).bind('mouseup.'+this.id, onDragStop); + $(document).on('mousemove.' + this.id, onDrag).on('mouseup.' + this.id, onDragStop); // enable dragging above iframes $('iframe').each(function(i, elem) { @@ -1429,7 +1429,7 @@ document.body.style.webkitUserSelect = 'auto'; // cancel the listening for drag events - $(document).unbind('.'+me.id); + $(document).off('.' + me.id); me.drag_active = false; // remove temp divs -- Gitblit v1.9.1