Aleksander Machniak
2016-05-22 0344b168276f80189e2254c75a762aff5b517b6b
program/js/googiespell.js
@@ -1,23 +1,36 @@
/*
 +-----------------------------------------------------------------------+
 | Roundcube SpellCheck script                                           |
 |   jQuery'fied spell checker based on GoogieSpell 4.0                  |
 |    (which was published under GPL "version 2 or any later version")   |
 |                                                                       |
 | This file is part of the Roundcube Webmail client                     |
 | Copyright (C) 2006 Amir Salihefendic                                  |
 | Copyright (C) 2009 The Roundcube Dev Team                             |
 | Copyright (C) 2011 Kolab Systems AG                                   |
 |                                                                       |
 | Licensed under the GNU General Public License version 3 or            |
 | any later version with exceptions for skins & plugins.                |
 | See the README file for a full license statement.                     |
 |                                                                       |
 +-----------------------------------------------------------------------+
 | Authors: 4mir Salihefendic <amix@amix.dk>                             |
 |          Aleksander Machniak - <alec [at] alec.pl>                    |
 +-----------------------------------------------------------------------+
*/
/**
 * Roundcube SpellCheck script
 *
 * jQuery'fied spell checker based on GoogieSpell 4.0
 * (which was published under GPL "version 2 or any later version")
 *
 * @licstart  The following is the entire license notice for the
 * JavaScript code in this file.
 *
 * Copyright (C) 2006 Amir Salihefendic
 * Copyright (C) 2009 The Roundcube Dev Team
 * Copyright (C) 2011 Kolab Systems AG
 *
 * The JavaScript code in this page is free software: you can
 * redistribute it and/or modify it under the terms of the GNU
 * General Public License (GNU GPL) as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option)
 * any later version.  The code is distributed WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.
 *
 * As additional permission under GNU GPL version 3 section 7, you
 * may distribute non-source (e.g., minimized or compacted) forms of
 * that code without the copy of the GNU GPL normally required by
 * section 4, provided you include this license notice and a URL
 * through which recipients can access the Corresponding Source.
 *
 * @licend  The above is the entire license notice
 * for the JavaScript code in this file.
 *
 * @author 4mir Salihefendic <amix@amix.dk>
 * @author Aleksander Machniak - <alec [at] alec.pl>
 */
var GOOGIE_CUR_LANG,
    GOOGIE_DEFAULT_LANG = 'en';
@@ -93,11 +106,11 @@
    this.cnt_errors_fixed = 0;
    // Set document's onclick to hide the language and error menu
    $(document).bind('click', function(e) {
    $(document).click(function(e) {
        var target = $(e.target);
        if(target.attr('googie_action_btn') != '1' && ref.isLangWindowShown())
        if (target.attr('googie_action_btn') != '1' && ref.isLangWindowShown())
            ref.hideLangWindow();
        if(target.attr('googie_action_btn') != '1' && ref.isErrorWindowShown())
        if (target.attr('googie_action_btn') != '1' && ref.isErrorWindowShown())
            ref.hideErrorWindow();
    });
@@ -289,6 +302,7 @@
    this.cnt_errors_fixed = 0;
    this.cnt_errors = 0;
    this.setStateChanged('checking_spell');
    this.orginal_text = '';
    if (!no_indicator && this.main_controller)
        this.appendIndicator(this.spell_span);
@@ -298,7 +312,9 @@
    this.ignore = ignore;
    this.hideLangWindow();
    if ($(this.text_area).val() == '' || ignore) {
    var area = $(this.text_area);
    if (area.val() == '' || ignore) {
        if (!this.custom_no_spelling_error)
            this.flashNoSpellingErrorState();
        else
@@ -307,7 +323,7 @@
        return;
    }
    this.createEditLayer(this.text_area.offsetWidth, this.text_area.offsetHeight);
    this.createEditLayer(area.width(), area.height());
    this.createErrorWindow();
    $('body').append(this.error_window);
@@ -315,9 +331,9 @@
    catch (e) { }
    if (this.main_controller)
        $(this.spell_span).unbind('click');
        $(this.spell_span).off('click');
    this.orginal_text = $(this.text_area).val();
    this.orginal_text = area.val();
};
this.parseResult = function(r_text)
@@ -449,7 +465,7 @@
this.ignoreError = function(elm, id)
{
    // @TODO: ignore all same words
    $(elm).removeAttr('class').css('color', '').unbind();
    $(elm).removeAttr('class').css('color', '').off();
    this.hideErrorWindow();
};
@@ -524,7 +540,7 @@
            $(dummy).html(suggestions[i]);
            $(item).mouseover(this.item_onmouseover).mouseout(this.item_onmouseout)
               .click(function(e) { ref.correctError(id, elm, e.target.firstChild) });
              .click(function(e) { ref.correctError(id, elm, e.target.firstChild) });
            item.appendChild(dummy);
            row.appendChild(item);
@@ -565,14 +581,15 @@
                    ref.saveOldValue(elm, elm.innerHTML);
                ref.updateOrginalText(offset, elm.innerHTML, edit_input.value, id);
                $(elm).attr('is_corrected', true).css('color', 'green').html(edit_input.value);
                $(elm).attr('is_corrected', true).css('color', 'green').text(edit_input.value);
                ref.hideErrorWindow();
            }
            return false;
        };
        $(edit_input).width(120).css({'margin': 0, 'padding': 0});
        $(edit_input).val(elm.innerHTML).attr('googie_action_btn', '1');
        $(edit_input).width(120)
          .css({'margin': 0, 'padding': 0})
          .val($(elm).text()).attr('googie_action_btn', '1');
        $(edit).css('cursor', 'default').attr('googie_action_btn', '1');
        $(ok_pic).attr('src', this.img_dir + 'ok.gif')
@@ -659,10 +676,10 @@
{
    this.edit_layer = document.createElement('div');
    $(this.edit_layer).addClass('googie_edit_layer').attr('id', 'googie_edit_layer')
        .width('auto').height(height);
        .width(width).height(height);
    if (this.text_area.nodeName.toLowerCase() != 'input' || $(this.text_area).val() == '') {
        $(this.edit_layer).css('overflow', 'auto').height(height-4);
        $(this.edit_layer).css('overflow', 'auto');
    } else {
        $(this.edit_layer).css('overflow', 'hidden');
    }
@@ -826,7 +843,7 @@
        this.lang_elms.push(item);
        $(item).attr('googieId', this.langlist_codes[i])
            .bind('click', function(e) {
            .click(function(e) {
                ref.deHighlightCurSel();
                ref.setCurrentLanguage($(this).attr('googieId'));
@@ -837,11 +854,11 @@
                ref.highlightCurSel();
                ref.hideLangWindow();
            })
            .bind('mouseover', function(e) {
            .mouseover(function(e) {
                if (this.className != "googie_list_selected")
                    this.className = "googie_list_onhover";
            })
            .bind('mouseout', function(e) {
            .mouseout(function(e) {
                if (this.className != "googie_list_selected")
                    this.className = "googie_list_onout";
            });
@@ -924,7 +941,7 @@
    $(switch_lan).addClass('googie_lang_3d_on')
        .append(img)
        .bind('click', function(e) {
        .click(function(e) {
            var elm = this.tagName.toLowerCase() == 'img' ? this.parentNode : this;
            if($(elm).hasClass('googie_lang_3d_click')) {
                elm.className = 'googie_lang_3d_on';
@@ -992,8 +1009,8 @@
    var ref = this;
        $(this.switch_lan_pic).hide();
        $(this.spell_span).empty().unbind().append(rsm)
            .bind('click', function() { ref.resumeEditing() })
        $(this.spell_span).empty().off().append(rsm)
            .click(function() { ref.resumeEditing(); })
            .removeClass().addClass('googie_resume_editing');
    }
@@ -1015,9 +1032,9 @@
        ref = this;
    if (this.custom_spellcheck_starter)
        $(span_chck).bind('click', function(e) { ref.custom_spellcheck_starter() });
        $(span_chck).click(function(e) { ref.custom_spellcheck_starter(); });
    else {
        $(span_chck).bind('click', function(e) { ref.spellCheck() });
        $(span_chck).click(function(e) { ref.spellCheck(); });
    }
    if (this.main_controller) {
@@ -1073,9 +1090,9 @@
        spn_btn = document.createTextNode(name);
    }
    $(btn).bind('click', c_fn)
        .bind('mouseover', this.item_onmouseover)
        .bind('mouseout', this.item_onmouseout);
    $(btn).click(c_fn)
        .mouseover(this.item_onmouseover)
        .mouseout(this.item_onmouseout);
    btn.appendChild(spn_btn);
    btn_row.appendChild(btn);