Changeset 2275 in subversion
- Timestamp:
- Feb 6, 2009 8:54:21 AM (4 years ago)
- Location:
- branches/devel-api
- Files:
-
- 5 edited
-
program/js/app.js (modified) (15 diffs)
-
program/js/common.js (modified) (7 diffs)
-
program/js/list.js (modified) (12 diffs)
-
skins/default/functions.js (modified) (3 diffs)
-
skins/default/mail.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/devel-api/program/js/app.js
r2265 r2275 11 11 | Charles McNulty <charles@charlesmcnulty.com> | 12 12 +-----------------------------------------------------------------------+ 13 | Requires: common.js, list.js|13 | Requires: jquery.js, common.js, list.js | 14 14 +-----------------------------------------------------------------------+ 15 15 … … 19 19 20 20 function rcube_webmail() 21 {21 { 22 22 this.env = new Object(); 23 23 this.labels = new Object(); … … 120 120 // execute the given script on load 121 121 this.add_onload = function(f) 122 {123 this.onloads[this.onloads.length] = f;124 };122 { 123 this.onloads[this.onloads.length] = f; 124 }; 125 125 126 126 // initialize webmail client … … 524 524 return ret !== null ? ret : (obj ? false : true); 525 525 } 526 527 // trigger plugin hook 528 var event_ret = this.triggerEvent('before'+command, props); 529 if (typeof event_ret != 'undefined') { 530 // abort if one the handlers returned false 531 if (event_ret === false) 532 return false; 533 else 534 props = event_ret; 535 } 526 536 527 537 // process internal command … … 535 545 case 'logout': 536 546 this.goto_url('logout', '', true); 537 break; 547 break; 538 548 539 549 // commands to switch task … … 1085 1095 1086 1096 } 1097 1098 this.triggerEvent('after'+command, props); 1087 1099 1088 1100 return obj ? false : true; … … 1180 1192 this.doc_mouse_up = function(e) 1181 1193 { 1182 var model, li ;1194 var model, list, li; 1183 1195 1184 1196 if (this.message_list) { 1185 1197 this.message_list.blur(); 1198 list = this.message_list; 1186 1199 model = this.env.mailboxes; 1187 1200 } 1188 1201 else if (this.contact_list) { 1189 1202 this.contact_list.blur(); 1203 list = this.contact_list; 1190 1204 model = this.env.address_sources; 1191 1205 } … … 1199 1213 this.command('moveto', model[this.env.last_folder_target].id); 1200 1214 this.env.last_folder_target = null; 1215 list.draglayer.hide(); 1201 1216 } 1202 1217 }; … … 1254 1269 this.env.last_folder_target = k; 1255 1270 } 1256 else 1271 else { 1257 1272 $(this.get_folder_li(k)).removeClass('droptarget'); 1273 this.env.last_folder_target = null; 1274 } 1258 1275 } 1259 1276 } … … 2418 2435 highlight = document.getElementById('rcmksearchSelected'); 2419 2436 if (!highlight) 2420 highlight = this.ksearch_pane. ul.firstChild;2437 highlight = this.ksearch_pane.__ul.firstChild; 2421 2438 2422 2439 if (highlight) … … 2494 2511 return; 2495 2512 2496 if (this.ksearch_pane && this.ksearch_pane. visible)2497 this.ksearch_pane. show(0);2513 if (this.ksearch_pane && this.ksearch_pane.is(":visible")) 2514 this.ksearch_pane.hide(); 2498 2515 2499 2516 // get string from current cursor pos to last comma … … 2539 2556 // create results pane if not present 2540 2557 if (!this.ksearch_pane) { 2541 ul = document.createElement('UL'); 2542 this.ksearch_pane = new rcube_layer('rcmKSearchpane', {vis:0, zindex:30000}); 2543 this.ksearch_pane.elm.appendChild(ul); 2544 this.ksearch_pane.ul = ul; 2545 } 2546 else 2547 ul = this.ksearch_pane.ul; 2558 ul = $('<ul>'); 2559 this.ksearch_pane = $('<div>').attr('id', 'rcmKSearchpane').css({ position:'absolute', 'z-index':30000 }).append(ul).appendTo(document.body); 2560 this.ksearch_pane.__ul = ul[0]; 2561 } 2548 2562 2549 2563 // remove all search results 2564 ul = this.ksearch_pane.__ul; 2550 2565 ul.innerHTML = ''; 2551 2566 … … 2578 2593 // move the results pane right under the input box and make it visible 2579 2594 var pos = $(this.ksearch_input).offset(); 2580 this.ksearch_pane.move(pos.left, pos.top + this.ksearch_input.offsetHeight); 2581 this.ksearch_pane.show(1); 2595 this.ksearch_pane.css({ left:pos.left+'px', top:(pos.top + this.ksearch_input.offsetHeight)+'px' }).show(); 2582 2596 } 2583 2597 // hide results pane … … 2612 2626 2613 2627 if (this.ksearch_pane) 2614 this.ksearch_pane. show(0);2628 this.ksearch_pane.hide(); 2615 2629 }; 2616 2630 … … 3965 3979 }; 3966 3980 3967 } // end object rcube_webmail 3968 3981 } // end object rcube_webmail 3982 3983 3984 // copy event engine prototype 3985 rcube_webmail.prototype.addEventListener = rcube_event_engine.prototype.addEventListener; 3986 rcube_webmail.prototype.removeEventListener = rcube_event_engine.prototype.removeEventListener; 3987 rcube_webmail.prototype.triggerEvent = rcube_event_engine.prototype.triggerEvent; 3988 -
branches/devel-api/program/js/common.js
r2228 r2275 94 94 95 95 96 // static functions for event handling96 // static functions for DOM event handling 97 97 var rcube_event = { 98 98 … … 235 235 236 236 237 var rcube_layer_objects = new Array(); 237 /** 238 * rcmail objects event interface 239 */ 240 function rcube_event_engine() 241 { 242 this._events = {}; 243 } 244 245 rcube_event_engine.prototype = { 246 247 /** 248 * Setter for object event handlers 249 * 250 * @param {String} Event name 251 * @param {Function} Handler function 252 * @return Listener ID (used to remove this handler later on) 253 */ 254 addEventListener: function(evt, func, obj) 255 { 256 if (!this._events) 257 this._events = {}; 258 if (!this._events[evt]) 259 this._events[evt] = []; 260 261 var e = {func:func, obj:obj ? obj : window}; 262 this._events[evt][this._events[evt].length] = e; 263 }, 264 265 /** 266 * Removes a specific event listener 267 * 268 * @param {String} Event name 269 * @param {Int} Listener ID to remove 270 */ 271 removeEventListener: function(evt, func, obj) 272 { 273 if (typeof obj == 'undefined') 274 obj = window; 275 276 for (var h,i=0; this._events && this._events[evt] && i < this._events[evt].length; i++) 277 if ((h = this._events[evt][i]) && h.func == func && h.obj == obj) 278 this._events[evt][i] = null; 279 }, 280 281 /** 282 * This will execute all registered event handlers 283 * 284 * @param {String} Event to trigger 285 * @param {Object} Event object/arguments 286 */ 287 triggerEvent: function(evt, e) 288 { 289 var ret, h; 290 if (typeof e == 'undefined') 291 e = {}; 292 if (typeof e == 'object') 293 e.event = evt; 294 295 if (this._events && this._events[evt] && !this._event_exec) { 296 this._event_exec = true; 297 for (var i=0; i < this._events[evt].length; i++) { 298 if ((h = this._events[evt][i])) { 299 if (typeof h.func == 'function') 300 ret = h.func.call ? h.func.call(h.obj, this, e) : h.func(this, e); 301 else if (typeof h.obj[h.func] == 'function') 302 ret = h.obj[h.func](this, e); 303 304 // cancel event execution 305 if (typeof ret != 'undefined' && !ret) 306 break; 307 } 308 } 309 } 310 311 this._event_exec = false; 312 return ret; 313 } 314 315 } // end rcube_event_engine.prototype 316 238 317 239 318 … … 244 323 */ 245 324 function rcube_layer(id, attributes) 246 {325 { 247 326 this.name = id; 248 327 … … 311 390 this.visible = (this.css.visibility=='visible' || this.css.visibility=='show' || this.css.visibility=='inherit') ? true : false; 312 391 313 this.id = rcube_layer_objects.length;314 this.obj = 'rcube_layer_objects['+this.id+']';315 rcube_layer_objects[this.id] = this;316 317 392 318 393 // ********* layer object methods ********* … … 328 403 } 329 404 330 331 // move the layer for a specific step332 this.shift = function(x,y)333 {334 x = Math.round(x*100)/100;335 y = Math.round(y*100)/100;336 this.move(this.x+x, this.y+y);337 }338 339 340 405 // change the layers width and height 341 406 this.resize = function(w,h) … … 345 410 this.width = w; 346 411 this.height = h; 347 }348 349 350 // cut the layer (top,width,height,left)351 this.clip = function(t,w,h,l)352 {353 this.css.clip='rect('+t+' '+w+' '+h+' '+l+')';354 this.clip_height = h;355 this.clip_width = w;356 412 } 357 413 … … 384 440 } 385 441 386 387 // set the given color to the layer background 388 this.set_bgcolor = function(c) 389 { 390 if(!c || c=='#') 391 c = 'transparent'; 392 393 this.css.backgroundColor = c; 394 } 395 396 397 // set the opacity of a layer to the given ammount (in %) 398 this.set_opacity = function(v) 399 { 400 if(!bw.opacity) 401 return; 402 403 var op = v<=1 ? Math.round(v*100) : parseInt(v); 404 405 if(bw.ie) 406 this.css.filter = 'alpha(opacity:'+op+')'; 407 else if(bw.safari) 408 { 409 this.css.opacity = op/100; 410 this.css.KhtmlOpacity = op/100; 411 } 412 else if(bw.mz) 413 this.css.MozOpacity = op/100; 414 } 415 } 442 } 416 443 417 444 -
branches/devel-api/program/js/list.js
r2260 r2275 52 52 this.dblclick_time = 600; 53 53 this.row_init = function(){}; 54 this.events = { click:[], dblclick:[], select:[], keypress:[], dragstart:[], dragmove:[], dragend:[] };55 54 56 55 // overwrite default paramaters … … 306 305 // row was double clicked 307 306 if (this.rows && dblclicked && this.in_selection(id)) 308 this.trigger _event('dblclick');307 this.triggerEvent('dblclick'); 309 308 else 310 this.trigger _event('click');309 this.triggerEvent('click'); 311 310 312 311 if (!this.drag_active) … … 406 405 // trigger event if selection changed 407 406 if (this.selection.join(',') != select_before) 408 this.trigger _event('select');407 this.triggerEvent('select'); 409 408 410 409 if (this.last_selected != 0 && this.rows[this.last_selected]) … … 518 517 // trigger event if selection changed 519 518 if (this.selection.join(',') != select_before) 520 this.trigger _event('select');519 this.triggerEvent('select'); 521 520 522 521 this.focus(); … … 554 553 555 554 if (num_select && !this.selection.length) 556 this.trigger _event('select');555 this.triggerEvent('select'); 557 556 }, 558 557 … … 634 633 this.shiftkey = e.shiftKey; 635 634 this.key_pressed = keyCode; 636 this.trigger _event('keypress');635 this.triggerEvent('keypress'); 637 636 638 637 if (this.key_pressed == this.BACKSPACE_KEY) … … 719 718 720 719 if (!this.draglayer) 721 this.draglayer = new rcube_layer('rcmdraglayer', {x:0, y:0, vis:0, zindex:2000});720 this.draglayer = $('<div>').attr('id', 'rcmdraglayer').css({ position:'absolute', display:'none', 'z-index':2000 }).appendTo(document.body); 722 721 723 722 // get subjects of selectedd messages … … 734 733 if (this.rows[this.selection[n]].obj) 735 734 { 735 if (n == 0) 736 this.drag_start_pos = $(this.rows[this.selection[n]].obj).offset(); 737 736 738 obj = this.rows[this.selection[n]].obj; 737 739 subject = ''; … … 754 756 } 755 757 756 this.draglayer. write(names);757 this.draglayer.show( 1);758 this.draglayer.html(names); 759 this.draglayer.show(); 758 760 759 761 this.drag_active = true; 760 this.trigger _event('dragstart');762 this.triggerEvent('dragstart'); 761 763 } 762 764 … … 764 766 { 765 767 var pos = rcube_event.get_mouse_pos(e); 766 this.draglayer. move(pos.x+20, pos.y-5);767 this.trigger _event('dragmove', e);768 this.draglayer.css({ left:(pos.x+20)+'px', top:(pos.y-5)+'px' }); 769 this.triggerEvent('dragmove', e); 768 770 } 769 771 … … 781 783 document.onmousemove = null; 782 784 783 if (this.draglayer && this.draglayer.visible) 784 this.draglayer.show(0); 785 if (this.draglayer && this.draglayer.is(':visible')) { 786 if (this.drag_start_pos) 787 this.draglayer.animate(this.drag_start_pos, 300, 'swing').hide(20); 788 else 789 this.draglayer.hide(); 790 } 785 791 786 792 this.drag_active = false; 787 this.trigger _event('dragend');793 this.triggerEvent('dragend'); 788 794 789 795 rcube_event.remove_listener({element:document, event:'mousemove', object:this, method:'drag_mouse_move'}); … … 817 823 818 824 return rcube_event.cancel(e); 819 },820 821 822 823 /**824 * Setter for object event handlers825 *826 * @param {String} Event name827 * @param {Function} Handler function828 * @return Listener ID (used to remove this handler later on)829 */830 addEventListener: function(evt, handler)831 {832 if (this.events[evt]) {833 var handle = this.events[evt].length;834 this.events[evt][handle] = handler;835 return handle;836 }837 else838 return false;839 },840 841 842 /**843 * Removes a specific event listener844 *845 * @param {String} Event name846 * @param {Int} Listener ID to remove847 */848 removeEventListener: function(evt, handle)849 {850 if (this.events[evt] && this.events[evt][handle])851 this.events[evt][handle] = null;852 },853 854 855 /**856 * This will execute all registered event handlers857 * @private858 */859 trigger_event: function(evt, p)860 {861 if (this.events[evt] && this.events[evt].length) {862 for (var i=0; i<this.events[evt].length; i++)863 if (typeof(this.events[evt][i]) == 'function')864 this.events[evt][i](this, p);865 }866 825 } 867 826 868 869 827 }; 870 828 829 rcube_list_widget.prototype.addEventListener = rcube_event_engine.prototype.addEventListener; 830 rcube_list_widget.prototype.removeEventListener = rcube_event_engine.prototype.removeEventListener; 831 rcube_list_widget.prototype.triggerEvent = rcube_event_engine.prototype.triggerEvent; -
branches/devel-api/skins/default/functions.js
r2196 r2275 129 129 function rcube_mail_ui() 130 130 { 131 this.markmenu = new rcube_layer('markmessagemenu');131 this.markmenu = $('#markmessagemenu'); 132 132 } 133 133 … … 137 137 { 138 138 if (typeof show == 'undefined') 139 show = this.markmenu. visible? false : true;139 show = this.markmenu.is(':visible') ? false : true; 140 140 141 141 var ref = rcube_find_object('markreadbutton'); 142 142 if (show && ref) 143 this.markmenu. move(ref.offsetLeft, ref.offsetTop + ref.offsetHeight);143 this.markmenu.css({ left:ref.offsetLeft, top:(ref.offsetTop + ref.offsetHeight) }); 144 144 145 this.markmenu .show(show);145 this.markmenu[show?'show':'hide'](); 146 146 }, 147 147 148 148 body_mouseup: function(evt, p) 149 149 { 150 if (this.markmenu && this.markmenu. visible&& rcube_event.get_target(evt) != rcube_find_object('markreadbutton'))150 if (this.markmenu && this.markmenu.is(':visible') && rcube_event.get_target(evt) != rcube_find_object('markreadbutton')) 151 151 this.show_markmenu(false); 152 152 }, … … 154 154 body_keypress: function(evt, p) 155 155 { 156 if (rcube_event.get_keycode(evt) == 27 && this.markmenu && this.markmenu. visible)156 if (rcube_event.get_keycode(evt) == 27 && this.markmenu && this.markmenu.is(':visible')) 157 157 this.show_markmenu(false); 158 158 } -
branches/devel-api/skins/default/mail.css
r2197 r2275 50 50 left: 90px; 51 51 width: auto; 52 visibility: hidden;52 display: none; 53 53 background-color: #F9F9F9; 54 54 border: 1px solid #CCC;
Note: See TracChangeset
for help on using the changeset viewer.
