Changeset 2224 in subversion
- Timestamp:
- Jan 8, 2009 4:02:21 PM (4 years ago)
- Location:
- branches/devel-api/program
- Files:
-
- 4 edited
-
include/rcube_html_page.php (modified) (4 diffs)
-
include/rcube_template.php (modified) (1 diff)
-
js/app.js (modified) (26 diffs)
-
js/common.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/devel-api/program/include/rcube_html_page.php
r1347 r2224 32 32 protected $charset = 'UTF-8'; 33 33 34 protected $script_tag_file = "<script type=\"text/javascript\" src=\"%s %s\"></script>\n";34 protected $script_tag_file = "<script type=\"text/javascript\" src=\"%s\"></script>\n"; 35 35 protected $script_tag = "<script type=\"text/javascript\">\n<!--\n%s\n\n//-->\n</script>\n"; 36 36 protected $default_template = "<html>\n<head><title></title></head>\n<body></body>\n</html>"; … … 54 54 { 55 55 static $sa_files = array(); 56 57 if (!ereg('^https?://', $file) && $file[0] != '/') 58 $file = $this->scripts_path . $file; 56 59 57 60 if (in_array($file, $sa_files)) { … … 166 169 if (is_array($this->script_files['head'])) { 167 170 foreach ($this->script_files['head'] as $file) { 168 $__page_header .= sprintf($this->script_tag_file, $ this->scripts_path, $file);171 $__page_header .= sprintf($this->script_tag_file, $file); 169 172 } 170 173 } … … 181 184 if (is_array($this->script_files['foot'])) { 182 185 foreach ($this->script_files['foot'] as $file) { 183 $__page_footer .= sprintf($this->script_tag_file, $ this->scripts_path, $file);186 $__page_footer .= sprintf($this->script_tag_file, $file); 184 187 } 185 188 } -
branches/devel-api/program/include/rcube_template.php
r2110 r2224 72 72 $this->add_script($javascript_foot, 'foot'); 73 73 $this->scripts_path = 'program/js/'; 74 $this->include_script('http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js'); 74 75 $this->include_script('common.js'); 75 76 $this->include_script('app.js'); -
branches/devel-api/program/js/app.js
r2204 r2224 198 198 this.env.spellcheck.spelling_state_observer = function(s){ ref.set_spellcheck_state(s); }; 199 199 this.set_spellcheck_state('ready'); 200 if ( rcube_find_object('_is_html').value== '1')200 if ($("input[name='_is_html']").val() == '1') 201 201 this.display_spellcheck_controls(false); 202 202 } … … 318 318 319 319 case 'login': 320 var input_user = rcube_find_object('rcmloginuser'); 321 var input_pass = rcube_find_object('rcmloginpwd'); 322 var input_tz = rcube_find_object('rcmlogintz'); 323 324 if (input_user) 325 input_user.onkeyup = function(e){ return rcmail.login_user_keyup(e); }; 326 if (input_user && input_user.value=='') 320 var input_user = $('#rcmloginuser'); 321 input_user.bind('keypress', function(e){ return rcmail.login_user_keyup(e); }); 322 323 if (input_user.val() == '') 327 324 input_user.focus(); 328 else if (input_pass)329 input_pass.focus();325 else 326 $('#rcmloginpwd').focus(); 330 327 331 328 // detect client timezone 332 if (input_tz) 333 input_tz.value = new Date().getTimezoneOffset() / -60; 329 $('#rcmlogintz').val(new Date().getTimezoneOffset() / -60); 334 330 335 331 this.enable_command('login', true); … … 419 415 420 416 //this.messageform = this.gui_objects.messageform; 421 var input_from = rcube_find_object('_from'); 422 var input_to = rcube_find_object('_to'); 423 var input_cc = rcube_find_object('_cc'); 424 var input_bcc = rcube_find_object('_bcc'); 425 var input_replyto = rcube_find_object('_replyto'); 426 var input_subject = rcube_find_object('_subject'); 427 var input_message = rcube_find_object('_message'); 428 var draftid = rcube_find_object('_draft_saveid'); 417 var input_from = $("[name='_from']"); 418 var input_to = $("[name='_to']"); 419 var input_subject = $("input[name='_subject']"); 429 420 430 421 // init live search events 431 if (input_to) 432 this.init_address_input_events(input_to); 433 if (input_cc) 434 this.init_address_input_events(input_cc); 435 if (input_bcc) 436 this.init_address_input_events(input_bcc); 422 this.init_address_input_events(input_to); 423 this.init_address_input_events($("[name='_cc']")); 424 this.init_address_input_events($("[name='_bcc']")); 437 425 438 426 // add signature according to selected identity 439 if (input_from && input_from.type=='select-one' && (!draftid || draftid.value=='') 440 // if we have HTML editor, signature is added in callback 441 && rcube_find_object('_is_html').value != '1') 442 { 443 this.change_identity(input_from); 444 } 445 446 if (input_to && input_to.value=='') 427 if (input_from.attr('type') == 'select-one' && $("input[name='_draft_saveid']").val() == '' 428 && $("input[name='_is_html']").val() != '1') { // if we have HTML editor, signature is added in callback 429 this.change_identity(input_from[0]); 430 } 431 432 if (input_to.val() == '') 447 433 input_to.focus(); 448 else if (input_subject && input_subject.value=='')434 else if (input_subject.val() == '') 449 435 input_subject.focus(); 450 436 else if (input_message) 451 this.set_caret2start( input_message);437 this.set_caret2start($("[name='_message']").get(0)); 452 438 453 439 // get summary of all field values … … 461 447 { 462 448 var handler = function(e){ return ref.ksearch_keypress(e,this); }; 463 464 if (obj.addEventListener) 465 obj.addEventListener(bw.safari ? 'keydown' : 'keypress', handler, false); 466 else 467 obj.onkeydown = handler; 468 469 obj.setAttribute('autocomplete', 'off'); 449 obj.bind((bw.safari ? 'keydown' : 'keypress'), handler); 450 obj.attr('autocomplete', 'off'); 470 451 }; 471 452 … … 659 640 if (this.gui_objects.editform) 660 641 { 661 var input_pagesize = rcube_find_object('_pagesize');662 var input_name = rcube_find_object('_name');663 var input_email = rcube_find_object('_email');642 var input_pagesize = $("input[name='_pagesize']"); 643 var input_name = $("input[name='_name']"); 644 var input_email = $("input[name='_email']"); 664 645 665 646 // user prefs 666 if (input_pagesize && isNaN(parseInt(input_pagesize.value)))647 if (input_pagesize.length && isNaN(parseInt(input_pagesize.val()))) 667 648 { 668 649 alert(this.get_label('nopagesizewarning')); … … 673 654 else 674 655 { 675 if (input_name && input_name.value== '')656 if (input_name.length && input_name.val() == '') 676 657 { 677 658 alert(this.get_label('nonamewarning')); … … 679 660 break; 680 661 } 681 else if (input_email && !rcube_check_email(input_email.value))662 else if (input_email.length && !rcube_check_email(input_email.val())) 682 663 { 683 664 alert(this.get_label('noemailwarning')); … … 1193 1174 { 1194 1175 var li, pos, list, height; 1195 list = rcube_find_object(this.task == 'mail' ? 'mailboxlist' : 'directorylist');1196 pos = rcube_get_object_pos(list);1197 this.env.folderlist_coords = { x1:pos.x, y1:pos.y, x2:pos.x + list.offsetWidth, y2:pos.y + list.offsetHeight};1176 list = $((this.task == 'mail' ? '#mailboxlist' : '#directorylist')); 1177 pos = list.offset(); 1178 this.env.folderlist_coords = { x1:pos.left, y1:pos.top, x2:pos.left + list.width(), y2:pos.top + list.height() }; 1198 1179 1199 1180 this.env.folder_coords = new Array(); 1200 1181 for (var k in model) { 1201 if (li = this.get_folder_li(k)) 1202 { 1203 pos = rcube_get_object_pos(li.firstChild); 1204 // only visible folders 1205 if (height = li.firstChild.offsetHeight) 1206 this.env.folder_coords[k] = {x1:pos.x, y1:pos.y, x2:pos.x + li.firstChild.offsetWidth, y2:pos.y + height}; 1207 } 1208 } 1209 } 1182 if (li = this.get_folder_li(k)) { 1183 pos = $(li.firstChild).offset(); 1184 // only visible folders 1185 if (height = li.firstChild.offsetHeight) 1186 this.env.folder_coords[k] = { x1:pos.left, y1:pos.top, x2:pos.left + li.firstChild.offsetWidth, y2:pos.top + height }; 1187 } 1188 } 1189 } 1210 1190 }; 1211 1191 1212 1192 this.drag_move = function(e) 1213 { 1214 if (this.gui_objects.folderlist && this.env.folder_coords) 1215 { 1193 { 1194 if (this.gui_objects.folderlist && this.env.folder_coords) { 1216 1195 var li, pos, mouse; 1217 1196 mouse = rcube_event.get_mouse_pos(e); … … 1219 1198 1220 1199 // if mouse pointer is outside of folderlist 1221 if (mouse.x < pos.x1 || mouse.x >= pos.x2 1222 || mouse.y < pos.y1 || mouse.y >= pos.y2) 1223 { 1224 if (this.env.last_folder_target) { 1225 this.set_classname(this.get_folder_li(this.env.last_folder_target), 'droptarget', false); 1200 if (mouse.x < pos.x1 || mouse.x >= pos.x2 || mouse.y < pos.y1 || mouse.y >= pos.y2) { 1201 if (this.env.last_folder_target) { 1202 this.set_classname(this.get_folder_li(this.env.last_folder_target), 'droptarget', false); 1226 1203 this.env.last_folder_target = null; 1227 }1228 return;1229 }1204 } 1205 return; 1206 } 1230 1207 1231 1208 // over the folders 1232 for (var k in this.env.folder_coords) 1233 { 1234 pos = this.env.folder_coords[k]; 1235 if (this.check_droptarget(k) && ((mouse.x >= pos.x1) && (mouse.x < pos.x2) 1236 && (mouse.y >= pos.y1) && (mouse.y < pos.y2))) 1237 { 1209 for (var k in this.env.folder_coords) { 1210 pos = this.env.folder_coords[k]; 1211 if (this.check_droptarget(k) && ((mouse.x >= pos.x1) && (mouse.x < pos.x2) 1212 && (mouse.y >= pos.y1) && (mouse.y < pos.y2))) { 1238 1213 this.set_classname(this.get_folder_li(k), 'droptarget', true); 1239 this.env.last_folder_target = k;1240 }1241 else1242 this.set_classname(this.get_folder_li(k), 'droptarget', false);1243 }1244 }1245 };1214 this.env.last_folder_target = k; 1215 } 1216 else 1217 this.set_classname(this.get_folder_li(k), 'droptarget', false); 1218 } 1219 } 1220 }; 1246 1221 1247 1222 this.collapse_folder = function(id) … … 1410 1385 { 1411 1386 this.set_message(id, 'unread', false); 1412 if (this.env.unread_counts[this.env.mailbox])1413 {1414 this.env.unread_counts[this.env.mailbox] -= 1;1415 this.set_unread_count(this.env.mailbox, this.env.unread_counts[this.env.mailbox], this.env.mailbox == 'INBOX');1416 }1417 }1387 if (this.env.unread_counts[this.env.mailbox]) 1388 { 1389 this.env.unread_counts[this.env.mailbox] -= 1; 1390 this.set_unread_count(this.env.mailbox, this.env.unread_counts[this.env.mailbox], this.env.mailbox == 'INBOX'); 1391 } 1392 } 1418 1393 } 1419 1394 }; … … 1422 1397 { 1423 1398 var frm; 1424 if (this.env.contentframe && (frm = rcube_find_object(this.env.contentframe)))1399 if (this.env.contentframe && (frm = $('#'+this.env.contentframe)) && frm.length) 1425 1400 { 1426 1401 if (!show && window.frames[this.env.contentframe]) … … 1430 1405 } 1431 1406 else if (!bw.safari) 1432 frm .style.display = show ? 'block' : 'none';1407 frm[show ? 'show' : 'hide'](); 1433 1408 } 1434 1409 … … 1985 1960 { 1986 1961 var key = rcube_event.get_keycode(e); 1987 var elm;1962 var passwd = $('#rcmloginpwd'); 1988 1963 1989 1964 // enter 1990 if ((key==13) && (elm = rcube_find_object('_pass'))) 1991 { 1992 elm.focus(); 1993 return false; 1965 if (key == 13 && passwd.length && !passwd.val()) { 1966 passwd.focus(); 1967 return rcube_event.cancel(e); 1994 1968 } 1969 1970 return true; 1995 1971 }; 1996 1972 … … 2004 1980 { 2005 1981 // check input fields 2006 var input_to = rcube_find_object('_to');2007 var input_cc = rcube_find_object('_cc');2008 var input_bcc = rcube_find_object('_bcc');2009 var input_from = rcube_find_object('_from');2010 var input_subject = rcube_find_object('_subject');2011 var input_message = rcube_find_object('_message');1982 var input_to = $("[name='_to']"); 1983 var input_cc = $("[name='_cc']"); 1984 var input_bcc = $("[name='_bcc']"); 1985 var input_from = $("[name='_from']"); 1986 var input_subject = $("[name='_subject']"); 1987 var input_message = $("[name='_message']"); 2012 1988 2013 1989 // check sender (if have no identities) 2014 if (input_from. type == 'text' && !rcube_check_email(input_from.value, true))1990 if (input_from.attr('type') == 'text' && !rcube_check_email(input_from.val(), true)) 2015 1991 { 2016 1992 alert(this.get_label('nosenderwarning')); … … 2020 1996 2021 1997 // check for empty recipient 2022 var recipients = input_to.val ue ? input_to.value : (input_cc.value ? input_cc.value : input_bcc.value);1998 var recipients = input_to.val() ? input_to.val() : (input_cc.val() ? input_cc.val() : input_bcc.val()); 2023 1999 if (!rcube_check_email(recipients.replace(/^\s+/, '').replace(/[\s,;]+$/, ''), true)) 2024 2000 { … … 2029 2005 2030 2006 // display localized warning for missing subject 2031 if (input_subject && input_subject.value== '')2007 if (input_subject.val() == '') 2032 2008 { 2033 2009 var subject = prompt(this.get_label('nosubjectwarning'), this.get_label('nosubject')); … … 2041 2017 else 2042 2018 { 2043 input_subject.val ue = subject ? subject : this.get_label('nosubject');2019 input_subject.val((subject ? subject : this.get_label('nosubject'))); 2044 2020 } 2045 2021 } 2046 2022 2047 2023 // check for empty body 2048 if ((!window.tinyMCE || !tinyMCE.get('compose-body')) && input_message.val ue== '' && !confirm(this.get_label('nobodywarning')))2024 if ((!window.tinyMCE || !tinyMCE.get('compose-body')) && input_message.val() == '' && !confirm(this.get_label('nobodywarning'))) 2049 2025 { 2050 2026 input_message.focus(); … … 2091 2067 this.set_draft_id = function(id) 2092 2068 { 2093 var f; 2094 if (f = rcube_find_object('_draft_saveid')) 2095 f.value = id; 2069 $("input[name='_draft_saveid']").val(id); 2096 2070 }; 2097 2071 … … 2108 2082 { 2109 2083 // check input fields 2110 var input_to = rcube_find_object('_to'); 2111 var input_cc = rcube_find_object('_cc'); 2112 var input_bcc = rcube_find_object('_bcc'); 2113 var input_subject = rcube_find_object('_subject'); 2114 var editor, input_message; 2084 var value_to = $("[name='_to']").val(); 2085 var value_cc = $("[name='_cc']").val(); 2086 var value_bcc = $("[name='_bcc']").val(); 2087 var value_subject = $("[name='_subject']").val(); 2115 2088 var str = ''; 2116 2089 2117 if (input_to && input_to.value) 2118 str += input_to.value+':'; 2119 if (input_cc && input_cc.value) 2120 str += input_cc.value+':'; 2121 if (input_bcc && input_bcc.value) 2122 str += input_bcc.value+':'; 2123 if (input_subject && input_subject.value) 2124 str += input_subject.value+':'; 2125 2126 if (editor = tinyMCE.get('compose-body')) 2090 if (value_to) 2091 str += value_to+':'; 2092 if (value_cc) 2093 str += value_cc+':'; 2094 if (value_bcc) 2095 str += value_bcc+':'; 2096 if (value_subject) 2097 str += value_subject+':'; 2098 2099 var editor = tinyMCE.get('compose-body'); 2100 if (editor) 2127 2101 str += editor.getContent(); 2128 2102 else 2129 { 2130 input_message = rcube_find_object('_message'); 2131 str += input_message.value; 2132 } 2103 str += $("[name='_message']").val(); 2133 2104 2134 2105 if (save) … … 2144 2115 2145 2116 var id = obj.options[obj.selectedIndex].value; 2146 var input_message = rcube_find_object('_message');2147 var message = input_message ? input_message.value : '';2148 var is_html = ( rcube_find_object('_is_html').value== '1');2117 var input_message = $("[name='_message']"); 2118 var message = input_message.val(); 2119 var is_html = ($("input[name='_is_html']").val() == '1'); 2149 2120 var sig, p; 2150 2121 … … 2160 2131 sig = this.env.signatures[this.env.identity]['plain_text']; 2161 2132 else 2162 sig = this.env.signatures[this.env.identity]['text'];2133 sig = this.env.signatures[this.env.identity]['text']; 2163 2134 2164 if (sig.indexOf('-- ')!=0)2135 if (sig.indexOf('-- ')!=0) 2165 2136 sig = '-- \n'+sig; 2166 2137 … … 2193 2164 // Append the signature as a div within the body 2194 2165 var sigElem = editor.dom.get('_rc_sig'); 2195 var newsig = '';2196 var htmlsig = true;2166 var newsig = ''; 2167 var htmlsig = true; 2197 2168 2198 2169 if (!sigElem) 2199 2170 { 2200 // add empty line before signature on IE2201 if (bw.ie)2171 // add empty line before signature on IE 2172 if (bw.ie) 2202 2173 editor.getBody().appendChild(editor.getDoc().createElement('br')); 2203 2174 2204 sigElem = editor.getDoc().createElement('div');2175 sigElem = editor.getDoc().createElement('div'); 2205 2176 sigElem.setAttribute('id', '_rc_sig'); 2206 2177 editor.getBody().appendChild(sigElem); 2207 2178 } 2208 2179 2209 if (this.env.signatures[id])2210 {2211 newsig = this.env.signatures[id]['text'];2212 htmlsig = this.env.signatures[id]['is_html'];2213 }2180 if (this.env.signatures[id]) 2181 { 2182 newsig = this.env.signatures[id]['text']; 2183 htmlsig = this.env.signatures[id]['is_html']; 2184 } 2214 2185 2215 2186 if (htmlsig) … … 2220 2191 } 2221 2192 2222 if (input_message) 2223 input_message.value = message; 2193 input_message.val(message); 2224 2194 2225 2195 this.env.identity = id; … … 2235 2205 if (elm = this.gui_objects.uploadbox) 2236 2206 { 2237 if (a && (list = this.gui_objects.attachmentlist)) 2238 { 2239 var pos = rcube_get_object_pos(list); 2240 var left = pos.x; 2241 var top = pos.y + list.offsetHeight + 10; 2242 2243 elm.style.top = top+'px'; 2244 elm.style.left = left+'px'; 2207 if (a && (list = this.gui_objects.attachmentlist)) 2208 { 2209 var pos = $(list).offset(); 2210 elm.style.top = (pos.top + list.offsetHeight + 10) + 'px'; 2211 elm.style.left = pos.left + 'px'; 2245 2212 } 2246 2213 … … 2249 2216 2250 2217 // clear upload form 2251 try {2218 try { 2252 2219 if (!a && this.gui_objects.attachmentform != this.gui_objects.messageform) 2253 this.gui_objects.attachmentform.reset();2254 }2255 catch(e){} // ignore errors2256 2257 return true; 2220 this.gui_objects.attachmentform.reset(); 2221 } 2222 catch(e){} // ignore errors 2223 2224 return true; 2258 2225 }; 2259 2226 … … 2581 2548 2582 2549 // move the results pane right under the input box and make it visible 2583 var pos = rcube_get_object_pos(this.ksearch_input);2584 this.ksearch_pane.move(pos. x, pos.y+this.ksearch_input.offsetHeight);2550 var pos = $(this.ksearch_input).offset(); 2551 this.ksearch_pane.move(pos.left, pos.top + this.ksearch_input.offsetHeight); 2585 2552 this.ksearch_pane.show(1); 2586 2553 } -
branches/devel-api/program/js/common.js
r2150 r2224 507 507 508 508 509 // return the absolute position of an object within the document510 function rcube_get_object_pos(obj, relative)511 {512 if(typeof(obj)=='string')513 obj = rcube_find_object(obj);514 515 if(!obj) return {x:0, y:0};516 517 var iX = (bw.layers) ? obj.x : obj.offsetLeft;518 var iY = (bw.layers) ? obj.y : obj.offsetTop;519 520 if(!relative && (bw.ie || bw.mz))521 {522 var elm = obj.offsetParent;523 while(elm && elm!=null)524 {525 iX += elm.offsetLeft - (elm.parentNode && elm.parentNode.scrollLeft ? elm.parentNode.scrollLeft : 0);526 iY += elm.offsetTop - (elm.parentNode && elm.parentNode.scrollTop ? elm.parentNode.scrollTop : 0);527 elm = elm.offsetParent;528 }529 }530 531 return {x:iX, y:iY};532 }533 534 // determine whether the mouse is over the given object or not535 function rcube_mouse_is_over(ev, obj)536 {537 var mouse = rcube_event.get_mouse_pos(ev);538 var pos = rcube_get_object_pos(obj);539 540 return ((mouse.x >= pos.x) && (mouse.x < (pos.x + obj.offsetWidth)) &&541 (mouse.y >= pos.y) && (mouse.y < (pos.y + obj.offsetHeight)));542 }543 544 545 /**546 * Return the currently applied value of a css property547 *548 * @param {Object} html_element Node reference549 * @param {String} css_property Property name to read in Javascript notation (eg. 'textAlign')550 * @param {String} mozilla_equivalent Equivalent property name in CSS notation (eg. 'text-align')551 * @return CSS property value552 * @type String553 */554 function get_elements_computed_style(html_element, css_property, mozilla_equivalent)555 {556 if (arguments.length==2)557 mozilla_equivalent = css_property;558 559 var el = html_element;560 if (typeof(html_element)=='string')561 el = rcube_find_object(html_element);562 563 if (el && el.currentStyle)564 return el.currentStyle[css_property];565 else if (el && document.defaultView && document.defaultView.getComputedStyle)566 return document.defaultView.getComputedStyle(el, null).getPropertyValue(mozilla_equivalent);567 else568 return false;569 }570 571 572 509 // cookie functions by GoogieSpell 573 510 function setCookie(name, value, expires, path, domain, secure)
Note: See TracChangeset
for help on using the changeset viewer.
