Changeset 335e66 in indico


Ignore:
Timestamp:
10/12/10 17:29:04 (3 years ago)
Author:
Pedro Ferreira <jose.pedro.ferreira@…>
Branches:
master, burotel, hello-world-walkthrough, ipv6, new-webex, v0.97-series, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, b8c30da8ebdbdcbd675a873997cc3e95f567de49, 4287315ec967a3da168d83963c14001db8487d53
Children:
8eabfb, 138bf2
Parents:
6e50e1
Message:

[FIX] Several CKeditor fixes

  • Added back the "plain text" mode (had misteriously disappeared);
  • Redid a bit the editor loading procedure, in order to conform to CKeditor instead of FCKeditor;
Location:
indico
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/webinterface/tpls/ConferenceCreation.tpl

    ra35282 r335e66  
    221221        }); 
    222222 
    223                 var editor = new RichTextWidget(500, 200,"IndicoMinimal"); 
     223                var editor = new RichTextWidget(500, 200,'','rich',"IndicoMinimal"); 
    224224                $E('descriptionBox').set(editor.draw()); 
    225225        }); 
  • indico/MaKaC/webinterface/tpls/MeetingCreation.tpl

    ra35282 r335e66  
    220220        verifyDates(); 
    221221 
    222         var editor = new RichTextWidget(500, 200,"IndicoMinimal"); 
     222        var editor = new RichTextWidget(500, 200,'','rich',"IndicoMinimal"); 
    223223        $E('descriptionBox').set(editor.draw()); 
    224224        }); 
  • indico/MaKaC/webinterface/tpls/SimpleEventCreation.tpl

    ra35282 r335e66  
    189189 
    190190 
    191         var editor = new RichTextWidget(500, 200,"IndicoMinimal"); 
     191        var editor = new RichTextWidget(500, 200,'','rich',"IndicoMinimal"); 
    192192        $E('descriptionBox').set(editor.draw()); 
    193193 
  • indico/htdocs/js/indico/Core/Auxiliar.js

    ra35282 r335e66  
    3131 
    3232                var accessor = getAccessorDeep(source); 
    33                 var field = new RichTextWidget(width, height); 
     33                var field = new RichTextWidget(width, height, '', 'rich'); 
    3434 
    3535                var fieldDiv = field.draw(); 
  • indico/htdocs/js/indico/Core/Widgets/RichText.js

    r6e50e1 r335e66  
    1212        });*/ 
    1313 
    14 type("RichTextWidget", ["IWidget", "Accessor"], 
     14type("RichTextEditor", ["IWidget", "Accessor"], 
    1515     { 
    1616         draw: function() { 
    17              selfReference = this; 
     17             var self = this; 
    1818             this.div = Html.div({'id': 'text' + this.divId, style : {height: this.height + 75, width: this.width}}); 
    19              window.setTimeout(function() { 
    20                  initializeEditor('text' + selfReference.divId , 
    21                                   selfReference.text , 
    22                                   selfReference.callbacks, 
    23                                   selfReference.width, 
    24                                   selfReference.height, 
    25                                   selfReference.toolbarSet); 
     19 
     20             setTimeout(function() { 
     21                 initializeEditor( 
     22                     self, 
     23                     'text' + self.divId , 
     24                     self.text , 
     25                     self.callbacks, 
     26                     self.width, 
     27                     self.height, 
     28                     self.toolbarSet); 
    2629             },50); 
    2730             return this.div; 
     
    6669             return CKEDITOR.instances["text" + this.divId]; 
    6770         } 
    68  
    6971     }, 
    7072     function(width, height, toolbarSet) { 
     
    7880     }); 
    7981 
     82type("RichTextWidget", ["IWidget", "Accessor"], 
     83     { 
     84         draw: function() { 
     85             this.richDiv.append(this.rich.draw()); 
     86             return Html.div({}, 
     87                             this.plain.draw(), 
     88                             this.richDiv, 
     89                             Widget.link(this.switchLink)); 
     90         }, 
     91 
     92         observe: function(callback) { 
     93            var self = this; 
     94 
     95             var observeFunc = function(value) { 
     96 
     97                 self.plain.unbind(); 
     98                 self.rich.unbind(); 
     99 
     100                 if (value == 'rich') { 
     101                    self.rich.observe(function() { 
     102                         callback(self.rich); 
     103                     }); 
     104                 } else { 
     105                     self.plain.observe(function() { 
     106                         callback(self.plain); 
     107                     }); 
     108                 } 
     109             }; 
     110 
     111             this.selected.observe(observeFunc); 
     112             observeFunc(this.selected.get()); 
     113         }, 
     114 
     115         get: function() { 
     116             return this.activeAccessor.get(); 
     117         }, 
     118 
     119         set: function(value, noDetection) { 
     120 
     121             this.currentText = value; 
     122 
     123             if (!any(noDetection, false)) { 
     124                 if ((this.isHtml(value)?'rich':'plain') != this.selected.get()) { 
     125                     this.switchLink.get()(false); 
     126                 } 
     127             } 
     128 
     129             if (value && (this.loaded || this.selected.get() == 'plain')) { 
     130                 this.activeAccessor.set(value); 
     131             } 
     132         }, 
     133 
     134         synchronizePlain: function() { 
     135             this.currentText = this.rich.get(); 
     136             this.plain.set(this.currentText); 
     137         }, 
     138 
     139         synchronizeRich: function() { 
     140             this.currentText = this.plain.get(); 
     141             this.rich.set(this.currentText); 
     142         }, 
     143 
     144         isHtml: function(text) { 
     145             if (/<.*>[\s\S]*<\/.*>/.exec(text)) { 
     146                 return true; 
     147             } else { 
     148                 return false; 
     149             } 
     150         }, 
     151 
     152         postDraw: function() { 
     153             this.rich.postDraw(); 
     154         }, 
     155 
     156         destroy: function() { 
     157             this.rich.destroy(); 
     158         } 
     159     }, 
     160     function(width, height, initialText, mode, toolbarSet) { 
     161 
     162         var textAreaParams = { style: {} }; 
     163         textAreaParams.style.width = pixels(width); 
     164         textAreaParams.style.height = pixels(height); 
     165 
     166         this.plain = new RealtimeTextArea(textAreaParams); 
     167         this.rich = new RichTextEditor(width, height, toolbarSet); 
     168         this.richDiv = Html.div({}); 
     169         this.currentText = any(initialText, ''); 
     170         this.loaded = false; 
     171 
     172         this.selected = new WatchValue(); 
     173 
     174         var toPlainFunc = function(sync) { 
     175             self.plain.setStyle('display', 'block'); 
     176             self.richDiv.setStyle('display', 'none'); 
     177             self.switchLink.set('toRich'); 
     178             self.activeAccessor = self.plain; 
     179             self.selected.set('plain'); 
     180             if (sync !== false) { 
     181                 self.synchronizePlain(); 
     182             } 
     183         }; 
     184 
     185         var toRichFunc  = function(sync) { 
     186             self.plain.setStyle('display', 'none'); 
     187             self.richDiv.setStyle('display', 'block'); 
     188             self.switchLink.set('toPlain'); 
     189             self.activeAccessor = self.rich; 
     190             self.selected.set('rich'); 
     191             if (sync !== false) { 
     192                 self.synchronizeRich(); 
     193             } 
     194         }; 
     195 
     196         var self = this; 
     197         this.switchLink = new Chooser( 
     198             { 
     199                 toPlain: command( 
     200                     toPlainFunc, 
     201                     $T("switch to plain text")), 
     202                 toRich: command( 
     203                     toRichFunc, 
     204                     $T("switch to rich text")) 
     205            }); 
     206 
     207         if (exists(mode) && mode=='rich') { 
     208             toRichFunc(); 
     209         } else if (exists(mode)){ 
     210             toPlainFunc(); 
     211         } else if (self.isHtml(self.currentText)) { 
     212             toRichFunc(); 
     213         } else { 
     214             toPlainFunc(); 
     215         } 
     216 
     217         this.rich.onLoad(function() { 
     218             self.loaded = true; 
     219             self.set(self.currentText, true); 
     220         }); 
     221 
     222      }); 
     223 
     224 
    80225type("RichTextInlineEditWidget", ["InlineEditWidget"], 
    81226        { 
    82227            _handleEditMode: function(value) { 
    83228 
    84                 this.description = new RichTextWidget(600, 400,'IndicoMinimal'); 
     229                this.description = new RichTextWidget(600, 400, 
     230                                                      '','rich', 
     231                                                      'IndicoMinimal'); 
    85232                this.description.set(value); 
    86233                return this.description.draw(); 
     
    133280 
    134281 
    135 function initializeEditor( editorId, text, callbacks, width, height, toolbarSet ){ 
     282function initializeEditor( wrapper, editorId, text, callbacks, width, height, toolbarSet ){ 
     283    // "wrapper" is the actual Indico API object that represents an editor 
     284 
    136285    try { 
    137286 
    138287        CKEDITOR.replace(editorId, {language : userLanguage, width : width, height : height - 75, 'toolbar': toolbarSet}); 
    139         CKEDITOR.instances[editorId].setData(text); 
    140         CKEDITOR.instances[editorId].on ('key', function(e) 
     288 
     289        var cki = CKEDITOR.instances[editorId]; 
     290 
     291        cki.setData(text); 
     292        cki.on ('key', function(e) 
    141293                { 
    142294                    each(callbacks, function(func) { 
     
    144296                    }) 
    145297                }); 
     298 
     299        // process onLoad events for each individual instance (wrapper) 
     300        cki.on ('instanceReady', function(e) 
     301                { 
     302                    each(wrapper.onLoadList, function(callback) { 
     303                                 callback(); 
     304                    }); 
     305 
     306                }); 
     307 
    146308    } 
    147309    catch (error) { 
    148         window.setTimeout(function() { 
    149             initializeEditor(editorId, text, callbacks, width, height); 
     310        setTimeout(function() { 
     311            initializeEditor(wrapper, editorId, text, callbacks, width, height); 
    150312        },50); 
    151313    } 
  • indico/htdocs/js/indico/Legacy/Dialogs.js

    ra35282 r335e66  
    583583               var killProgress = null; 
    584584 
    585                var rtWidget = new RichTextWidget(700,400,'IndicoFull'); 
     585               var rtWidget = new RichTextWidget(700, 400, '', 'rich', 'IndicoFull'); 
    586586 
    587587               var saveButton; 
Note: See TracChangeset for help on using the changeset viewer.