Ticket #1046: 1046.patch

File 1046.patch, 182.2 KB (added by liucougar, 6 years ago)
  • src/html/selection.js

     
    184184                        } 
    185185                } 
    186186        }, 
     187        getSelectedText: function(){ 
     188                if(dojo.doc().selection){ //IE 
     189                        if(dojo.html.selection.getType() == dojo.html.selectionType.CONTROL){ 
     190                                return null; 
     191                        } 
     192                        return dojo.doc().selection.createRange().text; 
     193                }else{ 
     194                        var selection = dojo.global().getSelection(); 
     195                        if(selection){ 
     196                                return selection.toString();; 
     197                        } 
     198                } 
     199        }, 
    187200        hasAncestorElement: function(tagName /* ... */){ 
    188201                return (dojo.html.selection.getAncestorElement.apply(this, arguments) != null); 
    189202        }, 
     
    268281                        range.select(); 
    269282                } 
    270283        }, 
    271  
    272284        remove: function() { 
    273285                // summary: delete selection 
    274286                if(dojo.doc().selection) { //IE 
  • src/widget/Editor2.js

     
    66dojo.require("dojo.io.*"); 
    77dojo.require("dojo.html.*"); 
    88dojo.require("dojo.html.layout"); 
    9 dojo.require("dojo.html.iframe"); 
    109dojo.require("dojo.widget.*"); 
    1110dojo.require("dojo.widget.RichText"); 
    1211dojo.require("dojo.widget.Editor2Toolbar"); 
     12 
    1313// dojo.require("dojo.widget.ColorPalette"); 
    1414// dojo.require("dojo.string.extras"); 
    1515 
    16 //The current focused Editor2 Instance 
    17 dojo.widget.Editor2._CurrentInstance = null; 
     16//API to manage current focused Editor2 Instance 
     17dojo.widget.Editor2Manager = { 
     18        //private variables 
     19        _currentInstance: null, 
     20        _loadedCommands: {}, 
    1821 
     22        destroy: function(){ 
     23                this._currentInstance = null; 
     24                for(var cmd in this._loadedCommands){ 
     25                        this._loadedCommands[cmd].destory(); 
     26                } 
     27        }, 
     28 
     29        commandState: {Disabled: 0, Latched: 1, Enabled: 2}, 
     30        //Public API 
     31        getCurrentInstance: function(){ 
     32                return this._currentInstance; 
     33        }, 
     34        setCurrentInstance: function(inst){ 
     35                this._currentInstance = inst; 
     36        }, 
     37        registerCommand: function(name, cmd){ 
     38                name = name.toLowerCase(); 
     39                if(this._loadedCommands[name]){ 
     40                        delete this._loadedCommands[name]; 
     41                } 
     42                this._loadedCommands[name] = cmd; 
     43        }, 
     44        getCommand: function(name){ 
     45                name = name.toLowerCase(); 
     46                var oCommand = this._loadedCommands[name]; 
     47                if(oCommand){ 
     48                        return oCommand; 
     49                } 
     50 
     51                switch(name){ 
     52                        case 'htmltoggle': 
     53                                //Editor2 natively provide the htmltoggle functionalitity 
     54                                //and it is treated as a builtin command  
     55                                oCommand = new dojo.widget.Editor2BrowserCommand(name); 
     56                                break; 
     57                        case 'formatblock': 
     58                                oCommand = new dojo.widget.Editor2FormatBlockCommand(name); 
     59                                break; 
     60                        case 'anchor': 
     61                                oCommand = new dojo.widget.Editor2Command(name); 
     62                                break; 
     63 
     64                        //dialog command 
     65                        case 'createlink': 
     66                                oCommand = new dojo.widget.Editor2DialogCommand(name,  
     67                                                {href: dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/createlink.html"),  
     68                                                        title: "Insert/Edit Link", width: "300px", height: "200px"}); 
     69                                break; 
     70                        case 'insertimage': 
     71                                oCommand = new dojo.widget.Editor2DialogCommand(name,  
     72                                                {href: dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/insertimage.html"),  
     73                                                        title: "Insert/Edit Image", width: "400px", height: "270px"}); 
     74                                break; 
     75                        // By default we assume that it is a builtin simple command. 
     76                        default: 
     77                                var curtInst = this.getCurrentInstance(); 
     78                                if((curtInst && curtInst.queryCommandAvailable(name)) || 
     79                                        (!curtInst && dojo.widget.Editor2.prototype.queryCommandAvailable(name))){ 
     80                                        oCommand = new dojo.widget.Editor2BrowserCommand(name); 
     81                                }else{ 
     82                                        dojo.debug("dojo.widget.Editor2Manager.getCommand: Unknown command "+name); 
     83                                        return; 
     84                                } 
     85                } 
     86                this._loadedCommands[name] = oCommand; 
     87                return oCommand; 
     88        }//, 
     89//      registerPerInstancePlugin: function(name){ 
     90//              if(!this._perInstancePlugins){ this._perInstancePlugins = []; } 
     91//              this._perInstancePlugins.push(name); 
     92//      }, 
     93//      getPlugin: function(pluginname, editor){ 
     94//              dojo.require(pluginname); 
     95//              if(dojo.lang.find(this._perInstancePlugins, pluginname) != -1){ 
     96//                      var plugin = dojo.evalObjPath(pluginname); 
     97//                      return new plugin(editor); 
     98//              } 
     99//              return null; 
     100//      } 
     101}; 
     102 
     103dojo.addOnUnload(dojo.widget.Editor2Manager, "destroy"); 
     104 
     105/* base class for all command in Editor2 */ 
     106dojo.lang.declare("dojo.widget.Editor2Command",null,{ 
     107                initializer: function(name){ 
     108                        this._name = name; 
     109                }, 
     110                //this function should be re-implemented in subclass 
     111                execute: function(para){ 
     112                        alert("Please implement your own execute() function for subclass of Editor2Command."); 
     113                }, 
     114                //default implemetation always returns Enabled 
     115                getState: function(){ 
     116                        return dojo.widget.Editor2Manager.commandState.Enabled; 
     117                }, 
     118                destory: function(){} 
     119        } 
     120); 
     121 
     122dojo.lang.declare("dojo.widget.Editor2BrowserCommand", dojo.widget.Editor2Command, { 
     123                execute: function(para){ 
     124                        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     125                        if(curInst){ 
     126                                dojo.debug("execute "+this._name); 
     127                                curInst.execCommand(this._name, para); 
     128                        } 
     129                }, 
     130                getState: function(){ 
     131                        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     132                        if(curInst){ 
     133                                try{ 
     134                                        if(curInst.queryCommandEnabled(this._name)){ 
     135                                                if(curInst.queryCommandState(this._name)){ 
     136                                                        return dojo.widget.Editor2Manager.commandState.Latched; 
     137                                                }else{ 
     138                                                        return dojo.widget.Editor2Manager.commandState.Enabled; 
     139                                                } 
     140                                        }else{ 
     141                                                return dojo.widget.Editor2Manager.commandState.Disabled; 
     142                                        } 
     143                                }catch (e) { 
     144                                        //dojo.debug("exception when getting state for command "+this._name+": "+e); 
     145                                        return dojo.widget.Editor2Manager.commandState.Enabled; 
     146                                } 
     147                        } 
     148                        return dojo.widget.Editor2Manager.commandState.Disabled; 
     149                }, 
     150                getValue: function(){ 
     151                        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     152                        if(curInst){ 
     153                                try{ 
     154                                        return curInst.queryCommandValue(this._name); 
     155                                }catch(e){} 
     156                        } 
     157                } 
     158        } 
     159); 
     160 
     161dojo.lang.declare("dojo.widget.Editor2FormatBlockCommand", dojo.widget.Editor2BrowserCommand, { 
     162                /* In none-ActiveX mode under IE, <p> and no <p> text can not be distinguished 
     163                getCurrentValue: function(){ 
     164                        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     165                        if(!curInst){ return ''; } 
     166 
     167                        var h = dojo.render.html; 
     168                         
     169                        // safari f's us for selection primitives 
     170                        if(h.safari){ return ''; } 
     171 
     172                        var selectedNode = (h.ie) ? curInst.document.selection.createRange().parentElement() : curInst.window.getSelection().anchorNode; 
     173                        // make sure we actuall have an element 
     174                        while((selectedNode)&&(selectedNode.nodeType != 1)){ 
     175                                selectedNode = selectedNode.parentNode; 
     176                        } 
     177                        if(!selectedNode){ return ''; } 
     178 
     179                        var formats = ["p", "pre", "h1", "h2", "h3", "h4", "h5", "h6", "address"]; 
     180                        // gotta run some specialized updates for the various 
     181                        // formatting options 
     182                        var type = formats[dojo.lang.find(formats, selectedNode.nodeName.toLowerCase())]; 
     183                        while((selectedNode!=curInst.editNode)&&(!type)){ 
     184                                selectedNode = selectedNode.parentNode; 
     185                                if(!selectedNode){ break; } 
     186                                type = formats[dojo.lang.find(formats, selectedNode.nodeName.toLowerCase())]; 
     187                        } 
     188                        if(!type){ 
     189                                type = ""; 
     190                        } 
     191                        return type; 
     192                }*/ 
     193        } 
     194); 
     195 
     196dojo.require("dojo.widget.FloatingPane"); 
    19197dojo.widget.defineWidget( 
     198        "dojo.widget.Editor2Dialog", 
     199        [dojo.widget.FloatingPane, dojo.widget.ModalDialogBase], 
     200        { 
     201                modal: true, 
     202                templatePath: dojo.uri.dojoUri("src/widget/templates/Editor2/EditorDialog.html"), 
     203                executeScripts: true, 
     204                refreshOnShow: true, //for debug for now 
     205 
     206                width: false, 
     207                height: false, 
     208 
     209                windowState: "minimized", 
     210                displayCloseAction: true, 
     211 
     212                postCreate: function(){ 
     213                        if(this.modal){ 
     214                                dojo.widget.ModalDialogBase.prototype.postCreate.call(this); 
     215                        }else{ 
     216                                with(this.domNode.style) { 
     217                                        zIndex = 999; 
     218                                        display = "none"; 
     219                                } 
     220//                              dojo.body().appendChild(this.domNode); 
     221                        } 
     222                        dojo.widget.Editor2Dialog.superclass.postCreate.call(this); 
     223                        if(this.width && this.height){ 
     224                                with(this.domNode.style){ 
     225                                        width = this.width; 
     226                                        height = this.height; 
     227                                } 
     228                        } 
     229                }, 
     230                show: function(){ 
     231                        dojo.widget.Editor2Dialog.superclass.show.apply(this, arguments); 
     232                        if(this.modal){ 
     233                                dojo.widget.ModalDialogBase.prototype.show.call(this); 
     234                        } 
     235                        this.placeModalDialog(); 
     236                        if(this.modal){ 
     237                                //place the background div under this modal pane 
     238                                this.shared.bg.style.zIndex = this.domNode.style.zIndex-1; 
     239                        } 
     240                }, 
     241                closeWindow: function(){ 
     242                        this.hide(); 
     243                        dojo.widget.Editor2Dialog.superclass.closeWindow.apply(this, arguments); 
     244                }, 
     245                hide: function(){ 
     246                        if(this.modal){ 
     247                                dojo.widget.ModalDialogBase.prototype.hide.call(this); 
     248                        }else{ 
     249                                dojo.widget.Editor2Dialog.superclass.hide.call(this); 
     250                        } 
     251                } 
     252        } 
     253); 
     254 
     255dojo.lang.declare("dojo.widget.Editor2DialogCommand", dojo.widget.Editor2BrowserCommand,  
     256        function(name, dialogParas){ 
     257                this.dialogParas = dialogParas; 
     258        }, 
     259{ 
     260        execute: function(){ 
     261                if(!this.dialog){ 
     262                        if(!this.dialogParas.href){ 
     263                                alert("Href should be set for dojo.widget.Editor2DialogCommand.dialogParas!"); 
     264                                return; 
     265                        } 
     266                        this.dialog = dojo.widget.createWidget("Editor2Dialog", this.dialogParas); 
     267 
     268                        dojo.body().appendChild(this.dialog.domNode); 
     269 
     270                        dojo.event.connect(this, "destroy", this.dialog, "destroy"); 
     271                } 
     272                this.dialog.show(); 
     273        } 
     274}); 
     275 
     276//uncomment these plugins to enable them 
     277//dojo.require("dojo.widget.Editor2Plugin.FindReplace"); 
     278 
     279//ContextMenu plugin should come before all other plugins which support 
     280//contextmenu, otherwise the menu for that plugin won't be shown 
     281dojo.require("dojo.widget.Editor2Plugin.ContextMenu"); 
     282//dojo.require("dojo.widget.Editor2Plugin.TableOperation"); 
     283//dojo.require("dojo.widget.Editor2Plugin.ToolbarDndSupport"); 
     284 
     285dojo.widget.defineWidget( 
    20286        "dojo.widget.Editor2", 
    21287        dojo.widget.RichText, 
    22288        { 
     
    27293                shareToolbar: false, 
    28294                toolbarAlwaysVisible: false, 
    29295                htmlEditing: false, 
    30                 _inHtmlMode: false, 
     296                _inSourceMode: false, 
    31297                _htmlEditNode: null, 
    32298 
    33                 commandList: dojo.widget.Editor2Toolbar.prototype.commandList, 
    34299                toolbarWidget: null, 
    35300                scrollInterval: null, 
    36                 toolbarTemplatePath: null, 
    37                  
     301//              toolbarTemplatePath: "src/widget/templates/Editor2/EditorToolbarFCKStyle.html", 
     302//              toolbarTemplateCssPath: "src/widget/templates/Editor2/FCKDefault/EditorToolbarFCKStyle.css", 
    38303 
     304                plugins: "", 
     305 
    39306                editorOnLoad: function(){ 
     307                        dojo.profile.start("dojo.widget.Editor2::editorOnLoad"); 
     308 
     309                        dojo.event.topic.publish("dojo.widget.Editor2::preLoadingToolbar", this); 
     310                        if(this.toolbarAlwaysVisible){ 
     311                                dojo.require("dojo.widget.Editor2Plugin.AlwaysShowToolbar"); 
     312                        } 
     313 
    40314                        var toolbars = dojo.widget.byType("Editor2Toolbar"); 
    41315                        if((!toolbars.length)||(!this.shareToolbar)){ 
    42316                                var tbOpts = {}; 
    43317                                this.toolbarTemplatePath = this.toolbarTemplatePath || "src/widget/templates/EditorToolbarOneline.html"; 
    44318                                tbOpts.templatePath = dojo.uri.dojoUri(this.toolbarTemplatePath); 
     319                                if(this.toolbarTemplateCssPath){ 
     320                                        tbOpts.templateCssPath = this.toolbarTemplateCssPath; 
     321                                } 
    45322                                if(this.toolbarWidget){ 
    46323                                        this.toolbarWidget.show(); 
    47324                                }else{ 
     
    49326                                                                                        tbOpts, this.domNode, "before"); 
    50327                                        dojo.event.connect(this, "close", this.toolbarWidget, "hide"); 
    51328                                        dojo.event.connect(this, "destroy", this.toolbarWidget, "destroy"); 
    52                                         this.toolbarWidget.hideUnusableButtons(this); 
    53329                                } 
    54330 
    55                                 if(this.object){ 
    56                                         this.tbBgIframe = new dojo.html.BackgroundIframe(this.toolbarWidget.domNode); 
    57                                         this.tbBgIframe.iframe.style.height = "30px"; 
    58                                 } 
    59  
    60                                 // need to set position fixed to wherever this thing has landed 
    61                                 if(this.toolbarAlwaysVisible){ 
    62                                         var src = document.documentElement||window; 
    63                                         this.scrollInterval = setInterval(dojo.lang.hitch(this, "globalOnScrollHandler"), 100); 
    64                                         // dojo.event.connect(src, "onscroll", this, "globalOnScrollHandler"); 
    65                                         dojo.event.connect("before", this, "destroyRendering", this, "unhookScroller"); 
    66                                 } 
     331                                this.toolbarLoaded(); 
    67332                        }else{ 
    68                                 // FIXME:       should we try harder to explicitly manage focus in 
    69                                 //                      order to prevent too many editors from all querying 
    70                                 //                      for button status concurrently? 
    71333                                // FIXME:       selecting in one shared toolbar doesn't clobber 
    72334                                //                      selection in the others. This is problematic. 
    73335                                this.toolbarWidget = toolbars[0]; 
    74336                        } 
     337 
    75338                        dojo.event.topic.registerPublisher("Editor2.clobberFocus", this, "clobberFocus"); 
    76339                        dojo.event.topic.subscribe("Editor2.clobberFocus", this, "setBlur"); 
    77                         dojo.event.connect(this.toolbarWidget.linkButton, "onclick",  
    78                                 dojo.lang.hitch(this, function(){ 
    79                                         var range; 
    80                                         if(this.document.selection){ 
    81                                                 range = this.document.selection.createRange().text; 
    82                                         }else if(dojo.render.html.mozilla){ 
    83                                                 range = this.window.getSelection().toString(); 
    84                                         } 
    85                                         if(range.length){ 
    86                                                 this.toolbarWidget.exec("createlink",  
    87                                                         prompt("Please enter the URL of the link:", "http://")); 
    88                                         }else{ 
    89                                                 alert("Please select text to link"); 
    90                                         } 
    91                                 }) 
    92                         ); 
    93340 
    94                         dojo.event.connect(this.toolbarWidget, "formatSelectClick", this, "focus"); 
    95                         dojo.event.connect(this.toolbarWidget, "saveClick", this, "save"); 
    96                         dojo.event.connect(this.toolbarWidget, "insertimageClick", this, "insertImage"); 
    97                         dojo.event.connect(this, "execCommand", this, "focus"); 
     341                        dojo.event.topic.publish("dojo.widget.Editor2::onLoad", this); 
     342                        dojo.profile.end("dojo.widget.Editor2::editorOnLoad"); 
     343                }, 
    98344 
    99                         if(this.htmlEditing){ 
    100                                 var tb = this.toolbarWidget.htmltoggleButton; 
    101                                 if(tb){ 
    102                                         tb.style.display = ""; 
    103                                         dojo.event.connect(this.toolbarWidget, "htmltoggleClick", 
    104                                                                                 this, "toggleHtmlEditing"); 
     345                //event for plugins to use 
     346                toolbarLoaded: function(){}, 
     347 
     348                registerLoadedPlugin: function(/*Object*/obj){ 
     349                        if(!this.loadedPlugins){ 
     350                                this.loadedPlugins = []; 
     351                        } 
     352                        this.loadedPlugins.push(obj); 
     353                }, 
     354                unregisterLoadedPlugin: function(/*Object*/obj){ 
     355                        for(var i in this.loadedPlugins){ 
     356                                if(this.loadedPlugins[i] === obj){ 
     357                                        delete this.loadedPlugins[i]; 
     358                                        return; 
    105359                                } 
    106360                        } 
     361                        dojo.debug("dojo.widget.Editor2.unregisterLoadedPlugin: unknow plugin object: "+obj); 
    107362                }, 
     363                //override the default one to provide extra commands 
     364                execCommand: function(command, argument){ 
     365                        switch(command.toLowerCase()){ 
     366                                case 'htmltoggle': 
     367                                        this.toggleHtmlEditing(); 
     368                                        break; 
     369                                default: 
     370                                        dojo.widget.Editor2.superclass.execCommand.call(this, command, argument); 
     371                        } 
     372                }, 
     373                queryCommandEnabled: function(command, argument){ 
     374                        switch(command.toLowerCase()){ 
     375                                case 'htmltoggle': 
     376                                        return true; 
     377                                default: 
     378                                        if(this._inSourceMode){ return false;} 
     379                                        return dojo.widget.Editor2.superclass.queryCommandEnabled.call(this, command, argument); 
     380                        } 
     381                }, 
     382                queryCommandState: function(command, argument){ 
     383                        switch(command.toLowerCase()){ 
     384                                case 'htmltoggle': 
     385                                        return this._inSourceMode; 
     386                                default: 
     387                                        return dojo.widget.Editor2.superclass.queryCommandState.call(this, command, argument); 
     388                        } 
     389                }, 
    108390 
     391                onClick: function(e){ 
     392                        dojo.widget.Editor2.superclass.onClick.call(this, e); 
     393                        //if Popup is used, call dojo.widget.PopupManager.onClick 
     394                        //manually when click in the editing area to close all 
     395                        //open popups (dropdowns)  
     396                        if(dojo.widget.PopupManager){ 
     397                                if(!e){ //IE 
     398                                        e = this.window.event; 
     399                                } 
     400                                dojo.widget.PopupManager.onClick(e); 
     401                        } 
     402                }, 
     403 
    109404                clobberFocus: function(){}, 
    110405                save: function(){ dojo.debug("Editor2.save"); }, 
    111406                insertImage: function(){ dojo.debug("Editor2.insertImage"); }, 
    112407                toggleHtmlEditing: function(){ 
    113                         if(this===dojo.widget.Editor2._CurrentInstance){ 
    114                                 if(!this._inHtmlMode){ 
    115                                         this._inHtmlMode = true; 
    116                                         this.toolbarWidget.highlightButton("htmltoggle"); 
     408                        if(this===dojo.widget.Editor2Manager.getCurrentInstance()){ 
     409                                if(!this._inSourceMode){ 
     410                                        this._inSourceMode = true; 
     411 
    117412                                        if(!this._htmlEditNode){ 
    118                                                 this._htmlEditNode = document.createElement("textarea"); 
     413                                                this._htmlEditNode = dojo.doc().createElement("textarea"); 
    119414                                                dojo.html.insertBefore(this._htmlEditNode, this.domNode); 
    120415                                        } 
    121416                                        this._htmlEditNode.style.display = ""; 
    122417                                        this._htmlEditNode.style.width = "100%"; 
    123418                                        this._htmlEditNode.style.height = dojo.html.getBorderBox(this.editNode).height+"px"; 
    124419                                        this._htmlEditNode.value = this.editNode.innerHTML; 
    125                                         this.domNode.style.display = "none"; 
     420 
     421                                        with(this.domNode.style){ 
     422                                                if(this.object){ 
     423                                                        //activeX object doesn't like to be hidden, so move it outside of screen instead 
     424                                                        position = "absolute"; 
     425                                                        left = "-2000px"; 
     426                                                        top = "-2000px"; 
     427                                                }else{ 
     428                                                        display = "none"; 
     429                                                } 
     430                                        } 
    126431                                }else{ 
    127                                         this._inHtmlMode = false; 
    128                                         this.domNode.style.display = ""; 
    129                                         this.toolbarWidget.unhighlightButton("htmltoggle"); 
     432                                        this._inSourceMode = false; 
     433 
     434                                        //In IE activeX mode, if _htmlEditNode is focused, 
     435                                        //when toggling, an error would occur, so unfocus it 
     436                                        this._htmlEditNode.blur(); 
     437 
     438                                        with(this.domNode.style){ 
     439                                                if(this.object){ 
     440                                                        position = ""; 
     441                                                        left = ""; 
     442                                                        top = ""; 
     443                                                }else{ 
     444                                                        display = ""; 
     445                                                } 
     446                                        } 
     447 
    130448                                        dojo.lang.setTimeout(this, "replaceEditorContent", 1, this._htmlEditNode.value); 
    131449                                        this._htmlEditNode.style.display = "none"; 
    132                                         this.editNode.focus(); 
     450                                        this.focus(); 
    133451                                } 
     452                                this.updateToolbar(true); 
    134453                        } 
    135454                }, 
    136455 
    137456                setFocus: function(){ 
    138                         if(dojo.widget.Editor2._CurrentInstance == this){ return; } 
     457                        dojo.debug("setFocus: start "+this.widgetId); 
     458                        if(dojo.widget.Editor2Manager.getCurrentInstance() === this){ return; } 
    139459 
    140                         if(this.toolbarWidget){ 
    141                                 this.clobberFocus(); 
    142                                 // dojo.debug("setFocus:", this); 
    143                                 dojo.widget.Editor2._CurrentInstance = this; 
    144                                 dojo.event.connect(this.toolbarWidget, "exec", this, "execCommand"); 
    145                         } 
     460                        this.clobberFocus(); 
     461                         dojo.debug("setFocus:", this); 
     462                        dojo.widget.Editor2Manager.setCurrentInstance(this); 
    146463                }, 
    147464 
    148465                setBlur: function(){ 
    149                         // dojo.debug("setBlur:", this); 
    150                         dojo.event.disconnect(this.toolbarWidget, "exec", this, "execCommand"); 
     466                        dojo.debug("setBlur:", this); 
     467                        //dojo.event.disconnect(this.toolbarWidget, "exec", this, "execCommand"); 
    151468                }, 
    152469 
    153                 _scrollSetUp: false, 
    154                 _fixEnabled: false, 
    155                 _scrollThreshold: false, 
    156                 _handleScroll: true, 
    157                 globalOnScrollHandler: function(){ 
    158                         var isIE = dojo.render.html.ie; 
    159                         if(!this._handleScroll){ return; } 
    160                         var dh = dojo.html; 
    161                         var tdn = this.toolbarWidget.domNode; 
    162                         var db = dojo.body(); 
    163                         var totalHeight = dh.getMarginBox(tdn).height; 
    164                         if(!this._scrollSetUp){ 
    165                                 this._scrollSetUp = true; 
    166                                 var editorWidth =  dh.getMarginBox(this.domNode).width;  
    167                                 this._scrollThreshold = dh.abs(tdn, false).y; 
    168                                 // dojo.debug("threshold:", this._scrollThreshold); 
    169                                 if((isIE)&&(db)&&(dh.getStyle(db, "background-image")=="none")){ 
    170                                         with(db.style){ 
    171                                                 backgroundImage = "url(" + dojo.uri.dojoUri("src/widget/templates/images/blank.gif") + ")"; 
    172                                                 backgroundAttachment = "fixed"; 
    173                                         } 
    174                                 } 
    175                         } 
    176  
    177                         var scrollPos = (window["pageYOffset"]) ? window["pageYOffset"] : (document["documentElement"]||document["body"]).scrollTop; 
    178  
    179                         // FIXME: need to have top and bottom thresholds so toolbar doesn't keep scrolling past the bottom 
    180                         if(scrollPos > this._scrollThreshold){ 
    181                                 // dojo.debug(scrollPos); 
    182                                 if(!this._fixEnabled){ 
    183                                         this.domNode.style.marginTop = totalHeight+"px"; 
    184                                         if(isIE){ 
    185                                                 // FIXME: should we just use setBehvior() here instead? 
    186                                                 var cl = dojo.html.abs(tdn).x; 
    187                                                 document.body.appendChild(tdn); 
    188                                                 tdn.style.left = cl+dojo.html.getPixelValue(document.body, "margin-left")+"px"; 
    189                                                 dojo.html.addClass(tdn, "IEFixedToolbar"); 
    190                                                 if(this.object){ 
    191                                                         dojo.html.addClass(this.tbBgIframe, "IEFixedToolbar"); 
    192                                                 } 
    193                                                  
    194                                         }else{ 
    195                                                 with(tdn.style){ 
    196                                                         position = "fixed"; 
    197                                                         top = "0px"; 
    198                                                 } 
    199                                         } 
    200                                         tdn.style.zIndex = 1000; 
    201                                         this._fixEnabled = true; 
    202                                 } 
    203                                 // if we're showing the floating toolbar, make sure that if 
    204                                 // we've scrolled past the bottom of the editor that we hide 
    205                                 // the toolbar for this instance of the editor. 
    206  
    207                                 // TODO: when we get multiple editor toolbar support working 
    208                                 // correctly, ensure that we check this against the scroll 
    209                                 // position of the bottom-most editor instance. 
    210                                 if(!dojo.render.html.safari){ 
    211                                         // safari reports a bunch of things incorrectly here 
    212                                         var eHeight = (this.height) ? parseInt(this.height) : ((this.object) ? dojo.html.getBorderBox(this.editNode).height : this._lastHeight); 
    213                                         if(scrollPos > (this._scrollThreshold+eHeight)){ 
    214                                                 tdn.style.display = "none"; 
    215                                         }else{ 
    216                                                 tdn.style.display = ""; 
    217                                         } 
    218                                 } 
    219  
    220                         }else if(this._fixEnabled){ 
    221                                 this.domNode.style.marginTop = null; 
    222                                 with(tdn.style){ 
    223                                         position = ""; 
    224                                         top = ""; 
    225                                         zIndex = ""; 
    226                                         if(isIE){ 
    227                                                 marginTop = ""; 
    228                                         } 
    229                                 } 
    230                                 if(isIE){ 
    231                                         dojo.html.removeClass(tdn, "IEFixedToolbar"); 
    232                                         dojo.html.insertBefore(tdn, this._htmlEditNode||this.domNode); 
    233                                 } 
    234                                 this._fixEnabled = false; 
    235                         } 
    236                 }, 
    237  
    238                 unhookScroller: function(){ 
    239                         this._handleScroll = false; 
    240                         clearInterval(this.scrollInterval); 
    241                         // var src = document["documentElement"]||window; 
    242                         // dojo.event.disconnect(src, "onscroll", this, "globalOnScrollHandler"); 
    243                         if(dojo.render.html.ie){ 
    244                                 dojo.html.removeClass(this.toolbarWidget.domNode, "IEFixedToolbar"); 
    245                         } 
    246                 }, 
    247  
    248470                _updateToolbarLastRan: null, 
    249471                _updateToolbarTimer: null, 
    250472                _updateToolbarFrequency: 500, 
     
    270492                        } 
    271493                        // end frequency checker 
    272494 
    273                         // FIXME: SEVERE: This forEach block breaks undo on IE 
    274                         dojo.lang.forEach(this.commandList,  
    275                                 function(cmd){ 
    276                                         if((cmd == "inserthtml") || (cmd == "save")){ return; } 
    277                                         try{ 
    278                                                 if(this.queryCommandEnabled(cmd)){ 
    279                                                         if(this.queryCommandState(cmd)){ 
    280                                                                 this.toolbarWidget.highlightButton(cmd); 
    281                                                         }else{ 
    282                                                                 this.toolbarWidget.unhighlightButton(cmd); 
    283                                                         } 
    284                                                 } 
    285                                         }catch(e){ 
    286                                                 // alert(cmd+":"+e); 
    287                                         } 
    288                                 }, 
    289                                 this 
    290                         ); 
     495                        //TODO 
     496                        //if((cmd == "inserthtml") || (cmd == "save")){ return; } 
    291497 
    292                         var h = dojo.render.html; 
    293                          
    294                         // safari f's us for selection primitives 
    295                         if(h.safari){ return; } 
     498                        //IE has the habit of generating events even when this editor is blurred, prevent this 
     499                        if(dojo.widget.Editor2Manager.getCurrentInstance() !== this){ return; } 
    296500 
    297                         var selectedNode = (h.ie) ? this.document.selection.createRange().parentElement() : this.window.getSelection().anchorNode; 
    298                         // make sure we actuall have an element 
    299                         while((selectedNode)&&(selectedNode.nodeType != 1)){ 
    300                                 selectedNode = selectedNode.parentNode; 
    301                         } 
    302                         if(!selectedNode){ return; } 
     501                        this.toolbarWidget.update(); 
     502                }, 
    303503 
    304                         var formats = ["p", "pre", "h1", "h2", "h3", "h4"]; 
    305                         // gotta run some specialized updates for the various 
    306                         // formatting options 
    307                         var type = formats[dojo.lang.find(formats, selectedNode.nodeName.toLowerCase())]; 
    308                         while((selectedNode)&&(selectedNode!=this.editNode)&&(!type)){ 
    309                                 selectedNode = selectedNode.parentNode; 
    310                                 type = formats[dojo.lang.find(formats, selectedNode.nodeName.toLowerCase())]; 
     504                destroy: function(){ 
     505                        //clean all loaded plugins 
     506                        for(var index in this.loadedPlugins){ 
     507                                this.loadedPlugins[index].destroy(); 
     508                                delete this.loadedPlugins[index]; 
    311509                        } 
    312                         if(!type){ 
    313                                 type = ""; 
    314                         }else{ 
    315                                 if(type.charAt(0)=="h"){ 
    316                                         this.toolbarWidget.unhighlightButton("bold"); 
    317                                 } 
    318                         } 
    319                         this.toolbarWidget.selectFormat(type); 
     510                        this._htmlEditNode = null; 
     511                        this.document = null; 
     512                        this.window = null; 
     513                        this.object = null; 
     514                        dojo.widget.Editor2.superclass.destroy.call(this); 
    320515                }, 
    321516 
    322                 updateItem: function(item) { 
    323                         try { 
    324                                 var cmd = item._name; 
    325                                 var enabled = this._richText.queryCommandEnabled(cmd); 
    326                                 item.setEnabled(enabled, false, true); 
     517                onDisplayChanged: function(e){ 
     518                        dojo.widget.Editor2.superclass.onDisplayChanged.call(this,e); 
     519                        this.updateToolbar(); 
     520                }, 
    327521 
    328                                 var active = this._richText.queryCommandState(cmd); 
    329                                 if(active && cmd == "underline") { 
    330                                         // don't activate underlining if we are on a link 
    331                                         active = !this._richText.queryCommandEnabled("unlink"); 
    332                                 } 
    333                                 item.setSelected(active, false, true); 
    334                                 return true; 
    335                         } catch(err) { 
    336                                 return false; 
     522                onLoad: function(){ 
     523                        try{ 
     524                                dojo.widget.Editor2.superclass.onLoad.call(this); 
     525                        }catch(e){ // FIXME: debug why this is throwing errors in IE! 
     526                                dojo.debug(e); 
    337527                        } 
     528                        this.editorOnLoad(); 
    338529                }, 
    339530 
     531                onFocus: function(){ 
     532                        dojo.widget.Editor2.superclass.onFocus.call(this); 
     533                        this.setFocus(); 
     534                }, 
     535 
    340536                _save: function(e){ 
    341537                        // FIXME: how should this behave when there's a larger form in play? 
    342538                        if(!this.isClosed){ 
    343539                                dojo.debug("save attempt"); 
    344540                                if(this.saveUrl.length){ 
    345541                                        var content = {}; 
    346                                         content[this.saveArgName] = this.getHtml(); 
     542                                        content[this.saveArgName] = this.getEditorContent(); 
    347543                                        dojo.io.bind({ 
    348544                                                method: this.saveMethod, 
    349545                                                url: this.saveUrl, 
     
    358554                        } 
    359555                } 
    360556        }, 
    361         "html", 
    362         function(){ 
    363                 var cp = dojo.widget.Editor2.prototype; 
    364                 if(!cp._wrappersSet){ 
    365                         cp._wrappersSet = true; 
    366                  
    367                         cp.onDisplayChanged = (function(odc){ 
    368                                 return function(){ 
    369                                         try{ 
    370                                                 odc.call(this); 
    371                                                 this.updateToolbar(); 
    372                                         }catch(e){} 
    373                                 }; 
    374                         })(cp.onDisplayChanged); 
    375  
    376                         cp.onLoad = (function(ol){ 
    377                                 return function(){ 
    378                                         try{ 
    379                                                 ol.call(this); 
    380                                         }catch(e){ // FIXME: debug why this is throwing errors in IE! 
    381                                                 dojo.debug(e); 
    382                                         } 
    383                                         this.editorOnLoad(); 
    384                                 }; 
    385                         })(cp.onLoad); 
    386                          
    387                         cp.onFocus = (function(of){ 
    388                                 return function(){ 
    389                                         of.call(this); 
    390                                         this.setFocus(); 
    391                                 }; 
    392                         })(cp.onFocus); 
    393                 } 
    394         } 
     557        "html" 
    395558); 
  • src/widget/Editor2Plugin/AlwaysShowToolbar.js

     
     1dojo.provide("dojo.widget.Editor2Plugin.AlwaysShowToolbar"); 
     2 
     3//dojo.widget.Editor2Manager.registerPerInstancePlugin("dojo.widget.Editor2Plugin.AlwaysShowToolbar"); 
     4 
     5dojo.event.topic.subscribe("dojo.widget.Editor2::onLoad", function(editor){ 
     6        if(editor.toolbarAlwaysVisible){ 
     7                var p = new dojo.widget.Editor2Plugin.AlwaysShowToolbar(editor); 
     8        } 
     9}); 
     10dojo.declare("dojo.widget.Editor2Plugin.AlwaysShowToolbar", null, 
     11        function(editor){ 
     12                this.editor = editor; 
     13                this.editor.registerLoadedPlugin(this); 
     14                dojo.event.connect(this.editor, "destroy", this, "destroy"); 
     15                this.setup(); 
     16        }, 
     17        { 
     18        _scrollSetUp: false, 
     19        _fixEnabled: false, 
     20        _scrollThreshold: false, 
     21        _handleScroll: true, 
     22 
     23        setup: function(){ 
     24                var tdn = this.editor.toolbarWidget; 
     25                if(!tdn.tbBgIframe){ 
     26                        tdn.tbBgIframe = new dojo.html.BackgroundIframe(tdn.domNode); 
     27                        tdn.tbBgIframe.onResized(); 
     28                } 
     29                this.scrollInterval = setInterval(dojo.lang.hitch(this, "globalOnScrollHandler"), 100); 
     30        }, 
     31 
     32        globalOnScrollHandler: function(){ 
     33                var isIE = dojo.render.html.ie; 
     34                if(!this._handleScroll){ return; } 
     35                var dh = dojo.html; 
     36                var tdn = this.editor.toolbarWidget.domNode; 
     37                var db = dojo.body(); 
     38                var totalHeight = dh.getMarginBox(tdn).height; 
     39                if(!this._scrollSetUp){ 
     40                        this._scrollSetUp = true; 
     41                        var editorWidth =  dh.getMarginBox(this.editor.domNode).width;  
     42                        this._scrollThreshold = dh.abs(tdn, true).y; 
     43                        // dojo.debug("threshold:", this._scrollThreshold); 
     44                        if((isIE)&&(db)&&(dh.getStyle(db, "background-image")=="none")){ 
     45                                with(db.style){ 
     46                                        backgroundImage = "url(" + dojo.uri.dojoUri("src/widget/templates/images/blank.gif") + ")"; 
     47                                        backgroundAttachment = "fixed"; 
     48                                } 
     49                        } 
     50                } 
     51 
     52                var scrollPos = (window["pageYOffset"]) ? window["pageYOffset"] : (document["documentElement"]||document["body"]).scrollTop; 
     53 
     54                // FIXME: need to have top and bottom thresholds so toolbar doesn't keep scrolling past the bottom 
     55                if(scrollPos > this._scrollThreshold){ 
     56                        // dojo.debug(scrollPos); 
     57                        if(!this._fixEnabled){ 
     58                                this.editor.domNode.style.marginTop = totalHeight+"px"; 
     59                                if(isIE){ 
     60                                        if(!this.editor.toolbarWidget.spaceTaker){ 
     61                                                this.editor.toolbarWidget.spaceTaker = dojo.doc().createElement('div'); 
     62                                                var spaceTaker = this.editor.toolbarWidget.spaceTaker; 
     63                                                var box = dojo.html.getMarginBox(tdn); 
     64                                                with(this.editor.toolbarWidget.spaceTaker.style){ 
     65                                                        width = box.width; 
     66                                                        height = box.height; 
     67                                                } 
     68                                                spaceTaker.style.display = "none"; 
     69                                                dojo.html.insertBefore(spaceTaker, tdn); 
     70                                        } 
     71                                        dojo.body().appendChild(tdn); 
     72 
     73                                        // FIXME: should we just use setBehvior() here instead? 
     74//                                      var cl = dojo.html.abs(tdn).x; 
     75//                                      tdn.style.left = cl+dojo.html.getPixelValue(dojo.body(), "margin-left")+"px"; 
     76                                        dojo.html.addClass(tdn, "IEFixedToolbar"); 
     77//                                      if(this.object){ 
     78//                                              dojo.html.addClass(tdn.tbBgIframe, "IEFixedToolbar"); 
     79//                                      } 
     80                                }else{ 
     81                                        with(tdn.style){ 
     82                                                position = "fixed"; 
     83                                                top = "0px"; 
     84                                        } 
     85                                } 
     86                                tdn.style.zIndex = 1000; 
     87                                this._fixEnabled = true; 
     88                        } 
     89                        // if we're showing the floating toolbar, make sure that if 
     90                        // we've scrolled past the bottom of the editor that we hide 
     91                        // the toolbar for this instance of the editor. 
     92 
     93                        // TODO: when we get multiple editor toolbar support working 
     94                        // correctly, ensure that we check this against the scroll 
     95                        // position of the bottom-most editor instance. 
     96                        if(!dojo.render.html.safari){ 
     97                                // safari reports a bunch of things incorrectly here 
     98                                var eHeight = (this.height) ? parseInt(this.editor.height) : ((this.editor.object) ? dojo.html.getBorderBox(this.editor.editNode).height : this.editor._lastHeight); 
     99                                if(scrollPos > (this._scrollThreshold+eHeight)){ 
     100                                        tdn.style.display = "none"; 
     101                                }else{ 
     102                                        tdn.style.display = ""; 
     103                                } 
     104                        } 
     105                }else if(this._fixEnabled){ 
     106                        this.editor.domNode.style.marginTop = null; 
     107                        with(tdn.style){ 
     108                                position = ""; 
     109                                top = ""; 
     110                                zIndex = ""; 
     111                        } 
     112                        if(isIE){ 
     113                                dojo.html.removeClass(tdn, "IEFixedToolbar"); 
     114                                dojo.html.insertBefore(tdn, this.editor._htmlEditNode||this.editor.domNode); 
     115                        } 
     116                        this._fixEnabled = false; 
     117                } 
     118        }, 
     119 
     120        destroy: function(){ 
     121                this._handleScroll = false; 
     122                clearInterval(this.scrollInterval); 
     123                this.editor.unregisterLoadedPlugin(this); 
     124                // var src = document["documentElement"]||window; 
     125                // dojo.event.disconnect(src, "onscroll", this, "globalOnScrollHandler"); 
     126                if(dojo.render.html.ie){ 
     127                        dojo.html.removeClass(this.editor.toolbarWidget.domNode, "IEFixedToolbar"); 
     128                } 
     129        } 
     130}); 
     131 No newline at end of file 
  • src/widget/Editor2Plugin/ToolbarDndSupport.js

    Property changes on: src\widget\Editor2Plugin\AlwaysShowToolbar.js
    ___________________________________________________________________
    Name: svn:eol-style
       + native
    
     
     1/*TODO: 
     2 * Add a command to toggle DnD support for a toolbar 
     3 * Save/restore order of toolbar/item 
     4 */ 
     5dojo.provide("dojo.widget.Editor2Plugin.ToolbarDndSupport"); 
     6dojo.require("dojo.dnd.*"); 
     7 
     8dojo.event.topic.subscribe("dojo.widget.Editor2::preLoadingToolbar", function(editor){ 
     9        dojo.dnd.dragManager.nestedTargets = true; 
     10        var p = new dojo.widget.Editor2Plugin.ToolbarDndSupport(editor); 
     11}); 
     12 
     13dojo.declare("dojo.widget.Editor2Plugin.ToolbarDndSupport", null,{ 
     14        lookForClass: "dojoEditorToolbarDnd TB_ToolbarSet TB_Toolbar", 
     15        initializer: function(editor){ 
     16                this.editor = editor; 
     17                dojo.event.connect(this.editor, "toolbarLoaded", this, "setup"); 
     18                dojo.event.connect(this.editor, "destroy", this, "destroy"); 
     19                this.editor.registerLoadedPlugin(this); 
     20        }, 
     21 
     22        setup: function(){ 
     23                dojo.event.disconnect(this.editor, "toolbarLoaded", this, "setup"); 
     24                var tbw = this.editor.toolbarWidget; 
     25 
     26                var nodes = dojo.html.getElementsByClass(this.lookForClass, tbw.domNode, null, dojo.html.classMatchType.ContainsAny); 
     27                if(!nodes){ 
     28                        dojo.debug("dojo.widget.Editor2Plugin.ToolbarDndSupport: No dom node with class in "+this.lookForClass); 
     29                        return; 
     30                } 
     31                for(var i=0; i<nodes.length; i++){ 
     32                        var node = nodes[i]; 
     33                        var droptarget = node.getAttribute("dojoETDropTarget"); 
     34                        if(droptarget){ 
     35                                (new dojo.dnd.HtmlDropTarget(node, [droptarget+tbw.widgetId])).vertical = true; 
     36                        } 
     37                        var dragsource = node.getAttribute("dojoETDragSource"); 
     38                        if(dragsource){ 
     39                                new dojo.dnd.HtmlDragSource(node, dragsource+tbw.widgetId); 
     40                        } 
     41                } 
     42        }, 
     43 
     44        destroy: function(){ 
     45                this.editor.unregisterLoadedPlugin(this); 
     46        } 
     47}); 
     48 
     49//let's have a command to enable DnD 
     50/*dojo.declare("dojo.widget.Editor2Plugin.ToolbarDndCommand", dojo.widget.Editor2Command,{ 
     51        execute: function(text, option){ 
     52                var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     53                if(curInst){ 
     54                } 
     55        }, 
     56        getState: function(){    
     57        } 
     58});*/ 
     59 No newline at end of file 
  • src/widget/Editor2Plugin/__package__.js

    Property changes on: src\widget\Editor2Plugin\ToolbarDndSupport.js
    ___________________________________________________________________
    Name: svn:eol-style
       + native
    
     
     1dojo.kwCompoundRequire({ 
     2        common: [ "dojo.widget.Editor2",  
     3                         "dojo.widget.Editor2Toolbar"] 
     4}); 
     5dojo.provide("dojo.widget.Editor2Plugin.*"); 
  • src/widget/Editor2Plugin/TableOperation.js

    Property changes on: src\widget\Editor2Plugin\__package__.js
    ___________________________________________________________________
    Name: svn:eol-style
       + native
    
     
     1dojo.provide("dojo.widget.Editor2Plugin.TableOperation"); 
     2 
     3//subscribe to dojo.widget.RichText::init, not onLoad because after onLoad 
     4//the stylesheets for the editing areas are already applied and the prefilters 
     5//are executed, so we have to insert our own trick before that point  
     6dojo.event.topic.subscribe("dojo.widget.RichText::init", function(editor){ 
     7        if(dojo.render.html.moz){ 
     8                //include the css file to show table border when border=0 
     9                editor.editingAreaStyleSheets.push(dojo.uri.dojoUri("src/widget/templates/Editor2/showtableborder_gecko.css")); 
     10        }else if(dojo.render.html.ie){ 
     11                //add/remove a class to a table with border=0 to show the border when loading/saving 
     12                editor.contentDomPreFilters.push(dojo.widget.Editor2Plugin.TableOperation.showIETableBorder); 
     13                editor.contentDomPostFilters.push(dojo.widget.Editor2Plugin.TableOperation.removeIEFakeClass); 
     14                //include the css file to show table border when border=0 
     15                editor.editingAreaStyleSheets.push(dojo.uri.dojoUri("src/widget/templates/Editor2/showtableborder_ie.css")); 
     16        } 
     17}); 
     18 
     19dojo.widget.Editor2Plugin.TableOperation = { 
     20        getToolbarItem: function(name){ 
     21                var name = name.toLowerCase(); 
     22         
     23                var item; 
     24                if(name == 'inserttable'){ 
     25                        item = new dojo.widget.Editor2ToolbarButton(name); 
     26                } 
     27         
     28                return item; 
     29        }, 
     30        getContextMenuGroup: function(name, contextmenuplugin){ 
     31                return new dojo.widget.Editor2Plugin.TableContextMenu(contextmenuplugin); 
     32        }, 
     33        deleteTableCommand: { 
     34                execute: function(){ 
     35                        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     36                        var table = dojo.withGlobal(curInst.window, "getAncestorElement", dojo.html.selection, ['table']); 
     37                        if(table){ 
     38                                dojo.withGlobal(curInst.window, "selectElement", dojo.html.selection, [table]); 
     39                                curInst.execCommand("inserthtml", " "); //Moz does not like an empty string, so a space here instead 
     40                        } 
     41                }, 
     42                //default implemetation always returns Enabled 
     43                getState: function(){ 
     44                        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     45                        var table = dojo.withGlobal(curInst.window, "hasAncestorElement", dojo.html.selection, ['table']); 
     46                        return table ? dojo.widget.Editor2Manager.commandState.Enabled : dojo.widget.Editor2Manager.commandState.Disabled; 
     47                }, 
     48                destory: function(){} 
     49        }, 
     50        showIETableBorder: function(dom){ 
     51                var tables = dom.getElementsByTagName('table'); 
     52                dojo.lang.forEach(tables, function(t){ 
     53                        dojo.html.addClass(t, "dojoShowIETableBorders"); 
     54                }); 
     55                return dom; 
     56        }, 
     57        removeIEFakeClass: function(dom){ 
     58                var tables = dom.getElementsByTagName('table'); 
     59                dojo.lang.forEach(tables, function(t){ 
     60                        dojo.html.removeClass(t, "dojoShowIETableBorders"); 
     61                }); 
     62                return dom; 
     63        } 
     64} 
     65 
     66//register commands: inserttable, deletetable 
     67dojo.widget.Editor2Manager.registerCommand("inserttable", new dojo.widget.Editor2DialogCommand('inserttable',  
     68                {href: dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/inserttable.html"),  
     69                                title: "Insert/Edit Table", width: "400px", height: "270px"})); 
     70dojo.widget.Editor2Manager.registerCommand("deletetable", dojo.widget.Editor2Plugin.TableOperation.deleteTableCommand); 
     71 
     72//register inserttable as toolbar item 
     73dojo.widget.Editor2ToolbarItemManager.registerHandler(dojo.widget.Editor2Plugin.TableOperation.getToolbarItem); 
     74 
     75//add context menu support if dojo.widget.Editor2Plugin.ContextMenu is included before this plugin 
     76if(dojo.widget.Editor2Plugin.ContextMenuManager){ 
     77        dojo.widget.Editor2Plugin.ContextMenuManager.registerGroup('Table', dojo.widget.Editor2Plugin.TableOperation.getContextMenuGroup); 
     78 
     79        dojo.declare("dojo.widget.Editor2Plugin.TableContextMenu",  
     80                dojo.widget.Editor2Plugin.SimpleContextMenu, 
     81        { 
     82                createItems: function(){ 
     83                        this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Delete Table", command: 'deletetable'})); 
     84                        this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Table Property", command: 'inserttable', iconClass: "TB_Button_Icon TB_Button_Table"})); 
     85                }, 
     86                checkVisibility: function(){ 
     87                        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     88                        var table = dojo.withGlobal(curInst.window, "hasAncestorElement", dojo.html.selection, ['table']); 
     89         
     90                        if(dojo.withGlobal(curInst.window, "hasAncestorElement", dojo.html.selection, ['table'])){ 
     91                                this.items[0].show(); 
     92                                this.items[1].show(); 
     93                                return true; 
     94                        }else{ 
     95                                this.items[0].hide(); 
     96                                this.items[1].hide(); 
     97                                return false; 
     98                        } 
     99                } 
     100        }); 
     101} 
     102 No newline at end of file 
  • src/widget/Editor2Plugin/ContextMenu.js

    Property changes on: src\widget\Editor2Plugin\TableOperation.js
    ___________________________________________________________________
    Name: svn:eol-style
       + native
    
     
     1dojo.provide("dojo.widget.Editor2Plugin.ContextMenu"); 
     2 
     3dojo.event.topic.subscribe("dojo.widget.Editor2::onLoad", function(editor){ 
     4//      if(editor.useContextMenu){ 
     5//alert("dojo.widget.Editor2::editorOnLoad"); 
     6                var p = new dojo.widget.Editor2Plugin.ContextMenu(editor); 
     7//      } 
     8}); 
     9dojo.widget.Editor2Plugin.ContextMenuManager = { 
     10        menuGroups: ['Generic', 'Link', 'Anchor', 'Image', 'List', 'Table'], 
     11        _registeredGroups: {}, 
     12        registerGroup: function(name, handler){ 
     13                if(this._registeredGroups[name]){ 
     14                        alert("dojo.widget.Editor2Plugin.ContextMenuManager.registerGroup: menu group "+name+"is already registered. Ignored."); 
     15                        return; 
     16                } 
     17                this._registeredGroups[name] = handler; 
     18        }, 
     19        removeGroup: function(name){ 
     20                delete this._registeredGroups[name]; 
     21        }, 
     22        getGroup: function(name, contextmenuplugin){ 
     23                if(this._registeredGroups[name]){ 
     24                        var item = this._registeredGroups[name](name, contextmenuplugin); 
     25                        if(item){ 
     26                                return item; 
     27                        } 
     28                } 
     29                switch(name){ 
     30                        case 'Generic': 
     31                        case 'Link': 
     32                        case 'Image': 
     33                                return new dojo.widget.Editor2Plugin[name+"ContextMenu"](contextmenuplugin); 
     34                        //TODO 
     35                        case 'Anchor': 
     36                        case 'List': 
     37                } 
     38        } 
     39}; 
     40 
     41dojo.declare("dojo.widget.Editor2Plugin.ContextMenu", null, 
     42        function(editor){ 
     43                this.groups = []; 
     44                this.separators = []; 
     45                this.editor = editor; 
     46                this.editor.registerLoadedPlugin(this); 
     47                this.contextMenu = dojo.widget.createWidget("PopupMenu2", {}); 
     48                dojo.body().appendChild(this.contextMenu.domNode); 
     49                this.contextMenu.bindDomNode(this.editor.document.body); 
     50 
     51                dojo.event.connect(this.contextMenu, "aboutToShow", this, "aboutToShow"); 
     52                dojo.event.connect(this.editor, "destroy", this, "destroy"); 
     53 
     54                this.setup(); 
     55        }, 
     56        { 
     57        setup: function(){ 
     58                var gs = dojo.widget.Editor2Plugin.ContextMenuManager.menuGroups; 
     59                for(i in gs){ 
     60                        var g = dojo.widget.Editor2Plugin.ContextMenuManager.getGroup(gs[i], this); 
     61                        if(g){ 
     62                                this.groups.push(g); 
     63                        } 
     64                } 
     65        }, 
     66        aboutToShow: function(){ 
     67                var first = true; 
     68                for(var i in this.groups){ 
     69                        if(i>0 && this.separators.length != this.groups.length-1){ 
     70                                this.separators.push(dojo.widget.createWidget("MenuSeparator2", {})); 
     71                                this.contextMenu.addChild(this.separators[this.separators.length-1]); 
     72                        } 
     73                        if(this.groups[i].refresh()){ 
     74                                if(i>0){ 
     75                                        if(first){ 
     76                                                this.separators[i-1].hide(); 
     77                                        }else{ 
     78                                                this.separators[i-1].show(); 
     79                                        } 
     80                                } 
     81                                if(first){ first = false; } 
     82                        }else{ 
     83                                if(i>0){ 
     84                                        this.separators[i-1].hide(); 
     85                                } 
     86                        } 
     87                } 
     88        }, 
     89        destroy: function(){ 
     90                this.editor.unregisterLoadedPlugin(this); 
     91                delete this.groups; 
     92                delete this.separators; 
     93                this.contextMenu.destroy(); 
     94                delete this.contextMenu; 
     95        } 
     96}); 
     97 
     98dojo.widget.defineWidget( 
     99        "dojo.widget.Editor2ContextMenuItem", 
     100        dojo.widget.MenuItem2, { 
     101        command: null, 
     102        postCreate: function(){ 
     103                if(!this.command){ 
     104                        this.command = this.caption; 
     105                } 
     106 
     107                dojo.widget.Editor2ContextMenuItem.superclass.postCreate.apply(this, arguments); 
     108        }, 
     109        setup: function(){ 
     110                this.cmd = dojo.widget.Editor2Manager.getCommand(this.command); 
     111                if(!this.cmd){ 
     112                        alert("command " + this.command + " is not recognized!"); 
     113                } 
     114        }, 
     115        onClick: function(){ 
     116                if(!this.cmd){ 
     117                        this.setup(); 
     118                } 
     119                if(this.cmd){ 
     120                        this.cmd.execute(); 
     121                } 
     122        }, 
     123        refresh: function(){ 
     124                if(!this.cmd){ 
     125                        this.setup(); 
     126                } 
     127                if(this.cmd){ 
     128                        if(this.cmd.getState() == dojo.widget.Editor2Manager.commandState.Disabled){ 
     129                                this.disable(); 
     130                                return false; 
     131                        }else{ 
     132                                this.enable(); 
     133                                return true; 
     134                        } 
     135                } 
     136        }, 
     137        //improve performance by skipping animation 
     138        hide: function(){ 
     139                this.domNode.style.display = "none"; 
     140        }, 
     141        show: function(){ 
     142                this.domNode.style.display = ""; 
     143        } 
     144}); 
     145dojo.declare("dojo.widget.Editor2Plugin.SimpleContextMenu", null, 
     146        function(contextmenuplugin){ 
     147                this.contextMenu = contextmenuplugin.contextMenu; 
     148                this.items = []; 
     149 
     150                dojo.event.connect(contextmenuplugin, "destroy", this, "destroy"); 
     151        }, 
     152        { 
     153        refresh: function(){ 
     154                if(!this.items.length){ 
     155                        this.createItems(); 
     156                        for(var i in this.items){ 
     157                                this.contextMenu.addChild(this.items[i]); 
     158                        } 
     159                } 
     160 
     161                return this.checkVisibility(); 
     162        }, 
     163        destroy: function(){ 
     164                this.contextmenu = null; 
     165                delete this.items; 
     166                delete this.contextMenu; 
     167        }, 
     168        //implement this to fill in the menu items 
     169        createItems: function(){        }, 
     170 
     171        //overload this to show/hide items 
     172        checkVisibility: function(){ 
     173                var show = false; 
     174                for(var i in this.items){ 
     175                        show = show || this.items[i].refresh(); 
     176                } 
     177                var action = show ? "show" : "hide"; 
     178                for(var i in this.items){ 
     179                        this.items[i][action](); 
     180                } 
     181                return show; 
     182        } 
     183}); 
     184dojo.declare("dojo.widget.Editor2Plugin.GenericContextMenu",  
     185        dojo.widget.Editor2Plugin.SimpleContextMenu, 
     186{ 
     187        createItems: function(){ 
     188                this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Cut", iconClass: "dojoE2TBIcon dojoE2TBIcon_Cut"})); 
     189                this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Copy", iconClass: "dojoE2TBIcon dojoE2TBIcon_Copy"})); 
     190                this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Paste", iconClass: "dojoE2TBIcon dojoE2TBIcon_Paste"})); 
     191        } 
     192}); 
     193dojo.declare("dojo.widget.Editor2Plugin.LinkContextMenu",  
     194        dojo.widget.Editor2Plugin.SimpleContextMenu, 
     195{ 
     196        createItems: function(){ 
     197                this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Modify Link", command: 'createlink', iconClass: "dojoE2TBIcon dojoE2TBIcon_Link"})); 
     198                this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Remove Link", command: 'unlink', iconClass: "dojoE2TBIcon dojoE2TBIcon_UnLink"})); 
     199        }, 
     200        checkVisibility: function(){ 
     201                var show = this.items[1].refresh(); 
     202                if(show){ 
     203                        this.items[0].refresh(); 
     204                        for(var i in this.items){ 
     205                                this.items[i].show(); 
     206                        } 
     207                }else{ 
     208                        for(var i in this.items){ 
     209                                this.items[i].hide(); 
     210                        } 
     211                } 
     212 
     213                return show; 
     214        } 
     215}); 
     216dojo.declare("dojo.widget.Editor2Plugin.ImageContextMenu",  
     217        dojo.widget.Editor2Plugin.SimpleContextMenu, 
     218{ 
     219        createItems: function(){ 
     220                this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Edit Image", command: 'insertimage', iconClass: "dojoE2TBIcon dojoE2TBIcon_Image"})); 
     221        }, 
     222        checkVisibility: function(){ 
     223                var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     224                var img = dojo.withGlobal(curInst.window, "getSelectedElement", dojo.html.selection); 
     225 
     226                if(img && img.tagName.toLowerCase() == 'img'){ 
     227                        this.items[0].show(); 
     228                        return true; 
     229                }else{ 
     230                        this.items[0].hide(); 
     231                        return false; 
     232                } 
     233        } 
     234}); 
  • src/widget/Editor2Plugin/FindReplace.js

    Property changes on: src\widget\Editor2Plugin\ContextMenu.js
    ___________________________________________________________________
    Name: svn:eol-style
       + native
    
     
     1dojo.provide("dojo.widget.Editor2Plugin.FindReplace"); 
     2 
     3//TODO replace, better GUI 
     4 
     5dojo.declare("dojo.widget.Editor2Plugin.FindCommand", dojo.widget.Editor2DialogCommand,{ 
     6        SearchOption: { 
     7                CaseSensitive: 4, 
     8                SearchBackwards: 64, 
     9                WholeWord: 2, 
     10                WrapSearch: 128 
     11        }, 
     12        find: function(text, option){ 
     13                var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     14                if(curInst){ 
     15                        curInst.focus(); 
     16                        if(window.find){ //moz 
     17                                curInst.window.find(text,  
     18                                        option & this.SearchOption.CaseSensitive ? true : false, 
     19                                        option & this.SearchOption.SearchBackwards ? true : false, 
     20                                        option & this.SearchOption.WrapSearch ? true : false, 
     21                                        option & this.SearchOption.WholeWord ? true : false 
     22                                        ); 
     23                        }else if(dojo.body().createTextRange){ //IE 
     24                                var range = curInst.document.body.createTextRange(); 
     25                                var found = range.findText(text, (option&this.SearchOption.SearchBackwards)?1:-1, option ); 
     26                                if(found){ 
     27                                        range.scrollIntoView() ; 
     28                                        range.select() ; 
     29                                }else{ 
     30                                        alert("Can not find "+text+" in the document"); 
     31                                } 
     32                        }else{ 
     33                                alert("No idea how to search in this browser. Please submit patch if you know."); 
     34                        } 
     35                } 
     36        } 
     37}); 
     38 
     39dojo.widget.Editor2Manager.registerCommand("Find", new dojo.widget.Editor2Plugin.FindCommand('find',  
     40                {href: dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/find.html"),  
     41                        title: "Find", width: "350px", height: "150px", modal: false})); 
     42dojo.widget.Editor2Manager.registerCommand("Replace", new dojo.widget.Editor2DialogCommand('replace',  
     43                {href: dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/replace.html"),  
     44                        title: "Replace", width: "350px", height: "200px", modal: false})); 
     45 
     46dojo.widget.Editor2Plugin.FindReplace = function(name){ 
     47        var name = name.toLowerCase(); 
     48 
     49        var item; 
     50        if(name == 'replace'){ 
     51                item = new dojo.widget.Editor2ToolbarButton('Replace'); 
     52        }else if(name == 'find') { 
     53                item = new dojo.widget.Editor2ToolbarButton('Find'); 
     54        } 
     55 
     56        return item; 
     57} 
     58 
     59dojo.widget.Editor2ToolbarItemManager.registerHandler(dojo.widget.Editor2Plugin.FindReplace); 
     60 No newline at end of file 
  • src/widget/Editor2Plugin/__package__.js

    Property changes on: src\widget\Editor2Plugin\FindReplace.js
    ___________________________________________________________________
    Name: svn:eol-style
       + native
    
     
     1dojo.kwCompoundRequire({ 
     2        common: [ "dojo.widget.Editor2",  
     3                         "dojo.widget.Editor2Toolbar"] 
     4}); 
     5dojo.provide("dojo.widget.Editor2Plugin.*"); 
  • src/widget/Editor2Plugin/AlwaysShowToolbar.js

    Property changes on: src\widget\Editor2Plugin\__package__.js
    ___________________________________________________________________
    Name: svn:eol-style
       + native
    
     
     1dojo.provide("dojo.widget.Editor2Plugin.AlwaysShowToolbar"); 
     2 
     3//dojo.widget.Editor2Manager.registerPerInstancePlugin("dojo.widget.Editor2Plugin.AlwaysShowToolbar"); 
     4 
     5dojo.event.topic.subscribe("dojo.widget.Editor2::onLoad", function(editor){ 
     6        if(editor.toolbarAlwaysVisible){ 
     7                var p = new dojo.widget.Editor2Plugin.AlwaysShowToolbar(editor); 
     8        } 
     9}); 
     10dojo.declare("dojo.widget.Editor2Plugin.AlwaysShowToolbar", null, 
     11        function(editor){ 
     12                this.editor = editor; 
     13                this.editor.registerLoadedPlugin(this); 
     14                dojo.event.connect(this.editor, "destroy", this, "destroy"); 
     15                this.setup(); 
     16        }, 
     17        { 
     18        _scrollSetUp: false, 
     19        _fixEnabled: false, 
     20        _scrollThreshold: false, 
     21        _handleScroll: true, 
     22 
     23        setup: function(){ 
     24                var tdn = this.editor.toolbarWidget; 
     25                if(!tdn.tbBgIframe){ 
     26                        tdn.tbBgIframe = new dojo.html.BackgroundIframe(tdn.domNode); 
     27                        tdn.tbBgIframe.onResized(); 
     28                } 
     29                this.scrollInterval = setInterval(dojo.lang.hitch(this, "globalOnScrollHandler"), 100); 
     30        }, 
     31 
     32        globalOnScrollHandler: function(){ 
     33                var isIE = dojo.render.html.ie; 
     34                if(!this._handleScroll){ return; } 
     35                var dh = dojo.html; 
     36                var tdn = this.editor.toolbarWidget.domNode; 
     37                var db = dojo.body(); 
     38                var totalHeight = dh.getMarginBox(tdn).height; 
     39                if(!this._scrollSetUp){ 
     40                        this._scrollSetUp = true; 
     41                        var editorWidth =  dh.getMarginBox(this.editor.domNode).width;  
     42                        this._scrollThreshold = dh.abs(tdn, true).y; 
     43                        // dojo.debug("threshold:", this._scrollThreshold); 
     44                        if((isIE)&&(db)&&(dh.getStyle(db, "background-image")=="none")){ 
     45                                with(db.style){ 
     46                                        backgroundImage = "url(" + dojo.uri.dojoUri("src/widget/templates/images/blank.gif") + ")"; 
     47                                        backgroundAttachment = "fixed"; 
     48                                } 
     49                        } 
     50                } 
     51 
     52                var scrollPos = (window["pageYOffset"]) ? window["pageYOffset"] : (document["documentElement"]||document["body"]).scrollTop; 
     53 
     54                // FIXME: need to have top and bottom thresholds so toolbar doesn't keep scrolling past the bottom 
     55                if(scrollPos > this._scrollThreshold){ 
     56                        // dojo.debug(scrollPos); 
     57                        if(!this._fixEnabled){ 
     58                                this.editor.domNode.style.marginTop = totalHeight+"px"; 
     59                                if(isIE){ 
     60                                        if(!this.editor.toolbarWidget.spaceTaker){ 
     61                                                this.editor.toolbarWidget.spaceTaker = dojo.doc().createElement('div'); 
     62                                                var spaceTaker = this.editor.toolbarWidget.spaceTaker; 
     63                                                var box = dojo.html.getMarginBox(tdn); 
     64                                                with(this.editor.toolbarWidget.spaceTaker.style){ 
     65                                                        width = box.width; 
     66                                                        height = box.height; 
     67                                                } 
     68                                                spaceTaker.style.display = "none"; 
     69                                                dojo.html.insertBefore(spaceTaker, tdn); 
     70                                        } 
     71                                        dojo.body().appendChild(tdn); 
     72 
     73                                        // FIXME: should we just use setBehvior() here instead? 
     74//                                      var cl = dojo.html.abs(tdn).x; 
     75//                                      tdn.style.left = cl+dojo.html.getPixelValue(dojo.body(), "margin-left")+"px"; 
     76                                        dojo.html.addClass(tdn, "IEFixedToolbar"); 
     77//                                      if(this.object){ 
     78//                                              dojo.html.addClass(tdn.tbBgIframe, "IEFixedToolbar"); 
     79//                                      } 
     80                                }else{ 
     81                                        with(tdn.style){ 
     82                                                position = "fixed"; 
     83                                                top = "0px"; 
     84                                        } 
     85                                } 
     86                                tdn.style.zIndex = 1000; 
     87                                this._fixEnabled = true; 
     88                        } 
     89                        // if we're showing the floating toolbar, make sure that if 
     90                        // we've scrolled past the bottom of the editor that we hide 
     91                        // the toolbar for this instance of the editor. 
     92 
     93                        // TODO: when we get multiple editor toolbar support working 
     94                        // correctly, ensure that we check this against the scroll 
     95                        // position of the bottom-most editor instance. 
     96                        if(!dojo.render.html.safari){ 
     97                                // safari reports a bunch of things incorrectly here 
     98                                var eHeight = (this.height) ? parseInt(this.editor.height) : ((this.editor.object) ? dojo.html.getBorderBox(this.editor.editNode).height : this.editor._lastHeight); 
     99                                if(scrollPos > (this._scrollThreshold+eHeight)){ 
     100                                        tdn.style.display = "none"; 
     101                                }else{ 
     102                                        tdn.style.display = ""; 
     103                                } 
     104                        } 
     105                }else if(this._fixEnabled){ 
     106                        this.editor.domNode.style.marginTop = null; 
     107                        with(tdn.style){ 
     108                                position = ""; 
     109                                top = ""; 
     110                                zIndex = ""; 
     111                        } 
     112                        if(isIE){ 
     113                                dojo.html.removeClass(tdn, "IEFixedToolbar"); 
     114                                dojo.html.insertBefore(tdn, this.editor._htmlEditNode||this.editor.domNode); 
     115                        } 
     116                        this._fixEnabled = false; 
     117                } 
     118        }, 
     119 
     120        destroy: function(){ 
     121                this._handleScroll = false; 
     122                clearInterval(this.scrollInterval); 
     123                this.editor.unregisterLoadedPlugin(this); 
     124                // var src = document["documentElement"]||window; 
     125                // dojo.event.disconnect(src, "onscroll", this, "globalOnScrollHandler"); 
     126                if(dojo.render.html.ie){ 
     127                        dojo.html.removeClass(this.editor.toolbarWidget.domNode, "IEFixedToolbar"); 
     128                } 
     129        } 
     130}); 
     131 No newline at end of file 
  • src/widget/Editor2Plugin/ContextMenu.js

    Property changes on: src\widget\Editor2Plugin\AlwaysShowToolbar.js
    ___________________________________________________________________
    Name: svn:eol-style
       + native
    
     
     1dojo.provide("dojo.widget.Editor2Plugin.ContextMenu"); 
     2 
     3dojo.event.topic.subscribe("dojo.widget.Editor2::onLoad", function(editor){ 
     4//      if(editor.useContextMenu){ 
     5//alert("dojo.widget.Editor2::editorOnLoad"); 
     6                var p = new dojo.widget.Editor2Plugin.ContextMenu(editor); 
     7//      } 
     8}); 
     9dojo.widget.Editor2Plugin.ContextMenuManager = { 
     10        menuGroups: ['Generic', 'Link', 'Anchor', 'Image', 'List', 'Table'], 
     11        _registeredGroups: {}, 
     12        registerGroup: function(name, handler){ 
     13                if(this._registeredGroups[name]){ 
     14                        alert("dojo.widget.Editor2Plugin.ContextMenuManager.registerGroup: menu group "+name+"is already registered. Ignored."); 
     15                        return; 
     16                } 
     17                this._registeredGroups[name] = handler; 
     18        }, 
     19        removeGroup: function(name){ 
     20                delete this._registeredGroups[name]; 
     21        }, 
     22        getGroup: function(name, contextmenuplugin){ 
     23                if(this._registeredGroups[name]){ 
     24                        var item = this._registeredGroups[name](name, contextmenuplugin); 
     25                        if(item){ 
     26                                return item; 
     27                        } 
     28                } 
     29                switch(name){ 
     30                        case 'Generic': 
     31                        case 'Link': 
     32                        case 'Image': 
     33                                return new dojo.widget.Editor2Plugin[name+"ContextMenu"](contextmenuplugin); 
     34                        //TODO 
     35                        case 'Anchor': 
     36                        case 'List': 
     37                } 
     38        } 
     39}; 
     40 
     41dojo.declare("dojo.widget.Editor2Plugin.ContextMenu", null, 
     42        function(editor){ 
     43                this.groups = []; 
     44                this.separators = []; 
     45                this.editor = editor; 
     46                this.editor.registerLoadedPlugin(this); 
     47                this.contextMenu = dojo.widget.createWidget("PopupMenu2", {}); 
     48                dojo.body().appendChild(this.contextMenu.domNode); 
     49                this.contextMenu.bindDomNode(this.editor.document.body); 
     50 
     51                dojo.event.connect(this.contextMenu, "aboutToShow", this, "aboutToShow"); 
     52                dojo.event.connect(this.editor, "destroy", this, "destroy"); 
     53 
     54                this.setup(); 
     55        }, 
     56        { 
     57        setup: function(){ 
     58                var gs = dojo.widget.Editor2Plugin.ContextMenuManager.menuGroups; 
     59                for(i in gs){ 
     60                        var g = dojo.widget.Editor2Plugin.ContextMenuManager.getGroup(gs[i], this); 
     61                        if(g){ 
     62                                this.groups.push(g); 
     63                        } 
     64                } 
     65        }, 
     66        aboutToShow: function(){ 
     67                var first = true; 
     68                for(var i in this.groups){ 
     69                        if(i>0 && this.separators.length != this.groups.length-1){ 
     70                                this.separators.push(dojo.widget.createWidget("MenuSeparator2", {})); 
     71                                this.contextMenu.addChild(this.separators[this.separators.length-1]); 
     72                        } 
     73                        if(this.groups[i].refresh()){ 
     74                                if(i>0){ 
     75                                        if(first){ 
     76                                                this.separators[i-1].hide(); 
     77                                        }else{ 
     78                                                this.separators[i-1].show(); 
     79                                        } 
     80                                } 
     81                                if(first){ first = false; } 
     82                        }else{ 
     83                                if(i>0){ 
     84                                        this.separators[i-1].hide(); 
     85                                } 
     86                        } 
     87                } 
     88        }, 
     89        destroy: function(){ 
     90                this.editor.unregisterLoadedPlugin(this); 
     91                delete this.groups; 
     92                delete this.separators; 
     93                this.contextMenu.destroy(); 
     94                delete this.contextMenu; 
     95        } 
     96}); 
     97 
     98dojo.widget.defineWidget( 
     99        "dojo.widget.Editor2ContextMenuItem", 
     100        dojo.widget.MenuItem2, { 
     101        command: null, 
     102        postCreate: function(){ 
     103                if(!this.command){ 
     104                        this.command = this.caption; 
     105                } 
     106 
     107                dojo.widget.Editor2ContextMenuItem.superclass.postCreate.apply(this, arguments); 
     108        }, 
     109        setup: function(){ 
     110                this.cmd = dojo.widget.Editor2Manager.getCommand(this.command); 
     111                if(!this.cmd){ 
     112                        alert("command " + this.command + " is not recognized!"); 
     113                } 
     114        }, 
     115        onClick: function(){ 
     116                if(!this.cmd){ 
     117                        this.setup(); 
     118                } 
     119                if(this.cmd){ 
     120                        this.cmd.execute(); 
     121                } 
     122        }, 
     123        refresh: function(){ 
     124                if(!this.cmd){ 
     125                        this.setup(); 
     126                } 
     127                if(this.cmd){ 
     128                        if(this.cmd.getState() == dojo.widget.Editor2Manager.commandState.Disabled){ 
     129                                this.disable(); 
     130                                return false; 
     131                        }else{ 
     132                                this.enable(); 
     133                                return true; 
     134                        } 
     135                } 
     136        }, 
     137        //improve performance by skipping animation 
     138        hide: function(){ 
     139                this.domNode.style.display = "none"; 
     140        }, 
     141        show: function(){ 
     142                this.domNode.style.display = ""; 
     143        } 
     144}); 
     145dojo.declare("dojo.widget.Editor2Plugin.SimpleContextMenu", null, 
     146        function(contextmenuplugin){ 
     147                this.contextMenu = contextmenuplugin.contextMenu; 
     148                this.items = []; 
     149 
     150                dojo.event.connect(contextmenuplugin, "destroy", this, "destroy"); 
     151        }, 
     152        { 
     153        refresh: function(){ 
     154                if(!this.items.length){ 
     155                        this.createItems(); 
     156                        for(var i in this.items){ 
     157                                this.contextMenu.addChild(this.items[i]); 
     158                        } 
     159                } 
     160 
     161                return this.checkVisibility(); 
     162        }, 
     163        destroy: function(){ 
     164                this.contextmenu = null; 
     165                delete this.items; 
     166                delete this.contextMenu; 
     167        }, 
     168        //implement this to fill in the menu items 
     169        createItems: function(){        }, 
     170 
     171        //overload this to show/hide items 
     172        checkVisibility: function(){ 
     173                var show = false; 
     174                for(var i in this.items){ 
     175                        show = show || this.items[i].refresh(); 
     176                } 
     177                var action = show ? "show" : "hide"; 
     178                for(var i in this.items){ 
     179                        this.items[i][action](); 
     180                } 
     181                return show; 
     182        } 
     183}); 
     184dojo.declare("dojo.widget.Editor2Plugin.GenericContextMenu",  
     185        dojo.widget.Editor2Plugin.SimpleContextMenu, 
     186{ 
     187        createItems: function(){ 
     188                this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Cut", iconClass: "dojoE2TBIcon dojoE2TBIcon_Cut"})); 
     189                this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Copy", iconClass: "dojoE2TBIcon dojoE2TBIcon_Copy"})); 
     190                this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Paste", iconClass: "dojoE2TBIcon dojoE2TBIcon_Paste"})); 
     191        } 
     192}); 
     193dojo.declare("dojo.widget.Editor2Plugin.LinkContextMenu",  
     194        dojo.widget.Editor2Plugin.SimpleContextMenu, 
     195{ 
     196        createItems: function(){ 
     197                this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Modify Link", command: 'createlink', iconClass: "dojoE2TBIcon dojoE2TBIcon_Link"})); 
     198                this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Remove Link", command: 'unlink', iconClass: "dojoE2TBIcon dojoE2TBIcon_UnLink"})); 
     199        }, 
     200        checkVisibility: function(){ 
     201                var show = this.items[1].refresh(); 
     202                if(show){ 
     203                        this.items[0].refresh(); 
     204                        for(var i in this.items){ 
     205                                this.items[i].show(); 
     206                        } 
     207                }else{ 
     208                        for(var i in this.items){ 
     209                                this.items[i].hide(); 
     210                        } 
     211                } 
     212 
     213                return show; 
     214        } 
     215}); 
     216dojo.declare("dojo.widget.Editor2Plugin.ImageContextMenu",  
     217        dojo.widget.Editor2Plugin.SimpleContextMenu, 
     218{ 
     219        createItems: function(){ 
     220                this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Edit Image", command: 'insertimage', iconClass: "dojoE2TBIcon dojoE2TBIcon_Image"})); 
     221        }, 
     222        checkVisibility: function(){ 
     223                var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     224                var img = dojo.withGlobal(curInst.window, "getSelectedElement", dojo.html.selection); 
     225 
     226                if(img && img.tagName.toLowerCase() == 'img'){ 
     227                        this.items[0].show(); 
     228                        return true; 
     229                }else{ 
     230                        this.items[0].hide(); 
     231                        return false; 
     232                } 
     233        } 
     234}); 
  • src/widget/Editor2Plugin/FindReplace.js

    Property changes on: src\widget\Editor2Plugin\ContextMenu.js
    ___________________________________________________________________
    Name: svn:eol-style
       + native
    
     
     1dojo.provide("dojo.widget.Editor2Plugin.FindReplace"); 
     2 
     3//TODO replace, better GUI 
     4 
     5dojo.declare("dojo.widget.Editor2Plugin.FindCommand", dojo.widget.Editor2DialogCommand,{ 
     6        SearchOption: { 
     7                CaseSensitive: 4, 
     8                SearchBackwards: 64, 
     9                WholeWord: 2, 
     10                WrapSearch: 128 
     11        }, 
     12        find: function(text, option){ 
     13                var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     14                if(curInst){ 
     15                        curInst.focus(); 
     16                        if(window.find){ //moz 
     17                                curInst.window.find(text,  
     18                                        option & this.SearchOption.CaseSensitive ? true : false, 
     19                                        option & this.SearchOption.SearchBackwards ? true : false, 
     20                                        option & this.SearchOption.WrapSearch ? true : false, 
     21                                        option & this.SearchOption.WholeWord ? true : false 
     22                                        ); 
     23                        }else if(dojo.body().createTextRange){ //IE 
     24                                var range = curInst.document.body.createTextRange(); 
     25                                var found = range.findText(text, (option&this.SearchOption.SearchBackwards)?1:-1, option ); 
     26                                if(found){ 
     27                                        range.scrollIntoView() ; 
     28                                        range.select() ; 
     29                                }else{ 
     30                                        alert("Can not find "+text+" in the document"); 
     31                                } 
     32                        }else{ 
     33                                alert("No idea how to search in this browser. Please submit patch if you know."); 
     34                        } 
     35                } 
     36        } 
     37}); 
     38 
     39dojo.widget.Editor2Manager.registerCommand("Find", new dojo.widget.Editor2Plugin.FindCommand('find',  
     40                {href: dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/find.html"),  
     41                        title: "Find", width: "350px", height: "150px", modal: false})); 
     42dojo.widget.Editor2Manager.registerCommand("Replace", new dojo.widget.Editor2DialogCommand('replace',  
     43                {href: dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/replace.html"),  
     44                        title: "Replace", width: "350px", height: "200px", modal: false})); 
     45 
     46dojo.widget.Editor2Plugin.FindReplace = function(name){ 
     47        var name = name.toLowerCase(); 
     48 
     49        var item; 
     50        if(name == 'replace'){ 
     51                item = new dojo.widget.Editor2ToolbarButton('Replace'); 
     52        }else if(name == 'find') { 
     53                item = new dojo.widget.Editor2ToolbarButton('Find'); 
     54        } 
     55 
     56        return item; 
     57} 
     58 
     59dojo.widget.Editor2ToolbarItemManager.registerHandler(dojo.widget.Editor2Plugin.FindReplace); 
     60 No newline at end of file 
  • src/widget/Editor2Plugin/TableOperation.js

    Property changes on: src\widget\Editor2Plugin\FindReplace.js
    ___________________________________________________________________
    Name: svn:eol-style
       + native
    
     
     1dojo.provide("dojo.widget.Editor2Plugin.TableOperation"); 
     2 
     3//subscribe to dojo.widget.RichText::init, not onLoad because after onLoad 
     4//the stylesheets for the editing areas are already applied and the prefilters 
     5//are executed, so we have to insert our own trick before that point  
     6dojo.event.topic.subscribe("dojo.widget.RichText::init", function(editor){ 
     7        if(dojo.render.html.moz){ 
     8                //include the css file to show table border when border=0 
     9                editor.editingAreaStyleSheets.push(dojo.uri.dojoUri("src/widget/templates/Editor2/showtableborder_gecko.css")); 
     10        }else if(dojo.render.html.ie){ 
     11                //add/remove a class to a table with border=0 to show the border when loading/saving 
     12                editor.contentDomPreFilters.push(dojo.widget.Editor2Plugin.TableOperation.showIETableBorder); 
     13                editor.contentDomPostFilters.push(dojo.widget.Editor2Plugin.TableOperation.removeIEFakeClass); 
     14                //include the css file to show table border when border=0 
     15                editor.editingAreaStyleSheets.push(dojo.uri.dojoUri("src/widget/templates/Editor2/showtableborder_ie.css")); 
     16        } 
     17}); 
     18 
     19dojo.widget.Editor2Plugin.TableOperation = { 
     20        getToolbarItem: function(name){ 
     21                var name = name.toLowerCase(); 
     22         
     23                var item; 
     24                if(name == 'inserttable'){ 
     25                        item = new dojo.widget.Editor2ToolbarButton(name); 
     26                } 
     27         
     28                return item; 
     29        }, 
     30        getContextMenuGroup: function(name, contextmenuplugin){ 
     31                return new dojo.widget.Editor2Plugin.TableContextMenu(contextmenuplugin); 
     32        }, 
     33        deleteTableCommand: { 
     34                execute: function(){ 
     35                        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     36                        var table = dojo.withGlobal(curInst.window, "getAncestorElement", dojo.html.selection, ['table']); 
     37                        if(table){ 
     38                                dojo.withGlobal(curInst.window, "selectElement", dojo.html.selection, [table]); 
     39                                curInst.execCommand("inserthtml", " "); //Moz does not like an empty string, so a space here instead 
     40                        } 
     41                }, 
     42                //default implemetation always returns Enabled 
     43                getState: function(){ 
     44                        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     45                        var table = dojo.withGlobal(curInst.window, "hasAncestorElement", dojo.html.selection, ['table']); 
     46                        return table ? dojo.widget.Editor2Manager.commandState.Enabled : dojo.widget.Editor2Manager.commandState.Disabled; 
     47                }, 
     48                destory: function(){} 
     49        }, 
     50        showIETableBorder: function(dom){ 
     51                var tables = dom.getElementsByTagName('table'); 
     52                dojo.lang.forEach(tables, function(t){ 
     53                        dojo.html.addClass(t, "dojoShowIETableBorders"); 
     54                }); 
     55                return dom; 
     56        }, 
     57        removeIEFakeClass: function(dom){ 
     58                var tables = dom.getElementsByTagName('table'); 
     59                dojo.lang.forEach(tables, function(t){ 
     60                        dojo.html.removeClass(t, "dojoShowIETableBorders"); 
     61                }); 
     62                return dom; 
     63        } 
     64} 
     65 
     66//register commands: inserttable, deletetable 
     67dojo.widget.Editor2Manager.registerCommand("inserttable", new dojo.widget.Editor2DialogCommand('inserttable',  
     68                {href: dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/inserttable.html"),  
     69                                title: "Insert/Edit Table", width: "400px", height: "270px"})); 
     70dojo.widget.Editor2Manager.registerCommand("deletetable", dojo.widget.Editor2Plugin.TableOperation.deleteTableCommand); 
     71 
     72//register inserttable as toolbar item 
     73dojo.widget.Editor2ToolbarItemManager.registerHandler(dojo.widget.Editor2Plugin.TableOperation.getToolbarItem); 
     74 
     75//add context menu support if dojo.widget.Editor2Plugin.ContextMenu is included before this plugin 
     76if(dojo.widget.Editor2Plugin.ContextMenuManager){ 
     77        dojo.widget.Editor2Plugin.ContextMenuManager.registerGroup('Table', dojo.widget.Editor2Plugin.TableOperation.getContextMenuGroup); 
     78 
     79        dojo.declare("dojo.widget.Editor2Plugin.TableContextMenu",  
     80                dojo.widget.Editor2Plugin.SimpleContextMenu, 
     81        { 
     82                createItems: function(){ 
     83                        this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Delete Table", command: 'deletetable'})); 
     84                        this.items.push(dojo.widget.createWidget("Editor2ContextMenuItem", {caption: "Table Property", command: 'inserttable', iconClass: "TB_Button_Icon TB_Button_Table"})); 
     85                }, 
     86                checkVisibility: function(){ 
     87                        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     88                        var table = dojo.withGlobal(curInst.window, "hasAncestorElement", dojo.html.selection, ['table']); 
     89         
     90                        if(dojo.withGlobal(curInst.window, "hasAncestorElement", dojo.html.selection, ['table'])){ 
     91                                this.items[0].show(); 
     92                                this.items[1].show(); 
     93                                return true; 
     94                        }else{ 
     95                                this.items[0].hide(); 
     96                                this.items[1].hide(); 
     97                                return false; 
     98                        } 
     99                } 
     100        }); 
     101} 
     102 No newline at end of file 
  • src/widget/Editor2Plugin/ToolbarDndSupport.js

    Property changes on: src\widget\Editor2Plugin\TableOperation.js
    ___________________________________________________________________
    Name: svn:eol-style
       + native
    
     
     1/*TODO: 
     2 * Add a command to toggle DnD support for a toolbar 
     3 * Save/restore order of toolbar/item 
     4 */ 
     5dojo.provide("dojo.widget.Editor2Plugin.ToolbarDndSupport"); 
     6dojo.require("dojo.dnd.*"); 
     7 
     8dojo.event.topic.subscribe("dojo.widget.Editor2::preLoadingToolbar", function(editor){ 
     9        dojo.dnd.dragManager.nestedTargets = true; 
     10        var p = new dojo.widget.Editor2Plugin.ToolbarDndSupport(editor); 
     11}); 
     12 
     13dojo.declare("dojo.widget.Editor2Plugin.ToolbarDndSupport", null,{ 
     14        lookForClass: "dojoEditorToolbarDnd TB_ToolbarSet TB_Toolbar", 
     15        initializer: function(editor){ 
     16                this.editor = editor; 
     17                dojo.event.connect(this.editor, "toolbarLoaded", this, "setup"); 
     18                dojo.event.connect(this.editor, "destroy", this, "destroy"); 
     19                this.editor.registerLoadedPlugin(this); 
     20        }, 
     21 
     22        setup: function(){ 
     23                dojo.event.disconnect(this.editor, "toolbarLoaded", this, "setup"); 
     24                var tbw = this.editor.toolbarWidget; 
     25 
     26                var nodes = dojo.html.getElementsByClass(this.lookForClass, tbw.domNode, null, dojo.html.classMatchType.ContainsAny); 
     27                if(!nodes){ 
     28                        dojo.debug("dojo.widget.Editor2Plugin.ToolbarDndSupport: No dom node with class in "+this.lookForClass); 
     29                        return; 
     30                } 
     31                for(var i=0; i<nodes.length; i++){ 
     32                        var node = nodes[i]; 
     33                        var droptarget = node.getAttribute("dojoETDropTarget"); 
     34                        if(droptarget){ 
     35                                (new dojo.dnd.HtmlDropTarget(node, [droptarget+tbw.widgetId])).vertical = true; 
     36                        } 
     37                        var dragsource = node.getAttribute("dojoETDragSource"); 
     38                        if(dragsource){ 
     39                                new dojo.dnd.HtmlDragSource(node, dragsource+tbw.widgetId); 
     40                        } 
     41                } 
     42        }, 
     43 
     44        destroy: function(){ 
     45                this.editor.unregisterLoadedPlugin(this); 
     46        } 
     47}); 
     48 
     49//let's have a command to enable DnD 
     50/*dojo.declare("dojo.widget.Editor2Plugin.ToolbarDndCommand", dojo.widget.Editor2Command,{ 
     51        execute: function(text, option){ 
     52                var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     53                if(curInst){ 
     54                } 
     55        }, 
     56        getState: function(){    
     57        } 
     58});*/ 
     59 No newline at end of file 
  • src/widget/Editor2Toolbar.js

    Property changes on: src\widget\Editor2Plugin\ToolbarDndSupport.js
    ___________________________________________________________________
    Name: svn:eol-style
       + native
    
     
    66dojo.require("dojo.html.layout"); 
    77dojo.require("dojo.html.display"); 
    88dojo.require("dojo.widget.RichText"); 
     9dojo.require("dojo.widget.Menu2"); 
    910dojo.require("dojo.widget.ColorPalette"); 
    1011 
    11 dojo.widget.defineWidget( 
    12         "dojo.widget.Editor2Toolbar", 
    13         dojo.widget.HtmlWidget, 
    14         { 
    15                 commandList: [ "bold", "italic", "underline", "subscript", "superscript", 
    16                         "fontname", "fontsize", "forecolor", "hilitecolor", "justifycenter", 
    17                         "justifyfull", "justifyleft", "justifyright", "cut", "copy", "paste", 
    18                         "delete", "undo", "redo", "createlink", "unlink", "removeformat", 
    19                         "inserthorizontalrule", "insertimage", "insertorderedlist", 
    20                         "insertunorderedlist", "indent", "outdent", "formatblock", "strikethrough",  
    21                         "inserthtml", "blockdirltr", "blockdirrtl", "dirltr", "dirrtl", 
    22                         "inlinedirltr", "inlinedirrtl", "inserttable", "insertcell", 
    23                         "insertcol", "insertrow", "deletecells", "deletecols", "deleterows", 
    24                         "mergecells", "splitcell" 
    25                 ], 
     12dojo.widget.Editor2ToolbarItemManager = { 
     13        _registeredItemHandlers: [], 
     14        registerHandler: function(obj, func){ 
     15                if(arguments.length == 1){ 
     16//                      for(i in this._registeredItemHandlers){ 
     17//                              if(func === this._registeredItemHandlers[i]){ 
     18//                                      dojo.debug("Editor2ToolbarItemManager handler "+func+" is already registered, ignored"); 
     19//                                      return; 
     20//                              } 
     21//                      } 
     22                        this._registeredItemHandlers.push(obj); 
     23                }else{ 
     24                        this._registeredItemHandlers.push(function(){return obj[func].apply(obj, arguments);}); 
     25                } 
     26        }, 
     27        removeHandler: function(func){ 
     28                for(i in this._registeredItemHandlers){ 
     29                        if(func === this._registeredItemHandlers[i]){ 
     30                                delete this._registeredItemHandlers[i]; 
     31                                return; 
     32                        } 
     33                } 
     34                dojo.debug("Editor2ToolbarItemManager handler "+func+" is not registered, can not remove."); 
     35        }, 
     36        destroy: function(){ 
     37                for(var i in this._registeredItemHandlers){ 
     38                        delete this._registeredItemHandlers[i]; 
     39                } 
     40        }, 
     41        getToolbarItem: function(name){ 
     42                var item; 
     43                name = name.toLowerCase(); 
     44                for(i in this._registeredItemHandlers){ 
     45                        item = this._registeredItemHandlers[i](name); 
     46                        if(item){ 
     47                                break; 
     48                        } 
     49                } 
    2650 
    27                 templatePath: dojo.uri.dojoUri("src/widget/templates/EditorToolbarOneline.html"), 
    28                 // templatePath: dojo.uri.dojoUri("src/widget/templates/EditorToolbar.html"), 
    29                 templateCssPath: dojo.uri.dojoUri("src/widget/templates/EditorToolbar.css"), 
     51                if(!item){ 
     52                        switch(name){ 
     53                                //button for builtin functions 
     54                                case 'bold': 
     55                                case 'copy': 
     56                                case 'cut': 
     57                                case 'delete': 
     58                                case 'indent': 
     59                                case 'inserthorizontalrule': 
     60                                case 'insertorderedlist': 
     61                                case 'insertunorderedlist': 
     62                                case 'italic': 
     63                                case 'justifycenter': 
     64                                case 'justifyfull': 
     65                                case 'justifyleft':  
     66                                case 'justifyright': 
     67                                case 'outdent': 
     68                                case 'paste': 
     69                                case 'redo': 
     70                                case 'removeformat': 
     71                                case 'selectall': 
     72                                case 'strikethrough': 
     73                                case 'subscript': 
     74                                case 'superscript': 
     75                                case 'underline': 
     76                                case 'undo':  
     77                                case 'unlink': 
     78                                case 'createlink': 
     79                                case 'insertimage': 
     80                                //extra simple buttons 
     81                                case 'htmltoggle': 
     82                                        item = new dojo.widget.Editor2ToolbarButton(name); 
     83                                        break; 
     84                                case 'forecolor':  
     85                                case 'hilitecolor': 
     86                                        item = new dojo.widget.Editor2ToolbarColorPaletteButton(name); 
     87                                        break; 
     88                                case 'plainformatblock': 
     89                                        item = new dojo.widget.Editor2ToolbarFormatBlockPlainSelect("formatblock"); 
     90                                        break; 
     91                                case 'formatblock': 
     92                                        item = new dojo.widget.Editor2ToolbarFormatBlockSelect("formatblock"); 
     93                                        break; 
     94                                case 'fontsize': 
     95                                        item = new dojo.widget.Editor2ToolbarFontSizeSelect("fontsize"); 
     96                                        break; 
     97                                case 'fontname': 
     98                                        item = new dojo.widget.Editor2ToolbarFontNameSelect("fontname"); 
     99                                        break; 
     100                                case 'inserttable': 
     101                                case 'insertcell': 
     102                                case 'insertcol': 
     103                                case 'insertrow': 
     104                                case 'deletecells': 
     105                                case 'deletecols': 
     106                                case 'deleterows': 
     107                                case 'mergecells': 
     108                                case 'splitcell': 
     109                                        dojo.debug(name + " is implemented in dojo.widget.Editor2Plugin.TableOperation, please require it first."); 
     110                                        break; 
     111                                //TODO: 
     112                                case 'inserthtml': 
     113                                case 'blockdirltr': 
     114                                case 'blockdirrtl': 
     115                                case 'dirltr': 
     116                                case 'dirrtl': 
     117                                case 'inlinedirltr': 
     118                                case 'inlinedirrtl': 
     119                                        dojo.debug("Not yet implemented toolbar item: "+name); 
     120                                        break; 
     121                                default: 
     122                                        dojo.debug("dojo.widget.Editor2ToolbarItemManager.getToolbarItem: Unknown toolbar item: "+name); 
     123                        } 
     124                } 
     125                return item; 
     126        } 
     127}; 
    30128 
    31                 forecolorPalette: null, 
    32                 hilitecolorPalette: null, 
     129dojo.addOnUnload(dojo.widget.Editor2ToolbarItemManager, "destroy"); 
    33130 
    34                 // DOM Nodes 
    35                 wikiwordButton: null, 
    36                 htmltoggleButton: null, 
    37                 insertimageButton: null, 
    38                 styleDropdownButton: null, 
    39                 styleDropdownContainer: null, 
    40                 copyButton: null, 
    41                 boldButton: null, 
    42                 italicButton: null, 
    43                 underlineButton: null, 
    44                 justifycenterButton: null, 
    45                 justifyleftButton: null, 
    46                 justifyfullButton: null, 
    47                 justifyrightButton: null, 
    48                 pasteButton: null, 
    49                 undoButton: null, 
    50                 redoButton: null, 
    51                 linkButton: null, 
    52                 insertunorderedlistButton: null, 
    53                 insertorderedlistButton: null, 
    54                 forecolorButton: null, 
    55                 forecolorDropDown: null, 
    56                 hilitecolorButton: null, 
    57                 hilitecolorDropDown: null, 
    58                 formatSelectBox: null, 
    59                 inserthorizontalruleButton: null, 
    60                 strikethroughButton: null, 
    61                 clickInterceptDiv: null, 
    62                 oneLineTr: null, 
    63                 saveButton: null, 
     131dojo.declare("dojo.widget.Editor2ToolbarButton", null,{ 
     132        initializer: function(name){ 
     133                this._name = name; 
     134                this._command = dojo.widget.Editor2Manager.getCommand(name); 
     135        }, 
     136        create: function(node, toolbar, isMenu){ 
     137                this._domNode = node; 
     138                //make this unselectable: different browsers 
     139                //use different properties for this, so use 
     140                //js do it automatically 
     141                this.disableSelection(this._domNode); 
     142                this._parentToolbar = toolbar; 
     143                dojo.event.connect(this._domNode, 'onclick', this, 'onClick'); 
     144                if(!isMenu){ 
     145                        dojo.event.connect(this._domNode, 'onmouseover', this, 'onMouseOver'); 
     146                        dojo.event.connect(this._domNode, 'onmouseout', this, 'onMouseOut'); 
     147                } 
     148        }, 
     149        disableSelection: function(rootnode){ 
     150                dojo.html.disableSelection(rootnode); 
     151                var nodes = rootnode.all || rootnode.getElementsByTagName("*"); 
     152                for(var x=0; x<nodes.length; x++){ 
     153                        dojo.html.disableSelection(nodes[x]); 
     154                } 
     155        }, 
     156        onMouseOver: function(){ 
     157                if(this._command.getState() != dojo.widget.Editor2Manager.commandState.Disabled){ 
     158                        this.highlightToolbarItem(); 
     159                } 
     160        }, 
     161        onMouseOut: function(){ 
     162                this.unhighlightToolbarItem(); 
     163        }, 
     164        destroy: function(){ 
     165//              dojo.event.disconnect(this._domNode, 'onclick', this, 'onClick'); 
     166//              dojo.event.disconnect(this._domNode, 'onmouseover', this, 'onMouseOver'); 
     167//              dojo.event.disconnect(this._domNode, 'onmouseout', this, 'onMouseOut'); 
     168                this._domNode = null; 
     169                delete this._command; 
     170                this._parentToolbar = null; 
     171        }, 
     172        onClick: function(e){ 
     173                if(this._domNode && !this._domNode.disabled && this._command){ 
     174                        e.preventDefault(); 
     175                        e.stopPropagation(); 
     176                        this._command.execute(); 
     177                } 
     178        }, 
     179        refreshState: function(){ 
     180                if(this._domNode && this._command){ 
     181                        var em = dojo.widget.Editor2Manager; 
     182                        var state = this._command.getState(); 
     183                        if(state != this._lastState){ 
     184                                switch(state){ 
     185                                        case em.commandState.Latched: 
     186                                                this.latchToolbarItem(); 
     187                                                break; 
     188                                        case em.commandState.Enabled: 
     189                                                this.enableToolbarItem(); 
     190                                                break; 
     191                                        case em.commandState.Disabled: 
     192                                        default: 
     193                                                this.disableToolbarItem(); 
     194                                } 
     195                                this._lastState = state; 
     196                        } 
     197                        return state; 
     198                } 
     199        }, 
    64200 
    65                 buttonClick: function(e){ e.preventDefault(); /* dojo.debug("buttonClick"); */ }, 
     201        latchToolbarItem: function(){ 
     202                this._domNode.disabled = false; 
     203                this.removeToolbarItemStyle(this._domNode); 
     204                dojo.html.addClass(this._domNode, this._parentToolbar.ToolbarLatchedItemStyle); 
     205        }, 
    66206 
    67                 buttonMouseOver: function(e){  }, 
    68                 buttonMouseOut: function(e){  }, 
     207        enableToolbarItem: function(){ 
     208                this._domNode.disabled = false; 
     209                this.removeToolbarItemStyle(this._domNode); 
     210                dojo.html.addClass(this._domNode, this._parentToolbar.ToolbarEnabledItemStyle); 
     211        }, 
    69212 
     213        disableToolbarItem: function(){ 
     214                this._domNode.disabled = true; 
     215                this.removeToolbarItemStyle(this._domNode); 
     216                dojo.html.addClass(this._domNode, this._parentToolbar.ToolbarDisabledItemStyle); 
     217        }, 
    70218 
    71                 // event signals 
    72                 preventSelect: function(e){ if(dojo.render.html.safari){ e.preventDefault(); } }, 
    73                 wikiwordClick: function(){ }, 
    74                 insertimageClick: function(){ }, 
    75                 htmltoggleClick: function(){ }, 
    76                 saveClick: function(){ }, 
     219        highlightToolbarItem: function(){ 
     220                dojo.html.addClass(this._domNode, this._parentToolbar.ToolbarHighlightedItemStyle); 
     221        }, 
    77222 
    78                 styleDropdownClick: function(){ 
    79                         dojo.debug("styleDropdownClick:", this.styleDropdownContainer); 
    80                         dojo.html.toggleShowing(this.styleDropdownContainer); 
    81                 }, 
     223        unhighlightToolbarItem: function(){ 
     224                dojo.html.removeClass(this._domNode, this._parentToolbar.ToolbarHighlightedItemStyle); 
     225        }, 
    82226 
    83                 copyClick: function(){ this.exec("copy"); }, 
    84                 boldClick: function(){ this.exec("bold"); }, 
    85                 italicClick: function(){ this.exec("italic"); }, 
    86                 underlineClick: function(){ this.exec("underline"); }, 
    87                 justifyleftClick: function(){ this.exec("justifyleft"); }, 
    88                 justifycenterClick: function(){ this.exec("justifycenter"); }, 
    89                 justifyfullClick: function(){ this.exec("justifyfull"); }, 
    90                 justifyrightClick: function(){ this.exec("justifyright"); }, 
    91                 pasteClick: function(){ this.exec("paste"); }, 
    92                 undoClick: function(){ this.exec("undo"); }, 
    93                 redoClick: function(){ this.exec("redo"); }, 
    94                 linkClick: function(){  
    95                         // FIXME: we need to alert the user if they haven't selected any text 
    96                         // this.exec(   "createlink",  
    97                         //                      prompt("Please enter the URL of the link:", "http://")); 
    98                 }, 
    99                 insertunorderedlistClick: function(){ this.exec("insertunorderedlist"); }, 
    100                 insertorderedlistClick: function(){ this.exec("insertorderedlist"); }, 
    101                 inserthorizontalruleClick: function(){ this.exec("inserthorizontalrule"); }, 
    102                 strikethroughClick: function(){ this.exec("strikethrough"); }, 
     227        removeToolbarItemStyle: function(){ 
     228                dojo.html.removeClass(this._domNode, this._parentToolbar.ToolbarEnabledItemStyle); 
     229                dojo.html.removeClass(this._domNode, this._parentToolbar.ToolbarLatchedItemStyle); 
     230                dojo.html.removeClass(this._domNode, this._parentToolbar.ToolbarDisabledItemStyle); 
     231                this.unhighlightToolbarItem(); 
     232        } 
     233}); 
    103234 
    104                 formatSelectClick: function(){  
    105                         var sv = this.formatSelectBox.value.toLowerCase(); 
    106                         this.exec("formatblock", sv); 
    107                 }, 
     235dojo.declare("dojo.widget.Editor2ToolbarDropDownButton", dojo.widget.Editor2ToolbarButton,{ 
     236        onClick: function(){ 
     237                if(this._domNode){ 
     238                        if(!this._dropdown){ 
     239                                this._dropdown = dojo.widget.createWidget("PopupContainer", {}); 
     240                                this._domNode.appendChild(this._dropdown.domNode); 
     241                        } 
     242                        if(this._dropdown.isShowingNow){ 
     243                                this._dropdown.close(); 
     244                        }else{ 
     245                                this.onDropDownShown();  
     246                                this._dropdown.open(this._domNode, null, this._domNode); 
     247                        } 
     248                } 
     249        }, 
     250        destroy: function(){ 
     251                this.onDropDownDestroy(); 
     252                if(this._dropdown){ 
     253                        this._dropdown.destroy(); 
     254                } 
     255                dojo.widget.Editor2ToolbarDropDownButton.superclass.destroy.call(this); 
     256        }, 
     257        onDropDownShown: function(){}, 
     258        onDropDownDestroy: function(){} 
     259}); 
    108260 
    109                 normalTextClick: function(){ this.exec("formatblock", "p"); }, 
    110                 h1TextClick: function(){ this.exec("formatblock", "h1"); }, 
    111                 h2TextClick: function(){ this.exec("formatblock", "h2"); }, 
    112                 h3TextClick: function(){ this.exec("formatblock", "h3"); }, 
    113                 h4TextClick: function(){ this.exec("formatblock", "h4"); }, 
    114                 indentClick: function(){ this.exec("indent"); }, 
    115                 outdentClick: function(){ this.exec("outdent"); }, 
     261dojo.declare("dojo.widget.Editor2ToolbarColorPaletteButton", dojo.widget.Editor2ToolbarDropDownButton,{ 
     262        onDropDownShown: function(){ 
     263                if(!this._colorpalette){ 
     264                        this._colorpalette = dojo.widget.createWidget("ColorPalette", {}); 
     265                        this._dropdown.addChild(this._colorpalette); 
    116266 
     267                        this.disableSelection(this._dropdown.domNode); 
     268                        this.disableSelection(this._colorpalette.domNode); 
     269                        //do we need a destory to delete this._colorpalette manually? 
     270                        //I assume as it is added to this._dropdown via addChild, it 
     271                        //should be deleted when this._dropdown is destroyed 
    117272 
    118                 hideAllDropDowns: function(){ 
    119                         this.domNode.style.height = ""; 
    120                         dojo.lang.forEach(dojo.widget.byType("Editor2Toolbar"), function(tb){ 
    121                                 try{ 
    122                                         dojo.html.hide(tb.forecolorDropDown); 
    123                                         dojo.html.hide(tb.hilitecolorDropDown); 
    124                                         dojo.html.hide(tb.styleDropdownContainer); 
    125                                         if(tb.clickInterceptDiv){ 
    126                                                 dojo.html.hide(tb.clickInterceptDiv); 
    127                                         } 
    128                                 }catch(e){} 
    129                                 if(dojo.render.html.ie){ 
    130                                         try{ 
    131                                                 dojo.html.hide(tb.forecolorPalette.bgIframe); 
    132                                         }catch(e){} 
    133                                         try{ 
    134                                                 dojo.html.hide(tb.hilitecolorPalette.bgIframe); 
    135                                         }catch(e){} 
     273                        dojo.event.connect(this._colorpalette, "onColorSelect", this, 'setColor'); 
     274                        dojo.event.connect(this._dropdown, "open", this, 'latchToolbarItem'); 
     275                        dojo.event.connect(this._dropdown, "close", this, 'enableToolbarItem'); 
     276                } 
     277        }, 
     278        setColor: function(color){ 
     279                this._dropdown.close(); 
     280                this._command.execute(color); 
     281        } 
     282}); 
     283 
     284dojo.declare("dojo.widget.Editor2ToolbarFormatBlockPlainSelect", dojo.widget.Editor2ToolbarButton,{ 
     285        create: function(node, toolbar){ 
     286                //TODO: check node is a select 
     287                this._domNode = node; 
     288                this.disableSelection(this._domNode); 
     289                this._parentToolbar = toolbar; 
     290                dojo.event.connect(this._domNode, 'onchange', this, 'onChange'); 
     291        }, 
     292 
     293        destroy: function(){ 
     294                this._domNode = null; 
     295                this._command = null; 
     296                this._parentToolbar = null; 
     297        }, 
     298 
     299        onChange: function(){ 
     300                if(this._domNode){ 
     301                        var sv = this._domNode.value.toLowerCase(); 
     302                        this._command.execute(sv); 
     303                } 
     304        }, 
     305 
     306        refreshState: function(){ 
     307                if(this._domNode && this._command){ 
     308                        dojo.widget.Editor2ToolbarFormatBlockPlainSelect.superclass.refreshState.call(this); 
     309                        var format = this._command.getValue(); 
     310                        if(!format){ format = ""; } 
     311                        dojo.lang.forEach(this._domNode.options, function(item){ 
     312                                if(item.value.toLowerCase() == format.toLowerCase()){ 
     313                                        item.selected = true; 
    136314                                } 
    137315                        }); 
    138                 }, 
     316                } 
     317        } 
     318}); 
    139319 
    140                 selectFormat: function(format){ 
    141                         if(this.formatSelectBox) { 
    142                                 dojo.lang.forEach(this.formatSelectBox.options, function(item){ 
    143                                         if(item.value.toLowerCase() == format.toLowerCase()){ 
    144                                                 // FIXME: SEVERE: setting selected on this item breaks the undo stack on IE 
    145                                                 item.selected = true; 
    146                                         } 
    147                                 }); 
    148                         } 
    149                 }, 
     320dojo.declare("dojo.widget.Editor2ToolbarComboItem", dojo.widget.Editor2ToolbarDropDownButton,{ 
     321        href: null, 
     322        create: function(node, toolbar){ 
     323                dojo.widget.Editor2ToolbarComboItem.superclass.create.call(this, node, toolbar); 
     324                //do not use lazy initilization, as we need the local names in refreshState() 
     325                if(!this._contentPane){ 
     326                        dojo.require("dojo.widget.ContentPane"); 
     327                        this._contentPane = dojo.widget.createWidget("ContentPane", {preload: 'true'}); 
     328                        this._contentPane.addOnLoad(this, "setup"); 
     329                        this._contentPane.setUrl(this.href); 
     330                } 
     331        }, 
    150332 
    151                 forecolorClick: function(e){ 
    152                         this.colorClick(e, "forecolor"); 
    153                 }, 
     333        onMouseOver: function(e){ 
     334                dojo.html.addClass(e.currentTarget, this._parentToolbar.ToolbarHighlightedSelectStyle); 
     335        }, 
     336        onMouseOut:function(e){ 
     337                dojo.html.removeClass(e.currentTarget, this._parentToolbar.ToolbarHighlightedSelectStyle); 
     338        }, 
    154339 
    155                 hilitecolorClick: function(e){ 
    156                         this.colorClick(e, "hilitecolor"); 
    157                 }, 
     340        onDropDownShown: function(){ 
     341                if(!this._dropdown.__addedContentPage){ 
     342                        this._dropdown.addChild(this._contentPane); 
     343                        this._dropdown.__addedContentPage = true; 
     344                } 
     345        }, 
    158346 
    159                 // FIXME: these methods aren't currently dealing with clicking in the 
    160                 // general document to hide the menu 
    161                 colorClick: function(e, type){ 
    162                         var h = dojo.render.html; 
    163                         this.hideAllDropDowns(); 
    164                         // FIXME: if we've been "popped out", we need to set the height of the toolbar. 
    165                         e.stopPropagation(); 
    166                         var dd = this[type+"DropDown"]; 
    167                         var pal = this[type+"Palette"]; 
    168                         dojo.html.toggleShowing(dd); 
    169                         if(!pal){ 
    170                                 pal = this[type+"Palette"] = dojo.widget.createWidget("ColorPalette", {}, dd, "first"); 
    171                                 var fcp = pal.domNode; 
    172                                 var mb = dojo.html.getMarginBox(fcp); 
    173                                 with(dd.style){ 
    174                                         width = mb.width + "px"; 
    175                                         height = mb.height + "px"; 
    176                                         zIndex = 1002; 
    177                                         position = "absolute"; 
    178                                 } 
     347        //overload this to connect event 
     348        setup: function(){}, 
    179349 
    180                                 dojo.event.connect(     "after", 
    181                                                                         pal, "onColorSelect", 
    182                                                                         this, "exec", 
    183                                                                         function(mi){ mi.args.unshift(type); return mi.proceed(); } 
    184                                 ); 
     350        onChange: function(e){ 
     351                var name = e.currentTarget.getAttribute("dropDownItemName"); 
     352                this._command.execute(name); 
     353                this._dropdown.close(); 
     354        }, 
    185355 
    186                                 dojo.event.connect(     "after", 
    187                                                                         pal, "onColorSelect", 
    188                                                                         dojo.html, "toggleShowing", 
    189                                                                         this, function(mi){ mi.args.unshift(dd); return mi.proceed(); } 
    190                                 ); 
     356        onMouseOverItem: function(e){ 
     357                dojo.html.addClass(e.currentTarget, this._parentToolbar.ToolbarHighlightedSelectItemStyle); 
     358        }, 
    191359 
    192                                 var cid = this.clickInterceptDiv; 
    193                                 if(!cid){ 
    194                                         cid = this.clickInterceptDiv = document.createElement("div"); 
    195                                         document.body.appendChild(cid); 
    196                                         with(cid.style){ 
    197                                                 backgroundColor = "transparent"; 
    198                                                 top = left = "0px"; 
    199                                                 height = width = "100%"; 
    200                                                 position = "absolute"; 
    201                                                 border = "none"; 
    202                                                 display = "none"; 
    203                                                 zIndex = 1001; 
     360        onMouseOutItem: function(e){ 
     361                dojo.html.removeClass(e.currentTarget, this._parentToolbar.ToolbarHighlightedSelectItemStyle); 
     362        }, 
     363 
     364        //overload this to update GUI item 
     365        refreshState: function(){} 
     366}); 
     367 
     368dojo.declare("dojo.widget.Editor2ToolbarFormatBlockSelect", dojo.widget.Editor2ToolbarComboItem,{ 
     369        href: dojo.uri.dojoUri("src/widget/templates/Editor2/EditorToolbar_FormatBlock.html"), 
     370 
     371        setup: function(){ 
     372                dojo.widget.Editor2ToolbarFormatBlockSelect.superclass.setup.call(this); 
     373 
     374                var nodes = this._contentPane.domNode.all || this._contentPane.domNode.getElementsByTagName("*"); 
     375                this._blockNames = {}; 
     376                this._blockDisplayNames = {}; 
     377                for(var x=0; x<nodes.length; x++){ 
     378                        var node = nodes[x]; 
     379                        dojo.html.disableSelection(node); 
     380                        var name=node.getAttribute("dropDownItemName") 
     381                        if(name){ 
     382                                this._blockNames[name] = node; 
     383                                var childrennodes = node.getElementsByTagName(name); 
     384                                this._blockDisplayNames[name] = childrennodes[childrennodes.length-1].innerHTML; 
     385                        } 
     386                } 
     387                for(var name in this._blockNames){ 
     388                        dojo.event.connect(this._blockNames[name], "onclick", this, "onChange"); 
     389                        dojo.event.connect(this._blockNames[name], "onmouseover", this, "onMouseOverItem"); 
     390                        dojo.event.connect(this._blockNames[name], "onmouseout", this, "onMouseOutItem"); 
     391                } 
     392        }, 
     393 
     394        onDropDownDestroy: function(){ 
     395                if(this._blockNames){ 
     396                        for(var name in this._blockNames){ 
     397                                delete this._blockNames[name]; 
     398                                delete this._blockDisplayNames[name]; 
     399                        } 
     400                } 
     401        }, 
     402 
     403        refreshState: function(){ 
     404                if(this._command){ 
     405                        //dojo.widget.Editor2ToolbarFormatBlockSelect.superclass.refreshState.call(this); 
     406                        var format = this._command.getValue(); 
     407                        if(format == this._lastSelectedFormat && this._blockDisplayNames){ 
     408                                return; 
     409                        } 
     410                        this._lastSelectedFormat = format; 
     411                        var label = this._domNode.getElementsByTagName("label")[0]; 
     412                        var isSet = false; 
     413                        if(this._blockDisplayNames){ 
     414                                for(var name in this._blockDisplayNames){ 
     415                                        if(name == format){ 
     416                                                label.innerHTML =       this._blockDisplayNames[name]; 
     417                                                isSet = true; 
     418                                                break; 
    204419                                        } 
    205                                         dojo.event.connect(cid, "onclick", function(){ cid.style.display = "none"; }); 
    206420                                } 
    207                                 dojo.event.connect(pal, "onColorSelect", function(){ cid.style.display = "none"; }); 
     421                                if(!isSet){ 
     422                                        label.innerHTML = "&nbsp;"; 
     423                                } 
     424                        } 
     425                } 
     426        } 
     427}); 
    208428 
    209                                 dojo.event.kwConnect({ 
    210                                         srcObj:         document.body,  
    211                                         srcFunc:        "onclick",  
    212                                         targetObj:      this, 
    213                                         targetFunc:     "hideAllDropDowns", 
    214                                         once:           true 
    215                                 }); 
    216                                 document.body.appendChild(dd); 
     429dojo.declare("dojo.widget.Editor2ToolbarFontSizeSelect", dojo.widget.Editor2ToolbarComboItem,{ 
     430        href: dojo.uri.dojoUri("src/widget/templates/Editor2/EditorToolbar_FontSize.html"), 
     431 
     432        setup: function(){ 
     433                dojo.widget.Editor2ToolbarFormatBlockSelect.superclass.setup.call(this); 
     434 
     435                var nodes = this._contentPane.domNode.all || this._contentPane.domNode.getElementsByTagName("*"); 
     436                this._fontsizes = {}; 
     437                this._fontSizeDisplayNames = {}; 
     438                for(var x=0; x<nodes.length; x++){ 
     439                        var node = nodes[x]; 
     440                        dojo.html.disableSelection(node); 
     441                        var name=node.getAttribute("dropDownItemName") 
     442                        if(name){ 
     443                                this._fontsizes[name] = node; 
     444                                this._fontSizeDisplayNames[name] = node.getElementsByTagName('font')[0].innerHTML; 
    217445                        } 
    218                         dojo.html.toggleShowing(this.clickInterceptDiv); 
    219                         var pos = dojo.html.abs(this[type+"Button"]); 
    220                         dojo.html.placeOnScreenPoint(dd, pos.x, pos.y, 0, false); 
    221                         if(pal.bgIframe){ 
    222                                 var mb = dojo.html.getMarginBox(dd); 
    223                                 with(pal.bgIframe.style){ 
    224                                         display = "block"; 
    225                                         left = dd.style.left; 
    226                                         top = dd.style.top; 
    227                                         width = mb.width+"px"; 
    228                                         height = mb.height+"px"; 
    229                                 } 
     446                } 
     447                for(var name in this._fontsizes){ 
     448                        dojo.event.connect(this._fontsizes[name], "onclick", this, "onChange"); 
     449                        dojo.event.connect(this._fontsizes[name], "onmouseover", this, "onMouseOverItem"); 
     450                        dojo.event.connect(this._fontsizes[name], "onmouseout", this, "onMouseOutItem"); 
     451                } 
     452        }, 
     453 
     454        onDropDownDestroy: function(){ 
     455                if(this._fontsizes){ 
     456                        for(var name in this._fontsizes){ 
     457                                delete this._fontsizes[name]; 
     458                                delete this._fontSizeDisplayNames[name]; 
    230459                        } 
    231                 }, 
     460                } 
     461        }, 
    232462 
    233                 uninitialize: function(){ 
    234                         if(!dojo.render.html.ie){ 
    235                                 // apparently this causes leakage on IE! 
    236                                 dojo.event.kwDisconnect({ 
    237                                         srcObj:         document.body,  
    238                                         srcFunc:        "onclick",  
    239                                         targetObj:      this, 
    240                                         targetFunc:     "hideAllDropDowns", 
    241                                         once:           true 
    242                                 }); 
     463        refreshState: function(){ 
     464                if(this._command){ 
     465                        //dojo.widget.Editor2ToolbarFormatBlockSelect.superclass.refreshState.call(this); 
     466                        var size = this._command.getValue(); 
     467                        if(size == this._lastSelectedSize && this._fontSizeDisplayNames){ 
     468                                return; 
    243469                        } 
    244                 }, 
     470                        this._lastSelectedSize = size; 
     471                        var label = this._domNode.getElementsByTagName("label")[0]; 
     472                        var isSet = false; 
     473                        if(this._fontSizeDisplayNames){ 
     474                                for(var name in this._fontSizeDisplayNames){ 
     475                                        if(name == size){ 
     476                                                label.innerHTML =       this._fontSizeDisplayNames[name]; 
     477                                                isSet = true; 
     478                                                break; 
     479                                        } 
     480                                } 
     481                                if(!isSet){ 
     482                                        label.innerHTML = "&nbsp;"; 
     483                                } 
     484                        } 
     485                } 
     486        } 
     487}); 
    245488 
    246                 // stub for observers 
    247                 exec: function(what, arg){ /* dojo.debug(what, new Date()); */ }, 
     489dojo.declare("dojo.widget.Editor2ToolbarFontNameSelect", dojo.widget.Editor2ToolbarFontSizeSelect,{ 
     490        href: dojo.uri.dojoUri("src/widget/templates/Editor2/EditorToolbar_FontName.html") 
     491}); 
    248492 
    249                 hideUnusableButtons: function(obj){ 
    250                         var op = obj||dojo.widget.RichText.prototype; 
    251                         dojo.lang.forEach(this.commandList, 
    252                                 function(cmd){ 
    253                                         if(this[cmd+"Button"]){ 
    254                                                 var cb = this[cmd+"Button"]; 
    255                                                 if(!op.queryCommandAvailable(cmd)){ 
    256                                                         cb.style.display = "none"; 
    257                                                         cb.parentNode.style.display = "none"; 
    258                                                 } 
     493dojo.widget.defineWidget( 
     494        "dojo.widget.Editor2Toolbar", 
     495        dojo.widget.HtmlWidget, 
     496        { 
     497                templatePath: dojo.uri.dojoUri("src/widget/templates/EditorToolbar.html"), 
     498                templateCssPath: dojo.uri.dojoUri("src/widget/templates/EditorToolbar.css"), 
     499 
     500                // DOM Nodes 
     501                saveButton: null, 
     502 
     503                ToolbarLatchedItemStyle: "ToolbarButtonLatched", 
     504                ToolbarEnabledItemStyle: "ToolbarButtonEnabled", 
     505                ToolbarDisabledItemStyle: "ToolbarButtonDisabled", 
     506                ToolbarHighlightedItemStyle: "ToolbarButtonHighlighted", 
     507                ToolbarHighlightedSelectStyle: "ToolbarSelectHighlighted", 
     508                ToolbarHighlightedSelectItemStyle: "ToolbarSelectHighlightedItem", 
     509 
     510//              itemNodeType: 'span', //all the items (with attribute dojoETItemName set) defined in the toolbar should be a of this type 
     511 
     512                postCreate: function(){ 
     513                        var nodes = dojo.html.getElementsByClass("dojoEditorToolbarItem", this.domNode/*, this.itemNodeType*/); 
     514 
     515                        this.items = {}; 
     516                        for(var x=0; x<nodes.length; x++){ 
     517                                var node = nodes[x]; 
     518                                var itemname = node.getAttribute("dojoETItemName"); 
     519                                if(itemname){ 
     520                                        var item = dojo.widget.Editor2ToolbarItemManager.getToolbarItem(itemname); 
     521                                        if(item){ 
     522                                                item.create(node, this); 
     523                                                this.items[itemname.toLowerCase()] = item; 
     524                                        }else{ 
     525                                                //hide unsupported toolbar items 
     526                                                node.style.display = "none"; 
    259527                                        } 
    260                                 }, 
    261                                 this); 
    262                                 if(this.oneLineTr){ 
    263                                         var lastVisibleIsSpacer = false; 
    264                                         var lastVisible = false; 
    265                                         var tds = this.oneLineTr.getElementsByTagName("td"); 
    266                                         dojo.lang.forEach(tds, function(td){ 
    267                                                 if(td.getAttribute("isSpacer")){ 
    268                                                         if(td.style.display != "none"){ 
    269                                                                 if(lastVisibleIsSpacer){ 
    270                                                                         td.style.display = "none"; 
    271                                                                 } 
    272                                                                 lastVisibleIsSpacer = true; 
    273                                                         }else{ 
    274                                                                 lastVisible = td; 
    275                                                                 lastVisibleIsSpacer = true; 
    276                                                         } 
    277                                                 }else{ 
    278                                                         if(td.style.display != "none"){ 
    279                                                                 lastVisible = td; 
    280                                                                 lastVisibleIsSpacer = false; 
    281                                                         } 
    282                                                 } 
    283                                         }); 
    284528                                } 
     529                        } 
    285530                }, 
    286531 
    287                 highlightButton: function(name){ 
    288                         var bn = name+"Button"; 
    289                         if(this[bn]){ 
    290                                 with(this[bn].style){ 
    291                                         backgroundColor = "White"; 
    292                                         border = "1px solid #aeaeab"; 
    293                                 } 
     532                // event signals 
     533                wikiwordClick: function(){ }, 
     534//              insertimageClick: function(){ }, 
     535                saveClick: function(){ }, 
     536 
     537                update: function(){ 
     538                        for(var cmd in this.items){ 
     539                                this.items[cmd].refreshState(); 
    294540                        } 
    295541                }, 
    296542 
    297                 unhighlightButton: function(name){ 
    298                         var bn = name+"Button"; 
    299                         if(this[bn]){ 
    300                                 // dojo.debug("unhighlighting:", name); 
    301                                 with(this[bn].style){ 
    302                                         backgroundColor = ""; 
    303                                         border = ""; 
    304                                 } 
     543                destroy: function(){ 
     544                        for(var it in this.items){ 
     545                                this.items[it].destroy(); 
     546                                delete this.items[it]; 
    305547                        } 
    306                 } 
     548                        dojo.widget.Editor2Toolbar.superclass.destroy.call(this); 
     549                }//, 
     550 
     551                // stub for observers 
     552//              exec: function(what, arg){ /* dojo.debug(what, new Date()); */ } 
    307553        }, 
    308554        "html", 
    309555        function(){ 
    310                 // dojo.event.connect(this, "fillInTemplate", this, "hideUnusableButtons"); 
    311556                dojo.event.connect(this, "fillInTemplate", dojo.lang.hitch(this, function(){ 
    312557                        if(dojo.render.html.ie){ 
    313558                                this.domNode.style.zoom = 1.0; 
  • src/widget/RichText.js

     
    292292                                        this.editNode.innerHTML = localhtml; 
    293293                                        var node = this.editNode.firstChild; 
    294294                                        while(node){ 
    295                                                 dojo.withGlobal(this.window, "selectElement", dojo.html.selection, node.firstChild); 
     295                                                dojo.withGlobal(this.window, "selectElement", dojo.html.selection, [node.firstChild]); 
    296296                                                var nativename = node.tagName.toLowerCase(); 
    297297                                                this._local2NativeFormatNames[nativename] = this.queryCommandValue("formatblock"); 
    298298                                                dojo.debug([nativename,this._local2NativeFormatNames[nativename]]); 
     
    621621                                '<style type="text/css">' + 
    622622                                '    body,html { padding: 0; margin: 0; }' + //font: ' + font + '; }' + 
    623623                                (this.height ? '' : '    body,  { overflow: hidden; }') + 
    624                                 //'    #bodywrapper {  }' + 
    625624                                '</style>' + 
    626625                                //'<base href="' + dojo.global().location + '">' + 
    627                                 '<body><div id="bodywrapper">' + html + '</div></body></html>'; 
     626                                '<body>' + html + '</body></html>'; 
    628627 
    629628                        this._cacheLocalBlockFormatNames(); 
    630629                }, 
     
    677676                        if (this.object){ 
    678677                                this.document = this.object.DOM; 
    679678                                this.window = this.document.parentWindow; 
    680                                 this.editNode = this.document.body.firstChild; 
     679                                this.editNode = this.document.body; 
    681680                                this.domNode.style.height = this.height ? this.height : this.minHeight; 
    682681                                this.connect(this, "onDisplayChanged", "_updateHeight"); 
    683682                        }else if (this.iframe && !dojo.render.html.ie){ 
     
    717716                                        } }; 
    718717                                        dojo.event.connect("before", this, "close", unBlur, "unBlur"); 
    719718                                        dojo.event.browser.addListener(this.document, "focus", dojo.lang.hitch(this, "onFocus")); 
    720                                  
    721                                         // safari can't handle key listeners, it kills the speed 
     719 
    722720                                        var addListener = dojo.event.browser.addListener; 
    723721                                        addListener(this.document, "keypress", dojo.lang.hitch(this, "onKeyPress")); 
    724722                                        addListener(this.document, "keydown", dojo.lang.hitch(this, "onKeyDown")); 
     
    10341032                        var command = joinObject.args[0].toLowerCase(); 
    10351033                        if(command == "formatblock"){ 
    10361034                                if(drh.safari){ command = "heading"; } 
    1037                                 if(this.object){ //IE activeX mode 
     1035                                if(this.object && joinObject.args[1]){ //IE activeX mode 
    10381036                                        joinObject.args[1] = this._native2LocalFormatNames[joinObject.args[1]]; 
    10391037                                } 
    10401038                                else if(drh.ie){ joinObject.args[1] = "<"+joinObject.args[1]+">"; } 
     
    11591157 
    11601158                        if(this.object){ 
    11611159                                switch (command) { 
     1160                                        case "hilitecolor": 
     1161                                                command = "setbackcolor"; 
     1162                                                break; 
    11621163                                        case "forecolor": 
    11631164                                        case "backcolor": 
    11641165                                        case "fontsize": 
     
    11751176                                        if(!range.htmlText){ 
    11761177                                                return; 
    11771178                                        } 
    1178                                         argument="<strike>"+range.htmlText+"<strike>"; 
     1179                                        argument=range.htmlText.strike(); 
    11791180                                }else if(command == "inserthorizontalrule"){ 
    11801181                                        command = "inserthtml"; 
    11811182                                        argument="<hr>"; 
     
    12501251                                var selectionEndOffset = selectionRange.endOffset; 
    12511252                                 
    12521253                                // select our link and unlink 
    1253                                 var a = dojo.withGlobal(this.window, "getAncestorElement", dojo.html.selection, 'a'); 
    1254                                 dojo.withGlobal(this.window, "selectElement", dojo.html.selection, a); 
     1254                                var a = dojo.withGlobal(this.window, "getAncestorElement", dojo.html.selection, ['a']); 
     1255                                dojo.withGlobal(this.window, "selectElement", dojo.html.selection, [a]); 
    12551256                                 
    12561257                                returnValue = this.document.execCommand("unlink", false, null); 
    12571258                                 
     
    13021303                queryCommandEnabled: function(command, argument){ 
    13031304                        if(this.object){ 
    13041305                                switch (command) { 
     1306                                        case "hilitecolor": 
     1307                                                command = "setbackcolor"; 
     1308                                                break; 
    13051309                                        case "forecolor": 
    13061310                                        case "backcolor": 
    13071311                                        case "fontsize": 
     
    13261330                        }else{ 
    13271331                                // mozilla returns true always 
    13281332                                if(command == "unlink" && dojo.render.html.mozilla){ 
    1329                                         return dojo.withGlobal(this.window, "hasAncestorElement", dojo.html.selection, 'a'); 
     1333                                        return dojo.withGlobal(this.window, "hasAncestorElement", dojo.html.selection, ['a']); 
    13301334                                } else if (command == "inserttable" && dojo.render.html.mozilla) { 
    13311335                                        return true; 
    13321336                                } 
     
    13451349                                        command = "setbackcolor"; 
    13461350                                }else if(command == "strikethrough"){ 
    13471351                                        //check whether we are under a <strike> 
    1348                                         return dojo.withGlobal(this.window, "hasAncestorElement", dojo.html.selection, 'strike'); 
     1352                                        return dojo.withGlobal(this.window, "hasAncestorElement", dojo.html.selection, ['strike']); 
    13491353                                }else if(command == "inserthorizontalrule"){ 
    13501354                                        return false; 
    13511355                                } 
     
    13921396                 
    13931397                placeCursorAtStart: function(){ 
    13941398                        this.focus(); 
    1395                         dojo.withGlobal(this.window, "selectElementChildren", dojo.html.selection, this.editNode); 
    1396                         dojo.withGlobal(this.window, "collapse", dojo.html.selection, true); 
     1399                        //see comments in placeCursorAtEnd 
     1400                        if(dojo.render.html.moz && this.editNode.firstChild &&  
     1401                                this.editNode.firstChild.nodeType != dojo.dom.TEXT_NODE){ 
     1402                                dojo.withGlobal(this.window, "selectElementChildren", dojo.html.selection, [this.editNode.firstChild]); 
     1403                        }else{ 
     1404                                dojo.withGlobal(this.window, "selectElementChildren", dojo.html.selection, [this.editNode]); 
     1405                        } 
     1406                        dojo.withGlobal(this.window, "collapse", dojo.html.selection, [true]); 
    13971407                }, 
    13981408 
    13991409                placeCursorAtEnd: function(){ 
     
    14021412                        //otherwise the cursor would be placed at the end of the closing tag of this.editNode.lastChild 
    14031413                        if(dojo.render.html.moz && this.editNode.lastChild &&  
    14041414                                this.editNode.lastChild.nodeType != dojo.dom.TEXT_NODE){ 
    1405                                 dojo.withGlobal(this.window, "selectElementChildren", dojo.html.selection, this.editNode.lastChild); 
     1415                                dojo.withGlobal(this.window, "selectElementChildren", dojo.html.selection, [this.editNode.lastChild]); 
    14061416                        }else{ 
    1407                                 dojo.withGlobal(this.window, "selectElementChildren", dojo.html.selection, this.editNode); 
     1417                                dojo.withGlobal(this.window, "selectElementChildren", dojo.html.selection, [this.editNode]); 
    14081418                        } 
    1409                         dojo.withGlobal(this.window, "collapse", dojo.html.selection, false); 
     1419                        dojo.withGlobal(this.window, "collapse", dojo.html.selection, [false]); 
    14101420                }, 
    14111421 
    14121422                //this function set the content while trying to maintain the undo stack 
     
    15211531                                if(dojo.string.trim(ec) == "&nbsp;"){ ec = ""; } 
    15221532                        }catch(e){ /* squelch */ } 
    15231533 
     1534                        if(dojo.render.html.ie && !this.object){ 
     1535                                //removing appended <P>&nbsp;</P> for IE in none-activeX mode 
     1536                                var re = new RegExp("(?:<p>&nbsp;</p>[\n\r]*)+$", "i"); 
     1537                                ec = ec.replace(re,""); 
     1538                        } 
     1539         
    15241540                        ec = this._postFilterContent(ec); 
    15251541 
    15261542                        if (this.relativeImageUrls) { 
  • src/widget/templates/Editor2/EditorToolbar_FormatBlock.html

     
     1<div class="SC_Panel" style="width: 190px; height: 150px;"> 
     2        <div class="SC_Item" dropDownItemName="p"> 
     3                <div class="BaseFont"> 
     4                        <p>Normal</p> 
     5                </div> 
     6        </div> 
     7        <div class="SC_Item" dropDownItemName="div"> 
     8                <div class="BaseFont"> 
     9                        <div>Normal (DIV)</div> 
     10                </div> 
     11        </div> 
     12        <div class="SC_Item" dropDownItemName="pre"> 
     13                <div class="BaseFont"> 
     14                        <pre>Formatted</pre> 
     15                </div> 
     16        </div> 
     17        <div class="SC_Item" dropDownItemName="address"> 
     18                <div class="BaseFont"> 
     19                        <address>Address</address> 
     20                </div> 
     21        </div> 
     22        <div class="SC_Item" dropDownItemName="h1"> 
     23                <div class="BaseFont"> 
     24                        <h1>Heading 1</h1> 
     25                </div> 
     26        </div> 
     27        <div class="SC_Item" dropDownItemName="h2"> 
     28                <div class="BaseFont"> 
     29                        <h2>Heading 2</h2> 
     30                </div> 
     31        </div> 
     32        <div class="SC_Item" dropDownItemName="h3"> 
     33                <div class="BaseFont"> 
     34                        <h3>Heading 3</h3> 
     35                </div> 
     36        </div> 
     37        <div class="SC_Item" dropDownItemName="h4"> 
     38                <div class="BaseFont"> 
     39                        <h4>Heading 4</h4> 
     40                </div> 
     41        </div> 
     42        <div class="SC_Item" dropDownItemName="h5"> 
     43                <div class="BaseFont"> 
     44                        <h5>Heading 5</h5> 
     45                </div> 
     46        </div> 
     47        <div class="SC_Item" dropDownItemName="h6"> 
     48                <div class="BaseFont"> 
     49                        <h6>Heading 6</h6> 
     50                </div> 
     51        </div> 
     52</div> 
     53 No newline at end of file 
  • src/widget/templates/Editor2/EditorToolbar_FontName.html

     
     1<div class="SC_Panel" style="width: 150px; height: 150px;"> 
     2        <div class="SC_Item" dropDownItemName="Arial"> 
     3                <font face="Arial" style="font-size: 12px;">Arial</font> 
     4        </div> 
     5        <div class="SC_Item" dropDownItemName="Comic Sans MS"> 
     6                <font face="Comic Sans MS" style="font-size: 12px;">Comic Sans MS</font> 
     7        </div> 
     8        <div class="SC_Item" dropDownItemName="Courier New"> 
     9                <font face="Courier New" style="font-size: 12px;">Courier New</font> 
     10        </div> 
     11        <div class="SC_Item" dropDownItemName="Tahoma"> 
     12                <font face="Tahoma" style="font-size: 12px;">Tahoma</font> 
     13        </div> 
     14        <div class="SC_Item" dropDownItemName="Times New Roman"> 
     15                <font face="Times New Roman" style="font-size: 12px;">Times New Roman</font> 
     16        </div> 
     17        <div class="SC_Item" dropDownItemName="Verdana"> 
     18                <font face="Verdana" style="font-size: 12px;">Verdana</font> 
     19        </div> 
     20</div> 
     21 No newline at end of file 
  • src/widget/templates/Editor2/showtableborder_gecko.css

     
     1/* For tables with the "border" attribute set to "0" */ 
     2table[border="0"],  
     3table[border="0"] > tr > td, table[border="0"] > tr > th,  
     4table[border="0"] > tbody > tr > td, table[border="0"] > tbody > tr > th,  
     5table[border="0"] > thead > tr > td, table[border="0"] > thead > tr > th,  
     6table[border="0"] > tfoot > tr > td, table[border="0"] > tfoot > tr > th 
     7{ 
     8        border: #d3d3d3 1px dotted ; 
     9} 
     10 
     11/* For tables with no "border" attribute set */ 
     12table:not([border]),  
     13table:not([border]) > tr > td, table:not([border]) > tr > th, 
     14table:not([border]) > tbody > tr > td, table:not([border]) > tbody > tr > th, 
     15table:not([border]) > thead > tr > td, table:not([border]) > thead > tr > th, 
     16table:not([border]) > tfoot > tr > td, table:not([border]) > tfoot > tr > th 
     17{ 
     18        border: #d3d3d3 1px dotted ; 
     19} 
     20 No newline at end of file 
  • src/widget/templates/Editor2/EditorDialog.html

     
     1<div id="${this.widgetId}" dojoAttachEvent="onMouseDown" class="dojoFloatingPane"> 
     2        <div dojoAttachPoint="titleBar" class="dojoFloatingPaneTitleBar"  style="display:none"> 
     3                <img dojoAttachPoint="titleBarIcon"  class="dojoFloatingPaneTitleBarIcon"> 
     4                <div dojoAttachPoint="closeAction" dojoAttachEvent="onClick:hide" 
     5                        class="dojoFloatingPaneCloseIcon"></div> 
     6                <div dojoAttachPoint="restoreAction" dojoAttachEvent="onClick:restoreWindow" 
     7                        class="dojoFloatingPaneRestoreIcon"></div> 
     8                <div dojoAttachPoint="maximizeAction" dojoAttachEvent="onClick:maximizeWindow" 
     9                        class="dojoFloatingPaneMaximizeIcon"></div> 
     10                <div dojoAttachPoint="minimizeAction" dojoAttachEvent="onClick:minimizeWindow" 
     11                        class="dojoFloatingPaneMinimizeIcon"></div> 
     12                <div dojoAttachPoint="titleBarText" class="dojoFloatingPaneTitleText">${this.title}</div> 
     13        </div> 
     14 
     15        <div id="${this.widgetId}_container" dojoAttachPoint="containerNode" class="dojoFloatingPaneClient"></div> 
     16 
     17        <div dojoAttachPoint="resizeBar" class="dojoFloatingPaneResizebar" style="display:none"></div> 
     18</div> 
     19 No newline at end of file 
  • src/widget/templates/Editor2/showtableborder_ie.css

     
     1table.dojoShowIETableBorders, table.dojoShowIETableBorders td, table.dojoShowIETableBorders th 
     2{ 
     3        border: #d3d3d3 1px solid; 
     4} 
     5 No newline at end of file 
  • src/widget/templates/Editor2/EditorToolbar_FontSize.html

     
     1<div class="SC_Panel" style="width: 150px; height: 150px;"> 
     2<table width="100%" cellspacing="0" cellpadding="0" style="table-layout: fixed;"> 
     3<tbody> 
     4<tr> 
     5<td nowrap=""> 
     6        <div class="SC_Item" dropDownItemName="1"> 
     7        <font size="1">xx-small</font> 
     8        </div> 
     9        <div class="SC_Item" dropDownItemName="2"> 
     10        <font size="2">x-small</font> 
     11        </div> 
     12        <div class="SC_Item" dropDownItemName="3"> 
     13        <font size="3">small</font> 
     14        </div> 
     15        <div class="SC_Item" dropDownItemName="4"> 
     16        <font size="4">medium</font> 
     17        </div> 
     18        <div class="SC_Item" dropDownItemName="5"> 
     19        <font size="5">large</font> 
     20        </div> 
     21        <div class="SC_Item" dropDownItemName="6"> 
     22        <font size="6">x-large</font> 
     23        </div> 
     24        <div class="SC_Item" dropDownItemName="7"> 
     25        <font size="7">xx-large</font> 
     26        </div> 
     27</td> 
     28</tr> 
     29</tbody> 
     30</table> 
     31</div> 
     32 No newline at end of file 
  • src/widget/templates/Editor2/Dialog/inserttable.html

     
     1<script> 
     2_container_.addOnLoad(function(){ 
     3        if(!_container_.refreshOnShow){ 
     4                dojo.event.connect(_container_, "show", this, "init"); 
     5        } 
     6        this.init(); 
     7}); 
     8 
     9this.editableAttributes = ['summery', 'height', 'cellspacing', 'cellpadding', 'border', 'align']; 
     10 
     11this.init = function(){ 
     12        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     13        this.tableNode = dojo.withGlobal(curInst.window, "getSelectedElement", dojo.html.selection); 
     14        if(!this.tableNode || this.tableNode.tagName.toLowerCase() != 'table'){ 
     15                this.tableNode = dojo.withGlobal(curInst.window, "getAncestorElement", dojo.html.selection, ['table']); 
     16        } 
     17 
     18        var tableAttributes = {}; 
     19        this.extraAttribText = ""; 
     20        if(this.tableNode){ 
     21                dojo.byId("dojo_inserttable_rows").value = this.tableNode.rows.length; 
     22                dojo.byId("dojo_inserttable_rows").disabled = true; 
     23                dojo.byId("dojo_inserttable_cols").value = this.tableNode.rows[0].cells.length; 
     24                dojo.byId("dojo_inserttable_cols").disabled = true; 
     25 
     26                if (this.tableNode.caption){ 
     27                        dojo.byId("dojo_inserttable_caption").value = this.tableNode.caption.innerHTML; 
     28                }else{ 
     29                        dojo.byId("dojo_inserttable_caption").value = ""; 
     30                } 
     31 
     32                var width = this.tableNode.style.width || this.tableNode.width; 
     33                if(width){ 
     34                        dojo.byId("dojo_inserttable_width").value = parseInt(width); 
     35                        if (width.indexOf('%') > -1){ 
     36                                dojo.byId("dojo_inserttable_widthtype").value = "percent"; 
     37                        }else{ 
     38                                dojo.byId("dojo_inserttable_widthtype").value = "pixels"; 
     39                        } 
     40                }else{ 
     41                        dojo.byId("dojo_inserttable_width").value = "100"; 
     42                } 
     43 
     44                var height = this.tableNode.style.height || this.tableNode.height; 
     45                if(height){ 
     46                        dojo.byId("dojo_inserttable_height").value = parseInt(width); 
     47                }else{ 
     48                        dojo.byId("dojo_inserttable_height").value = ""; 
     49                } 
     50 
     51                var attrs = this.tableNode.attributes; 
     52                for(var i=0; i<attrs.length; i++) { 
     53                        if(dojo.lang.find(this.editableAttributes, attrs[i].name.toLowerCase())>-1){ 
     54                                tableAttributes[attrs[i].name] = attrs[i].value; 
     55                        }else{ 
     56                                this.extraAttribText += attrs[i].name + '="'+attrs[i].value+'" '; 
     57                        } 
     58                } 
     59        }else{ 
     60                dojo.byId("dojo_inserttable_rows").value = 3; 
     61                dojo.byId("dojo_inserttable_rows").disabled = false; 
     62                dojo.byId("dojo_inserttable_cols").value = 2; 
     63                dojo.byId("dojo_inserttable_cols").disabled = false; 
     64                dojo.byId("dojo_inserttable_width").value = 100; 
     65                dojo.byId("dojo_inserttable_widthtype").value = "percent"; 
     66                dojo.byId("dojo_inserttable_height").value = ""; 
     67        } 
     68 
     69        for(var i in this.editableAttributes){ 
     70                name = this.editableAttributes[i]; 
     71                dojo.byId("dojo_inserttable_"+name).value = (tableAttributes[name] == undefined) ? "" : tableAttributes[name]; 
     72                if(name == 'height' && tableAttributes[name] != undefined){ 
     73                        dojo.byId("dojo_inserttable_"+name).value = tableAttributes[name]; 
     74                } 
     75        } 
     76}; 
     77 
     78this.ok = function(){ 
     79        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     80        var args = {}; 
     81 
     82        args['rows'] = dojo.byId("dojo_inserttable_rows").value; 
     83        args['cols'] = dojo.byId("dojo_inserttable_cols").value; 
     84        args['caption'] = dojo.byId("dojo_inserttable_caption").value; 
     85        args["tableattrs"] = ""; 
     86        if(dojo.byId("dojo_inserttable_widthtype").value == "percent"){ 
     87                args["tableattrs"] += 'width="'+dojo.byId("dojo_inserttable_width").value +'%" '; 
     88        }else{ 
     89                args["tableattrs"] += 'width="'+dojo.byId("dojo_inserttable_width").value +'px" '; 
     90        } 
     91        for(var i in this.editableAttributes){ 
     92                var name = this.editableAttributes[i]; 
     93                var value = dojo.byId("dojo_inserttable_"+name).value; 
     94                if(value.length > 0){ 
     95                        args["tableattrs"] += name + '="'+value+'" '; 
     96                } 
     97        } 
     98 
     99        if(!args["tableattrs"]){ 
     100                args["tableattrs"] = ""; 
     101        } 
     102 
     103        //show the border in IE by applying a custom class 
     104        if(dojo.render.html.ie && !dojo.byId("dojo_inserttable_border").value){ 
     105                args["tableattrs"] += 'class="dojoShowIETableBorders" '; 
     106        } 
     107 
     108        var html = "<table "+args["tableattrs"]+">"; 
     109        if(args['caption']){ 
     110                html += "<caption>"+args["caption"]+"</caption>"; 
     111        } 
     112        var outertbody = "<tbody>"; 
     113        if(this.tableNode){ 
     114                //retain the content 
     115                var tbody = this.tableNode.getElementsByTagName("tbody")[0]; 
     116                outertbody = tbody.outerHTML; 
     117                if(!outertbody){ 
     118                        var cnode = tbody.cloneNode(true); 
     119                        var tmpnode = tbody.ownerDocument.createElement("div"); 
     120                        tmpnode.appendChild(cnode); 
     121                        outertbody = tmpnode.innerHTML; 
     122                } 
     123                //TODO: save current selection and restore it later 
     124                dojo.withGlobal(curInst.window, "selectElement", dojo.html.selection, [this.tableNode]); 
     125        }else{ 
     126                var cols = "<tr>"; 
     127                for (var i = 0; i < +args.cols; i++) { cols += "<td></td>"; } 
     128                cols += "</tr>"; 
     129                for (var i = 0; i < args.rows; i++) { outertbody += cols; } 
     130                outertbody += "</tbody>"; 
     131        } 
     132        html += outertbody+"</table>"; 
     133        curInst.execCommand("inserthtml", html); 
     134 
     135        _container_.hide(); 
     136}; 
     137 
     138this.cancel = function(){ 
     139        _container_.hide(); 
     140}; 
     141 
     142</script> 
     143<table cellSpacing="1" cellPadding="1" width="100%" border="0"> 
     144        <tr> 
     145                <td valign="top"> 
     146                        <table cellSpacing="0" cellPadding="0" border="0"> 
     147                                <tr> 
     148 
     149                                        <td><span>Rows</span>:</td> 
     150                                        <td>&nbsp;<input id="dojo_inserttable_rows" type="text" maxLength="3" size="2" value="3"></td> 
     151                                </tr> 
     152                                <tr> 
     153                                        <td><span>Columns</span>:</td> 
     154                                        <td>&nbsp;<input id="dojo_inserttable_cols" type="text" maxLength="2" size="2" value="2"></td> 
     155                                </tr> 
     156 
     157                                <tr> 
     158                                        <td>&nbsp;</td> 
     159                                        <td>&nbsp;</td> 
     160                                </tr> 
     161                                <tr> 
     162                                        <td><span>Border size</span>:</td> 
     163                                        <td>&nbsp;<INPUT id="dojo_inserttable_border" type="text" maxLength="2" size="2" value="1"></td> 
     164                                </tr> 
     165 
     166                                <tr> 
     167                                        <td><span>Alignment</span>:</td> 
     168                                        <td>&nbsp;<select id="dojo_inserttable_align"> 
     169                                                        <option value="" selected>&lt;Not set&gt;</option> 
     170                                                        <option value="left">Left</option> 
     171                                                        <option value="center">Center</option> 
     172                                                        <option value="right">Right</option> 
     173                                                </select></td> 
     174                                </tr> 
     175                        </table> 
     176                </td> 
     177                <td>&nbsp;&nbsp;&nbsp;</td> 
     178                <td align="right" valign="top"> 
     179                        <table cellSpacing="0" cellPadding="0" border="0"> 
     180                                <tr> 
     181                                        <td><span>Width</span>:</td> 
     182                                        <td>&nbsp;<input id="dojo_inserttable_width" type="text" maxLength="4" size="3"></td> 
     183                                        <td>&nbsp;<select id="dojo_inserttable_widthtype"> 
     184                                                        <option value="percent" selected>percent</option> 
     185                                                        <option value="pixels">pixels</option> 
     186                                                </select></td> 
     187 
     188                                </tr> 
     189                                <tr> 
     190                                        <td><span>Height</span>:</td> 
     191                                        <td>&nbsp;<INPUT id="dojo_inserttable_height" type="text" maxLength="4" size="3"></td> 
     192                                        <td>&nbsp;<span>pixels</span></td> 
     193                                </tr> 
     194                                <tr> 
     195                                        <td>&nbsp;</td> 
     196                                        <td>&nbsp;</td> 
     197                                        <td>&nbsp;</td> 
     198                                </tr> 
     199                                <tr> 
     200                                        <td nowrap><span>Cell spacing</span>:</td> 
     201                                        <td>&nbsp;<input id="dojo_inserttable_cellspacing" type="text" maxLength="2" size="2" value="1"></td> 
     202                                        <td>&nbsp;</td> 
     203 
     204                                </tr> 
     205                                <tr> 
     206                                        <td nowrap><span>Cell padding</span>:</td> 
     207                                        <td>&nbsp;<input id="dojo_inserttable_cellpadding" type="text" maxLength="2" size="2" value="1"></td> 
     208                                        <td>&nbsp;</td> 
     209                                </tr> 
     210                        </table> 
     211                </td> 
     212        </tr> 
     213</table> 
     214<table cellSpacing="0" cellPadding="0" width="100%" border="0"> 
     215        <tr> 
     216                <td nowrap><span>Caption</span>:</td> 
     217                <td>&nbsp;</td> 
     218                <td width="100%" nowrap>&nbsp; 
     219                        <input id="dojo_inserttable_caption" type="text" style="WIDTH: 90%"></td> 
     220        </tr> 
     221        <tr> 
     222                <td nowrap><span>Summary</span>:</td> 
     223                <td>&nbsp;</td> 
     224                <td width="100%" nowrap>&nbsp; 
     225                        <input id="dojo_inserttable_summery" type="text" style="WIDTH: 90%"></td> 
     226        </tr> 
     227</table> 
     228<table><tr> 
     229<td><button dojoType='Button' onClick='scriptScope.ok();'>Ok</button></td> 
     230<td><button dojoType='Button' onClick='scriptScope.cancel();'>Cancel</button></td> 
     231</tr></table> 
     232 No newline at end of file 
  • src/widget/templates/Editor2/Dialog/find.html

     
     1<script> 
     2_container_.addOnLoad(function(){ 
     3        if(!_container_.refreshOnShow){ 
     4                dojo.event.connect(_container_, "show", this, "init"); 
     5        } 
     6        this.init(); 
     7}); 
     8 
     9this.init = function(){ 
     10//      if(dojo.render.html.ie){ 
     11//              dojo.byId("dojo_find_option_wholeword").parentNode.style.display = ''; 
     12//      } 
     13//      var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     14//      this.linkNode = dojo.withGlobal(curInst.window, "getAncestorElement", dojo.html.selection, ['a']); 
     15//      var linkAttributes = {}; 
     16//      this.extraAttribText = ""; 
     17//      if(this.linkNode){ 
     18//              var attrs = this.linkNode.attributes; 
     19//              for(var i=0; i<attrs.length; i++) { 
     20//                      if(dojo.lang.find(this.editableAttributes, attrs[i].name.toLowerCase())>-1){ 
     21//                              linkAttributes[attrs[i].name] = attrs[i].value; 
     22//                      }else{ 
     23//                              this.extraAttribText += attrs[i].name + '="'+attrs[i].value+'" '; 
     24//                      } 
     25//              } 
     26//      } 
     27//      for(var i in this.editableAttributes){ 
     28//              name = this.editableAttributes[i]; 
     29//              dojo.byId("dojo_createLink_"+name).value = (linkAttributes[name] == undefined) ? "" : linkAttributes[name] ; 
     30//      } 
     31} 
     32 
     33this.find = function(){ 
     34        var findcmd = dojo.widget.Editor2Manager.getCommand('find'); 
     35        var option = 0; 
     36 
     37        if(dojo.byId("dojo_find_option_casesens").checked){ 
     38                option |= findcmd.SearchOption.CaseSensitive; 
     39        } 
     40        if(dojo.byId("dojo_find_option_backwards").checked){ 
     41                option |= findcmd.SearchOption.SearchBackwards; 
     42        } 
     43 
     44        if(dojo.byId("dojo_find_option_wholeword").checked){ 
     45                option |= findcmd.SearchOption.WholeWord; 
     46        } 
     47//      if(dojo.byId("dojo_find_option_wrapsearch").checked){ 
     48//              option |= findcmd.SearchOption.WrapSearch; 
     49//      } 
     50        findcmd.find(dojo.byId("dojo_find_text").value, option); 
     51} 
     52this.cancel = function(){ 
     53        _container_.hide(); 
     54} 
     55</script> 
     56<table style="white-space: nowrap;"> 
     57<tr><td colspan='2'>Find: <input type="text" id="dojo_find_text" /></td></tr> 
     58<tr><td><input type="checkbox" dojoType="CheckBox" id="dojo_find_option_casesens" /> 
     59                <label for="dojo_find_option_casesens">Case Sensitive</label></td> 
     60                        <td><input type="checkbox" dojoType="CheckBox" id="dojo_find_option_backwards" /> 
     61                <label for="dojo_find_option_backwards">Search Backwards</label></td></tr> 
     62<tr><td style="display: none;"><input type="checkbox" dojoType="CheckBox" id="dojo_find_option_wholeword" /> 
     63                <label for="dojo_find_option_wholeword">Whole Word</label></td> 
     64                        <td><!-- Does not really work, comment out for now input type="checkbox" dojoType="CheckBox" id="dojo_find_option_wrapsearch" /> 
     65                <label for="dojo_find_option_wrapsearch">Wrap Search</label--></td></tr> 
     66</table> 
     67<table><tr> 
     68<td><button dojoType='Button' onClick='scriptScope.find();'>Find</button></td> 
     69<td><button dojoType='Button' onClick='scriptScope.cancel();'>Close</button></td> 
     70</tr></table> 
     71 No newline at end of file 
  • src/widget/templates/Editor2/Dialog/createlink.html

     
     1<script> 
     2_container_.addOnLoad(function(){ 
     3        if(!_container_.refreshOnShow){ 
     4                dojo.event.connect(_container_, "show", this, "init"); 
     5        } 
     6        this.init(); 
     7}); 
     8 
     9this.editableAttributes = ['href', 'target', 'class']; 
     10this.init = function(){ 
     11        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     12 
     13        this.linkNode = dojo.withGlobal(curInst.window, "getAncestorElement", dojo.html.selection, ['a']); 
     14        var linkAttributes = {}; 
     15        this.extraAttribText = ""; 
     16        if(this.linkNode){ 
     17                var attrs = this.linkNode.attributes; 
     18                for(var i=0; i<attrs.length; i++) { 
     19                        if(dojo.lang.find(this.editableAttributes, attrs[i].name.toLowerCase())>-1){ 
     20                                linkAttributes[attrs[i].name] = attrs[i].value; 
     21                        }else{ 
     22                                //IE lists all attributes, even default ones, filter them 
     23                                if(attrs[i].specified == undefined || attrs[i].specified){ 
     24                                        this.extraAttribText += attrs[i].name + '="'+attrs[i].value+'" '; 
     25                                } 
     26                        } 
     27                } 
     28        }else{ 
     29                var html = dojo.withGlobal(curInst.window, "getSelectedText", dojo.html.selection); 
     30                if(html == null || html.length == 0){ 
     31                        alert("Please select some text to create a link."); 
     32                        this.cancel(); 
     33                } 
     34        } 
     35 
     36        for(var i in this.editableAttributes){ 
     37                name = this.editableAttributes[i]; 
     38                dojo.byId("dojo_createLink_"+name).value = (linkAttributes[name] == undefined) ? "" : linkAttributes[name] ; 
     39        } 
     40} 
     41 
     42this.ok = function(){ 
     43        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     44        if(!this.linkNode){ 
     45                var html = dojo.withGlobal(curInst.window, "getSelectedText", dojo.html.selection); 
     46        }else{ 
     47                var html = this.linkNode.innerHTML; 
     48                dojo.withGlobal(curInst.window, "selectElement", dojo.html.selection, [this.linkNode]); 
     49        } 
     50 
     51        var attstr=''; 
     52        for(var i in this.editableAttributes){ 
     53                name = this.editableAttributes[i]; 
     54                var value = dojo.byId("dojo_createLink_"+name).value; 
     55                if(value.length > 0){ 
     56                        attstr += name + '="'+value+'" '; 
     57                } 
     58        } 
     59        curInst.execCommand('inserthtml', '<a '+attstr+this.extraAttribText+'>'+html+'</a>'); 
     60 
     61        this.cancel(); 
     62} 
     63this.cancel = function(){ 
     64        _container_.hide(); 
     65} 
     66</script> 
     67<table> 
     68<tr><td>URL</td><td> <input type="text" id="dojo_createLink_href" name="dojo_createLink_href"/></td></tr> 
     69<tr><td>Target </td><td><select id="dojo_createLink_target"> 
     70        <option value="">Self</option> 
     71        <option value="_blank">New Window</option> 
     72        <option value="_top">Top Window</option> 
     73        </select></td></tr> 
     74<tr><td>Class </td><td><input type="text" id="dojo_createLink_class" /></td></tr> 
     75</table> 
     76<table><tr> 
     77<td><button dojoType='Button' onClick='scriptScope.ok();'>OK</button></td> 
     78<td><button dojoType='Button' onClick='scriptScope.cancel();'>Cancel</button></td> 
     79</tr></table> 
     80 No newline at end of file 
  • src/widget/templates/Editor2/Dialog/insertimage.html

     
     1<script> 
     2_container_.addOnLoad(function(){ 
     3        if(!_container_.refreshOnShow){ 
     4                dojo.event.connect(_container_, "show", this, "init"); 
     5        } 
     6        this.init(); 
     7}); 
     8 
     9this.editableAttributes = ['src', 'alt', 'width', 'height', 'hspace', 'vspace', 'border', 'align']; 
     10 
     11this.init = function(){ 
     12        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     13        this.imageNode = dojo.withGlobal(curInst.window, "getSelectedElement", dojo.html.selection); 
     14        if(!this.imageNode){ 
     15                this.imageNode = dojo.withGlobal(curInst.window, "getAncestorElement", dojo.html.selection, ['img']); 
     16        } 
     17        var imageAttributes = {}; 
     18        this.extraAttribText = ""; 
     19        if(this.imageNode){ 
     20                var attrs = this.imageNode.attributes; 
     21                for(var i=0; i<attrs.length; i++) { 
     22                        if(dojo.lang.find(this.editableAttributes, attrs[i].name.toLowerCase())>-1){ 
     23                                imageAttributes[attrs[i].name] = attrs[i].value; 
     24                        }else{ 
     25                                this.extraAttribText += attrs[i].name + '="'+attrs[i].value+'" '; 
     26                        } 
     27                } 
     28        } 
     29        for(var i in this.editableAttributes){ 
     30                name = this.editableAttributes[i]; 
     31                dojo.byId("dojo_insertimage_"+name).value = (imageAttributes[name] == undefined) ? "" : imageAttributes[name] ; 
     32        } 
     33}; 
     34 
     35this.ok = function(){ 
     36        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     37        var insertcmd = dojo.widget.Editor2Manager.getCommand('inserthtml'); 
     38        var option = 0; 
     39 
     40        var attstr=''; 
     41        for(var i in this.editableAttributes){ 
     42                name = this.editableAttributes[i]; 
     43                var value = dojo.byId("dojo_insertimage_"+name).value; 
     44                if(value.length > 0){ 
     45                        attstr += name + '="'+value+'" '; 
     46                } 
     47        } 
     48        if(this.imageNode){ 
     49                dojo.withGlobal(curInst.window, "selectElement", dojo.html.selection, [this.imageNode]); 
     50        } 
     51        insertcmd.execute('<img '+attstr+this.extraAttribText+'/>'); 
     52        _container_.hide(); 
     53}; 
     54 
     55this.cancel = function(){ 
     56        _container_.hide(); 
     57}; 
     58 
     59</script> 
     60<table cellspacing="1" cellpadding="1" border="0" width="100%" height="100%"> 
     61                        <tr> 
     62                                <td> 
     63                                        <table cellspacing="0" cellpadding="0" width="100%" border="0"> 
     64                                                <tr> 
     65                                                        <td width="100%"> 
     66                                                                <span>URL</span> 
     67                                                        </td> 
     68                                                        <td style="display: none" nowrap="nowrap" rowspan="2"> 
     69                                                                <!--input id="btnBrowse" onclick="BrowseServer();" type="button" value="Browse Server"/--> 
     70                                                        </td> 
     71                                                </tr> 
     72                                                <tr> 
     73                                                        <td valign="top"> 
     74                                                                <input id="dojo_insertimage_src" style="width: 100%" type="text" /> 
     75                                                        </td> 
     76                                                </tr> 
     77                                        </table> 
     78                                </td> 
     79                        </tr> 
     80                        <tr> 
     81                                <td> 
     82                                        <span>Alternative Text</span><br /> 
     83                                        <input id="dojo_insertimage_alt" style="width: 100%" type="text" /><br /> 
     84                                </td> 
     85                        </tr> 
     86                        <tr> 
     87                                <td valign="top"> 
     88                                        <table><tr><td> 
     89                                                                <table cellspacing="0" cellpadding="0" border="0"> 
     90                                                                        <tr> 
     91                                                                                <td nowrap="nowrap"> 
     92                                                                                        <span>Width</span>&nbsp;</td> 
     93                                                                                <td> 
     94                                                                                        <input type="text" size="3" id="dojo_insertimage_width" /></td> 
     95 
     96                                                                                <td rowspan="2"> 
     97                                                                                        <!--div id="btnLockSizes" class="BtnLocked" onmouseover="this.className = (bLockRatio ? 'BtnLocked' : 'BtnUnlocked' ) + ' BtnOver';" 
     98                                                                                                onmouseout="this.className = (bLockRatio ? 'BtnLocked' : 'BtnUnlocked' );" title="Lock Sizes" 
     99                                                                                                onclick="SwitchLock(this);"> 
     100                                                                                        </div--> 
     101                                                                                </td> 
     102                                                                                <td rowspan="2"> 
     103                                                                                        <!--div id="btnResetSize" class="BtnReset" onmouseover="this.className='BtnReset BtnOver';" 
     104                                                                                                onmouseout="this.className='BtnReset';" title="Reset Size" onclick="ResetSizes();"> 
     105                                                                                        </div--> 
     106                                                                                </td> 
     107                                                                        </tr> 
     108 
     109                                                                        <tr> 
     110                                                                                <td nowrap="nowrap"> 
     111                                                                                        <span>Height</span>&nbsp;</td> 
     112                                                                                <td> 
     113                                                                                        <input type="text" size="3" id="dojo_insertimage_height" /></td> 
     114                                                                        </tr> 
     115                                                                </table> 
     116                                                        </td><td> 
     117 
     118                                                                <table cellspacing="0" cellpadding="0" border="0"> 
     119                                                                        <tr> 
     120 
     121                                                                                <td nowrap="nowrap"> 
     122                                                                                        <span >HSpace</span>&nbsp;</td> 
     123                                                                                <td> 
     124                                                                                        <input type="text" size="2" id="dojo_insertimage_hspace"/></td> 
     125                                                                        </tr> 
     126                                                                        <tr> 
     127                                                                                <td nowrap="nowrap"> 
     128                                                                                        <span >VSpace</span>&nbsp;</td> 
     129 
     130                                                                                <td> 
     131                                                                                        <input type="text" size="2" id="dojo_insertimage_vspace" /></td> 
     132                                                                        </tr> 
     133                                                                </table> 
     134                                                        </td></tr> 
     135                                                        <tr><td colspan="2"> 
     136                                                                <table cellspacing="0" cellpadding="0" border="0"> 
     137                                                                        <tr> 
     138                                                                                <td nowrap="nowrap"> 
     139                                                                                        <span>Border</span>&nbsp;</td> 
     140                                                                                <td> 
     141                                                                                        <input type="text" size="2" value="" id="dojo_insertimage_border" /></td> 
     142                                                                                <td>&nbsp;&nbsp;&nbsp;</td> 
     143                                                                                <td nowrap="nowrap"> 
     144                                                                                        <span >Align</span>&nbsp;</td> 
     145                                                                                <td> 
     146                                                                                        <select id="dojo_insertimage_align"> 
     147 
     148                                                                                                <option value="" selected="selected"></option> 
     149                                                                                                <option value="left">Left</option> 
     150                                                                                                <option value="absBottom">Abs Bottom</option> 
     151                                                                                                <option value="absMiddle">Abs Middle</option> 
     152                                                                                                <option value="baseline">Baseline</option> 
     153                                                                                                <option value="bottom">Bottom</option> 
     154 
     155                                                                                                <option value="middle">Middle</option> 
     156                                                                                                <option value="right">Right</option> 
     157                                                                                                <option value="textTop">Text Top</option> 
     158                                                                                                <option value="top">Top</option> 
     159                                                                                        </select> 
     160                                                                                </td> 
     161                                                                        </tr> 
     162                                                                </table> 
     163                                                        </td> 
     164                                                </tr></table> 
     165                                </td> 
     166                        </tr> 
     167                        <tr><td> 
     168                                <table><tr> 
     169                                <td><button dojoType='Button' onClick='scriptScope.ok();'>Ok</button></td> 
     170                                <td><button dojoType='Button' onClick='scriptScope.cancel();'>Cancel</button></td> 
     171                                </tr></table> 
     172                        </td></tr> 
     173                </table> 
     174 No newline at end of file 
  • src/widget/templates/Editor2/Dialog/replace.html

     
     1<script> 
     2_container_.addOnLoad(function(){ 
     3        if(!_container_.refreshOnShow){ 
     4                dojo.event.connect(_container_, "show", this, "init"); 
     5        } 
     6        this.init(); 
     7}); 
     8 
     9this.init = function(){ 
     10//      var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     11//      this.linkNode = dojo.withGlobal(curInst.window, "getAncestorElement", dojo.html.selection, 'a'); 
     12//      var linkAttributes = {}; 
     13//      this.extraAttribText = ""; 
     14//      if(this.linkNode){ 
     15//              var attrs = this.linkNode.attributes; 
     16//              for(var i=0; i<attrs.length; i++) { 
     17//                      if(dojo.lang.find(this.editableAttributes, attrs[i].name.toLowerCase())>-1){ 
     18//                              linkAttributes[attrs[i].name] = attrs[i].value; 
     19//                      }else{ 
     20//                              this.extraAttribText += attrs[i].name + '="'+attrs[i].value+'" '; 
     21//                      } 
     22//              } 
     23//      } 
     24//      for(var i in this.editableAttributes){ 
     25//              name = this.editableAttributes[i]; 
     26//              dojo.byId("dojo_createLink_"+name).value = (linkAttributes[name] == undefined) ? "" : linkAttributes[name] ; 
     27//      } 
     28}; 
     29 
     30this.replace = function(){ 
     31        alert("not implemented yet"); 
     32        return; 
     33        var findcmd = dojo.widget.Editor2Manager.getCommand('find'); 
     34        var option = 0; 
     35 
     36        if(dojo.byId("dojo_replace_option_casesens").checked){ 
     37                option |= findcmd.SearchOption.CaseSensitive; 
     38        } 
     39//      if(dojo.byId("dojo_replace_option_backwards").checked){ 
     40//              option |= findcmd.SearchOption.SearchBackwards; 
     41//      } 
     42//      if(dojo.byId("dojo_replace_option_wholeword").checked){ 
     43//              option |= findcmd.SearchOption.WholeWord; 
     44//      } 
     45        findcmd.execute(dojo.byId("dojo_replace_text").value, option); 
     46}; 
     47 
     48this.replaceAll = function(){ 
     49        alert("not implemented yet"); 
     50}; 
     51 
     52this.cancel = function(){ 
     53        _container_.hide(); 
     54}; 
     55 
     56</script> 
     57<table style="white-space: nowrap;"> 
     58<tr><td>Find: </td><td> <input type="text" id="dojo_replace_text" /></td></tr> 
     59<tr><td>Replace with: </td><td> <input type="text" id="dojo_replace_text" /></td></tr> 
     60<tr><td colspan='2'><table><tr><td><input type="checkbox" dojoType="CheckBox" id="dojo_replace_option_casesens" /> 
     61                <label for="dojo_replace_option_casesens">Case Sensitive</label></td> 
     62                        <td><input type="checkbox" dojoType="CheckBox" id="dojo_replace_option_backwards" /> 
     63                <label for="dojo_replace_option_backwards">Search Backwards</label></td></tr></table></td></tr> 
     64<!-- Does not really work, comment out for now tr><td><input type="checkbox" dojoType="CheckBox" id="dojo_replace_option_wholeword" /> 
     65                <label for="dojo_replace_option_wholeword">Whole Word</label></td> 
     66                        <td><input type="checkbox" dojoType="CheckBox" id="dojo_replace_option_wrapsearch" /> 
     67                <label for="dojo_replace_option_wrapsearch">Wrap Search</label></td></tr--> 
     68</table> 
     69<table><tr> 
     70<td><button dojoType='Button' onClick='scriptScope.replace();'>Replace</button></td> 
     71<td><button dojoType='Button' onClick='scriptScope.replaceAll();'>Replace All</button></td> 
     72<td><button dojoType='Button' onClick='scriptScope.cancel();'>Close</button></td> 
     73</tr></table> 
     74 No newline at end of file 
  • src/widget/templates/Editor2/Dialog/createlink.html

     
     1<script> 
     2_container_.addOnLoad(function(){ 
     3        if(!_container_.refreshOnShow){ 
     4                dojo.event.connect(_container_, "show", this, "init"); 
     5        } 
     6        this.init(); 
     7}); 
     8 
     9this.editableAttributes = ['href', 'target', 'class']; 
     10this.init = function(){ 
     11        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     12 
     13        this.linkNode = dojo.withGlobal(curInst.window, "getAncestorElement", dojo.html.selection, ['a']); 
     14        var linkAttributes = {}; 
     15        this.extraAttribText = ""; 
     16        if(this.linkNode){ 
     17                var attrs = this.linkNode.attributes; 
     18                for(var i=0; i<attrs.length; i++) { 
     19                        if(dojo.lang.find(this.editableAttributes, attrs[i].name.toLowerCase())>-1){ 
     20                                linkAttributes[attrs[i].name] = attrs[i].value; 
     21                        }else{ 
     22                                //IE lists all attributes, even default ones, filter them 
     23                                if(attrs[i].specified == undefined || attrs[i].specified){ 
     24                                        this.extraAttribText += attrs[i].name + '="'+attrs[i].value+'" '; 
     25                                } 
     26                        } 
     27                } 
     28        }else{ 
     29                var html = dojo.withGlobal(curInst.window, "getSelectedText", dojo.html.selection); 
     30                if(html == null || html.length == 0){ 
     31                        alert("Please select some text to create a link."); 
     32                        this.cancel(); 
     33                } 
     34        } 
     35 
     36        for(var i in this.editableAttributes){ 
     37                name = this.editableAttributes[i]; 
     38                dojo.byId("dojo_createLink_"+name).value = (linkAttributes[name] == undefined) ? "" : linkAttributes[name] ; 
     39        } 
     40} 
     41 
     42this.ok = function(){ 
     43        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     44        if(!this.linkNode){ 
     45                var html = dojo.withGlobal(curInst.window, "getSelectedText", dojo.html.selection); 
     46        }else{ 
     47                var html = this.linkNode.innerHTML; 
     48                dojo.withGlobal(curInst.window, "selectElement", dojo.html.selection, [this.linkNode]); 
     49        } 
     50 
     51        var attstr=''; 
     52        for(var i in this.editableAttributes){ 
     53                name = this.editableAttributes[i]; 
     54                var value = dojo.byId("dojo_createLink_"+name).value; 
     55                if(value.length > 0){ 
     56                        attstr += name + '="'+value+'" '; 
     57                } 
     58        } 
     59        curInst.execCommand('inserthtml', '<a '+attstr+this.extraAttribText+'>'+html+'</a>'); 
     60 
     61        this.cancel(); 
     62} 
     63this.cancel = function(){ 
     64        _container_.hide(); 
     65} 
     66</script> 
     67<table> 
     68<tr><td>URL</td><td> <input type="text" id="dojo_createLink_href" name="dojo_createLink_href"/></td></tr> 
     69<tr><td>Target </td><td><select id="dojo_createLink_target"> 
     70        <option value="">Self</option> 
     71        <option value="_blank">New Window</option> 
     72        <option value="_top">Top Window</option> 
     73        </select></td></tr> 
     74<tr><td>Class </td><td><input type="text" id="dojo_createLink_class" /></td></tr> 
     75</table> 
     76<table><tr> 
     77<td><button dojoType='Button' onClick='scriptScope.ok();'>OK</button></td> 
     78<td><button dojoType='Button' onClick='scriptScope.cancel();'>Cancel</button></td> 
     79</tr></table> 
     80 No newline at end of file 
  • src/widget/templates/Editor2/Dialog/find.html

     
     1<script> 
     2_container_.addOnLoad(function(){ 
     3        if(!_container_.refreshOnShow){ 
     4                dojo.event.connect(_container_, "show", this, "init"); 
     5        } 
     6        this.init(); 
     7}); 
     8 
     9this.init = function(){ 
     10//      if(dojo.render.html.ie){ 
     11//              dojo.byId("dojo_find_option_wholeword").parentNode.style.display = ''; 
     12//      } 
     13//      var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     14//      this.linkNode = dojo.withGlobal(curInst.window, "getAncestorElement", dojo.html.selection, ['a']); 
     15//      var linkAttributes = {}; 
     16//      this.extraAttribText = ""; 
     17//      if(this.linkNode){ 
     18//              var attrs = this.linkNode.attributes; 
     19//              for(var i=0; i<attrs.length; i++) { 
     20//                      if(dojo.lang.find(this.editableAttributes, attrs[i].name.toLowerCase())>-1){ 
     21//                              linkAttributes[attrs[i].name] = attrs[i].value; 
     22//                      }else{ 
     23//                              this.extraAttribText += attrs[i].name + '="'+attrs[i].value+'" '; 
     24//                      } 
     25//              } 
     26//      } 
     27//      for(var i in this.editableAttributes){ 
     28//              name = this.editableAttributes[i]; 
     29//              dojo.byId("dojo_createLink_"+name).value = (linkAttributes[name] == undefined) ? "" : linkAttributes[name] ; 
     30//      } 
     31} 
     32 
     33this.find = function(){ 
     34        var findcmd = dojo.widget.Editor2Manager.getCommand('find'); 
     35        var option = 0; 
     36 
     37        if(dojo.byId("dojo_find_option_casesens").checked){ 
     38                option |= findcmd.SearchOption.CaseSensitive; 
     39        } 
     40        if(dojo.byId("dojo_find_option_backwards").checked){ 
     41                option |= findcmd.SearchOption.SearchBackwards; 
     42        } 
     43 
     44        if(dojo.byId("dojo_find_option_wholeword").checked){ 
     45                option |= findcmd.SearchOption.WholeWord; 
     46        } 
     47//      if(dojo.byId("dojo_find_option_wrapsearch").checked){ 
     48//              option |= findcmd.SearchOption.WrapSearch; 
     49//      } 
     50        findcmd.find(dojo.byId("dojo_find_text").value, option); 
     51} 
     52this.cancel = function(){ 
     53        _container_.hide(); 
     54} 
     55</script> 
     56<table style="white-space: nowrap;"> 
     57<tr><td colspan='2'>Find: <input type="text" id="dojo_find_text" /></td></tr> 
     58<tr><td><input type="checkbox" dojoType="CheckBox" id="dojo_find_option_casesens" /> 
     59                <label for="dojo_find_option_casesens">Case Sensitive</label></td> 
     60                        <td><input type="checkbox" dojoType="CheckBox" id="dojo_find_option_backwards" /> 
     61                <label for="dojo_find_option_backwards">Search Backwards</label></td></tr> 
     62<tr><td style="display: none;"><input type="checkbox" dojoType="CheckBox" id="dojo_find_option_wholeword" /> 
     63                <label for="dojo_find_option_wholeword">Whole Word</label></td> 
     64                        <td><!-- Does not really work, comment out for now input type="checkbox" dojoType="CheckBox" id="dojo_find_option_wrapsearch" /> 
     65                <label for="dojo_find_option_wrapsearch">Wrap Search</label--></td></tr> 
     66</table> 
     67<table><tr> 
     68<td><button dojoType='Button' onClick='scriptScope.find();'>Find</button></td> 
     69<td><button dojoType='Button' onClick='scriptScope.cancel();'>Close</button></td> 
     70</tr></table> 
     71 No newline at end of file 
  • src/widget/templates/Editor2/Dialog/insertimage.html

     
     1<script> 
     2_container_.addOnLoad(function(){ 
     3        if(!_container_.refreshOnShow){ 
     4                dojo.event.connect(_container_, "show", this, "init"); 
     5        } 
     6        this.init(); 
     7}); 
     8 
     9this.editableAttributes = ['src', 'alt', 'width', 'height', 'hspace', 'vspace', 'border', 'align']; 
     10 
     11this.init = function(){ 
     12        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     13        this.imageNode = dojo.withGlobal(curInst.window, "getSelectedElement", dojo.html.selection); 
     14        if(!this.imageNode){ 
     15                this.imageNode = dojo.withGlobal(curInst.window, "getAncestorElement", dojo.html.selection, ['img']); 
     16        } 
     17        var imageAttributes = {}; 
     18        this.extraAttribText = ""; 
     19        if(this.imageNode){ 
     20                var attrs = this.imageNode.attributes; 
     21                for(var i=0; i<attrs.length; i++) { 
     22                        if(dojo.lang.find(this.editableAttributes, attrs[i].name.toLowerCase())>-1){ 
     23                                imageAttributes[attrs[i].name] = attrs[i].value; 
     24                        }else{ 
     25                                this.extraAttribText += attrs[i].name + '="'+attrs[i].value+'" '; 
     26                        } 
     27                } 
     28        } 
     29        for(var i in this.editableAttributes){ 
     30                name = this.editableAttributes[i]; 
     31                dojo.byId("dojo_insertimage_"+name).value = (imageAttributes[name] == undefined) ? "" : imageAttributes[name] ; 
     32        } 
     33}; 
     34 
     35this.ok = function(){ 
     36        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     37        var insertcmd = dojo.widget.Editor2Manager.getCommand('inserthtml'); 
     38        var option = 0; 
     39 
     40        var attstr=''; 
     41        for(var i in this.editableAttributes){ 
     42                name = this.editableAttributes[i]; 
     43                var value = dojo.byId("dojo_insertimage_"+name).value; 
     44                if(value.length > 0){ 
     45                        attstr += name + '="'+value+'" '; 
     46                } 
     47        } 
     48        if(this.imageNode){ 
     49                dojo.withGlobal(curInst.window, "selectElement", dojo.html.selection, [this.imageNode]); 
     50        } 
     51        insertcmd.execute('<img '+attstr+this.extraAttribText+'/>'); 
     52        _container_.hide(); 
     53}; 
     54 
     55this.cancel = function(){ 
     56        _container_.hide(); 
     57}; 
     58 
     59</script> 
     60<table cellspacing="1" cellpadding="1" border="0" width="100%" height="100%"> 
     61                        <tr> 
     62                                <td> 
     63                                        <table cellspacing="0" cellpadding="0" width="100%" border="0"> 
     64                                                <tr> 
     65                                                        <td width="100%"> 
     66                                                                <span>URL</span> 
     67                                                        </td> 
     68                                                        <td style="display: none" nowrap="nowrap" rowspan="2"> 
     69                                                                <!--input id="btnBrowse" onclick="BrowseServer();" type="button" value="Browse Server"/--> 
     70                                                        </td> 
     71                                                </tr> 
     72                                                <tr> 
     73                                                        <td valign="top"> 
     74                                                                <input id="dojo_insertimage_src" style="width: 100%" type="text" /> 
     75                                                        </td> 
     76                                                </tr> 
     77                                        </table> 
     78                                </td> 
     79                        </tr> 
     80                        <tr> 
     81                                <td> 
     82                                        <span>Alternative Text</span><br /> 
     83                                        <input id="dojo_insertimage_alt" style="width: 100%" type="text" /><br /> 
     84                                </td> 
     85                        </tr> 
     86                        <tr> 
     87                                <td valign="top"> 
     88                                        <table><tr><td> 
     89                                                                <table cellspacing="0" cellpadding="0" border="0"> 
     90                                                                        <tr> 
     91                                                                                <td nowrap="nowrap"> 
     92                                                                                        <span>Width</span>&nbsp;</td> 
     93                                                                                <td> 
     94                                                                                        <input type="text" size="3" id="dojo_insertimage_width" /></td> 
     95 
     96                                                                                <td rowspan="2"> 
     97                                                                                        <!--div id="btnLockSizes" class="BtnLocked" onmouseover="this.className = (bLockRatio ? 'BtnLocked' : 'BtnUnlocked' ) + ' BtnOver';" 
     98                                                                                                onmouseout="this.className = (bLockRatio ? 'BtnLocked' : 'BtnUnlocked' );" title="Lock Sizes" 
     99                                                                                                onclick="SwitchLock(this);"> 
     100                                                                                        </div--> 
     101                                                                                </td> 
     102                                                                                <td rowspan="2"> 
     103                                                                                        <!--div id="btnResetSize" class="BtnReset" onmouseover="this.className='BtnReset BtnOver';" 
     104                                                                                                onmouseout="this.className='BtnReset';" title="Reset Size" onclick="ResetSizes();"> 
     105                                                                                        </div--> 
     106                                                                                </td> 
     107                                                                        </tr> 
     108 
     109                                                                        <tr> 
     110                                                                                <td nowrap="nowrap"> 
     111                                                                                        <span>Height</span>&nbsp;</td> 
     112                                                                                <td> 
     113                                                                                        <input type="text" size="3" id="dojo_insertimage_height" /></td> 
     114                                                                        </tr> 
     115                                                                </table> 
     116                                                        </td><td> 
     117 
     118                                                                <table cellspacing="0" cellpadding="0" border="0"> 
     119                                                                        <tr> 
     120 
     121                                                                                <td nowrap="nowrap"> 
     122                                                                                        <span >HSpace</span>&nbsp;</td> 
     123                                                                                <td> 
     124                                                                                        <input type="text" size="2" id="dojo_insertimage_hspace"/></td> 
     125                                                                        </tr> 
     126                                                                        <tr> 
     127                                                                                <td nowrap="nowrap"> 
     128                                                                                        <span >VSpace</span>&nbsp;</td> 
     129 
     130                                                                                <td> 
     131                                                                                        <input type="text" size="2" id="dojo_insertimage_vspace" /></td> 
     132                                                                        </tr> 
     133                                                                </table> 
     134                                                        </td></tr> 
     135                                                        <tr><td colspan="2"> 
     136                                                                <table cellspacing="0" cellpadding="0" border="0"> 
     137                                                                        <tr> 
     138                                                                                <td nowrap="nowrap"> 
     139                                                                                        <span>Border</span>&nbsp;</td> 
     140                                                                                <td> 
     141                                                                                        <input type="text" size="2" value="" id="dojo_insertimage_border" /></td> 
     142                                                                                <td>&nbsp;&nbsp;&nbsp;</td> 
     143                                                                                <td nowrap="nowrap"> 
     144                                                                                        <span >Align</span>&nbsp;</td> 
     145                                                                                <td> 
     146                                                                                        <select id="dojo_insertimage_align"> 
     147 
     148                                                                                                <option value="" selected="selected"></option> 
     149                                                                                                <option value="left">Left</option> 
     150                                                                                                <option value="absBottom">Abs Bottom</option> 
     151                                                                                                <option value="absMiddle">Abs Middle</option> 
     152                                                                                                <option value="baseline">Baseline</option> 
     153                                                                                                <option value="bottom">Bottom</option> 
     154 
     155                                                                                                <option value="middle">Middle</option> 
     156                                                                                                <option value="right">Right</option> 
     157                                                                                                <option value="textTop">Text Top</option> 
     158                                                                                                <option value="top">Top</option> 
     159                                                                                        </select> 
     160                                                                                </td> 
     161                                                                        </tr> 
     162                                                                </table> 
     163                                                        </td> 
     164                                                </tr></table> 
     165                                </td> 
     166                        </tr> 
     167                        <tr><td> 
     168                                <table><tr> 
     169                                <td><button dojoType='Button' onClick='scriptScope.ok();'>Ok</button></td> 
     170                                <td><button dojoType='Button' onClick='scriptScope.cancel();'>Cancel</button></td> 
     171                                </tr></table> 
     172                        </td></tr> 
     173                </table> 
     174 No newline at end of file 
  • src/widget/templates/Editor2/Dialog/inserttable.html

     
     1<script> 
     2_container_.addOnLoad(function(){ 
     3        if(!_container_.refreshOnShow){ 
     4                dojo.event.connect(_container_, "show", this, "init"); 
     5        } 
     6        this.init(); 
     7}); 
     8 
     9this.editableAttributes = ['summery', 'height', 'cellspacing', 'cellpadding', 'border', 'align']; 
     10 
     11this.init = function(){ 
     12        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     13        this.tableNode = dojo.withGlobal(curInst.window, "getSelectedElement", dojo.html.selection); 
     14        if(!this.tableNode || this.tableNode.tagName.toLowerCase() != 'table'){ 
     15                this.tableNode = dojo.withGlobal(curInst.window, "getAncestorElement", dojo.html.selection, ['table']); 
     16        } 
     17 
     18        var tableAttributes = {}; 
     19        this.extraAttribText = ""; 
     20        if(this.tableNode){ 
     21                dojo.byId("dojo_inserttable_rows").value = this.tableNode.rows.length; 
     22                dojo.byId("dojo_inserttable_rows").disabled = true; 
     23                dojo.byId("dojo_inserttable_cols").value = this.tableNode.rows[0].cells.length; 
     24                dojo.byId("dojo_inserttable_cols").disabled = true; 
     25 
     26                if (this.tableNode.caption){ 
     27                        dojo.byId("dojo_inserttable_caption").value = this.tableNode.caption.innerHTML; 
     28                }else{ 
     29                        dojo.byId("dojo_inserttable_caption").value = ""; 
     30                } 
     31 
     32                var width = this.tableNode.style.width || this.tableNode.width; 
     33                if(width){ 
     34                        dojo.byId("dojo_inserttable_width").value = parseInt(width); 
     35                        if (width.indexOf('%') > -1){ 
     36                                dojo.byId("dojo_inserttable_widthtype").value = "percent"; 
     37                        }else{ 
     38                                dojo.byId("dojo_inserttable_widthtype").value = "pixels"; 
     39                        } 
     40                }else{ 
     41                        dojo.byId("dojo_inserttable_width").value = "100"; 
     42                } 
     43 
     44                var height = this.tableNode.style.height || this.tableNode.height; 
     45                if(height){ 
     46                        dojo.byId("dojo_inserttable_height").value = parseInt(width); 
     47                }else{ 
     48                        dojo.byId("dojo_inserttable_height").value = ""; 
     49                } 
     50 
     51                var attrs = this.tableNode.attributes; 
     52                for(var i=0; i<attrs.length; i++) { 
     53                        if(dojo.lang.find(this.editableAttributes, attrs[i].name.toLowerCase())>-1){ 
     54                                tableAttributes[attrs[i].name] = attrs[i].value; 
     55                        }else{ 
     56                                this.extraAttribText += attrs[i].name + '="'+attrs[i].value+'" '; 
     57                        } 
     58                } 
     59        }else{ 
     60                dojo.byId("dojo_inserttable_rows").value = 3; 
     61                dojo.byId("dojo_inserttable_rows").disabled = false; 
     62                dojo.byId("dojo_inserttable_cols").value = 2; 
     63                dojo.byId("dojo_inserttable_cols").disabled = false; 
     64                dojo.byId("dojo_inserttable_width").value = 100; 
     65                dojo.byId("dojo_inserttable_widthtype").value = "percent"; 
     66                dojo.byId("dojo_inserttable_height").value = ""; 
     67        } 
     68 
     69        for(var i in this.editableAttributes){ 
     70                name = this.editableAttributes[i]; 
     71                dojo.byId("dojo_inserttable_"+name).value = (tableAttributes[name] == undefined) ? "" : tableAttributes[name]; 
     72                if(name == 'height' && tableAttributes[name] != undefined){ 
     73                        dojo.byId("dojo_inserttable_"+name).value = tableAttributes[name]; 
     74                } 
     75        } 
     76}; 
     77 
     78this.ok = function(){ 
     79        var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     80        var args = {}; 
     81 
     82        args['rows'] = dojo.byId("dojo_inserttable_rows").value; 
     83        args['cols'] = dojo.byId("dojo_inserttable_cols").value; 
     84        args['caption'] = dojo.byId("dojo_inserttable_caption").value; 
     85        args["tableattrs"] = ""; 
     86        if(dojo.byId("dojo_inserttable_widthtype").value == "percent"){ 
     87                args["tableattrs"] += 'width="'+dojo.byId("dojo_inserttable_width").value +'%" '; 
     88        }else{ 
     89                args["tableattrs"] += 'width="'+dojo.byId("dojo_inserttable_width").value +'px" '; 
     90        } 
     91        for(var i in this.editableAttributes){ 
     92                var name = this.editableAttributes[i]; 
     93                var value = dojo.byId("dojo_inserttable_"+name).value; 
     94                if(value.length > 0){ 
     95                        args["tableattrs"] += name + '="'+value+'" '; 
     96                } 
     97        } 
     98 
     99        if(!args["tableattrs"]){ 
     100                args["tableattrs"] = ""; 
     101        } 
     102 
     103        //show the border in IE by applying a custom class 
     104        if(dojo.render.html.ie && !dojo.byId("dojo_inserttable_border").value){ 
     105                args["tableattrs"] += 'class="dojoShowIETableBorders" '; 
     106        } 
     107 
     108        var html = "<table "+args["tableattrs"]+">"; 
     109        if(args['caption']){ 
     110                html += "<caption>"+args["caption"]+"</caption>"; 
     111        } 
     112        var outertbody = "<tbody>"; 
     113        if(this.tableNode){ 
     114                //retain the content 
     115                var tbody = this.tableNode.getElementsByTagName("tbody")[0]; 
     116                outertbody = tbody.outerHTML; 
     117                if(!outertbody){ 
     118                        var cnode = tbody.cloneNode(true); 
     119                        var tmpnode = tbody.ownerDocument.createElement("div"); 
     120                        tmpnode.appendChild(cnode); 
     121                        outertbody = tmpnode.innerHTML; 
     122                } 
     123                //TODO: save current selection and restore it later 
     124                dojo.withGlobal(curInst.window, "selectElement", dojo.html.selection, [this.tableNode]); 
     125        }else{ 
     126                var cols = "<tr>"; 
     127                for (var i = 0; i < +args.cols; i++) { cols += "<td></td>"; } 
     128                cols += "</tr>"; 
     129                for (var i = 0; i < args.rows; i++) { outertbody += cols; } 
     130                outertbody += "</tbody>"; 
     131        } 
     132        html += outertbody+"</table>"; 
     133        curInst.execCommand("inserthtml", html); 
     134 
     135        _container_.hide(); 
     136}; 
     137 
     138this.cancel = function(){ 
     139        _container_.hide(); 
     140}; 
     141 
     142</script> 
     143<table cellSpacing="1" cellPadding="1" width="100%" border="0"> 
     144        <tr> 
     145                <td valign="top"> 
     146                        <table cellSpacing="0" cellPadding="0" border="0"> 
     147                                <tr> 
     148 
     149                                        <td><span>Rows</span>:</td> 
     150                                        <td>&nbsp;<input id="dojo_inserttable_rows" type="text" maxLength="3" size="2" value="3"></td> 
     151                                </tr> 
     152                                <tr> 
     153                                        <td><span>Columns</span>:</td> 
     154                                        <td>&nbsp;<input id="dojo_inserttable_cols" type="text" maxLength="2" size="2" value="2"></td> 
     155                                </tr> 
     156 
     157                                <tr> 
     158                                        <td>&nbsp;</td> 
     159                                        <td>&nbsp;</td> 
     160                                </tr> 
     161                                <tr> 
     162                                        <td><span>Border size</span>:</td> 
     163                                        <td>&nbsp;<INPUT id="dojo_inserttable_border" type="text" maxLength="2" size="2" value="1"></td> 
     164                                </tr> 
     165 
     166                                <tr> 
     167                                        <td><span>Alignment</span>:</td> 
     168                                        <td>&nbsp;<select id="dojo_inserttable_align"> 
     169                                                        <option value="" selected>&lt;Not set&gt;</option> 
     170                                                        <option value="left">Left</option> 
     171                                                        <option value="center">Center</option> 
     172                                                        <option value="right">Right</option> 
     173                                                </select></td> 
     174                                </tr> 
     175                        </table> 
     176                </td> 
     177                <td>&nbsp;&nbsp;&nbsp;</td> 
     178                <td align="right" valign="top"> 
     179                        <table cellSpacing="0" cellPadding="0" border="0"> 
     180                                <tr> 
     181                                        <td><span>Width</span>:</td> 
     182                                        <td>&nbsp;<input id="dojo_inserttable_width" type="text" maxLength="4" size="3"></td> 
     183                                        <td>&nbsp;<select id="dojo_inserttable_widthtype"> 
     184                                                        <option value="percent" selected>percent</option> 
     185                                                        <option value="pixels">pixels</option> 
     186                                                </select></td> 
     187 
     188                                </tr> 
     189                                <tr> 
     190                                        <td><span>Height</span>:</td> 
     191                                        <td>&nbsp;<INPUT id="dojo_inserttable_height" type="text" maxLength="4" size="3"></td> 
     192                                        <td>&nbsp;<span>pixels</span></td> 
     193                                </tr> 
     194                                <tr> 
     195                                        <td>&nbsp;</td> 
     196                                        <td>&nbsp;</td> 
     197                                        <td>&nbsp;</td> 
     198                                </tr> 
     199                                <tr> 
     200                                        <td nowrap><span>Cell spacing</span>:</td> 
     201                                        <td>&nbsp;<input id="dojo_inserttable_cellspacing" type="text" maxLength="2" size="2" value="1"></td> 
     202                                        <td>&nbsp;</td> 
     203 
     204                                </tr> 
     205                                <tr> 
     206                                        <td nowrap><span>Cell padding</span>:</td> 
     207                                        <td>&nbsp;<input id="dojo_inserttable_cellpadding" type="text" maxLength="2" size="2" value="1"></td> 
     208                                        <td>&nbsp;</td> 
     209                                </tr> 
     210                        </table> 
     211                </td> 
     212        </tr> 
     213</table> 
     214<table cellSpacing="0" cellPadding="0" width="100%" border="0"> 
     215        <tr> 
     216                <td nowrap><span>Caption</span>:</td> 
     217                <td>&nbsp;</td> 
     218                <td width="100%" nowrap>&nbsp; 
     219                        <input id="dojo_inserttable_caption" type="text" style="WIDTH: 90%"></td> 
     220        </tr> 
     221        <tr> 
     222                <td nowrap><span>Summary</span>:</td> 
     223                <td>&nbsp;</td> 
     224                <td width="100%" nowrap>&nbsp; 
     225                        <input id="dojo_inserttable_summery" type="text" style="WIDTH: 90%"></td> 
     226        </tr> 
     227</table> 
     228<table><tr> 
     229<td><button dojoType='Button' onClick='scriptScope.ok();'>Ok</button></td> 
     230<td><button dojoType='Button' onClick='scriptScope.cancel();'>Cancel</button></td> 
     231</tr></table> 
     232 No newline at end of file 
  • src/widget/templates/Editor2/Dialog/replace.html

     
     1<script> 
     2_container_.addOnLoad(function(){ 
     3        if(!_container_.refreshOnShow){ 
     4                dojo.event.connect(_container_, "show", this, "init"); 
     5        } 
     6        this.init(); 
     7}); 
     8 
     9this.init = function(){ 
     10//      var curInst = dojo.widget.Editor2Manager.getCurrentInstance(); 
     11//      this.linkNode = dojo.withGlobal(curInst.window, "getAncestorElement", dojo.html.selection, 'a'); 
     12//      var linkAttributes = {}; 
     13//      this.extraAttribText = ""; 
     14//      if(this.linkNode){ 
     15//              var attrs = this.linkNode.attributes; 
     16//              for(var i=0; i<attrs.length; i++) { 
     17//                      if(dojo.lang.find(this.editableAttributes, attrs[i].name.toLowerCase())>-1){ 
     18//                              linkAttributes[attrs[i].name] = attrs[i].value; 
     19//                      }else{ 
     20//                              this.extraAttribText += attrs[i].name + '="'+attrs[i].value+'" '; 
     21//                      } 
     22//              } 
     23//      } 
     24//      for(var i in this.editableAttributes){ 
     25//              name = this.editableAttributes[i]; 
     26//              dojo.byId("dojo_createLink_"+name).value = (linkAttributes[name] == undefined) ? "" : linkAttributes[name] ; 
     27//      } 
     28}; 
     29 
     30this.replace = function(){ 
     31        alert("not implemented yet"); 
     32        return; 
     33        var findcmd = dojo.widget.Editor2Manager.getCommand('find'); 
     34        var option = 0; 
     35 
     36        if(dojo.byId("dojo_replace_option_casesens").checked){ 
     37                option |= findcmd.SearchOption.CaseSensitive; 
     38        } 
     39//      if(dojo.byId("dojo_replace_option_backwards").checked){ 
     40//              option |= findcmd.SearchOption.SearchBackwards; 
     41//      } 
     42//      if(dojo.byId("dojo_replace_option_wholeword").checked){ 
     43//              option |= findcmd.SearchOption.WholeWord; 
     44//      } 
     45        findcmd.execute(dojo.byId("dojo_replace_text").value, option); 
     46}; 
     47 
     48this.replaceAll = function(){ 
     49        alert("not implemented yet"); 
     50}; 
     51 
     52this.cancel = function(){ 
     53        _container_.hide(); 
     54}; 
     55 
     56</script> 
     57<table style="white-space: nowrap;"> 
     58<tr><td>Find: </td><td> <input type="text" id="dojo_replace_text" /></td></tr> 
     59<tr><td>Replace with: </td><td> <input type="text" id="dojo_replace_text" /></td></tr> 
     60<tr><td colspan='2'><table><tr><td><input type="checkbox" dojoType="CheckBox" id="dojo_replace_option_casesens" /> 
     61                <label for="dojo_replace_option_casesens">Case Sensitive</label></td> 
     62                        <td><input type="checkbox" dojoType="CheckBox" id="dojo_replace_option_backwards" /> 
     63                <label for="dojo_replace_option_backwards">Search Backwards</label></td></tr></table></td></tr> 
     64<!-- Does not really work, comment out for now tr><td><input type="checkbox" dojoType="CheckBox" id="dojo_replace_option_wholeword" /> 
     65                <label for="dojo_replace_option_wholeword">Whole Word</label></td> 
     66                        <td><input type="checkbox" dojoType="CheckBox" id="dojo_replace_option_wrapsearch" /> 
     67                <label for="dojo_replace_option_wrapsearch">Wrap Search</label></td></tr--> 
     68</table> 
     69<table><tr> 
     70<td><button dojoType='Button' onClick='scriptScope.replace();'>Replace</button></td> 
     71<td><button dojoType='Button' onClick='scriptScope.replaceAll();'>Replace All</button></td> 
     72<td><button dojoType='Button' onClick='scriptScope.cancel();'>Close</button></td> 
     73</tr></table> 
     74 No newline at end of file 
  • src/widget/templates/Editor2/EditorDialog.html

     
     1<div id="${this.widgetId}" dojoAttachEvent="onMouseDown" class="dojoFloatingPane"> 
     2        <div dojoAttachPoint="titleBar" class="dojoFloatingPaneTitleBar"  style="display:none"> 
     3                <img dojoAttachPoint="titleBarIcon"  class="dojoFloatingPaneTitleBarIcon"> 
     4                <div dojoAttachPoint="closeAction" dojoAttachEvent="onClick:hide" 
     5                        class="dojoFloatingPaneCloseIcon"></div> 
     6                <div dojoAttachPoint="restoreAction" dojoAttachEvent="onClick:restoreWindow" 
     7                        class="dojoFloatingPaneRestoreIcon"></div> 
     8                <div dojoAttachPoint="maximizeAction" dojoAttachEvent="onClick:maximizeWindow" 
     9                        class="dojoFloatingPaneMaximizeIcon"></div> 
     10                <div dojoAttachPoint="minimizeAction" dojoAttachEvent="onClick:minimizeWindow" 
     11                        class="dojoFloatingPaneMinimizeIcon"></div> 
     12                <div dojoAttachPoint="titleBarText" class="dojoFloatingPaneTitleText">${this.title}</div> 
     13        </div> 
     14 
     15        <div id="${this.widgetId}_container" dojoAttachPoint="containerNode" class="dojoFloatingPaneClient"></div> 
     16 
     17        <div dojoAttachPoint="resizeBar" class="dojoFloatingPaneResizebar" style="display:none"></div> 
     18</div> 
     19 No newline at end of file 
  • src/widget/templates/Editor2/EditorToolbar_FontName.html

     
     1<div class="SC_Panel" style="width: 150px; height: 150px;"> 
     2        <div class="SC_Item" dropDownItemName="Arial"> 
     3                <font face="Arial" style="font-size: 12px;">Arial</font> 
     4        </div> 
     5        <div class="SC_Item" dropDownItemName="Comic Sans MS"> 
     6                <font face="Comic Sans MS" style="font-size: 12px;">Comic Sans MS</font> 
     7        </div> 
     8        <div class="SC_Item" dropDownItemName="Courier New"> 
     9                <font face="Courier New" style="font-size: 12px;">Courier New</font> 
     10        </div> 
     11        <div class="SC_Item" dropDownItemName="Tahoma"> 
     12                <font face="Tahoma" style="font-size: 12px;">Tahoma</font> 
     13        </div> 
     14        <div class="SC_Item" dropDownItemName="Times New Roman"> 
     15                <font face="Times New Roman" style="font-size: 12px;">Times New Roman</font> 
     16        </div> 
     17        <div class="SC_Item" dropDownItemName="Verdana"> 
     18                <font face="Verdana" style="font-size: 12px;">Verdana</font> 
     19        </div> 
     20</div> 
     21 No newline at end of file 
  • src/widget/templates/Editor2/EditorToolbar_FontSize.html

     
     1<div class="SC_Panel" style="width: 150px; height: 150px;"> 
     2<table width="100%" cellspacing="0" cellpadding="0" style="table-layout: fixed;"> 
     3<tbody> 
     4<tr> 
     5<td nowrap=""> 
     6        <div class="SC_Item" dropDownItemName="1"> 
     7        <font size="1">xx-small</font> 
     8        </div> 
     9        <div class="SC_Item" dropDownItemName="2"> 
     10        <font size="2">x-small</font> 
     11        </div> 
     12        <div class="SC_Item" dropDownItemName="3"> 
     13        <font size="3">small</font> 
     14        </div> 
     15        <div class="SC_Item" dropDownItemName="4"> 
     16        <font size="4">medium</font> 
     17        </div> 
     18        <div class="SC_Item" dropDownItemName="5"> 
     19        <font size="5">large</font> 
     20        </div> 
     21        <div class="SC_Item" dropDownItemName="6"> 
     22        <font size="6">x-large</font> 
     23        </div> 
     24        <div class="SC_Item" dropDownItemName="7"> 
     25        <font size="7">xx-large</font> 
     26        </div> 
     27</td> 
     28</tr> 
     29</tbody> 
     30</table> 
     31</div> 
     32 No newline at end of file 
  • src/widget/templates/Editor2/EditorToolbar_FormatBlock.html

     
     1<div class="SC_Panel" style="width: 190px; height: 150px;"> 
     2        <div class="SC_Item" dropDownItemName="p"> 
     3                <div class="BaseFont"> 
     4                        <p>Normal</p> 
     5                </div> 
     6        </div> 
     7        <div class="SC_Item" dropDownItemName="div"> 
     8                <div class="BaseFont"> 
     9                        <div>Normal (DIV)</div> 
     10                </div> 
     11        </div> 
     12        <div class="SC_Item" dropDownItemName="pre"> 
     13                <div class="BaseFont"> 
     14                        <pre>Formatted</pre> 
     15                </div> 
     16        </div> 
     17        <div class="SC_Item" dropDownItemName="address"> 
     18                <div class="BaseFont"> 
     19                        <address>Address</address> 
     20                </div> 
     21        </div> 
     22        <div class="SC_Item" dropDownItemName="h1"> 
     23                <div class="BaseFont"> 
     24                        <h1>Heading 1</h1> 
     25                </div> 
     26        </div> 
     27        <div class="SC_Item" dropDownItemName="h2"> 
     28                <div class="BaseFont"> 
     29                        <h2>Heading 2</h2> 
     30                </div> 
     31        </div> 
     32        <div class="SC_Item" dropDownItemName="h3"> 
     33                <div class="BaseFont"> 
     34                        <h3>Heading 3</h3> 
     35                </div> 
     36        </div> 
     37        <div class="SC_Item" dropDownItemName="h4"> 
     38                <div class="BaseFont"> 
     39                        <h4>Heading 4</h4> 
     40                </div> 
     41        </div> 
     42        <div class="SC_Item" dropDownItemName="h5"> 
     43                <div class="BaseFont"> 
     44                        <h5>Heading 5</h5> 
     45                </div> 
     46        </div> 
     47        <div class="SC_Item" dropDownItemName="h6"> 
     48                <div class="BaseFont"> 
     49                        <h6>Heading 6</h6> 
     50                </div> 
     51        </div> 
     52</div> 
     53 No newline at end of file 
  • src/widget/templates/Editor2/showtableborder_gecko.css

     
     1/* For tables with the "border" attribute set to "0" */ 
     2table[border="0"],  
     3table[border="0"] > tr > td, table[border="0"] > tr > th,  
     4table[border="0"] > tbody > tr > td, table[border="0"] > tbody > tr > th,  
     5table[border="0"] > thead > tr > td, table[border="0"] > thead > tr > th,  
     6table[border="0"] > tfoot > tr > td, table[border="0"] > tfoot > tr > th 
     7{ 
     8        border: #d3d3d3 1px dotted ; 
     9} 
     10 
     11/* For tables with no "border" attribute set */ 
     12table:not([border]),  
     13table:not([border]) > tr > td, table:not([border]) > tr > th, 
     14table:not([border]) > tbody > tr > td, table:not([border]) > tbody > tr > th, 
     15table:not([border]) > thead > tr > td, table:not([border]) > thead > tr > th, 
     16table:not([border]) > tfoot > tr > td, table:not([border]) > tfoot > tr > th 
     17{ 
     18        border: #d3d3d3 1px dotted ; 
     19} 
     20 No newline at end of file 
  • src/widget/templates/Editor2/showtableborder_ie.css

     
     1table.dojoShowIETableBorders, table.dojoShowIETableBorders td, table.dojoShowIETableBorders th 
     2{ 
     3        border: #d3d3d3 1px solid; 
     4} 
     5 No newline at end of file 
  • src/widget/templates/EditorToolbar.css

     
    6666        _border: none; 
    6767} 
    6868 
    69 span.icon { 
     69.dojoE2TBIcon { 
    7070        display: block; 
    7171        text-align: center; 
    7272        min-width: 18px; 
     
    7878} 
    7979 
    8080 
    81 span.icon[class~=icon] { 
     81.dojoE2TBIcon[class~=dojoE2TBIcon] { 
    8282} 
    8383 
     84.ToolbarButtonLatched { 
     85    border: #316ac5 1px solid; 
     86    background-color: #c1d2ee; 
     87} 
     88 
     89.ToolbarButtonHighlighted { 
     90    border: #316ac5 1px solid; 
     91    background-color: #dff1ff; 
     92} 
     93 
     94.ToolbarButtonDisabled{ 
     95    filter: gray() alpha(opacity=30); /* IE */ 
     96    opacity: 0.30; /* Safari, Opera and Mozilla */ 
     97} 
     98 
    8499.headingContainer { 
    85100        width: 150px; 
    86101        height: 30px; 
     
    95110.EditorToolbarDomNode select { 
    96111        font-size: 14px; 
    97112} 
     113  
     114.dojoE2TBIcon_Sep { width: 5px; min-width: 5px; max-width: 5px; background-position: 0px 0px} 
     115.dojoE2TBIcon_Backcolor { background-position: -18px 0px} 
     116.dojoE2TBIcon_Bold { background-position: -36px 0px} 
     117.dojoE2TBIcon_Cancel { background-position: -54px 0px} 
     118.dojoE2TBIcon_Copy { background-position: -72px 0px} 
     119.dojoE2TBIcon_Link { background-position: -90px 0px} 
     120.dojoE2TBIcon_Cut { background-position: -108px 0px} 
     121.dojoE2TBIcon_Delete { background-position: -126px 0px} 
     122.dojoE2TBIcon_TextColor { background-position: -144px 0px} 
     123.dojoE2TBIcon_BackgroundColor { background-position: -162px 0px} 
     124.dojoE2TBIcon_Indent { background-position: -180px 0px} 
     125.dojoE2TBIcon_HorizontalLine { background-position: -198px 0px} 
     126.dojoE2TBIcon_Image { background-position: -216px 0px} 
     127.dojoE2TBIcon_NumberedList { background-position: -234px 0px} 
     128.dojoE2TBIcon_Table { background-position: -252px 0px} 
     129.dojoE2TBIcon_BulletedList { background-position: -270px 0px} 
     130.dojoE2TBIcon_Italic { background-position: -288px 0px} 
     131.dojoE2TBIcon_CenterJustify { background-position: -306px 0px} 
     132.dojoE2TBIcon_BlockJustify { background-position: -324px 0px} 
     133.dojoE2TBIcon_LeftJustify { background-position: -342px 0px} 
     134.dojoE2TBIcon_RightJustify { background-position: -360px 0px} 
     135.dojoE2TBIcon_left_to_right { background-position: -378px 0px} 
     136.dojoE2TBIcon_list_bullet_indent { background-position: -396px 0px} 
     137.dojoE2TBIcon_list_bullet_outdent { background-position: -414px 0px} 
     138.dojoE2TBIcon_list_num_indent { background-position: -432px 0px} 
     139.dojoE2TBIcon_list_num_outdent { background-position: -450px 0px} 
     140.dojoE2TBIcon_Outdent { background-position: -468px 0px} 
     141.dojoE2TBIcon_Paste { background-position: -486px 0px} 
     142.dojoE2TBIcon_Redo { background-position: -504px 0px} 
     143dojoE2TBIcon_RemoveFormat { background-position: -522px 0px} 
     144.dojoE2TBIcon_right_to_left { background-position: -540px 0px} 
     145.dojoE2TBIcon_Save { background-position: -558px 0px} 
     146.dojoE2TBIcon_Space { background-position: -576px 0px} 
     147.dojoE2TBIcon_StrikeThrough { background-position: -594px 0px} 
     148.dojoE2TBIcon_Subscript { background-position: -612px 0px} 
     149.dojoE2TBIcon_Superscript { background-position: -630px 0px} 
     150.dojoE2TBIcon_Underline { background-position: -648px 0px} 
     151.dojoE2TBIcon_Undo { background-position: -666px 0px} 
     152.dojoE2TBIcon_WikiWord { background-position: -684px 0px} 
    98153 
    99 .sep { width: 5px; min-width: 5px; max-width: 5px; background-position: 0px 0px} 
    100 .backcolor { background-position: -18px 0px} 
    101 .bold { background-position: -36px 0px} 
    102 .cancel { background-position: -54px 0px} 
    103 .copy { background-position: -72px 0px} 
    104 .createlink { background-position: -90px 0px} 
    105 .cut { background-position: -108px 0px} 
    106 .delete { background-position: -126px 0px} 
    107 .forecolor { background-position: -144px 0px} 
    108 .hilitecolor { background-position: -162px 0px} 
    109 .indent { background-position: -180px 0px} 
    110 .inserthorizontalrule { background-position: -198px 0px} 
    111 .insertimage { background-position: -216px 0px} 
    112 .insertorderedlist { background-position: -234px 0px} 
    113 .inserttable { background-position: -252px 0px} 
    114 .insertunorderedlist { background-position: -270px 0px} 
    115 .italic { background-position: -288px 0px} 
    116 .justifycenter { background-position: -306px 0px} 
    117 .justifyfull { background-position: -324px 0px} 
    118 .justifyleft { background-position: -342px 0px} 
    119 .justifyright { background-position: -360px 0px} 
    120 .left_to_right { background-position: -378px 0px} 
    121 .list_bullet_indent { background-position: -396px 0px} 
    122 .list_bullet_outdent { background-position: -414px 0px} 
    123 .list_num_indent { background-position: -432px 0px} 
    124 .list_num_outdent { background-position: -450px 0px} 
    125 .outdent { background-position: -468px 0px} 
    126 .paste { background-position: -486px 0px} 
    127 .redo { background-position: -504px 0px} 
    128 .removeformat { background-position: -522px 0px} 
    129 .right_to_left { background-position: -540px 0px} 
    130 .save { background-position: -558px 0px} 
    131 .space { background-position: -576px 0px} 
    132 .strikethrough { background-position: -594px 0px} 
    133 .subscript { background-position: -612px 0px} 
    134 .superscript { background-position: -630px 0px} 
    135 .underline { background-position: -648px 0px} 
    136 .undo { background-position: -666px 0px} 
    137 .wikiword { background-position: -684px 0px} 
    138  
  • src/widget/templates/EditorToolbarOneline.html

     
    1 <div class="EditorToolbarDomNode EditorToolbarSmallBg"  
    2         unselectable="on" dojoOnMouseDown="preventSelect"> 
     1<div class="EditorToolbarDomNode EditorToolbarSmallBg"> 
    32        <table cellpadding="1" cellspacing="0" border="0"> 
    43                <!-- 
    54                        toobar options, in order: 
     
    2625 
    2726                --> 
    2827                <tbody> 
    29                         <tr valign="top" align="left" dojoAttachPoint="oneLineTr"> 
     28                        <tr valign="top" align="left"> 
    3029                                <td> 
    3130                                        <!-- htmltoggle --> 
    32                                         <span class="iconContainer" dojoAttachPoint="htmltoggleButton" 
    33                                                 dojoOnClick="htmltoggleClick; buttonClick;" style="display: none;"> 
    34                                                 <span title="Toggle Rich Text and HTML Markup Editing Modes" class="icon"  
    35                                                 style="background-image: none; width: 30px;"  
    36                                                 unselectable="on">&lt;h&gt;</span> 
     31                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="htmltoggle"> 
     32                                                <span title="Toggle Rich Text and HTML Markup Editing Modes" class="dojoE2TBIcon"  
     33                                                style="background-image: none; width: 30px;" >&lt;h&gt;</span> 
    3734                                        </span> 
    3835                                </td> 
    39                                 <td> 
    40                                         <!-- wikiword --> 
     36                                <!-- wikiword --> 
     37                                <!--td> 
    4138                                        <span class="iconContainer" dojoAttachPoint="wikiwordButton" 
    4239                                                dojoOnClick="wikiwordClick; buttonClick;" style="display: none;"> 
    43                                                 <span title="Toggle Wiki Word" class="icon wikiword"  
     40                                                <span title="Toggle Wiki Word" class="dojoE2TBIcon dojoE2TBIcon_wikiword"  
    4441                                                unselectable="on">&nbsp;</span> 
    4542                                        </span> 
    46                                 </td> 
     43                                </td--> 
    4744                                <td> 
    48                                         <!-- paste --> 
    49                                         <span class="iconContainer" dojoAttachPoint="copyButton" 
    50                                                 unselectable="on" dojoOnClick="copyClick; buttonClick;"> 
    51                                                 <span title="Copy (Ctrl-C)" class="icon copy" unselectable="on">&nbsp;</span> 
     45                                        <!-- copy --> 
     46                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="copy"> 
     47                                                <span title="Copy (Ctrl-C)" class="dojoE2TBIcon dojoE2TBIcon_Copy">&nbsp;</span> 
    5248                                        </span> 
    5349                                </td> 
    5450                                <td> 
    55                                         <!-- copy --> 
    56                                         <span class="iconContainer" dojoAttachPoint="pasteButton" 
    57                                                 dojoOnClick="pasteClick; buttonClick;" unselectable="on"> 
    58                                                 <span title="Paste (Ctrl-V)" class="icon paste" unselectable="on">&nbsp;</span> 
     51                                        <!-- paste --> 
     52                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="paste"> 
     53                                                <span title="Paste (Ctrl-V)" class="dojoE2TBIcon dojoE2TBIcon_Paste">&nbsp;</span> 
    5954                                        </span> 
    6055                                </td> 
    6156                                <td> 
    6257                                        <!-- undo --> 
    63                                         <span class="iconContainer" dojoAttachPoint="undoButton" 
    64                                                 dojoOnClick="undoClick; buttonClick;" unselectable="on"> 
     58                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="undo"> 
    6559                                                <!-- FIXME: should we have the text "undo" here? --> 
    66                                                 <span title="Undo (Ctrl-Z)" class="icon undo" unselectable="on">&nbsp;</span> 
     60                                                <span title="Undo (Ctrl-Z)" class="dojoE2TBIcon dojoE2TBIcon_Undo">&nbsp;</span> 
    6761                                        </span> 
    6862                                </td> 
    6963                                <td> 
    7064                                        <!-- redo --> 
    71                                         <span class="iconContainer" dojoAttachPoint="redoButton" 
    72                                                 dojoOnClick="redoClick; buttonClick;" unselectable="on"> 
    73                                                 <span title="Redo (Ctrl-R)" class="icon redo" unselectable="on">&nbsp;</span> 
     65                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="redo"> 
     66                                                <span title="Redo (Ctrl-R)" class="dojoE2TBIcon dojoE2TBIcon_Redo">&nbsp;</span> 
    7467                                        </span> 
    7568                                </td> 
    7669                                <td isSpacer="true"> 
    7770                                        <!-- spacer --> 
    7871                                        <span class="iconContainer"> 
    79                                                 <span class="icon sep" unselectable="on"  
    80                                                         style="width: 5px; min-width: 5px;"></span> 
     72                                                <span class="dojoE2TBIcon dojoE2TBIcon_Sep"     style="width: 5px; min-width: 5px;"></span> 
    8173                                        </span> 
    8274                                </td> 
    8375                                <td> 
    8476                                        <!-- link --> 
    85                                         <span class="iconContainer" dojoAttachPoint="linkButton" 
    86                                                 unselectable="on" dojoOnClick="linkClick; buttonClick;"> 
    87                                                 <span title="Create Link" class="icon createlink" unselectable="on">&nbsp;</span> 
     77                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="createlink"> 
     78                                                <span title="Create Link" class="dojoE2TBIcon dojoE2TBIcon_Link">&nbsp;</span> 
    8879                                        </span> 
    8980                                </td> 
    9081                                <td> 
    9182                                        <!-- insertimage --> 
    92                                         <span class="iconContainer"  
    93                                                 style="display: none;" 
    94                                                 dojoAttachPoint="insertimageButton" 
    95                                                 unselectable="on" dojoOnClick="insertimageClick; buttonClick;"> 
    96                                                 <span title="Insert Image" class="icon insertimage" unselectable="on">&nbsp;</span> 
     83                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="insertimage"> 
     84                                                <span title="Insert Image" class="dojoE2TBIcon dojoE2TBIcon_Image">&nbsp;</span> 
    9785                                        </span> 
    9886                                </td> 
    9987                                <td> 
    10088                                        <!-- inserthorizontalrule --> 
    101                                         <span class="iconContainer" dojoAttachPoint="inserthorizontalruleButton" 
    102                                                 unselectable="on" dojoOnClick="inserthorizontalruleClick; buttonClick;"> 
    103                                                 <span title="Insert Horizontal Rule" class="icon inserthorizontalrule " unselectable="on">&nbsp;</span> 
     89                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="inserthorizontalrule"> 
     90                                                <span title="Insert Horizontal Rule" class="dojoE2TBIcon dojoE2TBIcon_HorizontalLine ">&nbsp;</span> 
    10491                                        </span> 
    10592                                </td> 
    10693                                <td> 
    10794                                        <!-- bold --> 
    108                                         <span class="iconContainer" dojoAttachPoint="boldButton" 
    109                                                 unselectable="on" dojoOnClick="boldClick; buttonClick;"> 
    110                                                 <span title="Toggle Bold (Ctrl-B)" class="icon bold" unselectable="on">&nbsp;</span> 
     95                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="bold"> 
     96                                                <span title="Toggle Bold (Ctrl-B)" class="dojoE2TBIcon dojoE2TBIcon_Bold">&nbsp;</span> 
    11197                                        </span> 
    11298                                </td> 
    11399                                <td> 
    114100                                        <!-- italic --> 
    115                                         <span class="iconContainer" dojoAttachPoint="italicButton" 
    116                                                 dojoOnClick="italicClick; buttonClick;"> 
    117                                                 <span title="Toggle Italic (Ctrl-I)" class="icon italic" unselectable="on">&nbsp;</span> 
     101                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="italic"> 
     102                                                <span title="Toggle Italic (Ctrl-I)" class="dojoE2TBIcon dojoE2TBIcon_Italic">&nbsp;</span> 
    118103                                        </span> 
    119104                                </td> 
    120105                                <td> 
    121106                                        <!-- underline --> 
    122                                         <span class="iconContainer" dojoAttachPoint="underlineButton" 
    123                                                 dojoOnClick="underlineClick; buttonClick;"> 
    124                                                 <span title="Toggle Underline (Ctrl-U)" class="icon underline" unselectable="on">&nbsp;</span> 
     107                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="underline"> 
     108                                                <span title="Toggle Underline (Ctrl-U)" class="dojoE2TBIcon dojoE2TBIcon_Underline">&nbsp;</span> 
    125109                                        </span> 
    126110                                </td> 
    127111                                <td> 
    128112                                        <!-- strikethrough --> 
    129                                         <span class="iconContainer" dojoAttachPoint="strikethroughButton" 
    130                                                 dojoOnClick="strikethroughClick; buttonClick;"> 
     113                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="strikethrough"> 
    131114                                                <span title="Toggle Strike-Through"  
    132                                                         class="icon strikethrough" unselectable="on">&nbsp;</span> 
     115                                                        class="dojoE2TBIcon dojoE2TBIcon_StrikeThrough">&nbsp;</span> 
    133116                                        </span> 
    134117                                </td> 
    135118                                <td isSpacer="true"> 
    136119                                        <!-- spacer --> 
    137120                                        <span class="iconContainer"> 
    138                                                 <span class="icon sep" unselectable="on"  
     121                                                <span class="dojoE2TBIcon dojoE2TBIcon_Sep"  
    139122                                                        style="width: 5px; min-width: 5px;"></span> 
    140123                                        </span> 
    141124                                </td> 
    142125                                <td> 
    143126                                        <!-- insertunorderedlist --> 
    144                                         <span class="iconContainer" dojoAttachPoint="insertunorderedlistButton" 
    145                                                 unselectable="on"  
    146                                                 dojoOnClick="insertunorderedlistClick; buttonClick;"> 
     127                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="insertunorderedlist"> 
    147128                                                <span title="Insert Bullet List"  
    148                                                         class="icon insertunorderedlist" unselectable="on">&nbsp;</span> 
     129                                                        class="dojoE2TBIcon dojoE2TBIcon_BulletedList">&nbsp;</span> 
    149130                                        </span> 
    150131                                </td> 
    151132                                <td> 
    152133                                        <!-- insertorderedlist --> 
    153                                         <span class="iconContainer" dojoAttachPoint="insertorderedlistButton" 
    154                                                 unselectable="on" dojoOnClick="insertorderedlistClick; buttonClick;"> 
     134                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="insertorderedlist"> 
    155135                                                <span title="Insert Numbered List"  
    156                                                         class="icon insertorderedlist" unselectable="on">&nbsp;</span> 
     136                                                        class="dojoE2TBIcon dojoE2TBIcon_NumberedList">&nbsp;</span> 
    157137                                        </span> 
    158138                                </td> 
    159139                                <td isSpacer="true"> 
    160140                                        <!-- spacer --> 
    161141                                        <span class="iconContainer"> 
    162                                                 <span class="icon sep" unselectable="on"  
    163                                                         style="width: 5px; min-width: 5px;"></span> 
     142                                                <span class="dojoE2TBIcon dojoE2TBIcon_Sep" style="width: 5px; min-width: 5px;"></span> 
    164143                                        </span> 
    165144                                </td> 
    166145                                <td> 
    167146                                        <!-- indent --> 
    168                                         <span class="iconContainer" dojoAttachPoint="indentButton" 
    169                                                 unselectable="on" dojoOnClick="indentClick; buttonClick;"> 
    170                                                 <span title="Indent Selection" class="icon indent"  
     147                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="indent"> 
     148                                                <span title="Indent Selection" class="dojoE2TBIcon dojoE2TBIcon_Indent"  
    171149                                                        unselectable="on">&nbsp;</span> 
    172150                                        </span> 
    173151                                </td> 
    174152                                <td> 
    175153                                        <!-- outdent --> 
    176                                         <span class="iconContainer" dojoAttachPoint="outdentButton" 
    177                                                 unselectable="on" dojoOnClick="outdentClick; buttonClick;"> 
    178                                                 <span title="Outdent Selection" class="icon outdent"  
     154                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="outdent"> 
     155                                                <span title="Outdent Selection" class="dojoE2TBIcon dojoE2TBIcon_Outdent"  
    179156                                                        unselectable="on">&nbsp;</span> 
    180157                                        </span> 
    181158                                </td> 
    182159                                <td isSpacer="true"> 
    183160                                        <!-- spacer --> 
    184161                                        <span class="iconContainer"> 
    185                                                 <span class="icon sep" unselectable="on"  
    186                                                         style="width: 5px; min-width: 5px;"></span> 
     162                                                <span class="dojoE2TBIcon dojoE2TBIcon_Sep" style="width: 5px; min-width: 5px;"></span> 
    187163                                        </span> 
    188164                                </td> 
    189165                                <td> 
    190166                                        <!-- forecolor --> 
    191                                         <span class="iconContainer" dojoAttachPoint="forecolorButton" 
    192                                                 unselectable="on" dojoOnClick="forecolorClick; buttonClick;"> 
    193                                                 <span title="Change Text Color" class="icon forecolor"  
     167                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="forecolor"> 
     168                                                <span title="Change Text Color" class="dojoE2TBIcon dojoE2TBIcon_TextColor"  
    194169                                                        unselectable="on">&nbsp;</span> 
    195170                                        </span> 
    196                                         <div class="ColorDropdownContainer"  
    197                                                 style="display: none; margin-top: 22px;" 
    198                                                 dojoAttachPoint="forecolorDropDown"> 
    199                                         </div> 
    200171                                </td> 
    201172                                <td> 
    202173                                        <!-- hilitecolor --> 
    203                                         <span class="iconContainer" dojoAttachPoint="hilitecolorButton" 
    204                                                 unselectable="on" dojoOnClick="hilitecolorClick; buttonClick;"> 
    205                                                 <span title="Change Background Color" class="icon hilitecolor"  
     174                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="hilitecolor"> 
     175                                                <span title="Change Background Color" class="dojoE2TBIcon dojoE2TBIcon_BackgroundColor"  
    206176                                                        unselectable="on">&nbsp;</span> 
    207177                                        </span> 
    208                                         <div class="ColorDropdownContainer"  
    209                                                 style="display: none; margin-top: 22px;" 
    210                                                 dojoAttachPoint="hilitecolorDropDown"> 
    211                                         </div> 
    212178                                </td> 
    213179                                <td isSpacer="true"> 
    214180                                        <!-- spacer --> 
    215181                                        <span class="iconContainer"> 
    216                                                 <span class="icon sep" unselectable="on"  
    217                                                         style="width: 5px; min-width: 5px;"></span> 
     182                                                <span class="dojoE2TBIcon dojoE2TBIcon_Sep" style="width: 5px; min-width: 5px;"></span> 
    218183                                        </span> 
    219184                                </td> 
    220185                                <td> 
    221186                                        <!-- justify left --> 
    222                                         <span class="iconContainer" dojoAttachPoint="justifyleftButton" 
    223                                                 dojoOnClick="justifyleftClick; buttonClick;"> 
    224                                                 <span title="Justify Left" class="icon justifyleft" unselectable="on">&nbsp;</span> 
     187                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="justifyleft"> 
     188                                                <span title="Justify Left" class="dojoE2TBIcon dojoE2TBIcon_LeftJustify">&nbsp;</span> 
    225189                                        </span> 
    226190                                </td> 
    227191                                <td> 
    228192                                        <!-- justify center --> 
    229                                         <span class="iconContainer" dojoAttachPoint="justifycenterButton" 
    230                                                 dojoOnClick="justifycenterClick; buttonClick;"> 
    231                                                 <span title="Center" class="icon justifycenter" unselectable="on">&nbsp;</span> 
     193                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="justifycenter"> 
     194                                                <span title="Center" class="dojoE2TBIcon dojoE2TBIcon_CenterJustify">&nbsp;</span> 
    232195                                        </span> 
    233196                                </td> 
    234197                                <td> 
    235198                                        <!-- justify right --> 
    236                                         <span class="iconContainer" dojoAttachPoint="justifyrightButton" 
    237                                                 dojoOnClick="justifyrightClick; buttonClick;"> 
    238                                                 <span title="Justify Right" class="icon justifyright" unselectable="on">&nbsp;</span> 
     199                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="justifyright"> 
     200                                                <span title="Justify Right" class="dojoE2TBIcon dojoE2TBIcon_RightJustify">&nbsp;</span> 
    239201                                        </span> 
    240202                                </td> 
    241203                                <td> 
    242204                                        <!-- justify full --> 
    243                                         <span class="iconContainer" dojoAttachPoint="justifyfullButton" 
    244                                                 dojoOnClick="justifyfullClick; buttonClick;"> 
    245                                                 <span title="Justify Both" class="icon justifyfull" unselectable="on">&nbsp;</span> 
     205                                        <span class="iconContainer dojoEditorToolbarItem" dojoETItemName="justifyfull"> 
     206                                                <span title="Justify Both" class="dojoE2TBIcon dojoE2TBIcon_BlockJustify">&nbsp;</span> 
    246207                                        </span> 
    247208                                </td>    
    248209                                <td> 
    249210                                        <!-- font select --> 
    250                                         <select dojoOnChange="formatSelectClick; buttonClick;" 
    251                                                 dojoAttachPoint="formatSelectBox" unselectable="on"> 
     211                                        <select class="dojoEditorToolbarItem" dojoETItemName="plainformatblock"> 
    252212                                                <!-- FIXME: using "p" here inserts a paragraph in most cases! --> 
    253213                                                <option value="">-- format --</option> 
    254214                                                <option value="p">Normal</option> 
     
    264224                                        <!--<span class="iconContainer"  
    265225                                                dojoAttachPoint="saveButton" 
    266226                                                unselectable="on" dojoOnClick="saveClick; buttonClick;"> 
    267                                                 <span title="Save" class="icon save" unselectable="on">&nbsp;</span> 
     227                                                <span title="Save" class="dojoE2TBIcon dojoE2TBIcon_Save">&nbsp;</span> 
    268228                                        </span> 
    269229                                </td>--> 
    270230                                <td width="*">&nbsp;</td>