summaryrefslogtreecommitdiff
path: root/lib/dijit/_editor/plugins/AlwaysShowToolbar.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dijit/_editor/plugins/AlwaysShowToolbar.js')
-rw-r--r--lib/dijit/_editor/plugins/AlwaysShowToolbar.js192
1 files changed, 2 insertions, 190 deletions
diff --git a/lib/dijit/_editor/plugins/AlwaysShowToolbar.js b/lib/dijit/_editor/plugins/AlwaysShowToolbar.js
index 9d0b7ded8..665b4bb7d 100644
--- a/lib/dijit/_editor/plugins/AlwaysShowToolbar.js
+++ b/lib/dijit/_editor/plugins/AlwaysShowToolbar.js
@@ -1,190 +1,2 @@
-/*
- Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
- Available via Academic Free License >= 2.1 OR the modified BSD license.
- see: http://dojotoolkit.org/license for details
-*/
-
-
-if(!dojo._hasResource["dijit._editor.plugins.AlwaysShowToolbar"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
-dojo._hasResource["dijit._editor.plugins.AlwaysShowToolbar"] = true;
-dojo.provide("dijit._editor.plugins.AlwaysShowToolbar");
-dojo.require("dijit._editor._Plugin");
-
-
-dojo.declare("dijit._editor.plugins.AlwaysShowToolbar", dijit._editor._Plugin,
- {
- // summary:
- // This plugin is required for Editors in auto-expand mode.
- // It handles the auto-expansion as the user adds/deletes text,
- // and keeps the editor's toolbar visible even when the top of the editor
- // has scrolled off the top of the viewport (usually when editing a long
- // document).
- // description:
- // Specify this in extraPlugins (or plugins) parameter and also set
- // height to "".
- // example:
- // | <div dojoType="dijit.Editor" height=""
- // | extraPlugins="['dijit._editor.plugins.AlwaysShowToolbar']">
-
- // _handleScroll: Boolean
- // Enables/disables the handler for scroll events
- _handleScroll: true,
-
- setEditor: function(e){
- // Overrides _Plugin.setEditor().
- if(!e.iframe){
- console.log('Port AlwaysShowToolbar plugin to work with Editor without iframe');
- return;
- }
-
- this.editor = e;
-
- e.onLoadDeferred.addCallback(dojo.hitch(this, this.enable));
- },
-
- enable: function(d){
- // summary:
- // Enable plugin. Called when Editor has finished initializing.
- // tags:
- // private
-
- this._updateHeight();
- this.connect(window, 'onscroll', "globalOnScrollHandler");
- this.connect(this.editor, 'onNormalizedDisplayChanged', "_updateHeight");
- return d;
- },
-
- _updateHeight: function(){
- // summary:
- // Updates the height of the editor area to fit the contents.
- var e = this.editor;
- if(!e.isLoaded){ return; }
- if(e.height){ return; }
-
- var height = dojo._getMarginSize(e.editNode).h;
- if(dojo.isOpera){
- height = e.editNode.scrollHeight;
- }
- // console.debug('height',height);
- // alert(this.editNode);
-
- //height maybe zero in some cases even though the content is not empty,
- //we try the height of body instead
- if(!height){
- height = dojo._getMarginSize(e.document.body).h;
- }
-
- if(height == 0){
- console.debug("Can not figure out the height of the editing area!");
- return; //prevent setting height to 0
- }
- if(dojo.isIE <= 7 && this.editor.minHeight){
- var min = parseInt(this.editor.minHeight);
- if(height < min){ height = min; }
- }
- if(height != this._lastHeight){
- this._lastHeight = height;
- // this.editorObject.style.height = this._lastHeight + "px";
- dojo.marginBox(e.iframe, { h: this._lastHeight });
- }
- },
-
- // _lastHeight: Integer
- // Height in px of the editor at the last time we did sizing
- _lastHeight: 0,
-
- globalOnScrollHandler: function(){
- // summary:
- // Handler for scroll events that bubbled up to <html>
- // tags:
- // private
-
- var isIE6 = dojo.isIE < 7;
- if(!this._handleScroll){ return; }
- var tdn = this.editor.header;
- var db = dojo.body;
-
- if(!this._scrollSetUp){
- this._scrollSetUp = true;
- this._scrollThreshold = dojo.position(tdn, true).y;
-// console.log("threshold:", this._scrollThreshold);
- //what's this for?? comment out for now
-// if((isIE6)&&(db)&&(dojo.style(db, "backgroundIimage")=="none")){
-// db.style.backgroundImage = "url(" + dojo.uri.moduleUri("dijit", "templates/blank.gif") + ")";
-// db.style.backgroundAttachment = "fixed";
-// }
- }
-
- var scrollPos = dojo._docScroll().y;
- var s = tdn.style;
-
- if(scrollPos > this._scrollThreshold && scrollPos < this._scrollThreshold+this._lastHeight){
- // dojo.debug(scrollPos);
- if(!this._fixEnabled){
- var tdnbox = dojo._getMarginSize(tdn);
- this.editor.iframe.style.marginTop = tdnbox.h+"px";
-
- if(isIE6){
- s.left = dojo.position(tdn).x;
- if(tdn.previousSibling){
- this._IEOriginalPos = ['after',tdn.previousSibling];
- }else if(tdn.nextSibling){
- this._IEOriginalPos = ['before',tdn.nextSibling];
- }else{
- this._IEOriginalPos = ['last',tdn.parentNode];
- }
- dojo.body().appendChild(tdn);
- dojo.addClass(tdn,'dijitIEFixedToolbar');
- }else{
- s.position = "fixed";
- s.top = "0px";
- }
-
- dojo.marginBox(tdn, { w: tdnbox.w });
- s.zIndex = 2000;
- this._fixEnabled = true;
- }
- // if we're showing the floating toolbar, make sure that if
- // we've scrolled past the bottom of the editor that we hide
- // the toolbar for this instance of the editor.
-
- // TODO: when we get multiple editor toolbar support working
- // correctly, ensure that we check this against the scroll
- // position of the bottom-most editor instance.
- var eHeight = (this.height) ? parseInt(this.editor.height) : this.editor._lastHeight;
- s.display = (scrollPos > this._scrollThreshold+eHeight) ? "none" : "";
- }else if(this._fixEnabled){
- this.editor.iframe.style.marginTop = '';
- s.position = "";
- s.top = "";
- s.zIndex = "";
- s.display = "";
- if(isIE6){
- s.left = "";
- dojo.removeClass(tdn,'dijitIEFixedToolbar');
- if(this._IEOriginalPos){
- dojo.place(tdn, this._IEOriginalPos[1], this._IEOriginalPos[0]);
- this._IEOriginalPos = null;
- }else{
- dojo.place(tdn, this.editor.iframe, 'before');
- }
- }
- s.width = "";
- this._fixEnabled = false;
- }
- },
-
- destroy: function(){
- // Overrides _Plugin.destroy(). TODO: call this.inherited() rather than repeating code.
- this._IEOriginalPos = null;
- this._handleScroll = false;
- dojo.forEach(this._connects, dojo.disconnect);
-// clearInterval(this.scrollInterval);
-
- if(dojo.isIE < 7){
- dojo.removeClass(this.editor.header, 'dijitIEFixedToolbar');
- }
- }
-});
-
-}
+//>>built
+define("dijit/_editor/plugins/AlwaysShowToolbar",["dojo/_base/declare","dojo/dom-class","dojo/dom-construct","dojo/dom-geometry","dojo/_base/lang","dojo/_base/sniff","dojo/_base/window","../_Plugin"],function(_1,_2,_3,_4,_5,_6,_7,_8){return _1("dijit._editor.plugins.AlwaysShowToolbar",_8,{_handleScroll:true,setEditor:function(e){if(!e.iframe){return;}this.editor=e;e.onLoadDeferred.addCallback(_5.hitch(this,this.enable));},enable:function(d){this._updateHeight();this.connect(window,"onscroll","globalOnScrollHandler");this.connect(this.editor,"onNormalizedDisplayChanged","_updateHeight");return d;},_updateHeight:function(){var e=this.editor;if(!e.isLoaded){return;}if(e.height){return;}var _9=_4.getMarginSize(e.editNode).h;if(_6("opera")){_9=e.editNode.scrollHeight;}if(!_9){_9=_4.getMarginSize(e.document.body).h;}if(_9==0){return;}if(_6("ie")<=7&&this.editor.minHeight){var _a=parseInt(this.editor.minHeight);if(_9<_a){_9=_a;}}if(_9!=this._lastHeight){this._lastHeight=_9;_4.setMarginBox(e.iframe,{h:this._lastHeight});}},_lastHeight:0,globalOnScrollHandler:function(){var _b=_6("ie")<7;if(!this._handleScroll){return;}var _c=this.editor.header;if(!this._scrollSetUp){this._scrollSetUp=true;this._scrollThreshold=_4.position(_c,true).y;}var _d=_4.docScroll().y;var s=_c.style;if(_d>this._scrollThreshold&&_d<this._scrollThreshold+this._lastHeight){if(!this._fixEnabled){var _e=_4.getMarginSize(_c);this.editor.iframe.style.marginTop=_e.h+"px";if(_b){s.left=_4.position(_c).x;if(_c.previousSibling){this._IEOriginalPos=["after",_c.previousSibling];}else{if(_c.nextSibling){this._IEOriginalPos=["before",_c.nextSibling];}else{this._IEOriginalPos=["last",_c.parentNode];}}_7.body().appendChild(_c);_2.add(_c,"dijitIEFixedToolbar");}else{s.position="fixed";s.top="0px";}_4.setMarginBox(_c,{w:_e.w});s.zIndex=2000;this._fixEnabled=true;}var _f=(this.height)?parseInt(this.editor.height):this.editor._lastHeight;s.display=(_d>this._scrollThreshold+_f)?"none":"";}else{if(this._fixEnabled){this.editor.iframe.style.marginTop="";s.position="";s.top="";s.zIndex="";s.display="";if(_b){s.left="";_2.remove(_c,"dijitIEFixedToolbar");if(this._IEOriginalPos){_3.place(_c,this._IEOriginalPos[1],this._IEOriginalPos[0]);this._IEOriginalPos=null;}else{_3.place(_c,this.editor.iframe,"before");}}s.width="";this._fixEnabled=false;}}},destroy:function(){this._IEOriginalPos=null;this._handleScroll=false;this.inherited(arguments);if(_6("ie")<7){_2.remove(this.editor.header,"dijitIEFixedToolbar");}}});}); \ No newline at end of file