Don't use deprecated (soon) jQuery .bind() and .unbind() methods

pull/299/merge
Aleksander Machniak 9 years ago
parent c8c4cafb1f
commit d9ff47b011

@ -246,7 +246,7 @@ rcube_webmail.prototype.managesieve_updatelist = function(action, o)
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_dragend = function(e)
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 @@ rcube_webmail.prototype.managesieve_tip_register = function(tips)
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 @@ rcube_webmail.prototype.managesieve_tip_register = function(tips)
top -= tip.height();
tip.css({left: left, top: top, minWidth: (minwidth-2) + 'px'}).show();
})
.bind('mouseleave', function(e) { tip.hide(); });
});
}
};

@ -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;

@ -6,7 +6,7 @@ if (window.rcmail) {
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');

@ -77,7 +77,7 @@ function rcube_webmail()
});
// 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 @@ function rcube_webmail()
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 @@ function rcube_webmail()
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 @@ function rcube_webmail()
// 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 @@ function rcube_webmail()
$('#'+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 @@ function rcube_webmail()
.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 @@ function rcube_webmail()
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 @@ function rcube_webmail()
}
// 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,

@ -661,7 +661,7 @@ function rcube_text_editor(config, id)
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');

@ -106,11 +106,11 @@ function GoogieSpell(img_dir, server_url, has_dict)
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 @@ this.prepare = function(ignore, no_indicator)
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.correctError = function(id, elm, l_elm, rm_pre_space)
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.createLangWindow = function()
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 @@ this.createLangWindow = function()
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 @@ this.createChangeLangPic = function()
$(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 @@ this.resumeEditingState = function()
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 @@ this.checkSpellingState = function(fire)
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 @@ this.createButton = function(name, css_class, c_fn)
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);

@ -401,11 +401,11 @@ show_attachmentmenu: function(elem, event)
{
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 @@ function rcube_init_mail_ui()
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;

@ -115,7 +115,7 @@ function rcube_splitter(attrib)
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 @@ function rcube_splitter(attrib)
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();

@ -159,7 +159,7 @@ function rcube_mail_ui()
// 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 @@ function rcube_mail_ui()
{
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 @@ function rcube_mail_ui()
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 @@ function rcube_splitter(p)
.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 @@ function rcube_splitter(p)
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 @@ function rcube_splitter(p)
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

Loading…
Cancel
Save