1 if(!dojo._hasResource["dijit._editor.plugins.AlwaysShowToolbar"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dijit._editor.plugins.AlwaysShowToolbar"] = true;
3 dojo.provide("dijit._editor.plugins.AlwaysShowToolbar");
5 dojo.declare("dijit._editor.plugins.AlwaysShowToolbar", dijit._editor._Plugin,
8 setEditor: function(e){
10 // setTimeout(dojo.hitch(this,this.enable), 10000);
11 e.onLoadDeferred.addCallback(dojo.hitch(this, this.enable));
12 // this.scrollInterval = setInterval(dojo.hitch(this, "globalOnScrollHandler"), 100);
16 this.connect(window, 'onscroll', "globalOnScrollHandler");
17 this.connect(this.editor, 'onNormalizedDisplayChanged', "_updateHeight");
20 _updateHeight: function(){
22 // Updates the height of the editor area to fit the contents.
24 if(!e.isLoaded){ return; }
25 if(e.height){ return; }
27 var height = dojo.marginBox(e.editNode).h;
29 height = e.editNode.scrollHeight;
31 // console.debug('height',height);
32 // alert(this.editNode);
34 //height maybe zero in some cases even though the content is not empty,
35 //we try the height of body instead
37 height = dojo.marginBox(e.document.body).h;
41 console.debug("Can not figure out the height of the editing area!");
42 return; //prevent setting height to 0
44 if(height != this._lastHeight){
45 this._lastHeight = height;
46 // this.editorObject.style.height = this._lastHeight + "px";
47 dojo.marginBox(e.iframe, { h: this._lastHeight });
48 // this.iframe.height=this._lastHeight+10+'px';
49 // this.iframe.style.height=this._lastHeight+'px';
53 globalOnScrollHandler: function(){
54 var isIE = dojo.isIE && dojo.isIE<7;
55 if(!this._handleScroll){ return; }
56 var tdn = this.editor.toolbar.domNode;
59 if(!this._scrollSetUp){
60 this._scrollSetUp = true;
61 this._scrollThreshold = dojo._abs(tdn, true).y;
62 // console.log("threshold:", this._scrollThreshold);
63 //what's this for?? comment out for now
64 // if((isIE)&&(db)&&(dojo.style(db, "backgroundIimage")=="none")){
65 // db.style.backgroundImage = "url(" + dojo.uri.moduleUri("dijit", "templates/blank.gif") + ")";
66 // db.style.backgroundAttachment = "fixed";
70 var scrollPos = dojo._docScroll().y;
73 if(scrollPos > this._scrollThreshold && scrollPos < this._scrollThreshold+this._lastHeight){
74 // dojo.debug(scrollPos);
75 if(!this._fixEnabled){
76 var tdnbox = dojo.marginBox(tdn);
77 this.editor.iframe.style.marginTop = tdnbox.h+"px";
80 s.left = dojo._abs(tdn).x;
81 if(tdn.previousSibling){
82 this._IEOriginalPos = ['after',tdn.previousSibling];
83 }else if(tdn.nextSibling){
84 this._IEOriginalPos = ['before',tdn.nextSibling];
86 this._IEOriginalPos = ['last',tdn.parentNode];
88 dojo.body().appendChild(tdn);
89 dojo.addClass(tdn,'dijitIEFixedToolbar');
95 dojo.marginBox(tdn, { w: tdnbox.w });
97 this._fixEnabled = true;
99 // if we're showing the floating toolbar, make sure that if
100 // we've scrolled past the bottom of the editor that we hide
101 // the toolbar for this instance of the editor.
103 // TODO: when we get multiple editor toolbar support working
104 // correctly, ensure that we check this against the scroll
105 // position of the bottom-most editor instance.
106 var eHeight = (this.height) ? parseInt(this.editor.height) : this.editor._lastHeight;
107 s.display = (scrollPos > this._scrollThreshold+eHeight) ? "none" : "";
108 }else if(this._fixEnabled){
109 this.editor.iframe.style.marginTop = '';
116 dojo.removeClass(tdn,'dijitIEFixedToolbar');
117 if(this._IEOriginalPos){
118 dojo.place(tdn, this._IEOriginalPos[1], this._IEOriginalPos[0]);
119 this._IEOriginalPos = null;
121 dojo.place(tdn, this.editor.iframe, 'before');
125 this._fixEnabled = false;
129 this._IEOriginalPos = null;
130 this._handleScroll = false;
131 dojo.forEach(this._connects, dojo.disconnect);
132 // clearInterval(this.scrollInterval);
134 if(dojo.isIE && dojo.isIE<7){
135 dojo.removeClass(this.editor.toolbar.domNode, 'dijitIEFixedToolbar');