+ * @class Roo.Resizable
+ * @extends Roo.util.Observable
+ * <p>Applies drag handles to an element to make it resizable. The drag handles are inserted into the element
+ * and positioned absolute. Some elements, such as a textarea or image, don't support this. To overcome that, you can wrap
+ * the textarea in a div and set "resizeChild" to true (or to the id of the element), <b>or</b> set wrap:true in your config and
+ * the element will be wrapped for you automatically.</p>
+ * <p>Here is the list of valid resize handles:</p>
+ * <pre>
+Value Description
+------ -------------------
+ 'n' north
+ 's' south
+ 'e' east
+ 'w' west
+ 'nw' northwest
+ 'sw' southwest
+ 'se' southeast
+ 'ne' northeast
+ 'hd' horizontal drag
+ 'all' all
+</pre>
+ * <p>Here's an example showing the creation of a typical Resizable:</p>
+ * <pre><code>
+var resizer = new Roo.Resizable("element-id", {
+ handles: 'all',
+ minWidth: 200,
+ minHeight: 100,
+ maxWidth: 500,
+ maxHeight: 400,
+ pinned: true
+});
+resizer.on("resize", myHandler);
+</code></pre>
+ * <p>To hide a particular handle, set its display to none in CSS, or through script:<br>
+ * resizer.east.setDisplayed(false);</p>
+ * @cfg {Boolean/String/Element} resizeChild True to resize the first child, or id/element to resize (defaults to false)
+ * @cfg {Array/String} adjustments String "auto" or an array [width, height] with values to be <b>added</b> to the
+ * resize operation's new size (defaults to [0, 0])
+ * @cfg {Number} minWidth The minimum width for the element (defaults to 5)
+ * @cfg {Number} minHeight The minimum height for the element (defaults to 5)
+ * @cfg {Number} maxWidth The maximum width for the element (defaults to 10000)
+ * @cfg {Number} maxHeight The maximum height for the element (defaults to 10000)
+ * @cfg {Boolean} enabled False to disable resizing (defaults to true)
+ * @cfg {Boolean} wrap True to wrap an element with a div if needed (required for textareas and images, defaults to false)
+ * @cfg {Number} width The width of the element in pixels (defaults to null)
+ * @cfg {Number} height The height of the element in pixels (defaults to null)
+ * @cfg {Boolean} animate True to animate the resize (not compatible with dynamic sizing, defaults to false)
+ * @cfg {Number} duration Animation duration if animate = true (defaults to .35)
+ * @cfg {Boolean} dynamic True to resize the element while dragging instead of using a proxy (defaults to false)
+ * @cfg {String} handles String consisting of the resize handles to display (defaults to undefined)
+ * @cfg {Boolean} multiDirectional <b>Deprecated</b>. The old style of adding multi-direction resize handles, deprecated
+ * in favor of the handles config option (defaults to false)
+ * @cfg {Boolean} disableTrackOver True to disable mouse tracking. This is only applied at config time. (defaults to false)
+ * @cfg {String} easing Animation easing if animate = true (defaults to 'easingOutStrong')
+ * @cfg {Number} widthIncrement The increment to snap the width resize in pixels (dynamic must be true, defaults to 0)
+ * @cfg {Number} heightIncrement The increment to snap the height resize in pixels (dynamic must be true, defaults to 0)
+ * @cfg {Boolean} pinned True to ensure that the resize handles are always visible, false to display them only when the
+ * user mouses over the resizable borders. This is only applied at config time. (defaults to false)
+ * @cfg {Boolean} preserveRatio True to preserve the original ratio between height and width during resize (defaults to false)
+ * @cfg {Boolean} transparent True for transparent handles. This is only applied at config time. (defaults to false)
+ * @cfg {Number} minX The minimum allowed page X for the element (only used for west resizing, defaults to 0)
+ * @cfg {Number} minY The minimum allowed page Y for the element (only used for north resizing, defaults to 0)
+ * @cfg {Boolean} draggable Convenience to initialize drag drop (defaults to false)
+ * @constructor
+ * Create a new resizable component
+ * @param {String/HTMLElement/Roo.Element} el The id or element to resize
+ * @param {Object} config configuration options
+ */
+Roo.Resizable = function(el, config)
+{
+ this.el = Roo.get(el);
+
+ if(config && config.wrap){
+ config.resizeChild = this.el;
+ this.el = this.el.wrap(typeof config.wrap == "object" ? config.wrap : {cls:"xresizable-wrap"});
+ this.el.id = this.el.dom.id = config.resizeChild.id + "-rzwrap";
+ this.el.setStyle("overflow", "hidden");
+ this.el.setPositioning(config.resizeChild.getPositioning());
+ config.resizeChild.clearPositioning();
+ if(!config.width || !config.height){
+ var csize = config.resizeChild.getSize();
+ this.el.setSize(csize.width, csize.height);
+ }
+ if(config.pinned && !config.adjustments){
+ config.adjustments = "auto";
+ }
+ }
+
+ this.proxy = this.el.createProxy({tag: "div", cls: "x-resizable-proxy", id: this.el.id + "-rzproxy"});
+ this.proxy.unselectable();
+ this.proxy.enableDisplayMode('block');
+
+ Roo.apply(this, config);
+
+ if(this.pinned){
+ this.disableTrackOver = true;
+ this.el.addClass("x-resizable-pinned");
+ }
+ // if the element isn't positioned, make it relative
+ var position = this.el.getStyle("position");
+ if(position != "absolute" && position != "fixed"){
+ this.el.setStyle("position", "relative");
+ }
+ if(!this.handles){ // no handles passed, must be legacy style
+ this.handles = 's,e,se';
+ if(this.multiDirectional){
+ this.handles += ',n,w';
+ }
+ }
+ if(this.handles == "all"){
+ this.handles = "n s e w ne nw se sw";
+ }
+ var hs = this.handles.split(/\s*?[,;]\s*?| /);
+ var ps = Roo.Resizable.positions;
+ for(var i = 0, len = hs.length; i < len; i++){
+ if(hs[i] && ps[hs[i]]){
+ var pos = ps[hs[i]];
+ this[pos] = new Roo.Resizable.Handle(this, pos, this.disableTrackOver, this.transparent);
+ }
+ }
+ // legacy
+ this.corner = this.southeast;
+
+ // updateBox = the box can move..
+ if(this.handles.indexOf("n") != -1 || this.handles.indexOf("w") != -1 || this.handles.indexOf("hd") != -1) {
+ this.updateBox = true;
+ }
+
+ this.activeHandle = null;
+
+ if(this.resizeChild){
+ if(typeof this.resizeChild == "boolean"){
+ this.resizeChild = Roo.get(this.el.dom.firstChild, true);
+ }else{
+ this.resizeChild = Roo.get(this.resizeChild, true);
+ }
+ }
+
+ if(this.adjustments == "auto"){
+ var rc = this.resizeChild;
+ var hw = this.west, he = this.east, hn = this.north, hs = this.south;
+ if(rc && (hw || hn)){
+ rc.position("relative");
+ rc.setLeft(hw ? hw.el.getWidth() : 0);
+ rc.setTop(hn ? hn.el.getHeight() : 0);
+ }
+ this.adjustments = [
+ (he ? -he.el.getWidth() : 0) + (hw ? -hw.el.getWidth() : 0),
+ (hn ? -hn.el.getHeight() : 0) + (hs ? -hs.el.getHeight() : 0) -1
+ ];
+ }
+
+ if(this.draggable){
+ this.dd = this.dynamic ?
+ this.el.initDD(null) : this.el.initDDProxy(null, {dragElId: this.proxy.id});
+ this.dd.setHandleElId(this.resizeChild ? this.resizeChild.id : this.el.id);
+ }
+
+ // public events
+ this.addEvents({
+ /**
+ * @event beforeresize
+ * Fired before resize is allowed. Set enabled to false to cancel resize.
+ * @param {Roo.Resizable} this
+ * @param {Roo.EventObject} e The mousedown event
+ */
+ "beforeresize" : true,
+ /**
+ * @event resizing
+ * Fired a resizing.
+ * @param {Roo.Resizable} this
+ * @param {Number} x The new x position
+ * @param {Number} y The new y position
+ * @param {Number} w The new w width
+ * @param {Number} h The new h hight
+ * @param {Roo.EventObject} e The mouseup event
+ */
+ "resizing" : true,
+ /**
+ * @event resize
+ * Fired after a resize.
+ * @param {Roo.Resizable} this
+ * @param {Number} width The new width
+ * @param {Number} height The new height
+ * @param {Roo.EventObject} e The mouseup event
+ */
+ "resize" : true
+ });
+
+ if(this.width !== null && this.height !== null){
+ this.resizeTo(this.width, this.height);
+ }else{
+ this.updateChildSize();
+ }
+ if(Roo.isIE){
+ this.el.dom.style.zoom = 1;
+ }
+ Roo.Resizable.superclass.constructor.call(this);
+};
+
+Roo.extend(Roo.Resizable, Roo.util.Observable, {
+ resizeChild : false,
+ adjustments : [0, 0],
+ minWidth : 5,
+ minHeight : 5,
+ maxWidth : 10000,
+ maxHeight : 10000,
+ enabled : true,
+ animate : false,
+ duration : .35,
+ dynamic : false,
+ handles : false,
+ multiDirectional : false,
+ disableTrackOver : false,
+ easing : 'easeOutStrong',
+ widthIncrement : 0,
+ heightIncrement : 0,
+ pinned : false,
+ width : null,
+ height : null,
+ preserveRatio : false,
+ transparent: false,
+ minX: 0,
+ minY: 0,
+ draggable: false,
+
+ /**
+ * @cfg {String/HTMLElement/Element} constrainTo Constrain the resize to a particular element
+ */
+ constrainTo: undefined,
+ /**
+ * @cfg {Roo.lib.Region} resizeRegion Constrain the resize to a particular region
+ */
+ resizeRegion: undefined,
+
+
+ /**
+ * Perform a manual resize
+ * @param {Number} width
+ * @param {Number} height
+ */
+ resizeTo : function(width, height){
+ this.el.setSize(width, height);
+ this.updateChildSize();
+ this.fireEvent("resize", this, width, height, null);
+ },
+
+ // private
+ startSizing : function(e, handle){
+ this.fireEvent("beforeresize", this, e);
+ if(this.enabled){ // 2nd enabled check in case disabled before beforeresize handler
+
+ if(!this.overlay){
+ this.overlay = this.el.createProxy({tag: "div", cls: "x-resizable-overlay", html: " "});
+ this.overlay.unselectable();
+ this.overlay.enableDisplayMode("block");
+ this.overlay.on("mousemove", this.onMouseMove, this);
+ this.overlay.on("mouseup", this.onMouseUp, this);
+ }
+ this.overlay.setStyle("cursor", handle.el.getStyle("cursor"));
+
+ this.resizing = true;
+ this.startBox = this.el.getBox();
+ this.startPoint = e.getXY();
+ this.offsets = [(this.startBox.x + this.startBox.width) - this.startPoint[0],
+ (this.startBox.y + this.startBox.height) - this.startPoint[1]];
+
+ this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
+ this.overlay.show();
+
+ if(this.constrainTo) {
+ var ct = Roo.get(this.constrainTo);
+ this.resizeRegion = ct.getRegion().adjust(
+ ct.getFrameWidth('t'),
+ ct.getFrameWidth('l'),
+ -ct.getFrameWidth('b'),
+ -ct.getFrameWidth('r')
+ );
+ }
+
+ this.proxy.setStyle('visibility', 'hidden'); // workaround display none
+ this.proxy.show();
+ this.proxy.setBox(this.startBox);
+ if(!this.dynamic){
+ this.proxy.setStyle('visibility', 'visible');
+ }
+ }
+ },
+
+ // private
+ onMouseDown : function(handle, e){
+ if(this.enabled){
+ e.stopEvent();
+ this.activeHandle = handle;
+ this.startSizing(e, handle);
+ }
+ },
+
+ // private
+ onMouseUp : function(e){
+ var size = this.resizeElement();
+ this.resizing = false;
+ this.handleOut();
+ this.overlay.hide();
+ this.proxy.hide();
+ this.fireEvent("resize", this, size.width, size.height, e);
+ },
+
+ // private
+ updateChildSize : function(){
+
+ if(this.resizeChild){
+ var el = this.el;
+ var child = this.resizeChild;
+ var adj = this.adjustments;
+ if(el.dom.offsetWidth){
+ var b = el.getSize(true);
+ child.setSize(b.width+adj[0], b.height+adj[1]);
+ }
+ // Second call here for IE
+ // The first call enables instant resizing and
+ // the second call corrects scroll bars if they
+ // exist
+ if(Roo.isIE){
+ setTimeout(function(){
+ if(el.dom.offsetWidth){
+ var b = el.getSize(true);
+ child.setSize(b.width+adj[0], b.height+adj[1]);
+ }
+ }, 10);
+ }
+ }
+ },
+
+ // private
+ snap : function(value, inc, min){
+ if(!inc || !value) {
+ return value;
+ }
+ var newValue = value;
+ var m = value % inc;
+ if(m > 0){
+ if(m > (inc/2)){
+ newValue = value + (inc-m);
+ }else{
+ newValue = value - m;
+ }
+ }
+ return Math.max(min, newValue);
+ },
+
+ // private
+ resizeElement : function(){
+ var box = this.proxy.getBox();
+ if(this.updateBox){
+ this.el.setBox(box, false, this.animate, this.duration, null, this.easing);
+ }else{
+ this.el.setSize(box.width, box.height, this.animate, this.duration, null, this.easing);
+ }
+ this.updateChildSize();
+ if(!this.dynamic){
+ this.proxy.hide();
+ }
+ return box;
+ },
+
+ // private
+ constrain : function(v, diff, m, mx){
+ if(v - diff < m){
+ diff = v - m;
+ }else if(v - diff > mx){
+ diff = mx - v;
+ }
+ return diff;
+ },
+
+ // private
+ onMouseMove : function(e){
+
+ if(this.enabled){
+ try{// try catch so if something goes wrong the user doesn't get hung
+
+ if(this.resizeRegion && !this.resizeRegion.contains(e.getPoint())) {
+ return;
+ }
+
+ //var curXY = this.startPoint;
+ var curSize = this.curSize || this.startBox;
+ var x = this.startBox.x, y = this.startBox.y;
+ var ox = x, oy = y;
+ var w = curSize.width, h = curSize.height;
+ var ow = w, oh = h;
+ var mw = this.minWidth, mh = this.minHeight;
+ var mxw = this.maxWidth, mxh = this.maxHeight;
+ var wi = this.widthIncrement;
+ var hi = this.heightIncrement;
+
+ var eventXY = e.getXY();
+ var diffX = -(this.startPoint[0] - Math.max(this.minX, eventXY[0]));
+ var diffY = -(this.startPoint[1] - Math.max(this.minY, eventXY[1]));
+
+ var pos = this.activeHandle.position;
+
+ switch(pos){
+ case "east":
+ w += diffX;
+ w = Math.min(Math.max(mw, w), mxw);
+ break;
+
+ case "south":
+ h += diffY;
+ h = Math.min(Math.max(mh, h), mxh);
+ break;
+ case "southeast":
+ w += diffX;
+ h += diffY;
+ w = Math.min(Math.max(mw, w), mxw);
+ h = Math.min(Math.max(mh, h), mxh);
+ break;
+ case "north":
+ diffY = this.constrain(h, diffY, mh, mxh);
+ y += diffY;
+ h -= diffY;
+ break;
+ case "hdrag":
+
+ if (wi) {
+ var adiffX = Math.abs(diffX);
+ var sub = (adiffX % wi); // how much
+ if (sub > (wi/2)) { // far enough to snap
+ diffX = (diffX > 0) ? diffX-sub + wi : diffX+sub - wi;
+ } else {
+ // remove difference..
+ diffX = (diffX > 0) ? diffX-sub : diffX+sub;
+ }
+ }
+ x += diffX;
+ x = Math.max(this.minX, x);
+ break;
+ case "west":
+ diffX = this.constrain(w, diffX, mw, mxw);
+ x += diffX;
+ w -= diffX;
+ break;
+ case "northeast":
+ w += diffX;
+ w = Math.min(Math.max(mw, w), mxw);
+ diffY = this.constrain(h, diffY, mh, mxh);
+ y += diffY;
+ h -= diffY;
+ break;
+ case "northwest":
+ diffX = this.constrain(w, diffX, mw, mxw);
+ diffY = this.constrain(h, diffY, mh, mxh);
+ y += diffY;
+ h -= diffY;
+ x += diffX;
+ w -= diffX;
+ break;
+ case "southwest":
+ diffX = this.constrain(w, diffX, mw, mxw);
+ h += diffY;
+ h = Math.min(Math.max(mh, h), mxh);
+ x += diffX;
+ w -= diffX;
+ break;
+ }
+
+ var sw = this.snap(w, wi, mw);
+ var sh = this.snap(h, hi, mh);
+ if(sw != w || sh != h){
+ switch(pos){
+ case "northeast":
+ y -= sh - h;
+ break;
+ case "north":
+ y -= sh - h;
+ break;
+ case "southwest":
+ x -= sw - w;
+ break;
+ case "west":
+ x -= sw - w;
+ break;
+ case "northwest":
+ x -= sw - w;
+ y -= sh - h;
+ break;
+ }
+ w = sw;
+ h = sh;
+ }
+
+ if(this.preserveRatio){
+ switch(pos){
+ case "southeast":
+ case "east":
+ h = oh * (w/ow);
+ h = Math.min(Math.max(mh, h), mxh);
+ w = ow * (h/oh);
+ break;
+ case "south":
+ w = ow * (h/oh);
+ w = Math.min(Math.max(mw, w), mxw);
+ h = oh * (w/ow);
+ break;
+ case "northeast":
+ w = ow * (h/oh);
+ w = Math.min(Math.max(mw, w), mxw);
+ h = oh * (w/ow);
+ break;
+ case "north":
+ var tw = w;
+ w = ow * (h/oh);
+ w = Math.min(Math.max(mw, w), mxw);
+ h = oh * (w/ow);
+ x += (tw - w) / 2;
+ break;
+ case "southwest":
+ h = oh * (w/ow);
+ h = Math.min(Math.max(mh, h), mxh);
+ var tw = w;
+ w = ow * (h/oh);
+ x += tw - w;
+ break;
+ case "west":
+ var th = h;
+ h = oh * (w/ow);
+ h = Math.min(Math.max(mh, h), mxh);
+ y += (th - h) / 2;
+ var tw = w;
+ w = ow * (h/oh);
+ x += tw - w;
+ break;
+ case "northwest":
+ var tw = w;
+ var th = h;
+ h = oh * (w/ow);
+ h = Math.min(Math.max(mh, h), mxh);
+ w = ow * (h/oh);
+ y += th - h;
+ x += tw - w;
+ break;
+
+ }
+ }
+ if (pos == 'hdrag') {
+ w = ow;
+ }
+ this.proxy.setBounds(x, y, w, h);
+ if(this.dynamic){
+ this.resizeElement();
+ }
+ }catch(e){}
+ }
+ this.fireEvent("resizing", this, x, y, w, h, e);
+ },
+
+ // private
+ handleOver : function(){
+ if(this.enabled){
+ this.el.addClass("x-resizable-over");
+ }
+ },
+
+ // private
+ handleOut : function(){
+ if(!this.resizing){
+ this.el.removeClass("x-resizable-over");
+ }
+ },
+
+ /**
+ * Returns the element this component is bound to.
+ * @return {Roo.Element}
+ */
+ getEl : function(){
+ return this.el;
+ },
+
+ /**
+ * Returns the resizeChild element (or null).
+ * @return {Roo.Element}
+ */
+ getResizeChild : function(){
+ return this.resizeChild;
+ },
+ groupHandler : function()
+ {
+
+ },
+ /**
+ * Destroys this resizable. If the element was wrapped and
+ * removeEl is not true then the element remains.
+ * @param {Boolean} removeEl (optional) true to remove the element from the DOM
+ */
+ destroy : function(removeEl){
+ this.proxy.remove();
+ if(this.overlay){
+ this.overlay.removeAllListeners();
+ this.overlay.remove();
+ }
+ var ps = Roo.Resizable.positions;
+ for(var k in ps){
+ if(typeof ps[k] != "function" && this[ps[k]]){
+ var h = this[ps[k]];
+ h.el.removeAllListeners();
+ h.el.remove();
+ }
+ }
+ if(removeEl){
+ this.el.update("");
+ this.el.remove();
+ }
+ }
+});
+
+// private
+// hash to map config positions to true positions
+Roo.Resizable.positions = {
+ n: "north", s: "south", e: "east", w: "west", se: "southeast", sw: "southwest", nw: "northwest", ne: "northeast",
+ hd: "hdrag"
+};
+
+// private
+Roo.Resizable.Handle = function(rz, pos, disableTrackOver, transparent){
+ if(!this.tpl){
+ // only initialize the template if resizable is used
+ var tpl = Roo.DomHelper.createTemplate(
+ {tag: "div", cls: "x-resizable-handle x-resizable-handle-{0}"}
+ );
+ tpl.compile();
+ Roo.Resizable.Handle.prototype.tpl = tpl;
+ }
+ this.position = pos;
+ this.rz = rz;
+ // show north drag fro topdra
+ var handlepos = pos == 'hdrag' ? 'north' : pos;
+
+ this.el = this.tpl.append(rz.el.dom, [handlepos], true);
+ if (pos == 'hdrag') {
+ this.el.setStyle('cursor', 'pointer');
+ }
+ this.el.unselectable();
+ if(transparent){
+ this.el.setOpacity(0);
+ }
+ this.el.on("mousedown", this.onMouseDown, this);
+ if(!disableTrackOver){
+ this.el.on("mouseover", this.onMouseOver, this);
+ this.el.on("mouseout", this.onMouseOut, this);
+ }
+};
+
+// private
+Roo.Resizable.Handle.prototype = {
+ afterResize : function(rz){
+ Roo.log('after?');
+ // do nothing
+ },
+ // private
+ onMouseDown : function(e){
+ this.rz.onMouseDown(this, e);
+ },
+ // private
+ onMouseOver : function(e){
+ this.rz.handleOver(this, e);
+ },
+ // private
+ onMouseOut : function(e){
+ this.rz.handleOut(this, e);
+ }
+};/*
+ * Based on:
+ * Ext JS Library 1.1.1
+ * Copyright(c) 2006-2007, Ext JS, LLC.
+ *
+ * Originally Released Under LGPL - original licence link has changed is not relivant.
+ *
+ * Fork - LGPL
+ * <script type="text/javascript">
+ */
+
+/**
+ * @class Roo.Editor
+ * @extends Roo.Component
+ * A base editor field that handles displaying/hiding on demand and has some built-in sizing and event handling logic.
+ * @constructor
+ * Create a new Editor
+ * @param {Roo.form.Field} field The Field object (or descendant)
+ * @param {Object} config The config object
+ */
+Roo.Editor = function(field, config){
+ Roo.Editor.superclass.constructor.call(this, config);
+ this.field = field;
+ this.addEvents({
+ /**
+ * @event beforestartedit
+ * Fires when editing is initiated, but before the value changes. Editing can be canceled by returning
+ * false from the handler of this event.
+ * @param {Editor} this
+ * @param {Roo.Element} boundEl The underlying element bound to this editor
+ * @param {Mixed} value The field value being set
+ */
+ "beforestartedit" : true,
+ /**
+ * @event startedit
+ * Fires when this editor is displayed
+ * @param {Roo.Element} boundEl The underlying element bound to this editor
+ * @param {Mixed} value The starting field value
+ */
+ "startedit" : true,
+ /**
+ * @event beforecomplete
+ * Fires after a change has been made to the field, but before the change is reflected in the underlying
+ * field. Saving the change to the field can be canceled by returning false from the handler of this event.
+ * Note that if the value has not changed and ignoreNoChange = true, the editing will still end but this
+ * event will not fire since no edit actually occurred.
+ * @param {Editor} this
+ * @param {Mixed} value The current field value
+ * @param {Mixed} startValue The original field value
+ */
+ "beforecomplete" : true,
+ /**
+ * @event complete
+ * Fires after editing is complete and any changed value has been written to the underlying field.
+ * @param {Editor} this
+ * @param {Mixed} value The current field value
+ * @param {Mixed} startValue The original field value
+ */
+ "complete" : true,
+ /**
+ * @event specialkey
+ * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
+ * {@link Roo.EventObject#getKey} to determine which key was pressed.
+ * @param {Roo.form.Field} this
+ * @param {Roo.EventObject} e The event object
+ */
+ "specialkey" : true
+ });
+};
+
+Roo.extend(Roo.Editor, Roo.Component, {
+ /**
+ * @cfg {Boolean/String} autosize
+ * True for the editor to automatically adopt the size of the underlying field, "width" to adopt the width only,
+ * or "height" to adopt the height only (defaults to false)
+ */
+ /**
+ * @cfg {Boolean} revertInvalid
+ * True to automatically revert the field value and cancel the edit when the user completes an edit and the field
+ * validation fails (defaults to true)
+ */
+ /**
+ * @cfg {Boolean} ignoreNoChange
+ * True to skip the the edit completion process (no save, no events fired) if the user completes an edit and
+ * the value has not changed (defaults to false). Applies only to string values - edits for other data types
+ * will never be ignored.
+ */
+ /**
+ * @cfg {Boolean} hideEl
+ * False to keep the bound element visible while the editor is displayed (defaults to true)
+ */
+ /**
+ * @cfg {Mixed} value
+ * The data value of the underlying field (defaults to "")
+ */
+ value : "",
+ /**
+ * @cfg {String} alignment
+ * The position to align to (see {@link Roo.Element#alignTo} for more details, defaults to "c-c?").
+ */
+ alignment: "c-c?",
+ /**
+ * @cfg {Boolean/String} shadow "sides" for sides/bottom only, "frame" for 4-way shadow, and "drop"
+ * for bottom-right shadow (defaults to "frame")
+ */
+ shadow : "frame",
+ /**
+ * @cfg {Boolean} constrain True to constrain the editor to the viewport
+ */
+ constrain : false,
+ /**
+ * @cfg {Boolean} completeOnEnter True to complete the edit when the enter key is pressed (defaults to false)
+ */
+ completeOnEnter : false,
+ /**
+ * @cfg {Boolean} cancelOnEsc True to cancel the edit when the escape key is pressed (defaults to false)
+ */
+ cancelOnEsc : false,
+ /**
+ * @cfg {Boolean} updateEl True to update the innerHTML of the bound element when the update completes (defaults to false)
+ */
+ updateEl : false,
+
+ // private
+ onRender : function(ct, position){
+ this.el = new Roo.Layer({
+ shadow: this.shadow,
+ cls: "x-editor",
+ parentEl : ct,
+ shim : this.shim,
+ shadowOffset:4,
+ id: this.id,
+ constrain: this.constrain
+ });
+ this.el.setStyle("overflow", Roo.isGecko ? "auto" : "hidden");
+ if(this.field.msgTarget != 'title'){
+ this.field.msgTarget = 'qtip';
+ }
+ this.field.render(this.el);
+ if(Roo.isGecko){
+ this.field.el.dom.setAttribute('autocomplete', 'off');
+ }
+ this.field.on("specialkey", this.onSpecialKey, this);
+ if(this.swallowKeys){
+ this.field.el.swallowEvent(['keydown','keypress']);
+ }
+ this.field.show();
+ this.field.on("blur", this.onBlur, this);
+ if(this.field.grow){
+ this.field.on("autosize", this.el.sync, this.el, {delay:1});
+ }
+ },
+
+ onSpecialKey : function(field, e)
+ {
+ //Roo.log('editor onSpecialKey');
+ if(this.completeOnEnter && e.getKey() == e.ENTER){
+ e.stopEvent();
+ this.completeEdit();
+ return;
+ }
+ // do not fire special key otherwise it might hide close the editor...
+ if(e.getKey() == e.ENTER){
+ return;
+ }
+ if(this.cancelOnEsc && e.getKey() == e.ESC){
+ this.cancelEdit();
+ return;
+ }
+ this.fireEvent('specialkey', field, e);
+
+ },
+
+ /**
+ * Starts the editing process and shows the editor.
+ * @param {String/HTMLElement/Element} el The element to edit
+ * @param {String} value (optional) A value to initialize the editor with. If a value is not provided, it defaults
+ * to the innerHTML of el.
+ */
+ startEdit : function(el, value){
+ if(this.editing){
+ this.completeEdit();
+ }
+ this.boundEl = Roo.get(el);
+ var v = value !== undefined ? value : this.boundEl.dom.innerHTML;
+ if(!this.rendered){
+ this.render(this.parentEl || document.body);
+ }
+ if(this.fireEvent("beforestartedit", this, this.boundEl, v) === false){
+ return;
+ }
+ this.startValue = v;
+ this.field.setValue(v);
+ if(this.autoSize){
+ var sz = this.boundEl.getSize();
+ switch(this.autoSize){
+ case "width":
+ this.setSize(sz.width, "");
+ break;
+ case "height":
+ this.setSize("", sz.height);
+ break;
+ default:
+ this.setSize(sz.width, sz.height);
+ }
+ }
+ this.el.alignTo(this.boundEl, this.alignment);
+ this.editing = true;
+ if(Roo.QuickTips){
+ Roo.QuickTips.disable();
+ }
+ this.show();
+ },
+
+ /**
+ * Sets the height and width of this editor.
+ * @param {Number} width The new width
+ * @param {Number} height The new height
+ */
+ setSize : function(w, h){
+ this.field.setSize(w, h);
+ if(this.el){
+ this.el.sync();
+ }
+ },
+
+ /**
+ * Realigns the editor to the bound field based on the current alignment config value.
+ */
+ realign : function(){
+ this.el.alignTo(this.boundEl, this.alignment);
+ },
+
+ /**
+ * Ends the editing process, persists the changed value to the underlying field, and hides the editor.
+ * @param {Boolean} remainVisible Override the default behavior and keep the editor visible after edit (defaults to false)
+ */
+ completeEdit : function(remainVisible){
+ if(!this.editing){
+ return;
+ }
+ var v = this.getValue();
+ if(this.revertInvalid !== false && !this.field.isValid()){
+ v = this.startValue;
+ this.cancelEdit(true);
+ }
+ if(String(v) === String(this.startValue) && this.ignoreNoChange){
+ this.editing = false;
+ this.hide();
+ return;
+ }
+ if(this.fireEvent("beforecomplete", this, v, this.startValue) !== false){
+ this.editing = false;
+ if(this.updateEl && this.boundEl){
+ this.boundEl.update(v);
+ }
+ if(remainVisible !== true){
+ this.hide();
+ }
+ this.fireEvent("complete", this, v, this.startValue);
+ }
+ },
+
+ // private
+ onShow : function(){
+ this.el.show();
+ if(this.hideEl !== false){
+ this.boundEl.hide();
+ }
+ this.field.show();
+ if(Roo.isIE && !this.fixIEFocus){ // IE has problems with focusing the first time
+ this.fixIEFocus = true;
+ this.deferredFocus.defer(50, this);
+ }else{
+ this.field.focus();
+ }
+ this.fireEvent("startedit", this.boundEl, this.startValue);
+ },
+
+ deferredFocus : function(){
+ if(this.editing){
+ this.field.focus();
+ }
+ },
+
+ /**
+ * Cancels the editing process and hides the editor without persisting any changes. The field value will be
+ * reverted to the original starting value.
+ * @param {Boolean} remainVisible Override the default behavior and keep the editor visible after
+ * cancel (defaults to false)
+ */
+ cancelEdit : function(remainVisible){
+ if(this.editing){
+ this.setValue(this.startValue);
+ if(remainVisible !== true){
+ this.hide();
+ }
+ }
+ },
+
+ // private
+ onBlur : function(){
+ if(this.allowBlur !== true && this.editing){
+ this.completeEdit();
+ }
+ },
+
+ // private
+ onHide : function(){
+ if(this.editing){
+ this.completeEdit();
+ return;
+ }
+ this.field.blur();
+ if(this.field.collapse){
+ this.field.collapse();
+ }
+ this.el.hide();
+ if(this.hideEl !== false){
+ this.boundEl.show();
+ }
+ if(Roo.QuickTips){
+ Roo.QuickTips.enable();
+ }
+ },
+
+ /**
+ * Sets the data value of the editor
+ * @param {Mixed} value Any valid value supported by the underlying field
+ */
+ setValue : function(v){
+ this.field.setValue(v);
+ },
+
+ /**
+ * Gets the data value of the editor
+ * @return {Mixed} The data value
+ */
+ getValue : function(){
+ return this.field.getValue();
+ }
+});/*
+ * Based on:
+ * Ext JS Library 1.1.1
+ * Copyright(c) 2006-2007, Ext JS, LLC.
+ *
+ * Originally Released Under LGPL - original licence link has changed is not relivant.
+ *
+ * Fork - LGPL
+ * <script type="text/javascript">
+ */
+
+/**
+ * @class Roo.BasicDialog
+ * @extends Roo.util.Observable
+ * @parent none builder
+ * Lightweight Dialog Class. The code below shows the creation of a typical dialog using existing HTML markup:
+ * <pre><code>
+var dlg = new Roo.BasicDialog("my-dlg", {
+ height: 200,
+ width: 300,
+ minHeight: 100,
+ minWidth: 150,
+ modal: true,
+ proxyDrag: true,
+ shadow: true
+});
+dlg.addKeyListener(27, dlg.hide, dlg); // ESC can also close the dialog
+dlg.addButton('OK', dlg.hide, dlg); // Could call a save function instead of hiding
+dlg.addButton('Cancel', dlg.hide, dlg);
+dlg.show();
+</code></pre>
+ <b>A Dialog should always be a direct child of the body element.</b>
+ * @cfg {Boolean/DomHelper} autoCreate True to auto create from scratch, or using a DomHelper Object (defaults to false)
+ * @cfg {String} title Default text to display in the title bar (defaults to null)
+ * @cfg {Number} width Width of the dialog in pixels (can also be set via CSS). Determined by browser if unspecified.
+ * @cfg {Number} height Height of the dialog in pixels (can also be set via CSS). Determined by browser if unspecified.
+ * @cfg {Number} x The default left page coordinate of the dialog (defaults to center screen)
+ * @cfg {Number} y The default top page coordinate of the dialog (defaults to center screen)
+ * @cfg {String/Element} animateTarget Id or element from which the dialog should animate while opening
+ * (defaults to null with no animation)
+ * @cfg {Boolean} resizable False to disable manual dialog resizing (defaults to true)
+ * @cfg {String} resizeHandles Which resize handles to display - see the {@link Roo.Resizable} handles config
+ * property for valid values (defaults to 'all')
+ * @cfg {Number} minHeight The minimum allowable height for a resizable dialog (defaults to 80)
+ * @cfg {Number} minWidth The minimum allowable width for a resizable dialog (defaults to 200)
+ * @cfg {Boolean} modal True to show the dialog modally, preventing user interaction with the rest of the page (defaults to false)
+ * @cfg {Boolean} autoScroll True to allow the dialog body contents to overflow and display scrollbars (defaults to false)
+ * @cfg {Boolean} closable False to remove the built-in top-right corner close button (defaults to true)
+ * @cfg {Boolean} collapsible False to remove the built-in top-right corner collapse button (defaults to true)
+ * @cfg {Boolean} constraintoviewport True to keep the dialog constrained within the visible viewport boundaries (defaults to true)
+ * @cfg {Boolean} syncHeightBeforeShow True to cause the dimensions to be recalculated before the dialog is shown (defaults to false)
+ * @cfg {Boolean} draggable False to disable dragging of the dialog within the viewport (defaults to true)
+ * @cfg {Boolean} autoTabs If true, all elements with class 'x-dlg-tab' will get automatically converted to tabs (defaults to false)
+ * @cfg {String} tabTag The tag name of tab elements, used when autoTabs = true (defaults to 'div')
+ * @cfg {Boolean} proxyDrag True to drag a lightweight proxy element rather than the dialog itself, used when
+ * draggable = true (defaults to false)
+ * @cfg {Boolean} fixedcenter True to ensure that anytime the dialog is shown or resized it gets centered (defaults to false)
+ * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
+ * shadow (defaults to false)
+ * @cfg {Number} shadowOffset The number of pixels to offset the shadow if displayed (defaults to 5)
+ * @cfg {String} buttonAlign Valid values are "left," "center" and "right" (defaults to "right")
+ * @cfg {Number} minButtonWidth Minimum width of all dialog buttons (defaults to 75)
+ * @cfg {Array} buttons Array of buttons
+ * @cfg {Boolean} shim True to create an iframe shim that prevents selects from showing through (defaults to false)
+ * @constructor
+ * Create a new BasicDialog.
+ * @param {String/HTMLElement/Roo.Element} el The container element or DOM node, or its id
+ * @param {Object} config Configuration options
+ */
+Roo.BasicDialog = function(el, config){
+ this.el = Roo.get(el);
+ var dh = Roo.DomHelper;
+ if(!this.el && config && config.autoCreate){
+ if(typeof config.autoCreate == "object"){
+ if(!config.autoCreate.id){
+ config.autoCreate.id = el;
+ }
+ this.el = dh.append(document.body,
+ config.autoCreate, true);
+ }else{
+ this.el = dh.append(document.body,
+ {tag: "div", id: el, style:'visibility:hidden;'}, true);
+ }
+ }
+ el = this.el;
+ el.setDisplayed(true);
+ el.hide = this.hideAction;
+ this.id = el.id;
+ el.addClass("x-dlg");
+
+ Roo.apply(this, config);
+
+ this.proxy = el.createProxy("x-dlg-proxy");
+ this.proxy.hide = this.hideAction;
+ this.proxy.setOpacity(.5);
+ this.proxy.hide();
+
+ if(config.width){
+ el.setWidth(config.width);
+ }
+ if(config.height){
+ el.setHeight(config.height);
+ }
+ this.size = el.getSize();
+ if(typeof config.x != "undefined" && typeof config.y != "undefined"){
+ this.xy = [config.x,config.y];
+ }else{
+ this.xy = el.getCenterXY(true);
+ }
+ /** The header element @type Roo.Element */
+ this.header = el.child("> .x-dlg-hd");
+ /** The body element @type Roo.Element */
+ this.body = el.child("> .x-dlg-bd");
+ /** The footer element @type Roo.Element */
+ this.footer = el.child("> .x-dlg-ft");
+
+ if(!this.header){
+ this.header = el.createChild({tag: "div", cls:"x-dlg-hd", html: " "}, this.body ? this.body.dom : null);
+ }
+ if(!this.body){
+ this.body = el.createChild({tag: "div", cls:"x-dlg-bd"});
+ }
+
+ this.header.unselectable();
+ if(this.title){
+ this.header.update(this.title);
+ }
+ // this element allows the dialog to be focused for keyboard event
+ this.focusEl = el.createChild({tag: "a", href:"#", cls:"x-dlg-focus", tabIndex:"-1"});
+ this.focusEl.swallowEvent("click", true);
+
+ this.header.wrap({cls:"x-dlg-hd-right"}).wrap({cls:"x-dlg-hd-left"}, true);
+
+ // wrap the body and footer for special rendering
+ this.bwrap = this.body.wrap({tag: "div", cls:"x-dlg-dlg-body"});
+ if(this.footer){
+ this.bwrap.dom.appendChild(this.footer.dom);
+ }
+
+ this.bg = this.el.createChild({
+ tag: "div", cls:"x-dlg-bg",
+ html: '<div class="x-dlg-bg-left"><div class="x-dlg-bg-right"><div class="x-dlg-bg-center"> </div></div></div>'
+ });
+ this.centerBg = this.bg.child("div.x-dlg-bg-center");
+
+
+ if(this.autoScroll !== false && !this.autoTabs){
+ this.body.setStyle("overflow", "auto");
+ }
+
+ this.toolbox = this.el.createChild({cls: "x-dlg-toolbox"});
+
+ if(this.closable !== false){
+ this.el.addClass("x-dlg-closable");
+ this.close = this.toolbox.createChild({cls:"x-dlg-close"});
+ this.close.on("click", this.closeClick, this);
+ this.close.addClassOnOver("x-dlg-close-over");
+ }
+ if(this.collapsible !== false){
+ this.collapseBtn = this.toolbox.createChild({cls:"x-dlg-collapse"});
+ this.collapseBtn.on("click", this.collapseClick, this);
+ this.collapseBtn.addClassOnOver("x-dlg-collapse-over");
+ this.header.on("dblclick", this.collapseClick, this);
+ }
+ if(this.resizable !== false){
+ this.el.addClass("x-dlg-resizable");
+ this.resizer = new Roo.Resizable(el, {
+ minWidth: this.minWidth || 80,
+ minHeight:this.minHeight || 80,
+ handles: this.resizeHandles || "all",
+ pinned: true
+ });
+ this.resizer.on("beforeresize", this.beforeResize, this);
+ this.resizer.on("resize", this.onResize, this);
+ }
+ if(this.draggable !== false){
+ el.addClass("x-dlg-draggable");
+ if (!this.proxyDrag) {
+ var dd = new Roo.dd.DD(el.dom.id, "WindowDrag");
+ }
+ else {
+ var dd = new Roo.dd.DDProxy(el.dom.id, "WindowDrag", {dragElId: this.proxy.id});
+ }
+ dd.setHandleElId(this.header.id);
+ dd.endDrag = this.endMove.createDelegate(this);
+ dd.startDrag = this.startMove.createDelegate(this);
+ dd.onDrag = this.onDrag.createDelegate(this);
+ dd.scroll = false;
+ this.dd = dd;
+ }
+ if(this.modal){
+ this.mask = dh.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
+ this.mask.enableDisplayMode("block");
+ this.mask.hide();
+ this.el.addClass("x-dlg-modal");
+ }
+ if(this.shadow){
+ this.shadow = new Roo.Shadow({
+ mode : typeof this.shadow == "string" ? this.shadow : "sides",
+ offset : this.shadowOffset
+ });
+ }else{
+ this.shadowOffset = 0;
+ }
+ if(Roo.useShims && this.shim !== false){
+ this.shim = this.el.createShim();
+ this.shim.hide = this.hideAction;
+ this.shim.hide();
+ }else{
+ this.shim = false;
+ }
+ if(this.autoTabs){
+ this.initTabs();
+ }
+ if (this.buttons) {
+ var bts= this.buttons;
+ this.buttons = [];
+ Roo.each(bts, function(b) {
+ this.addButton(b);
+ }, this);
+ }
+
+
+ this.addEvents({
+ /**
+ * @event keydown
+ * Fires when a key is pressed
+ * @param {Roo.BasicDialog} this
+ * @param {Roo.EventObject} e
+ */
+ "keydown" : true,
+ /**
+ * @event move
+ * Fires when this dialog is moved by the user.
+ * @param {Roo.BasicDialog} this
+ * @param {Number} x The new page X
+ * @param {Number} y The new page Y
+ */
+ "move" : true,
+ /**
+ * @event resize
+ * Fires when this dialog is resized by the user.
+ * @param {Roo.BasicDialog} this
+ * @param {Number} width The new width
+ * @param {Number} height The new height
+ */
+ "resize" : true,
+ /**
+ * @event beforehide
+ * Fires before this dialog is hidden.
+ * @param {Roo.BasicDialog} this
+ */
+ "beforehide" : true,
+ /**
+ * @event hide
+ * Fires when this dialog is hidden.
+ * @param {Roo.BasicDialog} this
+ */
+ "hide" : true,
+ /**
+ * @event beforeshow
+ * Fires before this dialog is shown.
+ * @param {Roo.BasicDialog} this
+ */
+ "beforeshow" : true,
+ /**
+ * @event show
+ * Fires when this dialog is shown.
+ * @param {Roo.BasicDialog} this
+ */
+ "show" : true
+ });
+ el.on("keydown", this.onKeyDown, this);
+ el.on("mousedown", this.toFront, this);
+ Roo.EventManager.onWindowResize(this.adjustViewport, this, true);
+ this.el.hide();
+ Roo.DialogManager.register(this);
+ Roo.BasicDialog.superclass.constructor.call(this);
+};
+
+Roo.extend(Roo.BasicDialog, Roo.util.Observable, {
+ shadowOffset: Roo.isIE ? 6 : 5,
+ minHeight: 80,
+ minWidth: 200,
+ minButtonWidth: 75,
+ defaultButton: null,
+ buttonAlign: "right",
+ tabTag: 'div',
+ firstShow: true,
+
+ /**
+ * Sets the dialog title text
+ * @param {String} text The title text to display
+ * @return {Roo.BasicDialog} this
+ */
+ setTitle : function(text){
+ this.header.update(text);
+ return this;
+ },
+
+ // private
+ closeClick : function(){
+ this.hide();
+ },
+
+ // private
+ collapseClick : function(){
+ this[this.collapsed ? "expand" : "collapse"]();
+ },
+
+ /**
+ * Collapses the dialog to its minimized state (only the title bar is visible).
+ * Equivalent to the user clicking the collapse dialog button.
+ */
+ collapse : function(){
+ if(!this.collapsed){
+ this.collapsed = true;
+ this.el.addClass("x-dlg-collapsed");
+ this.restoreHeight = this.el.getHeight();
+ this.resizeTo(this.el.getWidth(), this.header.getHeight());
+ }
+ },
+
+ /**
+ * Expands a collapsed dialog back to its normal state. Equivalent to the user
+ * clicking the expand dialog button.
+ */
+ expand : function(){
+ if(this.collapsed){
+ this.collapsed = false;
+ this.el.removeClass("x-dlg-collapsed");
+ this.resizeTo(this.el.getWidth(), this.restoreHeight);
+ }
+ },
+
+ /**
+ * Reinitializes the tabs component, clearing out old tabs and finding new ones.
+ * @return {Roo.TabPanel} The tabs component
+ */
+ initTabs : function(){
+ var tabs = this.getTabs();
+ while(tabs.getTab(0)){
+ tabs.removeTab(0);
+ }
+ this.el.select(this.tabTag+'.x-dlg-tab').each(function(el){
+ var dom = el.dom;
+ tabs.addTab(Roo.id(dom), dom.title);
+ dom.title = "";
+ });
+ tabs.activate(0);
+ return tabs;
+ },
+
+ // private
+ beforeResize : function(){
+ this.resizer.minHeight = Math.max(this.minHeight, this.getHeaderFooterHeight(true)+40);
+ },
+
+ // private
+ onResize : function(){
+ this.refreshSize();
+ this.syncBodyHeight();
+ this.adjustAssets();
+ this.focus();
+ this.fireEvent("resize", this, this.size.width, this.size.height);
+ },
+
+ // private
+ onKeyDown : function(e){
+ if(this.isVisible()){
+ this.fireEvent("keydown", this, e);
+ }
+ },
+
+ /**
+ * Resizes the dialog.
+ * @param {Number} width
+ * @param {Number} height
+ * @return {Roo.BasicDialog} this
+ */
+ resizeTo : function(width, height){
+ this.el.setSize(width, height);
+ this.size = {width: width, height: height};
+ this.syncBodyHeight();
+ if(this.fixedcenter){
+ this.center();
+ }
+ if(this.isVisible()){
+ this.constrainXY();
+ this.adjustAssets();
+ }
+ this.fireEvent("resize", this, width, height);
+ return this;
+ },
+
+
+ /**
+ * Resizes the dialog to fit the specified content size.
+ * @param {Number} width
+ * @param {Number} height
+ * @return {Roo.BasicDialog} this
+ */
+ setContentSize : function(w, h){
+ h += this.getHeaderFooterHeight() + this.body.getMargins("tb");
+ w += this.body.getMargins("lr") + this.bwrap.getMargins("lr") + this.centerBg.getPadding("lr");
+ //if(!this.el.isBorderBox()){
+ h += this.body.getPadding("tb") + this.bwrap.getBorderWidth("tb") + this.body.getBorderWidth("tb") + this.el.getBorderWidth("tb");
+ w += this.body.getPadding("lr") + this.bwrap.getBorderWidth("lr") + this.body.getBorderWidth("lr") + this.bwrap.getPadding("lr") + this.el.getBorderWidth("lr");
+ //}
+ if(this.tabs){
+ h += this.tabs.stripWrap.getHeight() + this.tabs.bodyEl.getMargins("tb") + this.tabs.bodyEl.getPadding("tb");
+ w += this.tabs.bodyEl.getMargins("lr") + this.tabs.bodyEl.getPadding("lr");
+ }
+ this.resizeTo(w, h);
+ return this;
+ },
+
+ /**
+ * Adds a key listener for when this dialog is displayed. This allows you to hook in a function that will be
+ * executed in response to a particular key being pressed while the dialog is active.
+ * @param {Number/Array/Object} key Either the numeric key code, array of key codes or an object with the following options:
+ * {key: (number or array), shift: (true/false), ctrl: (true/false), alt: (true/false)}
+ * @param {Function} fn The function to call
+ * @param {Object} scope (optional) The scope of the function
+ * @return {Roo.BasicDialog} this
+ */
+ addKeyListener : function(key, fn, scope){
+ var keyCode, shift, ctrl, alt;
+ if(typeof key == "object" && !(key instanceof Array)){
+ keyCode = key["key"];
+ shift = key["shift"];
+ ctrl = key["ctrl"];
+ alt = key["alt"];
+ }else{
+ keyCode = key;
+ }
+ var handler = function(dlg, e){
+ if((!shift || e.shiftKey) && (!ctrl || e.ctrlKey) && (!alt || e.altKey)){
+ var k = e.getKey();
+ if(keyCode instanceof Array){
+ for(var i = 0, len = keyCode.length; i < len; i++){
+ if(keyCode[i] == k){
+ fn.call(scope || window, dlg, k, e);
+ return;
+ }
+ }
+ }else{
+ if(k == keyCode){
+ fn.call(scope || window, dlg, k, e);
+ }
+ }
+ }
+ };
+ this.on("keydown", handler);
+ return this;
+ },
+
+ /**
+ * Returns the TabPanel component (creates it if it doesn't exist).
+ * Note: If you wish to simply check for the existence of tabs without creating them,
+ * check for a null 'tabs' property.
+ * @return {Roo.TabPanel} The tabs component
+ */
+ getTabs : function(){
+ if(!this.tabs){
+ this.el.addClass("x-dlg-auto-tabs");
+ this.body.addClass(this.tabPosition == "bottom" ? "x-tabs-bottom" : "x-tabs-top");
+ this.tabs = new Roo.TabPanel(this.body.dom, this.tabPosition == "bottom");
+ }
+ return this.tabs;
+ },
+
+ /**
+ * Adds a button to the footer section of the dialog.
+ * @param {String/Object} config A string becomes the button text, an object can either be a Button config
+ * object or a valid Roo.DomHelper element config
+ * @param {Function} handler The function called when the button is clicked
+ * @param {Object} scope (optional) The scope of the handler function (accepts position as a property)
+ * @return {Roo.Button} The new button
+ */
+ addButton : function(config, handler, scope){
+ var dh = Roo.DomHelper;
+ if(!this.footer){
+ this.footer = dh.append(this.bwrap, {tag: "div", cls:"x-dlg-ft"}, true);
+ }
+ if(!this.btnContainer){
+ var tb = this.footer.createChild({
+
+ cls:"x-dlg-btns x-dlg-btns-"+this.buttonAlign,
+ html:'<table cellspacing="0"><tbody><tr></tr></tbody></table><div class="x-clear"></div>'
+ }, null, true);
+ this.btnContainer = tb.firstChild.firstChild.firstChild;
+ }
+ var bconfig = {
+ handler: handler,
+ scope: scope,
+ minWidth: this.minButtonWidth,
+ hideParent:true
+ };
+ if(typeof config == "string"){
+ bconfig.text = config;
+ }else{
+ if(config.tag){
+ bconfig.dhconfig = config;
+ }else{
+ Roo.apply(bconfig, config);
+ }
+ }
+ var fc = false;
+ if ((typeof(bconfig.position) != 'undefined') && bconfig.position < this.btnContainer.childNodes.length-1) {
+ bconfig.position = Math.max(0, bconfig.position);
+ fc = this.btnContainer.childNodes[bconfig.position];
+ }
+
+ var btn = new Roo.Button(
+ fc ?
+ this.btnContainer.insertBefore(document.createElement("td"),fc)
+ : this.btnContainer.appendChild(document.createElement("td")),
+ //Roo.get(this.btnContainer).createChild( { tag: 'td'}, fc ),
+ bconfig
+ );
+ this.syncBodyHeight();
+ if(!this.buttons){
+ /**
+ * Array of all the buttons that have been added to this dialog via addButton
+ * @type Array
+ */
+ this.buttons = [];
+ }
+ this.buttons.push(btn);
+ return btn;
+ },
+
+ /**
+ * Sets the default button to be focused when the dialog is displayed.
+ * @param {Roo.BasicDialog.Button} btn The button object returned by {@link #addButton}
+ * @return {Roo.BasicDialog} this
+ */
+ setDefaultButton : function(btn){
+ this.defaultButton = btn;
+ return this;
+ },
+
+ // private
+ getHeaderFooterHeight : function(safe){
+ var height = 0;
+ if(this.header){
+ height += this.header.getHeight();
+ }
+ if(this.footer){
+ var fm = this.footer.getMargins();
+ height += (this.footer.getHeight()+fm.top+fm.bottom);
+ }
+ height += this.bwrap.getPadding("tb")+this.bwrap.getBorderWidth("tb");
+ height += this.centerBg.getPadding("tb");
+ return height;
+ },
+
+ // private
+ syncBodyHeight : function()
+ {
+ var bd = this.body, // the text
+ cb = this.centerBg, // wrapper around bottom.. but does not seem to be used..
+ bw = this.bwrap;
+ var height = this.size.height - this.getHeaderFooterHeight(false);
+ bd.setHeight(height-bd.getMargins("tb"));
+ var hh = this.header.getHeight();
+ var h = this.size.height-hh;
+ cb.setHeight(h);
+
+ bw.setLeftTop(cb.getPadding("l"), hh+cb.getPadding("t"));
+ bw.setHeight(h-cb.getPadding("tb"));
+
+ bw.setWidth(this.el.getWidth(true)-cb.getPadding("lr"));
+ bd.setWidth(bw.getWidth(true));
+ if(this.tabs){
+ this.tabs.syncHeight();
+ if(Roo.isIE){
+ this.tabs.el.repaint();
+ }
+ }
+ },
+
+ /**
+ * Restores the previous state of the dialog if Roo.state is configured.
+ * @return {Roo.BasicDialog} this
+ */
+ restoreState : function(){
+ var box = Roo.state.Manager.get(this.stateId || (this.el.id + "-state"));
+ if(box && box.width){
+ this.xy = [box.x, box.y];
+ this.resizeTo(box.width, box.height);
+ }
+ return this;
+ },
+
+ // private
+ beforeShow : function(){
+ this.expand();
+ if(this.fixedcenter){
+ this.xy = this.el.getCenterXY(true);
+ }
+ if(this.modal){
+ Roo.get(document.body).addClass("x-body-masked");
+ this.mask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
+ this.mask.show();
+ }
+ this.constrainXY();
+ },
+
+ // private
+ animShow : function(){
+ var b = Roo.get(this.animateTarget).getBox();
+ this.proxy.setSize(b.width, b.height);
+ this.proxy.setLocation(b.x, b.y);
+ this.proxy.show();
+ this.proxy.setBounds(this.xy[0], this.xy[1], this.size.width, this.size.height,
+ true, .35, this.showEl.createDelegate(this));
+ },
+
+ /**
+ * Shows the dialog.
+ * @param {String/HTMLElement/Roo.Element} animateTarget (optional) Reset the animation target
+ * @return {Roo.BasicDialog} this
+ */
+ show : function(animateTarget){
+ if (this.fireEvent("beforeshow", this) === false){
+ return;
+ }
+ if(this.syncHeightBeforeShow){
+ this.syncBodyHeight();
+ }else if(this.firstShow){
+ this.firstShow = false;
+ this.syncBodyHeight(); // sync the height on the first show instead of in the constructor
+ }
+ this.animateTarget = animateTarget || this.animateTarget;
+ if(!this.el.isVisible()){
+ this.beforeShow();
+ if(this.animateTarget && Roo.get(this.animateTarget)){
+ this.animShow();
+ }else{
+ this.showEl();
+ }
+ }
+ return this;
+ },
+
+ // private
+ showEl : function(){
+ this.proxy.hide();
+ this.el.setXY(this.xy);
+ this.el.show();
+ this.adjustAssets(true);
+ this.toFront();
+ this.focus();
+ // IE peekaboo bug - fix found by Dave Fenwick
+ if(Roo.isIE){
+ this.el.repaint();
+ }
+ this.fireEvent("show", this);
+ },
+
+ /**
+ * Focuses the dialog. If a defaultButton is set, it will receive focus, otherwise the
+ * dialog itself will receive focus.
+ */
+ focus : function(){
+ if(this.defaultButton){
+ this.defaultButton.focus();
+ }else{
+ this.focusEl.focus();
+ }
+ },
+
+ // private
+ constrainXY : function(){
+ if(this.constraintoviewport !== false){
+ if(!this.viewSize){
+ if(this.container){
+ var s = this.container.getSize();
+ this.viewSize = [s.width, s.height];
+ }else{
+ this.viewSize = [Roo.lib.Dom.getViewWidth(),Roo.lib.Dom.getViewHeight()];
+ }
+ }
+ var s = Roo.get(this.container||document).getScroll();
+
+ var x = this.xy[0], y = this.xy[1];
+ var w = this.size.width, h = this.size.height;
+ var vw = this.viewSize[0], vh = this.viewSize[1];
+ // only move it if it needs it
+ var moved = false;
+ // first validate right/bottom
+ if(x + w > vw+s.left){
+ x = vw - w;
+ moved = true;
+ }
+ if(y + h > vh+s.top){
+ y = vh - h;
+ moved = true;
+ }
+ // then make sure top/left isn't negative
+ if(x < s.left){
+ x = s.left;
+ moved = true;
+ }
+ if(y < s.top){
+ y = s.top;
+ moved = true;
+ }
+ if(moved){
+ // cache xy
+ this.xy = [x, y];
+ if(this.isVisible()){
+ this.el.setLocation(x, y);
+ this.adjustAssets();
+ }
+ }
+ }
+ },
+
+ // private
+ onDrag : function(){
+ if(!this.proxyDrag){
+ this.xy = this.el.getXY();
+ this.adjustAssets();
+ }
+ },
+
+ // private
+ adjustAssets : function(doShow){
+ var x = this.xy[0], y = this.xy[1];
+ var w = this.size.width, h = this.size.height;
+ if(doShow === true){
+ if(this.shadow){
+ this.shadow.show(this.el);
+ }
+ if(this.shim){
+ this.shim.show();
+ }
+ }
+ if(this.shadow && this.shadow.isVisible()){
+ this.shadow.show(this.el);
+ }
+ if(this.shim && this.shim.isVisible()){
+ this.shim.setBounds(x, y, w, h);
+ }
+ },
+
+ // private
+ adjustViewport : function(w, h){
+ if(!w || !h){
+ w = Roo.lib.Dom.getViewWidth();
+ h = Roo.lib.Dom.getViewHeight();
+ }
+ // cache the size
+ this.viewSize = [w, h];
+ if(this.modal && this.mask.isVisible()){
+ this.mask.setSize(w, h); // first make sure the mask isn't causing overflow
+ this.mask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
+ }
+ if(this.isVisible()){
+ this.constrainXY();
+ }
+ },
+
+ /**
+ * Destroys this dialog and all its supporting elements (including any tabs, shim,
+ * shadow, proxy, mask, etc.) Also removes all event listeners.
+ * @param {Boolean} removeEl (optional) true to remove the element from the DOM
+ */
+ destroy : function(removeEl){
+ if(this.isVisible()){
+ this.animateTarget = null;
+ this.hide();
+ }
+ Roo.EventManager.removeResizeListener(this.adjustViewport, this);
+ if(this.tabs){
+ this.tabs.destroy(removeEl);
+ }
+ Roo.destroy(
+ this.shim,
+ this.proxy,
+ this.resizer,
+ this.close,
+ this.mask
+ );
+ if(this.dd){
+ this.dd.unreg();
+ }
+ if(this.buttons){
+ for(var i = 0, len = this.buttons.length; i < len; i++){
+ this.buttons[i].destroy();
+ }
+ }
+ this.el.removeAllListeners();
+ if(removeEl === true){
+ this.el.update("");
+ this.el.remove();
+ }
+ Roo.DialogManager.unregister(this);
+ },
+
+ // private
+ startMove : function(){
+ if(this.proxyDrag){
+ this.proxy.show();
+ }
+ if(this.constraintoviewport !== false){
+ this.dd.constrainTo(document.body, {right: this.shadowOffset, bottom: this.shadowOffset});
+ }
+ },
+
+ // private
+ endMove : function(){
+ if(!this.proxyDrag){
+ Roo.dd.DD.prototype.endDrag.apply(this.dd, arguments);
+ }else{
+ Roo.dd.DDProxy.prototype.endDrag.apply(this.dd, arguments);
+ this.proxy.hide();
+ }
+ this.refreshSize();
+ this.adjustAssets();
+ this.focus();
+ this.fireEvent("move", this, this.xy[0], this.xy[1]);
+ },
+
+ /**
+ * Brings this dialog to the front of any other visible dialogs
+ * @return {Roo.BasicDialog} this
+ */
+ toFront : function(){
+ Roo.DialogManager.bringToFront(this);
+ return this;
+ },
+
+ /**
+ * Sends this dialog to the back (under) of any other visible dialogs
+ * @return {Roo.BasicDialog} this
+ */
+ toBack : function(){
+ Roo.DialogManager.sendToBack(this);
+ return this;
+ },
+
+ /**
+ * Centers this dialog in the viewport
+ * @return {Roo.BasicDialog} this
+ */
+ center : function(){
+ var xy = this.el.getCenterXY(true);
+ this.moveTo(xy[0], xy[1]);
+ return this;
+ },
+
+ /**
+ * Moves the dialog's top-left corner to the specified point
+ * @param {Number} x
+ * @param {Number} y
+ * @return {Roo.BasicDialog} this
+ */
+ moveTo : function(x, y){
+ this.xy = [x,y];
+ if(this.isVisible()){
+ this.el.setXY(this.xy);
+ this.adjustAssets();
+ }
+ return this;
+ },
+
+ /**
+ * Aligns the dialog to the specified element
+ * @param {String/HTMLElement/Roo.Element} element The element to align to.
+ * @param {String} position The position to align to (see {@link Roo.Element#alignTo} for more details).
+ * @param {Array} offsets (optional) Offset the positioning by [x, y]
+ * @return {Roo.BasicDialog} this
+ */
+ alignTo : function(element, position, offsets){
+ this.xy = this.el.getAlignToXY(element, position, offsets);
+ if(this.isVisible()){
+ this.el.setXY(this.xy);
+ this.adjustAssets();
+ }
+ return this;
+ },
+
+ /**
+ * Anchors an element to another element and realigns it when the window is resized.
+ * @param {String/HTMLElement/Roo.Element} element The element to align to.
+ * @param {String} position The position to align to (see {@link Roo.Element#alignTo} for more details)
+ * @param {Array} offsets (optional) Offset the positioning by [x, y]
+ * @param {Boolean/Number} monitorScroll (optional) true to monitor body scroll and reposition. If this parameter
+ * is a number, it is used as the buffer delay (defaults to 50ms).
+ * @return {Roo.BasicDialog} this
+ */
+ anchorTo : function(el, alignment, offsets, monitorScroll){
+ var action = function(){
+ this.alignTo(el, alignment, offsets);
+ };
+ Roo.EventManager.onWindowResize(action, this);
+ var tm = typeof monitorScroll;
+ if(tm != 'undefined'){
+ Roo.EventManager.on(window, 'scroll', action, this,
+ {buffer: tm == 'number' ? monitorScroll : 50});
+ }
+ action.call(this);
+ return this;
+ },
+
+ /**
+ * Returns true if the dialog is visible
+ * @return {Boolean}
+ */
+ isVisible : function(){
+ return this.el.isVisible();
+ },
+
+ // private
+ animHide : function(callback){
+ var b = Roo.get(this.animateTarget).getBox();
+ this.proxy.show();
+ this.proxy.setBounds(this.xy[0], this.xy[1], this.size.width, this.size.height);
+ this.el.hide();
+ this.proxy.setBounds(b.x, b.y, b.width, b.height, true, .35,
+ this.hideEl.createDelegate(this, [callback]));
+ },
+
+ /**
+ * Hides the dialog.
+ * @param {Function} callback (optional) Function to call when the dialog is hidden
+ * @return {Roo.BasicDialog} this
+ */
+ hide : function(callback){
+ if (this.fireEvent("beforehide", this) === false){
+ return;
+ }
+ if(this.shadow){
+ this.shadow.hide();
+ }
+ if(this.shim) {
+ this.shim.hide();
+ }
+ // sometimes animateTarget seems to get set.. causing problems...
+ // this just double checks..
+ if(this.animateTarget && Roo.get(this.animateTarget)) {
+ this.animHide(callback);
+ }else{
+ this.el.hide();
+ this.hideEl(callback);
+ }
+ return this;
+ },
+
+ // private
+ hideEl : function(callback){
+ this.proxy.hide();
+ if(this.modal){
+ this.mask.hide();
+ Roo.get(document.body).removeClass("x-body-masked");
+ }
+ this.fireEvent("hide", this);
+ if(typeof callback == "function"){
+ callback();
+ }
+ },
+
+ // private
+ hideAction : function(){
+ this.setLeft("-10000px");
+ this.setTop("-10000px");
+ this.setStyle("visibility", "hidden");
+ },
+
+ // private
+ refreshSize : function(){
+ this.size = this.el.getSize();
+ this.xy = this.el.getXY();
+ Roo.state.Manager.set(this.stateId || this.el.id + "-state", this.el.getBox());
+ },
+
+ // private
+ // z-index is managed by the DialogManager and may be overwritten at any time
+ setZIndex : function(index){
+ if(this.modal){
+ this.mask.setStyle("z-index", index);
+ }
+ if(this.shim){
+ this.shim.setStyle("z-index", ++index);
+ }
+ if(this.shadow){
+ this.shadow.setZIndex(++index);
+ }
+ this.el.setStyle("z-index", ++index);
+ if(this.proxy){
+ this.proxy.setStyle("z-index", ++index);
+ }
+ if(this.resizer){
+ this.resizer.proxy.setStyle("z-index", ++index);
+ }
+
+ this.lastZIndex = index;
+ },
+
+ /**
+ * Returns the element for this dialog
+ * @return {Roo.Element} The underlying dialog Element
+ */
+ getEl : function(){
+ return this.el;
+ }
+});
+
+/**
+ * @class Roo.DialogManager
+ * Provides global access to BasicDialogs that have been created and
+ * support for z-indexing (layering) multiple open dialogs.
+ */
+Roo.DialogManager = function(){
+ var list = {};
+ var accessList = [];
+ var front = null;
+
+ // private
+ var sortDialogs = function(d1, d2){
+ return (!d1._lastAccess || d1._lastAccess < d2._lastAccess) ? -1 : 1;
+ };
+
+ // private
+ var orderDialogs = function(){
+ accessList.sort(sortDialogs);
+ var seed = Roo.DialogManager.zseed;
+ for(var i = 0, len = accessList.length; i < len; i++){
+ var dlg = accessList[i];
+ if(dlg){
+ dlg.setZIndex(seed + (i*10));
+ }
+ }
+ };
+
+ return {
+ /**
+ * The starting z-index for BasicDialogs (defaults to 9000)
+ * @type Number The z-index value
+ */
+ zseed : 9000,
+
+ // private
+ register : function(dlg){
+ list[dlg.id] = dlg;
+ accessList.push(dlg);
+ },
+
+ // private
+ unregister : function(dlg){
+ delete list[dlg.id];
+ var i=0;
+ var len=0;
+ if(!accessList.indexOf){
+ for( i = 0, len = accessList.length; i < len; i++){
+ if(accessList[i] == dlg){
+ accessList.splice(i, 1);
+ return;
+ }
+ }
+ }else{
+ i = accessList.indexOf(dlg);
+ if(i != -1){
+ accessList.splice(i, 1);
+ }
+ }
+ },
+
+ /**
+ * Gets a registered dialog by id
+ * @param {String/Object} id The id of the dialog or a dialog
+ * @return {Roo.BasicDialog} this
+ */
+ get : function(id){
+ return typeof id == "object" ? id : list[id];
+ },
+
+ /**
+ * Brings the specified dialog to the front
+ * @param {String/Object} dlg The id of the dialog or a dialog
+ * @return {Roo.BasicDialog} this
+ */
+ bringToFront : function(dlg){
+ dlg = this.get(dlg);
+ if(dlg != front){
+ front = dlg;
+ dlg._lastAccess = new Date().getTime();
+ orderDialogs();
+ }
+ return dlg;
+ },
+
+ /**
+ * Sends the specified dialog to the back
+ * @param {String/Object} dlg The id of the dialog or a dialog
+ * @return {Roo.BasicDialog} this
+ */
+ sendToBack : function(dlg){
+ dlg = this.get(dlg);
+ dlg._lastAccess = -(new Date().getTime());
+ orderDialogs();
+ return dlg;
+ },
+
+ /**
+ * Hides all dialogs
+ */
+ hideAll : function(){
+ for(var id in list){
+ if(list[id] && typeof list[id] != "function" && list[id].isVisible()){
+ list[id].hide();
+ }
+ }
+ }
+ };
+}();
+
+/**
+ * @class Roo.LayoutDialog
+ * @extends Roo.BasicDialog
+ * @children Roo.ContentPanel
+ * @parent builder none
+ * Dialog which provides adjustments for working with a layout in a Dialog.
+ * Add your necessary layout config options to the dialog's config.<br>
+ * Example usage (including a nested layout):
+ * <pre><code>
+if(!dialog){
+ dialog = new Roo.LayoutDialog("download-dlg", {
+ modal: true,
+ width:600,
+ height:450,
+ shadow:true,
+ minWidth:500,
+ minHeight:350,
+ autoTabs:true,
+ proxyDrag:true,
+ // layout config merges with the dialog config
+ center:{
+ tabPosition: "top",
+ alwaysShowTabs: true
+ }
+ });
+ dialog.addKeyListener(27, dialog.hide, dialog);
+ dialog.setDefaultButton(dialog.addButton("Close", dialog.hide, dialog));
+ dialog.addButton("Build It!", this.getDownload, this);
+
+ // we can even add nested layouts
+ var innerLayout = new Roo.BorderLayout("dl-inner", {
+ east: {
+ initialSize: 200,
+ autoScroll:true,
+ split:true
+ },
+ center: {
+ autoScroll:true
+ }
+ });
+ innerLayout.beginUpdate();
+ innerLayout.add("east", new Roo.ContentPanel("dl-details"));
+ innerLayout.add("center", new Roo.ContentPanel("selection-panel"));
+ innerLayout.endUpdate(true);
+
+ var layout = dialog.getLayout();
+ layout.beginUpdate();
+ layout.add("center", new Roo.ContentPanel("standard-panel",
+ {title: "Download the Source", fitToFrame:true}));
+ layout.add("center", new Roo.NestedLayoutPanel(innerLayout,
+ {title: "Build your own roo.js"}));
+ layout.getRegion("center").showPanel(sp);
+ layout.endUpdate();
+}
+</code></pre>
+ * @constructor
+ * @param {String/HTMLElement/Roo.Element} el The id of or container element, or config
+ * @param {Object} config configuration options
+ */
+Roo.LayoutDialog = function(el, cfg){
+
+ var config= cfg;
+ if (typeof(cfg) == 'undefined') {
+ config = Roo.apply({}, el);
+ // not sure why we use documentElement here.. - it should always be body.
+ // IE7 borks horribly if we use documentElement.
+ // webkit also does not like documentElement - it creates a body element...
+ el = Roo.get( document.body || document.documentElement ).createChild();
+ //config.autoCreate = true;
+ }
+
+
+ config.autoTabs = false;
+ Roo.LayoutDialog.superclass.constructor.call(this, el, config);
+ this.body.setStyle({overflow:"hidden", position:"relative"});
+ this.layout = new Roo.BorderLayout(this.body.dom, config);
+ this.layout.monitorWindowResize = false;
+ this.el.addClass("x-dlg-auto-layout");
+ // fix case when center region overwrites center function
+ this.center = Roo.BasicDialog.prototype.center;
+ this.on("show", this.layout.layout, this.layout, true);
+ if (config.items) {
+ var xitems = config.items;
+ delete config.items;
+ Roo.each(xitems, this.addxtype, this);
+ }
+
+
+};
+Roo.extend(Roo.LayoutDialog, Roo.BasicDialog, {
+
+
+ /**
+ * @cfg {Roo.LayoutRegion} east
+ */
+ /**
+ * @cfg {Roo.LayoutRegion} west
+ */
+ /**
+ * @cfg {Roo.LayoutRegion} south
+ */
+ /**
+ * @cfg {Roo.LayoutRegion} north
+ */
+ /**
+ * @cfg {Roo.LayoutRegion} center
+ */
+ /**
+ * @cfg {Roo.Button} buttons[] Bottom buttons..
+ */
+
+
+ /**
+ * Ends update of the layout <strike>and resets display to none</strike>. Use standard beginUpdate/endUpdate on the layout.
+ * @deprecated
+ */
+ endUpdate : function(){
+ this.layout.endUpdate();
+ },
+
+ /**
+ * Begins an update of the layout <strike>and sets display to block and visibility to hidden</strike>. Use standard beginUpdate/endUpdate on the layout.
+ * @deprecated
+ */
+ beginUpdate : function(){
+ this.layout.beginUpdate();
+ },
+
+ /**
+ * Get the BorderLayout for this dialog
+ * @return {Roo.BorderLayout}
+ */
+ getLayout : function(){
+ return this.layout;
+ },
+
+ showEl : function(){
+ Roo.LayoutDialog.superclass.showEl.apply(this, arguments);
+ if(Roo.isIE7){
+ this.layout.layout();
+ }
+ },
+
+ // private
+ // Use the syncHeightBeforeShow config option to control this automatically
+ syncBodyHeight : function(){
+ Roo.LayoutDialog.superclass.syncBodyHeight.call(this);
+ if(this.layout){this.layout.layout();}
+ },
+
+ /**
+ * Add an xtype element (actually adds to the layout.)
+ * @return {Object} xdata xtype object data.
+ */
+
+ addxtype : function(c) {
+ return this.layout.addxtype(c);
+ }
+});/*
+ * Based on:
+ * Ext JS Library 1.1.1
+ * Copyright(c) 2006-2007, Ext JS, LLC.
+ *
+ * Originally Released Under LGPL - original licence link has changed is not relivant.
+ *
+ * Fork - LGPL
+ * <script type="text/javascript">
+ */
+
+/**
+ * @class Roo.MessageBox
+ * @static
+ * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
+ * Example usage:
+ *<pre><code>
+// Basic alert:
+Roo.Msg.alert('Status', 'Changes saved successfully.');
+
+// Prompt for user data:
+Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
+ if (btn == 'ok'){
+ // process text value...
+ }
+});
+
+// Show a dialog using config options:
+Roo.Msg.show({
+ title:'Save Changes?',
+ msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
+ buttons: Roo.Msg.YESNOCANCEL,
+ fn: processResult,
+ animEl: 'elId'
+});
+</code></pre>
+ * @static
+ */
+Roo.MessageBox = function(){
+ var dlg, opt, mask, waitTimer;
+ var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
+ var buttons, activeTextEl, bwidth;
+
+ // private
+ var handleButton = function(button){
+ dlg.hide();
+ Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
+ };
+
+ // private
+ var handleHide = function(){
+ if(opt && opt.cls){
+ dlg.el.removeClass(opt.cls);
+ }
+ if(waitTimer){
+ Roo.TaskMgr.stop(waitTimer);
+ waitTimer = null;
+ }
+ };
+
+ // private
+ var updateButtons = function(b){
+ var width = 0;
+ if(!b){
+ buttons["ok"].hide();
+ buttons["cancel"].hide();
+ buttons["yes"].hide();
+ buttons["no"].hide();
+ dlg.footer.dom.style.display = 'none';
+ return width;
+ }
+ dlg.footer.dom.style.display = '';
+ for(var k in buttons){
+ if(typeof buttons[k] != "function"){
+ if(b[k]){
+ buttons[k].show();
+ buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.MessageBox.buttonText[k]);
+ width += buttons[k].el.getWidth()+15;
+ }else{
+ buttons[k].hide();
+ }
+ }
+ }
+ return width;
+ };
+
+ // private
+ var handleEsc = function(d, k, e){
+ if(opt && opt.closable !== false){
+ dlg.hide();
+ }
+ if(e){
+ e.stopEvent();
+ }
+ };
+
+ return {
+ /**
+ * Returns a reference to the underlying {@link Roo.BasicDialog} element
+ * @return {Roo.BasicDialog} The BasicDialog element
+ */
+ getDialog : function(){
+ if(!dlg){
+ dlg = new Roo.BasicDialog("x-msg-box", {
+ autoCreate : true,
+ shadow: true,
+ draggable: true,
+ resizable:false,
+ constraintoviewport:false,
+ fixedcenter:true,
+ collapsible : false,
+ shim:true,
+ modal: true,
+ width:400, height:100,
+ buttonAlign:"center",
+ closeClick : function(){
+ if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
+ handleButton("no");
+ }else{
+ handleButton("cancel");
+ }
+ }
+ });
+
+ dlg.on("hide", handleHide);
+ mask = dlg.mask;
+ dlg.addKeyListener(27, handleEsc);
+ buttons = {};
+ var bt = this.buttonText;
+ buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
+ buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
+ buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
+ buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
+ bodyEl = dlg.body.createChild({
+
+ html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" /><textarea class="roo-mb-textarea"></textarea><div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
+ });
+ msgEl = bodyEl.dom.firstChild;
+ textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
+ textboxEl.enableDisplayMode();
+ textboxEl.addKeyListener([10,13], function(){
+ if(dlg.isVisible() && opt && opt.buttons){
+ if(opt.buttons.ok){
+ handleButton("ok");
+ }else if(opt.buttons.yes){
+ handleButton("yes");
+ }
+ }
+ });
+ textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
+ textareaEl.enableDisplayMode();
+ progressEl = Roo.get(bodyEl.dom.childNodes[4]);
+ progressEl.enableDisplayMode();
+ var pf = progressEl.dom.firstChild;
+ if (pf) {
+ pp = Roo.get(pf.firstChild);
+ pp.setHeight(pf.offsetHeight);
+ }
+
+ }
+ return dlg;
+ },
+
+ /**
+ * Updates the message box body text
+ * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
+ * the XHTML-compliant non-breaking space character '&#160;')
+ * @return {Roo.MessageBox} This message box
+ */
+ updateText : function(text){
+ if(!dlg.isVisible() && !opt.width){
+ dlg.resizeTo(this.maxWidth, 100); // resize first so content is never clipped from previous shows
+ }
+ msgEl.innerHTML = text || ' ';
+
+ var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
+ //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
+ var w = Math.max(
+ Math.min(opt.width || cw , this.maxWidth),
+ Math.max(opt.minWidth || this.minWidth, bwidth)
+ );
+ if(opt.prompt){
+ activeTextEl.setWidth(w);
+ }
+ if(dlg.isVisible()){
+ dlg.fixedcenter = false;
+ }
+ // to big, make it scroll. = But as usual stupid IE does not support
+ // !important..
+
+ if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
+ bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
+ bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
+ } else {
+ bodyEl.dom.style.height = '';
+ bodyEl.dom.style.overflowY = '';
+ }
+ if (cw > w) {
+ bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
+ } else {
+ bodyEl.dom.style.overflowX = '';
+ }
+
+ dlg.setContentSize(w, bodyEl.getHeight());
+ if(dlg.isVisible()){
+ dlg.fixedcenter = true;
+ }
+ return this;
+ },
+
+ /**
+ * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
+ * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
+ * @param {Number} value Any number between 0 and 1 (e.g., .5)
+ * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
+ * @return {Roo.MessageBox} This message box
+ */
+ updateProgress : function(value, text){
+ if(text){
+ this.updateText(text);
+ }
+ if (pp) { // weird bug on my firefox - for some reason this is not defined
+ pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
+ }
+ return this;
+ },
+
+ /**
+ * Returns true if the message box is currently displayed
+ * @return {Boolean} True if the message box is visible, else false
+ */
+ isVisible : function(){
+ return dlg && dlg.isVisible();
+ },
+
+ /**
+ * Hides the message box if it is displayed
+ */
+ hide : function(){
+ if(this.isVisible()){
+ dlg.hide();
+ }
+ },
+
+ /**
+ * Displays a new message box, or reinitializes an existing message box, based on the config options
+ * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
+ * The following config object properties are supported:
+ * <pre>
+Property Type Description
+---------- --------------- ------------------------------------------------------------------------------------
+animEl String/Element An id or Element from which the message box should animate as it opens and
+ closes (defaults to undefined)
+buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
+ cancel:'Bar'}), or false to not show any buttons (defaults to false)
+closable Boolean False to hide the top-right close button (defaults to true). Note that
+ progress and wait dialogs will ignore this property and always hide the
+ close button as they can only be closed programmatically.
+cls String A custom CSS class to apply to the message box element
+defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
+ displayed (defaults to 75)
+fn Function A callback function to execute after closing the dialog. The arguments to the
+ function will be btn (the name of the button that was clicked, if applicable,
+ e.g. "ok"), and text (the value of the active text field, if applicable).
+ Progress and wait dialogs will ignore this option since they do not respond to
+ user actions and can only be closed programmatically, so any required function
+ should be called by the same code after it closes the dialog.
+icon String A CSS class that provides a background image to be used as an icon for
+ the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
+maxWidth Number The maximum width in pixels of the message box (defaults to 600)
+minWidth Number The minimum width in pixels of the message box (defaults to 100)
+modal Boolean False to allow user interaction with the page while the message box is
+ displayed (defaults to true)
+msg String A string that will replace the existing message box body text (defaults
+ to the XHTML-compliant non-breaking space character ' ')
+multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
+progress Boolean True to display a progress bar (defaults to false)
+progressText String The text to display inside the progress bar if progress = true (defaults to '')
+prompt Boolean True to prompt the user to enter single-line text (defaults to false)
+proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
+title String The title text
+value String The string value to set into the active textbox element if displayed
+wait Boolean True to display a progress bar (defaults to false)
+width Number The width of the dialog in pixels
+</pre>
+ *
+ * Example usage:
+ * <pre><code>
+Roo.Msg.show({
+ title: 'Address',
+ msg: 'Please enter your address:',
+ width: 300,
+ buttons: Roo.MessageBox.OKCANCEL,
+ multiline: true,
+ fn: saveAddress,
+ animEl: 'addAddressBtn'
+});
+</code></pre>
+ * @param {Object} config Configuration options
+ * @return {Roo.MessageBox} This message box
+ */
+ show : function(options)
+ {
+
+ // this causes nightmares if you show one dialog after another
+ // especially on callbacks..
+
+ if(this.isVisible()){
+
+ this.hide();
+ Roo.log("[Roo.Messagebox] Show called while message displayed:" );
+ Roo.log("Old Dialog Message:" + msgEl.innerHTML );
+ Roo.log("New Dialog Message:" + options.msg )
+ //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
+ //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
+
+ }
+ var d = this.getDialog();
+ opt = options;
+ d.setTitle(opt.title || " ");
+ d.close.setDisplayed(opt.closable !== false);
+ activeTextEl = textboxEl;
+ opt.prompt = opt.prompt || (opt.multiline ? true : false);
+ if(opt.prompt){
+ if(opt.multiline){
+ textboxEl.hide();
+ textareaEl.show();
+ textareaEl.setHeight(typeof opt.multiline == "number" ?
+ opt.multiline : this.defaultTextHeight);
+ activeTextEl = textareaEl;
+ }else{
+ textboxEl.show();
+ textareaEl.hide();
+ }
+ }else{
+ textboxEl.hide();
+ textareaEl.hide();
+ }
+ progressEl.setDisplayed(opt.progress === true);
+ this.updateProgress(0);
+ activeTextEl.dom.value = opt.value || "";
+ if(opt.prompt){
+ dlg.setDefaultButton(activeTextEl);
+ }else{
+ var bs = opt.buttons;
+ var db = null;
+ if(bs && bs.ok){
+ db = buttons["ok"];
+ }else if(bs && bs.yes){
+ db = buttons["yes"];
+ }
+ dlg.setDefaultButton(db);
+ }
+ bwidth = updateButtons(opt.buttons);
+ this.updateText(opt.msg);
+ if(opt.cls){
+ d.el.addClass(opt.cls);
+ }
+ d.proxyDrag = opt.proxyDrag === true;
+ d.modal = opt.modal !== false;
+ d.mask = opt.modal !== false ? mask : false;
+ if(!d.isVisible()){
+ // force it to the end of the z-index stack so it gets a cursor in FF
+ document.body.appendChild(dlg.el.dom);
+ d.animateTarget = null;
+ d.show(options.animEl);
+ }
+ dlg.toFront();
+ return this;
+ },
+
+ /**
+ * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
+ * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
+ * and closing the message box when the process is complete.
+ * @param {String} title The title bar text
+ * @param {String} msg The message box body text
+ * @return {Roo.MessageBox} This message box
+ */
+ progress : function(title, msg){
+ this.show({
+ title : title,
+ msg : msg,
+ buttons: false,
+ progress:true,
+ closable:false,
+ minWidth: this.minProgressWidth,
+ modal : true
+ });
+ return this;
+ },
+
+ /**
+ * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
+ * If a callback function is passed it will be called after the user clicks the button, and the
+ * id of the button that was clicked will be passed as the only parameter to the callback
+ * (could also be the top-right close button).
+ * @param {String} title The title bar text
+ * @param {String} msg The message box body text
+ * @param {Function} fn (optional) The callback function invoked after the message box is closed
+ * @param {Object} scope (optional) The scope of the callback function
+ * @return {Roo.MessageBox} This message box
+ */
+ alert : function(title, msg, fn, scope){
+ this.show({
+ title : title,
+ msg : msg,
+ buttons: this.OK,
+ fn: fn,
+ scope : scope,
+ modal : true
+ });
+ return this;
+ },
+
+ /**
+ * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
+ * interaction while waiting for a long-running process to complete that does not have defined intervals.
+ * You are responsible for closing the message box when the process is complete.
+ * @param {String} msg The message box body text
+ * @param {String} title (optional) The title bar text
+ * @return {Roo.MessageBox} This message box
+ */
+ wait : function(msg, title){
+ this.show({
+ title : title,
+ msg : msg,
+ buttons: false,
+ closable:false,
+ progress:true,
+ modal:true,
+ width:300,
+ wait:true
+ });
+ waitTimer = Roo.TaskMgr.start({
+ run: function(i){
+ Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
+ },
+ interval: 1000
+ });
+ return this;
+ },
+
+ /**
+ * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
+ * If a callback function is passed it will be called after the user clicks either button, and the id of the
+ * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
+ * @param {String} title The title bar text
+ * @param {String} msg The message box body text
+ * @param {Function} fn (optional) The callback function invoked after the message box is closed
+ * @param {Object} scope (optional) The scope of the callback function
+ * @return {Roo.MessageBox} This message box
+ */
+ confirm : function(title, msg, fn, scope){
+ this.show({
+ title : title,
+ msg : msg,
+ buttons: this.YESNO,
+ fn: fn,
+ scope : scope,
+ modal : true
+ });
+ return this;
+ },
+
+ /**
+ * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
+ * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
+ * is passed it will be called after the user clicks either button, and the id of the button that was clicked
+ * (could also be the top-right close button) and the text that was entered will be passed as the two
+ * parameters to the callback.
+ * @param {String} title The title bar text
+ * @param {String} msg The message box body text
+ * @param {Function} fn (optional) The callback function invoked after the message box is closed
+ * @param {Object} scope (optional) The scope of the callback function
+ * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
+ * property, or the height in pixels to create the textbox (defaults to false / single-line)
+ * @return {Roo.MessageBox} This message box
+ */
+ prompt : function(title, msg, fn, scope, multiline){
+ this.show({
+ title : title,
+ msg : msg,
+ buttons: this.OKCANCEL,
+ fn: fn,
+ minWidth:250,
+ scope : scope,
+ prompt:true,
+ multiline: multiline,
+ modal : true
+ });
+ return this;
+ },
+
+ /**
+ * Button config that displays a single OK button
+ * @type Object
+ */
+ OK : {ok:true},
+ /**
+ * Button config that displays Yes and No buttons
+ * @type Object
+ */
+ YESNO : {yes:true, no:true},
+ /**
+ * Button config that displays OK and Cancel buttons
+ * @type Object
+ */
+ OKCANCEL : {ok:true, cancel:true},
+ /**
+ * Button config that displays Yes, No and Cancel buttons
+ * @type Object
+ */
+ YESNOCANCEL : {yes:true, no:true, cancel:true},
+
+ /**
+ * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
+ * @type Number
+ */
+ defaultTextHeight : 75,
+ /**
+ * The maximum width in pixels of the message box (defaults to 600)
+ * @type Number
+ */
+ maxWidth : 600,
+ /**
+ * The minimum width in pixels of the message box (defaults to 100)
+ * @type Number
+ */
+ minWidth : 100,
+ /**
+ * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
+ * for setting a different minimum width than text-only dialogs may need (defaults to 250)
+ * @type Number
+ */
+ minProgressWidth : 250,
+ /**
+ * An object containing the default button text strings that can be overriden for localized language support.
+ * Supported properties are: ok, cancel, yes and no.
+ * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
+ * @type Object
+ */
+ buttonText : {
+ ok : "OK",
+ cancel : "Cancel",
+ yes : "Yes",
+ no : "No"
+ }
+ };
+}();
+
+/**
+ * Shorthand for {@link Roo.MessageBox}
+ */
+Roo.Msg = Roo.MessageBox;/*
+ * Based on:
+ * Ext JS Library 1.1.1
+ * Copyright(c) 2006-2007, Ext JS, LLC.
+ *
+ * Originally Released Under LGPL - original licence link has changed is not relivant.
+ *
+ * Fork - LGPL
+ * <script type="text/javascript">
+ */
+/**
+ * @class Roo.QuickTips
+ * Provides attractive and customizable tooltips for any element.
+ * @static
+ */
+Roo.QuickTips = function(){
+ var el, tipBody, tipBodyText, tipTitle, tm, cfg, close, tagEls = {}, esc, removeCls = null, bdLeft, bdRight;
+ var ce, bd, xy, dd;
+ var visible = false, disabled = true, inited = false;
+ var showProc = 1, hideProc = 1, dismissProc = 1, locks = [];
+
+ var onOver = function(e){
+ if(disabled){
+ return;
+ }
+ var t = e.getTarget();
+ if(!t || t.nodeType !== 1 || t == document || t == document.body){
+ return;
+ }
+ if(ce && t == ce.el){
+ clearTimeout(hideProc);
+ return;
+ }
+ if(t && tagEls[t.id]){
+ tagEls[t.id].el = t;
+ showProc = show.defer(tm.showDelay, tm, [tagEls[t.id]]);
+ return;
+ }
+ var ttp, et = Roo.fly(t);
+ var ns = cfg.namespace;
+ if(tm.interceptTitles && t.title){
+ ttp = t.title;
+ t.qtip = ttp;
+ t.removeAttribute("title");
+ e.preventDefault();
+ }else{
+ ttp = t.qtip || et.getAttributeNS(ns, cfg.attribute) || et.getAttributeNS(cfg.alt_namespace, cfg.attribute) ;
+ }
+ if(ttp){
+ showProc = show.defer(tm.showDelay, tm, [{
+ el: t,
+ text: ttp.replace(/\\n/g,'<br/>'),
+ width: et.getAttributeNS(ns, cfg.width),
+ autoHide: et.getAttributeNS(ns, cfg.hide) != "user",
+ title: et.getAttributeNS(ns, cfg.title),
+ cls: et.getAttributeNS(ns, cfg.cls)
+ }]);
+ }
+ };
+
+ var onOut = function(e){
+ clearTimeout(showProc);
+ var t = e.getTarget();
+ if(t && ce && ce.el == t && (tm.autoHide && ce.autoHide !== false)){
+ hideProc = setTimeout(hide, tm.hideDelay);
+ }
+ };
+
+ var onMove = function(e){
+ if(disabled){
+ return;
+ }
+ xy = e.getXY();
+ xy[1] += 18;
+ if(tm.trackMouse && ce){
+ el.setXY(xy);
+ }
+ };
+
+ var onDown = function(e){
+ clearTimeout(showProc);
+ clearTimeout(hideProc);
+ if(!e.within(el)){
+ if(tm.hideOnClick){
+ hide();
+ tm.disable();
+ tm.enable.defer(100, tm);
+ }
+ }
+ };
+
+ var getPad = function(){
+ return 2;//bdLeft.getPadding('l')+bdRight.getPadding('r');
+ };
+
+ var show = function(o){
+ if(disabled){
+ return;
+ }
+ clearTimeout(dismissProc);
+ ce = o;
+ if(removeCls){ // in case manually hidden
+ el.removeClass(removeCls);
+ removeCls = null;
+ }
+ if(ce.cls){
+ el.addClass(ce.cls);
+ removeCls = ce.cls;
+ }
+ if(ce.title){
+ tipTitle.update(ce.title);
+ tipTitle.show();
+ }else{
+ tipTitle.update('');
+ tipTitle.hide();
+ }
+ el.dom.style.width = tm.maxWidth+'px';
+ //tipBody.dom.style.width = '';
+ tipBodyText.update(o.text);
+ var p = getPad(), w = ce.width;
+ if(!w){
+ var td = tipBodyText.dom;
+ var aw = Math.max(td.offsetWidth, td.clientWidth, td.scrollWidth);
+ if(aw > tm.maxWidth){
+ w = tm.maxWidth;
+ }else if(aw < tm.minWidth){
+ w = tm.minWidth;
+ }else{
+ w = aw;
+ }
+ }
+ //tipBody.setWidth(w);
+ el.setWidth(parseInt(w, 10) + p);
+ if(ce.autoHide === false){
+ close.setDisplayed(true);
+ if(dd){
+ dd.unlock();
+ }
+ }else{
+ close.setDisplayed(false);
+ if(dd){
+ dd.lock();
+ }
+ }
+ if(xy){
+ el.avoidY = xy[1]-18;
+ el.setXY(xy);
+ }
+ if(tm.animate){
+ el.setOpacity(.1);
+ el.setStyle("visibility", "visible");
+ el.fadeIn({callback: afterShow});
+ }else{
+ afterShow();
+ }
+ };
+
+ var afterShow = function(){
+ if(ce){
+ el.show();
+ esc.enable();
+ if(tm.autoDismiss && ce.autoHide !== false){
+ dismissProc = setTimeout(hide, tm.autoDismissDelay);
+ }
+ }
+ };
+
+ var hide = function(noanim){
+ clearTimeout(dismissProc);
+ clearTimeout(hideProc);
+ ce = null;
+ if(el.isVisible()){
+ esc.disable();
+ if(noanim !== true && tm.animate){
+ el.fadeOut({callback: afterHide});
+ }else{
+ afterHide();
+ }
+ }
+ };
+
+ var afterHide = function(){
+ el.hide();
+ if(removeCls){
+ el.removeClass(removeCls);
+ removeCls = null;
+ }
+ };
+
+ return {
+ /**
+ * @cfg {Number} minWidth
+ * The minimum width of the quick tip (defaults to 40)
+ */
+ minWidth : 40,
+ /**
+ * @cfg {Number} maxWidth
+ * The maximum width of the quick tip (defaults to 300)
+ */
+ maxWidth : 300,
+ /**
+ * @cfg {Boolean} interceptTitles
+ * True to automatically use the element's DOM title value if available (defaults to false)
+ */
+ interceptTitles : false,
+ /**
+ * @cfg {Boolean} trackMouse
+ * True to have the quick tip follow the mouse as it moves over the target element (defaults to false)
+ */
+ trackMouse : false,
+ /**
+ * @cfg {Boolean} hideOnClick
+ * True to hide the quick tip if the user clicks anywhere in the document (defaults to true)
+ */
+ hideOnClick : true,
+ /**
+ * @cfg {Number} showDelay
+ * Delay in milliseconds before the quick tip displays after the mouse enters the target element (defaults to 500)
+ */
+ showDelay : 500,
+ /**
+ * @cfg {Number} hideDelay
+ * Delay in milliseconds before the quick tip hides when autoHide = true (defaults to 200)
+ */
+ hideDelay : 200,
+ /**
+ * @cfg {Boolean} autoHide
+ * True to automatically hide the quick tip after the mouse exits the target element (defaults to true).
+ * Used in conjunction with hideDelay.
+ */
+ autoHide : true,
+ /**
+ * @cfg {Boolean}
+ * True to automatically hide the quick tip after a set period of time, regardless of the user's actions
+ * (defaults to true). Used in conjunction with autoDismissDelay.
+ */
+ autoDismiss : true,
+ /**
+ * @cfg {Number}
+ * Delay in milliseconds before the quick tip hides when autoDismiss = true (defaults to 5000)
+ */
+ autoDismissDelay : 5000,
+ /**
+ * @cfg {Boolean} animate
+ * True to turn on fade animation. Defaults to false (ClearType/scrollbar flicker issues in IE7).
+ */
+ animate : false,
+
+ /**
+ * @cfg {String} title
+ * Title text to display (defaults to ''). This can be any valid HTML markup.
+ */
+ title: '',
+ /**
+ * @cfg {String} text
+ * Body text to display (defaults to ''). This can be any valid HTML markup.
+ */
+ text : '',
+ /**
+ * @cfg {String} cls
+ * A CSS class to apply to the base quick tip element (defaults to '').
+ */
+ cls : '',
+ /**
+ * @cfg {Number} width
+ * Width in pixels of the quick tip (defaults to auto). Width will be ignored if it exceeds the bounds of
+ * minWidth or maxWidth.
+ */
+ width : null,
+
+ /**
+ * Initialize and enable QuickTips for first use. This should be called once before the first attempt to access
+ * or display QuickTips in a page.
+ */
+ init : function(){
+ tm = Roo.QuickTips;
+ cfg = tm.tagConfig;
+ if(!inited){
+ if(!Roo.isReady){ // allow calling of init() before onReady
+ Roo.onReady(Roo.QuickTips.init, Roo.QuickTips);
+ return;
+ }
+ el = new Roo.Layer({cls:"x-tip", shadow:"drop", shim: true, constrain:true, shadowOffset:4});
+ el.fxDefaults = {stopFx: true};
+ // maximum custom styling
+ //el.update('<div class="x-tip-top-left"><div class="x-tip-top-right"><div class="x-tip-top"></div></div></div><div class="x-tip-bd-left"><div class="x-tip-bd-right"><div class="x-tip-bd"><div class="x-tip-close"></div><h3></h3><div class="x-tip-bd-inner"></div><div class="x-clear"></div></div></div></div><div class="x-tip-ft-left"><div class="x-tip-ft-right"><div class="x-tip-ft"></div></div></div>');
+ el.update('<div class="x-tip-bd"><div class="x-tip-close"></div><h3></h3><div class="x-tip-bd-inner"></div><div class="x-clear"></div></div>');
+ tipTitle = el.child('h3');
+ tipTitle.enableDisplayMode("block");
+ tipBody = el.child('div.x-tip-bd');
+ tipBodyText = el.child('div.x-tip-bd-inner');
+ //bdLeft = el.child('div.x-tip-bd-left');
+ //bdRight = el.child('div.x-tip-bd-right');
+ close = el.child('div.x-tip-close');
+ close.enableDisplayMode("block");
+ close.on("click", hide);
+ var d = Roo.get(document);
+ d.on("mousedown", onDown);
+ d.on("mouseover", onOver);
+ d.on("mouseout", onOut);
+ d.on("mousemove", onMove);
+ esc = d.addKeyListener(27, hide);
+ esc.disable();
+ if(Roo.dd.DD){
+ dd = el.initDD("default", null, {
+ onDrag : function(){
+ el.sync();
+ }
+ });
+ dd.setHandleElId(tipTitle.id);
+ dd.lock();
+ }
+ inited = true;
+ }
+ this.enable();
+ },
+
+ /**
+ * Configures a new quick tip instance and assigns it to a target element. The following config options
+ * are supported:
+ * <pre>
+Property Type Description
+---------- --------------------- ------------------------------------------------------------------------
+target Element/String/Array An Element, id or array of ids that this quick tip should be tied to
+ * </ul>
+ * @param {Object} config The config object
+ */
+ register : function(config){
+ var cs = config instanceof Array ? config : arguments;
+ for(var i = 0, len = cs.length; i < len; i++) {
+ var c = cs[i];
+ var target = c.target;
+ if(target){
+ if(target instanceof Array){
+ for(var j = 0, jlen = target.length; j < jlen; j++){
+ tagEls[target[j]] = c;
+ }
+ }else{
+ tagEls[typeof target == 'string' ? target : Roo.id(target)] = c;
+ }
+ }
+ }
+ },
+
+ /**
+ * Removes this quick tip from its element and destroys it.
+ * @param {String/HTMLElement/Element} el The element from which the quick tip is to be removed.
+ */
+ unregister : function(el){
+ delete tagEls[Roo.id(el)];
+ },
+
+ /**
+ * Enable this quick tip.
+ */
+ enable : function(){
+ if(inited && disabled){
+ locks.pop();
+ if(locks.length < 1){
+ disabled = false;
+ }
+ }
+ },
+
+ /**
+ * Disable this quick tip.
+ */
+ disable : function(){
+ disabled = true;
+ clearTimeout(showProc);
+ clearTimeout(hideProc);
+ clearTimeout(dismissProc);
+ if(ce){
+ hide(true);
+ }
+ locks.push(1);
+ },
+
+ /**
+ * Returns true if the quick tip is enabled, else false.
+ */
+ isEnabled : function(){
+ return !disabled;
+ },
+
+ // private
+ tagConfig : {
+ namespace : "roo", // was ext?? this may break..
+ alt_namespace : "ext",
+ attribute : "qtip",
+ width : "width",
+ target : "target",
+ title : "qtitle",
+ hide : "hide",
+ cls : "qclass"
+ }
+ };
+}();
+
+// backwards compat
+Roo.QuickTips.tips = Roo.QuickTips.register;/*
+ * Based on:
+ * Ext JS Library 1.1.1
+ * Copyright(c) 2006-2007, Ext JS, LLC.
+ *
+ * Originally Released Under LGPL - original licence link has changed is not relivant.
+ *
+ * Fork - LGPL
+ * <script type="text/javascript">
+ */
+
+
+/**
+ * @class Roo.tree.TreePanel
+ * @extends Roo.data.Tree
+ * @cfg {Roo.tree.TreeNode} root The root node
+ * @cfg {Boolean} rootVisible false to hide the root node (defaults to true)
+ * @cfg {Boolean} lines false to disable tree lines (defaults to true)
+ * @cfg {Boolean} enableDD true to enable drag and drop
+ * @cfg {Boolean} enableDrag true to enable just drag
+ * @cfg {Boolean} enableDrop true to enable just drop
+ * @cfg {Object} dragConfig Custom config to pass to the {@link Roo.tree.TreeDragZone} instance
+ * @cfg {Object} dropConfig Custom config to pass to the {@link Roo.tree.TreeDropZone} instance
+ * @cfg {String} ddGroup The DD group this TreePanel belongs to
+ * @cfg {String} ddAppendOnly True if the tree should only allow append drops (use for trees which are sorted)
+ * @cfg {Boolean} ddScroll true to enable YUI body scrolling
+ * @cfg {Boolean} containerScroll true to register this container with ScrollManager
+ * @cfg {Boolean} hlDrop false to disable node highlight on drop (defaults to the value of Roo.enableFx)
+ * @cfg {String} hlColor The color of the node highlight (defaults to C3DAF9)
+ * @cfg {Boolean} animate true to enable animated expand/collapse (defaults to the value of Roo.enableFx)
+ * @cfg {Boolean} singleExpand true if only 1 node per branch may be expanded
+ * @cfg {Boolean} selModel A tree selection model to use with this TreePanel (defaults to a {@link Roo.tree.DefaultSelectionModel})
+ * @cfg {Roo.tree.TreeLoader} loader A TreeLoader for use with this TreePanel
+ * @cfg {Roo.tree.TreeEditor} editor The TreeEditor to display when clicked.
+ * @cfg {String} pathSeparator The token used to separate sub-paths in path strings (defaults to '/')
+ * @cfg {Function} renderer DEPRECATED - use TreeLoader:create event / Sets the rendering (formatting) function for the nodes. to return HTML markup for the tree view. The render function is called with the following parameters:<ul><li>The {Object} The data for the node.</li></ul>
+ * @cfg {Function} rendererTip DEPRECATED - use TreeLoader:create event / Sets the rendering (formatting) function for the nodes hovertip to return HTML markup for the tree view. The render function is called with the following parameters:<ul><li>The {Object} The data for the node.</li></ul>
+ *