[128] | 1 | /** |
---|
| 2 | * http://www.openjs.com/scripts/events/keyboard_shortcuts/ |
---|
| 3 | * Version : 2.01.A |
---|
| 4 | * By Binny V A |
---|
| 5 | * License : BSD |
---|
| 6 | */ |
---|
| 7 | shortcut = { |
---|
| 8 | 'all_shortcuts':{},//All the shortcuts are stored in this array |
---|
[6910] | 9 | 'disabled': false, |
---|
[128] | 10 | 'add': function(shortcut_combination,callback,opt) { |
---|
| 11 | //Provide a set of default options |
---|
| 12 | var default_options = { |
---|
| 13 | 'type':'keydown', |
---|
| 14 | 'propagate':false, |
---|
| 15 | 'disable_in_input':false, |
---|
| 16 | 'target':document, |
---|
| 17 | 'keycode':false |
---|
| 18 | } |
---|
| 19 | if(!opt) opt = default_options; |
---|
| 20 | else { |
---|
| 21 | for(var dfo in default_options) { |
---|
| 22 | if(typeof opt[dfo] == 'undefined') opt[dfo] = default_options[dfo]; |
---|
| 23 | } |
---|
| 24 | } |
---|
[1390] | 25 | |
---|
[5134] | 26 | var ele = opt.target; |
---|
[128] | 27 | if(typeof opt.target == 'string') ele = document.getElementById(opt.target); |
---|
| 28 | var ths = this; |
---|
| 29 | shortcut_combination = shortcut_combination.toLowerCase(); |
---|
| 30 | |
---|
| 31 | //The function to be called at keypress |
---|
| 32 | var func = function(e) { |
---|
| 33 | e = e || window.event; |
---|
| 34 | |
---|
| 35 | if(opt['disable_in_input']) { //Don't enable shortcut keys in Input, Textarea fields |
---|
| 36 | var element; |
---|
| 37 | if(e.target) element=e.target; |
---|
| 38 | else if(e.srcElement) element=e.srcElement; |
---|
| 39 | if(element.nodeType==3) element=element.parentNode; |
---|
[6910] | 40 | |
---|
[128] | 41 | if(element.tagName == 'INPUT' || element.tagName == 'TEXTAREA') return; |
---|
| 42 | } |
---|
[6910] | 43 | |
---|
| 44 | if(shortcut.disabled === true) |
---|
| 45 | return; |
---|
| 46 | |
---|
| 47 | |
---|
[128] | 48 | //Find Which key is pressed |
---|
| 49 | if (e.keyCode) code = e.keyCode; |
---|
| 50 | else if (e.which) code = e.which; |
---|
| 51 | var character = String.fromCharCode(code).toLowerCase(); |
---|
| 52 | |
---|
| 53 | if(code == 188) character=","; //If the user presses , when the type is onkeydown |
---|
| 54 | if(code == 190) character="."; //If the user presses , when the type is onkeydown |
---|
| 55 | |
---|
| 56 | var keys = shortcut_combination.split("+"); |
---|
| 57 | //Key Pressed - counts the number of valid keypresses - if it is same as the number of keys, the shortcut function is invoked |
---|
| 58 | var kp = 0; |
---|
| 59 | |
---|
| 60 | //Work around for stupid Shift key bug created by using lowercase - as a result the shift+num combination was broken |
---|
| 61 | var shift_nums = { |
---|
| 62 | "`":"~", |
---|
| 63 | "1":"!", |
---|
| 64 | "2":"@", |
---|
| 65 | "3":"#", |
---|
| 66 | "4":"$", |
---|
| 67 | "5":"%", |
---|
| 68 | "6":"^", |
---|
| 69 | "7":"&", |
---|
| 70 | "8":"*", |
---|
| 71 | "9":"(", |
---|
| 72 | "0":")", |
---|
| 73 | "-":"_", |
---|
| 74 | "=":"+", |
---|
| 75 | ";":":", |
---|
| 76 | "'":"\"", |
---|
| 77 | ",":"<", |
---|
| 78 | ".":">", |
---|
| 79 | "/":"?", |
---|
| 80 | "\\":"|" |
---|
| 81 | } |
---|
| 82 | //Special Keys - and their codes |
---|
| 83 | var special_keys = { |
---|
| 84 | 'esc':27, |
---|
| 85 | 'escape':27, |
---|
| 86 | 'tab':9, |
---|
| 87 | 'space':32, |
---|
| 88 | 'return':13, |
---|
| 89 | 'enter':13, |
---|
| 90 | 'backspace':8, |
---|
| 91 | |
---|
| 92 | 'scrolllock':145, |
---|
| 93 | 'scroll_lock':145, |
---|
| 94 | 'scroll':145, |
---|
| 95 | 'capslock':20, |
---|
| 96 | 'caps_lock':20, |
---|
| 97 | 'caps':20, |
---|
| 98 | 'numlock':144, |
---|
| 99 | 'num_lock':144, |
---|
| 100 | 'num':144, |
---|
| 101 | |
---|
| 102 | 'pause':19, |
---|
| 103 | 'break':19, |
---|
| 104 | |
---|
| 105 | 'insert':45, |
---|
| 106 | 'home':36, |
---|
| 107 | 'delete':46, |
---|
| 108 | 'end':35, |
---|
| 109 | |
---|
| 110 | 'pageup':33, |
---|
| 111 | 'page_up':33, |
---|
| 112 | 'pu':33, |
---|
| 113 | |
---|
| 114 | 'pagedown':34, |
---|
| 115 | 'page_down':34, |
---|
| 116 | 'pd':34, |
---|
| 117 | |
---|
| 118 | 'left':37, |
---|
| 119 | 'up':38, |
---|
| 120 | 'right':39, |
---|
| 121 | 'down':40, |
---|
| 122 | |
---|
| 123 | 'f1':112, |
---|
| 124 | 'f2':113, |
---|
| 125 | 'f3':114, |
---|
| 126 | 'f4':115, |
---|
| 127 | 'f5':116, |
---|
| 128 | 'f6':117, |
---|
| 129 | 'f7':118, |
---|
| 130 | 'f8':119, |
---|
| 131 | 'f9':120, |
---|
| 132 | 'f10':121, |
---|
| 133 | 'f11':122, |
---|
| 134 | 'f12':123 |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | var modifiers = { |
---|
[4761] | 138 | shift: {wanted:false, pressed:false}, |
---|
| 139 | ctrl : {wanted:false, pressed:false}, |
---|
| 140 | alt : {wanted:false, pressed:false}, |
---|
| 141 | meta : {wanted:false, pressed:false} //Meta is Mac specific |
---|
[128] | 142 | }; |
---|
| 143 | |
---|
| 144 | if(e.ctrlKey) modifiers.ctrl.pressed = true; |
---|
| 145 | if(e.shiftKey) modifiers.shift.pressed = true; |
---|
| 146 | if(e.altKey) modifiers.alt.pressed = true; |
---|
| 147 | if(e.metaKey) modifiers.meta.pressed = true; |
---|
| 148 | |
---|
| 149 | for(var i=0; k=keys[i],i<keys.length; i++) { |
---|
| 150 | //Modifiers |
---|
| 151 | if(k == 'ctrl' || k == 'control') { |
---|
| 152 | kp++; |
---|
| 153 | modifiers.ctrl.wanted = true; |
---|
| 154 | |
---|
| 155 | } else if(k == 'shift') { |
---|
| 156 | kp++; |
---|
| 157 | modifiers.shift.wanted = true; |
---|
| 158 | |
---|
| 159 | } else if(k == 'alt') { |
---|
| 160 | kp++; |
---|
| 161 | modifiers.alt.wanted = true; |
---|
| 162 | } else if(k == 'meta') { |
---|
| 163 | kp++; |
---|
| 164 | modifiers.meta.wanted = true; |
---|
| 165 | } else if(k.length > 1) { //If it is a special key |
---|
| 166 | if(special_keys[k] == code) kp++; |
---|
| 167 | |
---|
| 168 | } else if(opt['keycode']) { |
---|
| 169 | if(opt['keycode'] == code) kp++; |
---|
| 170 | |
---|
| 171 | } else { //The special keys did not match |
---|
| 172 | if(character == k) kp++; |
---|
| 173 | else { |
---|
| 174 | if(shift_nums[character] && e.shiftKey) { //Stupid Shift key bug created by using lowercase |
---|
| 175 | character = shift_nums[character]; |
---|
| 176 | if(character == k) kp++; |
---|
| 177 | } |
---|
| 178 | } |
---|
| 179 | } |
---|
| 180 | } |
---|
| 181 | |
---|
| 182 | if(kp == keys.length && |
---|
| 183 | modifiers.ctrl.pressed == modifiers.ctrl.wanted && |
---|
| 184 | modifiers.shift.pressed == modifiers.shift.wanted && |
---|
| 185 | modifiers.alt.pressed == modifiers.alt.wanted && |
---|
| 186 | modifiers.meta.pressed == modifiers.meta.wanted) { |
---|
| 187 | callback(e); |
---|
| 188 | |
---|
| 189 | if(!opt['propagate']) { //Stop the event |
---|
| 190 | //e.cancelBubble is supported by IE - this will kill the bubbling process. |
---|
[5338] | 191 | if ( Element('border_id_0') && Element('border_id_0').className != 'menu-sel' ){ |
---|
| 192 | return false; |
---|
| 193 | } |
---|
[128] | 194 | e.cancelBubble = true; |
---|
| 195 | e.returnValue = false; |
---|
| 196 | |
---|
[5338] | 197 | |
---|
[128] | 198 | //e.stopPropagation works in Firefox. |
---|
| 199 | if (e.stopPropagation) { |
---|
[5338] | 200 | if ( Element('border_id_0') && Element('border_id_0').className != 'menu-sel' ){ |
---|
| 201 | return false; |
---|
| 202 | } |
---|
| 203 | |
---|
[128] | 204 | e.stopPropagation(); |
---|
| 205 | e.preventDefault(); |
---|
| 206 | } |
---|
| 207 | return false; |
---|
| 208 | } |
---|
[5338] | 209 | |
---|
[128] | 210 | } |
---|
[7881] | 211 | if (currentTab == 0 && code == 13){ |
---|
| 212 | e.stopPropagation(); |
---|
| 213 | e.preventDefault(); |
---|
| 214 | } |
---|
[128] | 215 | } |
---|
| 216 | this.all_shortcuts[shortcut_combination] = { |
---|
| 217 | 'callback':func, |
---|
| 218 | 'target':ele, |
---|
| 219 | 'event': opt['type'] |
---|
| 220 | }; |
---|
| 221 | //Attach the function with the event |
---|
| 222 | if(ele.addEventListener) ele.addEventListener(opt['type'], func, false); |
---|
| 223 | else if(ele.attachEvent) ele.attachEvent('on'+opt['type'], func); |
---|
| 224 | else ele['on'+opt['type']] = func; |
---|
| 225 | }, |
---|
| 226 | |
---|
| 227 | //Remove the shortcut - just specify the shortcut and I will remove the binding |
---|
| 228 | 'remove':function(shortcut_combination) { |
---|
| 229 | shortcut_combination = shortcut_combination.toLowerCase(); |
---|
| 230 | var binding = this.all_shortcuts[shortcut_combination]; |
---|
| 231 | delete(this.all_shortcuts[shortcut_combination]) |
---|
| 232 | if(!binding) return; |
---|
| 233 | var type = binding['event']; |
---|
| 234 | var ele = binding['target']; |
---|
| 235 | var callback = binding['callback']; |
---|
| 236 | |
---|
| 237 | if(ele.detachEvent) ele.detachEvent('on'+type, callback); |
---|
| 238 | else if(ele.removeEventListener) ele.removeEventListener(type, callback, false); |
---|
| 239 | else ele['on'+type] = false; |
---|
| 240 | } |
---|
| 241 | } |
---|
| 242 | |
---|
| 243 | /* ExpressMail Functions */ |
---|
[5338] | 244 | |
---|
[139] | 245 | var shift_up_count = 0; |
---|
| 246 | var shift_down_count = 0; |
---|
[1390] | 247 | var selMessageShortcut = ""; |
---|
| 248 | |
---|
[5939] | 249 | shortcut.add("N",function(e) |
---|
[3194] | 250 | { |
---|
| 251 | // avoids problem related at ticket #1011 |
---|
[5975] | 252 | e.preventDefault(); |
---|
[3194] | 253 | var search_in_focus = false; |
---|
| 254 | var search_win = document.getElementById( 'QuickCatalogSearch_window_QuickCatalogSearch' ); |
---|
| 255 | if ( search_win && search_win.style.visibility != 'hidden' ) |
---|
| 256 | search_in_focus = true; |
---|
[139] | 257 | |
---|
[3194] | 258 | if ( ! search_in_focus ) |
---|
| 259 | new_message("new","null"); |
---|
| 260 | },{'disable_in_input':true}); |
---|
| 261 | |
---|
[139] | 262 | shortcut.add("Esc",function(){ |
---|
| 263 | var window_closed = false; |
---|
[4787] | 264 | var search_win = document.getElementById( 'window_QuickCatalogSearch' ); |
---|
| 265 | |
---|
[7736] | 266 | if ($('.ZebraDialog.custom-zebra-filter').css('visibility') != 'visible') |
---|
[139] | 267 | delete_border(get_msg_id(), 'false'); |
---|
[7736] | 268 | },{'disable_in_input':false}); |
---|
[139] | 269 | |
---|
[4761] | 270 | shortcut.add("I",function(){print_all();},{'disable_in_input':true}); |
---|
[7707] | 271 | shortcut.add("E",function(e){ if(e.preventDefault) e.preventDefault(); else event.returnValue = false; setTimeout(function(){exec_msg_action('forward');},50);},{'disable_in_input':true}); |
---|
| 272 | shortcut.add("R",function(e){ if(e.preventDefault) e.preventDefault(); else event.returnValue = false; setTimeout(function(){exec_msg_action('reply');},50);},{'disable_in_input':true}); |
---|
| 273 | shortcut.add("T",function(e){ if(e.preventDefault) e.preventDefault(); else event.returnValue = false; setTimeout(function(){var msg_id = get_msg_id(); if(msg_id) new_message("reply_to_all_with_history",msg_id);},50);},{'disable_in_input':true}); |
---|
[6070] | 274 | shortcut.add("O",function(e){ if(e.preventDefault) e.preventDefault(); else event.returnValue = false; show_head_option();},{'disable_in_input':true}); |
---|
| 275 | shortcut.add("M",function(e){ if(e.preventDefault) e.preventDefault(); else event.returnValue = false; show_address_full();},{'disable_in_input':true}); |
---|
[1390] | 276 | |
---|
[8064] | 277 | shortcut.add("Delete",function(e){ |
---|
[7153] | 278 | if(currentTab == 0){ |
---|
[7534] | 279 | proxy_mensagens.delete_msgs(current_folder, get_selected_messages(), 'null'); |
---|
[7153] | 280 | }else{ |
---|
[8064] | 281 | if (e.target.className.indexOf("box") == -1) |
---|
| 282 | proxy_mensagens.delete_msgs(openTab.imapBox[currentTab], currentTab.substring(0, selMessageShortcut.indexOf("_r")), 'null'); |
---|
[128] | 283 | } |
---|
| 284 | } |
---|
| 285 | ,{'disable_in_input':true}); |
---|
| 286 | |
---|
[5635] | 287 | shortcut.add("Ctrl+Up",function(){exec_msg_action('previous');/*select_msg('null', 'up');*/},{'disable_in_input':true}); |
---|
| 288 | shortcut.add("Ctrl+Down",function(){exec_msg_action('next');/*select_msg('null', 'down');*/},{'disable_in_input':true}); |
---|
[536] | 289 | |
---|
[6197] | 290 | if (is_ie || is_webkit) |
---|
[536] | 291 | { |
---|
[4761] | 292 | //********************** |
---|
[5911] | 293 | shortcut.add('up', function(e) |
---|
[6930] | 294 | { |
---|
| 295 | if(currentTab == 0){ |
---|
| 296 | $(".selected_shortcut_msg").removeClass("selected_shortcut_msg"); |
---|
| 297 | if($(".current_selected_shortcut_msg").prev().parents("#tbody_box").length) |
---|
| 298 | $(".current_selected_shortcut_msg").blur().removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg"); |
---|
| 299 | $(".current_selected_shortcut_msg").addClass("selected_shortcut_msg").focus(); |
---|
| 300 | } |
---|
| 301 | },{'disable_in_input':true}); |
---|
[4761] | 302 | |
---|
| 303 | |
---|
[6930] | 304 | shortcut.add('down', function(e) |
---|
| 305 | { |
---|
| 306 | if(currentTab == 0){ |
---|
| 307 | $(".selected_shortcut_msg").removeClass("selected_shortcut_msg"); |
---|
| 308 | if($(".current_selected_shortcut_msg").next().parents("#tbody_box").length) |
---|
| 309 | $(".current_selected_shortcut_msg").blur().removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg"); |
---|
| 310 | $(".current_selected_shortcut_msg").addClass("selected_shortcut_msg").focus(); |
---|
| 311 | } |
---|
| 312 | },{'disable_in_input':true}); |
---|
[4761] | 313 | |
---|
[6930] | 314 | shortcut.add('space', function(e) |
---|
| 315 | { |
---|
| 316 | if(currentTab == 0){ |
---|
| 317 | var allchecked = true; |
---|
| 318 | $.each( $(".selected_shortcut_msg"), function(index, value){ |
---|
| 319 | if($(value).find(":checkbox").attr("checked") == undefined){ |
---|
| 320 | allchecked = false; |
---|
| 321 | } |
---|
| 322 | }); |
---|
| 323 | if(allchecked){ |
---|
| 324 | $(".selected_shortcut_msg").removeClass("selected_msg").find('input[type="checkbox"]').removeAttr("checked"); |
---|
| 325 | }else{ |
---|
| 326 | //$(".current_selected_shortcut_msg").addClass("selected_msg").find('input[type="checkbox"]').attr("checked", true); |
---|
| 327 | $(".selected_shortcut_msg").addClass("selected_msg").find('input[type="checkbox"]').attr("checked", true); |
---|
| 328 | } |
---|
| 329 | $.each( $(".selected_shortcut_msg"), function(index, value){ |
---|
| 330 | updateSelectedMsgs($(value).find(":checkbox").is(':checked'),$(value).attr("id")); |
---|
| 331 | }); |
---|
| 332 | $(".current_selected_shortcut_msg").focus(); |
---|
| 333 | } |
---|
| 334 | },{'disable_in_input':true}); |
---|
[4761] | 335 | |
---|
| 336 | //**************** |
---|
| 337 | |
---|
[6930] | 338 | shortcut.add("Shift+down",function() |
---|
| 339 | { |
---|
| 340 | if(currentTab == 0){ |
---|
| 341 | //$(".selected_shortcut_msg").removeClass("selected_shortcut_msg"); |
---|
| 342 | if($(".current_selected_shortcut_msg").next().parents("#tbody_box").length) |
---|
| 343 | if($(".current_selected_shortcut_msg").next().hasClass("selected_shortcut_msg")) |
---|
| 344 | $(".current_selected_shortcut_msg").blur().removeClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg"); |
---|
| 345 | else |
---|
| 346 | $(".current_selected_shortcut_msg").blur().addClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg"); |
---|
| 347 | $(".current_selected_shortcut_msg").focus(); |
---|
| 348 | } |
---|
| 349 | },{'disable_in_input':true, 'propagate':false}); |
---|
| 350 | |
---|
| 351 | shortcut.add("Shift+up",function(){ |
---|
| 352 | if(currentTab == 0){ |
---|
| 353 | //$(".selected_shortcut_msg").removeClass("selected_shortcut_msg"); |
---|
| 354 | if($(".current_selected_shortcut_msg").prev().parents("#tbody_box").length) |
---|
| 355 | if($(".current_selected_shortcut_msg").prev().hasClass("selected_shortcut_msg")) |
---|
| 356 | $(".current_selected_shortcut_msg").blur().removeClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg"); |
---|
| 357 | else |
---|
| 358 | $(".current_selected_shortcut_msg").blur().addClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg"); |
---|
| 359 | $(".current_selected_shortcut_msg").focus(); |
---|
| 360 | } |
---|
| 361 | },{'disable_in_input':true, 'propagate':false}); |
---|
[139] | 362 | } |
---|
[536] | 363 | else |
---|
| 364 | { |
---|
[6930] | 365 | shortcut.add("Up",function(){ |
---|
[7406] | 366 | if (currentTab == 0){ |
---|
| 367 | $(".selected_shortcut_msg").removeClass("selected_shortcut_msg"); |
---|
| 368 | if($(".current_selected_shortcut_msg").prev().parents("#tbody_box").length) |
---|
| 369 | $(".current_selected_shortcut_msg").blur().removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg"); |
---|
| 370 | $(".current_selected_shortcut_msg").focus(); |
---|
| 371 | } |
---|
[6930] | 372 | },{'disable_in_input':true}); |
---|
[6707] | 373 | |
---|
[6930] | 374 | shortcut.add("Down",function(){ |
---|
[7406] | 375 | if (currentTab == 0){ |
---|
| 376 | $(".selected_shortcut_msg").removeClass("selected_shortcut_msg"); |
---|
| 377 | if($(".current_selected_shortcut_msg").next().parents("#tbody_box").length) |
---|
| 378 | $(".current_selected_shortcut_msg").blur().removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg"); |
---|
| 379 | $(".current_selected_shortcut_msg").focus(); |
---|
| 380 | } |
---|
[6930] | 381 | },{'disable_in_input':true}); |
---|
| 382 | |
---|
| 383 | shortcut.add("Shift+down",function(){ |
---|
| 384 | if(currentTab == 0){ |
---|
| 385 | if($(".current_selected_shortcut_msg").next().parents("#tbody_box").length) |
---|
| 386 | if($(".current_selected_shortcut_msg").next().hasClass("selected_shortcut_msg")) |
---|
| 387 | $(".current_selected_shortcut_msg").blur().removeClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg"); |
---|
| 388 | else |
---|
| 389 | $(".current_selected_shortcut_msg").blur().addClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg"); |
---|
| 390 | $(".current_selected_shortcut_msg").focus(); |
---|
| 391 | } |
---|
| 392 | },{'type':'keypress','disable_in_input':true, 'propagate':false}); |
---|
| 393 | |
---|
| 394 | shortcut.add("Shift+up",function(){ |
---|
| 395 | if(currentTab == 0){ |
---|
| 396 | if($(".current_selected_shortcut_msg").prev().parents("#tbody_box").length) |
---|
| 397 | if($(".current_selected_shortcut_msg").prev().hasClass("selected_shortcut_msg")) |
---|
| 398 | $(".current_selected_shortcut_msg").blur().removeClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg"); |
---|
| 399 | else |
---|
| 400 | $(".current_selected_shortcut_msg").blur().addClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg"); |
---|
| 401 | $(".current_selected_shortcut_msg").focus(); |
---|
| 402 | } |
---|
| 403 | },{'type':'keypress', 'disable_in_input':true, 'propagate':false}); |
---|
| 404 | shortcut.add('Space', function(e) |
---|
| 405 | { |
---|
| 406 | if(currentTab == 0){ |
---|
| 407 | var allchecked = true; |
---|
| 408 | $.each( $(".selected_shortcut_msg"), function(index, value){ |
---|
| 409 | if($(value).find(":checkbox").attr("checked") == undefined){ |
---|
| 410 | allchecked = false; |
---|
| 411 | } |
---|
| 412 | }); |
---|
| 413 | if(allchecked){ |
---|
| 414 | |
---|
| 415 | $(".selected_shortcut_msg").removeClass("selected_msg").find('input[type="checkbox"]').removeAttr("checked"); |
---|
| 416 | }else{ |
---|
| 417 | //$(".current_selected_shortcut_msg").addClass("selected_msg").find('input[type="checkbox"]').attr("checked", true); |
---|
| 418 | $(".selected_shortcut_msg").addClass("selected_msg").find('input[type="checkbox"]').attr("checked", true); |
---|
| 419 | } |
---|
| 420 | |
---|
| 421 | $.each( $(".selected_shortcut_msg"), function(index, value){ |
---|
| 422 | updateSelectedMsgs($(value).find(":checkbox").is(':checked'),$(value).attr("id")); |
---|
| 423 | }); |
---|
| 424 | } |
---|
| 425 | },{'disable_in_input':true}); |
---|
[139] | 426 | } |
---|
[128] | 427 | |
---|
| 428 | shortcut.add("return",function(){ |
---|
[6930] | 429 | if ( Element('border_id_0').className==='menu-sel' ) |
---|
| 430 | { |
---|
| 431 | all_messages = Element('tbody_box').childNodes; |
---|
| 432 | for (var i=0; i < all_messages.length; i++) |
---|
| 433 | { |
---|
| 434 | if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) |
---|
| 435 | { |
---|
| 436 | Element("td_from_" + all_messages[i].id).onclick(); |
---|
| 437 | return; |
---|
| 438 | } |
---|
| 439 | } |
---|
| 440 | } |
---|
[4761] | 441 | },{'disable_in_input':true}); |
---|
[128] | 442 | |
---|
[139] | 443 | shortcut.add("f9",function(){ |
---|
[6930] | 444 | Element("em_refresh_button").onclick(); |
---|
| 445 | return; |
---|
| 446 | },{'disable_in_input':false}); |
---|
[128] | 447 | |
---|
| 448 | function exec_msg_action(action) |
---|
| 449 | { |
---|
[6930] | 450 | var msg_id = get_msg_id(); |
---|
| 451 | if (msg_id) |
---|
| 452 | { |
---|
| 453 | var msg_id = 'msg_opt_' + action + '_' + msg_id; |
---|
| 454 | try {Element(msg_id).onclick();} |
---|
| 455 | catch(e){/*alert(e);*/} |
---|
[128] | 456 | } |
---|
[6930] | 457 | return; |
---|
| 458 | } |
---|
[128] | 459 | |
---|
[3168] | 460 | function show_head_option() |
---|
| 461 | { |
---|
[6930] | 462 | var msg_id = get_msg_id(); |
---|
[3168] | 463 | if (msg_id) { |
---|
[6930] | 464 | var msg_id = 'option_hide_more_' + msg_id; |
---|
| 465 | try {Element(msg_id).onclick();} |
---|
| 466 | catch(e){/*alert(e);*/} |
---|
[3168] | 467 | } |
---|
[6930] | 468 | return; |
---|
| 469 | } |
---|
[3168] | 470 | |
---|
| 471 | function show_address_full() |
---|
| 472 | { |
---|
[6930] | 473 | var toaddress = Element('div_toaddress_' + get_msg_id()); |
---|
| 474 | var ccaddress = Element('div_ccaddress_' + get_msg_id()); |
---|
| 475 | |
---|
| 476 | if(toaddress && '' == toaddress.style.display) { |
---|
| 477 | show_div_address_full(get_msg_id(),'to'); |
---|
| 478 | } |
---|
| 479 | else { |
---|
| 480 | if(toaddress) |
---|
| 481 | toaddress.style.display = ''; |
---|
| 482 | var toaddress_full = Element('div_toaddress_full_' + get_msg_id()); |
---|
| 483 | if(toaddress_full) |
---|
| 484 | toaddress_full.style.display = 'none'; |
---|
| 485 | } |
---|
| 486 | if(ccaddress && '' == ccaddress.style.display) { |
---|
| 487 | show_div_address_full(get_msg_id(),'cc'); |
---|
| 488 | } |
---|
| 489 | else { |
---|
| 490 | if(ccaddress) |
---|
| 491 | ccaddress.style.display = ''; |
---|
| 492 | var ccaddress_full = Element('div_ccaddress_full_' + get_msg_id()); |
---|
| 493 | if(ccaddress_full) |
---|
| 494 | ccaddress_full.style.display = 'none'; |
---|
| 495 | } |
---|
| 496 | return; |
---|
[3168] | 497 | } |
---|
| 498 | |
---|
[128] | 499 | function get_msg_id() |
---|
| 500 | { |
---|
[6930] | 501 | children = Element('border_tr').childNodes; |
---|
| 502 | |
---|
| 503 | for (var i=0; i<children.length; i++) |
---|
| 504 | { |
---|
| 505 | if ( (children[i].nodeName==='TD') && (children[i].className==='menu-sel') && children[i].id != 'border_id_0') |
---|
| 506 | { |
---|
| 507 | var border_selected = children[i]; |
---|
| 508 | var msg_id = border_selected.id.replace("border_id_",""); |
---|
| 509 | return msg_id; |
---|
| 510 | } |
---|
| 511 | } |
---|
| 512 | return false; |
---|
[128] | 513 | } |
---|
| 514 | |
---|
[163] | 515 | function select_msg(msg_number, keyboard_action, force_msg_selection) |
---|
[128] | 516 | { |
---|
[6930] | 517 | /* |
---|
| 518 | ** Se caso for limpado toda a caixa de email, |
---|
| 519 | ** e adicionado um novo atalho de selecao. |
---|
| 520 | ** main.js on function refrash and line 629. |
---|
| 521 | */ |
---|
| 522 | $("#table_box").find("tr").attr("tabindex", -1); |
---|
[7038] | 523 | $("#table_box").find("tr").css("outline", "none"); |
---|
[139] | 524 | |
---|
[6930] | 525 | if(keyboard_action == "reload_msg"){ |
---|
| 526 | if( $("#tbody_box .current_selected_shortcut_msg").length == 0 ){ |
---|
| 527 | $("#tbody_box tr:first").addClass("current_selected_shortcut_msg selected_shortcut_msg"); |
---|
| 528 | } |
---|
[1390] | 529 | } |
---|
[139] | 530 | |
---|
[6930] | 531 | shift_up_count = 0; |
---|
| 532 | shift_down_count = 0; |
---|
| 533 | |
---|
| 534 | if (msg_number != 'null') { |
---|
| 535 | |
---|
| 536 | if(Element(msg_number)){ |
---|
| 537 | unselect_all_msgs(); |
---|
| 538 | $("#tbody_box tr").removeClass("current_selected_shortcut_msg selected_shortcut_msg"); |
---|
| 539 | $("#"+msg_number).addClass('current_selected_shortcut_msg selected_shortcut_msg'); |
---|
| 540 | } |
---|
| 541 | |
---|
| 542 | } else { |
---|
| 543 | var scrollMain = Element('divScrollMain_0'); |
---|
| 544 | var selection_size = parseInt(preferences.line_height) + 10; |
---|
| 545 | |
---|
| 546 | if( keyboard_action == 'down') { |
---|
| 547 | |
---|
| 548 | if(!Element("chk_box_select_all_messages").checked){ |
---|
| 549 | |
---|
| 550 | $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){ |
---|
| 551 | |
---|
| 552 | if($(this).hasClass("selected_shortcut_msg") && $(this).next().length){ |
---|
[7757] | 553 | $(this).removeClass("selected_shortcut_msg current_selected_shortcut_msg"); |
---|
[7103] | 554 | $(this).next().addClass("selected_shortcut_msg current_selected_shortcut_msg"); |
---|
[6930] | 555 | return false; |
---|
| 556 | } |
---|
| 557 | }); |
---|
| 558 | |
---|
| 559 | } else { |
---|
| 560 | |
---|
| 561 | $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){ |
---|
| 562 | |
---|
| 563 | if($(this).hasClass("current_selected") && $(this).next().length){ |
---|
| 564 | $(this).removeClass("current_selected"); |
---|
| 565 | $(this).removeClass("selected_shortcut_msg"); |
---|
| 566 | $(this).next().addClass("current_selected"); |
---|
| 567 | $(this).next().addClass("selected_shortcut_msg"); |
---|
| 568 | return false; |
---|
| 569 | } |
---|
| 570 | |
---|
| 571 | }); |
---|
| 572 | $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){ |
---|
| 573 | if(!$(this).hasClass("current_selected")) |
---|
| 574 | $(this).removeClass("selected_shortcut_msg"); |
---|
| 575 | }); |
---|
| 576 | } |
---|
| 577 | |
---|
| 578 | } else if( keyboard_action == 'up') { |
---|
| 579 | |
---|
| 580 | if(!Element("chk_box_select_all_messages").checked){ |
---|
| 581 | |
---|
| 582 | $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){ |
---|
| 583 | |
---|
| 584 | if($(this).hasClass("selected_shortcut_msg") && $(this).prev().length){ |
---|
[7757] | 585 | $(this).removeClass("selected_shortcut_msg current_selected_shortcut_msg"); |
---|
[7103] | 586 | $(this).prev().addClass("selected_shortcut_msg current_selected_shortcut_msg"); |
---|
[6930] | 587 | return false; |
---|
| 588 | } |
---|
| 589 | |
---|
| 590 | }); |
---|
| 591 | |
---|
| 592 | } else { |
---|
| 593 | |
---|
| 594 | $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){ |
---|
| 595 | |
---|
| 596 | if($(this).hasClass("current_selected") && $(this).prev().length){ |
---|
| 597 | $(this).removeClass("current_selected"); |
---|
| 598 | $(this).removeClass("selected_shortcut_msg"); |
---|
| 599 | $(this).prev().addClass("current_selected"); |
---|
| 600 | $(this).prev().addClass("selected_shortcut_msg"); |
---|
| 601 | return false; |
---|
| 602 | } |
---|
| 603 | |
---|
| 604 | }); |
---|
| 605 | $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){ |
---|
| 606 | if(!$(this).hasClass("current_selected")) |
---|
| 607 | $(this).removeClass("selected_shortcut_msg"); |
---|
| 608 | }); |
---|
| 609 | |
---|
| 610 | } |
---|
| 611 | |
---|
| 612 | } |
---|
| 613 | return true; |
---|
| 614 | } |
---|
| 615 | } |
---|
| 616 | |
---|
[139] | 617 | function select_bottom_msg() |
---|
| 618 | { |
---|
[6930] | 619 | all_messages = Element('tbody_box').childNodes; |
---|
| 620 | |
---|
| 621 | if ( exist_className(all_messages[all_messages.length-1], 'selected_shortcut_msg') ) |
---|
| 622 | return; |
---|
| 623 | |
---|
| 624 | for (var i=all_messages.length-1; i >=0; i--) |
---|
| 625 | { |
---|
| 626 | if ( (exist_className(all_messages[i], 'selected_shortcut_msg')) && (i+1 <= all_messages.length-1) ) |
---|
| 627 | { |
---|
| 628 | shift_down_count++; |
---|
| 629 | add_className(all_messages[i+1], 'selected_msg'); |
---|
| 630 | break; |
---|
| 631 | } |
---|
| 632 | } |
---|
[139] | 633 | } |
---|
| 634 | |
---|
| 635 | function select_top_msg() |
---|
| 636 | { |
---|
[6930] | 637 | all_messages = Element('tbody_box').childNodes; |
---|
| 638 | |
---|
| 639 | if ( exist_className(all_messages[0], 'selected_shortcut_msg') ) |
---|
| 640 | return; |
---|
| 641 | |
---|
| 642 | for (var i=0; i <=all_messages.length-1; i++) |
---|
| 643 | { |
---|
| 644 | if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) |
---|
| 645 | { |
---|
| 646 | shift_up_count++; |
---|
| 647 | add_className(all_messages[i-1], 'selected_msg'); |
---|
| 648 | break; |
---|
| 649 | } |
---|
| 650 | } |
---|
[139] | 651 | } |
---|
| 652 | |
---|
| 653 | function unselect_bottom_msg() |
---|
| 654 | { |
---|
[6930] | 655 | all_messages = Element('tbody_box').childNodes; |
---|
| 656 | for (var i=all_messages.length-1; i >=0; i--) |
---|
| 657 | { |
---|
| 658 | if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) |
---|
| 659 | { |
---|
| 660 | shift_down_count--; |
---|
| 661 | remove_className(all_messages[i], 'selected_msg'); |
---|
| 662 | break; |
---|
| 663 | } |
---|
| 664 | } |
---|
[139] | 665 | } |
---|
| 666 | |
---|
| 667 | function unselect_top_msg() |
---|
| 668 | { |
---|
[6930] | 669 | all_messages = Element('tbody_box').childNodes; |
---|
| 670 | for (var i=0; i <=all_messages.length-1; i++) |
---|
| 671 | { |
---|
| 672 | if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) |
---|
| 673 | { |
---|
| 674 | shift_up_count--; |
---|
| 675 | remove_className(all_messages[i], 'selected_msg'); |
---|
| 676 | break; |
---|
| 677 | } |
---|
| 678 | } |
---|
[163] | 679 | } |
---|
| 680 | |
---|
| 681 | function unselect_all_msgs() |
---|
| 682 | { |
---|
[6930] | 683 | all_messages = Element('tbody_box').childNodes; |
---|
| 684 | for (var i=0; i <=all_messages.length-1; i++) |
---|
| 685 | { |
---|
| 686 | remove_className(all_messages[i], 'selected_msg'); |
---|
| 687 | } |
---|
[6070] | 688 | } |
---|