Changeset ae8a2a55 in github
- Timestamp:
- Jun 2, 2010 8:06:10 AM (3 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- 05a631a
- Parents:
- 1126fc6
- File:
-
- 1 edited
-
program/js/googiespell.js (modified) (53 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/js/googiespell.js
r677e1f2 rae8a2a55 8 8 AUTHORS 9 9 4mir Salihefendic (http://amix.dk) - amix@amix.dk 10 Aleksander Machniak - alec [at] alec.pl10 Aleksander Machniak - alec [at] alec.pl 11 11 */ 12 12 … … 15 15 16 16 function GoogieSpell(img_dir, server_url) { 17 var ref = this; 17 var ref = this, 18 cookie_value = getCookie('language'); 19 20 GOOGIE_CUR_LANG = cookie_value != null ? cookie_value : GOOGIE_DEFAULT_LANG; 18 21 19 22 this.array_keys = function(arr) { 20 var res = []; 21 for (var key in arr) { res.push([key]); } 22 return res; 23 } 24 25 var cookie_value = getCookie('language'); 26 GOOGIE_CUR_LANG = cookie_value != null ? cookie_value : GOOGIE_DEFAULT_LANG; 23 var res = []; 24 for (var key in arr) { res.push([key]); } 25 return res; 26 } 27 27 28 28 this.img_dir = img_dir; … … 30 30 31 31 this.org_lang_to_word = { 32 "da": "Dansk", "de": "Deutsch", "en": "English",32 "da": "Dansk", "de": "Deutsch", "en": "English", 33 33 "es": "Español", "fr": "Français", "it": "Italiano", 34 34 "nl": "Nederlands", "pl": "Polski", "pt": "Português", … … 50 50 this.lang_no_error_found = "No spelling errors found"; 51 51 this.lang_no_suggestions = "No suggestions"; 52 52 53 53 this.show_spell_img = false; // roundcube mod. 54 54 this.decoration = true; … … 57 57 this.report_ta_not_found = true; 58 58 59 // Extensions59 // Extensions 60 60 this.custom_ajax_error = null; 61 61 this.custom_no_spelling_error = null; 62 this.custom_menu_builder = []; // Should take an eval function and a build menu function63 this.custom_item_evaulator = null; // Should take an eval function and a build menu function62 this.custom_menu_builder = []; // Should take an eval function and a build menu function 63 this.custom_item_evaulator = null; // Should take an eval function and a build menu function 64 64 this.extra_menu_items = []; 65 65 this.custom_spellcheck_starter = null; 66 66 this.main_controller = true; 67 67 68 // Observers68 // Observers 69 69 this.lang_state_observer = null; 70 70 this.spelling_state_observer = null; … … 72 72 this.all_errors_fixed_observer = null; 73 73 74 // Focus links - used to give the text box focus74 // Focus links - used to give the text box focus 75 75 this.use_focus = false; 76 76 this.focus_link_t = null; 77 77 this.focus_link_b = null; 78 78 79 // Counters79 // Counters 80 80 this.cnt_errors = 0; 81 81 this.cnt_errors_fixed = 0; 82 83 // Set document's onclick to hide the language and error menu82 83 // Set document's onclick to hide the language and error menu 84 84 $(document).bind('click', function(e) { 85 85 if($(e.target).attr('googie_action_btn') != '1' && ref.isLangWindowShown()) 86 ref.hideLangWindow();87 if($(e.target).attr('googie_action_btn') != '1' && ref.isErrorWindowShown())86 ref.hideLangWindow(); 87 if($(e.target).attr('googie_action_btn') != '1' && ref.isErrorWindowShown()) 88 88 ref.hideErrorWindow(); 89 89 }); … … 95 95 if (this.text_area) { 96 96 if (!this.spell_container && this.decoration) { 97 var table = document.createElement('table'); 98 var tbody = document.createElement('tbody'); 99 var tr = document.createElement('tr'); 100 var spell_container = document.createElement('td'); 101 102 var r_width = this.isDefined(this.force_width) ? this.force_width : this.text_area.offsetWidth; 103 var r_height = this.isDefined(this.force_height) ? this.force_height : 16; 97 var table = document.createElement('table'), 98 tbody = document.createElement('tbody'), 99 tr = document.createElement('tr'), 100 spell_container = document.createElement('td'), 101 r_width = this.isDefined(this.force_width) ? this.force_width : this.text_area.offsetWidth, 102 r_height = this.isDefined(this.force_height) ? this.force_height : 16; 104 103 105 104 tr.appendChild(spell_container); … … 116 115 if (this.report_ta_not_found) 117 116 alert('Text area not found'); 118 } 117 }; 119 118 120 119 ////// … … 123 122 this.setSpellContainer = function(id) { 124 123 this.spell_container = typeof(id) == 'string' ? document.getElementById(id) : id; 125 } 124 }; 126 125 127 126 this.setLanguages = function(lang_dict) { 128 127 this.lang_to_word = lang_dict; 129 128 this.langlist_codes = this.array_keys(lang_dict); 130 } 129 }; 131 130 132 131 this.setCurrentLanguage = function(lan_code) { … … 137 136 now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000); 138 137 setCookie('language', lan_code, now); 139 } 138 }; 140 139 141 140 this.setForceWidthHeight = function(width, height) { … … 143 142 this.force_width = width; 144 143 this.force_height = height; 145 } 144 }; 146 145 147 146 this.setDecoration = function(bool) { 148 147 this.decoration = bool; 149 } 148 }; 150 149 151 150 this.dontUseCloseButtons = function() { 152 151 this.use_close_btn = false; 153 } 152 }; 154 153 155 154 this.appendNewMenuItem = function(name, call_back_fn, checker) { 156 155 this.extra_menu_items.push([name, call_back_fn, checker]); 157 } 156 }; 158 157 159 158 this.appendCustomMenuBuilder = function(eval, builder) { 160 159 this.custom_menu_builder.push([eval, builder]); 161 } 160 }; 162 161 163 162 this.setFocus = function() { … … 170 169 return false; 171 170 } 172 } 171 }; 173 172 174 173 … … 180 179 if (this.spelling_state_observer != null && this.report_state_change) 181 180 this.spelling_state_observer(current_state, this); 182 } 181 }; 183 182 184 183 this.setReportStateChange = function(bool) { 185 184 this.report_state_change = bool; 186 } 185 }; 187 186 188 187 … … 192 191 this.getUrl = function() { 193 192 return this.server_url + GOOGIE_CUR_LANG; 194 } 193 }; 195 194 196 195 this.escapeSpecial = function(val) { 197 196 return val.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"); 198 } 197 }; 199 198 200 199 this.createXMLReq = function (text) { … … 202 201 + '<spellrequest textalreadyclipped="0" ignoredups="0" ignoredigits="1" ignoreallcaps="1">' 203 202 + '<text>' + text + '</text></spellrequest>'; 204 } 203 }; 205 204 206 205 this.spellCheck = function(ignore) { … … 230 229 $('body').append(this.error_window); 231 230 232 try { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); } 231 try { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); } 233 232 catch (e) { } 234 233 … … 242 241 $.ajax({ type: 'POST', url: this.getUrl(), 243 242 data: this.createXMLReq(req_text), dataType: 'text', 244 error: function(o) {245 if (ref.custom_ajax_error)246 ref.custom_ajax_error(ref);247 else248 alert('An error was encountered on the server. Please try again later.');249 if (ref.main_controller) {250 $(ref.spell_span).remove();251 ref.removeIndicator();252 }253 ref.checkSpellingState();254 },243 error: function(o) { 244 if (ref.custom_ajax_error) 245 ref.custom_ajax_error(ref); 246 else 247 alert('An error was encountered on the server. Please try again later.'); 248 if (ref.main_controller) { 249 $(ref.spell_span).remove(); 250 ref.removeIndicator(); 251 } 252 ref.checkSpellingState(); 253 }, 255 254 success: function(data) { 256 var r_text = data;255 var r_text = data; 257 256 ref.results = ref.parseResult(r_text); 258 257 if (r_text.match(/<c.*>/) != null) { 259 //Before parsing be sure that errors were found260 ref.showErrorsInIframe();261 ref.resumeEditingState();258 // Before parsing be sure that errors were found 259 ref.showErrorsInIframe(); 260 ref.resumeEditingState(); 262 261 } else { 263 if (!ref.custom_no_spelling_error)264 ref.flashNoSpellingErrorState();262 if (!ref.custom_no_spelling_error) 263 ref.flashNoSpellingErrorState(); 265 264 else 266 ref.custom_no_spelling_error(ref);265 ref.custom_no_spelling_error(ref); 267 266 } 268 267 ref.removeIndicator(); 269 }268 } 270 269 }); 271 } 270 }; 272 271 273 272 … … 277 276 this.parseResult = function(r_text) { 278 277 // Returns an array: result[item] -> ['attrs'], ['suggestions'] 279 var re_split_attr_c = /\w+="(\d+|true)"/g; 280 var re_split_text = /\t/g; 281 282 var matched_c = r_text.match(/<c[^>]*>[^<]*<\/c>/g); 283 var results = new Array(); 278 var re_split_attr_c = /\w+="(\d+|true)"/g, 279 re_split_text = /\t/g, 280 matched_c = r_text.match(/<c[^>]*>[^<]*<\/c>/g), 281 results = []; 284 282 285 283 if (matched_c == null) 286 284 return results; 287 288 for (var i=0 ; i < matched_c.length; i++) {289 var item = new Array();285 286 for (var i=0, len=matched_c.length; i < len; i++) { 287 var item = []; 290 288 this.errorFound(); 291 289 292 //Get attributes 293 item['attrs'] = new Array(); 294 var split_c = matched_c[i].match(re_split_attr_c); 290 // Get attributes 291 item['attrs'] = []; 292 var c_attr, val, 293 split_c = matched_c[i].match(re_split_attr_c); 295 294 for (var j=0; j < split_c.length; j++) { 296 varc_attr = split_c[j].split(/=/);297 va r val = c_attr[1].replace(/"/g, '');295 c_attr = split_c[j].split(/=/); 296 val = c_attr[1].replace(/"/g, ''); 298 297 item['attrs'][c_attr[0]] = val != 'true' ? parseInt(val) : val; 299 298 } 300 299 301 // Get suggestions302 item['suggestions'] = new Array();303 var only_text = matched_c[i].replace(/<[^>]*>/g, '') ;304 varsplit_t = only_text.split(re_split_text);300 // Get suggestions 301 item['suggestions'] = []; 302 var only_text = matched_c[i].replace(/<[^>]*>/g, ''), 303 split_t = only_text.split(re_split_text); 305 304 for (var k=0; k < split_t.length; k++) { 306 305 if(split_t[k] != '') … … 311 310 312 311 return results; 313 } 312 }; 314 313 315 314 … … 320 319 this.error_window = document.createElement('div'); 321 320 $(this.error_window).addClass('googie_window').attr('googie_action_btn', '1'); 322 } 321 }; 323 322 324 323 this.isErrorWindowShown = function() { 325 324 return $(this.error_window).is(':visible'); 326 } 325 }; 327 326 328 327 this.hideErrorWindow = function() { 329 328 $(this.error_window).css('visibility', 'hidden'); 330 329 $(this.error_window_iframe).css('visibility', 'hidden'); 331 } 330 }; 332 331 333 332 this.updateOrginalText = function(offset, old_value, new_value, id) { 334 var part_1 = this.orginal_text.substring(0, offset); 335 var part_2 = this.orginal_text.substring(offset+old_value.length); 333 var part_1 = this.orginal_text.substring(0, offset), 334 part_2 = this.orginal_text.substring(offset+old_value.length), 335 add_2_offset = new_value.length - old_value.length; 336 336 337 this.orginal_text = part_1 + new_value + part_2; 337 338 $(this.text_area).val(this.orginal_text); 338 var add_2_offset = new_value.length - old_value.length; 339 for (var j=0; j < this.results.length; j++) { 340 //Don't edit the offset of the current item 339 for (var j=0, len=this.results.length; j<len; j++) { 340 // Don't edit the offset of the current item 341 341 if (j != id && j > id) 342 342 this.results[j]['attrs']['o'] += add_2_offset; 343 343 } 344 } 344 }; 345 345 346 346 this.saveOldValue = function(elm, old_value) { 347 347 elm.is_changed = true; 348 348 elm.old_value = old_value; 349 } 349 }; 350 350 351 351 this.createListSeparator = function() { 352 var td = document.createElement('td') ;353 vartr = document.createElement('tr');352 var td = document.createElement('td'), 353 tr = document.createElement('tr'); 354 354 355 355 $(td).html(' ').attr('googie_action_btn', '1') … … 358 358 359 359 return tr; 360 } 360 }; 361 361 362 362 this.correctError = function(id, elm, l_elm, rm_pre_space) { 363 var old_value = elm.innerHTML ;364 var new_value = l_elm.nodeType == 3 ? l_elm.nodeValue : l_elm.innerHTML;365 varoffset = this.results[id]['attrs']['o'];363 var old_value = elm.innerHTML, 364 new_value = l_elm.nodeType == 3 ? l_elm.nodeValue : l_elm.innerHTML, 365 offset = this.results[id]['attrs']['o']; 366 366 367 367 if (rm_pre_space) { … … 381 381 if (!this.isDefined(elm.old_value)) 382 382 this.saveOldValue(elm, old_value); 383 383 384 384 this.errorFixed(); 385 } 385 }; 386 386 387 387 this.showErrorWindow = function(elm, id) { … … 389 389 this.show_menu_observer(this); 390 390 391 var ref = this; 392 var pos = $(elm).offset(); 391 var ref = this, 392 pos = $(elm).offset(), 393 table = document.createElement('table'), 394 list = document.createElement('tbody'); 395 393 396 pos.top -= this.edit_layer.scrollTop; 394 397 … … 396 399 'top': (pos.top+20)+'px', 'left': (pos.left)+'px'}).html(''); 397 400 398 var table = document.createElement('table');399 var list = document.createElement('tbody');400 401 401 $(table).addClass('googie_list').attr('googie_action_btn', '1'); 402 402 403 // Check if we should use custom menu builder, if not we use the default403 // Check if we should use custom menu builder, if not we use the default 404 404 var changed = false; 405 405 for (var k=0; k<this.custom_menu_builder.length; k++) { … … 411 411 } 412 412 if (!changed) { 413 //Build up the result list 414 var suggestions = this.results[id]['suggestions']; 415 var offset = this.results[id]['attrs']['o']; 416 var len = this.results[id]['attrs']['l']; 413 // Build up the result list 414 var suggestions = this.results[id]['suggestions'], 415 offset = this.results[id]['attrs']['o'], 416 len = this.results[id]['attrs']['l'], 417 row, item, dummy; 417 418 418 419 if (suggestions.length == 0) { 419 var row = document.createElement('tr');420 var item = document.createElement('td');421 vardummy = document.createElement('span');420 row = document.createElement('tr'), 421 item = document.createElement('td'), 422 dummy = document.createElement('span'); 422 423 423 424 $(dummy).text(this.lang_no_suggestions); … … 429 430 } 430 431 431 for ( i=0; i < suggestions.length; i++) {432 var row = document.createElement('tr');433 var item = document.createElement('td');434 vardummy = document.createElement('span');432 for (var i=0, len=suggestions.length; i < len; i++) { 433 row = document.createElement('tr'), 434 item = document.createElement('td'), 435 dummy = document.createElement('span'); 435 436 436 437 $(dummy).html(suggestions[i]); 437 438 438 439 $(item).bind('mouseover', this.item_onmouseover) 439 .bind('mouseout', this.item_onmouseout)440 .bind('click', function(e) { ref.correctError(id, elm, e.target.firstChild) });440 .bind('mouseout', this.item_onmouseout) 441 .bind('click', function(e) { ref.correctError(id, elm, e.target.firstChild) }); 441 442 442 443 item.appendChild(dummy); … … 447 448 //The element is changed, append the revert 448 449 if (elm.is_changed && elm.innerHTML != elm.old_value) { 449 var old_value = elm.old_value ;450 var revert_row = document.createElement('tr');451 var revert = document.createElement('td');452 varrev_span = document.createElement('span');453 454 $(rev_span).addClass('googie_list_revert').html(this.lang_revert + ' ' + old_value);450 var old_value = elm.old_value, 451 revert_row = document.createElement('tr'), 452 revert = document.createElement('td'), 453 rev_span = document.createElement('span'); 454 455 $(rev_span).addClass('googie_list_revert').html(this.lang_revert + ' ' + old_value); 455 456 456 457 $(revert).bind('mouseover', this.item_onmouseover) 457 .bind('mouseout', this.item_onmouseout)458 .bind('click', function(e) {458 .bind('mouseout', this.item_onmouseout) 459 .bind('click', function(e) { 459 460 ref.updateOrginalText(offset, elm.innerHTML, old_value, id); 460 461 $(elm).attr('is_corrected', true).css('color', '#b91414').html(old_value); 461 462 ref.hideErrorWindow(); 462 });463 }); 463 464 464 465 revert.appendChild(rev_span); … … 467 468 } 468 469 469 // Append the edit box470 var edit_row = document.createElement('tr') ;471 var edit = document.createElement('td');472 var edit_input = document.createElement('input');473 var ok_pic = document.createElement('img');474 varedit_form = document.createElement('form');470 // Append the edit box 471 var edit_row = document.createElement('tr'), 472 edit = document.createElement('td'), 473 edit_input = document.createElement('input'), 474 ok_pic = document.createElement('img'), 475 edit_form = document.createElement('form'); 475 476 476 477 var onsub = function () { … … 480 481 481 482 ref.updateOrginalText(offset, elm.innerHTML, edit_input.value, id); 482 $(elm).attr('is_corrected', true).css('color', 'green').html(edit_input.value);483 $(elm).attr('is_corrected', true).css('color', 'green').html(edit_input.value); 483 484 ref.hideErrorWindow(); 484 485 } … … 486 487 }; 487 488 488 $(edit_input).width(120).css({'margin': 0, 'padding': 0});489 $(edit_input).val(elm.innerHTML).attr('googie_action_btn', '1');490 $(edit).css('cursor', 'default').attr('googie_action_btn', '1');491 492 $(ok_pic).attr('src', this.img_dir + 'ok.gif')493 .width(32).height(16)494 .css({'cursor': 'pointer', 'margin-left': '2px', 'margin-right': '2px'})495 .bind('click', onsub);489 $(edit_input).width(120).css({'margin': 0, 'padding': 0}); 490 $(edit_input).val(elm.innerHTML).attr('googie_action_btn', '1'); 491 $(edit).css('cursor', 'default').attr('googie_action_btn', '1'); 492 493 $(ok_pic).attr('src', this.img_dir + 'ok.gif') 494 .width(32).height(16) 495 .css({'cursor': 'pointer', 'margin-left': '2px', 'margin-right': '2px'}) 496 .bind('click', onsub); 496 497 497 498 $(edit_form).attr('googie_action_btn', '1') 498 .css({'margin': 0, 'padding': 0, 'cursor': 'default', 'white-space': 'nowrap'})499 .bind('submit', onsub);500 501 edit_form.appendChild(edit_input);502 edit_form.appendChild(ok_pic);499 .css({'margin': 0, 'padding': 0, 'cursor': 'default', 'white-space': 'nowrap'}) 500 .bind('submit', onsub); 501 502 edit_form.appendChild(edit_input); 503 edit_form.appendChild(ok_pic); 503 504 edit.appendChild(edit_form); 504 505 edit_row.appendChild(edit); 505 506 list.appendChild(edit_row); 506 507 507 // Append extra menu items508 // Append extra menu items 508 509 if (this.extra_menu_items.length > 0) 509 list.appendChild(this.createListSeparator());510 510 list.appendChild(this.createListSeparator()); 511 511 512 var loop = function(i) { 512 if (i < ref.extra_menu_items.length) { 513 var e_elm = ref.extra_menu_items[i]; 514 515 if (!e_elm[2] || e_elm[2](elm, ref)) { 516 var e_row = document.createElement('tr'); 517 var e_col = document.createElement('td'); 518 519 $(e_col).html(e_elm[0]) 520 .bind('mouseover', ref.item_onmouseover) 521 .bind('mouseout', ref.item_onmouseout) 522 .bind('click', function() { return e_elm[1](elm, ref) }); 523 524 e_row.appendChild(e_col); 525 list.appendChild(e_row); 526 } 527 loop(i+1); 513 if (i < ref.extra_menu_items.length) { 514 var e_elm = ref.extra_menu_items[i]; 515 516 if (!e_elm[2] || e_elm[2](elm, ref)) { 517 var e_row = document.createElement('tr'), 518 e_col = document.createElement('td'); 519 520 $(e_col).html(e_elm[0]) 521 .bind('mouseover', ref.item_onmouseover) 522 .bind('mouseout', ref.item_onmouseout) 523 .bind('click', function() { return e_elm[1](elm, ref) }); 524 525 e_row.appendChild(e_col); 526 list.appendChild(e_row); 528 527 } 529 } 530 528 loop(i+1); 529 } 530 }; 531 531 532 loop(0); 532 533 loop = null; … … 541 542 this.error_window.appendChild(table); 542 543 543 // Dummy for IE - dropdown bug fix544 // Dummy for IE - dropdown bug fix 544 545 if ($.browser.msie) { 545 if (!this.error_window_iframe) {546 if (!this.error_window_iframe) { 546 547 var iframe = $('<iframe>').css({'position': 'absolute', 'z-index': -1}); 547 $('body').append(iframe);548 $('body').append(iframe); 548 549 this.error_window_iframe = iframe; 549 550 } 550 551 551 $(this.error_window_iframe).css({'visibility': 'visible',552 'top': this.error_window.offsetTop, 'left': this.error_window.offsetLeft,552 $(this.error_window_iframe).css({'visibility': 'visible', 553 'top': this.error_window.offsetTop, 'left': this.error_window.offsetLeft, 553 554 'width': this.error_window.offsetWidth, 'height': this.error_window.offsetHeight}); 554 555 } 555 } 556 }; 556 557 557 558 … … 583 584 }); 584 585 } 585 } 586 }; 586 587 587 588 this.resumeEditing = function() { … … 609 610 } 610 611 this.checkSpellingState(false); 611 } 612 }; 612 613 613 614 this.createErrorLink = function(text, id) { 614 var elm = document.createElement('span') ;615 var ref = this;616 vard = function (e) {615 var elm = document.createElement('span'), 616 ref = this, 617 d = function (e) { 617 618 ref.showErrorWindow(elm, id); 618 619 d = null; 619 620 return false; 620 };621 621 }; 622 622 623 $(elm).html(text).addClass('googie_link').bind('click', d) 623 624 .attr({'googie_action_btn' : '1', 'g_id' : id, 'is_corrected' : false}); 624 625 625 626 return elm; 626 } 627 }; 627 628 628 629 this.createPart = function(txt_part) { … … 635 636 txt_part = txt_part.replace(/^ /g, " "); 636 637 txt_part = txt_part.replace(/ $/g, " "); 637 638 638 639 var span = document.createElement('span'); 639 640 $(span).html(txt_part); 640 641 return span; 641 } 642 }; 642 643 643 644 this.showErrorsInIframe = function() { 644 var output = document.createElement('div') 645 var pointer = 0;646 varresults = this.results;645 var output = document.createElement('div'), 646 pointer = 0, 647 results = this.results; 647 648 648 649 if (results.length > 0) { 649 for (var i=0 ; i < results.length; i++) {650 var offset = results[i]['attrs']['o'] ;651 var len = results[i]['attrs']['l'];652 var part_1_text = this.orginal_text.substring(pointer, offset);653 varpart_1 = this.createPart(part_1_text);654 650 for (var i=0, length=results.length; i < length; i++) { 651 var offset = results[i]['attrs']['o'], 652 len = results[i]['attrs']['l'], 653 part_1_text = this.orginal_text.substring(pointer, offset), 654 part_1 = this.createPart(part_1_text); 655 655 656 output.appendChild(part_1); 656 657 pointer += offset - pointer; 657 658 // If the last child was an error, then insert some space658 659 // If the last child was an error, then insert some space 659 660 var err_link = this.createErrorLink(this.orginal_text.substr(offset, len), i); 660 661 this.error_links.push(err_link); … … 662 663 pointer += len; 663 664 } 664 //Insert the rest of the orginal text 665 var part_2_text = this.orginal_text.substr(pointer, this.orginal_text.length); 666 var part_2 = this.createPart(part_2_text); 665 666 // Insert the rest of the orginal text 667 var part_2_text = this.orginal_text.substr(pointer, this.orginal_text.length), 668 part_2 = this.createPart(part_2_text); 667 669 668 670 output.appendChild(part_2); … … 676 678 if (this.custom_item_evaulator) 677 679 $.map(this.error_links, function(elm){me.custom_item_evaulator(me, elm)}); 678 680 679 681 $(this.edit_layer).append(output); 680 682 681 // Hide text area and show edit layer683 // Hide text area and show edit layer 682 684 $(this.text_area).hide(); 683 685 $(this.edit_layer).insertBefore(this.text_area); … … 692 694 693 695 // this.edit_layer.scrollTop = this.ta_scroll_top; 694 } 696 }; 695 697 696 698 … … 703 705 .width(100).attr('googie_action_btn', '1'); 704 706 705 //Build up the result list 706 var table = document.createElement('table'); 707 var list = document.createElement('tbody'); 708 var ref = this; 707 // Build up the result list 708 var table = document.createElement('table'), 709 list = document.createElement('tbody'), 710 ref = this, 711 row, item, span; 709 712 710 713 $(table).addClass('googie_list').width('100%'); 711 this.lang_elms = new Array();714 this.lang_elms = []; 712 715 713 716 for (i=0; i < this.langlist_codes.length; i++) { 714 varrow = document.createElement('tr');715 varitem = document.createElement('td');716 varspan = document.createElement('span');717 718 $(span).text(this.lang_to_word[this.langlist_codes[i]]);717 row = document.createElement('tr'); 718 item = document.createElement('td'); 719 span = document.createElement('span'); 720 721 $(span).text(this.lang_to_word[this.langlist_codes[i]]); 719 722 this.lang_elms.push(item); 720 723 721 724 $(item).attr('googieId', this.langlist_codes[i]) 722 725 .bind('click', function(e) { 723 ref.deHighlightCurSel();724 ref.setCurrentLanguage($(this).attr('googieId'));725 726 if (ref.lang_state_observer != null) {726 ref.deHighlightCurSel(); 727 ref.setCurrentLanguage($(this).attr('googieId')); 728 729 if (ref.lang_state_observer != null) { 727 730 ref.lang_state_observer(); 728 }729 730 ref.highlightCurSel();731 ref.hideLangWindow();731 } 732 733 ref.highlightCurSel(); 734 ref.hideLangWindow(); 732 735 }) 733 .bind('mouseover', function(e) { 734 if (this.className != "googie_list_selected")736 .bind('mouseover', function(e) { 737 if (this.className != "googie_list_selected") 735 738 this.className = "googie_list_onhover"; 736 739 }) 737 .bind('mouseout', function(e) { 738 if (this.className != "googie_list_selected")739 this.className = "googie_list_onout"; 740 .bind('mouseout', function(e) { 741 if (this.className != "googie_list_selected") 742 this.className = "googie_list_onout"; 740 743 }); 741 744 742 item.appendChild(span);745 item.appendChild(span); 743 746 row.appendChild(item); 744 747 list.appendChild(row); 745 748 } 746 749 747 // Close button750 // Close button 748 751 if (this.use_close_btn) { 749 752 list.appendChild(this.createCloseButton(function () { ref.hideLangWindow.apply(ref) })); … … 754 757 table.appendChild(list); 755 758 this.language_window.appendChild(table); 756 } 759 }; 757 760 758 761 this.isLangWindowShown = function() { 759 762 return $(this.language_window).is(':hidden'); 760 } 763 }; 761 764 762 765 this.hideLangWindow = function() { 763 766 $(this.language_window).css('visibility', 'hidden'); 764 767 $(this.switch_lan_pic).removeClass().addClass('googie_lang_3d_on'); 765 } 768 }; 766 769 767 770 this.deHighlightCurSel = function() { 768 771 $(this.lang_cur_elm).removeClass().addClass('googie_list_onout'); 769 } 772 }; 770 773 771 774 this.highlightCurSel = function() { … … 781 784 } 782 785 } 783 } 786 }; 784 787 785 788 this.showLangWindow = function(elm) { … … 790 793 $('body').append(this.language_window); 791 794 792 var pos = $(elm).offset() ;793 var top = pos.top + $(elm).height();794 var left = this.change_lang_pic_placement == 'right' ?795 pos.left - 100 + $(elm).width() : pos.left + $(elm).width();795 var pos = $(elm).offset(), 796 top = pos.top + $(elm).height(), 797 left = this.change_lang_pic_placement == 'right' ? 798 pos.left - 100 + $(elm).width() : pos.left + $(elm).width(); 796 799 797 800 $(this.language_window).css({'visibility': 'visible', 'top' : top+'px','left' : left+'px'}); 798 801 799 802 this.highlightCurSel(); 800 } 803 }; 801 804 802 805 this.createChangeLangPic = function() { 803 806 var img = $('<img>') 804 .attr({src: this.img_dir + 'change_lang.gif', 'alt': 'Change language', 'googie_action_btn': '1'}); 805 806 var switch_lan = document.createElement('span'); 807 var ref = this; 807 .attr({src: this.img_dir + 'change_lang.gif', 'alt': 'Change language', 'googie_action_btn': '1'}), 808 switch_lan = document.createElement('span'); 809 ref = this; 808 810 809 811 $(switch_lan).addClass('googie_lang_3d_on') 810 .append(img)811 .bind('click', function(e) {812 .append(img) 813 .bind('click', function(e) { 812 814 var elm = this.tagName.toLowerCase() == 'img' ? this.parentNode : this; 813 815 if($(elm).hasClass('googie_lang_3d_click')) { 814 elm.className = 'googie_lang_3d_on';815 ref.hideLangWindow();816 elm.className = 'googie_lang_3d_on'; 817 ref.hideLangWindow(); 816 818 } 817 819 else { 818 elm.className = 'googie_lang_3d_click';819 ref.showLangWindow(elm);820 elm.className = 'googie_lang_3d_click'; 821 ref.showLangWindow(elm); 820 822 } 821 });823 }); 822 824 823 825 return switch_lan; 824 } 826 }; 825 827 826 828 this.createSpellDiv = function() { … … 830 832 831 833 if (this.show_spell_img) { 832 $(span).append(' ').append($('<img>').attr('src', this.img_dir + 'spellc.gif'));834 $(span).append(' ').append($('<img>').attr('src', this.img_dir + 'spellc.gif')); 833 835 } 834 836 return span; 835 } 837 }; 836 838 837 839 … … 844 846 var ref = this; 845 847 if (this.main_controller) { 846 var no_spell_errors;847 if (on_finish) {848 var no_spell_errors; 849 if (on_finish) { 848 850 var fn = function() { 849 on_finish();850 ref.checkSpellingState();851 on_finish(); 852 ref.checkSpellingState(); 851 853 }; 852 854 no_spell_errors = fn; 853 }854 else855 } 856 else 855 857 no_spell_errors = function () { ref.checkSpellingState() }; 856 858 … … 863 865 window.setTimeout(no_spell_errors, 1000); 864 866 } 865 } 867 }; 866 868 867 869 this.resumeEditingState = function() { … … 881 883 try { this.edit_layer.scrollTop = this.ta_scroll_top; } 882 884 catch (e) {}; 883 } 885 }; 884 886 885 887 this.checkSpellingState = function(fire) { … … 892 894 this.switch_lan_pic = document.createElement('span'); 893 895 894 var span_chck = this.createSpellDiv() ;895 varref = this;896 var span_chck = this.createSpellDiv(), 897 ref = this; 896 898 897 899 if (this.custom_spellcheck_starter) … … 903 905 if (this.main_controller) { 904 906 if (this.change_lang_pic_placement == 'left') { 905 $(this.spell_container).empty().append(this.switch_lan_pic).append(' ').append(span_chck);907 $(this.spell_container).empty().append(this.switch_lan_pic).append(' ').append(span_chck); 906 908 } else { 907 $(this.spell_container).empty().append(span_chck).append(' ').append(this.switch_lan_pic);908 }909 $(this.spell_container).empty().append(span_chck).append(' ').append(this.switch_lan_pic); 910 } 909 911 } 910 912 911 913 this.spell_span = span_chck; 912 } 914 }; 913 915 914 916 … … 918 920 this.isDefined = function(o) { 919 921 return (o != 'undefined' && o != null) 920 } 922 }; 921 923 922 924 this.errorFixed = function() { … … 927 929 this.all_errors_fixed_observer(); 928 930 } 929 } 931 }; 930 932 931 933 this.errorFound = function() { 932 934 this.cnt_errors++; 933 } 935 }; 934 936 935 937 this.createCloseButton = function(c_fn) { 936 938 return this.createButton(this.lang_close, 'googie_list_close', c_fn); 937 } 939 }; 938 940 939 941 this.createButton = function(name, css_class, c_fn) { 940 var btn_row = document.createElement('tr') ;941 var btn = document.createElement('td');942 varspn_btn;942 var btn_row = document.createElement('tr'), 943 btn = document.createElement('td'), 944 spn_btn; 943 945 944 946 if (css_class) { 945 947 spn_btn = document.createElement('span'); 946 $(spn_btn).addClass(css_class).html(name);948 $(spn_btn).addClass(css_class).html(name); 947 949 } else { 948 950 spn_btn = document.createTextNode(name); … … 950 952 951 953 $(btn).bind('click', c_fn) 952 .bind('mouseover', this.item_onmouseover)953 .bind('mouseout', this.item_onmouseout);954 .bind('mouseover', this.item_onmouseover) 955 .bind('mouseout', this.item_onmouseout); 954 956 955 957 btn.appendChild(spn_btn); … … 957 959 958 960 return btn_row; 959 } 961 }; 960 962 961 963 this.removeIndicator = function(elm) { … … 964 966 if (window.rcmail) 965 967 rcmail.set_busy(false); 966 } 968 }; 967 969 968 970 this.appendIndicator = function(elm) { 969 971 // modified by roundcube 970 972 if (window.rcmail) 971 rcmail.set_busy(true, 'checking');972 /* 973 rcmail.set_busy(true, 'checking'); 974 /* 973 975 this.indicator = document.createElement('img'); 974 976 $(this.indicator).attr('src', this.img_dir + 'indicator.gif') 975 .css({'margin-right': '5px', 'text-decoration': 'none'}).width(16).height(16);976 977 .css({'margin-right': '5px', 'text-decoration': 'none'}).width(16).height(16); 978 977 979 if (elm) 978 $(this.indicator).insertBefore(elm);980 $(this.indicator).insertBefore(elm); 979 981 else 980 $('body').append(this.indicator);981 */ 982 $('body').append(this.indicator); 983 */ 982 984 } 983 985 … … 986 988 $(link).attr({'href': 'javascript:;', 'name': name}); 987 989 return link; 988 } 990 }; 989 991 990 992 this.item_onmouseover = function(e) { 991 if (this.className != "googie_list_revert" && this.className != "googie_list_close")992 this.className = "googie_list_onhover";993 if (this.className != 'googie_list_revert' && this.className != 'googie_list_close') 994 this.className = 'googie_list_onhover'; 993 995 else 994 this.parentNode.className = "googie_list_onhover";995 } 996 this.parentNode.className = 'googie_list_onhover'; 997 }; 996 998 this.item_onmouseout = function(e) { 997 if (this.className != "googie_list_revert" && this.className != "googie_list_close")998 this.className = "googie_list_onout";999 if (this.className != 'googie_list_revert' && this.className != 'googie_list_close') 1000 this.className = 'googie_list_onout'; 999 1001 else 1000 this.parentNode.className = "googie_list_onout";1001 } 1002 1003 1004 }; 1002 this.parentNode.className = 'googie_list_onout'; 1003 }; 1004 1005 1006 };
Note: See TracChangeset
for help on using the changeset viewer.
