Added feature #14057: htmlArea RTE: Extjize the RTE ajax requests.
authorStanislas Rolland <typo3@sjbr.ca>
Sat, 10 Apr 2010 20:09:15 +0000 (20:09 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Sat, 10 Apr 2010 20:09:15 +0000 (20:09 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@7271 709f56b5-9817-0410-a4d7-c38de5d9e867

17 files changed:
ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/extensions/Acronym/class.tx_rtehtmlarea_acronym.php
typo3/sysext/rtehtmlarea/extensions/Language/class.tx_rtehtmlarea_language.php
typo3/sysext/rtehtmlarea/extensions/SelectFont/class.tx_rtehtmlarea_selectfont.php
typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/Acronym/acronym.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockStyle/block-style.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/CopyPaste/copy-paste.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/Language/language.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/SelectFont/select-font.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/SpellChecker/spell-checker.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/TYPO3HtmlParser/typo3html-parser.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/TYPO3Link/typo3link.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/TableOperations/table-operations.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/TextStyle/text-style.js
typo3/sysext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php

index d8f2643..36b4718 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2010-04-10  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Added feature #14051: htmlArea RTE: Streamline the RTE loading process
+       * Added feature #14057: htmlArea RTE: Extjize the RTE ajax requests.
 
 2010-04-09  Michael Stucki  <michael@typo3.org>
 
index 8a37ba8..e11b234 100644 (file)
@@ -1,6 +1,7 @@
 2010-04-10  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Added feature #14051: htmlArea RTE: Streamline the RTE loading process
+       * Added feature #14057: htmlArea RTE: Extjize the RTE ajax requests.
 
 2010-04-08  Stanislas Rolland  <typo3@sjbr.ca>
 
index 2142761..d5ed4ae 100644 (file)
@@ -177,7 +177,7 @@ class tx_rtehtmlarea_acronym extends tx_rtehtmlareaapi {
                $whereClause .= t3lib_BEfunc::deleteClause($tableB);
                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $tableAB, $whereClause);
                while ($acronymRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                       $item = array($GLOBALS['LANG']->csConvObj->utf8_encode($acronymRow['term'], $charset), $GLOBALS['LANG']->csConvObj->utf8_encode($acronymRow['acronym'], $charset), $GLOBALS['LANG']->csConvObj->utf8_encode(strtolower($acronymRow['lg_iso_2']), $charset) . ($acronymRow['lg_country_iso_2'] ? ('-' . $acronymRow['lg_country_iso_2']) : ''));
+                       $item = array('term' => $GLOBALS['LANG']->csConvObj->utf8_encode($acronymRow['term'], $charset), 'abbr' => $GLOBALS['LANG']->csConvObj->utf8_encode($acronymRow['acronym'], $charset), 'language' => $GLOBALS['LANG']->csConvObj->utf8_encode(strtolower($acronymRow['lg_iso_2']), $charset) . ($acronymRow['lg_country_iso_2'] ? ('-' . $acronymRow['lg_country_iso_2']) : ''));
                        if ($acronymRow['type'] == 1) {
                                $acronymArray[] = $item;
                        } else if ($acronymRow['type'] == 2) {
@@ -186,10 +186,9 @@ class tx_rtehtmlarea_acronym extends tx_rtehtmlareaapi {
                }
                $this->acronymIndex = count($acronymArray);
                $this->abbreviationIndex = count($abbrArray);
-               return 'var acronyms = ' . json_encode($acronymArray) . ';' . 'var abbreviations = ' . json_encode($abbrArray) . ';';
+               return json_encode(array('abbr' => $abbrArray, 'acronym' => $acronymArray));
        }
 }
-
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/Acronym/class.tx_rtehtmlarea_acronym.php']) {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/Acronym/class.tx_rtehtmlarea_acronym.php']);
 }
index 58e0280..4881d9c 100644 (file)
@@ -88,15 +88,14 @@ class tx_rtehtmlarea_language extends tx_rtehtmlareaapi {
                        $languages = array_flip(array_merge($languages, $this->getLanguages()));
                        $languagesJSArray = array();
                        foreach ($languages as $key => $value) {
-                               $languagesJSArray[] = array($key, $value);
+                               $languagesJSArray[] = array('text' => $key, 'value' => $value);
                        }
-                       $languagesJSArray = 'var options = ' . json_encode($languagesJSArray) . ';';
+                       $languagesJSArray = json_encode(array('options' => $languagesJSArray));
                        $registerRTEinJavascriptString .= '
                        RTEarea['.$RTEcounter.'].buttons.'. $button .'.dataUrl = "' . $this->htmlAreaRTE->writeTemporaryFile('', $button . '_' . $this->htmlAreaRTE->contentLanguageUid, 'js', $languagesJSArray) . '";';
                }
                return $registerRTEinJavascriptString;
        }
-
        /**
         * Getting all languages into an array
         *      where the key is the ISO alpha-2 code of the language
@@ -159,9 +158,7 @@ class tx_rtehtmlarea_language extends tx_rtehtmlareaapi {
                }
        }
 }
-
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/Language/class.tx_rtehtmlarea_language.php']) {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/Language/class.tx_rtehtmlarea_language.php']);
 }
-
 ?>
\ No newline at end of file
index 08299ba..f3b4e0e 100644 (file)
@@ -176,11 +176,10 @@ class tx_rtehtmlarea_selectfont extends tx_rtehtmlareaapi {
                }
                        // Setting the JS list of options
                $itemsJSArray = array();
-               foreach ($items as $option) {
-                       $itemsJSArray[] = $option;
+               foreach ($items as $name => $option) {
+                       $itemsJSArray[] = array('text' => $option[0], 'value' => $option[1]);
                }
-               $itemsJSArray = 'var options = ' . json_encode($itemsJSArray) . ';';
-               
+               $itemsJSArray = json_encode(array('options' => $itemsJSArray));
                        // Adding to button JS configuration
                if (!is_array( $this->thisConfig['buttons.']) || !is_array($this->thisConfig['buttons.'][$buttonId . '.'])) {
                        $configureRTEInJavascriptString .= '
@@ -190,8 +189,7 @@ class tx_rtehtmlarea_selectfont extends tx_rtehtmlareaapi {
                        RTEarea['.$RTEcounter.'].buttons.'. $buttonId . '.dataUrl = \'' . $this->htmlAreaRTE->writeTemporaryFile('', $buttonId . '_'. $this->htmlAreaRTE->contentLanguageUid, 'js', $itemsJSArray) . '\';';
                return $configureRTEInJavascriptString;
        }
-} // end of class
-
+}
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/SelectFont/class.tx_rtehtmlarea_selectfont.php']) {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/SelectFont/class.tx_rtehtmlarea_selectfont.php']);
 }
index 12d8f2d..ec8f94f 100644 (file)
@@ -37,7 +37,9 @@
 if (typeof(HTMLArea) == 'undefined') {
        // Establish HTMLArea name space
 Ext.namespace('HTMLArea.util.TYPO3', 'HTMLArea.util.Tips', 'HTMLArea.util.Color', 'Ext.ux.form', 'Ext.ux.menu', 'Ext.ux.Toolbar');
-       // Establish some constants
+/***************************************************
+ *  CONSTANTS
+ ***************************************************/
 Ext.apply(HTMLArea, {
                // Browser identification
        is_gecko        : Ext.isGecko || Ext.isOpera || Ext.isWebKit,
@@ -95,65 +97,6 @@ HTMLArea.init = function() {
        HTMLArea._appendToLog("[HTMLArea::init]: Editor content skin CSS set to: " + HTMLArea.editedContentCSS);
 };
 /***************************************************
- *  SCRIPT LOADING
- ***************************************************/
-/*
- * Get a script using asynchronous XMLHttpRequest
- */
-HTMLArea.MSXML_XMLHTTP_PROGIDS = new Array('Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP');
-HTMLArea.XMLHTTPResponseHandler = function (request, url) {
-       return (function() {
-               if (request.readyState == 4) {
-                       if (request.status == 200) {
-                               try {
-                                       eval(request.responseText);
-                               } catch (e) {
-                                       HTMLArea._appendToLog('ERROR [HTMLArea::getScript]: Unable to get script ' + url + ': ' + e);
-                               }
-                       } else {
-                               HTMLArea._appendToLog('ERROR [HTMLArea::getScript]: Unable to get ' + url + ' . Server reported ' + request.status);
-                       }
-               }
-       });
-};
-HTMLArea._getScript = function (i,asynchronous,url) {
-       if (typeof(asynchronous) == 'undefined') {
-               var asynchronous = true;
-       }
-       if (window.XMLHttpRequest) {
-               var request = new XMLHttpRequest();
-       } else if (window.ActiveXObject) {
-               var success = false;
-               for (var k = 0; k < HTMLArea.MSXML_XMLHTTP_PROGIDS.length && !success; k++) {
-                       try {
-                               var request = new ActiveXObject(HTMLArea.MSXML_XMLHTTP_PROGIDS[k]);
-                               success = true;
-                       } catch (e) { }
-               }
-               if (!success) {
-                       return false;
-               }
-       }
-       if (request) {
-               HTMLArea._appendToLog('[HTMLArea::getScript]: Requesting script ' + url);
-               request.open('GET', url, asynchronous);
-               if (asynchronous) {
-                       request.onreadystatechange = HTMLArea.XMLHTTPResponseHandler(request, url);
-               }
-               if (window.XMLHttpRequest) {
-                       request.send(null);
-               } else if (window.ActiveXObject) {
-                       request.send();
-               }
-               if (!asynchronous) {
-                       return (request.status == 200 ? request.responseText : '');
-               }
-               return true;
-       } else {
-               return false;
-       }
-};
-/***************************************************
  *  EDITOR CONFIGURATION
  ***************************************************/
 HTMLArea.Config = function (editorId) {
@@ -219,6 +162,7 @@ HTMLArea.Config = function (editorId) {
                        submitValue: false,
                        forceSelection: true,
                        mode: 'local',
+                       storeRoot: 'options',
                        storeFields: [ { name: 'text'}, { name: 'value'}],
                        valueField: 'value',
                        displayField: 'text',
@@ -257,12 +201,24 @@ HTMLArea.Config = Ext.extend(HTMLArea.Config, {
                        // Set some additional properties
                switch (config.xtype) {
                        case 'htmlareacombo':
-                                       // Create combo store
-                               config.store = new Ext.data.ArrayStore({
-                                       autoDestroy:  true,
-                                       fields: config.storeFields,
-                                       data: config.options
-                               });
+                               if (config.options) {
+                                               // Create combo array store
+                                       config.store = new Ext.data.ArrayStore({
+                                               autoDestroy:  true,
+                                               fields: config.storeFields,
+                                               data: config.options
+                                       });
+                               } else if (config.storeUrl) {
+                                       config.mode = 'remote';
+                                               // Create combo json store
+                                       config.store = new Ext.data.JsonStore({
+                                               autoDestroy:  true,
+                                               autoLoad: true,
+                                               root: config.storeRoot,
+                                               fields: config.storeFields,
+                                               url: config.storeUrl
+                                       });
+                               }
                                config.hideLabel = Ext.isEmpty(config.fieldLabel);
                                config.helpTitle = config.tooltip;
                                break;
@@ -3644,73 +3600,6 @@ Ext.ux.form.ColorPaletteField = Ext.extend(Ext.form.TriggerField, {
        }
 });
 Ext.reg('colorpalettefield', Ext.ux.form.ColorPaletteField);
-/*
- * Use XML HTTPRequest to post some data back to the server and do something
- * with the response (asyncronously or syncronously); this is used by such things as the spellchecker update personal dict function
- */
-HTMLArea._postback = function(url, data, handler, addParams, charset, asynchronous) {
-       if (typeof(charset) == "undefined") var charset = "utf-8";
-       if (typeof(asynchronous) == "undefined") {
-               var asynchronous = true;
-       }
-       var req = null;
-       if (window.XMLHttpRequest) req = new XMLHttpRequest();
-               else if (window.ActiveXObject) {
-                       var success = false;
-                       for (var k = 0; k < HTMLArea.MSXML_XMLHTTP_PROGIDS.length && !success; k++) {
-                               try {
-                                       req = new ActiveXObject(HTMLArea.MSXML_XMLHTTP_PROGIDS[k]);
-                                       success = true;
-                               } catch (e) { }
-                       }
-               }
-
-       if(req) {
-               var content = '';
-               for (var i in data) {
-                       content += (content.length ? '&' : '') + i + '=' + encodeURIComponent(data[i]);
-               }
-               content += (content.length ? '&' : '') + 'charset=' + charset;
-               if (typeof(addParams) != "undefined") content += addParams;
-
-               function callBack() {
-                       if (req.readyState == 4) {
-                               if (req.status == 200) {
-                                       if (typeof(handler) == "function") handler(req.responseText, req);
-                                       HTMLArea._appendToLog("[HTMLArea::_postback]: Server response: " + req.responseText);
-                               } else {
-                                       HTMLArea._appendToLog("ERROR [HTMLArea::_postback]: Unable to post " + url + " . Server reported " + req.statusText);
-                               }
-                       }
-               }
-               if (asynchronous) {
-                       req.onreadystatechange = callBack;
-               }
-               function sendRequest() {
-                       HTMLArea._appendToLog("[HTMLArea::_postback]: Request: " + content);
-                       req.send(content);
-               }
-
-               req.open('POST', url, asynchronous);
-               req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
-               if (!asynchronous) {
-                       HTMLArea.pendingSynchronousXMLHttpRequest = true;
-                       sendRequest();
-                       if (req.status == 200) {
-                               if (typeof(handler) == "function") {
-                                       handler(req.responseText, req);
-                               }
-                               HTMLArea._appendToLog("[HTMLArea::_postback]: Server response: " + req.responseText);
-                       } else {
-                               HTMLArea._appendToLog("ERROR [HTMLArea::_postback]: Unable to post " + url + " . Server reported " + req.statusText);
-                       }
-                       HTMLArea.pendingSynchronousXMLHttpRequest = false;
-               } else {
-                       window.setTimeout(sendRequest, 500);
-               }
-       }
-};
-
 /**
  * Internet Explorer returns an item having the _name_ equal to the given id, even if it's not having any id.
  * This way it can return a different form field even if it's not a textarea.  This works around the problem by
@@ -3887,6 +3776,7 @@ HTMLArea.Plugin = HTMLArea.Base.extend({
        constructor : function(editor, pluginName) {
                this.editor = editor;
                this.editorNumber = editor.editorId;
+               this.editorId = editor.editorId;
                this.editorConfiguration = editor.config;
                this.name = pluginName;
                try {
@@ -4184,7 +4074,9 @@ HTMLArea.Plugin = HTMLArea.Base.extend({
         */
        onUpdateToolbar: Ext.emptyFn,
        /**
-        * Deprecated as of TYPO3 4.4
+        ***********************************************
+        * THIS FUNCTION IS DEPRECATED AS OF TYPO3 4.4 *
+        ***********************************************
         * Register the key handler to the editor keyMap in onGenerate function
         * The keyPress event handler
         * This function may be defined by the plugin subclass.
@@ -4219,12 +4111,15 @@ HTMLArea.Plugin = HTMLArea.Base.extend({
        onGenerate: Ext.emptyFn,
        /**
         * Make function reference in order to avoid memory leakage in IE
+        ***********************************************
+        * THIS FUNCTION IS DEPRECATED AS OF TYPO3 4.4 *
+        ***********************************************
         *
         * @param       string          functionName: the name of the plugin function to be invoked
         *
         * @return      function        function definition invoking the specified function of the plugin
         */
-       makeFunctionReference : function (functionName) {
+       makeFunctionReference: function (functionName) {
                var self = this;
                return (function(arg1, arg2, arg3) {
                        return (self[functionName](arg1, arg2, arg3));});
@@ -4237,53 +4132,76 @@ HTMLArea.Plugin = HTMLArea.Base.extend({
         *
         * @return      string          the localization of the label
         */
-       localize : function (label) {
+       localize: function (label) {
                return this.I18N[label] || HTMLArea.I18N.dialogs[label] || HTMLArea.I18N.tooltips[label] || HTMLArea.I18N.msg[label];
        },
-
        /**
-        * Load a Javascript file synchronously
+        * Load a Javascript file asynchronously
         *
         * @param       string          url: url of the file to load
+        * @param       function        callBack: the callBack function
         *
-        * @return      boolean         true on success
+        * @return      boolean         true on success of the request submission
         */
-       getJavascriptFile : function (url, noEval) {
-               var script = HTMLArea._getScript(0, false, url);
-               if (script) {
-                       if (noEval) {
-                               return script;
-                       } else {
-                               try {
-                                       eval(script);
-                                       return true;
-                               } catch(e) {
-                                       this.appendToLog("getJavascriptFile", "Error evaluating contents of Javascript file: " + url);
-                                       return false;
-                               }
-                       }
-               } else {
-                       return false;
-               }
+       getJavascriptFile: function (url, callback) {
+               var success = false;
+               this.appendToLog('getJavascriptFile', 'Requesting script ' + url);
+               Ext.Ajax.request({
+                       method: 'GET',
+                       url: url,
+                       callback: callback,
+                       success: function (response) {
+                               success = true;
+                       },
+                       failure: function (response) {
+                               this.appendToLog('getJavascriptFile', 'Unable to get ' + url + ' . Server reported ' + response.status);
+                       },
+                       scope: this
+               });
+               return success;
        },
-
        /**
         * Post data to the server
         *
         * @param       string          url: url to post data to
         * @param       object          data: data to be posted
-        * @param       function        handler: function that will handle the response returned by the server
-        * @param       boolean         asynchronous: flag indicating if the request should processed asynchronously or not
+        * @param       function        callback: function that will handle the response returned by the server
         *
         * @return      boolean         true on success
         */
-        postData : function (url, data, handler, asynchronous) {
-                if (typeof(asynchronous) == "undefined") {
-                        var asynchronous = true;
-                }
-                HTMLArea._postback(url, data, handler, this.editorConfiguration.RTEtsConfigParams, (this.editorConfiguration.typo3ContentCharset ? this.editorConfiguration.typo3ContentCharset : "utf-8"), asynchronous);
+        postData: function (url, data, callback) {
+               var success = false;
+               data.charset = this.editorConfiguration.typo3ContentCharset ? this.editorConfiguration.typo3ContentCharset : 'utf-8';
+               var params = '';
+               Ext.iterate(data, function (parameter, value) {
+                       params += (params.length ? '&' : '') + parameter + '=' + encodeURIComponent(value);
+               });
+               params += this.editorConfiguration.RTEtsConfigParams;
+               this.appendToLog('postData', 'Posting to ' + url + '. Data: ' + params);
+               Ext.Ajax.request({
+                       method: 'POST',
+                       headers: {
+                               'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
+                       },
+                       url: url,
+                       params: params,
+                       callback: Ext.isFunction(callback) ? callback: function (options, success, response) {
+                               if (success) {
+                                       this.appendToLog('postData', 'Post request to ' + url + ' successful. Server response: ' + response.responseText);
+                               } else {
+                                       this.appendToLog('postData', 'Post request to ' + url + ' failed. Server reported ' + response.status);
+                               }
+                       },
+                       success: function (response) {
+                               success = true;
+                       },
+                       failure: function (response) {
+                               this.appendToLog('postData', 'Unable to post ' + url + ' . Server reported ' + response.status);
+                       },
+                       scope: this
+               });
+               return success;
         },
-
        /**
         ***********************************************
         * THIS FUNCTION IS DEPRECATED AS OF TYPO3 4.4 *
index fc94aac..a6df65a 100644 (file)
  * TYPO3 SVN ID: $Id$
  */
 Acronym = HTMLArea.Plugin.extend({
-       constructor : function(editor, pluginName) {
+       constructor: function(editor, pluginName) {
                this.base(editor, pluginName);
        },
        /*
         * This function gets called by the class constructor
         */
-       configurePlugin : function(editor) {
+       configurePlugin: function(editor) {
                this.pageTSConfiguration = this.editorConfiguration.buttons.acronym;
-               this.acronymUrl = this.pageTSConfiguration.acronymUrl;
-               this.data = this.getJavascriptFile(this.acronymUrl, 'noEval');
-               if (this.data) {
-                       eval(this.data);
-               };
-               this.data = {
-                       acronym: acronyms,
-                       abbr: abbreviations
-               };
                /*
                 * Registering plugin "About" information
                 */
@@ -253,10 +244,12 @@ Acronym = HTMLArea.Plugin.extend({
                        itemId: 'termSelector',
                        helpTitle: this.localize('Select_a_term'),
                        tpl: '<tpl for="."><div ext:qtip="{abbr}" style="text-align:left;font-size:11px;" class="x-combo-list-item">{term}</div></tpl>',
-                       store: new Ext.data.ArrayStore({
+                       store: new Ext.data.JsonStore({
                                autoDestroy:  true,
+                               autoLoad: true,
+                               root: type,
                                fields: [ { name: 'term'}, { name: 'abbr'},  { name: 'language'}],
-                               data: this.data[type]
+                               url: this.pageTSConfiguration.acronymUrl
                        }),
                        width: 350,
                        listeners: {
@@ -278,10 +271,12 @@ Acronym = HTMLArea.Plugin.extend({
                        fieldLabel: this.localize('Abridged_term'),
                        itemId: 'abbrSelector',
                        helpTitle: this.localize('Select_an_' + type),
-                       store: new Ext.data.ArrayStore({
+                       store: new Ext.data.JsonStore({
                                autoDestroy:  true,
+                               autoLoad: true,
+                               root: type,
                                fields: [ { name: 'term'}, { name: 'abbr'},  { name: 'language'}],
-                               data: this.data[type]
+                               url: this.pageTSConfiguration.acronymUrl
                        }),
                        width: 100,
                        listeners: {
@@ -297,19 +292,30 @@ Acronym = HTMLArea.Plugin.extend({
                }, this.configDefaults['combo']));
                var languageObject = this.getPluginInstance('Language');
                if (this.getButton('Language')) {
-                       var languageStore = new Ext.data.ArrayStore({
+                       var selectedLanguage = !Ext.isEmpty(element) ? languageObject.getLanguageAttribute(element) : 'none';
+                       function initLanguageStore (store) {
+                               if (selectedLanguage !== 'none') {
+                                       store.removeAt(0);
+                                       store.insert(0, new store.recordType({
+                                               text: languageObject.localize('Remove language mark'),
+                                               value: 'none'
+                                       }));
+                               }
+                               this.getButton('Language').setValue('none');
+                       }
+                       var languageStore = new Ext.data.JsonStore({
                                autoDestroy:  true,
+                               autoLoad: true,
+                               root: 'options',
                                fields: [ { name: 'text'}, { name: 'value'} ],
-                               data: this.getDropDownConfiguration('Language').options
+                               url: this.getDropDownConfiguration('Language').dataUrl,
+                               listeners: {
+                                       load: {
+                                               fn: initLanguageStore,
+                                               scope: this
+                                       }
+                               }
                        });
-                       var selectedLanguage = !Ext.isEmpty(element) ? languageObject.getLanguageAttribute(element) : 'none';
-                       if (selectedLanguage !== 'none') {
-                               languageStore.removeAt(0);
-                               languageStore.insert(0, new languageStore.recordType({
-                                       text: languageObject.localize('Remove language mark'),
-                                       value: 'none'
-                               }));
-                       }
                        itemsConfig.push(Ext.apply({
                                xtype: 'combo',
                                fieldLabel: this.localize('Language'),
@@ -321,7 +327,17 @@ Acronym = HTMLArea.Plugin.extend({
                                tpl: '<tpl for="."><div ext:qtip="{value}" style="text-align:left;font-size:11px;" class="x-combo-list-item">{text}</div></tpl>',
                                store: languageStore,
                                width: 200,
-                               value: selectedLanguage
+                               value: selectedLanguage,
+                               listeners: {
+                                       render: {
+                                               fn: function (combo) {
+                                                               // Load the language dropdown
+                                                       combo.getStore().load({
+                                                               callback: function () { combo.setValue(selectedLanguage); }
+                                                       });
+                                               }
+                                       }
+                               }
                        }, this.configDefaults['combo']));
                }
                return {
index dfb36ac..d79d847 100644 (file)
@@ -247,18 +247,31 @@ BlockStyle = HTMLArea.Plugin.extend({
         * This function gets called on plugin generation, on toolbar update and on change mode
         * Re-initiate the parsing of the style sheets, if not yet completed, and refresh our toolbar components
         */
-       generate : function(editor, dropDownId) {
-               if (this.cssLoaded && this.getEditorMode() === "wysiwyg" && this.editor.isEditable()) {
+       generate: function(editor, dropDownId) {
+               if (this.cssLoaded && this.getEditorMode() === 'wysiwyg' && this.editor.isEditable()) {
                        this.updateValue(dropDownId);
                } else {
                        if (this.cssTimeout) {
                                window.clearTimeout(this.cssTimeout);
                                this.cssTimeout = null;
                        }
-                       if (this.classesUrl && (typeof(HTMLArea.classesLabels) === "undefined")) {
-                               this.getJavascriptFile(this.classesUrl);
+                       if (this.classesUrl && (typeof(HTMLArea.classesLabels) === 'undefined')) {
+                               this.getJavascriptFile(this.classesUrl, function (options, success, response) {
+                                       if (success) {
+                                               try {
+                                                       if (typeof(HTMLArea.classesLabels) === 'undefined') {
+                                                               eval(response.responseText);
+                                                               this.appendToLog('generate', 'Javascript file successfully evaluated: ' + this.classesUrl);
+                                                       }
+                                               } catch(e) {
+                                                       this.appendToLog('generate', 'Error evaluating contents of Javascript file: ' + this.classesUrl);
+                                               }
+                                       }
+                                       this.buildCssArray(this.editor, dropDownId);
+                               });
+                       } else {
+                               this.buildCssArray(this.editor, dropDownId);
                        }
-                       this.buildCssArray(this.editor, dropDownId);
                }
        },
        
index 83411a6..08c0dc9 100644 (file)
@@ -408,8 +408,7 @@ CopyPaste = HTMLArea.Plugin.extend({
                                if (InstallTrigger.enabled()) {
                                        var mozillaXpi = new Object();
                                        mozillaXpi["AllowClipboard Helper"] = this.buttonsConfiguration.paste.mozillaAllowClipboardURL;
-                                       var mozillaInstallCallback = this.makeFunctionReference("mozillaInstallCallback");
-                                       InstallTrigger.install(mozillaXpi, mozillaInstallCallback);
+                                       InstallTrigger.install(mozillaXpi, this.mozillaInstallCallback);
                                } else {
                                        alert(this.localize("Mozilla-Org-Install-Not-Enabled"));
                                        this.appendToLog("mozillaClipboardAccessException", "Mozilla install was not enabled.");
index 121678d..cbbbf24 100644 (file)
@@ -102,28 +102,23 @@ Language = HTMLArea.Plugin.extend({
                 */
                var buttonId = 'Language';
                if (this.buttonsConfiguration[buttonId.toLowerCase()] && this.buttonsConfiguration[buttonId.toLowerCase()].dataUrl) {
-                               // Load the options var
-                       var optionsData = this.getJavascriptFile(this.buttonsConfiguration[buttonId.toLowerCase()].dataUrl, "noEval");
-                       if (optionsData) {
-                               eval(optionsData);
-                       }
-               }
-               var dropDownConfiguration = {
-                       id              : buttonId,
-                       tooltip         : this.localize(buttonId + '-Tooltip'),
-                       options         : options,
-                       action          : 'onChange'
-               };
-               if (this.buttonsConfiguration.language) {
-                       dropDownConfiguration.width = this.buttonsConfiguration.language.width ? parseInt(this.buttonsConfiguration.language.width, 10) : 200;
-                       if (this.buttonsConfiguration.language.listWidth) {
-                               dropDownConfiguration.listWidth = parseInt(this.buttonsConfiguration.language.listWidth, 10);
-                       }
-                       if (this.buttonsConfiguration.language.maxHeight) {
-                               dropDownConfiguration.maxHeight = parseInt(this.buttonsConfiguration.language.maxHeight, 10);
+                       var dropDownConfiguration = {
+                               id              : buttonId,
+                               tooltip         : this.localize(buttonId + '-Tooltip'),
+                               storeUrl        : this.buttonsConfiguration[buttonId.toLowerCase()].dataUrl,
+                               action          : 'onChange'
+                       };
+                       if (this.buttonsConfiguration.language) {
+                               dropDownConfiguration.width = this.buttonsConfiguration.language.width ? parseInt(this.buttonsConfiguration.language.width, 10) : 200;
+                               if (this.buttonsConfiguration.language.listWidth) {
+                                       dropDownConfiguration.listWidth = parseInt(this.buttonsConfiguration.language.listWidth, 10);
+                               }
+                               if (this.buttonsConfiguration.language.maxHeight) {
+                                       dropDownConfiguration.maxHeight = parseInt(this.buttonsConfiguration.language.maxHeight, 10);
+                               }
                        }
+                       this.registerDropDown(dropDownConfiguration);
                }
-               this.registerDropDown(dropDownConfiguration);
                return true;
        },
        /*
@@ -137,7 +132,7 @@ Language = HTMLArea.Plugin.extend({
        /*
         * This function gets called when the editor is generated
         */
-       onGenerate : function () {
+       onGenerate: function () {
                        // Add rules to the stylesheet for language mark highlighting
                        // Model: body.htmlarea-show-language-marks *[lang=en]:before { content: "en: "; }
                        // Works in IE8, but not in earlier versions of IE
@@ -160,8 +155,12 @@ Language = HTMLArea.Plugin.extend({
                                return true;
                        });
                }
+                       // Load the language dropdown
+               this.getButton('Language').getStore().load({
+                       callback: function () { this.getButton('Language').setValue('none'); },
+                       scope: this
+               });
        },
-
        /*
         * This function gets called when a button was pressed.
         *
index 30d5066..a30f11f 100644 (file)
  * TYPO3 SVN ID: $Id$
  */
 SelectFont = HTMLArea.Plugin.extend({
-               
-       constructor : function(editor, pluginName) {
+       constructor: function(editor, pluginName) {
                this.base(editor, pluginName);
        },
-       
        /*
         * This function gets called by the class constructor
         */
-       configurePlugin : function (editor) {
-
+       configurePlugin: function (editor) {
                this.buttonsConfiguration = this.editorConfiguration.buttons;
                this.disablePCexamples = this.editorConfiguration.disablePCexamples;
-
                        // Font formating will use the style attribute
                if (this.getPluginInstance("TextStyle")) {
                        this.getPluginInstance("TextStyle").addAllowedAttribute("style");
@@ -81,19 +77,11 @@ SelectFont = HTMLArea.Plugin.extend({
                 */
                Ext.each(this.dropDownList, function (dropDown) {
                        var buttonId = dropDown[0];
-                               // Load the options var
-                       var options = [];
-                       if (this.buttonsConfiguration[dropDown[2]] && this.buttonsConfiguration[dropDown[2]].dataUrl) {
-                               var optionsData = this.getJavascriptFile(this.buttonsConfiguration[dropDown[2]].dataUrl, "noEval");
-                               if (optionsData) {
-                                       eval(optionsData);
-                               }
-                       }
                        var dropDownConfiguration = {
                                id: buttonId,
                                tooltip: this.localize(buttonId.toLowerCase()),
-                               options: options,
-                               action: "onChange",
+                               storeUrl: this.buttonsConfiguration[dropDown[2]].dataUrl,
+                               action: 'onChange',
                                tpl: this.disablePCexamples ? '' : '<tpl for="."><div ext:qtip="{value}" style="' + dropDown[3] + '" class="x-combo-list-item">{text}</div></tpl>'
                        };
                        if (this.buttonsConfiguration[dropDown[2]]) {
@@ -112,31 +100,40 @@ SelectFont = HTMLArea.Plugin.extend({
                }, this);
                return true;
         },
-        
        /*
         * The list of buttons added by this plugin
         */
-       dropDownList : [
+       dropDownList: [
                ['FontName', null, 'fontstyle', 'font-family:{value};text-align:left;font-size:11px;'],
                ['FontSize', null, 'fontsize', 'text-align:left;font-size:{value};']
        ],
-       
        /*
         * Conversion object: button name to corresponding style property name
         */
-       styleProperty : {
+       styleProperty: {
                FontName        : "fontFamily",
                FontSize        : "fontSize"
        },
-       
        /*
         * Conversion object: button name to corresponding css property name
         */
-       cssProperty : {
+       cssProperty: {
                FontName        : "font-family",
                FontSize        : "font-size"
        },
        /*
+        * This funcion is invoked by the editor when it is being generated
+        */
+       onGenerate: function () {
+                       // Load the dropdowns
+               Ext.each(this.dropDownList, function (dropDown) {
+                       this.getButton(dropDown[0]).getStore().load({
+                               callback: function () { this.getButton(dropDown[0]).setValue('none'); },
+                               scope: this
+                       })
+               }, this);
+       },
+       /*
         * This function gets called when some font style or font size was selected from the dropdown lists
         */
        onChange: function (editor, combo, record, index) {
@@ -194,7 +191,7 @@ SelectFont = HTMLArea.Plugin.extend({
         *
         * @return      void
         */
-       setStyle : function (element, buttonId, value) {
+       setStyle: function (element, buttonId, value) {
                element.style[this.styleProperty[buttonId]] = (value && value !== 'none') ? value : '';
                        // In IE, we need to remove the empty attribute in order to unset it
                if (HTMLArea.is_ie && (!value || value == 'none')) {
@@ -211,7 +208,6 @@ SelectFont = HTMLArea.Plugin.extend({
                        }
                }
        },
-
        /*
         * This function gets called when the toolbar is updated
         */
@@ -223,8 +219,8 @@ SelectFont = HTMLArea.Plugin.extend({
                        var value = parentElement.style[this.styleProperty[select.itemId]];
                        if (!value) {
                                if (HTMLArea.is_gecko) {
-                                       if (editor._doc.defaultView.getComputedStyle(parentElement, null)) {
-                                               value = editor._doc.defaultView.getComputedStyle(parentElement, null).getPropertyValue(this.cssProperty[select.itemId]);
+                                       if (editor.document.defaultView.getComputedStyle(parentElement, null)) {
+                                               value = editor.document.defaultView.getComputedStyle(parentElement, null).getPropertyValue(this.cssProperty[select.itemId]);
                                        }
                                } else {
                                        value = parentElement.currentStyle[this.styleProperty[select.itemId]];
@@ -241,7 +237,7 @@ SelectFont = HTMLArea.Plugin.extend({
                        }
                        if (index != -1) {
                                select.setValue(store.getAt(index).get('value'));
-                       } else {
+                       } else if (store.getCount()) {
                                select.setValue('none');
                        }
                        select.setDisabled(!endPointsInSameBlock || (selectionEmpty && /^body$/i.test(parentElement.nodeName)));
index 8105353..d8ad14d 100644 (file)
@@ -430,7 +430,7 @@ SpellChecker = HTMLArea.Plugin.extend({
                                data['to_r_list[' + index + '][0]'] = replacement[0];
                                data['to_r_list[' + index + '][1]'] = replacement[1];
                        });
-                       HTMLArea._postback(this.pageTSconfiguration.path, data);
+                       this.postData(this.pageTSconfiguration.path, data);
                }
                this.close();
                return false;
index d7ecde0..d847c3e 100644 (file)
@@ -91,18 +91,23 @@ TYPO3HtmlParser = HTMLArea.Plugin.extend({
                        editor.cleanAppleStyleSpans(editor._doc.body);
                }
                var bookmark = editor.getBookmark(editor._createRange(editor._getSelection()));
+               var url = this.parseHtmlModulePath;
                var content = {
-                       editorNo : this.editorNumber,
+                       editorNo : this.editorId,
                        content  : editor.getInnerHTML()
                };
-                       // Server-based synchronous pasted content cleaning
-               this.postData(  this.parseHtmlModulePath,
+                       // Server-based cleaning of pasted content
+               this.postData(  url,
                                content,
-                               function(response) {
-                                       editor.setHTML(response);
-                                       editor.selectRange(editor.moveToBookmark(bookmark));
-                               },
-                               false
+                               function (options, success, response) {
+                                       if (success) {
+                                               editor.setHTML(response.responseText);
+                                               editor.selectRange(editor.moveToBookmark(bookmark));
+                                               this.appendToLog('clean', 'Post request to ' + url + ' successful. Server response: ' + response.responseText);
+                                       } else {
+                                               this.appendToLog('clean', 'Post request to ' + url + ' failed. Server reported ' + response.status);
+                                       }
+                               }
                );
        },
        /*
index 28545e1..eb42465 100644 (file)
@@ -82,6 +82,26 @@ TYPO3Link = HTMLArea.Plugin.extend({
                ['UnLink', 'a', false, false, 'unlink']
        ],
        /*
+        * This function is invoked when the editor is being generated
+        */
+       onGenerate: function () {
+                       // Download the definition of special anchor classes if not yet done
+               if (this.classesAnchorUrl && (typeof(HTMLArea.classesAnchorSetup) === 'undefined')) {
+                       this.getJavascriptFile(this.classesAnchorUrl, function (options, success, response) {
+                               if (success) {
+                                       try {
+                                               if (typeof(HTMLArea.classesAnchorSetup) === 'undefined') {
+                                                       eval(response.responseText);
+                                                       this.appendToLog('ongenerate', 'Javascript file successfully evaluated: ' + this.classesAnchorUrl);
+                                               }
+                                       } catch(e) {
+                                               this.appendToLog('ongenerate', 'Error evaluating contents of Javascript file: ' + this.classesAnchorUrl);
+                                       }
+                               }
+                       });
+               }
+       },
+       /*
         * This function gets called when the button was pressed
         *
         * @param       object          editor: the editor instance
@@ -94,58 +114,68 @@ TYPO3Link = HTMLArea.Plugin.extend({
                        // Could be a button or its hotkey
                var buttonId = this.translateHotKey(id);
                buttonId = buttonId ? buttonId : id;
-               
                        // Download the definition of special anchor classes if not yet done
-               if (this.classesAnchorUrl && (typeof(HTMLArea.classesAnchorSetup) === "undefined")) {
-                       this.getJavascriptFile(this.classesAnchorUrl);
-               }
-               
-               if (buttonId === "UnLink") {
-                       this.unLink();
-                       return false;
-               }
-               
-               var additionalParameter;
-               var node = this.editor.getParentElement();
-               var el = HTMLArea.getElementObject(node, "a");
-               if (el != null && /^a$/i.test(el.nodeName)) node = el;
-               if (node != null && /^a$/i.test(node.nodeName)) {
-                       additionalParameter = "&curUrl[href]=" + encodeURIComponent(node.getAttribute("href"));
-                       if (node.target) additionalParameter += "&curUrl[target]=" + encodeURIComponent(node.target);
-                       if (node.className) additionalParameter += "&curUrl[class]=" + encodeURIComponent(node.className);
-                       if (node.title) additionalParameter += "&curUrl[title]=" + encodeURIComponent(node.title);
-                       if (this.pageTSConfiguration && this.pageTSConfiguration.additionalAttributes) {
-                               var additionalAttributes = this.pageTSConfiguration.additionalAttributes.split(",");
-                               for (var i = additionalAttributes.length; --i >= 0;) {
-                                       if (node.hasAttribute(additionalAttributes[i])) {
-                                               additionalParameter += "&curUrl[" + additionalAttributes[i] + "]=" + encodeURIComponent(node.getAttribute(additionalAttributes[i]));
+               if (this.classesAnchorUrl && (typeof(HTMLArea.classesAnchorSetup) === 'undefined')) {
+                       this.getJavascriptFile(this.classesAnchorUrl, function (options, success, response) {
+                               if (success) {
+                                       try {
+                                               if (typeof(HTMLArea.classesAnchorSetup) === 'undefined') {
+                                                       eval(response.responseText);
+                                                       this.appendToLog('onButtonPress', 'Javascript file successfully evaluated: ' + this.classesAnchorUrl);
+                                               }
+                                               this.onButtonPress(editor, id, target);
+                                       } catch(e) {
+                                               this.appendToLog('onButtonPress', 'Error evaluating contents of Javascript file: ' + this.classesAnchorUrl);
                                        }
                                }
+                       });
+               } else {
+                       if (buttonId === "UnLink") {
+                               this.unLink();
+                               return false;
                        }
-               } else if (this.editor.hasSelectedText()) {
-                       var text = this.editor.getSelectedHTML();
-                       if (text && text != null) {
-                               var offset = text.toLowerCase().indexOf("<a");
-                               if (offset!=-1) {
-                                       var ATagContent = text.substring(offset+2);
-                                       offset = ATagContent.toUpperCase().indexOf(">");
-                                       ATagContent = ATagContent.substring(0,offset);
-                                       additionalParameter = "&curUrl[all]=" + encodeURIComponent(ATagContent);
+                       var additionalParameter;
+                       var node = this.editor.getParentElement();
+                       var el = HTMLArea.getElementObject(node, "a");
+                       if (el != null && /^a$/i.test(el.nodeName)) node = el;
+                       if (node != null && /^a$/i.test(node.nodeName)) {
+                               additionalParameter = "&curUrl[href]=" + encodeURIComponent(node.getAttribute("href"));
+                               if (node.target) additionalParameter += "&curUrl[target]=" + encodeURIComponent(node.target);
+                               if (node.className) additionalParameter += "&curUrl[class]=" + encodeURIComponent(node.className);
+                               if (node.title) additionalParameter += "&curUrl[title]=" + encodeURIComponent(node.title);
+                               if (this.pageTSConfiguration && this.pageTSConfiguration.additionalAttributes) {
+                                       var additionalAttributes = this.pageTSConfiguration.additionalAttributes.split(",");
+                                       for (var i = additionalAttributes.length; --i >= 0;) {
+                                               if (node.hasAttribute(additionalAttributes[i])) {
+                                                       additionalParameter += "&curUrl[" + additionalAttributes[i] + "]=" + encodeURIComponent(node.getAttribute(additionalAttributes[i]));
+                                               }
+                                       }
+                               }
+                       } else if (this.editor.hasSelectedText()) {
+                               var text = this.editor.getSelectedHTML();
+                               if (text && text != null) {
+                                       var offset = text.toLowerCase().indexOf("<a");
+                                       if (offset!=-1) {
+                                               var ATagContent = text.substring(offset+2);
+                                               offset = ATagContent.toUpperCase().indexOf(">");
+                                               ATagContent = ATagContent.substring(0,offset);
+                                               additionalParameter = "&curUrl[all]=" + encodeURIComponent(ATagContent);
+                                       }
                                }
                        }
+                       this.openContainerWindow(
+                               buttonId,
+                               buttonId.toLowerCase(),
+                               this.getWindowDimensions(
+                                       {
+                                               width:  550,
+                                               height: 350
+                                       },
+                                       buttonId
+                               ),
+                               this.makeUrlFromModulePath(this.modulePath, additionalParameter)
+                       );
                }
-               this.openContainerWindow(
-                       buttonId,
-                       buttonId.toLowerCase(),
-                       this.getWindowDimensions(
-                               {
-                                       width:  550,
-                                       height: 350
-                               },
-                               buttonId
-                       ),
-                       this.makeUrlFromModulePath(this.modulePath, additionalParameter)
-               );
                return false;
        },
        /*
index 7ac4bd0..48ebeff 100644 (file)
@@ -1182,33 +1182,46 @@ TableOperations = HTMLArea.Plugin.extend({
         *
         * @return      void
         */
-       reStyleTable : function (table) {
+       reStyleTable: function (table) {
                if (table) {
-                       if (this.classesUrl && (typeof(HTMLArea.classesAlternating) === "undefined" || typeof(HTMLArea.classesCounting) === "undefined")) {
-                               this.getJavascriptFile(this.classesUrl);
-                       }
-                       var classNames = table.className.trim().split(" ");
-                       for (var i = classNames.length; --i >= 0;) {
-                               var classConfiguration = HTMLArea.classesAlternating[classNames[i]];
-                               if (classConfiguration && classConfiguration.rows) {
-                                       if (classConfiguration.rows.oddClass && classConfiguration.rows.evenClass) {
-                                               this.alternateRows(table, classConfiguration);
+                       if (this.classesUrl && (typeof(HTMLArea.classesAlternating) === 'undefined' || typeof(HTMLArea.classesCounting) === 'undefined')) {
+                               this.getJavascriptFile(this.classesUrl, function (options, success, response) {
+                                       if (success) {
+                                               try {
+                                                       if (typeof(HTMLArea.classesAlternating) === 'undefined' || typeof(HTMLArea.classesCounting) === 'undefined') {
+                                                               eval(response.responseText);
+                                                               this.appendToLog('reStyleTable', 'Javascript file successfully evaluated: ' + this.classesUrl);
+                                                       }
+                                                       this.reStyleTable(table);
+                                               } catch(e) {
+                                                       this.appendToLog('reStyleTable', 'Error evaluating contents of Javascript file: ' + this.classesUrl);
+                                               }
                                        }
-                               }
-                               if (classConfiguration && classConfiguration.columns) {
-                                       if (classConfiguration.columns.oddClass && classConfiguration.columns.evenClass) {
-                                               this.alternateColumns(table, classConfiguration);
+                               });
+                       } else {
+                               var classNames = table.className.trim().split(' ');
+                               for (var i = classNames.length; --i >= 0;) {
+                                       var classConfiguration = HTMLArea.classesAlternating[classNames[i]];
+                                       if (classConfiguration && classConfiguration.rows) {
+                                               if (classConfiguration.rows.oddClass && classConfiguration.rows.evenClass) {
+                                                       this.alternateRows(table, classConfiguration);
+                                               }
                                        }
-                               }
-                               classConfiguration = HTMLArea.classesCounting[classNames[i]];
-                               if (classConfiguration && classConfiguration.rows) {
-                                       if (classConfiguration.rows.rowClass) {
-                                               this.countRows(table, classConfiguration);
+                                       if (classConfiguration && classConfiguration.columns) {
+                                               if (classConfiguration.columns.oddClass && classConfiguration.columns.evenClass) {
+                                                       this.alternateColumns(table, classConfiguration);
+                                               }
                                        }
-                               }
-                               if (classConfiguration && classConfiguration.columns) {
-                                       if (classConfiguration.columns.columnClass) {
-                                               this.countColumns(table, classConfiguration);
+                                       classConfiguration = HTMLArea.classesCounting[classNames[i]];
+                                       if (classConfiguration && classConfiguration.rows) {
+                                               if (classConfiguration.rows.rowClass) {
+                                                       this.countRows(table, classConfiguration);
+                                               }
+                                       }
+                                       if (classConfiguration && classConfiguration.columns) {
+                                               if (classConfiguration.columns.columnClass) {
+                                                       this.countColumns(table, classConfiguration);
+                                               }
                                        }
                                }
                        }
@@ -1222,18 +1235,31 @@ TableOperations = HTMLArea.Plugin.extend({
         *
         * @return      void
         */
-       removeAlternatingClasses : function (table, removeClass) {
+       removeAlternatingClasses: function (table, removeClass) {
                if (table) {
-                       if (this.classesUrl && typeof(HTMLArea.classesAlternating) === "undefined") {
-                               this.getJavascriptFile(this.classesUrl);
-                       }
-                       var classConfiguration = HTMLArea.classesAlternating[removeClass];
-                       if (classConfiguration) {
-                               if (classConfiguration.rows && classConfiguration.rows.oddClass && classConfiguration.rows.evenClass) {
-                                       this.alternateRows(table, classConfiguration, true);
-                               }
-                               if (classConfiguration.columns && classConfiguration.columns.oddClass && classConfiguration.columns.evenClass) {
-                                       this.alternateColumns(table, classConfiguration, true);
+                       if (this.classesUrl && typeof(HTMLArea.classesAlternating) === 'undefined') {
+                               this.getJavascriptFile(this.classesUrl, function (options, success, response) {
+                                       if (success) {
+                                               try {
+                                                       if (typeof(HTMLArea.classesAlternating) === 'undefined') {
+                                                               eval(response.responseText);
+                                                               this.appendToLog('removeAlternatingClasses', 'Javascript file successfully evaluated: ' + this.classesUrl);
+                                                       }
+                                                       this.removeAlternatingClasses(table, removeClass);
+                                               } catch(e) {
+                                                       this.appendToLog('removeAlternatingClasses', 'Error evaluating contents of Javascript file: ' + this.classesUrl);
+                                               }
+                                       }
+                               });
+                       } else {
+                               var classConfiguration = HTMLArea.classesAlternating[removeClass];
+                               if (classConfiguration) {
+                                       if (classConfiguration.rows && classConfiguration.rows.oddClass && classConfiguration.rows.evenClass) {
+                                               this.alternateRows(table, classConfiguration, true);
+                                       }
+                                       if (classConfiguration.columns && classConfiguration.columns.oddClass && classConfiguration.columns.evenClass) {
+                                               this.alternateColumns(table, classConfiguration, true);
+                                       }
                                }
                        }
                }
@@ -1321,7 +1347,7 @@ TableOperations = HTMLArea.Plugin.extend({
                                }
                        }
                }
-       },      
+       },
        /*
         * Removes from rows/cells the counting classes of an counting style scheme
         *
@@ -1330,18 +1356,31 @@ TableOperations = HTMLArea.Plugin.extend({
         *
         * @return      void
         */
-       removeCountingClasses : function (table, removeClass) {
+       removeCountingClasses: function (table, removeClass) {
                if (table) {
-                       if (this.classesUrl && typeof(HTMLArea.classesCounting) === "undefined") {
-                               this.getJavascriptFile(this.classesUrl);
-                       }
-                       var classConfiguration = HTMLArea.classesCounting[removeClass];
-                       if (classConfiguration) {
-                               if (classConfiguration.rows && classConfiguration.rows.rowClass) {
-                                       this.countRows(table, classConfiguration, true);
-                               }
-                               if (classConfiguration.columns && classConfiguration.columns.columnClass) {
-                                       this.countColumns(table, classConfiguration, true);
+                       if (this.classesUrl && typeof(HTMLArea.classesCounting) === 'undefined') {
+                               this.getJavascriptFile(this.classesUrl, function (options, success, response) {
+                                       if (success) {
+                                               try {
+                                                       if (typeof(HTMLArea.classesCounting) === 'undefined') {
+                                                               eval(response.responseText);
+                                                               this.appendToLog('removeCountingClasses', 'Javascript file successfully evaluated: ' + this.classesUrl);
+                                                       }
+                                                       this.removeCountingClasses(table, removeClass);
+                                               } catch(e) {
+                                                       this.appendToLog('removeCountingClasses', 'Error evaluating contents of Javascript file: ' + this.classesUrl);
+                                               }
+                                       }
+                               });
+                       } else {
+                               var classConfiguration = HTMLArea.classesCounting[removeClass];
+                               if (classConfiguration) {
+                                       if (classConfiguration.rows && classConfiguration.rows.rowClass) {
+                                               this.countRows(table, classConfiguration, true);
+                                       }
+                                       if (classConfiguration.columns && classConfiguration.columns.columnClass) {
+                                               this.countColumns(table, classConfiguration, true);
+                                       }
                                }
                        }
                }
@@ -1897,19 +1936,26 @@ TableOperations = HTMLArea.Plugin.extend({
                var itemsConfig = [];
                var languageObject = this.getPluginInstance('Language');
                if (this.removedProperties.indexOf('language') == -1 && this.getButton('Language')) {
-                       var languageStore = new Ext.data.ArrayStore({
+                       var selectedLanguage = !Ext.isEmpty(element) ? languageObject.getLanguageAttribute(element) : 'none';
+                       function initLanguageStore (store) {
+                               if (selectedLanguage !== 'none') {
+                                       store.removeAt(0);
+                                       store.insert(0, new store.recordType({
+                                               text: languageObject.localize('Remove language mark'),
+                                               value: 'none'
+                                       }));
+                               }
+                       }
+                       var languageStore = new Ext.data.JsonStore({
                                autoDestroy:  true,
+                               autoLoad: true,
+                               root: 'options',
                                fields: [ { name: 'text'}, { name: 'value'} ],
-                               data: this.getDropDownConfiguration('Language').options
+                               url: this.getDropDownConfiguration('Language').dataUrl,
+                               listeners: {
+                                       load: initLanguageStore
+                               }
                        });
-                       var selectedLanguage = !Ext.isEmpty(element) ? languageObject.getLanguageAttribute(element) : 'none';
-                       if (selectedLanguage !== 'none') {
-                               languageStore.removeAt(0);
-                               languageStore.insert(0, new languageStore.recordType({
-                                       text: languageObject.localize('Remove language mark'),
-                                       value: 'none'
-                               }));
-                       }
                        itemsConfig.push(Ext.apply({
                                xtype: 'combo',
                                fieldLabel: this.localize('Language'),
index 7c001e4..82e6edd 100644 (file)
@@ -234,7 +234,7 @@ TextStyle = HTMLArea.Plugin.extend({
         * This function gets called on plugin generation, on toolbar update and  on change mode
         * Re-initiate the parsing of the style sheets, if not yet completed, and refresh our toolbar components
         */
-       generate : function(editor, dropDownId) {
+       generate: function (editor, dropDownId) {
                if (this.cssLoaded) {
                        this.updateToolbar(dropDownId);
                } else {
@@ -242,10 +242,23 @@ TextStyle = HTMLArea.Plugin.extend({
                                window.clearTimeout(this.cssTimeout);
                                this.cssTimeout = null;
                        }
-                       if (this.classesUrl && (typeof(HTMLArea.classesLabels) === "undefined")) {
-                               this.getJavascriptFile(this.classesUrl);
+                       if (this.classesUrl && (typeof(HTMLArea.classesLabels) === 'undefined')) {
+                               this.getJavascriptFile(this.classesUrl, function (options, success, response) {
+                                       if (success) {
+                                               try {
+                                                       if (typeof(HTMLArea.classesLabels) === 'undefined') {
+                                                               eval(response.responseText);
+                                                               this.appendToLog('generate', 'Javascript file successfully evaluated: ' + this.classesUrl);
+                                                       }
+                                               } catch(e) {
+                                                       this.appendToLog('generate', 'Error evaluating contents of Javascript file: ' + this.classesUrl);
+                                               }
+                                       }
+                                       this.buildCssArray(this.editor, dropDownId);
+                               });
+                       } else {
+                               this.buildCssArray(this.editor, dropDownId);
                        }
-                       this.buildCssArray(editor, dropDownId);
                }
        },
        
index 294ee12..acdb57e 100644 (file)
@@ -486,10 +486,9 @@ class tx_rtehtmlarea_select_image extends browse_links {
                                if (classesImage) var styleSelector=\'<select id="iClass" name="iClass" style="width:140px;">' . $classesImageJSOptions  . '</select>\';
                                var floatSelector=\'<select id="iFloat" name="iFloat"><option value="">' . $LANG->getLL('notSet') . '</option><option value="none">' . $LANG->getLL('nonFloating') . '</option><option value="left">' . $LANG->getLL('left') . '</option><option value="right">' . $LANG->getLL('right') . '</option></select>\';
                                if (plugin.getButton("Language")) {
-                                       var languageOptions = plugin.getDropDownConfiguration("Language").options;
                                        var languageSelector = \'<select id="iLang" name="iLang">\';
-                                       Ext.each(languageOptions, function (option) {
-                                               languageSelector +=\'<option value="\' + option[1] + \'">\' + option[0] + \'</option>\';
+                                       plugin.getButton("Language").getStore().each(function (record) {
+                                               languageSelector +=\'<option value="\' + record.get("value") + \'">\' + record.get("text") + \'</option>\';
                                        });
                                        languageSelector += \'</select>\';
                                }