From ab8fdaa604b8caecfb9192ea7c6c77417bfbdd47 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Tue, 31 Jul 2012 04:27:37 -0400 Subject: [PATCH] Small code improvement --- program/js/app.js | 29 ++++++++++++++++------------- 1 files changed, 16 insertions(+), 13 deletions(-) diff --git a/program/js/app.js b/program/js/app.js index 01d38fa..e0f3b23 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -5360,13 +5360,6 @@ } }; - // enable/disable buttons for page shifting - this.set_page_buttons = function() - { - this.enable_command('nextpage', 'lastpage', (this.env.pagecount > this.env.current_page)); - this.enable_command('previouspage', 'firstpage', (this.env.current_page > 1)); - }; - // set event handlers on registered buttons this.init_buttons = function() { @@ -5374,7 +5367,7 @@ if (typeof cmd !== 'string') continue; - for (var i=0; i< this.buttons[cmd].length; i++) { + for (var i=0; i<this.buttons[cmd].length; i++) { init_button(cmd, this.buttons[cmd][i]); } } @@ -5393,28 +5386,31 @@ button = a_buttons[n]; obj = document.getElementById(button.id); + if (!obj) + continue; + // get default/passive setting of the button - if (obj && button.type == 'image' && !button.status) { + if (button.type == 'image' && !button.status) { button.pas = obj._original_src ? obj._original_src : obj.src; // respect PNG fix on IE browsers if (obj.runtimeStyle && obj.runtimeStyle.filter && obj.runtimeStyle.filter.match(/src=['"]([^'"]+)['"]/)) button.pas = RegExp.$1; } - else if (obj && !button.status) + else if (!button.status) button.pas = String(obj.className); // set image according to button state - if (obj && button.type == 'image' && button[state]) { + if (button.type == 'image' && button[state]) { button.status = state; obj.src = button[state]; } // set class name according to button state - else if (obj && button[state] !== undefined) { + else if (button[state] !== undefined) { button.status = state; obj.className = button[state]; } // disable/enable input buttons - if (obj && button.type=='input') { + if (button.type == 'input') { button.status = state; obj.disabled = !state; } @@ -5637,6 +5633,13 @@ this.messages = {}; }; + // enable/disable buttons for page shifting + this.set_page_buttons = function() + { + this.enable_command('nextpage', 'lastpage', (this.env.pagecount > this.env.current_page)); + this.enable_command('previouspage', 'firstpage', (this.env.current_page > 1)); + }; + // mark a mailbox as selected and set environment variable this.select_folder = function(name, prefix, encode) { -- Gitblit v1.9.1