Changeset 340546c in github


Ignore:
Timestamp:
May 31, 2011 3:38:56 AM (2 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
09c59ab
Parents:
644e3ad9
Message:
  • Optimization for spellcheck_before_send: don't invoke new ajax request. While we already have mispellings, we can return them and enable spellchecker directly without querying the server again
Location:
program
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • program/js/app.js

    r644e3ad9 r340546c  
    30183018    } 
    30193019  }; 
     3020 
     3021  // resume spellchecking, highlight provided mispellings without new ajax request 
     3022  this.spellcheck_resume = function(ishtml, data) 
     3023  { 
     3024    if (ishtml) { 
     3025      var ed = tinyMCE.get(this.env.composebody); 
     3026        sp = ed.plugins.spellchecker; 
     3027 
     3028      sp.active = 1; 
     3029      sp._markWords(data); 
     3030      ed.nodeChanged(); 
     3031    } 
     3032    else { 
     3033      var sp = this.env.spellcheck; 
     3034      sp.prepare(false, true); 
     3035      sp.processData(data); 
     3036    } 
     3037  } 
    30203038 
    30213039  this.set_draft_id = function(id) 
  • program/js/googiespell.js

    r644e3ad9 r340546c  
    204204 
    205205this.spellCheck = function(ignore) { 
    206     this.cnt_errors_fixed = 0; 
    207     this.cnt_errors = 0; 
    208     this.setStateChanged('checking_spell'); 
    209  
    210     if (this.main_controller) 
    211         this.appendIndicator(this.spell_span); 
    212  
    213     this.error_links = []; 
    214     this.ta_scroll_top = this.text_area.scrollTop; 
    215     this.ignore = ignore; 
    216     this.hideLangWindow(); 
    217  
    218     if ($(this.text_area).val() == '' || ignore) { 
    219         if (!this.custom_no_spelling_error) 
    220             this.flashNoSpellingErrorState(); 
    221         else 
    222             this.custom_no_spelling_error(this); 
    223         this.removeIndicator(); 
    224         return; 
    225     } 
    226  
    227     this.createEditLayer(this.text_area.offsetWidth, this.text_area.offsetHeight); 
    228     this.createErrorWindow(); 
    229     $('body').append(this.error_window); 
    230  
    231     try { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); } 
    232     catch (e) { } 
    233  
    234     if (this.main_controller) 
    235         $(this.spell_span).unbind('click'); 
    236  
    237     this.orginal_text = $(this.text_area).val(); 
    238     var req_text = this.escapeSpecial(this.orginal_text); 
    239     var ref = this; 
     206    this.prepare(ignore); 
     207 
     208    var req_text = this.escapeSpecial(this.orginal_text), 
     209        ref = this; 
    240210 
    241211    $.ajax({ type: 'POST', url: this.getUrl(), 
     
    253223            }, 
    254224        success: function(data) { 
    255                 var r_text = data; 
    256             ref.results = ref.parseResult(r_text); 
    257             if (r_text.match(/<c.*>/) != null) { 
    258                     // Before parsing be sure that errors were found 
    259                     ref.showErrorsInIframe(); 
    260                     ref.resumeEditingState(); 
    261             } else { 
     225            ref.processData(data); 
     226            if (!ref.results.length) { 
    262227                    if (!ref.custom_no_spelling_error) 
    263228                        ref.flashNoSpellingErrorState(); 
     
    274239// Spell checking functions 
    275240///// 
     241this.prepare = function(ignore, no_indicator) 
     242{ 
     243    this.cnt_errors_fixed = 0; 
     244    this.cnt_errors = 0; 
     245    this.setStateChanged('checking_spell'); 
     246 
     247    if (!no_indicator && this.main_controller) 
     248        this.appendIndicator(this.spell_span); 
     249 
     250    this.error_links = []; 
     251    this.ta_scroll_top = this.text_area.scrollTop; 
     252    this.ignore = ignore; 
     253    this.hideLangWindow(); 
     254 
     255    if ($(this.text_area).val() == '' || ignore) { 
     256        if (!this.custom_no_spelling_error) 
     257            this.flashNoSpellingErrorState(); 
     258        else 
     259            this.custom_no_spelling_error(this); 
     260        this.removeIndicator(); 
     261        return; 
     262    } 
     263 
     264    this.createEditLayer(this.text_area.offsetWidth, this.text_area.offsetHeight); 
     265    this.createErrorWindow(); 
     266    $('body').append(this.error_window); 
     267 
     268    try { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); } 
     269    catch (e) { } 
     270 
     271    if (this.main_controller) 
     272        $(this.spell_span).unbind('click'); 
     273 
     274    this.orginal_text = $(this.text_area).val(); 
     275}; 
     276 
    276277this.parseResult = function(r_text) { 
    277278    // Returns an array: result[item] -> ['attrs'], ['suggestions'] 
     
    312313}; 
    313314 
     315this.processData = function(data) 
     316{ 
     317    this.results = this.parseResult(data); 
     318    if (this.results.length) { 
     319            this.showErrorsInIframe(); 
     320            this.resumeEditingState(); 
     321    } 
     322}; 
    314323 
    315324////// 
  • program/steps/mail/sendmail.inc

    r644e3ad9 r340546c  
    412412  // Check spelling before send 
    413413  if ($CONFIG['spellcheck_before_send'] && $CONFIG['enable_spellcheck'] 
    414     && empty($_SESSION['compose']['spell_checked']) 
     414    && empty($_SESSION['compose']['spell_checked']) && !empty($message_body) 
    415415  ) { 
    416416    $spellchecker = new rcube_spellchecker(get_input_value('_lang', RCUBE_INPUT_GPC)); 
     
    420420 
    421421    if (!$spell_result) { 
     422      $result = $isHtml ? $spellchecker->get_words() : $spellchecker->get_xml(); 
    422423      $OUTPUT->show_message('mispellingsfound', 'error'); 
    423       $OUTPUT->command('command', 'spellcheck'); 
     424      $OUTPUT->command('spellcheck_resume', $isHtml, $result); 
    424425      $OUTPUT->send('iframe'); 
    425426    } 
Note: See TracChangeset for help on using the changeset viewer.