- for(i; i < attrs.length; i++) {
- var n = attrs[i];
- if(this.isDefined(n)) {
- if(typeof(n) == "string")
- n = document.createTextNode(n);
- elm.appendChild(n);
- }
- }
- return elm;
- },
-
- UL: function() { return this.createDOM.apply(this, ["ul", arguments]); },
- LI: function() { return this.createDOM.apply(this, ["li", arguments]); },
- TD: function() { return this.createDOM.apply(this, ["td", arguments]); },
- TR: function() { return this.createDOM.apply(this, ["tr", arguments]); },
- TH: function() { return this.createDOM.apply(this, ["th", arguments]); },
- TBODY: function() { return this.createDOM.apply(this, ["tbody", arguments]); },
- TABLE: function() { return this.createDOM.apply(this, ["table", arguments]); },
- INPUT: function() { return this.createDOM.apply(this, ["input", arguments]); },
- SPAN: function() { return this.createDOM.apply(this, ["span", arguments]); },
- B: function() { return this.createDOM.apply(this, ["b", arguments]); },
- A: function() { return this.createDOM.apply(this, ["a", arguments]); },
- DIV: function() { return this.createDOM.apply(this, ["div", arguments]); },
- IMG: function() { return this.createDOM.apply(this, ["img", arguments]); },
- BUTTON: function() { return this.createDOM.apply(this, ["button", arguments]); },
- H1: function() { return this.createDOM.apply(this, ["h1", arguments]); },
- H2: function() { return this.createDOM.apply(this, ["h2", arguments]); },
- H3: function() { return this.createDOM.apply(this, ["h3", arguments]); },
- BR: function() { return this.createDOM.apply(this, ["br", arguments]); },
- TEXTAREA: function() { return this.createDOM.apply(this, ["textarea", arguments]); },
- FORM: function() { return this.createDOM.apply(this, ["form", arguments]); },
- P: function() { return this.createDOM.apply(this, ["p", arguments]); },
- SELECT: function() { return this.createDOM.apply(this, ["select", arguments]); },
- OPTION: function() { return this.createDOM.apply(this, ["option", arguments]); },
- TN: function(text) { return document.createTextNode(text); },
- IFRAME: function() { return this.createDOM.apply(this, ["iframe", arguments]); },
- SCRIPT: function() { return this.createDOM.apply(this, ["script", arguments]); },
-
-////
-// Ajax functions
-////
- /**
- * @returns A new XMLHttpRequest object
- */
- getXMLHttpRequest: function() {
- var try_these = [
- function () { return new XMLHttpRequest(); },
- function () { return new ActiveXObject('Msxml2.XMLHTTP'); },
- function () { return new ActiveXObject('Microsoft.XMLHTTP'); },
- function () { return new ActiveXObject('Msxml2.XMLHTTP.4.0'); },
- function () { throw "Browser does not support XMLHttpRequest"; }
- ];
- for (var i = 0; i < try_these.length; i++) {
- var func = try_these[i];
- try {
- return func();
- } catch (e) {
- }
- }
- },
-
- /**
- * Use this function to do a simple HTTP Request
- */
- doSimpleXMLHttpRequest: function(url) {
- var req = this.getXMLHttpRequest();
- req.open("GET", url, true);
- return this.sendXMLHttpRequest(req);
- },
-
- getRequest: function(url, data) {
- var req = this.getXMLHttpRequest();
- req.open("POST", url, true);
- req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- return this.sendXMLHttpRequest(req);
- },
-
- /**
- * Send a XMLHttpRequest
- */
- sendXMLHttpRequest: function(req, data) {
- var d = new AJSDeferred(req);
-
- var onreadystatechange = function () {
- if (req.readyState == 4) {
- try {
- var status = req.status;
- }
- catch(e) {};
- if(status == 200 || status == 304 || req.responseText == null) {
- d.callback(req, data);
- }
- else {
- d.errback();
- }
- }
- }
- req.onreadystatechange = onreadystatechange;
- return d;
- },
-
- /**
- * Represent an object as a string
- */
- reprString: function(o) {
- return ('"' + o.replace(/(["\\])/g, '\\$1') + '"'
- ).replace(/[\f]/g, "\\f"
- ).replace(/[\b]/g, "\\b"
- ).replace(/[\n]/g, "\\n"
- ).replace(/[\t]/g, "\\t"
- ).replace(/[\r]/g, "\\r");
- },
-
- /**
- * Serialize an object to JSON notation
- */
- serializeJSON: function(o) {
- var objtype = typeof(o);
- if (objtype == "undefined") {
- return "undefined";
- } else if (objtype == "number" || objtype == "boolean") {
- return o + "";
- } else if (o === null) {
- return "null";
- }
- if (objtype == "string") {
- return this.reprString(o);
- }
- var me = arguments.callee;
- var newObj;
- if (typeof(o.__json__) == "function") {
- newObj = o.__json__();
- if (o !== newObj) {
- return me(newObj);
- }
- }
- if (typeof(o.json) == "function") {
- newObj = o.json();
- if (o !== newObj) {
- return me(newObj);
- }
- }
- if (objtype != "function" && typeof(o.length) == "number") {
- var res = [];
- for (var i = 0; i < o.length; i++) {
- var val = me(o[i]);
- if (typeof(val) != "string") {
- val = "undefined";
+ this.org_lang_to_word = {
+ "da": "Dansk", "de": "Deutsch", "en": "English",
+ "es": "Español", "fr": "Français", "it": "Italiano",
+ "nl": "Nederlands", "pl": "Polski", "pt": "Português",
+ "fi": "Suomi", "sv": "Svenska"
+ };
+ this.lang_to_word = this.org_lang_to_word;
+ this.langlist_codes = this.array_keys(this.lang_to_word);
+ this.show_change_lang_pic = true;
+ this.change_lang_pic_placement = 'right';
+ this.report_state_change = true;
+
+ this.ta_scroll_top = 0;
+ this.el_scroll_top = 0;
+
+ this.lang_chck_spell = "Check spelling";
+ this.lang_revert = "Revert to";
+ this.lang_close = "Close";
+ this.lang_rsm_edt = "Resume editing";
+ this.lang_no_error_found = "No spelling errors found";
+ this.lang_no_suggestions = "No suggestions";
+ this.lang_learn_word = "Add to dictionary";
+
+ this.show_spell_img = false; // roundcube mod.
+ this.decoration = true;
+ this.use_close_btn = false;
+ this.edit_layer_dbl_click = true;
+ this.report_ta_not_found = true;
+
+ // Extensions
+ this.custom_ajax_error = null;
+ this.custom_no_spelling_error = null;
+ this.custom_menu_builder = []; // Should take an eval function and a build menu function
+ this.custom_item_evaulator = null; // Should take an eval function and a build menu function
+ this.extra_menu_items = [];
+ this.custom_spellcheck_starter = null;
+ this.main_controller = true;
+ this.has_dictionary = has_dict;
+
+ // Observers
+ this.lang_state_observer = null;
+ this.spelling_state_observer = null;
+ this.show_menu_observer = null;
+ this.all_errors_fixed_observer = null;
+
+ // Focus links - used to give the text box focus
+ this.use_focus = false;
+ this.focus_link_t = null;
+ this.focus_link_b = null;
+
+ // Counters
+ this.cnt_errors = 0;
+ this.cnt_errors_fixed = 0;
+
+ // Set document's onclick to hide the language and error menu
+ $(document).bind('click', function(e) {
+ var target = $(e.target);
+ if(target.attr('googie_action_btn') != '1' && ref.isLangWindowShown())
+ ref.hideLangWindow();
+ if(target.attr('googie_action_btn') != '1' && ref.isErrorWindowShown())
+ ref.hideErrorWindow();
+ });
+
+
+this.decorateTextarea = function(id)
+{
+ this.text_area = typeof id === 'string' ? document.getElementById(id) : id;
+
+ if (this.text_area) {
+ if (!this.spell_container && this.decoration) {
+ var table = document.createElement('table'),
+ tbody = document.createElement('tbody'),
+ tr = document.createElement('tr'),
+ spell_container = document.createElement('td'),
+ r_width = this.isDefined(this.force_width) ? this.force_width : this.text_area.offsetWidth,
+ r_height = this.isDefined(this.force_height) ? this.force_height : 16;
+
+ tr.appendChild(spell_container);
+ tbody.appendChild(tr);
+ $(table).append(tbody).insertBefore(this.text_area).width('100%').height(r_height);
+ $(spell_container).height(r_height).width(r_width).css('text-align', 'right');
+
+ this.spell_container = spell_container;