Replace Array.prototype.last() with jQuery.last to avoid side-effects in array iterations

pull/195/head
Thomas Bruederli 10 years ago
parent d4d62ac414
commit f5de03208e

@ -6597,10 +6597,8 @@ function rcube_webmail()
this.treelist.select(name); this.treelist.select(name);
} }
else if (this.gui_objects.folderlist) { else if (this.gui_objects.folderlist) {
$('li.selected', this.gui_objects.folderlist) $('li.selected', this.gui_objects.folderlist).removeClass('selected');
.removeClass('selected').addClass('unfocused'); $(this.get_folder_li(name, prefix, encode)).addClass('selected');
$(this.get_folder_li(name, prefix, encode))
.removeClass('unfocused').addClass('selected');
// trigger event hook // trigger event hook
this.triggerEvent('selectfolder', { folder:name, prefix:prefix }); this.triggerEvent('selectfolder', { folder:name, prefix:prefix });
@ -6976,8 +6974,8 @@ function rcube_webmail()
this.hide_menu(this.menu_stack[i]); this.hide_menu(this.menu_stack[i]);
} }
if (stack && this.menu_stack.length) { if (stack && this.menu_stack.length) {
obj.data('parent', this.menu_stack.last()); obj.data('parent', $.last(this.menu_stack));
obj.css('z-index', ($('#'+this.menu_stack.last()).css('z-index') || 0) + 1); obj.css('z-index', ($('#'+$.last(this.menu_stack)).css('z-index') || 0) + 1);
} }
else if (!stack && this.menu_stack.length) { else if (!stack && this.menu_stack.length) {
this.hide_menu(this.menu_stack[0], event); this.hide_menu(this.menu_stack[0], event);
@ -7027,7 +7025,7 @@ function rcube_webmail()
// focus previous menu in stack // focus previous menu in stack
if (this.menu_stack.length && keyboard) { if (this.menu_stack.length && keyboard) {
this.menu_keyboard_active = true; this.menu_keyboard_active = true;
this.focused_menu = this.menu_stack.last(); this.focused_menu = $.last(this.menu_stack);
if (!obj || !obj.data('opener')) if (!obj || !obj.data('opener'))
$('#'+this.focused_menu).find('a,input:not(:disabled)').not('[aria-disabled=true]').first().focus(); $('#'+this.focused_menu).find('a,input:not(:disabled)').not('[aria-disabled=true]').first().focus();
} }

@ -607,8 +607,8 @@ if (!String.prototype.startsWith) {
} }
// array utility function // array utility function
Array.prototype.last = function() { jQuery.last = function(arr) {
return this[this.length-1]; return arr && arr.length ? arr[arr.length-1] : undefined;
} }
// jQuery plugin to emulate HTML5 placeholder attributes on input elements // jQuery plugin to emulate HTML5 placeholder attributes on input elements

Loading…
Cancel
Save