+/**\r
+ * @preserve jquery.layout 1.3.0 - Release Candidate 30.51\r
+ * $Date: 2012-05-12 08:00:00 (Sat, 12 May 2012) $\r
+ * $Rev: 303005 $\r
+ *\r
+ * Copyright (c) 2012 \r
+ * Fabrizio Balliano (http://www.fabrizioballiano.net)\r
+ * Kevin Dalman (http://allpro.net)\r
+ *\r
+ * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html)\r
+ * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses.\r
+ *\r
+ * Changelog: http://layout.jquery-dev.net/changelog.cfm#1.3.0.rc30.5\r
+ *\r
+ * Docs: http://layout.jquery-dev.net/documentation.html\r
+ * Tips: http://layout.jquery-dev.net/tips.html\r
+ * Help: http://groups.google.com/group/jquery-ui-layout\r
+ */\r
+\r
+/* JavaDoc Info: http://code.google.com/closure/compiler/docs/js-for-compiler.html\r
+ * {!Object} non-nullable type (never NULL)\r
+ * {?string} nullable type (sometimes NULL) - default for {Object}\r
+ * {number=} optional parameter\r
+ * {*} ALL types\r
+ */\r
+\r
+// NOTE: For best readability, view with a fixed-width font and tabs equal to 4-chars\r
+\r
+;(function ($) {\r
+\r
+// alias Math methods - used a lot!\r
+var min = Math.min\r
+, max = Math.max\r
+, round = Math.floor\r
+;\r
+function isStr (v) { return $.type(v) === "string"; }\r
+\r
+function runPluginCallbacks (Instance, a_fn) {\r
+ if ($.isArray(a_fn)) \r
+ for (var i=0, c=a_fn.length; i<c; i++) {\r
+ var fn = a_fn[i];\r
+ try {\r
+ if (isStr(fn)) // 'name' of a function\r
+ fn = eval(fn);\r
+ if ($.isFunction(fn))\r
+ fn( Instance );\r
+ } catch (ex) {}\r
+ }\r
+};\r
+\r
+\r
+\r
+/*\r
+ * GENERIC $.layout METHODS - used by all layouts\r
+ */\r
+$.layout = {\r
+\r
+ version: "1.3.rc30.51"\r
+, revision: 0.033005 // 1.3.0 final = 1.0300 - major(n+).minor(nn)+patch(nn+)\r
+\r
+ // LANGUAGE CUSTOMIZATION\r
+, language: {\r
+ // Tips and messages for resizers, togglers, custom buttons, etc.\r
+ Open: "Open" // eg: "Open Pane"\r
+ , Close: "Close"\r
+ , Resize: "Resize"\r
+ , Slide: "Slide Open"\r
+ , Pin: "Pin"\r
+ , Unpin: "Un-Pin"\r
+ , noRoomToOpenTip: "Not enough room to show this pane."\r
+ , minSizeWarning: "Panel has reached its minimum size"\r
+ , maxSizeWarning: "Panel has reached its maximum size"\r
+ // Developer error messages\r
+ , pane: "pane" // description of "layout pane element"\r
+ , selector: "selector" // description of "jQuery-selector"\r
+ , errButton: "Error Adding Button \n\nInvalid "\r
+ , errContainerMissing: "UI Layout Initialization Error\n\nThe specified layout-container does not exist."\r
+ , errCenterPaneMissing: "UI Layout Initialization Error\n\nThe center-pane element does not exist.\n\nThe center-pane is a required element."\r
+ , errContainerHeight: "UI Layout Initialization Warning\n\nThe layout-container \"CONTAINER\" has no height.\n\nTherefore the layout is 0-height and hence 'invisible'!"\r
+ }\r
+\r
+ // can update code here if $.browser is phased out\r
+, browser: {\r
+ mozilla: !!$.browser.mozilla\r
+ , webkit: !!$.browser.webkit || !!$.browser.safari // webkit = jQ 1.4\r
+ , msie: !!$.browser.msie\r
+ , isIE6: !!$.browser.msie && $.browser.version == 6\r
+ , version: $.browser.version // not used in Layout core, but may be used by plugins\r
+ }\r
+\r
+ // *PREDEFINED* EFFECTS & DEFAULTS \r
+ // MUST list effect here - OR MUST set an fxSettings option (can be an empty hash: {})\r
+, effects: {\r
+\r
+ // Pane Open/Close Animations\r
+ slide: {\r
+ all: { duration: "fast" } // eg: duration: 1000, easing: "easeOutBounce"\r
+ , north: { direction: "up" }\r
+ , south: { direction: "down" }\r
+ , east: { direction: "right"}\r
+ , west: { direction: "left" }\r
+ }\r
+ , drop: {\r
+ all: { duration: "slow" }\r
+ , north: { direction: "up" }\r
+ , south: { direction: "down" }\r
+ , east: { direction: "right"}\r
+ , west: { direction: "left" }\r
+ }\r
+ , scale: {\r
+ all: { duration: "fast" }\r
+ }\r
+ // these are not recommended, but can be used\r
+ , blind: {}\r
+ , clip: {}\r
+ , explode: {}\r
+ , fade: {}\r
+ , fold: {}\r
+ , puff: {}\r
+\r
+ // Pane Resize Animations\r
+ , size: {\r
+ all: { easing: "swing" }\r
+ }\r
+ }\r
+\r
+ // INTERNAL CONFIG DATA - DO NOT CHANGE THIS!\r
+, config: {\r
+ optionRootKeys: "effects,panes,north,south,west,east,center".split(",")\r
+ , allPanes: "north,south,west,east,center".split(",")\r
+ , borderPanes: "north,south,west,east".split(",")\r
+ , oppositeEdge: {\r
+ north: "south"\r
+ , south: "north"\r
+ , east: "west"\r
+ , west: "east"\r
+ }\r
+ // offscreen data\r
+ , offscreenCSS: { left: "-99999px", right: "auto" } // used by hide/close if useOffscreenClose=true\r
+ , offscreenReset: "offscreenReset" // key used for data\r
+ // CSS used in multiple places\r
+ , hidden: { visibility: "hidden" }\r
+ , visible: { visibility: "visible" }\r
+ // layout element settings\r
+ , resizers: {\r
+ cssReq: {\r
+ position: "absolute"\r
+ , padding: 0\r
+ , margin: 0\r
+ , fontSize: "1px"\r
+ , textAlign: "left" // to counter-act "center" alignment!\r
+ , overflow: "hidden" // prevent toggler-button from overflowing\r
+ // SEE $.layout.defaults.zIndexes.resizer_normal\r
+ }\r
+ , cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true\r
+ background: "#DDD"\r
+ , border: "none"\r
+ }\r
+ }\r
+ , togglers: {\r
+ cssReq: {\r
+ position: "absolute"\r
+ , display: "block"\r
+ , padding: 0\r
+ , margin: 0\r
+ , overflow: "hidden"\r
+ , textAlign: "center"\r
+ , fontSize: "1px"\r
+ , cursor: "pointer"\r
+ , zIndex: 1\r
+ }\r
+ , cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true\r
+ background: "#AAA"\r
+ }\r
+ }\r
+ , content: {\r
+ cssReq: {\r
+ position: "relative" /* contain floated or positioned elements */\r
+ }\r
+ , cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true\r
+ overflow: "auto"\r
+ , padding: "10px"\r
+ }\r
+ , cssDemoPane: { // DEMO CSS - REMOVE scrolling from 'pane' when it has a content-div\r
+ overflow: "hidden"\r
+ , padding: 0\r
+ }\r
+ }\r
+ , panes: { // defaults for ALL panes - overridden by 'per-pane settings' below\r
+ cssReq: {\r
+ position: "absolute"\r
+ , margin: 0\r
+ // $.layout.defaults.zIndexes.pane_normal\r
+ }\r
+ , cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true\r
+ padding: "10px"\r
+ , background: "#FFF"\r
+ , border: "1px solid #BBB"\r
+ , overflow: "auto"\r
+ }\r
+ }\r
+ , north: {\r
+ side: "Top"\r
+ , sizeType: "Height"\r
+ , dir: "horz"\r
+ , cssReq: {\r
+ top: 0\r
+ , bottom: "auto"\r
+ , left: 0\r
+ , right: 0\r
+ , width: "auto"\r
+ // height: DYNAMIC\r
+ }\r
+ }\r
+ , south: {\r
+ side: "Bottom"\r
+ , sizeType: "Height"\r
+ , dir: "horz"\r
+ , cssReq: {\r
+ top: "auto"\r
+ , bottom: 0\r
+ , left: 0\r
+ , right: 0\r
+ , width: "auto"\r
+ // height: DYNAMIC\r
+ }\r
+ }\r
+ , east: {\r
+ side: "Right"\r
+ , sizeType: "Width"\r
+ , dir: "vert"\r
+ , cssReq: {\r
+ left: "auto"\r
+ , right: 0\r
+ , top: "auto" // DYNAMIC\r
+ , bottom: "auto" // DYNAMIC\r
+ , height: "auto"\r
+ // width: DYNAMIC\r
+ }\r
+ }\r
+ , west: {\r
+ side: "Left"\r
+ , sizeType: "Width"\r
+ , dir: "vert"\r
+ , cssReq: {\r
+ left: 0\r
+ , right: "auto"\r
+ , top: "auto" // DYNAMIC\r
+ , bottom: "auto" // DYNAMIC\r
+ , height: "auto"\r
+ // width: DYNAMIC\r
+ }\r
+ }\r
+ , center: {\r
+ dir: "center"\r
+ , cssReq: {\r
+ left: "auto" // DYNAMIC\r
+ , right: "auto" // DYNAMIC\r
+ , top: "auto" // DYNAMIC\r
+ , bottom: "auto" // DYNAMIC\r
+ , height: "auto"\r
+ , width: "auto"\r
+ }\r
+ }\r
+ }\r
+\r
+ // CALLBACK FUNCTION NAMESPACE - used to store reusable callback functions\r
+, callbacks: {}\r
+\r
+, getParentPaneElem: function (el) {\r
+ // must pass either a container or pane element\r
+ var $el = $(el)\r
+ , layout = $el.data("layout") || $el.data("parentLayout");\r
+ if (layout) {\r
+ var $cont = layout.container;\r
+ // see if this container is directly-nested inside an outer-pane\r
+ if ($cont.data("layoutPane")) return $cont;\r
+ var $pane = $cont.closest("."+ $.layout.defaults.panes.paneClass);\r
+ // if a pane was found, return it\r
+ if ($pane.data("layoutPane")) return $pane;\r
+ }\r
+ return null;\r
+ }\r
+\r
+, getParentPaneInstance: function (el) {\r
+ // must pass either a container or pane element\r
+ var $pane = $.layout.getParentPaneElem(el);\r
+ return $pane ? $pane.data("layoutPane") : null;\r
+ }\r
+\r
+, getParentLayoutInstance: function (el) {\r
+ // must pass either a container or pane element\r
+ var $pane = $.layout.getParentPaneElem(el);\r
+ return $pane ? $pane.data("parentLayout") : null;\r
+ }\r
+\r
+, getEventObject: function (evt) {\r
+ return typeof evt === "object" && evt.stopPropagation ? evt : null;\r
+ }\r
+, parsePaneName: function (evt_or_pane) {\r
+ // getEventObject() automatically calls .stopPropagation(), WHICH MUST BE DONE!\r
+ var evt = $.layout.getEventObject( evt_or_pane );\r
+ if (evt) {\r
+ // ALWAYS stop propagation of events triggered in Layout!\r
+ evt.stopPropagation();\r
+ return $(this).data("layoutEdge");\r
+ }\r
+ else\r
+ return evt_or_pane;\r
+ }\r
+\r
+\r
+ // LAYOUT-PLUGIN REGISTRATION\r
+ // more plugins can added beyond this default list\r
+, plugins: {\r
+ draggable: !!$.fn.draggable // resizing\r
+ , effects: {\r
+ core: !!$.effects // animimations (specific effects tested by initOptions)\r
+ , slide: $.effects && $.effects.slide // default effect\r
+ }\r
+ }\r
+\r
+// arrays of plugin or other methods to be triggered for events in *each layout* - will be passed 'Instance'\r
+, onCreate: [] // runs when layout is just starting to be created - right after options are set\r
+, onLoad: [] // runs after layout container and global events init, but before initPanes is called\r
+, onReady: [] // runs after initialization *completes* - ie, after initPanes completes successfully\r
+, onDestroy: [] // runs after layout is destroyed\r
+, onUnload: [] // runs after layout is destroyed OR when page unloads\r
+, afterOpen: [] // runs after setAsOpen() completes\r
+, afterClose: [] // runs after setAsClosed() completes\r
+\r
+ /*\r
+ * GENERIC UTILITY METHODS\r
+ */\r
+\r
+ // calculate and return the scrollbar width, as an integer\r
+, scrollbarWidth: function () { return window.scrollbarWidth || $.layout.getScrollbarSize('width'); }\r
+, scrollbarHeight: function () { return window.scrollbarHeight || $.layout.getScrollbarSize('height'); }\r
+, getScrollbarSize: function (dim) {\r
+ var $c = $('<div style="position: absolute; top: -10000px; left: -10000px; width: 100px; height: 100px; overflow: scroll;"></div>').appendTo("body");\r
+ var d = { width: $c.width() - $c[0].clientWidth, height: $c.height() - $c[0].clientHeight };\r
+ $c.remove();\r
+ window.scrollbarWidth = d.width;\r
+ window.scrollbarHeight = d.height;\r
+ return dim.match(/^(width|height)$/) ? d[dim] : d;\r
+ }\r
+\r
+\r
+ /**\r
+ * Returns hash container 'display' and 'visibility'\r
+ *\r
+ * @see $.swap() - swaps CSS, runs callback, resets CSS\r
+ */\r
+, showInvisibly: function ($E, force) {\r
+ if (!$E) return {};\r
+ if (!$E.jquery) $E = $($E);\r
+ var CSS = {\r
+ display: $E.css('display')\r
+ , visibility: $E.css('visibility')\r
+ };\r
+ if (force || CSS.display === "none") { // only if not *already hidden*\r
+ $E.css({ display: "block", visibility: "hidden" }); // show element 'invisibly' so can be measured\r
+ return CSS;\r
+ }\r
+ else return {};\r
+ }\r
+\r
+ /**\r
+ * Returns data for setting size of an element (container or a pane).\r
+ *\r
+ * @see _create(), onWindowResize() for container, plus others for pane\r
+ * @return JSON Returns a hash of all dimensions: top, bottom, left, right, outerWidth, innerHeight, etc\r
+ */\r
+, getElementDimensions: function ($E) {\r
+ var\r
+ d = {} // dimensions hash\r
+ , x = d.css = {} // CSS hash\r
+ , i = {} // TEMP insets\r
+ , b, p // TEMP border, padding\r
+ , N = $.layout.cssNum\r
+ , off = $E.offset()\r
+ ;\r
+ d.offsetLeft = off.left;\r
+ d.offsetTop = off.top;\r
+\r
+ $.each("Left,Right,Top,Bottom".split(","), function (idx, e) { // e = edge\r
+ b = x["border" + e] = $.layout.borderWidth($E, e);\r
+ p = x["padding"+ e] = $.layout.cssNum($E, "padding"+e);\r
+ i[e] = b + p; // total offset of content from outer side\r
+ d["inset"+ e] = p;\r
+ });\r
+\r
+ d.offsetWidth = $E.innerWidth(); // offsetWidth is used in calc when doing manual resize\r
+ d.offsetHeight = $E.innerHeight(); // ditto\r
+ d.outerWidth = $E.outerWidth();\r
+ d.outerHeight = $E.outerHeight();\r
+ d.innerWidth = max(0, d.outerWidth - i.Left - i.Right);\r
+ d.innerHeight = max(0, d.outerHeight - i.Top - i.Bottom);\r
+\r
+ x.width = $E.width();\r
+ x.height = $E.height();\r
+ x.top = N($E,"top",true);\r
+ x.bottom = N($E,"bottom",true);\r
+ x.left = N($E,"left",true);\r
+ x.right = N($E,"right",true);\r
+\r
+ //d.visible = $E.is(":visible");// && x.width > 0 && x.height > 0;\r
+\r
+ return d;\r
+ }\r
+\r
+, getElementCSS: function ($E, list) {\r
+ var\r
+ CSS = {}\r
+ , style = $E[0].style\r
+ , props = list.split(",")\r
+ , sides = "Top,Bottom,Left,Right".split(",")\r
+ , attrs = "Color,Style,Width".split(",")\r
+ , p, s, a, i, j, k\r
+ ;\r
+ for (i=0; i < props.length; i++) {\r
+ p = props[i];\r
+ if (p.match(/(border|padding|margin)$/))\r
+ for (j=0; j < 4; j++) {\r
+ s = sides[j];\r
+ if (p === "border")\r
+ for (k=0; k < 3; k++) {\r
+ a = attrs[k];\r
+ CSS[p+s+a] = style[p+s+a];\r
+ }\r
+ else\r
+ CSS[p+s] = style[p+s];\r
+ }\r
+ else\r
+ CSS[p] = style[p];\r
+ };\r
+ return CSS\r
+ }\r
+\r
+ /**\r
+ * Return the innerWidth for the current browser/doctype\r
+ *\r
+ * @see initPanes(), sizeMidPanes(), initHandles(), sizeHandles()\r
+ * @param {Array.<Object>} $E Must pass a jQuery object - first element is processed\r
+ * @param {number=} outerWidth (optional) Can pass a width, allowing calculations BEFORE element is resized\r
+ * @return {number} Returns the innerWidth of the elem by subtracting padding and borders\r
+ */\r
+, cssWidth: function ($E, outerWidth) {\r
+ var\r
+ b = $.layout.borderWidth\r
+ , n = $.layout.cssNum\r
+ ;\r
+ // a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed\r
+ if (outerWidth <= 0) return 0;\r
+\r
+ if (!$.support.boxModel) return outerWidth;\r
+\r
+ // strip border and padding from outerWidth to get CSS Width\r
+ var W = outerWidth\r
+ - b($E, "Left")\r
+ - b($E, "Right")\r
+ - n($E, "paddingLeft") \r
+ - n($E, "paddingRight")\r
+ ;\r
+\r
+ return max(0,W);\r
+ }\r
+\r
+ /**\r
+ * Return the innerHeight for the current browser/doctype\r
+ *\r
+ * @see initPanes(), sizeMidPanes(), initHandles(), sizeHandles()\r
+ * @param {Array.<Object>} $E Must pass a jQuery object - first element is processed\r
+ * @param {number=} outerHeight (optional) Can pass a width, allowing calculations BEFORE element is resized\r
+ * @return {number} Returns the innerHeight of the elem by subtracting padding and borders\r
+ */\r
+, cssHeight: function ($E, outerHeight) {\r
+ var\r
+ b = $.layout.borderWidth\r
+ , n = $.layout.cssNum\r
+ ;\r
+ // a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed\r
+ if (outerHeight <= 0) return 0;\r
+\r
+ if (!$.support.boxModel) return outerHeight;\r
+\r
+ // strip border and padding from outerHeight to get CSS Height\r
+ var H = outerHeight\r
+ - b($E, "Top")\r
+ - b($E, "Bottom")\r
+ - n($E, "paddingTop")\r
+ - n($E, "paddingBottom")\r
+ ;\r
+\r
+ return max(0,H);\r
+ }\r
+\r
+ /**\r
+ * Returns the 'current CSS numeric value' for a CSS property - 0 if property does not exist\r
+ *\r
+ * @see Called by many methods\r
+ * @param {Array.<Object>} $E Must pass a jQuery object - first element is processed\r
+ * @param {string} prop The name of the CSS property, eg: top, width, etc.\r
+ * @param {boolean=} [allowAuto=false] true = return 'auto' if that is value; false = return 0\r
+ * @return {(string|number)} Usually used to get an integer value for position (top, left) or size (height, width)\r
+ */\r
+, cssNum: function ($E, prop, allowAuto) {\r
+ if (!$E.jquery) $E = $($E);\r
+ var CSS = $.layout.showInvisibly($E)\r
+ , p = $.curCSS($E[0], prop, true)\r
+ , v = allowAuto && p=="auto" ? p : (parseInt(p, 10) || 0);\r
+ $E.css( CSS ); // RESET\r
+ return v;\r
+ }\r
+\r
+, borderWidth: function (el, side) {\r
+ if (el.jquery) el = el[0];\r
+ var b = "border"+ side.substr(0,1).toUpperCase() + side.substr(1); // left => Left\r
+ return $.curCSS(el, b+"Style", true) === "none" ? 0 : (parseInt($.curCSS(el, b+"Width", true), 10) || 0);\r
+ }\r
+\r
+ /**\r
+ * Mouse-tracking utility - FUTURE REFERENCE\r
+ *\r
+ * init: if (!window.mouse) {\r
+ * window.mouse = { x: 0, y: 0 };\r
+ * $(document).mousemove( $.layout.trackMouse );\r
+ * }\r
+ *\r
+ * @param {Object} evt\r
+ *\r
+, trackMouse: function (evt) {\r
+ window.mouse = { x: evt.clientX, y: evt.clientY };\r
+ }\r
+ */\r
+\r
+ /**\r
+ * SUBROUTINE for preventPrematureSlideClose option\r
+ *\r
+ * @param {Object} evt\r
+ * @param {Object=} el\r
+ */\r
+, isMouseOverElem: function (evt, el) {\r
+ var\r
+ $E = $(el || this)\r
+ , d = $E.offset()\r
+ , T = d.top\r
+ , L = d.left\r
+ , R = L + $E.outerWidth()\r
+ , B = T + $E.outerHeight()\r
+ , x = evt.pageX // evt.clientX ?\r
+ , y = evt.pageY // evt.clientY ?\r
+ ;\r
+ // if X & Y are < 0, probably means is over an open SELECT\r
+ return ($.layout.browser.msie && x < 0 && y < 0) || ((x >= L && x <= R) && (y >= T && y <= B));\r
+ }\r
+\r
+ /**\r
+ * Message/Logging Utility\r
+ *\r
+ * @example $.layout.msg("My message"); // log text\r
+ * @example $.layout.msg("My message", true); // alert text\r
+ * @example $.layout.msg({ foo: "bar" }, "Title"); // log hash-data, with custom title\r
+ * @example $.layout.msg({ foo: "bar" }, true, "Title", { sort: false }); -OR-\r
+ * @example $.layout.msg({ foo: "bar" }, "Title", { sort: false, display: true }); // alert hash-data\r
+ *\r
+ * @param {(Object|string)} info String message OR Hash/Array\r
+ * @param {(Boolean|string|Object)=} [popup=false] True means alert-box - can be skipped\r
+ * @param {(Object|string)=} [debugTitle=""] Title for Hash data - can be skipped\r
+ * @param {Object=} [debutOpts={}] Extra options for debug output\r
+ */\r
+, msg: function (info, popup, debugTitle, debugOpts) {\r
+ if ($.isPlainObject(info) && window.debugData) {\r
+ if (typeof popup === "string") {\r
+ debugOpts = debugTitle;\r
+ debugTitle = popup;\r
+ }\r
+ else if (typeof debugTitle === "object") {\r
+ debugOpts = debugTitle;\r
+ debugTitle = null;\r
+ }\r
+ var t = debugTitle || "log( <object> )"\r
+ , o = $.extend({ sort: false, returnHTML: false, display: false }, debugOpts);\r
+ if (popup === true || o.display)\r
+ debugData( info, t, o );\r
+ else if (window.console)\r
+ console.log(debugData( info, t, o ));\r
+ }\r
+ else if (popup)\r
+ alert(info);\r
+ else if (window.console)\r
+ console.log(info);\r
+ else {\r
+ var id = "#layoutLogger"\r
+ , $l = $(id);\r
+ if (!$l.length)\r
+ $l = createLog();\r
+ $l.children("ul").append('<li style="padding: 4px 10px; margin: 0; border-top: 1px solid #CCC;">'+ info.replace(/\</g,"<").replace(/\>/g,">") +'</li>');\r
+ }\r
+\r
+ function createLog () {\r
+ var pos = $.support.fixedPosition ? 'fixed' : 'absolute'\r
+ , $e = $('<div id="layoutLogger" style="position: '+ pos +'; top: 5px; z-index: 999999; max-width: 25%; overflow: hidden; border: 1px solid #000; border-radius: 5px; background: #FBFBFB; box-shadow: 0 2px 10px rgba(0,0,0,0.3);">'\r
+ + '<div style="font-size: 13px; font-weight: bold; padding: 5px 10px; background: #F6F6F6; border-radius: 5px 5px 0 0; cursor: move;">'\r
+ + '<span style="float: right; padding-left: 7px; cursor: pointer;" title="Remove Console" onclick="$(this).closest(\'#layoutLogger\').remove()">X</span>Layout console.log</div>'\r
+ + '<ul style="font-size: 13px; font-weight: none; list-style: none; margin: 0; padding: 0 0 2px;"></ul>'\r
+ + '</div>'\r
+ ).appendTo("body");\r
+ $e.css('left', $(window).width() - $e.outerWidth() - 5)\r
+ if ($.ui.draggable) $e.draggable({ handle: ':first-child' });\r
+ return $e;\r
+ };\r
+ }\r
+\r
+};\r
+\r
+var lang = $.layout.language; // alias used in defaults...\r
+\r
+// DEFAULT OPTIONS - CHANGE IF DESIRED\r
+$.layout.defaults = {\r
+/*\r
+ * LAYOUT & LAYOUT-CONTAINER OPTIONS\r
+ * - none of these options are applicable to individual panes\r
+ */\r
+ name: "" // Not required, but useful for buttons and used for the state-cookie\r
+, containerSelector: "" // ONLY used when specifying a childOptions - to find container-element that is NOT directly-nested\r
+, containerClass: "ui-layout-container" // layout-container element\r
+, scrollToBookmarkOnLoad: true // after creating a layout, scroll to bookmark in URL (.../page.htm#myBookmark)\r
+, resizeWithWindow: true // bind thisLayout.resizeAll() to the window.resize event\r
+, resizeWithWindowDelay: 200 // delay calling resizeAll because makes window resizing very jerky\r
+, resizeWithWindowMaxDelay: 0 // 0 = none - force resize every XX ms while window is being resized\r
+, onresizeall_start: null // CALLBACK when resizeAll() STARTS - NOT pane-specific\r
+, onresizeall_end: null // CALLBACK when resizeAll() ENDS - NOT pane-specific\r
+, onload_start: null // CALLBACK when Layout inits - after options initialized, but before elements\r
+, onload_end: null // CALLBACK when Layout inits - after EVERYTHING has been initialized\r
+, onunload_start: null // CALLBACK when Layout is destroyed OR onWindowUnload\r
+, onunload_end: null // CALLBACK when Layout is destroyed OR onWindowUnload\r
+, autoBindCustomButtons: false // search for buttons with ui-layout-button class and auto-bind them\r
+, initPanes: true // false = DO NOT initialize the panes onLoad - will init later\r
+, showErrorMessages: true // enables fatal error messages to warn developers of common errors\r
+, showDebugMessages: false // display console-and-alert debug msgs - IF this Layout version _has_ debugging code!\r
+// Changing this zIndex value will cause other zIndex values to automatically change\r
+, zIndex: null // the PANE zIndex - resizers and masks will be +1\r
+// DO NOT CHANGE the zIndex values below unless you clearly understand their relationships\r
+, zIndexes: { // set _default_ z-index values here...\r
+ pane_normal: 0 // normal z-index for panes\r
+ , content_mask: 1 // applied to overlays used to mask content INSIDE panes during resizing\r
+ , resizer_normal: 2 // normal z-index for resizer-bars\r
+ , pane_sliding: 100 // applied to *BOTH* the pane and its resizer when a pane is 'slid open'\r
+ , pane_animate: 1000 // applied to the pane when being animated - not applied to the resizer\r
+ , resizer_drag: 10000 // applied to the CLONED resizer-bar when being 'dragged'\r
+ }\r
+/*\r
+ * PANE DEFAULT SETTINGS\r
+ * - settings under the 'panes' key become the default settings for *all panes*\r
+ * - ALL pane-options can also be set specifically for each panes, which will override these 'default values'\r
+ */\r
+, panes: { // default options for 'all panes' - will be overridden by 'per-pane settings'\r
+ applyDemoStyles: false // NOTE: renamed from applyDefaultStyles for clarity\r
+ , closable: true // pane can open & close\r
+ , resizable: true // when open, pane can be resized \r
+ , slidable: true // when closed, pane can 'slide open' over other panes - closes on mouse-out\r
+ , initClosed: false // true = init pane as 'closed'\r
+ , initHidden: false // true = init pane as 'hidden' - no resizer-bar/spacing\r
+ // SELECTORS\r
+ //, paneSelector: "" // MUST be pane-specific - jQuery selector for pane\r
+ , contentSelector: ".ui-layout-content" // INNER div/element to auto-size so only it scrolls, not the entire pane!\r
+ , contentIgnoreSelector: ".ui-layout-ignore" // element(s) to 'ignore' when measuring 'content'\r
+ , findNestedContent: false // true = $P.find(contentSelector), false = $P.children(contentSelector)\r
+ // GENERIC ROOT-CLASSES - for auto-generated classNames\r
+ , paneClass: "ui-layout-pane" // Layout Pane\r
+ , resizerClass: "ui-layout-resizer" // Resizer Bar\r
+ , togglerClass: "ui-layout-toggler" // Toggler Button\r
+ , buttonClass: "ui-layout-button" // CUSTOM Buttons - eg: '[ui-layout-button]-toggle/-open/-close/-pin'\r
+ // ELEMENT SIZE & SPACING\r
+ //, size: 100 // MUST be pane-specific -initial size of pane\r
+ , minSize: 0 // when manually resizing a pane\r
+ , maxSize: 0 // ditto, 0 = no limit\r
+ , spacing_open: 6 // space between pane and adjacent panes - when pane is 'open'\r
+ , spacing_closed: 6 // ditto - when pane is 'closed'\r
+ , togglerLength_open: 50 // Length = WIDTH of toggler button on north/south sides - HEIGHT on east/west sides\r
+ , togglerLength_closed: 50 // 100% OR -1 means 'full height/width of resizer bar' - 0 means 'hidden'\r
+ , togglerAlign_open: "center" // top/left, bottom/right, center, OR...\r
+ , togglerAlign_closed: "center" // 1 => nn = offset from top/left, -1 => -nn == offset from bottom/right\r
+ , togglerTip_open: lang.Close // Toggler tool-tip (title)\r
+ , togglerTip_closed: lang.Open // ditto\r
+ , togglerContent_open: "" // text or HTML to put INSIDE the toggler\r
+ , togglerContent_closed: "" // ditto\r
+ // RESIZING OPTIONS\r
+ , resizerDblClickToggle: true // \r
+ , autoResize: true // IF size is 'auto' or a percentage, then recalc 'pixel size' whenever the layout resizes\r
+ , autoReopen: true // IF a pane was auto-closed due to noRoom, reopen it when there is room? False = leave it closed\r
+ , resizerDragOpacity: 1 // option for ui.draggable\r
+ //, resizerCursor: "" // MUST be pane-specific - cursor when over resizer-bar\r
+ , maskContents: false // true = add DIV-mask over-or-inside this pane so can 'drag' over IFRAMES\r
+ , maskObjects: false // true = add IFRAME-mask over-or-inside this pane to cover objects/applets - content-mask will overlay this mask\r
+ , maskZindex: null // will override zIndexes.content_mask if specified - not applicable to iframe-panes\r
+ , resizingGrid: false // grid size that the resizers will snap-to during resizing, eg: [20,20]\r
+ , livePaneResizing: false // true = LIVE Resizing as resizer is dragged\r
+ , liveContentResizing: false // true = re-measure header/footer heights as resizer is dragged\r
+ , liveResizingTolerance: 1 // how many px change before pane resizes, to control performance\r
+ // TIPS & MESSAGES - also see lang object\r
+ , noRoomToOpenTip: lang.noRoomToOpenTip\r
+ , resizerTip: lang.Resize // Resizer tool-tip (title)\r
+ , sliderTip: lang.Slide // resizer-bar triggers 'sliding' when pane is closed\r
+ , sliderCursor: "pointer" // cursor when resizer-bar will trigger 'sliding'\r
+ , slideTrigger_open: "click" // click, dblclick, mouseenter\r
+ , slideTrigger_close: "mouseleave"// click, mouseleave\r
+ , slideDelay_open: 300 // applies only for mouseenter event - 0 = instant open\r
+ , slideDelay_close: 300 // applies only for mouseleave event (300ms is the minimum!)\r
+ , hideTogglerOnSlide: false // when pane is slid-open, should the toggler show?\r
+ , preventQuickSlideClose: $.layout.browser.webkit // Chrome triggers slideClosed as it is opening\r
+ , preventPrematureSlideClose: false // handle incorrect mouseleave trigger, like when over a SELECT-list in IE\r
+ // HOT-KEYS & MISC\r
+ , showOverflowOnHover: false // will bind allowOverflow() utility to pane.onMouseOver\r
+ , enableCursorHotkey: true // enabled 'cursor' hotkeys\r
+ //, customHotkey: "" // MUST be pane-specific - EITHER a charCode OR a character\r
+ , customHotkeyModifier: "SHIFT" // either 'SHIFT', 'CTRL' or 'CTRL+SHIFT' - NOT 'ALT'\r
+ // PANE ANIMATION\r
+ // NOTE: fxSss_open, fxSss_close & fxSss_size options (eg: fxName_open) are auto-generated if not passed\r
+ , fxName: "slide" // ('none' or blank), slide, drop, scale -- only relevant to 'open' & 'close', NOT 'size'\r
+ , fxSpeed: null // slow, normal, fast, 200, nnn - if passed, will OVERRIDE fxSettings.duration\r
+ , fxSettings: {} // can be passed, eg: { easing: "easeOutBounce", duration: 1500 }\r
+ , fxOpacityFix: true // tries to fix opacity in IE to restore anti-aliasing after animation\r
+ , animatePaneSizing: false // true = animate resizing after dragging resizer-bar OR sizePane() is called\r
+ /* NOTE: Action-specific FX options are auto-generated from the options above if not specifically set:\r
+ fxName_open: "slide" // 'Open' pane animation\r
+ fnName_close: "slide" // 'Close' pane animation\r
+ fxName_size: "slide" // 'Size' pane animation - when animatePaneSizing = true\r
+ fxSpeed_open: null\r
+ fxSpeed_close: null\r
+ fxSpeed_size: null\r
+ fxSettings_open: {}\r
+ fxSettings_close: {}\r
+ fxSettings_size: {}\r
+ */\r
+ // CHILD/NESTED LAYOUTS\r
+ , childOptions: null // Layout-options for nested/child layout - even {} is valid as options\r
+ , initChildLayout: true // true = child layout will be created as soon as _this_ layout completes initialization\r
+ , destroyChildLayout: true // true = destroy child-layout if this pane is destroyed\r
+ , resizeChildLayout: true // true = trigger child-layout.resizeAll() when this pane is resized\r
+ // PANE CALLBACKS\r
+ , triggerEventsOnLoad: false // true = trigger onopen OR onclose callbacks when layout initializes\r
+ , triggerEventsDuringLiveResize: true // true = trigger onresize callback REPEATEDLY if livePaneResizing==true\r
+ , onshow_start: null // CALLBACK when pane STARTS to Show - BEFORE onopen/onhide_start\r
+ , onshow_end: null // CALLBACK when pane ENDS being Shown - AFTER onopen/onhide_end\r
+ , onhide_start: null // CALLBACK when pane STARTS to Close - BEFORE onclose_start\r
+ , onhide_end: null // CALLBACK when pane ENDS being Closed - AFTER onclose_end\r
+ , onopen_start: null // CALLBACK when pane STARTS to Open\r
+ , onopen_end: null // CALLBACK when pane ENDS being Opened\r
+ , onclose_start: null // CALLBACK when pane STARTS to Close\r
+ , onclose_end: null // CALLBACK when pane ENDS being Closed\r
+ , onresize_start: null // CALLBACK when pane STARTS being Resized ***FOR ANY REASON***\r
+ , onresize_end: null // CALLBACK when pane ENDS being Resized ***FOR ANY REASON***\r
+ , onsizecontent_start: null // CALLBACK when sizing of content-element STARTS\r
+ , onsizecontent_end: null // CALLBACK when sizing of content-element ENDS\r
+ , onswap_start: null // CALLBACK when pane STARTS to Swap\r
+ , onswap_end: null // CALLBACK when pane ENDS being Swapped\r
+ , ondrag_start: null // CALLBACK when pane STARTS being ***MANUALLY*** Resized\r
+ , ondrag_end: null // CALLBACK when pane ENDS being ***MANUALLY*** Resized\r
+ }\r
+/*\r
+ * PANE-SPECIFIC SETTINGS\r
+ * - options listed below MUST be specified per-pane - they CANNOT be set under 'panes'\r
+ * - all options under the 'panes' key can also be set specifically for any pane\r
+ * - most options under the 'panes' key apply only to 'border-panes' - NOT the the center-pane\r
+ */\r
+, north: {\r
+ paneSelector: ".ui-layout-north"\r
+ , size: "auto" // eg: "auto", "30%", .30, 200\r
+ , resizerCursor: "n-resize" // custom = url(myCursor.cur)\r
+ , customHotkey: "" // EITHER a charCode (43) OR a character ("o")\r
+ }\r
+, south: {\r
+ paneSelector: ".ui-layout-south"\r
+ , size: "auto"\r
+ , resizerCursor: "s-resize"\r
+ , customHotkey: ""\r
+ }\r
+, east: {\r
+ paneSelector: ".ui-layout-east"\r
+ , size: 200\r
+ , resizerCursor: "e-resize"\r
+ , customHotkey: ""\r
+ }\r
+, west: {\r
+ paneSelector: ".ui-layout-west"\r
+ , size: 200\r
+ , resizerCursor: "w-resize"\r
+ , customHotkey: ""\r
+ }\r
+, center: {\r
+ paneSelector: ".ui-layout-center"\r
+ , minWidth: 0\r
+ , minHeight: 0\r
+ }\r
+};\r
+\r
+$.layout.optionsMap = {\r
+ // layout/global options - NOT pane-options\r
+ layout: ("stateManagement,effects,zIndexes,"\r
+ + "name,zIndex,scrollToBookmarkOnLoad,showErrorMessages,"\r
+ + "resizeWithWindow,resizeWithWindowDelay,resizeWithWindowMaxDelay,"\r
+ + "onresizeall,onresizeall_start,onresizeall_end,onload,onunload,autoBindCustomButtons").split(",")\r
+// borderPanes: [ ALL options that are NOT specified as 'layout' ]\r
+ // default.panes options that apply to the center-pane (most options apply _only_ to border-panes)\r
+, center: ("paneClass,contentSelector,contentIgnoreSelector,findNestedContent,applyDemoStyles,triggerEventsOnLoad,"\r
+ + "showOverflowOnHover,maskContents,maskObjects,liveContentResizing,"\r
+ + "childOptions,initChildLayout,resizeChildLayout,destroyChildLayout,"\r
+ + "onresize,onresize_start,onresize_end,onsizecontent,onsizecontent_start,onsizecontent_end").split(",")\r
+ // options that MUST be specifically set 'per-pane' - CANNOT set in the panes (defaults) key\r
+, noDefault: ("paneSelector,resizerCursor,customHotkey").split(",")\r
+};\r
+\r
+/**\r
+ * Processes options passed in converts flat-format data into subkey (JSON) format\r
+ * In flat-format, subkeys are _currently_ separated with 2 underscores, like north__optName\r
+ * Plugins may also call this method so they can transform their own data\r
+ *\r
+ * @param {!Object} hash Data/options passed by user - may be a single level or nested levels\r
+ * @return {Object} Returns hash of minWidth & minHeight\r
+ */\r
+$.layout.transformData = function (hash) {\r
+ var json = { panes: {}, center: {} } // init return object\r
+ , data, branch, optKey, keys, key, val, i, c;\r
+\r
+ if (typeof hash !== "object") return json; // no options passed\r
+\r
+ // convert all 'flat-keys' to 'sub-key' format\r
+ for (optKey in hash) {\r
+ branch = json;\r
+ data = $.layout.optionsMap.layout;\r
+ val = hash[ optKey ];\r
+ keys = optKey.split("__"); // eg: west__size or north__fxSettings__duration\r
+ c = keys.length - 1;\r
+ // convert underscore-delimited to subkeys\r
+ for (i=0; i <= c; i++) {\r
+ key = keys[i];\r
+ if (i === c)\r
+ branch[key] = val;\r
+ else if (!branch[key])\r
+ branch[key] = {}; // create the subkey\r
+ // recurse to sub-key for next loop - if not done\r
+ branch = branch[key];\r
+ }\r
+ }\r
+\r
+ return json;\r
+}\r
+\r
+// INTERNAL CONFIG DATA - DO NOT CHANGE THIS!\r
+$.layout.backwardCompatibility = {\r
+ // data used by renameOldOptions()\r
+ map: {\r
+ // OLD Option Name: NEW Option Name\r
+ applyDefaultStyles: "applyDemoStyles"\r
+ , resizeNestedLayout: "resizeChildLayout"\r
+ , resizeWhileDragging: "livePaneResizing"\r
+ , resizeContentWhileDragging: "liveContentResizing"\r
+ , triggerEventsWhileDragging: "triggerEventsDuringLiveResize"\r
+ , maskIframesOnResize: "maskContents"\r
+ , useStateCookie: "stateManagement.enabled"\r
+ , "cookie.autoLoad": "stateManagement.autoLoad"\r
+ , "cookie.autoSave": "stateManagement.autoSave"\r
+ , "cookie.keys": "stateManagement.stateKeys"\r
+ , "cookie.name": "stateManagement.cookie.name"\r
+ , "cookie.domain": "stateManagement.cookie.domain"\r
+ , "cookie.path": "stateManagement.cookie.path"\r
+ , "cookie.expires": "stateManagement.cookie.expires"\r
+ , "cookie.secure": "stateManagement.cookie.secure"\r
+ }\r
+ /**\r
+ * @param {Object} opts\r
+ */\r
+, renameOptions: function (opts) {\r
+ var map = $.layout.backwardCompatibility.map\r
+ , oldData, newData, value\r
+ ;\r
+ for (var itemPath in map) {\r
+ oldData = getBranch( itemPath );\r
+ value = oldData.branch[ oldData.key ]\r
+ if (value !== undefined) {\r
+ newData = getBranch( map[itemPath], true )\r
+ newData.branch[ newData.key ] = value;\r
+ delete oldData.branch[ oldData.key ];\r
+ }\r
+ }\r
+\r
+ /**\r
+ * @param {string} path\r
+ * @param {boolean=} [create=false] Create path if does not exist\r
+ */\r
+ function getBranch (path, create) {\r
+ var a = path.split(".") // split keys into array\r
+ , c = a.length - 1\r
+ , D = { branch: opts, key: a[c] } // init branch at top & set key (last item)\r
+ , i = 0, k, undef;\r
+ for (; i<c; i++) { // skip the last key (data)\r
+ k = a[i];\r
+ if (D.branch[ k ] == undefined) { // child-key does not exist\r
+ if (create) {\r
+ D.branch = D.branch[ k ] = {}; // create child-branch\r
+ }\r
+ else // can't go any farther\r
+ D.branch = {}; // branch is undefined\r
+ }\r
+ else\r
+ D.branch = D.branch[ k ]; // get child-branch\r
+ }\r
+ return D;\r
+ };\r
+ }\r
+ /**\r
+ * @param {Object} opts\r
+ */\r
+, renameAllOptions: function (opts) {\r
+ var ren = $.layout.backwardCompatibility.renameOptions;\r
+ // rename root (layout) options\r
+ ren( opts );\r
+ // rename 'defaults' to 'panes'\r
+ if (opts.defaults) {\r
+ if (typeof opts.panes !== "object")\r
+ opts.panes = {};\r
+ $.extend(true, opts.panes, opts.defaults);\r
+ delete opts.defaults;\r
+ }\r
+ // rename options in the the options.panes key\r
+ if (opts.panes) ren( opts.panes );\r
+ // rename options inside *each pane key*, eg: options.west\r
+ $.each($.layout.config.allPanes, function (i, pane) {\r
+ if (opts[pane]) ren( opts[pane] );\r
+ }); \r
+ return opts;\r
+ }\r
+};\r
+\r
+\r
+\r
+/* ============================================================\r
+ * BEGIN WIDGET: $( selector ).layout( {options} );\r
+ * ============================================================\r
+ */\r
+$.fn.layout = function (opts) {\r
+ var\r
+\r
+ // local aliases to global data\r
+ browser = $.layout.browser\r
+, lang = $.layout.language // internal alias\r
+, _c = $.layout.config\r
+\r
+ // local aliases to utlity methods\r
+, cssW = $.layout.cssWidth\r
+, cssH = $.layout.cssHeight\r
+, elDims = $.layout.getElementDimensions\r
+, elCSS = $.layout.getElementCSS\r
+, evtObj = $.layout.getEventObject\r
+, evtPane = $.layout.parsePaneName\r
+\r
+/**\r
+ * options - populated by initOptions()\r
+ */\r
+, options = $.extend(true, {}, $.layout.defaults)\r
+, effects = options.effects = $.extend(true, {}, $.layout.effects)\r
+\r
+/**\r
+ * layout-state object\r
+ */\r
+, state = {\r
+ // generate unique ID to use for event.namespace so can unbind only events added by 'this layout'\r
+ id: "layout"+ $.now() // code uses alias: sID\r
+ , initialized: false\r
+ , container: {} // init all keys\r
+ , north: {}\r
+ , south: {}\r
+ , east: {}\r
+ , west: {}\r
+ , center: {}\r
+ }\r
+\r
+/**\r
+ * parent/child-layout pointers\r
+ */\r
+//, hasParentLayout = false - exists ONLY inside Instance so can be set externally\r
+, children = {\r
+ north: null\r
+ , south: null\r
+ , east: null\r
+ , west: null\r
+ , center: null\r
+ }\r
+\r
+/*\r
+ * ###########################\r
+ * INTERNAL HELPER FUNCTIONS\r
+ * ###########################\r
+ */\r
+\r
+ /**\r
+ * Manages all internal timers\r
+ */\r
+, timer = {\r
+ data: {}\r
+ , set: function (s, fn, ms) { timer.clear(s); timer.data[s] = setTimeout(fn, ms); }\r
+ , clear: function (s) { var t=timer.data; if (t[s]) {clearTimeout(t[s]); delete t[s];} }\r
+ }\r
+\r
+, _log = function (msg, popup) {\r
+ $.layout.msg( options.name +' / '+ msg, (popup && options.showErrorMessages) );\r
+ }\r
+\r
+ /**\r
+ * Executes a Callback function after a trigger event, like resize, open or close\r
+ *\r
+ * @param {string} evtName Name of the layout callback, eg "onresize_start"\r
+ * @param {?string} pane This is passed only so we can pass the 'pane object' to the callback\r
+ * @param {?boolean} skipBoundEvents Accepts a function name, OR a comma-delimited array: [0]=function name, [1]=argument\r
+ */\r
+, _runCallbacks = function (evtName, pane, skipBoundEvents) {\r
+ var o = pane ? options[pane] : options\r
+ // names like onopen and onopen_end separate are interchangeable in options...\r
+ , lng = evtName + (evtName.match(/_/) ? "" : "_end")\r
+ , shrt = lng.match(/_end$/) ? lng.substr(0, lng.length - 4) : ""\r
+ , fn = o[lng]\r
+ , retVal = "NC" // NC = No Callback\r
+ , args = []\r
+ ;\r
+ if (!fn && shrt)\r
+ fn = o[shrt];\r
+\r
+ // first trigger the callback set in the options\r
+ if (fn) {\r
+ //try {\r
+ // convert function name (string) to function object\r
+ if (isStr( fn )) {\r
+ if (fn.match(/,/)) {\r
+ // function name cannot contain a comma, \r
+ // so must be a function name AND a parameter to pass\r
+ args = fn.split(",")\r
+ , fn = eval(args[0]);\r
+ }\r
+ else // just the name of an external function?\r
+ fn = eval(fn);\r
+ }\r
+ // execute the callback, if exists\r
+ if ($.isFunction( fn )) {\r
+ if (args.length)\r
+ retVal = fn(args[1]); // pass the argument parsed from 'list'\r
+ else if (pane && $Ps[pane])\r
+ // pass data: pane-name, pane-element, pane-state, pane-options, and layout-name\r
+ retVal = fn( pane, $Ps[pane], state[pane], options[pane], options.name );\r
+ else // must be a layout/container callback - pass suitable info\r
+ retVal = fn( Instance, state, options, options.name );\r
+ }\r
+ //}\r
+ //catch (ex) {}\r
+ }\r
+\r
+ // trigger additional events bound directly to the pane\r
+ if (!skipBoundEvents && retVal !== false) {\r
+ if (pane) { // PANE events can be bound to each pane-elements\r
+ $Ps[pane].triggerHandler('layoutpane'+ lng, [ pane, $Ps[pane], state[pane], options[pane], options.name ]);\r
+ if (shrt)\r
+ $Ps[pane].triggerHandler('layoutpane'+ shrt, [ pane, $Ps[pane], state[pane], options[pane], options.name ]);\r
+ }\r
+ else // LAYOUT events can be bound to the container-element\r
+ $N.triggerHandler('layout'+ lng, [ pane, $Ps[pane], state[pane], options[pane], options.name ]);\r
+ }\r
+\r
+ // ALWAYS resizeChildLayout after a resize event - even during initialization\r
+ if (evtName === "onresize_end" || evtName === "onsizecontent_end")\r
+ resizeChildLayout(pane); \r
+\r
+ return retVal;\r
+ }\r
+\r
+\r
+ /**\r
+ * cure iframe display issues in IE & other browsers\r
+ */\r
+, _fixIframe = function (pane) {\r
+ if (browser.mozilla) return; // skip FireFox - it auto-refreshes iframes onShow\r
+ var $P = $Ps[pane];\r
+ // if the 'pane' is an iframe, do it\r
+ if (state[pane].tagName === "IFRAME")\r
+ $P.css(_c.hidden).css(_c.visible); \r
+ else // ditto for any iframes INSIDE the pane\r
+ $P.find('IFRAME').css(_c.hidden).css(_c.visible);\r
+ }\r
+\r
+ /**\r
+ * @param {string} pane Can accept ONLY a 'pane' (east, west, etc)\r
+ * @param {number=} outerSize (optional) Can pass a width, allowing calculations BEFORE element is resized\r
+ * @return {number} Returns the innerHeight/Width of el by subtracting padding and borders\r
+ */\r
+, cssSize = function (pane, outerSize) {\r
+ var fn = _c[pane].dir=="horz" ? cssH : cssW;\r
+ return fn($Ps[pane], outerSize);\r
+ }\r
+\r
+ /**\r
+ * @param {string} pane Can accept ONLY a 'pane' (east, west, etc)\r
+ * @return {Object} Returns hash of minWidth & minHeight\r
+ */\r
+, cssMinDims = function (pane) {\r
+ // minWidth/Height means CSS width/height = 1px\r
+ var $P = $Ps[pane]\r
+ , dir = _c[pane].dir\r
+ , d = {\r
+ minWidth: 1001 - cssW($P, 1000)\r
+ , minHeight: 1001 - cssH($P, 1000)\r
+ }\r
+ ;\r
+ if (dir === "horz") d.minSize = d.minHeight;\r
+ if (dir === "vert") d.minSize = d.minWidth;\r
+ return d;\r
+ }\r
+\r
+ // TODO: see if these methods can be made more useful...\r
+ // TODO: *maybe* return cssW/H from these so caller can use this info\r
+\r
+ /**\r
+ * @param {(string|!Object)} el\r
+ * @param {number=} outerWidth\r
+ * @param {boolean=} [autoHide=false]\r
+ */\r
+, setOuterWidth = function (el, outerWidth, autoHide) {\r
+ var $E = el, w;\r
+ if (isStr(el)) $E = $Ps[el]; // west\r
+ else if (!el.jquery) $E = $(el);\r
+ w = cssW($E, outerWidth);\r
+ $E.css({ width: w });\r
+ if (w > 0) {\r
+ if (autoHide && $E.data('autoHidden') && $E.innerHeight() > 0) {\r
+ $E.show().data('autoHidden', false);\r
+ if (!browser.mozilla) // FireFox refreshes iframes - IE does not\r
+ // make hidden, then visible to 'refresh' display after animation\r
+ $E.css(_c.hidden).css(_c.visible);\r
+ }\r
+ }\r
+ else if (autoHide && !$E.data('autoHidden'))\r
+ $E.hide().data('autoHidden', true);\r
+ }\r
+\r
+ /**\r
+ * @param {(string|!Object)} el\r
+ * @param {number=} outerHeight\r
+ * @param {boolean=} [autoHide=false]\r
+ */\r
+, setOuterHeight = function (el, outerHeight, autoHide) {\r
+ var $E = el, h;\r
+ if (isStr(el)) $E = $Ps[el]; // west\r
+ else if (!el.jquery) $E = $(el);\r
+ h = cssH($E, outerHeight);\r
+ $E.css({ height: h, visibility: "visible" }); // may have been 'hidden' by sizeContent\r
+ if (h > 0 && $E.innerWidth() > 0) {\r
+ if (autoHide && $E.data('autoHidden')) {\r
+ $E.show().data('autoHidden', false);\r
+ if (!browser.mozilla) // FireFox refreshes iframes - IE does not\r
+ $E.css(_c.hidden).css(_c.visible);\r
+ }\r
+ }\r
+ else if (autoHide && !$E.data('autoHidden'))\r
+ $E.hide().data('autoHidden', true);\r
+ }\r
+\r
+ /**\r
+ * @param {(string|!Object)} el\r
+ * @param {number=} outerSize\r
+ * @param {boolean=} [autoHide=false]\r
+ */\r
+, setOuterSize = function (el, outerSize, autoHide) {\r
+ if (_c[pane].dir=="horz") // pane = north or south\r
+ setOuterHeight(el, outerSize, autoHide);\r
+ else // pane = east or west\r
+ setOuterWidth(el, outerSize, autoHide);\r
+ }\r
+\r
+\r
+ /**\r
+ * Converts any 'size' params to a pixel/integer size, if not already\r
+ * If 'auto' or a decimal/percentage is passed as 'size', a pixel-size is calculated\r
+ *\r
+ /**\r
+ * @param {string} pane\r
+ * @param {(string|number)=} size\r
+ * @param {string=} [dir]\r
+ * @return {number}\r
+ */\r
+, _parseSize = function (pane, size, dir) {\r
+ if (!dir) dir = _c[pane].dir;\r
+\r
+ if (isStr(size) && size.match(/%/))\r
+ size = (size === '100%') ? -1 : parseInt(size, 10) / 100; // convert % to decimal\r
+\r
+ if (size === 0)\r
+ return 0;\r
+ else if (size >= 1)\r
+ return parseInt(size, 10);\r
+\r
+ var o = options, avail = 0;\r
+ if (dir=="horz") // north or south or center.minHeight\r
+ avail = sC.innerHeight - ($Ps.north ? o.north.spacing_open : 0) - ($Ps.south ? o.south.spacing_open : 0);\r
+ else if (dir=="vert") // east or west or center.minWidth\r
+ avail = sC.innerWidth - ($Ps.west ? o.west.spacing_open : 0) - ($Ps.east ? o.east.spacing_open : 0);\r
+\r
+ if (size === -1) // -1 == 100%\r
+ return avail;\r
+ else if (size > 0) // percentage, eg: .25\r
+ return round(avail * size);\r
+ else if (pane=="center")\r
+ return 0;\r
+ else { // size < 0 || size=='auto' || size==Missing || size==Invalid\r
+ // auto-size the pane\r
+ var dim = (dir === "horz" ? "height" : "width")\r
+ , $P = $Ps[pane]\r
+ , $C = dim === 'height' ? $Cs[pane] : false\r
+ , vis = $.layout.showInvisibly($P) // show pane invisibly if hidden\r
+ , szP = $P.css(dim) // SAVE current pane size\r
+ , szC = $C ? $C.css(dim) : 0 // SAVE current content size\r
+ ;\r
+ $P.css(dim, "auto");\r
+ if ($C) $C.css(dim, "auto");\r
+ size = (dim === "height") ? $P.outerHeight() : $P.outerWidth(); // MEASURE\r
+ $P.css(dim, szP).css(vis); // RESET size & visibility\r
+ if ($C) $C.css(dim, szC);\r
+ return size;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Calculates current 'size' (outer-width or outer-height) of a border-pane - optionally with 'pane-spacing' added\r
+ *\r
+ * @param {(string|!Object)} pane\r
+ * @param {boolean=} [inclSpace=false]\r
+ * @return {number} Returns EITHER Width for east/west panes OR Height for north/south panes - adjusted for boxModel & browser\r
+ */\r
+, getPaneSize = function (pane, inclSpace) {\r
+ var \r
+ $P = $Ps[pane]\r
+ , o = options[pane]\r
+ , s = state[pane]\r
+ , oSp = (inclSpace ? o.spacing_open : 0)\r
+ , cSp = (inclSpace ? o.spacing_closed : 0)\r
+ ;\r
+ if (!$P || s.isHidden)\r
+ return 0;\r
+ else if (s.isClosed || (s.isSliding && inclSpace))\r
+ return cSp;\r
+ else if (_c[pane].dir === "horz")\r
+ return $P.outerHeight() + oSp;\r
+ else // dir === "vert"\r
+ return $P.outerWidth() + oSp;\r
+ }\r
+\r
+ /**\r
+ * Calculate min/max pane dimensions and limits for resizing\r
+ *\r
+ * @param {string} pane\r
+ * @param {boolean=} [slide=false]\r
+ */\r
+, setSizeLimits = function (pane, slide) {\r
+ if (!isInitialized()) return;\r
+ var \r
+ o = options[pane]\r
+ , s = state[pane]\r
+ , c = _c[pane]\r
+ , dir = c.dir\r
+ , side = c.side.toLowerCase()\r
+ , type = c.sizeType.toLowerCase()\r
+ , isSliding = (slide != undefined ? slide : s.isSliding) // only open() passes 'slide' param\r
+ , $P = $Ps[pane]\r
+ , paneSpacing = o.spacing_open\r
+ // measure the pane on the *opposite side* from this pane\r
+ , altPane = _c.oppositeEdge[pane]\r
+ , altS = state[altPane]\r
+ , $altP = $Ps[altPane]\r
+ , altPaneSize = (!$altP || altS.isVisible===false || altS.isSliding ? 0 : (dir=="horz" ? $altP.outerHeight() : $altP.outerWidth()))\r
+ , altPaneSpacing = ((!$altP || altS.isHidden ? 0 : options[altPane][ altS.isClosed !== false ? "spacing_closed" : "spacing_open" ]) || 0)\r
+ // limitSize prevents this pane from 'overlapping' opposite pane\r
+ , containerSize = (dir=="horz" ? sC.innerHeight : sC.innerWidth)\r
+ , minCenterDims = cssMinDims("center")\r
+ , minCenterSize = dir=="horz" ? max(options.center.minHeight, minCenterDims.minHeight) : max(options.center.minWidth, minCenterDims.minWidth)\r
+ // if pane is 'sliding', then ignore center and alt-pane sizes - because 'overlays' them\r
+ , limitSize = (containerSize - paneSpacing - (isSliding ? 0 : (_parseSize("center", minCenterSize, dir) + altPaneSize + altPaneSpacing)))\r
+ , minSize = s.minSize = max( _parseSize(pane, o.minSize), cssMinDims(pane).minSize )\r
+ , maxSize = s.maxSize = min( (o.maxSize ? _parseSize(pane, o.maxSize) : 100000), limitSize )\r
+ , r = s.resizerPosition = {} // used to set resizing limits\r
+ , top = sC.insetTop\r
+ , left = sC.insetLeft\r
+ , W = sC.innerWidth\r
+ , H = sC.innerHeight\r
+ , rW = o.spacing_open // subtract resizer-width to get top/left position for south/east\r
+ ;\r
+ switch (pane) {\r
+ case "north": r.min = top + minSize;\r
+ r.max = top + maxSize;\r
+ break;\r
+ case "west": r.min = left + minSize;\r
+ r.max = left + maxSize;\r
+ break;\r
+ case "south": r.min = top + H - maxSize - rW;\r
+ r.max = top + H - minSize - rW;\r
+ break;\r
+ case "east": r.min = left + W - maxSize - rW;\r
+ r.max = left + W - minSize - rW;\r
+ break;\r
+ };\r
+ }\r
+\r
+ /**\r
+ * Returns data for setting the size/position of center pane. Also used to set Height for east/west panes\r
+ *\r
+ * @return JSON Returns a hash of all dimensions: top, bottom, left, right, (outer) width and (outer) height\r
+ */\r
+, calcNewCenterPaneDims = function () {\r
+ var d = {\r
+ top: getPaneSize("north", true) // true = include 'spacing' value for pane\r
+ , bottom: getPaneSize("south", true)\r
+ , left: getPaneSize("west", true)\r
+ , right: getPaneSize("east", true)\r
+ , width: 0\r
+ , height: 0\r
+ };\r
+\r
+ // NOTE: sC = state.container\r
+ // calc center-pane outer dimensions\r
+ d.width = sC.innerWidth - d.left - d.right; // outerWidth\r
+ d.height = sC.innerHeight - d.bottom - d.top; // outerHeight\r
+ // add the 'container border/padding' to get final positions relative to the container\r
+ d.top += sC.insetTop;\r
+ d.bottom += sC.insetBottom;\r
+ d.left += sC.insetLeft;\r
+ d.right += sC.insetRight;\r
+\r
+ return d;\r
+ }\r
+\r
+\r
+ /**\r
+ * @param {!Object} el\r
+ * @param {boolean=} [allStates=false]\r
+ */\r
+, getHoverClasses = function (el, allStates) {\r
+ var\r
+ $El = $(el)\r
+ , type = $El.data("layoutRole")\r
+ , pane = $El.data("layoutEdge")\r
+ , o = options[pane]\r
+ , root = o[type +"Class"]\r
+ , _pane = "-"+ pane // eg: "-west"\r
+ , _open = "-open"\r
+ , _closed = "-closed"\r
+ , _slide = "-sliding"\r
+ , _hover = "-hover " // NOTE the trailing space\r
+ , _state = $El.hasClass(root+_closed) ? _closed : _open\r
+ , _alt = _state === _closed ? _open : _closed\r
+ , classes = (root+_hover) + (root+_pane+_hover) + (root+_state+_hover) + (root+_pane+_state+_hover)\r
+ ;\r
+ if (allStates) // when 'removing' classes, also remove alternate-state classes\r
+ classes += (root+_alt+_hover) + (root+_pane+_alt+_hover);\r
+\r
+ if (type=="resizer" && $El.hasClass(root+_slide))\r
+ classes += (root+_slide+_hover) + (root+_pane+_slide+_hover);\r
+\r
+ return $.trim(classes);\r
+ }\r
+, addHover = function (evt, el) {\r
+ var $E = $(el || this);\r
+ if (evt && $E.data("layoutRole") === "toggler")\r
+ evt.stopPropagation(); // prevent triggering 'slide' on Resizer-bar\r
+ $E.addClass( getHoverClasses($E) );\r
+ }\r
+, removeHover = function (evt, el) {\r
+ var $E = $(el || this);\r
+ $E.removeClass( getHoverClasses($E, true) );\r
+ }\r
+\r
+, onResizerEnter = function (evt) { // ALSO called by toggler.mouseenter\r
+ if ($.fn.disableSelection)\r
+ $("body").disableSelection();\r
+ }\r
+, onResizerLeave = function (evt, el) {\r
+ var\r
+ e = el || this // el is only passed when called by the timer\r
+ , pane = $(e).data("layoutEdge")\r
+ , name = pane +"ResizerLeave"\r
+ ;\r
+ timer.clear(pane+"_openSlider"); // cancel slideOpen timer, if set\r
+ timer.clear(name); // cancel enableSelection timer - may re/set below\r
+ // this method calls itself on a timer because it needs to allow\r
+ // enough time for dragging to kick-in and set the isResizing flag\r
+ // dragging has a 100ms delay set, so this delay must be >100\r
+ if (!el) // 1st call - mouseleave event\r
+ timer.set(name, function(){ onResizerLeave(evt, e); }, 200);\r
+ // if user is resizing, then dragStop will enableSelection(), so can skip it here\r
+ else if (!state[pane].isResizing && $.fn.enableSelection) // 2nd call - by timer\r
+ $("body").enableSelection();\r
+ }\r
+\r
+/*\r
+ * ###########################\r
+ * INITIALIZATION METHODS\r
+ * ###########################\r
+ */\r
+\r
+ /**\r
+ * Initialize the layout - called automatically whenever an instance of layout is created\r
+ *\r
+ * @see none - triggered onInit\r
+ * @return mixed true = fully initialized | false = panes not initialized (yet) | 'cancel' = abort\r
+ */\r
+, _create = function () {\r
+ // initialize config/options\r
+ initOptions();\r
+ var o = options;\r
+\r
+ // TEMP state so isInitialized returns true during init process\r
+ state.creatingLayout = true;\r
+\r
+ // init plugins for this layout, if there are any (eg: stateManagement)\r
+ runPluginCallbacks( Instance, $.layout.onCreate );\r
+\r
+ // options & state have been initialized, so now run beforeLoad callback\r
+ // onload will CANCEL layout creation if it returns false\r
+ if (false === _runCallbacks("onload_start"))\r
+ return 'cancel';\r
+\r
+ // initialize the container element\r
+ _initContainer();\r
+\r
+ // bind hotkey function - keyDown - if required\r
+ initHotkeys();\r
+\r
+ // bind window.onunload\r
+ $(window).bind("unload."+ sID, unload);\r
+\r
+ // init plugins for this layout, if there are any (eg: customButtons)\r
+ runPluginCallbacks( Instance, $.layout.onLoad );\r
+\r
+ // if layout elements are hidden, then layout WILL NOT complete initialization!\r
+ // initLayoutElements will set initialized=true and run the onload callback IF successful\r
+ if (o.initPanes) _initLayoutElements();\r
+\r
+ delete state.creatingLayout;\r
+\r
+ return state.initialized;\r
+ }\r
+\r
+ /**\r
+ * Initialize the layout IF not already\r
+ *\r
+ * @see All methods in Instance run this test\r
+ * @return boolean true = layoutElements have been initialized | false = panes are not initialized (yet)\r
+ */\r
+, isInitialized = function () {\r
+ if (state.initialized || state.creatingLayout) return true; // already initialized\r
+ else return _initLayoutElements(); // try to init panes NOW\r
+ }\r
+\r
+ /**\r
+ * Initialize the layout - called automatically whenever an instance of layout is created\r
+ *\r
+ * @see _create() & isInitialized\r
+ * @return An object pointer to the instance created\r
+ */\r
+, _initLayoutElements = function (retry) {\r
+ // initialize config/options\r
+ var o = options;\r
+\r
+ // CANNOT init panes inside a hidden container!\r
+ if (!$N.is(":visible")) {\r
+ // handle Chrome bug where popup window 'has no height'\r
+ // if layout is BODY element, try again in 50ms\r
+ // SEE: http://layout.jquery-dev.net/samples/test_popup_window.html\r
+ if ( !retry && browser.webkit && $N[0].tagName === "BODY" )\r
+ setTimeout(function(){ _initLayoutElements(true); }, 50);\r
+ return false;\r
+ }\r
+\r
+ // a center pane is required, so make sure it exists\r
+ if (!getPane("center").length) {\r
+ if (options.showErrorMessages)\r
+ _log( lang.errCenterPaneMissing, true );\r
+ return false;\r
+ }\r
+\r
+ // TEMP state so isInitialized returns true during init process\r
+ state.creatingLayout = true;\r
+\r
+ // update Container dims\r
+ $.extend(sC, elDims( $N ));\r
+\r
+ // initialize all layout elements\r
+ initPanes(); // size & position panes - calls initHandles() - which calls initResizable()\r
+\r
+ if (o.scrollToBookmarkOnLoad) {\r
+ var l = self.location;\r
+ if (l.hash) l.replace( l.hash ); // scrollTo Bookmark\r
+ }\r
+\r
+ // check to see if this layout 'nested' inside a pane\r
+ if (Instance.hasParentLayout)\r
+ o.resizeWithWindow = false;\r
+ // bind resizeAll() for 'this layout instance' to window.resize event\r
+ else if (o.resizeWithWindow)\r
+ $(window).bind("resize."+ sID, windowResize);\r
+\r
+ delete state.creatingLayout;\r
+ state.initialized = true;\r
+\r
+ // init plugins for this layout, if there are any\r
+ runPluginCallbacks( Instance, $.layout.onReady );\r
+\r
+ // now run the onload callback, if exists\r
+ _runCallbacks("onload_end");\r
+\r
+ return true; // elements initialized successfully\r
+ }\r
+\r
+ /**\r
+ * Initialize nested layouts - called when _initLayoutElements completes\r
+ *\r
+ * NOT CURRENTLY USED\r
+ *\r
+ * @see _initLayoutElements\r
+ * @return An object pointer to the instance created\r
+ */\r
+, _initChildLayouts = function () {\r
+ $.each(_c.allPanes, function (idx, pane) {\r
+ if (options[pane].initChildLayout)\r
+ createChildLayout( pane );\r
+ });\r
+ }\r
+\r
+ /**\r
+ * Initialize nested layouts for a specific pane - can optionally pass layout-options\r
+ *\r
+ * @see _initChildLayouts\r
+ * @param {string} pane The pane being opened, ie: north, south, east, or west\r
+ * @param {Object=} [opts] Layout-options - if passed, will OVERRRIDE options[pane].childOptions\r
+ * @return An object pointer to the layout instance created - or null\r
+ */\r
+, createChildLayout = function (evt_or_pane, opts) {\r
+ var pane = evtPane.call(this, evt_or_pane)\r
+ , $P = $Ps[pane]\r
+ , C = children\r
+ ;\r
+ if ($P) {\r
+ var $C = $Cs[pane]\r
+ , o = opts || options[pane].childOptions\r
+ , d = "layout"\r
+ // determine which element is supposed to be the 'child container'\r
+ // if pane has a 'containerSelector' OR a 'content-div', use those instead of the pane\r
+ , $Cont = o.containerSelector ? $P.find( o.containerSelector ) : ($C || $P)\r
+ , containerFound = $Cont.length\r
+ // see if a child-layout ALREADY exists on this element\r
+ , child = containerFound ? (C[pane] = $Cont.data(d) || null) : null\r
+ ;\r
+ // if no layout exists, but childOptions are set, try to create the layout now\r
+ if (!child && containerFound && o)\r
+ child = C[pane] = $Cont.eq(0).layout(o) || null;\r
+ if (child)\r
+ child.hasParentLayout = true; // set parent-flag in child\r
+ }\r
+ Instance[pane].child = C[pane]; // ALWAYS set pane-object pointer, even if null\r
+ }\r
+\r
+, windowResize = function () {\r
+ var delay = Number(options.resizeWithWindowDelay);\r
+ if (delay < 10) delay = 100; // MUST have a delay!\r
+ // resizing uses a delay-loop because the resize event fires repeatly - except in FF, but delay anyway\r
+ timer.clear("winResize"); // if already running\r
+ timer.set("winResize", function(){\r
+ timer.clear("winResize");\r
+ timer.clear("winResizeRepeater");\r
+ var dims = elDims( $N );\r
+ // only trigger resizeAll() if container has changed size\r
+ if (dims.innerWidth !== sC.innerWidth || dims.innerHeight !== sC.innerHeight)\r
+ resizeAll();\r
+ }, delay);\r
+ // ALSO set fixed-delay timer, if not already running\r
+ if (!timer.data["winResizeRepeater"]) setWindowResizeRepeater();\r
+ }\r
+\r
+, setWindowResizeRepeater = function () {\r
+ var delay = Number(options.resizeWithWindowMaxDelay);\r
+ if (delay > 0)\r
+ timer.set("winResizeRepeater", function(){ setWindowResizeRepeater(); resizeAll(); }, delay);\r
+ }\r
+\r
+, unload = function () {\r
+ var o = options;\r
+\r
+ _runCallbacks("onunload_start");\r
+\r
+ // trigger plugin callabacks for this layout (eg: stateManagement)\r
+ runPluginCallbacks( Instance, $.layout.onUnload );\r
+\r
+ _runCallbacks("onunload_end");\r
+ }\r
+\r
+ /**\r
+ * Validate and initialize container CSS and events\r
+ *\r
+ * @see _create()\r
+ */\r
+, _initContainer = function () {\r
+ var\r
+ N = $N[0]\r
+ , tag = sC.tagName = N.tagName\r
+ , id = sC.id = N.id\r
+ , cls = sC.className = N.className\r
+ , o = options\r
+ , name = o.name\r
+ , fullPage= (tag === "BODY")\r
+ , props = "overflow,position,margin,padding,border"\r
+ , css = "layoutCSS"\r
+ , CSS = {}\r
+ , hid = "hidden" // used A LOT!\r
+ // see if this container is a 'pane' inside an outer-layout\r
+ , parent = $N.data("parentLayout") // parent-layout Instance\r
+ , pane = $N.data("layoutEdge") // pane-name in parent-layout\r
+ , isChild = parent && pane\r
+ ;\r
+ // sC -> state.container\r
+ sC.selector = $N.selector.split(".slice")[0];\r
+ sC.ref = (o.name ? o.name +' layout / ' : '') + tag + (id ? "#"+id : cls ? '.['+cls+']' : ''); // used in messages\r
+\r
+ $N .data({\r
+ layout: Instance\r
+ , layoutContainer: sID // FLAG to indicate this is a layout-container - contains unique internal ID\r
+ })\r
+ .addClass(o.containerClass)\r
+ ;\r
+ var layoutMethods = {\r
+ destroy: ''\r
+ , initPanes: ''\r
+ , resizeAll: 'resizeAll'\r
+ , resize: 'resizeAll'\r
+ }\r
+ , name;\r
+ // loop hash and bind all methods - include layoutID namespacing\r
+ for (name in layoutMethods) {\r
+ $N.bind("layout"+ name.toLowerCase() +"."+ sID, Instance[ layoutMethods[name] || name ]);\r
+ }\r
+\r
+ // if this container is another layout's 'pane', then set child/parent pointers\r
+ if (isChild) {\r
+ // update parent flag\r
+ Instance.hasParentLayout = true;\r
+ // set pointers to THIS child-layout (Instance) in parent-layout\r
+ // NOTE: parent.PANE.child is an ALIAS to parent.children.PANE\r
+ parent[pane].child = parent.children[pane] = $N.data("layout");\r
+ }\r
+\r
+ // SAVE original container CSS for use in destroy()\r
+ if (!$N.data(css)) {\r
+ // handle props like overflow different for BODY & HTML - has 'system default' values\r
+ if (fullPage) {\r
+ CSS = $.extend( elCSS($N, props), {\r
+ height: $N.css("height")\r
+ , overflow: $N.css("overflow")\r
+ , overflowX: $N.css("overflowX")\r
+ , overflowY: $N.css("overflowY")\r
+ });\r
+ // ALSO SAVE <HTML> CSS\r
+ var $H = $("html");\r
+ $H.data(css, {\r
+ height: "auto" // FF would return a fixed px-size!\r
+ , overflow: $H.css("overflow")\r
+ , overflowX: $H.css("overflowX")\r
+ , overflowY: $H.css("overflowY")\r
+ });\r
+ }\r
+ else // handle props normally for non-body elements\r
+ CSS = elCSS($N, props+",top,bottom,left,right,width,height,overflow,overflowX,overflowY");\r
+\r
+ $N.data(css, CSS);\r
+ }\r
+\r
+ try { // format html/body if this is a full page layout\r
+ if (fullPage) {\r
+ $("html").css({\r
+ height: "100%"\r
+ , overflow: hid\r
+ , overflowX: hid\r
+ , overflowY: hid\r
+ });\r
+ $("body").css({\r
+ position: "relative"\r
+ , height: "100%"\r
+ , overflow: hid\r
+ , overflowX: hid\r
+ , overflowY: hid\r
+ , margin: 0\r
+ , padding: 0 // TODO: test whether body-padding could be handled?\r
+ , border: "none" // a body-border creates problems because it cannot be measured!\r
+ });\r
+\r
+ // set current layout-container dimensions\r
+ $.extend(sC, elDims( $N ));\r
+ }\r
+ else { // set required CSS for overflow and position\r
+ // ENSURE container will not 'scroll'\r
+ CSS = { overflow: hid, overflowX: hid, overflowY: hid }\r
+ var\r
+ p = $N.css("position")\r
+ , h = $N.css("height")\r
+ ;\r
+ // if this is a NESTED layout, then container/outer-pane ALREADY has position and height\r
+ if (!isChild) {\r
+ if (!p || !p.match(/fixed|absolute|relative/))\r
+ CSS.position = "relative"; // container MUST have a 'position'\r
+ /*\r
+ if (!h || h=="auto")\r
+ CSS.height = "100%"; // container MUST have a 'height'\r
+ */\r
+ }\r
+ $N.css( CSS );\r
+\r
+ // set current layout-container dimensions\r
+ if ( $N.is(":visible") ) {\r
+ $.extend(sC, elDims( $N ));\r
+ if (o.showErrorMessages && sC.innerHeight < 1)\r
+ _log( lang.errContainerHeight.replace(/CONTAINER/, sC.ref), true );\r
+ }\r
+ }\r
+ } catch (ex) {}\r
+ }\r
+\r
+ /**\r
+ * Bind layout hotkeys - if options enabled\r
+ *\r
+ * @see _create() and addPane()\r
+ * @param {string=} [panes=""] The edge(s) to process\r
+ */\r
+, initHotkeys = function (panes) {\r
+ panes = panes ? panes.split(",") : _c.borderPanes;\r
+ // bind keyDown to capture hotkeys, if option enabled for ANY pane\r
+ $.each(panes, function (i, pane) {\r
+ var o = options[pane];\r
+ if (o.enableCursorHotkey || o.customHotkey) {\r
+ $(document).bind("keydown."+ sID, keyDown); // only need to bind this ONCE\r
+ return false; // BREAK - binding was done\r
+ }\r
+ });\r
+ }\r
+\r
+ /**\r
+ * Build final OPTIONS data\r
+ *\r
+ * @see _create()\r
+ */\r
+, initOptions = function () {\r
+ var data, d, pane, key, val, i, c, o;\r
+\r
+ // reprocess user's layout-options to have correct options sub-key structure\r
+ opts = $.layout.transformData( opts ); // panes = default subkey\r
+\r
+ // auto-rename old options for backward compatibility\r
+ opts = $.layout.backwardCompatibility.renameAllOptions( opts );\r
+\r
+ // if user-options has 'panes' key (pane-defaults), process it...\r
+ if (!$.isEmptyObject(opts.panes)) {\r
+ // REMOVE any pane-defaults that MUST be set per-pane\r
+ data = $.layout.optionsMap.noDefault;\r
+ for (i=0, c=data.length; i<c; i++) {\r
+ key = data[i];\r
+ delete opts.panes[key]; // OK if does not exist\r
+ }\r
+ // REMOVE any layout-options specified under opts.panes\r
+ data = $.layout.optionsMap.layout;\r
+ for (i=0, c=data.length; i<c; i++) {\r
+ key = data[i];\r
+ delete opts.panes[key]; // OK if does not exist\r
+ }\r
+ }\r
+\r
+ // MOVE any NON-layout-options to opts.panes\r
+ data = $.layout.optionsMap.layout;\r
+ var rootKeys = $.layout.config.optionRootKeys;\r
+ for (key in opts) {\r
+ val = opts[key];\r
+ if ($.inArray(key, rootKeys) < 0 && $.inArray(key, data) < 0) {\r
+ if (!opts.panes[key])\r
+ opts.panes[key] = $.isPlainObject(val) ? $.extend(true, {}, val) : val;\r
+ delete opts[key]\r
+ }\r
+ }\r
+\r
+ // START by updating ALL options from opts\r
+ $.extend(true, options, opts);\r
+\r
+ // CREATE final options (and config) for EACH pane\r
+ $.each(_c.allPanes, function (i, pane) {\r
+\r
+ // apply 'pane-defaults' to CONFIG.[PANE]\r
+ _c[pane] = $.extend( true, {}, _c.panes, _c[pane] );\r
+\r
+ d = options.panes;\r
+ o = options[pane];\r
+\r
+ // center-pane uses SOME keys in defaults.panes branch\r
+ if (pane === 'center') {\r
+ // ONLY copy keys from opts.panes listed in: $.layout.optionsMap.center\r
+ data = $.layout.optionsMap.center; // list of 'center-pane keys'\r
+ for (i=0, c=data.length; i<c; i++) { // loop the list...\r
+ key = data[i];\r
+ // only need to use pane-default if pane-specific value not set\r
+ if (!opts.center[key] && (opts.panes[key] || !o[key]))\r
+ o[key] = d[key]; // pane-default\r
+ }\r
+ }\r
+ else {\r
+ // border-panes use ALL keys in defaults.panes branch\r
+ o = options[pane] = $.extend({}, d, o); // re-apply pane-specific opts AFTER pane-defaults\r
+ createFxOptions( pane );\r
+ // ensure all border-pane-specific base-classes exist\r
+ if (!o.resizerClass) o.resizerClass = "ui-layout-resizer";\r
+ if (!o.togglerClass) o.togglerClass = "ui-layout-toggler";\r
+ }\r
+ // ensure we have base pane-class (ALL panes)\r
+ if (!o.paneClass) o.paneClass = "ui-layout-pane";\r
+ });\r
+\r
+ // update options.zIndexes if a zIndex-option specified\r
+ var zo = opts.zIndex\r
+ , z = options.zIndexes;\r
+ if (zo > 0) {\r
+ z.pane_normal = zo;\r
+ z.content_mask = max(zo+1, z.content_mask); // MIN = +1\r
+ z.resizer_normal = max(zo+2, z.resizer_normal); // MIN = +2\r
+ }\r
+\r
+ function createFxOptions ( pane ) {\r
+ var o = options[pane]\r
+ , d = options.panes;\r
+ // ensure fxSettings key to avoid errors\r
+ if (!o.fxSettings) o.fxSettings = {};\r
+ if (!d.fxSettings) d.fxSettings = {};\r
+\r
+ $.each(["_open","_close","_size"], function (i,n) { \r
+ var\r
+ sName = "fxName"+ n\r
+ , sSpeed = "fxSpeed"+ n\r
+ , sSettings = "fxSettings"+ n\r
+ // recalculate fxName according to specificity rules\r
+ , fxName = o[sName] =\r
+ o[sName] // options.west.fxName_open\r
+ || d[sName] // options.panes.fxName_open\r
+ || o.fxName // options.west.fxName\r
+ || d.fxName // options.panes.fxName\r
+ || "none" // MEANS $.layout.defaults.panes.fxName == "" || false || null || 0\r
+ ;\r
+ // validate fxName to ensure is valid effect - MUST have effect-config data in options.effects\r
+ if (fxName === "none" || !$.effects || !$.effects[fxName] || !options.effects[fxName])\r
+ fxName = o[sName] = "none"; // effect not loaded OR unrecognized fxName\r
+\r
+ // set vars for effects subkeys to simplify logic\r
+ var fx = options.effects[fxName] || {} // effects.slide\r
+ , fx_all = fx.all || null // effects.slide.all\r
+ , fx_pane = fx[pane] || null // effects.slide.west\r
+ ;\r
+ // create fxSpeed[_open|_close|_size]\r
+ o[sSpeed] =\r
+ o[sSpeed] // options.west.fxSpeed_open\r
+ || d[sSpeed] // options.west.fxSpeed_open\r
+ || o.fxSpeed // options.west.fxSpeed\r
+ || d.fxSpeed // options.panes.fxSpeed\r
+ || null // DEFAULT - let fxSetting.duration control speed\r
+ ;\r
+ // create fxSettings[_open|_close|_size]\r
+ o[sSettings] = $.extend(\r
+ {}\r
+ , fx_all // effects.slide.all\r
+ , fx_pane // effects.slide.west\r
+ , d.fxSettings // options.panes.fxSettings\r
+ , o.fxSettings // options.west.fxSettings\r
+ , d[sSettings] // options.panes.fxSettings_open\r
+ , o[sSettings] // options.west.fxSettings_open\r
+ );\r
+ });\r
+\r
+ // DONE creating action-specific-settings for this pane,\r
+ // so DELETE generic options - are no longer meaningful\r
+ delete o.fxName;\r
+ delete o.fxSpeed;\r
+ delete o.fxSettings;\r
+ }\r
+\r
+ // DELETE 'panes' key now that we are done - values were copied to EACH pane\r
+ delete options.panes;\r
+ }\r
+\r
+ /**\r
+ * Initialize module objects, styling, size and position for all panes\r
+ *\r
+ * @see _initElements()\r
+ * @param {string} pane The pane to process\r
+ */\r
+, getPane = function (pane) {\r
+ var sel = options[pane].paneSelector\r
+ if (sel.substr(0,1)==="#") // ID selector\r
+ // NOTE: elements selected 'by ID' DO NOT have to be 'children'\r
+ return $N.find(sel).eq(0);\r
+ else { // class or other selector\r
+ var $P = $N.children(sel).eq(0);\r
+ // look for the pane nested inside a 'form' element\r
+ return $P.length ? $P : $N.children("form:first").children(sel).eq(0);\r
+ }\r
+ }\r
+\r
+, initPanes = function () {\r
+ // NOTE: do north & south FIRST so we can measure their height - do center LAST\r
+ $.each(_c.allPanes, function (idx, pane) {\r
+ addPane( pane, true );\r
+ });\r
+\r
+ // init the pane-handles NOW in case we have to hide or close the pane below\r
+ initHandles();\r
+\r
+ // now that all panes have been initialized and initially-sized,\r
+ // make sure there is really enough space available for each pane\r
+ $.each(_c.borderPanes, function (i, pane) {\r
+ if ($Ps[pane] && state[pane].isVisible) { // pane is OPEN\r
+ setSizeLimits(pane);\r
+ makePaneFit(pane); // pane may be Closed, Hidden or Resized by makePaneFit()\r
+ }\r
+ });\r
+ // size center-pane AGAIN in case we 'closed' a border-pane in loop above\r
+ sizeMidPanes("center");\r
+\r
+ // Chrome/Webkit sometimes fires callbacks BEFORE it completes resizing!\r
+ // Before RC30.3, there was a 10ms delay here, but that caused layout \r
+ // to load asynchrously, which is BAD, so try skipping delay for now\r
+\r
+ // process pane contents and callbacks, and init/resize child-layout if exists\r
+ $.each(_c.allPanes, function (i, pane) {\r
+ var o = options[pane];\r
+ if ($Ps[pane]) {\r
+ if (state[pane].isVisible) { // pane is OPEN\r
+ sizeContent(pane);\r
+ // trigger pane.onResize if triggerEventsOnLoad = true\r
+ if (o.triggerEventsOnLoad)\r
+ _runCallbacks("onresize_end", pane);\r
+ else // automatic if onresize called, otherwise call it specifically\r
+ // resize child - IF inner-layout already exists (created before this layout)\r
+ resizeChildLayout(pane);\r
+ }\r
+ // init childLayout - even if pane is not visible\r
+ if (o.initChildLayout && o.childOptions)\r
+ createChildLayout(pane);\r
+ }\r
+ });\r
+ }\r
+\r
+ /**\r
+ * Add a pane to the layout - subroutine of initPanes()\r
+ *\r
+ * @see initPanes()\r
+ * @param {string} pane The pane to process\r
+ * @param {boolean=} [force=false] Size content after init\r
+ */\r
+, addPane = function (pane, force) {\r
+ if (!force && !isInitialized()) return;\r
+ var\r
+ o = options[pane]\r
+ , s = state[pane]\r
+ , c = _c[pane]\r
+ , fx = s.fx\r
+ , dir = c.dir\r
+ , spacing = o.spacing_open || 0\r
+ , isCenter = (pane === "center")\r
+ , CSS = {}\r
+ , $P = $Ps[pane]\r
+ , size, minSize, maxSize\r
+ ;\r
+ // if pane-pointer already exists, remove the old one first\r
+ if ($P)\r
+ removePane( pane, false, true, false );\r
+ else\r
+ $Cs[pane] = false; // init\r
+\r
+ $P = $Ps[pane] = getPane(pane);\r
+ if (!$P.length) {\r
+ $Ps[pane] = false; // logic\r
+ return;\r
+ }\r
+\r
+ // SAVE original Pane CSS\r
+ if (!$P.data("layoutCSS")) {\r
+ var props = "position,top,left,bottom,right,width,height,overflow,zIndex,display,backgroundColor,padding,margin,border";\r
+ $P.data("layoutCSS", elCSS($P, props));\r
+ }\r
+\r
+ // create alias for pane data in Instance - initHandles will add more\r
+ Instance[pane] = { name: pane, pane: $Ps[pane], content: $Cs[pane], options: options[pane], state: state[pane], child: children[pane] };\r
+\r
+ // add classes, attributes & events\r
+ $P .data({\r
+ parentLayout: Instance // pointer to Layout Instance\r
+ , layoutPane: Instance[pane] // NEW pointer to pane-alias-object\r
+ , layoutEdge: pane\r
+ , layoutRole: "pane"\r
+ })\r
+ .css(c.cssReq).css("zIndex", options.zIndexes.pane_normal)\r
+ .css(o.applyDemoStyles ? c.cssDemo : {}) // demo styles\r
+ .addClass( o.paneClass +" "+ o.paneClass+"-"+pane ) // default = "ui-layout-pane ui-layout-pane-west" - may be a dupe of 'paneSelector'\r
+ .bind("mouseenter."+ sID, addHover )\r
+ .bind("mouseleave."+ sID, removeHover )\r
+ ;\r
+ var paneMethods = {\r
+ hide: ''\r
+ , show: ''\r
+ , toggle: ''\r
+ , close: ''\r
+ , open: ''\r
+ , slideOpen: ''\r
+ , slideClose: ''\r
+ , slideToggle: ''\r
+ , size: 'manualSizePane'\r
+ , sizePane: 'manualSizePane'\r
+ , sizeContent: ''\r
+ , sizeHandles: ''\r
+ , enableClosable: ''\r
+ , disableClosable: ''\r
+ , enableSlideable: ''\r
+ , disableSlideable: ''\r
+ , enableResizable: ''\r
+ , disableResizable: ''\r
+ , swapPanes: 'swapPanes'\r
+ , swap: 'swapPanes'\r
+ , move: 'swapPanes'\r
+ , removePane: 'removePane'\r
+ , remove: 'removePane'\r
+ , createChildLayout: ''\r
+ , resizeChildLayout: ''\r
+ , resizeAll: 'resizeAll'\r
+ , resizeLayout: 'resizeAll'\r
+ }\r
+ , name;\r
+ // loop hash and bind all methods - include layoutID namespacing\r
+ for (name in paneMethods) {\r
+ $P.bind("layoutpane"+ name.toLowerCase() +"."+ sID, Instance[ paneMethods[name] || name ]);\r
+ }\r
+\r
+ // see if this pane has a 'scrolling-content element'\r
+ initContent(pane, false); // false = do NOT sizeContent() - called later\r
+\r
+ if (!isCenter) {\r
+ // call _parseSize AFTER applying pane classes & styles - but before making visible (if hidden)\r
+ // if o.size is auto or not valid, then MEASURE the pane and use that as its 'size'\r
+ size = s.size = _parseSize(pane, o.size);\r
+ minSize = _parseSize(pane,o.minSize) || 1;\r
+ maxSize = _parseSize(pane,o.maxSize) || 100000;\r
+ if (size > 0) size = max(min(size, maxSize), minSize);\r
+\r
+ // state for border-panes\r
+ s.isClosed = false; // true = pane is closed\r
+ s.isSliding = false; // true = pane is currently open by 'sliding' over adjacent panes\r
+ s.isResizing= false; // true = pane is in process of being resized\r
+ s.isHidden = false; // true = pane is hidden - no spacing, resizer or toggler is visible!\r
+\r
+ // array for 'pin buttons' whose classNames are auto-updated on pane-open/-close\r
+ if (!s.pins) s.pins = [];\r
+ }\r
+ // states common to ALL panes\r
+ s.tagName = $P[0].tagName;\r
+ s.edge = pane; // useful if pane is (or about to be) 'swapped' - easy find out where it is (or is going)\r
+ s.noRoom = false; // true = pane 'automatically' hidden due to insufficient room - will unhide automatically\r
+ s.isVisible = true; // false = pane is invisible - closed OR hidden - simplify logic\r
+\r
+ // set css-position to account for container borders & padding\r
+ switch (pane) {\r
+ case "north": CSS.top = sC.insetTop;\r
+ CSS.left = sC.insetLeft;\r
+ CSS.right = sC.insetRight;\r
+ break;\r
+ case "south": CSS.bottom = sC.insetBottom;\r
+ CSS.left = sC.insetLeft;\r
+ CSS.right = sC.insetRight;\r
+ break;\r
+ case "west": CSS.left = sC.insetLeft; // top, bottom & height set by sizeMidPanes()\r
+ break;\r
+ case "east": CSS.right = sC.insetRight; // ditto\r
+ break;\r
+ case "center": // top, left, width & height set by sizeMidPanes()\r
+ }\r
+\r
+ if (dir === "horz") // north or south pane\r
+ CSS.height = cssH($P, size);\r
+ else if (dir === "vert") // east or west pane\r
+ CSS.width = cssW($P, size);\r
+ //else if (isCenter) {}\r
+\r
+ $P.css(CSS); // apply size -- top, bottom & height will be set by sizeMidPanes\r
+ if (dir != "horz") sizeMidPanes(pane, true); // true = skipCallback\r
+\r
+ // close or hide the pane if specified in settings\r
+ if (o.initClosed && o.closable && !o.initHidden)\r
+ close(pane, true, true); // true, true = force, noAnimation\r
+ else if (o.initHidden || o.initClosed)\r
+ hide(pane); // will be completely invisible - no resizer or spacing\r
+ else if (!s.noRoom)\r
+ // make the pane visible - in case was initially hidden\r
+ $P.css("display","block");\r
+ // ELSE setAsOpen() - called later by initHandles()\r
+\r
+ // RESET visibility now - pane will appear IF display:block\r
+ $P.css("visibility","visible");\r
+\r
+ // check option for auto-handling of pop-ups & drop-downs\r
+ if (o.showOverflowOnHover)\r
+ $P.hover( allowOverflow, resetOverflow );\r
+\r
+ // if manually adding a pane AFTER layout initialization, then...\r
+ if (state.initialized) {\r
+ initHandles( pane );\r
+ initHotkeys( pane );\r
+ resizeAll(); // will sizeContent if pane is visible\r
+ if (s.isVisible) { // pane is OPEN\r
+ if (o.triggerEventsOnLoad)\r
+ _runCallbacks("onresize_end", pane);\r
+ else // automatic if onresize called, otherwise call it specifically\r
+ // resize child - IF inner-layout already exists (created before this layout)\r
+ resizeChildLayout(pane); // a previously existing childLayout\r
+ }\r
+ if (o.initChildLayout && o.childOptions)\r
+ createChildLayout(pane);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Initialize module objects, styling, size and position for all resize bars and toggler buttons\r
+ *\r
+ * @see _create()\r
+ * @param {string=} [panes=""] The edge(s) to process\r
+ */\r
+, initHandles = function (panes) {\r
+ panes = panes ? panes.split(",") : _c.borderPanes;\r
+\r
+ // create toggler DIVs for each pane, and set object pointers for them, eg: $R.north = north toggler DIV\r
+ $.each(panes, function (i, pane) {\r
+ var $P = $Ps[pane];\r
+ $Rs[pane] = false; // INIT\r
+ $Ts[pane] = false;\r
+ if (!$P) return; // pane does not exist - skip\r
+\r
+ var \r
+ o = options[pane]\r
+ , s = state[pane]\r
+ , c = _c[pane]\r
+ , rClass = o.resizerClass\r
+ , tClass = o.togglerClass\r
+ , side = c.side.toLowerCase()\r
+ , spacing = (s.isVisible ? o.spacing_open : o.spacing_closed)\r
+ , _pane = "-"+ pane // used for classNames\r
+ , _state = (s.isVisible ? "-open" : "-closed") // used for classNames\r
+ , I = Instance[pane]\r
+ // INIT RESIZER BAR\r
+ , $R = I.resizer = $Rs[pane] = $("<div></div>")\r
+ // INIT TOGGLER BUTTON\r
+ , $T = I.toggler = (o.closable ? $Ts[pane] = $("<div></div>") : false)\r
+ ;\r
+\r
+ //if (s.isVisible && o.resizable) ... handled by initResizable\r
+ if (!s.isVisible && o.slidable)\r
+ $R.attr("title", o.sliderTip).css("cursor", o.sliderCursor);\r
+\r
+ $R // if paneSelector is an ID, then create a matching ID for the resizer, eg: "#paneLeft" => "paneLeft-resizer"\r
+ .attr("id", (o.paneSelector.substr(0,1)=="#" ? o.paneSelector.substr(1) + "-resizer" : ""))\r
+ .data({\r
+ parentLayout: Instance\r
+ , layoutPane: Instance[pane] // NEW pointer to pane-alias-object\r
+ , layoutEdge: pane\r
+ , layoutRole: "resizer"\r
+ })\r
+ .css(_c.resizers.cssReq).css("zIndex", options.zIndexes.resizer_normal)\r
+ .css(o.applyDemoStyles ? _c.resizers.cssDemo : {}) // add demo styles\r
+ .addClass(rClass +" "+ rClass+_pane)\r
+ .hover(addHover, removeHover) // ALWAYS add hover-classes, even if resizing is not enabled - handle with CSS instead\r
+ .hover(onResizerEnter, onResizerLeave) // ALWAYS NEED resizer.mouseleave to balance toggler.mouseenter\r
+ .appendTo($N) // append DIV to container\r
+ ;\r
+\r
+ if ($T) {\r
+ $T // if paneSelector is an ID, then create a matching ID for the resizer, eg: "#paneLeft" => "#paneLeft-toggler"\r
+ .attr("id", (o.paneSelector.substr(0,1)=="#" ? o.paneSelector.substr(1) + "-toggler" : ""))\r
+ .data({\r
+ parentLayout: Instance\r
+ , layoutPane: Instance[pane] // NEW pointer to pane-alias-object\r
+ , layoutEdge: pane\r
+ , layoutRole: "toggler"\r
+ })\r
+ .css(_c.togglers.cssReq) // add base/required styles\r
+ .css(o.applyDemoStyles ? _c.togglers.cssDemo : {}) // add demo styles\r
+ .addClass(tClass +" "+ tClass+_pane)\r
+ .hover(addHover, removeHover) // ALWAYS add hover-classes, even if toggling is not enabled - handle with CSS instead\r
+ .bind("mouseenter", onResizerEnter) // NEED toggler.mouseenter because mouseenter MAY NOT fire on resizer\r
+ .appendTo($R) // append SPAN to resizer DIV\r
+ ;\r
+ // ADD INNER-SPANS TO TOGGLER\r
+ if (o.togglerContent_open) // ui-layout-open\r
+ $("<span>"+ o.togglerContent_open +"</span>")\r
+ .data({\r
+ layoutEdge: pane\r
+ , layoutRole: "togglerContent"\r
+ })\r
+ .data("layoutRole", "togglerContent")\r
+ .data("layoutEdge", pane)\r
+ .addClass("content content-open")\r
+ .css("display","none")\r
+ .appendTo( $T )\r
+ //.hover( addHover, removeHover ) // use ui-layout-toggler-west-hover .content-open instead!\r
+ ;\r
+ if (o.togglerContent_closed) // ui-layout-closed\r
+ $("<span>"+ o.togglerContent_closed +"</span>")\r
+ .data({\r
+ layoutEdge: pane\r
+ , layoutRole: "togglerContent"\r
+ })\r
+ .addClass("content content-closed")\r
+ .css("display","none")\r
+ .appendTo( $T )\r
+ //.hover( addHover, removeHover ) // use ui-layout-toggler-west-hover .content-closed instead!\r
+ ;\r
+ // ADD TOGGLER.click/.hover\r
+ enableClosable(pane);\r
+ }\r
+\r
+ // add Draggable events\r
+ initResizable(pane);\r
+\r
+ // ADD CLASSNAMES & SLIDE-BINDINGS - eg: class="resizer resizer-west resizer-open"\r
+ if (s.isVisible)\r
+ setAsOpen(pane); // onOpen will be called, but NOT onResize\r
+ else {\r
+ setAsClosed(pane); // onClose will be called\r
+ bindStartSlidingEvent(pane, true); // will enable events IF option is set\r
+ }\r
+\r
+ });\r
+\r
+ // SET ALL HANDLE DIMENSIONS\r
+ sizeHandles();\r
+ }\r
+\r
+\r
+ /**\r
+ * Initialize scrolling ui-layout-content div - if exists\r
+ *\r
+ * @see initPane() - or externally after an Ajax injection\r
+ * @param {string} [pane] The pane to process\r
+ * @param {boolean=} [resize=true] Size content after init\r
+ */\r
+, initContent = function (pane, resize) {\r
+ if (!isInitialized()) return;\r
+ var \r
+ o = options[pane]\r
+ , sel = o.contentSelector\r
+ , I = Instance[pane]\r
+ , $P = $Ps[pane]\r
+ , $C\r
+ ;\r
+ if (sel) $C = I.content = $Cs[pane] = (o.findNestedContent)\r
+ ? $P.find(sel).eq(0) // match 1-element only\r
+ : $P.children(sel).eq(0)\r
+ ;\r
+ if ($C && $C.length) {\r
+ $C.data("layoutRole", "content");\r
+ // SAVE original Pane CSS\r
+ if (!$C.data("layoutCSS"))\r
+ $C.data("layoutCSS", elCSS($C, "height"));\r
+ $C.css( _c.content.cssReq );\r
+ if (o.applyDemoStyles) {\r
+ $C.css( _c.content.cssDemo ); // add padding & overflow: auto to content-div\r
+ $P.css( _c.content.cssDemoPane ); // REMOVE padding/scrolling from pane\r
+ }\r
+ state[pane].content = {}; // init content state\r
+ if (resize !== false) sizeContent(pane);\r
+ // sizeContent() is called AFTER init of all elements\r
+ }\r
+ else\r
+ I.content = $Cs[pane] = false;\r
+ }\r
+\r
+\r
+ /**\r
+ * Add resize-bars to all panes that specify it in options\r
+ * -dependancy: $.fn.resizable - will skip if not found\r
+ *\r
+ * @see _create()\r
+ * @param {string=} [panes=""] The edge(s) to process\r
+ */\r
+, initResizable = function (panes) {\r
+ var draggingAvailable = $.layout.plugins.draggable\r
+ , side // set in start()\r
+ ;\r
+ panes = panes ? panes.split(",") : _c.borderPanes;\r
+\r
+ $.each(panes, function (idx, pane) {\r
+ var o = options[pane];\r
+ if (!draggingAvailable || !$Ps[pane] || !o.resizable) {\r
+ o.resizable = false;\r
+ return true; // skip to next\r
+ }\r
+\r
+ var s = state[pane]\r
+ , z = options.zIndexes\r
+ , c = _c[pane]\r
+ , side = c.dir=="horz" ? "top" : "left"\r
+ , opEdge = _c.oppositeEdge[pane]\r
+ , masks = pane +",center,"+ opEdge + (c.dir=="horz" ? ",west,east" : "")\r
+ , $P = $Ps[pane]\r
+ , $R = $Rs[pane]\r
+ , base = o.resizerClass\r
+ , lastPos = 0 // used when live-resizing\r
+ , r, live // set in start because may change\r
+ // 'drag' classes are applied to the ORIGINAL resizer-bar while dragging is in process\r
+ , resizerClass = base+"-drag" // resizer-drag\r
+ , resizerPaneClass = base+"-"+pane+"-drag" // resizer-north-drag\r
+ // 'helper' class is applied to the CLONED resizer-bar while it is being dragged\r
+ , helperClass = base+"-dragging" // resizer-dragging\r
+ , helperPaneClass = base+"-"+pane+"-dragging" // resizer-north-dragging\r
+ , helperLimitClass = base+"-dragging-limit" // resizer-drag\r
+ , helperPaneLimitClass = base+"-"+pane+"-dragging-limit" // resizer-north-drag\r
+ , helperClassesSet = false // logic var\r
+ ;\r
+\r
+ if (!s.isClosed)\r
+ $R.attr("title", o.resizerTip)\r
+ .css("cursor", o.resizerCursor); // n-resize, s-resize, etc\r
+\r
+ $R.draggable({\r
+ containment: $N[0] // limit resizing to layout container\r
+ , axis: (c.dir=="horz" ? "y" : "x") // limit resizing to horz or vert axis\r
+ , delay: 0\r
+ , distance: 1\r
+ , grid: o.resizingGrid\r
+ // basic format for helper - style it using class: .ui-draggable-dragging\r
+ , helper: "clone"\r
+ , opacity: o.resizerDragOpacity\r
+ , addClasses: false // avoid ui-state-disabled class when disabled\r
+ //, iframeFix: o.draggableIframeFix // TODO: consider using when bug is fixed\r
+ , zIndex: z.resizer_drag\r
+\r
+ , start: function (e, ui) {\r
+ // REFRESH options & state pointers in case we used swapPanes\r
+ o = options[pane];\r
+ s = state[pane];\r
+ // re-read options\r
+ live = o.livePaneResizing;\r
+\r
+ // ondrag_start callback - will CANCEL hide if returns false\r
+ // TODO: dragging CANNOT be cancelled like this, so see if there is a way?\r
+ if (false === _runCallbacks("ondrag_start", pane)) return false;\r
+\r
+ s.isResizing = true; // prevent pane from closing while resizing\r
+ timer.clear(pane+"_closeSlider"); // just in case already triggered\r
+\r
+ // SET RESIZER LIMITS - used in drag()\r
+ setSizeLimits(pane); // update pane/resizer state\r
+ r = s.resizerPosition;\r
+ lastPos = ui.position[ side ]\r
+\r
+ $R.addClass( resizerClass +" "+ resizerPaneClass ); // add drag classes\r
+ helperClassesSet = false; // reset logic var - see drag()\r
+\r
+ // DISABLE TEXT SELECTION (probably already done by resizer.mouseOver)\r
+ $('body').disableSelection(); \r
+\r
+ // MASK PANES CONTAINING IFRAMES, APPLETS OR OTHER TROUBLESOME ELEMENTS\r
+ showMasks( masks );\r
+ }\r
+\r
+ , drag: function (e, ui) {\r
+ if (!helperClassesSet) { // can only add classes after clone has been added to the DOM\r
+ //$(".ui-draggable-dragging")\r
+ ui.helper\r
+ .addClass( helperClass +" "+ helperPaneClass ) // add helper classes\r
+ .css({ right: "auto", bottom: "auto" }) // fix dir="rtl" issue\r
+ .children().css("visibility","hidden") // hide toggler inside dragged resizer-bar\r
+ ;\r
+ helperClassesSet = true;\r
+ // draggable bug!? RE-SET zIndex to prevent E/W resize-bar showing through N/S pane!\r
+ if (s.isSliding) $Ps[pane].css("zIndex", z.pane_sliding);\r
+ }\r
+ // CONTAIN RESIZER-BAR TO RESIZING LIMITS\r
+ var limit = 0;\r
+ if (ui.position[side] < r.min) {\r
+ ui.position[side] = r.min;\r
+ limit = -1;\r
+ }\r
+ else if (ui.position[side] > r.max) {\r
+ ui.position[side] = r.max;\r
+ limit = 1;\r
+ }\r
+ // ADD/REMOVE dragging-limit CLASS\r
+ if (limit) {\r
+ ui.helper.addClass( helperLimitClass +" "+ helperPaneLimitClass ); // at dragging-limit\r
+ window.defaultStatus = (limit>0 && pane.match(/north|west/)) || (limit<0 && pane.match(/south|east/)) ? lang.maxSizeWarning : lang.minSizeWarning;\r
+ }\r
+ else {\r
+ ui.helper.removeClass( helperLimitClass +" "+ helperPaneLimitClass ); // not at dragging-limit\r
+ window.defaultStatus = "";\r
+ }\r
+ // DYNAMICALLY RESIZE PANES IF OPTION ENABLED\r
+ // won't trigger unless resizer has actually moved!\r
+ if (live && Math.abs(ui.position[side] - lastPos) >= o.liveResizingTolerance) {\r
+ lastPos = ui.position[side];\r
+ resizePanes(e, ui, pane)\r
+ }\r
+ }\r
+\r
+ , stop: function (e, ui) {\r
+ $('body').enableSelection(); // RE-ENABLE TEXT SELECTION\r
+ window.defaultStatus = ""; // clear 'resizing limit' message from statusbar\r
+ $R.removeClass( resizerClass +" "+ resizerPaneClass ); // remove drag classes from Resizer\r
+ s.isResizing = false;\r
+ resizePanes(e, ui, pane, true, masks); // true = resizingDone\r
+ }\r
+\r
+ });\r
+ });\r
+\r
+ /**\r
+ * resizePanes\r
+ *\r
+ * Sub-routine called from stop() - and drag() if livePaneResizing\r
+ *\r
+ * @param {!Object} evt\r
+ * @param {!Object} ui\r
+ * @param {string} pane\r
+ * @param {boolean=} [resizingDone=false]\r
+ */\r
+ var resizePanes = function (evt, ui, pane, resizingDone, masks) {\r
+ var dragPos = ui.position\r
+ , c = _c[pane]\r
+ , o = options[pane]\r
+ , s = state[pane]\r
+ , resizerPos\r
+ ;\r
+ switch (pane) {\r
+ case "north": resizerPos = dragPos.top; break;\r
+ case "west": resizerPos = dragPos.left; break;\r
+ case "south": resizerPos = sC.offsetHeight - dragPos.top - o.spacing_open; break;\r
+ case "east": resizerPos = sC.offsetWidth - dragPos.left - o.spacing_open; break;\r
+ };\r
+ // remove container margin from resizer position to get the pane size\r
+ var newSize = resizerPos - sC["inset"+ c.side];\r
+\r
+ // Disable OR Resize Mask(s) created in drag.start\r
+ if (!resizingDone) {\r
+ // ensure we meet liveResizingTolerance criteria\r
+ if (Math.abs(newSize - s.size) < o.liveResizingTolerance)\r
+ return; // SKIP resize this time\r
+ // resize the pane\r
+ manualSizePane(pane, newSize, false, true); // true = noAnimation\r
+ sizeMasks(); // resize all visible masks\r
+ }\r
+ else { // resizingDone\r
+ // ondrag_end callback\r
+ if (false !== _runCallbacks("ondrag_end", pane))\r
+ manualSizePane(pane, newSize, false, true); // true = noAnimation\r
+ hideMasks(); // hide all masks, which include panes with 'content/iframe-masks'\r
+ if (s.isSliding && masks) // RE-SHOW only 'object-masks' so objects won't show through sliding pane\r
+ showMasks( masks, true ); // true = onlyForObjects\r
+ }\r
+ };\r
+ }\r
+\r
+ /**\r
+ * sizeMask\r
+ *\r
+ * Needed to overlay a DIV over an IFRAME-pane because mask CANNOT be *inside* the pane\r
+ * Called when mask created, and during livePaneResizing\r
+ */\r
+, sizeMask = function () {\r
+ var $M = $(this)\r
+ , pane = $M.data("layoutMask") // eg: "west"\r
+ , s = state[pane]\r
+ ;\r
+ // only masks over an IFRAME-pane need manual resizing\r
+ if (s.tagName == "IFRAME" && s.isVisible) // no need to mask closed/hidden panes\r
+ $M.css({\r
+ top: s.offsetTop\r
+ , left: s.offsetLeft\r
+ , width: s.outerWidth\r
+ , height: s.outerHeight\r
+ });\r
+ /* ALT Method...\r
+ var $P = $Ps[pane];\r
+ $M.css( $P.position() ).css({ width: $P[0].offsetWidth, height: $P[0].offsetHeight });\r
+ */\r
+ }\r
+, sizeMasks = function () {\r
+ $Ms.each( sizeMask ); // resize all 'visible' masks\r
+ }\r
+\r
+, showMasks = function (panes, onlyForObjects) {\r
+ var a = panes ? panes.split(",") : $.layout.config.allPanes\r
+ , z = options.zIndexes\r
+ , o, s;\r
+ $.each(a, function(i,p){\r
+ s = state[p];\r
+ o = options[p];\r
+ if (s.isVisible && ( (!onlyForObjects && o.maskContents) || o.maskObjects )) {\r
+ getMasks(p).each(function(){\r
+ sizeMask.call(this);\r
+ this.style.zIndex = s.isSliding ? z.pane_sliding+1 : z.pane_normal+1\r
+ this.style.display = "block";\r
+ });\r
+ }\r
+ });\r
+ }\r
+\r
+, hideMasks = function () {\r
+ // ensure no pane is resizing - could be a timing issue\r
+ var skip;\r
+ $.each( $.layout.config.borderPanes, function(i,p){\r
+ if (state[p].isResizing) {\r
+ skip = true;\r
+ return false; // BREAK\r
+ }\r
+ });\r
+ if (!skip)\r
+ $Ms.hide(); // hide ALL masks\r
+ }\r
+\r
+, getMasks = function (pane) {\r
+ var $Masks = $([])\r
+ , $M, i = 0, c = $Ms.length\r
+ ;\r
+ for (; i<c; i++) {\r
+ $M = $Ms.eq(i);\r
+ if ($M.data("layoutMask") === pane)\r
+ $Masks = $Masks.add( $M );\r
+ }\r
+ if ($Masks.length)\r
+ return $Masks;\r
+ else\r
+ return createMasks(pane);\r
+ }\r
+\r
+ /**\r
+ * createMasks\r
+ *\r
+ * Generates both DIV (ALWAYS used) and IFRAME (optional) elements as masks\r
+ * An IFRAME mask is created *under* the DIV when maskObjects=true, because a DIV cannot mask an applet\r
+ */\r
+, createMasks = function (pane) {\r
+ var\r
+ $P = $Ps[pane]\r
+ , s = state[pane]\r
+ , o = options[pane]\r
+ , z = options.zIndexes\r
+ //, objMask = o.maskObjects && s.tagName != "IFRAME" // check for option\r
+ , $Masks = $([])\r
+ , isIframe, el, $M, css, i\r
+ ;\r
+ if (!o.maskContents && !o.maskObjects) return $Masks;\r
+ // if o.maskObjects=true, then loop TWICE to create BOTH kinds of mask, else only create a DIV\r
+ for (i=0; i < (o.maskObjects ? 2 : 1); i++) {\r
+ isIframe = o.maskObjects && i==0;\r
+ el = document.createElement( isIframe ? "iframe" : "div" );\r
+ $M = $(el).data("layoutMask", pane); // add data to relate mask to pane\r
+ el.className = "ui-layout-mask ui-layout-mask-"+ pane; // for user styling\r
+ css = el.style;\r
+ // styles common to both DIVs and IFRAMES\r
+ css.display = "block";\r
+ css.position = "absolute";\r
+ if (isIframe) { // IFRAME-only props\r
+ el.frameborder = 0;\r
+ el.src = "about:blank";\r
+ css.opacity = 0;\r
+ css.filter = "Alpha(Opacity='0')";\r
+ css.border = 0;\r
+ }\r
+ // if pane is an IFRAME, then must mask the pane itself\r
+ if (s.tagName == "IFRAME") {\r
+ // NOTE sizing done by a subroutine so can be called during live-resizing\r
+ css.zIndex = z.pane_normal+1; // 1-higher than pane\r
+ $N.append( el ); // append to LAYOUT CONTAINER\r
+ }\r
+ // otherwise put masks *inside the pane* to mask its contents\r
+ else {\r
+ $M.addClass("ui-layout-mask-inside-pane");\r
+ css.zIndex = o.maskZindex || z.content_mask; // usually 1, but customizable\r
+ css.top = 0;\r
+ css.left = 0;\r
+ css.width = "100%";\r
+ css.height = "100%";\r
+ $P.append( el ); // append INSIDE pane element\r
+ }\r
+ // add to return object\r
+ $Masks = $Masks.add( el );\r
+ // add Mask to cached array so can be resized & reused\r
+ $Ms = $Ms.add( el );\r
+ }\r
+ return $Masks;\r
+ }\r
+\r
+\r
+ /**\r
+ * Destroy this layout and reset all elements\r
+ *\r
+ * @param {boolean=} [destroyChildren=false] Destory Child-Layouts first?\r
+ */\r
+, destroy = function (destroyChildren) {\r
+ // UNBIND layout events and remove global object\r
+ $(window).unbind("."+ sID); // resize & unload\r
+ $(document).unbind("."+ sID); // keyDown (hotkeys)\r
+\r
+ // need to look for parent layout BEFORE we remove the container data, else skips a level\r
+ //var parentPane = Instance.hasParentLayout ? $.layout.getParentPaneInstance( $N ) : null;\r
+\r
+ // reset layout-container\r
+ $N .clearQueue()\r
+ .removeData("layout")\r
+ .removeData("layoutContainer")\r
+ .removeClass(options.containerClass)\r
+ .unbind("."+ sID) // remove ALL Layout events\r
+ ;\r
+\r
+ // remove all mask elements that have been created\r
+ $Ms.remove();\r
+\r
+ // loop all panes to remove layout classes, attributes and bindings\r
+ $.each(_c.allPanes, function (i, pane) {\r
+ removePane( pane, false, true, destroyChildren ); // true = skipResize\r
+ });\r
+\r
+ // do NOT reset container CSS if is a 'pane' (or 'content') in an outer-layout - ie, THIS layout is 'nested'\r
+ var css = "layoutCSS";\r
+ if ($N.data(css) && !$N.data("layoutRole")) // RESET CSS\r
+ $N.css( $N.data(css) ).removeData(css);\r
+\r
+ // for full-page layouts, also reset the <HTML> CSS\r
+ if (sC.tagName === "BODY" && ($N = $("html")).data(css)) // RESET <HTML> CSS\r
+ $N.css( $N.data(css) ).removeData(css);\r
+\r
+ // trigger plugins for this layout, if there are any\r
+ runPluginCallbacks( Instance, $.layout.onDestroy );\r
+\r
+ // trigger state-management and onunload callback\r
+ unload();\r
+\r
+ // clear the Instance of everything except for container & options (so could recreate)\r
+ // RE-CREATE: myLayout = myLayout.container.layout( myLayout.options );\r
+ for (n in Instance)\r
+ if (!n.match(/^(container|options)$/)) delete Instance[ n ];\r
+ // add a 'destroyed' flag to make it easy to check\r
+ Instance.destroyed = true;\r
+\r
+ // if this is a child layout, CLEAR the child-pointer in the parent\r
+ /* for now the pointer REMAINS, but with only container, options and destroyed keys\r
+ if (parentPane) {\r
+ var layout = parentPane.pane.data("parentLayout");\r
+ parentPane.child = layout.children[ parentPane.name ] = null;\r
+ }\r
+ */\r
+\r
+ return Instance; // for coding convenience\r
+ }\r
+\r
+ /**\r
+ * Remove a pane from the layout - subroutine of destroy()\r
+ *\r
+ * @see destroy()\r
+ * @param {string} pane The pane to process\r
+ * @param {boolean=} [remove=false] Remove the DOM element?\r
+ * @param {boolean=} [skipResize=false] Skip calling resizeAll()?\r
+ */\r
+, removePane = function (evt_or_pane, remove, skipResize, destroyChild) {\r
+ if (!isInitialized()) return;\r
+ var pane = evtPane.call(this, evt_or_pane)\r
+ , $P = $Ps[pane]\r
+ , $C = $Cs[pane]\r
+ , $R = $Rs[pane]\r
+ , $T = $Ts[pane]\r
+ ;\r
+ //alert( '$P.length = '+ $P.length );\r
+ // NOTE: elements can still exist even after remove()\r
+ // so check for missing data(), which is cleared by removed()\r
+ if ($P && $.isEmptyObject( $P.data() )) $P = false;\r
+ if ($C && $.isEmptyObject( $C.data() )) $C = false;\r
+ if ($R && $.isEmptyObject( $R.data() )) $R = false;\r
+ if ($T && $.isEmptyObject( $T.data() )) $T = false;\r
+\r
+ if ($P) $P.stop(true, true);\r
+\r
+ // check for a child layout\r
+ var o = options[pane]\r
+ , s = state[pane]\r
+ , d = "layout"\r
+ , css = "layoutCSS"\r
+ , child = children[pane] || ($P ? $P.data(d) : 0) || ($C ? $C.data(d) : 0) || null\r
+ , destroy = destroyChild !== undefined ? destroyChild : o.destroyChildLayout\r
+ ;\r
+\r
+ // FIRST destroy the child-layout(s)\r
+ if (destroy && child && !child.destroyed) {\r
+ child.destroy(true); // tell child-layout to destroy ALL its child-layouts too\r
+ if (child.destroyed) // destroy was successful\r
+ child = null; // clear pointer for logic below \r
+ }\r
+\r
+ if ($P && remove && !child)\r
+ $P.remove();\r
+ else if ($P && $P[0]) {\r
+ // create list of ALL pane-classes that need to be removed\r
+ var root = o.paneClass // default="ui-layout-pane"\r
+ , pRoot = root +"-"+ pane // eg: "ui-layout-pane-west"\r
+ , _open = "-open"\r
+ , _sliding= "-sliding"\r
+ , _closed = "-closed"\r
+ , classes = [ root, root+_open, root+_closed, root+_sliding, // generic classes\r
+ pRoot, pRoot+_open, pRoot+_closed, pRoot+_sliding ] // pane-specific classes\r
+ ;\r
+ $.merge(classes, getHoverClasses($P, true)); // ADD hover-classes\r
+ // remove all Layout classes from pane-element\r
+ $P .removeClass( classes.join(" ") ) // remove ALL pane-classes\r
+ .removeData("parentLayout")\r
+ .removeData("layoutPane")\r
+ .removeData("layoutRole")\r
+ .removeData("layoutEdge")\r
+ .removeData("autoHidden") // in case set\r
+ .unbind("."+ sID) // remove ALL Layout events\r
+ // TODO: remove these extra unbind commands when jQuery is fixed\r
+ //.unbind("mouseenter"+ sID)\r
+ //.unbind("mouseleave"+ sID)\r
+ ;\r
+ // do NOT reset CSS if this pane/content is STILL the container of a nested layout!\r
+ // the nested layout will reset its 'container' CSS when/if it is destroyed\r
+ if ($C && $C.data(d)) {\r
+ // a content-div may not have a specific width, so give it one to contain the Layout\r
+ $C.width( $C.width() );\r
+ child.resizeAll(); // now resize the Layout\r
+ }\r
+ else if ($C)\r
+ $C.css( $C.data(css) ).removeData(css).removeData("layoutRole");\r
+ // remove pane AFTER content in case there was a nested layout\r
+ if (!$P.data(d))\r
+ $P.css( $P.data(css) ).removeData(css);\r
+ }\r
+\r
+ // REMOVE pane resizer and toggler elements\r
+ if ($T) $T.remove();\r
+ if ($R) $R.remove();\r
+\r
+ // CLEAR all pointers and state data\r
+ Instance[pane] = $Ps[pane] = $Cs[pane] = $Rs[pane] = $Ts[pane] = children[pane] = false;\r
+ s = { removed: true };\r
+\r
+ if (!skipResize)\r
+ resizeAll();\r
+ }\r
+\r
+\r
+/*\r
+ * ###########################\r
+ * ACTION METHODS\r
+ * ###########################\r
+ */\r
+\r
+, _hidePane = function (pane) {\r
+ var $P = $Ps[pane]\r
+ , o = options[pane]\r
+ , s = $P[0].style\r
+ ;\r
+ if (o.useOffscreenClose) {\r
+ if (!$P.data(_c.offscreenReset))\r
+ $P.data(_c.offscreenReset, { left: s.left, right: s.right });\r
+ $P.css( _c.offscreenCSS );\r
+ }\r
+ else\r
+ $P.hide().removeData(_c.offscreenReset);\r
+ }\r
+\r
+, _showPane = function (pane) {\r
+ var $P = $Ps[pane]\r
+ , o = options[pane]\r
+ , off = _c.offscreenCSS\r
+ , old = $P.data(_c.offscreenReset)\r
+ , s = $P[0].style\r
+ ;\r
+ $P .show() // ALWAYS show, just in case\r
+ .removeData(_c.offscreenReset);\r
+ if (o.useOffscreenClose && old) {\r
+ if (s.left == off.left)\r
+ s.left = old.left;\r
+ if (s.right == off.right)\r
+ s.right = old.right;\r
+ }\r
+ }\r
+\r
+\r
+ /**\r
+ * Completely 'hides' a pane, including its spacing - as if it does not exist\r
+ * The pane is not actually 'removed' from the source, so can use 'show' to un-hide it\r
+ *\r
+ * @param {string} pane The pane being hidden, ie: north, south, east, or west\r
+ * @param {boolean=} [noAnimation=false] \r
+ */\r
+, hide = function (evt_or_pane, noAnimation) {\r
+ if (!isInitialized()) return;\r
+ var pane = evtPane.call(this, evt_or_pane)\r
+ , o = options[pane]\r
+ , s = state[pane]\r
+ , $P = $Ps[pane]\r
+ , $R = $Rs[pane]\r
+ ;\r
+ if (!$P || s.isHidden) return; // pane does not exist OR is already hidden\r
+\r
+ // onhide_start callback - will CANCEL hide if returns false\r
+ if (state.initialized && false === _runCallbacks("onhide_start", pane)) return;\r
+\r
+ s.isSliding = false; // just in case\r
+\r
+ // now hide the elements\r
+ if ($R) $R.hide(); // hide resizer-bar\r
+ if (!state.initialized || s.isClosed) {\r
+ s.isClosed = true; // to trigger open-animation on show()\r
+ s.isHidden = true;\r
+ s.isVisible = false;\r
+ if (!state.initialized)\r
+ _hidePane(pane); // no animation when loading page\r
+ sizeMidPanes(_c[pane].dir === "horz" ? "" : "center");\r
+ if (state.initialized || o.triggerEventsOnLoad)\r
+ _runCallbacks("onhide_end", pane);\r
+ }\r
+ else {\r
+ s.isHiding = true; // used by onclose\r
+ close(pane, false, noAnimation); // adjust all panes to fit\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Show a hidden pane - show as 'closed' by default unless openPane = true\r
+ *\r
+ * @param {string} pane The pane being opened, ie: north, south, east, or west\r
+ * @param {boolean=} [openPane=false]\r
+ * @param {boolean=} [noAnimation=false]\r
+ * @param {boolean=} [noAlert=false]\r
+ */\r
+, show = function (evt_or_pane, openPane, noAnimation, noAlert) {\r
+ if (!isInitialized()) return;\r
+ var pane = evtPane.call(this, evt_or_pane)\r
+ , o = options[pane]\r
+ , s = state[pane]\r
+ , $P = $Ps[pane]\r
+ , $R = $Rs[pane]\r
+ ;\r
+ if (!$P || !s.isHidden) return; // pane does not exist OR is not hidden\r
+\r
+ // onshow_start callback - will CANCEL show if returns false\r
+ if (false === _runCallbacks("onshow_start", pane)) return;\r
+\r
+ s.isSliding = false; // just in case\r
+ s.isShowing = true; // used by onopen/onclose\r
+ //s.isHidden = false; - will be set by open/close - if not cancelled\r
+\r
+ // now show the elements\r
+ //if ($R) $R.show(); - will be shown by open/close\r
+ if (openPane === false)\r
+ close(pane, true); // true = force\r
+ else\r
+ open(pane, false, noAnimation, noAlert); // adjust all panes to fit\r
+ }\r
+\r
+\r
+ /**\r
+ * Toggles a pane open/closed by calling either open or close\r
+ *\r
+ * @param {string} pane The pane being toggled, ie: north, south, east, or west\r
+ * @param {boolean=} [slide=false]\r
+ */\r
+, toggle = function (evt_or_pane, slide) {\r
+ if (!isInitialized()) return;\r
+ var evt = evtObj(evt_or_pane)\r
+ , pane = evtPane.call(this, evt_or_pane)\r
+ , s = state[pane]\r
+ ;\r
+ if (evt) // called from to $R.dblclick OR triggerPaneEvent\r
+ evt.stopImmediatePropagation();\r
+ if (s.isHidden)\r
+ show(pane); // will call 'open' after unhiding it\r
+ else if (s.isClosed)\r
+ open(pane, !!slide);\r
+ else\r
+ close(pane);\r
+ }\r
+\r
+\r
+ /**\r
+ * Utility method used during init or other auto-processes\r
+ *\r
+ * @param {string} pane The pane being closed\r
+ * @param {boolean=} [setHandles=false]\r
+ */\r
+, _closePane = function (pane, setHandles) {\r
+ var\r
+ $P = $Ps[pane]\r
+ , s = state[pane]\r
+ ;\r
+ _hidePane(pane);\r
+ s.isClosed = true;\r
+ s.isVisible = false;\r
+ // UNUSED: if (setHandles) setAsClosed(pane, true); // true = force\r
+ }\r
+\r
+ /**\r
+ * Close the specified pane (animation optional), and resize all other panes as needed\r
+ *\r
+ * @param {string} pane The pane being closed, ie: north, south, east, or west\r
+ * @param {boolean=} [force=false]\r
+ * @param {boolean=} [noAnimation=false]\r
+ * @param {boolean=} [skipCallback=false]\r
+ */\r
+, close = function (evt_or_pane, force, noAnimation, skipCallback) {\r
+ var pane = evtPane.call(this, evt_or_pane);\r
+ // if pane has been initialized, but NOT the complete layout, close pane instantly\r
+ if (!state.initialized && $Ps[pane]) {\r
+ _closePane(pane); // INIT pane as closed\r
+ return;\r
+ }\r
+ if (!isInitialized()) return;\r
+\r
+ var\r
+ $P = $Ps[pane]\r
+ , $R = $Rs[pane]\r
+ , $T = $Ts[pane]\r
+ , o = options[pane]\r
+ , s = state[pane]\r
+ , c = _c[pane]\r
+ , doFX, isShowing, isHiding, wasSliding;\r
+\r
+ // QUEUE in case another action/animation is in progress\r
+ $N.queue(function( queueNext ){\r
+ \r
+ if ( !$P\r
+ || (!o.closable && !s.isShowing && !s.isHiding) // invalid request // (!o.resizable && !o.closable) ???\r
+ || (!force && s.isClosed && !s.isShowing) // already closed\r
+ ) return queueNext();\r
+\r
+ // onclose_start callback - will CANCEL hide if returns false\r
+ // SKIP if just 'showing' a hidden pane as 'closed'\r
+ var abort = !s.isShowing && false === _runCallbacks("onclose_start", pane);\r
+\r
+ // transfer logic vars to temp vars\r
+ isShowing = s.isShowing;\r
+ isHiding = s.isHiding;\r
+ wasSliding = s.isSliding;\r
+ // now clear the logic vars (REQUIRED before aborting)\r
+ delete s.isShowing;\r
+ delete s.isHiding;\r
+\r
+ if (abort) return queueNext();\r
+\r
+ doFX = !noAnimation && !s.isClosed && (o.fxName_close != "none");\r
+ s.isMoving = true;\r
+ s.isClosed = true;\r
+ s.isVisible = false;\r
+ // update isHidden BEFORE sizing panes\r
+ if (isHiding) s.isHidden = true;\r
+ else if (isShowing) s.isHidden = false;\r
+\r
+ if (s.isSliding) // pane is being closed, so UNBIND trigger events\r
+ bindStopSlidingEvents(pane, false); // will set isSliding=false\r
+ else // resize panes adjacent to this one\r
+ sizeMidPanes(_c[pane].dir === "horz" ? "" : "center", false); // false = NOT skipCallback\r
+\r
+ // if this pane has a resizer bar, move it NOW - before animation\r
+ setAsClosed(pane);\r
+\r
+ // CLOSE THE PANE\r
+ if (doFX) { // animate the close\r
+ // mask panes with objects\r
+ var masks = "center"+ (c.dir=="horz" ? ",west,east" : "");\r
+ showMasks( masks, true ); // true = ONLY mask panes with maskObjects=true\r
+ lockPaneForFX(pane, true); // need to set left/top so animation will work\r
+ $P.hide( o.fxName_close, o.fxSettings_close, o.fxSpeed_close, function () {\r
+ lockPaneForFX(pane, false); // undo\r
+ if (s.isClosed) close_2();\r
+ queueNext();\r
+ });\r
+ }\r
+ else { // hide the pane without animation\r
+ _hidePane(pane);\r
+ close_2();\r
+ queueNext();\r
+ };\r
+ });\r
+\r
+ // SUBROUTINE\r
+ function close_2 () {\r
+ s.isMoving = false;\r
+ bindStartSlidingEvent(pane, true); // will enable if o.slidable = true\r
+\r
+ // if opposite-pane was autoClosed, see if it can be autoOpened now\r
+ var altPane = _c.oppositeEdge[pane];\r
+ if (state[ altPane ].noRoom) {\r
+ setSizeLimits( altPane );\r
+ makePaneFit( altPane );\r
+ }\r
+\r
+ // hide any masks shown while closing\r
+ hideMasks();\r
+\r
+ if (!skipCallback && (state.initialized || o.triggerEventsOnLoad)) {\r
+ // onclose callback - UNLESS just 'showing' a hidden pane as 'closed'\r
+ if (!isShowing) _runCallbacks("onclose_end", pane);\r
+ // onhide OR onshow callback\r
+ if (isShowing) _runCallbacks("onshow_end", pane);\r
+ if (isHiding) _runCallbacks("onhide_end", pane);\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * @param {string} pane The pane just closed, ie: north, south, east, or west\r
+ */\r
+, setAsClosed = function (pane) {\r
+ var\r
+ $P = $Ps[pane]\r
+ , $R = $Rs[pane]\r
+ , $T = $Ts[pane]\r
+ , o = options[pane]\r
+ , s = state[pane]\r
+ , side = _c[pane].side.toLowerCase()\r
+ , inset = "inset"+ _c[pane].side\r
+ , rClass = o.resizerClass\r
+ , tClass = o.togglerClass\r
+ , _pane = "-"+ pane // used for classNames\r
+ , _open = "-open"\r
+ , _sliding= "-sliding"\r
+ , _closed = "-closed"\r
+ ;\r
+ $R\r
+ .css(side, sC[inset]) // move the resizer\r
+ .removeClass( rClass+_open +" "+ rClass+_pane+_open )\r
+ .removeClass( rClass+_sliding +" "+ rClass+_pane+_sliding )\r
+ .addClass( rClass+_closed +" "+ rClass+_pane+_closed )\r
+ .unbind("dblclick."+ sID)\r
+ ;\r
+ // DISABLE 'resizing' when closed - do this BEFORE bindStartSlidingEvent?\r
+ if (o.resizable && $.layout.plugins.draggable)\r
+ $R\r
+ .draggable("disable")\r
+ .removeClass("ui-state-disabled") // do NOT apply disabled styling - not suitable here\r
+ .css("cursor", "default")\r
+ .attr("title","")\r
+ ;\r
+\r
+ // if pane has a toggler button, adjust that too\r
+ if ($T) {\r
+ $T\r
+ .removeClass( tClass+_open +" "+ tClass+_pane+_open )\r
+ .addClass( tClass+_closed +" "+ tClass+_pane+_closed )\r
+ .attr("title", o.togglerTip_closed) // may be blank\r
+ ;\r
+ // toggler-content - if exists\r
+ $T.children(".content-open").hide();\r
+ $T.children(".content-closed").css("display","block");\r
+ }\r
+\r
+ // sync any 'pin buttons'\r
+ syncPinBtns(pane, false);\r
+\r
+ if (state.initialized) {\r
+ // resize 'length' and position togglers for adjacent panes\r
+ sizeHandles();\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Open the specified pane (animation optional), and resize all other panes as needed\r
+ *\r
+ * @param {string} pane The pane being opened, ie: north, south, east, or west\r
+ * @param {boolean=} [slide=false]\r
+ * @param {boolean=} [noAnimation=false]\r
+ * @param {boolean=} [noAlert=false]\r
+ */\r
+, open = function (evt_or_pane, slide, noAnimation, noAlert) {\r
+ if (!isInitialized()) return;\r
+ var pane = evtPane.call(this, evt_or_pane)\r
+ , $P = $Ps[pane]\r
+ , $R = $Rs[pane]\r
+ , $T = $Ts[pane]\r
+ , o = options[pane]\r
+ , s = state[pane]\r
+ , c = _c[pane]\r
+ , doFX, isShowing\r
+ ;\r
+ // QUEUE in case another action/animation is in progress\r
+ $N.queue(function( queueNext ){\r
+\r
+ if ( !$P\r
+ || (!o.resizable && !o.closable && !s.isShowing) // invalid request\r
+ || (s.isVisible && !s.isSliding) // already open\r
+ ) return queueNext();\r
+\r
+ // pane can ALSO be unhidden by just calling show(), so handle this scenario\r
+ if (s.isHidden && !s.isShowing) {\r
+ queueNext(); // call before show() because it needs the queue free\r
+ show(pane, true);\r
+ return;\r
+ }\r
+\r
+ if (o.autoResize && s.size != o.size) // resize pane to original size set in options\r
+ sizePane(pane, o.size, true, true, true); // true=skipCallback/forceResize/noAnimation\r
+ else\r
+ // make sure there is enough space available to open the pane\r
+ setSizeLimits(pane, slide);\r
+\r
+ // onopen_start callback - will CANCEL open if returns false\r
+ var cbReturn = _runCallbacks("onopen_start", pane);\r
+\r
+ if (cbReturn === "abort")\r
+ return queueNext();\r
+\r
+ // update pane-state again in case options were changed in onopen_start\r
+ if (cbReturn !== "NC") // NC = "No Callback"\r
+ setSizeLimits(pane, slide);\r
+\r
+ if (s.minSize > s.maxSize) { // INSUFFICIENT ROOM FOR PANE TO OPEN!\r
+ syncPinBtns(pane, false); // make sure pin-buttons are reset\r
+ if (!noAlert && o.noRoomToOpenTip)\r
+ alert(o.noRoomToOpenTip);\r
+ return queueNext(); // ABORT\r
+ }\r
+\r
+ if (slide) // START Sliding - will set isSliding=true\r
+ bindStopSlidingEvents(pane, true); // BIND trigger events to close sliding-pane\r
+ else if (s.isSliding) // PIN PANE (stop sliding) - open pane 'normally' instead\r
+ bindStopSlidingEvents(pane, false); // UNBIND trigger events - will set isSliding=false\r
+ else if (o.slidable)\r
+ bindStartSlidingEvent(pane, false); // UNBIND trigger events\r
+\r
+ s.noRoom = false; // will be reset by makePaneFit if 'noRoom'\r
+ makePaneFit(pane);\r
+\r
+ // transfer logic var to temp var\r
+ isShowing = s.isShowing;\r
+ // now clear the logic var\r
+ delete s.isShowing;\r
+\r
+ doFX = !noAnimation && s.isClosed && (o.fxName_open != "none");\r
+ s.isMoving = true;\r
+ s.isVisible = true;\r
+ s.isClosed = false;\r
+ // update isHidden BEFORE sizing panes - WHY??? Old?\r
+ if (isShowing) s.isHidden = false;\r
+\r
+ if (doFX) { // ANIMATE\r
+ // mask panes with objects\r
+ var masks = "center"+ (c.dir=="horz" ? ",west,east" : "");\r
+ if (s.isSliding) masks += ","+ _c.oppositeEdge[pane];\r
+ showMasks( masks, true ); // true = ONLY mask panes with maskObjects=true\r
+ lockPaneForFX(pane, true); // need to set left/top so animation will work\r
+ $P.show( o.fxName_open, o.fxSettings_open, o.fxSpeed_open, function() {\r
+ lockPaneForFX(pane, false); // undo\r
+ if (s.isVisible) open_2(); // continue\r
+ queueNext();\r
+ });\r
+ }\r
+ else { // no animation\r
+ _showPane(pane);// just show pane and...\r
+ open_2(); // continue\r
+ queueNext();\r
+ };\r
+ });\r
+\r
+ // SUBROUTINE\r
+ function open_2 () {\r
+ s.isMoving = false;\r
+\r
+ // cure iframe display issues\r
+ _fixIframe(pane);\r
+\r
+ // NOTE: if isSliding, then other panes are NOT 'resized'\r
+ if (!s.isSliding) { // resize all panes adjacent to this one\r
+ hideMasks(); // remove any masks shown while opening\r
+ sizeMidPanes(_c[pane].dir=="vert" ? "center" : "", false); // false = NOT skipCallback\r
+ }\r
+\r
+ // set classes, position handles and execute callbacks...\r
+ setAsOpen(pane);\r
+ };\r
+ \r
+ }\r
+\r
+ /**\r
+ * @param {string} pane The pane just opened, ie: north, south, east, or west\r
+ * @param {boolean=} [skipCallback=false]\r
+ */\r
+, setAsOpen = function (pane, skipCallback) {\r
+ var \r
+ $P = $Ps[pane]\r
+ , $R = $Rs[pane]\r
+ , $T = $Ts[pane]\r
+ , o = options[pane]\r
+ , s = state[pane]\r
+ , side = _c[pane].side.toLowerCase()\r
+ , inset = "inset"+ _c[pane].side\r
+ , rClass = o.resizerClass\r
+ , tClass = o.togglerClass\r
+ , _pane = "-"+ pane // used for classNames\r
+ , _open = "-open"\r
+ , _closed = "-closed"\r
+ , _sliding= "-sliding"\r
+ ;\r
+ $R\r
+ .css(side, sC[inset] + getPaneSize(pane)) // move the resizer\r
+ .removeClass( rClass+_closed +" "+ rClass+_pane+_closed )\r
+ .addClass( rClass+_open +" "+ rClass+_pane+_open )\r
+ ;\r
+ if (s.isSliding)\r
+ $R.addClass( rClass+_sliding +" "+ rClass+_pane+_sliding )\r
+ else // in case 'was sliding'\r
+ $R.removeClass( rClass+_sliding +" "+ rClass+_pane+_sliding )\r
+\r
+ if (o.resizerDblClickToggle)\r
+ $R.bind("dblclick", toggle );\r
+ removeHover( 0, $R ); // remove hover classes\r
+ if (o.resizable && $.layout.plugins.draggable)\r
+ $R .draggable("enable")\r
+ .css("cursor", o.resizerCursor)\r
+ .attr("title", o.resizerTip);\r
+ else if (!s.isSliding)\r
+ $R.css("cursor", "default"); // n-resize, s-resize, etc\r
+\r
+ // if pane also has a toggler button, adjust that too\r
+ if ($T) {\r
+ $T .removeClass( tClass+_closed +" "+ tClass+_pane+_closed )\r
+ .addClass( tClass+_open +" "+ tClass+_pane+_open )\r
+ .attr("title", o.togglerTip_open); // may be blank\r
+ removeHover( 0, $T ); // remove hover classes\r
+ // toggler-content - if exists\r
+ $T.children(".content-closed").hide();\r
+ $T.children(".content-open").css("display","block");\r
+ }\r
+\r
+ // sync any 'pin buttons'\r
+ syncPinBtns(pane, !s.isSliding);\r
+\r
+ // update pane-state dimensions - BEFORE resizing content\r
+ $.extend(s, elDims($P));\r
+\r
+ if (state.initialized) {\r
+ // resize resizer & toggler sizes for all panes\r
+ sizeHandles();\r
+ // resize content every time pane opens - to be sure\r
+ sizeContent(pane, true); // true = remeasure headers/footers, even if 'pane.isMoving'\r
+ }\r
+\r
+ if (!skipCallback && (state.initialized || o.triggerEventsOnLoad) && $P.is(":visible")) {\r
+ // onopen callback\r
+ _runCallbacks("onopen_end", pane);\r
+ // onshow callback - TODO: should this be here?\r
+ if (s.isShowing) _runCallbacks("onshow_end", pane);\r
+\r
+ // ALSO call onresize because layout-size *may* have changed while pane was closed\r
+ if (state.initialized)\r
+ _runCallbacks("onresize_end", pane);\r
+ }\r
+\r
+ // TODO: Somehow sizePane("north") is being called after this point???\r
+ }\r
+\r
+\r
+ /**\r
+ * slideOpen / slideClose / slideToggle\r
+ *\r
+ * Pass-though methods for sliding\r
+ */\r
+, slideOpen = function (evt_or_pane) {\r
+ if (!isInitialized()) return;\r
+ var evt = evtObj(evt_or_pane)\r
+ , pane = evtPane.call(this, evt_or_pane)\r
+ , s = state[pane]\r
+ , delay = options[pane].slideDelay_open\r
+ ;\r
+ // prevent event from triggering on NEW resizer binding created below\r
+ if (evt) evt.stopImmediatePropagation();\r
+\r
+ if (s.isClosed && evt && evt.type === "mouseenter" && delay > 0)\r
+ // trigger = mouseenter - use a delay\r
+ timer.set(pane+"_openSlider", open_NOW, delay);\r
+ else\r
+ open_NOW(); // will unbind events if is already open\r
+\r
+ /**\r
+ * SUBROUTINE for timed open\r
+ */\r
+ function open_NOW () {\r
+ if (!s.isClosed) // skip if no longer closed!\r
+ bindStopSlidingEvents(pane, true); // BIND trigger events to close sliding-pane\r
+ else if (!s.isMoving)\r
+ open(pane, true); // true = slide - open() will handle binding\r
+ };\r
+ }\r
+\r
+, slideClose = function (evt_or_pane) {\r
+ if (!isInitialized()) return;\r
+ var evt = evtObj(evt_or_pane)\r
+ , pane = evtPane.call(this, evt_or_pane)\r
+ , o = options[pane]\r
+ , s = state[pane]\r
+ , delay = s.isMoving ? 1000 : 300 // MINIMUM delay - option may override\r
+ ;\r
+ if (s.isClosed || s.isResizing)\r
+ return; // skip if already closed OR in process of resizing\r
+ else if (o.slideTrigger_close === "click")\r
+ close_NOW(); // close immediately onClick\r
+ else if (o.preventQuickSlideClose && s.isMoving)\r
+ return; // handle Chrome quick-close on slide-open\r
+ else if (o.preventPrematureSlideClose && evt && $.layout.isMouseOverElem(evt, $Ps[pane]))\r
+ return; // handle incorrect mouseleave trigger, like when over a SELECT-list in IE\r
+ else if (evt) // trigger = mouseleave - use a delay\r
+ // 1 sec delay if 'opening', else .3 sec\r
+ timer.set(pane+"_closeSlider", close_NOW, max(o.slideDelay_close, delay));\r
+ else // called programically\r
+ close_NOW();\r
+\r
+ /**\r
+ * SUBROUTINE for timed close\r
+ */\r
+ function close_NOW () {\r
+ if (s.isClosed) // skip 'close' if already closed!\r
+ bindStopSlidingEvents(pane, false); // UNBIND trigger events - TODO: is this needed here?\r
+ else if (!s.isMoving)\r
+ close(pane); // close will handle unbinding\r
+ };\r
+ }\r
+\r
+ /**\r
+ * @param {string} pane The pane being opened, ie: north, south, east, or west\r
+ */\r
+, slideToggle = function (evt_or_pane) {\r
+ var pane = evtPane.call(this, evt_or_pane);\r
+ toggle(pane, true);\r
+ }\r
+\r
+\r
+ /**\r
+ * Must set left/top on East/South panes so animation will work properly\r
+ *\r
+ * @param {string} pane The pane to lock, 'east' or 'south' - any other is ignored!\r
+ * @param {boolean} doLock true = set left/top, false = remove\r
+ */\r
+, lockPaneForFX = function (pane, doLock) {\r
+ var $P = $Ps[pane]\r
+ , s = state[pane]\r
+ , o = options[pane]\r
+ , z = options.zIndexes\r
+ ;\r
+ if (doLock) {\r
+ $P.css({ zIndex: z.pane_animate }); // overlay all elements during animation\r
+ if (pane=="south")\r
+ $P.css({ top: sC.insetTop + sC.innerHeight - $P.outerHeight() });\r
+ else if (pane=="east")\r
+ $P.css({ left: sC.insetLeft + sC.innerWidth - $P.outerWidth() });\r
+ }\r
+ else { // animation DONE - RESET CSS\r
+ // TODO: see if this can be deleted. It causes a quick-close when sliding in Chrome\r
+ $P.css({ zIndex: (s.isSliding ? z.pane_sliding : z.pane_normal) });\r
+ if (pane=="south")\r
+ $P.css({ top: "auto" });\r
+ // if pane is positioned 'off-screen', then DO NOT screw with it!\r
+ else if (pane=="east" && !$P.css("left").match(/\-99999/))\r
+ $P.css({ left: "auto" });\r
+ // fix anti-aliasing in IE - only needed for animations that change opacity\r
+ if (browser.msie && o.fxOpacityFix && o.fxName_open != "slide" && $P.css("filter") && $P.css("opacity") == 1)\r
+ $P[0].style.removeAttribute('filter');\r
+ }\r
+ }\r
+\r
+\r
+ /**\r
+ * Toggle sliding functionality of a specific pane on/off by adding removing 'slide open' trigger\r
+ *\r
+ * @see open(), close()\r
+ * @param {string} pane The pane to enable/disable, 'north', 'south', etc.\r
+ * @param {boolean} enable Enable or Disable sliding?\r
+ */\r
+, bindStartSlidingEvent = function (pane, enable) {\r
+ var o = options[pane]\r
+ , $P = $Ps[pane]\r
+ , $R = $Rs[pane]\r
+ , evtName = o.slideTrigger_open.toLowerCase()\r
+ ;\r
+ if (!$R || (enable && !o.slidable)) return;\r
+\r
+ // make sure we have a valid event\r
+ if (evtName.match(/mouseover/))\r
+ evtName = o.slideTrigger_open = "mouseenter";\r
+ else if (!evtName.match(/click|dblclick|mouseenter/)) \r
+ evtName = o.slideTrigger_open = "click";\r
+\r
+ $R\r
+ // add or remove event\r
+ [enable ? "bind" : "unbind"](evtName +'.'+ sID, slideOpen)\r
+ // set the appropriate cursor & title/tip\r
+ .css("cursor", enable ? o.sliderCursor : "default")\r
+ .attr("title", enable ? o.sliderTip : "")\r
+ ;\r
+ }\r
+\r
+ /**\r
+ * Add or remove 'mouseleave' events to 'slide close' when pane is 'sliding' open or closed\r
+ * Also increases zIndex when pane is sliding open\r
+ * See bindStartSlidingEvent for code to control 'slide open'\r
+ *\r
+ * @see slideOpen(), slideClose()\r
+ * @param {string} pane The pane to process, 'north', 'south', etc.\r
+ * @param {boolean} enable Enable or Disable events?\r
+ */\r
+, bindStopSlidingEvents = function (pane, enable) {\r
+ var o = options[pane]\r
+ , s = state[pane]\r
+ , c = _c[pane]\r
+ , z = options.zIndexes\r
+ , evtName = o.slideTrigger_close.toLowerCase()\r
+ , action = (enable ? "bind" : "unbind")\r
+ , $P = $Ps[pane]\r
+ , $R = $Rs[pane]\r
+ ;\r
+ s.isSliding = enable; // logic\r
+ timer.clear(pane+"_closeSlider"); // just in case\r
+\r
+ // remove 'slideOpen' event from resizer\r
+ // ALSO will raise the zIndex of the pane & resizer\r
+ if (enable) bindStartSlidingEvent(pane, false);\r
+\r
+ // RE/SET zIndex - increases when pane is sliding-open, resets to normal when not\r
+ $P.css("zIndex", enable ? z.pane_sliding : z.pane_normal);\r
+ $R.css("zIndex", enable ? z.pane_sliding+2 : z.resizer_normal); // NOTE: mask = pane_sliding+1\r
+\r
+ // make sure we have a valid event\r
+ if (!evtName.match(/click|mouseleave/))\r
+ evtName = o.slideTrigger_close = "mouseleave"; // also catches 'mouseout'\r
+\r
+ // add/remove slide triggers\r
+ $R[action](evtName, slideClose); // base event on resize\r
+ // need extra events for mouseleave\r
+ if (evtName === "mouseleave") {\r
+ // also close on pane.mouseleave\r
+ $P[action]("mouseleave."+ sID, slideClose);\r
+ // cancel timer when mouse moves between 'pane' and 'resizer'\r
+ $R[action]("mouseenter."+ sID, cancelMouseOut);\r
+ $P[action]("mouseenter."+ sID, cancelMouseOut);\r
+ }\r
+\r
+ if (!enable)\r
+ timer.clear(pane+"_closeSlider");\r
+ else if (evtName === "click" && !o.resizable) {\r
+ // IF pane is not resizable (which already has a cursor and tip) \r
+ // then set the a cursor & title/tip on resizer when sliding\r
+ $R.css("cursor", enable ? o.sliderCursor : "default");\r
+ $R.attr("title", enable ? o.togglerTip_open : ""); // use Toggler-tip, eg: "Close Pane"\r
+ }\r
+\r
+ // SUBROUTINE for mouseleave timer clearing\r
+ function cancelMouseOut (evt) {\r
+ timer.clear(pane+"_closeSlider");\r
+ evt.stopPropagation();\r
+ }\r
+ }\r
+\r
+\r
+ /**\r
+ * Hides/closes a pane if there is insufficient room - reverses this when there is room again\r
+ * MUST have already called setSizeLimits() before calling this method\r
+ *\r
+ * @param {string} pane The pane being resized\r
+ * @param {boolean=} [isOpening=false] Called from onOpen?\r
+ * @param {boolean=} [skipCallback=false] Should the onresize callback be run?\r
+ * @param {boolean=} [force=false]\r
+ */\r
+, makePaneFit = function (pane, isOpening, skipCallback, force) {\r
+ var\r
+ o = options[pane]\r
+ , s = state[pane]\r
+ , c = _c[pane]\r
+ , $P = $Ps[pane]\r
+ , $R = $Rs[pane]\r
+ , isSidePane = c.dir==="vert"\r
+ , hasRoom = false\r
+ ;\r
+ // special handling for center & east/west panes\r
+ if (pane === "center" || (isSidePane && s.noVerticalRoom)) {\r
+ // see if there is enough room to display the pane\r
+ // ERROR: hasRoom = s.minHeight <= s.maxHeight && (isSidePane || s.minWidth <= s.maxWidth);\r
+ hasRoom = (s.maxHeight >= 0);\r
+ if (hasRoom && s.noRoom) { // previously hidden due to noRoom, so show now\r
+ _showPane(pane);\r
+ if ($R) $R.show();\r
+ s.isVisible = true;\r
+ s.noRoom = false;\r
+ if (isSidePane) s.noVerticalRoom = false;\r
+ _fixIframe(pane);\r
+ }\r
+ else if (!hasRoom && !s.noRoom) { // not currently hidden, so hide now\r
+ _hidePane(pane);\r
+ if ($R) $R.hide();\r
+ s.isVisible = false;\r
+ s.noRoom = true;\r
+ }\r
+ }\r
+\r
+ // see if there is enough room to fit the border-pane\r
+ if (pane === "center") {\r
+ // ignore center in this block\r
+ }\r
+ else if (s.minSize <= s.maxSize) { // pane CAN fit\r
+ hasRoom = true;\r
+ if (s.size > s.maxSize) // pane is too big - shrink it\r
+ sizePane(pane, s.maxSize, skipCallback, force, true); // true = noAnimation\r
+ else if (s.size < s.minSize) // pane is too small - enlarge it\r
+ sizePane(pane, s.minSize, skipCallback, force, true);\r
+ // need s.isVisible because new pseudoClose method keeps pane visible, but off-screen\r
+ else if ($R && s.isVisible && $P.is(":visible")) {\r
+ // make sure resizer-bar is positioned correctly\r
+ // handles situation where nested layout was 'hidden' when initialized\r
+ var side = c.side.toLowerCase()\r
+ , pos = s.size + sC["inset"+ c.side]\r
+ ;\r
+ if ($.layout.cssNum($R, side) != pos) $R.css( side, pos );\r
+ }\r
+\r
+ // if was previously hidden due to noRoom, then RESET because NOW there is room\r
+ if (s.noRoom) {\r
+ // s.noRoom state will be set by open or show\r
+ if (s.wasOpen && o.closable) {\r
+ if (o.autoReopen)\r
+ open(pane, false, true, true); // true = noAnimation, true = noAlert\r
+ else // leave the pane closed, so just update state\r
+ s.noRoom = false;\r
+ }\r
+ else\r
+ show(pane, s.wasOpen, true, true); // true = noAnimation, true = noAlert\r
+ }\r
+ }\r
+ else { // !hasRoom - pane CANNOT fit\r
+ if (!s.noRoom) { // pane not set as noRoom yet, so hide or close it now...\r
+ s.noRoom = true; // update state\r
+ s.wasOpen = !s.isClosed && !s.isSliding;\r
+ if (s.isClosed){} // SKIP\r
+ else if (o.closable) // 'close' if possible\r
+ close(pane, true, true); // true = force, true = noAnimation\r
+ else // 'hide' pane if cannot just be closed\r
+ hide(pane, true); // true = noAnimation\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+ /**\r
+ * sizePane / manualSizePane\r
+ * sizePane is called only by internal methods whenever a pane needs to be resized\r
+ * manualSizePane is an exposed flow-through method allowing extra code when pane is 'manually resized'\r
+ *\r
+ * @param {string} pane The pane being resized\r
+ * @param {number} size The *desired* new size for this pane - will be validated\r
+ * @param {boolean=} [skipCallback=false] Should the onresize callback be run?\r
+ * @param {boolean=} [noAnimation=false]\r
+ */\r
+, manualSizePane = function (evt_or_pane, size, skipCallback, noAnimation) {\r
+ if (!isInitialized()) return;\r
+ var pane = evtPane.call(this, evt_or_pane)\r
+ , o = options[pane]\r
+ , s = state[pane]\r
+ // if resizing callbacks have been delayed and resizing is now DONE, force resizing to complete...\r
+ , forceResize = o.livePaneResizing && !s.isResizing\r
+ ;\r
+ // ANY call to manualSizePane disables autoResize - ie, percentage sizing\r
+ o.autoResize = false;\r
+ // flow-through...\r
+ sizePane(pane, size, skipCallback, forceResize, noAnimation); // will animate resize if option enabled\r
+ }\r
+\r
+ /**\r
+ * @param {string} pane The pane being resized\r
+ * @param {number} size The *desired* new size for this pane - will be validated\r
+ * @param {boolean=} [skipCallback=false] Should the onresize callback be run?\r
+ * @param {boolean=} [force=false] Force resizing even if does not seem necessary\r
+ * @param {boolean=} [noAnimation=false]\r
+ */\r
+, sizePane = function (evt_or_pane, size, skipCallback, force, noAnimation) {\r
+ if (!isInitialized()) return;\r
+ var pane = evtPane.call(this, evt_or_pane) // probably NEVER called from event?\r
+ , o = options[pane]\r
+ , s = state[pane]\r
+ , $P = $Ps[pane]\r
+ , $R = $Rs[pane]\r
+ , side = _c[pane].side.toLowerCase()\r
+ , dimName = _c[pane].sizeType.toLowerCase()\r
+ , inset = "inset"+ _c[pane].side\r
+ , skipResizeWhileDragging = s.isResizing && !o.triggerEventsDuringLiveResize\r
+ , doFX = noAnimation !== true && o.animatePaneSizing\r
+ , oldSize, newSize\r
+ ;\r
+ // QUEUE in case another action/animation is in progress\r
+ $N.queue(function( queueNext ){\r
+ // calculate 'current' min/max sizes\r
+ setSizeLimits(pane); // update pane-state\r
+ oldSize = s.size;\r
+ size = _parseSize(pane, size); // handle percentages & auto\r
+ size = max(size, _parseSize(pane, o.minSize));\r
+ size = min(size, s.maxSize);\r
+ if (size < s.minSize) { // not enough room for pane!\r
+ queueNext(); // call before makePaneFit() because it needs the queue free\r
+ makePaneFit(pane, false, skipCallback); // will hide or close pane\r
+ return;\r
+ }\r
+\r
+ // IF newSize is same as oldSize, then nothing to do - abort\r
+ if (!force && size === oldSize)\r
+ return queueNext();\r
+\r
+ // onresize_start callback CANNOT cancel resizing because this would break the layout!\r
+ if (!skipCallback && state.initialized && s.isVisible)\r
+ _runCallbacks("onresize_start", pane);\r
+\r
+ // resize the pane, and make sure its visible\r
+ newSize = cssSize(pane, size);\r
+\r
+ if (doFX && $P.is(":visible")) { // ANIMATE\r
+ var fx = $.layout.effects.size[pane] || $.layout.effects.size.all\r
+ , easing = o.fxSettings_size.easing || fx.easing\r
+ , z = options.zIndexes\r
+ , props = {};\r
+ props[ dimName ] = newSize +'px';\r
+ s.isMoving = true;\r
+ // overlay all elements during animation\r
+ $P.css({ zIndex: z.pane_animate })\r
+ .show().animate( props, o.fxSpeed_size, easing, function(){\r
+ // reset zIndex after animation\r
+ $P.css({ zIndex: (s.isSliding ? z.pane_sliding : z.pane_normal) });\r
+ s.isMoving = false;\r
+ sizePane_2(); // continue\r
+ queueNext();\r
+ });\r
+ }\r
+ else { // no animation\r
+ $P.css( dimName, newSize ); // resize pane\r
+ // if pane is visible, then \r
+ if ($P.is(":visible"))\r
+ sizePane_2(); // continue\r
+ else {\r
+ // pane is NOT VISIBLE, so just update state data...\r
+ // when pane is *next opened*, it will have the new size\r
+ s.size = size; // update state.size\r
+ $.extend(s, elDims($P)); // update state dimensions\r
+ }\r
+ queueNext();\r
+ };\r
+\r
+ });\r
+\r
+ // SUBROUTINE\r
+ function sizePane_2 () {\r
+ /* Panes are sometimes not sized precisely in some browsers!?\r
+ * This code will resize the pane up to 3 times to nudge the pane to the correct size\r
+ */\r
+ var actual = dimName==='width' ? $P.outerWidth() : $P.outerHeight()\r
+ , tries = [{\r
+ pane: pane\r
+ , count: 1\r
+ , target: size\r
+ , actual: actual\r
+ , correct: (size === actual)\r
+ , attempt: size\r
+ , cssSize: newSize\r
+ }]\r
+ , lastTry = tries[0]\r
+ , msg = 'Inaccurate size after resizing the '+ pane +'-pane.'\r
+ ;\r
+ while ( !lastTry.correct ) {\r
+ thisTry = { pane: pane, count: lastTry.count+1, target: size };\r
+\r
+ if (lastTry.actual > size)\r
+ thisTry.attempt = max(0, lastTry.attempt - (lastTry.actual - size));\r
+ else // lastTry.actual < size\r
+ thisTry.attempt = max(0, lastTry.attempt + (size - lastTry.actual));\r
+\r
+ thisTry.cssSize = cssSize(pane, thisTry.attempt);\r
+ $P.css( dimName, thisTry.cssSize );\r
+\r
+ thisTry.actual = dimName=='width' ? $P.outerWidth() : $P.outerHeight();\r
+ thisTry.correct = (size === thisTry.actual);\r
+\r
+ // if showDebugMessages, log attempts and alert the user of this *non-fatal error*\r
+ if (options.showDebugMessages) {\r
+ if ( tries.length === 1) {\r
+ _log(msg, false);\r
+ _log(lastTry, false);\r
+ }\r
+ _log(thisTry, false);\r
+ }\r
+\r
+ // after 4 tries, is as close as its gonna get!\r
+ if (tries.length > 3) break;\r
+\r
+ tries.push( thisTry );\r
+ lastTry = tries[ tries.length - 1 ];\r
+ }\r
+ // END TESTING CODE\r
+\r
+ // update pane-state dimensions\r
+ s.size = size;\r
+ $.extend(s, elDims($P));\r
+\r
+ if (s.isVisible && $P.is(":visible")) {\r
+ // reposition the resizer-bar\r
+ if ($R) $R.css( side, size + sC[inset] );\r
+ // resize the content-div\r
+ sizeContent(pane);\r
+ }\r
+\r
+ if (!skipCallback && !skipResizeWhileDragging && state.initialized && s.isVisible)\r
+ _runCallbacks("onresize_end", pane);\r
+\r
+ // resize all the adjacent panes, and adjust their toggler buttons\r
+ // when skipCallback passed, it means the controlling method will handle 'other panes'\r
+ if (!skipCallback) {\r
+ // also no callback if live-resize is in progress and NOT triggerEventsDuringLiveResize\r
+ if (!s.isSliding) sizeMidPanes(_c[pane].dir=="horz" ? "" : "center", skipResizeWhileDragging, force);\r
+ sizeHandles();\r
+ }\r
+\r
+ // if opposite-pane was autoClosed, see if it can be autoOpened now\r
+ var altPane = _c.oppositeEdge[pane];\r
+ if (size < oldSize && state[ altPane ].noRoom) {\r
+ setSizeLimits( altPane );\r
+ makePaneFit( altPane, false, skipCallback );\r
+ }\r
+\r
+ // DEBUG - ALERT user/developer so they know there was a sizing problem\r
+ if (options.showDebugMessages && tries.length > 1)\r
+ _log(msg +'\nSee the Error Console for details.', true);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * @see initPanes(), sizePane(), resizeAll(), open(), close(), hide()\r
+ * @param {string} panes The pane(s) being resized, comma-delmited string\r
+ * @param {boolean=} [skipCallback=false] Should the onresize callback be run?\r
+ * @param {boolean=} [force=false]\r
+ */\r
+, sizeMidPanes = function (panes, skipCallback, force) {\r
+ panes = (panes ? panes : "east,west,center").split(",");\r
+\r
+ $.each(panes, function (i, pane) {\r
+ if (!$Ps[pane]) return; // NO PANE - skip\r
+ var \r
+ o = options[pane]\r
+ , s = state[pane]\r
+ , $P = $Ps[pane]\r
+ , $R = $Rs[pane]\r
+ , isCenter= (pane=="center")\r
+ , hasRoom = true\r
+ , CSS = {}\r
+ , newCenter = calcNewCenterPaneDims()\r
+ ;\r
+ // update pane-state dimensions\r
+ $.extend(s, elDims($P));\r
+\r
+ if (pane === "center") {\r
+ if (!force && s.isVisible && newCenter.width === s.outerWidth && newCenter.height === s.outerHeight)\r
+ return true; // SKIP - pane already the correct size\r
+ // set state for makePaneFit() logic\r
+ $.extend(s, cssMinDims(pane), {\r
+ maxWidth: newCenter.width\r
+ , maxHeight: newCenter.height\r
+ });\r
+ CSS = newCenter;\r
+ // convert OUTER width/height to CSS width/height \r
+ CSS.width = cssW($P, CSS.width);\r
+ // NEW - allow pane to extend 'below' visible area rather than hide it\r
+ CSS.height = cssH($P, CSS.height);\r
+ hasRoom = CSS.width >= 0 && CSS.height >= 0; // height >= 0 = ALWAYS TRUE NOW\r
+ // during layout init, try to shrink east/west panes to make room for center\r
+ if (!state.initialized && o.minWidth > s.outerWidth) {\r
+ var\r
+ reqPx = o.minWidth - s.outerWidth\r
+ , minE = options.east.minSize || 0\r
+ , minW = options.west.minSize || 0\r
+ , sizeE = state.east.size\r
+ , sizeW = state.west.size\r
+ , newE = sizeE\r
+ , newW = sizeW\r
+ ;\r
+ if (reqPx > 0 && state.east.isVisible && sizeE > minE) {\r
+ newE = max( sizeE-minE, sizeE-reqPx );\r
+ reqPx -= sizeE-newE;\r
+ }\r
+ if (reqPx > 0 && state.west.isVisible && sizeW > minW) {\r
+ newW = max( sizeW-minW, sizeW-reqPx );\r
+ reqPx -= sizeW-newW;\r
+ }\r
+ // IF we found enough extra space, then resize the border panes as calculated\r
+ if (reqPx === 0) {\r
+ if (sizeE != minE)\r
+ sizePane('east', newE, true, force, true); // true = skipCallback/noAnimation - initPanes will handle when done\r
+ if (sizeW != minW)\r
+ sizePane('west', newW, true, force, true);\r
+ // now start over!\r
+ sizeMidPanes('center', skipCallback, force);\r
+ return; // abort this loop\r
+ }\r
+ }\r
+ }\r
+ else { // for east and west, set only the height, which is same as center height\r
+ // set state.min/maxWidth/Height for makePaneFit() logic\r
+ if (s.isVisible && !s.noVerticalRoom)\r
+ $.extend(s, elDims($P), cssMinDims(pane))\r
+ if (!force && !s.noVerticalRoom && newCenter.height === s.outerHeight)\r
+ return true; // SKIP - pane already the correct size\r
+ // east/west have same top, bottom & height as center\r
+ CSS.top = newCenter.top;\r
+ CSS.bottom = newCenter.bottom;\r
+ // NEW - allow pane to extend 'below' visible area rather than hide it\r
+ CSS.height = cssH($P, newCenter.height);\r
+ s.maxHeight = CSS.height;\r
+ hasRoom = (s.maxHeight >= 0); // ALWAYS TRUE NOW\r
+ if (!hasRoom) s.noVerticalRoom = true; // makePaneFit() logic\r
+ }\r
+\r
+ if (hasRoom) {\r
+ // resizeAll passes skipCallback because it triggers callbacks after ALL panes are resized\r
+ if (!skipCallback && state.initialized)\r
+ _runCallbacks("onresize_start", pane);\r
+\r
+ $P.css(CSS); // apply the CSS to pane\r
+ sizeHandles(pane); // also update resizer length\r
+ if (s.noRoom && !s.isClosed && !s.isHidden)\r
+ makePaneFit(pane); // will re-open/show auto-closed/hidden pane\r
+ if (s.isVisible) {\r
+ $.extend(s, elDims($P)); // update pane dimensions\r
+ if (state.initialized) sizeContent(pane); // also resize the contents, if exists\r
+ }\r
+ }\r
+ else if (!s.noRoom && s.isVisible) // no room for pane\r
+ makePaneFit(pane); // will hide or close pane\r
+\r
+ if (!s.isVisible)\r
+ return true; // DONE - next pane\r
+\r
+ /*\r
+ * Extra CSS for IE6 or IE7 in Quirks-mode - add 'width' to NORTH/SOUTH panes\r
+ * Normally these panes have only 'left' & 'right' positions so pane auto-sizes\r
+ * ALSO required when pane is an IFRAME because will NOT default to 'full width'\r
+ */\r
+ if (pane === "center") { // finished processing midPanes\r
+ var b = $.layout.browser;\r
+ var fix = b.isIE6 || (b.msie && !$.support.boxModel);\r
+ if ($Ps.north && (fix || state.north.tagName=="IFRAME")) \r
+ $Ps.north.css("width", cssW($Ps.north, sC.innerWidth));\r
+ if ($Ps.south && (fix || state.south.tagName=="IFRAME"))\r
+ $Ps.south.css("width", cssW($Ps.south, sC.innerWidth));\r
+ }\r
+\r
+ // resizeAll passes skipCallback because it triggers callbacks after ALL panes are resized\r
+ if (!skipCallback && state.initialized)\r
+ _runCallbacks("onresize_end", pane);\r
+ });\r
+ }\r
+\r
+\r
+ /**\r
+ * @see window.onresize(), callbacks or custom code\r
+ */\r
+, resizeAll = function () {\r
+ if (!state.initialized) {\r
+ _initLayoutElements();\r
+ return; // no need to resize since we just initialized!\r
+ }\r
+ var oldW = sC.innerWidth\r
+ , oldH = sC.innerHeight\r
+ ;\r
+ // cannot size layout when 'container' is hidden or collapsed\r
+ if (!$N.is(":visible:") ) return;\r
+ $.extend( state.container, elDims( $N ) ); // UPDATE container dimensions\r
+ if (!sC.outerHeight) return;\r
+\r
+ // onresizeall_start will CANCEL resizing if returns false\r
+ // state.container has already been set, so user can access this info for calcuations\r
+ if (false === _runCallbacks("onresizeall_start")) return false;\r
+\r
+ var // see if container is now 'smaller' than before\r
+ shrunkH = (sC.innerHeight < oldH)\r
+ , shrunkW = (sC.innerWidth < oldW)\r
+ , $P, o, s, dir\r
+ ;\r
+ // NOTE special order for sizing: S-N-E-W\r
+ $.each(["south","north","east","west"], function (i, pane) {\r
+ if (!$Ps[pane]) return; // no pane - SKIP\r
+ s = state[pane];\r
+ o = options[pane];\r
+ dir = _c[pane].dir;\r
+\r
+ if (o.autoResize && s.size != o.size) // resize pane to original size set in options\r
+ sizePane(pane, o.size, true, true, true); // true=skipCallback/forceResize/noAnimation\r
+ else {\r
+ setSizeLimits(pane);\r
+ makePaneFit(pane, false, true, true); // true=skipCallback/forceResize\r
+ }\r
+ });\r
+\r
+ sizeMidPanes("", true, true); // true=skipCallback, true=forceResize\r
+ sizeHandles(); // reposition the toggler elements\r
+\r
+ // trigger all individual pane callbacks AFTER layout has finished resizing\r
+ o = options; // reuse alias\r
+ $.each(_c.allPanes, function (i, pane) {\r
+ $P = $Ps[pane];\r
+ if (!$P) return; // SKIP\r
+ if (state[pane].isVisible) // undefined for non-existent panes\r
+ _runCallbacks("onresize_end", pane); // callback - if exists\r
+ });\r
+\r
+ _runCallbacks("onresizeall_end");\r
+ //_triggerLayoutEvent(pane, 'resizeall');\r
+ }\r
+\r
+ /**\r
+ * Whenever a pane resizes or opens that has a nested layout, trigger resizeAll\r
+ *\r
+ * @param {string} pane The pane just resized or opened\r
+ */\r
+, resizeChildLayout = function (evt_or_pane) {\r
+ var pane = evtPane.call(this, evt_or_pane);\r
+ if (!options[pane].resizeChildLayout) return;\r
+ var $P = $Ps[pane]\r
+ , $C = $Cs[pane]\r
+ , d = "layout"\r
+ , P = Instance[pane]\r
+ , L = children[pane]\r
+ ;\r
+ // user may have manually set EITHER instance pointer, so handle that\r
+ if (P.child && !L) {\r
+ // have to reverse the pointers!\r
+ var el = P.child.container;\r
+ L = children[pane] = (el ? el.data(d) : 0) || null; // set pointer _directly_ to layout instance\r
+ }\r
+\r
+ // if a layout-pointer exists, see if child has been destroyed\r
+ if (L && L.destroyed)\r
+ L = children[pane] = null; // clear child pointers\r
+ // no child layout pointer is set - see if there is a child layout NOW\r
+ if (!L) L = children[pane] = $P.data(d) || ($C ? $C.data(d) : 0) || null; // set/update child pointers\r
+\r
+ // ALWAYS refresh the pane.child alias\r
+ P.child = children[pane];\r
+\r
+ if (L) L.resizeAll();\r
+ }\r
+\r
+\r
+ /**\r
+ * IF pane has a content-div, then resize all elements inside pane to fit pane-height\r
+ *\r
+ * @param {string=} [panes=""] The pane(s) being resized\r
+ * @param {boolean=} [remeasure=false] Should the content (header/footer) be remeasured?\r
+ */\r
+, sizeContent = function (evt_or_panes, remeasure) {\r
+ if (!isInitialized()) return;\r
+\r
+ var panes = evtPane.call(this, evt_or_panes);\r
+ panes = panes ? panes.split(",") : _c.allPanes;\r
+\r
+ $.each(panes, function (idx, pane) {\r
+ var\r
+ $P = $Ps[pane]\r
+ , $C = $Cs[pane]\r
+ , o = options[pane]\r
+ , s = state[pane]\r
+ , m = s.content // m = measurements\r
+ ;\r
+ if (!$P || !$C || !$P.is(":visible")) return true; // NOT VISIBLE - skip\r
+\r
+ // if content-element was REMOVED, update OR remove the pointer\r
+ if (!$C.length) {\r
+ initContent(pane, false); // false = do NOT sizeContent() - already there!\r
+ if (!$C) return; // no replacement element found - pointer have been removed\r
+ }\r
+\r
+ // onsizecontent_start will CANCEL resizing if returns false\r
+ if (false === _runCallbacks("onsizecontent_start", pane)) return;\r
+\r
+ // skip re-measuring offsets if live-resizing\r
+ if ((!s.isMoving && !s.isResizing) || o.liveContentResizing || remeasure || m.top == undefined) {\r
+ _measure();\r
+ // if any footers are below pane-bottom, they may not measure correctly,\r
+ // so allow pane overflow and re-measure\r
+ if (m.hiddenFooters > 0 && $P.css("overflow") === "hidden") {\r
+ $P.css("overflow", "visible");\r
+ _measure(); // remeasure while overflowing\r
+ $P.css("overflow", "hidden");\r
+ }\r
+ }\r
+ // NOTE: spaceAbove/Below *includes* the pane paddingTop/Bottom, but not pane.borders\r
+ var newH = s.innerHeight - (m.spaceAbove - s.css.paddingTop) - (m.spaceBelow - s.css.paddingBottom);\r
+\r
+ if (!$C.is(":visible") || m.height != newH) {\r
+ // size the Content element to fit new pane-size - will autoHide if not enough room\r
+ setOuterHeight($C, newH, true); // true=autoHide\r
+ m.height = newH; // save new height\r
+ };\r
+\r
+ if (state.initialized)\r
+ _runCallbacks("onsizecontent_end", pane);\r
+\r
+ function _below ($E) {\r
+ return max(s.css.paddingBottom, (parseInt($E.css("marginBottom"), 10) || 0));\r
+ };\r
+\r
+ function _measure () {\r
+ var\r
+ ignore = options[pane].contentIgnoreSelector\r
+ , $Fs = $C.nextAll().not(ignore || ':lt(0)') // not :lt(0) = ALL\r
+ , $Fs_vis = $Fs.filter(':visible')\r
+ , $F = $Fs_vis.filter(':last')\r
+ ;\r
+ m = {\r
+ top: $C[0].offsetTop\r
+ , height: $C.outerHeight()\r
+ , numFooters: $Fs.length\r
+ , hiddenFooters: $Fs.length - $Fs_vis.length\r
+ , spaceBelow: 0 // correct if no content footer ($E)\r
+ }\r
+ m.spaceAbove = m.top; // just for state - not used in calc\r
+ m.bottom = m.top + m.height;\r
+ if ($F.length)\r
+ //spaceBelow = (LastFooter.top + LastFooter.height) [footerBottom] - Content.bottom + max(LastFooter.marginBottom, pane.paddingBotom)\r
+ m.spaceBelow = ($F[0].offsetTop + $F.outerHeight()) - m.bottom + _below($F);\r
+ else // no footer - check marginBottom on Content element itself\r
+ m.spaceBelow = _below($C);\r
+ };\r
+ });\r
+ }\r
+\r
+\r
+ /**\r
+ * Called every time a pane is opened, closed, or resized to slide the togglers to 'center' and adjust their length if necessary\r
+ *\r
+ * @see initHandles(), open(), close(), resizeAll()\r
+ * @param {string=} [panes=""] The pane(s) being resized\r
+ */\r
+, sizeHandles = function (evt_or_panes) {\r
+ var panes = evtPane.call(this, evt_or_panes)\r
+ panes = panes ? panes.split(",") : _c.borderPanes;\r
+\r
+ $.each(panes, function (i, pane) {\r
+ var \r
+ o = options[pane]\r
+ , s = state[pane]\r
+ , $P = $Ps[pane]\r
+ , $R = $Rs[pane]\r
+ , $T = $Ts[pane]\r
+ , $TC\r
+ ;\r
+ if (!$P || !$R) return;\r
+\r
+ var\r
+ dir = _c[pane].dir\r
+ , _state = (s.isClosed ? "_closed" : "_open")\r
+ , spacing = o["spacing"+ _state]\r
+ , togAlign = o["togglerAlign"+ _state]\r
+ , togLen = o["togglerLength"+ _state]\r
+ , paneLen\r
+ , left\r
+ , offset\r
+ , CSS = {}\r
+ ;\r
+\r
+ if (spacing === 0) {\r
+ $R.hide();\r
+ return;\r
+ }\r
+ else if (!s.noRoom && !s.isHidden) // skip if resizer was hidden for any reason\r
+ $R.show(); // in case was previously hidden\r
+\r
+ // Resizer Bar is ALWAYS same width/height of pane it is attached to\r
+ if (dir === "horz") { // north/south\r
+ //paneLen = $P.outerWidth(); // s.outerWidth || \r
+ paneLen = sC.innerWidth; // handle offscreen-panes\r
+ s.resizerLength = paneLen;\r
+ left = $.layout.cssNum($P, "left")\r
+ $R.css({\r
+ width: cssW($R, paneLen) // account for borders & padding\r
+ , height: cssH($R, spacing) // ditto\r
+ , left: left > -9999 ? left : sC.insetLeft // handle offscreen-panes\r
+ });\r
+ }\r
+ else { // east/west\r
+ paneLen = $P.outerHeight(); // s.outerHeight || \r
+ s.resizerLength = paneLen;\r
+ $R.css({\r
+ height: cssH($R, paneLen) // account for borders & padding\r
+ , width: cssW($R, spacing) // ditto\r
+ , top: sC.insetTop + getPaneSize("north", true) // TODO: what if no North pane?\r
+ //, top: $.layout.cssNum($Ps["center"], "top")\r
+ });\r
+ }\r
+\r
+ // remove hover classes\r
+ removeHover( o, $R );\r
+\r
+ if ($T) {\r
+ if (togLen === 0 || (s.isSliding && o.hideTogglerOnSlide)) {\r
+ $T.hide(); // always HIDE the toggler when 'sliding'\r
+ return;\r
+ }\r
+ else\r
+ $T.show(); // in case was previously hidden\r
+\r
+ if (!(togLen > 0) || togLen === "100%" || togLen > paneLen) {\r
+ togLen = paneLen;\r
+ offset = 0;\r
+ }\r
+ else { // calculate 'offset' based on options.PANE.togglerAlign_open/closed\r
+ if (isStr(togAlign)) {\r
+ switch (togAlign) {\r
+ case "top":\r
+ case "left": offset = 0;\r
+ break;\r
+ case "bottom":\r
+ case "right": offset = paneLen - togLen;\r
+ break;\r
+ case "middle":\r
+ case "center":\r
+ default: offset = round((paneLen - togLen) / 2); // 'default' catches typos\r
+ }\r
+ }\r
+ else { // togAlign = number\r
+ var x = parseInt(togAlign, 10); //\r
+ if (togAlign >= 0) offset = x;\r
+ else offset = paneLen - togLen + x; // NOTE: x is negative!\r
+ }\r
+ }\r
+\r
+ if (dir === "horz") { // north/south\r
+ var width = cssW($T, togLen);\r
+ $T.css({\r
+ width: width // account for borders & padding\r
+ , height: cssH($T, spacing) // ditto\r
+ , left: offset // TODO: VERIFY that toggler positions correctly for ALL values\r
+ , top: 0\r
+ });\r
+ // CENTER the toggler content SPAN\r
+ $T.children(".content").each(function(){\r
+ $TC = $(this);\r
+ $TC.css("marginLeft", round((width-$TC.outerWidth())/2)); // could be negative\r
+ });\r
+ }\r
+ else { // east/west\r
+ var height = cssH($T, togLen);\r
+ $T.css({\r
+ height: height // account for borders & padding\r
+ , width: cssW($T, spacing) // ditto\r
+ , top: offset // POSITION the toggler\r
+ , left: 0\r
+ });\r
+ // CENTER the toggler content SPAN\r
+ $T.children(".content").each(function(){\r
+ $TC = $(this);\r
+ $TC.css("marginTop", round((height-$TC.outerHeight())/2)); // could be negative\r
+ });\r
+ }\r
+\r
+ // remove ALL hover classes\r
+ removeHover( 0, $T );\r
+ }\r
+\r
+ // DONE measuring and sizing this resizer/toggler, so can be 'hidden' now\r
+ if (!state.initialized && (o.initHidden || s.noRoom)) {\r
+ $R.hide();\r
+ if ($T) $T.hide();\r
+ }\r
+ });\r
+ }\r
+\r
+\r
+ /**\r
+ * @param {string} pane\r
+ */\r
+, enableClosable = function (evt_or_pane) {\r
+ if (!isInitialized()) return;\r
+ var pane = evtPane.call(this, evt_or_pane)\r
+ , $T = $Ts[pane]\r
+ , o = options[pane]\r
+ ;\r
+ if (!$T) return;\r
+ o.closable = true;\r
+ $T .bind("click."+ sID, function(evt){ evt.stopPropagation(); toggle(pane); })\r
+ .css("visibility", "visible")\r
+ .css("cursor", "pointer")\r
+ .attr("title", state[pane].isClosed ? o.togglerTip_closed : o.togglerTip_open) // may be blank\r
+ .show();\r
+ }\r
+ /**\r
+ * @param {string} pane\r
+ * @param {boolean=} [hide=false]\r
+ */\r
+, disableClosable = function (evt_or_pane, hide) {\r
+ if (!isInitialized()) return;\r
+ var pane = evtPane.call(this, evt_or_pane)\r
+ , $T = $Ts[pane]\r
+ ;\r
+ if (!$T) return;\r
+ options[pane].closable = false;\r
+ // is closable is disable, then pane MUST be open!\r
+ if (state[pane].isClosed) open(pane, false, true);\r
+ $T .unbind("."+ sID)\r
+ .css("visibility", hide ? "hidden" : "visible") // instead of hide(), which creates logic issues\r
+ .css("cursor", "default")\r
+ .attr("title", "");\r
+ }\r
+\r
+\r
+ /**\r
+ * @param {string} pane\r
+ */\r
+, enableSlidable = function (evt_or_pane) {\r
+ if (!isInitialized()) return;\r
+ var pane = evtPane.call(this, evt_or_pane)\r
+ , $R = $Rs[pane]\r
+ ;\r
+ if (!$R || !$R.data('draggable')) return;\r
+ options[pane].slidable = true; \r
+ if (s.isClosed)\r
+ bindStartSlidingEvent(pane, true);\r
+ }\r
+ /**\r
+ * @param {string} pane\r
+ */\r
+, disableSlidable = function (evt_or_pane) {\r
+ if (!isInitialized()) return;\r
+ var pane = evtPane.call(this, evt_or_pane)\r
+ , $R = $Rs[pane]\r
+ ;\r
+ if (!$R) return;\r
+ options[pane].slidable = false; \r
+ if (state[pane].isSliding)\r
+ close(pane, false, true);\r
+ else {\r
+ bindStartSlidingEvent(pane, false);\r
+ $R .css("cursor", "default")\r
+ .attr("title", "");\r
+ removeHover(null, $R[0]); // in case currently hovered\r
+ }\r
+ }\r
+\r
+\r
+ /**\r
+ * @param {string} pane\r
+ */\r
+, enableResizable = function (evt_or_pane) {\r
+ if (!isInitialized()) return;\r
+ var pane = evtPane.call(this, evt_or_pane)\r
+ , $R = $Rs[pane]\r
+ , o = options[pane]\r
+ ;\r
+ if (!$R || !$R.data('draggable')) return;\r
+ o.resizable = true; \r
+ $R.draggable("enable");\r
+ if (!state[pane].isClosed)\r
+ $R .css("cursor", o.resizerCursor)\r
+ .attr("title", o.resizerTip);\r
+ }\r
+ /**\r
+ * @param {string} pane\r
+ */\r
+, disableResizable = function (evt_or_pane) {\r
+ if (!isInitialized()) return;\r
+ var pane = evtPane.call(this, evt_or_pane)\r
+ , $R = $Rs[pane]\r
+ ;\r
+ if (!$R || !$R.data('draggable')) return;\r
+ options[pane].resizable = false; \r
+ $R .draggable("disable")\r
+ .css("cursor", "default")\r
+ .attr("title", "");\r
+ removeHover(null, $R[0]); // in case currently hovered\r
+ }\r
+\r
+\r
+ /**\r
+ * Move a pane from source-side (eg, west) to target-side (eg, east)\r
+ * If pane exists on target-side, move that to source-side, ie, 'swap' the panes\r
+ *\r
+ * @param {string} pane1 The pane/edge being swapped\r
+ * @param {string} pane2 ditto\r
+ */\r
+, swapPanes = function (evt_or_pane1, pane2) {\r
+ if (!isInitialized()) return;\r
+ var pane1 = evtPane.call(this, evt_or_pane1);\r
+ // change state.edge NOW so callbacks can know where pane is headed...\r
+ state[pane1].edge = pane2;\r
+ state[pane2].edge = pane1;\r
+ // run these even if NOT state.initialized\r
+ if (false === _runCallbacks("onswap_start", pane1)\r
+ || false === _runCallbacks("onswap_start", pane2)\r
+ ) {\r
+ state[pane1].edge = pane1; // reset\r
+ state[pane2].edge = pane2;\r
+ return;\r
+ }\r
+\r
+ var\r
+ oPane1 = copy( pane1 )\r
+ , oPane2 = copy( pane2 )\r
+ , sizes = {}\r
+ ;\r
+ sizes[pane1] = oPane1 ? oPane1.state.size : 0;\r
+ sizes[pane2] = oPane2 ? oPane2.state.size : 0;\r
+\r
+ // clear pointers & state\r
+ $Ps[pane1] = false; \r
+ $Ps[pane2] = false;\r
+ state[pane1] = {};\r
+ state[pane2] = {};\r
+ \r
+ // ALWAYS remove the resizer & toggler elements\r
+ if ($Ts[pane1]) $Ts[pane1].remove();\r
+ if ($Ts[pane2]) $Ts[pane2].remove();\r
+ if ($Rs[pane1]) $Rs[pane1].remove();\r
+ if ($Rs[pane2]) $Rs[pane2].remove();\r
+ $Rs[pane1] = $Rs[pane2] = $Ts[pane1] = $Ts[pane2] = false;\r
+\r
+ // transfer element pointers and data to NEW Layout keys\r
+ move( oPane1, pane2 );\r
+ move( oPane2, pane1 );\r
+\r
+ // cleanup objects\r
+ oPane1 = oPane2 = sizes = null;\r
+\r
+ // make panes 'visible' again\r
+ if ($Ps[pane1]) $Ps[pane1].css(_c.visible);\r
+ if ($Ps[pane2]) $Ps[pane2].css(_c.visible);\r
+\r
+ // fix any size discrepancies caused by swap\r
+ resizeAll();\r
+\r
+ // run these even if NOT state.initialized\r
+ _runCallbacks("onswap_end", pane1);\r
+ _runCallbacks("onswap_end", pane2);\r
+\r
+ return;\r
+\r
+ function copy (n) { // n = pane\r
+ var\r
+ $P = $Ps[n]\r
+ , $C = $Cs[n]\r
+ ;\r
+ return !$P ? false : {\r
+ pane: n\r
+ , P: $P ? $P[0] : false\r
+ , C: $C ? $C[0] : false\r
+ , state: $.extend(true, {}, state[n])\r
+ , options: $.extend(true, {}, options[n])\r
+ }\r
+ };\r
+\r
+ function move (oPane, pane) {\r
+ if (!oPane) return;\r
+ var\r
+ P = oPane.P\r
+ , C = oPane.C\r
+ , oldPane = oPane.pane\r
+ , c = _c[pane]\r
+ , side = c.side.toLowerCase()\r
+ , inset = "inset"+ c.side\r
+ // save pane-options that should be retained\r
+ , s = $.extend({}, state[pane])\r
+ , o = options[pane]\r
+ // RETAIN side-specific FX Settings - more below\r
+ , fx = { resizerCursor: o.resizerCursor }\r
+ , re, size, pos\r
+ ;\r
+ $.each("fxName,fxSpeed,fxSettings".split(","), function (i, k) {\r
+ fx[k +"_open"] = o[k +"_open"];\r
+ fx[k +"_close"] = o[k +"_close"];\r
+ fx[k +"_size"] = o[k +"_size"];\r
+ });\r
+\r
+ // update object pointers and attributes\r
+ $Ps[pane] = $(P)\r
+ .data({\r
+ layoutPane: Instance[pane] // NEW pointer to pane-alias-object\r
+ , layoutEdge: pane\r
+ })\r
+ .css(_c.hidden)\r
+ .css(c.cssReq)\r
+ ;\r
+ $Cs[pane] = C ? $(C) : false;\r
+\r
+ // set options and state\r
+ options[pane] = $.extend({}, oPane.options, fx);\r
+ state[pane] = $.extend({}, oPane.state);\r
+\r
+ // change classNames on the pane, eg: ui-layout-pane-east ==> ui-layout-pane-west\r
+ re = new RegExp(o.paneClass +"-"+ oldPane, "g");\r
+ P.className = P.className.replace(re, o.paneClass +"-"+ pane);\r
+\r
+ // ALWAYS regenerate the resizer & toggler elements\r
+ initHandles(pane); // create the required resizer & toggler\r
+\r
+ // if moving to different orientation, then keep 'target' pane size\r
+ if (c.dir != _c[oldPane].dir) {\r
+ size = sizes[pane] || 0;\r
+ setSizeLimits(pane); // update pane-state\r
+ size = max(size, state[pane].minSize);\r
+ // use manualSizePane to disable autoResize - not useful after panes are swapped\r
+ manualSizePane(pane, size, true, true); // true/true = skipCallback/noAnimation\r
+ }\r
+ else // move the resizer here\r
+ $Rs[pane].css(side, sC[inset] + (state[pane].isVisible ? getPaneSize(pane) : 0));\r
+\r
+\r
+ // ADD CLASSNAMES & SLIDE-BINDINGS\r
+ if (oPane.state.isVisible && !s.isVisible)\r
+ setAsOpen(pane, true); // true = skipCallback\r
+ else {\r
+ setAsClosed(pane);\r
+ bindStartSlidingEvent(pane, true); // will enable events IF option is set\r
+ }\r
+\r
+ // DESTROY the object\r
+ oPane = null;\r
+ };\r
+ }\r
+\r
+\r
+ /**\r
+ * INTERNAL method to sync pin-buttons when pane is opened or closed\r
+ * Unpinned means the pane is 'sliding' - ie, over-top of the adjacent panes\r
+ *\r
+ * @see open(), setAsOpen(), setAsClosed()\r
+ * @param {string} pane These are the params returned to callbacks by layout()\r
+ * @param {boolean} doPin True means set the pin 'down', False means 'up'\r
+ */\r
+, syncPinBtns = function (pane, doPin) {\r
+ if ($.layout.plugins.buttons)\r
+ $.each(state[pane].pins, function (i, selector) {\r
+ $.layout.buttons.setPinState(Instance, $(selector), pane, doPin);\r
+ });\r
+ }\r
+\r
+; // END var DECLARATIONS\r
+\r
+ /**\r
+ * Capture keys when enableCursorHotkey - toggle pane if hotkey pressed\r
+ *\r
+ * @see document.keydown()\r
+ */\r
+ function keyDown (evt) {\r
+ if (!evt) return true;\r
+ var code = evt.keyCode;\r
+ if (code < 33) return true; // ignore special keys: ENTER, TAB, etc\r
+\r
+ var\r
+ PANE = {\r
+ 38: "north" // Up Cursor - $.ui.keyCode.UP\r
+ , 40: "south" // Down Cursor - $.ui.keyCode.DOWN\r
+ , 37: "west" // Left Cursor - $.ui.keyCode.LEFT\r
+ , 39: "east" // Right Cursor - $.ui.keyCode.RIGHT\r
+ }\r
+ , ALT = evt.altKey // no worky!\r
+ , SHIFT = evt.shiftKey\r
+ , CTRL = evt.ctrlKey\r
+ , CURSOR = (CTRL && code >= 37 && code <= 40)\r
+ , o, k, m, pane\r
+ ;\r
+\r
+ if (CURSOR && options[PANE[code]].enableCursorHotkey) // valid cursor-hotkey\r
+ pane = PANE[code];\r
+ else if (CTRL || SHIFT) // check to see if this matches a custom-hotkey\r
+ $.each(_c.borderPanes, function (i, p) { // loop each pane to check its hotkey\r
+ o = options[p];\r
+ k = o.customHotkey;\r
+ m = o.customHotkeyModifier; // if missing or invalid, treated as "CTRL+SHIFT"\r
+ if ((SHIFT && m=="SHIFT") || (CTRL && m=="CTRL") || (CTRL && SHIFT)) { // Modifier matches\r
+ if (k && code === (isNaN(k) || k <= 9 ? k.toUpperCase().charCodeAt(0) : k)) { // Key matches\r
+ pane = p;\r
+ return false; // BREAK\r
+ }\r
+ }\r
+ });\r
+\r
+ // validate pane\r
+ if (!pane || !$Ps[pane] || !options[pane].closable || state[pane].isHidden)\r
+ return true;\r
+\r
+ toggle(pane);\r
+\r
+ evt.stopPropagation();\r
+ evt.returnValue = false; // CANCEL key\r
+ return false;\r
+ };\r
+\r
+\r
+/*\r
+ * ######################################\r
+ * UTILITY METHODS\r
+ * called externally or by initButtons\r
+ * ######################################\r
+ */\r
+\r
+ /**\r
+ * Change/reset a pane overflow setting & zIndex to allow popups/drop-downs to work\r
+ *\r
+ * @param {Object=} [el] (optional) Can also be 'bound' to a click, mouseOver, or other event\r
+ */\r
+ function allowOverflow (el) {\r
+ if (!isInitialized()) return;\r
+ if (this && this.tagName) el = this; // BOUND to element\r
+ var $P;\r
+ if (isStr(el))\r
+ $P = $Ps[el];\r
+ else if ($(el).data("layoutRole"))\r
+ $P = $(el);\r
+ else\r
+ $(el).parents().each(function(){\r
+ if ($(this).data("layoutRole")) {\r
+ $P = $(this);\r
+ return false; // BREAK\r
+ }\r
+ });\r
+ if (!$P || !$P.length) return; // INVALID\r
+\r
+ var\r
+ pane = $P.data("layoutEdge")\r
+ , s = state[pane]\r
+ ;\r
+\r
+ // if pane is already raised, then reset it before doing it again!\r
+ // this would happen if allowOverflow is attached to BOTH the pane and an element \r
+ if (s.cssSaved)\r
+ resetOverflow(pane); // reset previous CSS before continuing\r
+\r
+ // if pane is raised by sliding or resizing, or its closed, then abort\r
+ if (s.isSliding || s.isResizing || s.isClosed) {\r
+ s.cssSaved = false;\r
+ return;\r
+ }\r
+\r
+ var\r
+ newCSS = { zIndex: (options.zIndexes.resizer_normal + 1) }\r
+ , curCSS = {}\r
+ , of = $P.css("overflow")\r
+ , ofX = $P.css("overflowX")\r
+ , ofY = $P.css("overflowY")\r
+ ;\r
+ // determine which, if any, overflow settings need to be changed\r
+ if (of != "visible") {\r
+ curCSS.overflow = of;\r
+ newCSS.overflow = "visible";\r
+ }\r
+ if (ofX && !ofX.match(/visible|auto/)) {\r
+ curCSS.overflowX = ofX;\r
+ newCSS.overflowX = "visible";\r
+ }\r
+ if (ofY && !ofY.match(/visible|auto/)) {\r
+ curCSS.overflowY = ofX;\r
+ newCSS.overflowY = "visible";\r
+ }\r
+\r
+ // save the current overflow settings - even if blank!\r
+ s.cssSaved = curCSS;\r
+\r
+ // apply new CSS to raise zIndex and, if necessary, make overflow 'visible'\r
+ $P.css( newCSS );\r
+\r
+ // make sure the zIndex of all other panes is normal\r
+ $.each(_c.allPanes, function(i, p) {\r
+ if (p != pane) resetOverflow(p);\r
+ });\r
+\r
+ };\r
+ /**\r
+ * @param {Object=} [el] (optional) Can also be 'bound' to a click, mouseOver, or other event\r
+ */\r
+ function resetOverflow (el) {\r
+ if (!isInitialized()) return;\r
+ if (this && this.tagName) el = this; // BOUND to element\r
+ var $P;\r
+ if (isStr(el))\r
+ $P = $Ps[el];\r
+ else if ($(el).data("layoutRole"))\r
+ $P = $(el);\r
+ else\r
+ $(el).parents().each(function(){\r
+ if ($(this).data("layoutRole")) {\r
+ $P = $(this);\r
+ return false; // BREAK\r
+ }\r
+ });\r
+ if (!$P || !$P.length) return; // INVALID\r
+\r
+ var\r
+ pane = $P.data("layoutEdge")\r
+ , s = state[pane]\r
+ , CSS = s.cssSaved || {}\r
+ ;\r
+ // reset the zIndex\r
+ if (!s.isSliding && !s.isResizing)\r
+ $P.css("zIndex", options.zIndexes.pane_normal);\r
+\r
+ // reset Overflow - if necessary\r
+ $P.css( CSS );\r
+\r
+ // clear var\r
+ s.cssSaved = false;\r
+ };\r
+\r
+/*\r
+ * #####################\r
+ * CREATE/RETURN LAYOUT\r
+ * #####################\r
+ */\r
+\r
+ // validate that container exists\r
+ var $N = $(this).eq(0); // FIRST matching Container element\r
+ if (!$N.length) {\r
+ if (options.showErrorMessages)\r
+ _log( lang.errContainerMissing, true );\r
+ return null;\r
+ };\r
+\r
+ // Users retrieve Instance of a layout with: $N.layout() OR $N.data("layout")\r
+ // return the Instance-pointer if layout has already been initialized\r
+ if ($N.data("layoutContainer") && $N.data("layout"))\r
+ return $N.data("layout"); // cached pointer\r
+\r
+ // init global vars\r
+ var \r
+ $Ps = {} // Panes x5 - set in initPanes()\r
+ , $Cs = {} // Content x5 - set in initPanes()\r
+ , $Rs = {} // Resizers x4 - set in initHandles()\r
+ , $Ts = {} // Togglers x4 - set in initHandles()\r
+ , $Ms = $([]) // Masks - up to 2 masks per pane (IFRAME + DIV)\r
+ // aliases for code brevity\r
+ , sC = state.container // alias for easy access to 'container dimensions'\r
+ , sID = state.id // alias for unique layout ID/namespace - eg: "layout435"\r
+ ;\r
+\r
+ // create Instance object to expose data & option Properties, and primary action Methods\r
+ var Instance = {\r
+ // layout data\r
+ options: options // property - options hash\r
+ , state: state // property - dimensions hash\r
+ // object pointers\r
+ , container: $N // property - object pointers for layout container\r
+ , panes: $Ps // property - object pointers for ALL Panes: panes.north, panes.center\r
+ , contents: $Cs // property - object pointers for ALL Content: contents.north, contents.center\r
+ , resizers: $Rs // property - object pointers for ALL Resizers, eg: resizers.north\r
+ , togglers: $Ts // property - object pointers for ALL Togglers, eg: togglers.north\r
+ // border-pane open/close\r
+ , hide: hide // method - ditto\r
+ , show: show // method - ditto\r
+ , toggle: toggle // method - pass a 'pane' ("north", "west", etc)\r
+ , open: open // method - ditto\r
+ , close: close // method - ditto\r
+ , slideOpen: slideOpen // method - ditto\r
+ , slideClose: slideClose // method - ditto\r
+ , slideToggle: slideToggle // method - ditto\r
+ // pane actions\r
+ , setSizeLimits: setSizeLimits // method - pass a 'pane' - update state min/max data\r
+ , _sizePane: sizePane // method -intended for user by plugins only!\r
+ , sizePane: manualSizePane // method - pass a 'pane' AND an 'outer-size' in pixels or percent, or 'auto'\r
+ , sizeContent: sizeContent // method - pass a 'pane'\r
+ , swapPanes: swapPanes // method - pass TWO 'panes' - will swap them\r
+ // pane element methods\r
+ , initContent: initContent // method - ditto\r
+ , addPane: addPane // method - pass a 'pane'\r
+ , removePane: removePane // method - pass a 'pane' to remove from layout, add 'true' to delete the pane-elem\r
+ , createChildLayout: createChildLayout// method - pass a 'pane' and (optional) layout-options (OVERRIDES options[pane].childOptions\r
+ // special pane option setting\r
+ , enableClosable: enableClosable // method - pass a 'pane'\r
+ , disableClosable: disableClosable // method - ditto\r
+ , enableSlidable: enableSlidable // method - ditto\r
+ , disableSlidable: disableSlidable // method - ditto\r
+ , enableResizable: enableResizable // method - ditto\r
+ , disableResizable: disableResizable// method - ditto\r
+ // utility methods for panes\r
+ , allowOverflow: allowOverflow // utility - pass calling element (this)\r
+ , resetOverflow: resetOverflow // utility - ditto\r
+ // layout control\r
+ , destroy: destroy // method - no parameters\r
+ , initPanes: isInitialized // method - no parameters\r
+ , resizeAll: resizeAll // method - no parameters\r
+ // callback triggering\r
+ , runCallbacks: _runCallbacks // method - pass evtName & pane (if a pane-event), eg: trigger("onopen", "west")\r
+ // alias collections of options, state and children - created in addPane and extended elsewhere\r
+ , hasParentLayout: false // set by initContainer()\r
+ , children: children // pointers to child-layouts, eg: Instance.children["west"]\r
+ , north: false // alias group: { name: pane, pane: $Ps[pane], options: options[pane], state: state[pane], child: children[pane] }\r
+ , south: false // ditto\r
+ , west: false // ditto\r
+ , east: false // ditto\r
+ , center: false // ditto\r
+ };\r
+\r
+ // create the border layout NOW\r
+ if (_create() === 'cancel') // onload_start callback returned false to CANCEL layout creation\r
+ return null;\r
+ else // true OR false -- if layout-elements did NOT init (hidden or do not exist), can auto-init later\r
+ return Instance; // return the Instance object\r
+\r
+}\r
+\r
+\r
+\r
+\r
+/**\r
+ * jquery.layout.state 1.0\r
+ * $Date: 2011-07-16 08:00:00 (Sat, 16 July 2011) $\r
+ *\r
+ * Copyright (c) 2010 \r
+ * Kevin Dalman (http://allpro.net)\r
+ *\r
+ * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html)\r
+ * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses.\r
+ *\r
+ * @dependancies: UI Layout 1.3.0.rc30.1 or higher\r
+ * @dependancies: $.ui.cookie (above)\r
+ *\r
+ * @support: http://groups.google.com/group/jquery-ui-layout\r
+ */\r
+/*\r
+ * State-management options stored in options.stateManagement, which includes a .cookie hash\r
+ * Default options saves ALL KEYS for ALL PANES, ie: pane.size, pane.isClosed, pane.isHidden\r
+ *\r
+ * // STATE/COOKIE OPTIONS\r
+ * @example $(el).layout({\r
+ stateManagement: {\r
+ enabled: true\r
+ , stateKeys: "east.size,west.size,east.isClosed,west.isClosed"\r
+ , cookie: { name: "appLayout", path: "/" }\r
+ }\r
+ })\r
+ * @example $(el).layout({ stateManagement__enabled: true }) // enable auto-state-management using cookies\r
+ * @example $(el).layout({ stateManagement__cookie: { name: "appLayout", path: "/" } })\r
+ * @example $(el).layout({ stateManagement__cookie__name: "appLayout", stateManagement__cookie__path: "/" })\r
+ *\r
+ * // STATE/COOKIE METHODS\r
+ * @example myLayout.saveCookie( "west.isClosed,north.size,south.isHidden", {expires: 7} );\r
+ * @example myLayout.loadCookie();\r
+ * @example myLayout.deleteCookie();\r
+ * @example var JSON = myLayout.readState(); // CURRENT Layout State\r
+ * @example var JSON = myLayout.readCookie(); // SAVED Layout State (from cookie)\r
+ * @example var JSON = myLayout.state.stateData; // LAST LOADED Layout State (cookie saved in layout.state hash)\r
+ *\r
+ * CUSTOM STATE-MANAGEMENT (eg, saved in a database)\r
+ * @example var JSON = myLayout.readState( "west.isClosed,north.size,south.isHidden" );\r
+ * @example myLayout.loadState( JSON );\r
+ */\r
+\r
+/**\r
+ * UI COOKIE UTILITY\r
+ *\r
+ * A $.cookie OR $.ui.cookie namespace *should be standard*, but until then...\r
+ * This creates $.ui.cookie so Layout does not need the cookie.jquery.js plugin\r
+ * NOTE: This utility is REQUIRED by the layout.state plugin\r
+ *\r
+ * Cookie methods in Layout are created as part of State Management \r
+ */\r
+if (!$.ui) $.ui = {};\r
+$.ui.cookie = {\r
+\r
+ // cookieEnabled is not in DOM specs, but DOES works in all browsers,including IE6\r
+ acceptsCookies: !!navigator.cookieEnabled\r
+\r
+, read: function (name) {\r
+ var\r
+ c = document.cookie\r
+ , cs = c ? c.split(';') : []\r
+ , pair // loop var\r
+ ;\r
+ for (var i=0, n=cs.length; i < n; i++) {\r
+ pair = $.trim(cs[i]).split('='); // name=value pair\r
+ if (pair[0] == name) // found the layout cookie\r
+ return decodeURIComponent(pair[1]);\r
+\r
+ }\r
+ return null;\r
+ }\r
+\r
+, write: function (name, val, cookieOpts) {\r
+ var\r
+ params = ''\r
+ , date = ''\r
+ , clear = false\r
+ , o = cookieOpts || {}\r
+ , x = o.expires\r
+ ;\r
+ if (x && x.toUTCString)\r
+ date = x;\r
+ else if (x === null || typeof x === 'number') {\r
+ date = new Date();\r
+ if (x > 0)\r
+ date.setDate(date.getDate() + x);\r
+ else {\r
+ date.setFullYear(1970);\r
+ clear = true;\r
+ }\r
+ }\r
+ if (date) params += ';expires='+ date.toUTCString();\r
+ if (o.path) params += ';path='+ o.path;\r
+ if (o.domain) params += ';domain='+ o.domain;\r
+ if (o.secure) params += ';secure';\r
+ document.cookie = name +'='+ (clear ? "" : encodeURIComponent( val )) + params; // write or clear cookie\r
+ }\r
+\r
+, clear: function (name) {\r
+ $.ui.cookie.write(name, '', {expires: -1});\r
+ }\r
+\r
+};\r
+// if cookie.jquery.js is not loaded, create an alias to replicate it\r
+// this may be useful to other plugins or code dependent on that plugin\r
+if (!$.cookie) $.cookie = function (k, v, o) {\r
+ var C = $.ui.cookie;\r
+ if (v === null)\r
+ C.clear(k);\r
+ else if (v === undefined)\r
+ return C.read(k);\r
+ else\r
+ C.write(k, v, o);\r
+};\r
+\r
+\r
+// tell Layout that the state plugin is available\r
+$.layout.plugins.stateManagement = true;\r
+\r
+// Add State-Management options to layout.defaults\r
+$.layout.config.optionRootKeys.push("stateManagement");\r
+$.layout.defaults.stateManagement = {\r
+ enabled: false // true = enable state-management, even if not using cookies\r
+, autoSave: true // Save a state-cookie when page exits?\r
+, autoLoad: true // Load the state-cookie when Layout inits?\r
+ // List state-data to save - must be pane-specific\r
+, stateKeys: "north.size,south.size,east.size,west.size,"+\r
+ "north.isClosed,south.isClosed,east.isClosed,west.isClosed,"+\r
+ "north.isHidden,south.isHidden,east.isHidden,west.isHidden"\r
+, cookie: {\r
+ name: "" // If not specified, will use Layout.name, else just "Layout"\r
+ , domain: "" // blank = current domain\r
+ , path: "" // blank = current page, '/' = entire website\r
+ , expires: "" // 'days' to keep cookie - leave blank for 'session cookie'\r
+ , secure: false\r
+ }\r
+};\r
+// Set stateManagement as a layout-option, NOT a pane-option\r
+$.layout.optionsMap.layout.push("stateManagement");\r
+\r
+/*\r
+ * State Management methods\r
+ */\r
+$.layout.state = {\r
+\r
+ /**\r
+ * Get the current layout state and save it to a cookie\r
+ *\r
+ * myLayout.saveCookie( keys, cookieOpts )\r
+ *\r
+ * @param {Object} inst\r
+ * @param {(string|Array)=} keys\r
+ * @param {Object=} opts\r
+ */\r
+ saveCookie: function (inst, keys, cookieOpts) {\r
+ var o = inst.options\r
+ , oS = o.stateManagement\r
+ , oC = $.extend(true, {}, oS.cookie, cookieOpts || null)\r
+ , data = inst.state.stateData = inst.readState( keys || oS.stateKeys ) // read current panes-state\r
+ ;\r
+ $.ui.cookie.write( oC.name || o.name || "Layout", $.layout.state.encodeJSON(data), oC );\r
+ return $.extend(true, {}, data); // return COPY of state.stateData data\r
+ }\r
+\r
+ /**\r
+ * Remove the state cookie\r
+ *\r
+ * @param {Object} inst\r
+ */\r
+, deleteCookie: function (inst) {\r
+ var o = inst.options;\r
+ $.ui.cookie.clear( o.stateManagement.cookie.name || o.name || "Layout" );\r
+ }\r
+\r
+ /**\r
+ * Read & return data from the cookie - as JSON\r
+ *\r
+ * @param {Object} inst\r
+ */\r
+, readCookie: function (inst) {\r
+ var o = inst.options;\r
+ var c = $.ui.cookie.read( o.stateManagement.cookie.name || o.name || "Layout" );\r
+ // convert cookie string back to a hash and return it\r
+ return c ? $.layout.state.decodeJSON(c) : {};\r
+ }\r
+\r
+ /**\r
+ * Get data from the cookie and USE IT to loadState\r
+ *\r
+ * @param {Object} inst\r
+ */\r
+, loadCookie: function (inst) {\r
+ var c = $.layout.state.readCookie(inst); // READ the cookie\r
+ if (c) {\r
+ inst.state.stateData = $.extend(true, {}, c); // SET state.stateData\r
+ inst.loadState(c); // LOAD the retrieved state\r
+ }\r
+ return c;\r
+ }\r
+ \r
+ /**\r
+ * Update layout options from the cookie, if one exists\r
+ *\r
+ * @param {Object} inst\r
+ * @param {Object=} stateData\r
+ * @param {boolean=} animate\r
+ */\r
+, loadState: function (inst, stateData, animate) {\r
+ stateData = $.layout.transformData( stateData ); // panes = default subkey\r
+ if ($.isEmptyObject( stateData )) return;\r
+ $.extend(true, inst.options, stateData); // update layout options\r
+ // if layout has already been initialized, then UPDATE layout state\r
+ if (inst.state.initialized) {\r
+ var pane, vis, o, s, h, c\r
+ , noAnimate = (animate===false)\r
+ ;\r
+ $.each($.layout.config.borderPanes, function (idx, pane) {\r
+ state = inst.state[pane];\r
+ o = stateData[ pane ];\r
+ if (typeof o != 'object') return; // no key, continue\r
+ s = o.size;\r
+ c = o.initClosed;\r
+ h = o.initHidden;\r
+ vis = state.isVisible;\r
+ // resize BEFORE opening\r
+ if (!vis)\r
+ inst.sizePane(pane, s, false, false);\r
+ if (h === true) inst.hide(pane, noAnimate);\r
+ else if (c === false) inst.open (pane, false, noAnimate);\r
+ else if (c === true) inst.close(pane, false, noAnimate);\r
+ else if (h === false) inst.show (pane, false, noAnimate);\r
+ // resize AFTER any other actions\r
+ if (vis)\r
+ inst.sizePane(pane, s, false, noAnimate); // animate resize if option passed\r
+ });\r
+ };\r
+ }\r
+\r
+ /**\r
+ * Get the *current layout state* and return it as a hash\r
+ *\r
+ * @param {Object=} inst\r
+ * @param {(string|Array)=} keys\r
+ */\r
+, readState: function (inst, keys) {\r
+ var\r
+ data = {}\r
+ , alt = { isClosed: 'initClosed', isHidden: 'initHidden' }\r
+ , state = inst.state\r
+ , panes = $.layout.config.allPanes\r
+ , pair, pane, key, val\r
+ ;\r
+ if (!keys) keys = inst.options.stateManagement.stateKeys; // if called by user\r
+ if ($.isArray(keys)) keys = keys.join(",");\r
+ // convert keys to an array and change delimiters from '__' to '.'\r
+ keys = keys.replace(/__/g, ".").split(',');\r
+ // loop keys and create a data hash\r
+ for (var i=0, n=keys.length; i < n; i++) {\r
+ pair = keys[i].split(".");\r
+ pane = pair[0];\r
+ key = pair[1];\r
+ if ($.inArray(pane, panes) < 0) continue; // bad pane!\r
+ val = state[ pane ][ key ];\r
+ if (val == undefined) continue;\r
+ if (key=="isClosed" && state[pane]["isSliding"])\r
+ val = true; // if sliding, then *really* isClosed\r
+ ( data[pane] || (data[pane]={}) )[ alt[key] ? alt[key] : key ] = val;\r
+ }\r
+ return data;\r
+ }\r
+\r
+ /**\r
+ * Stringify a JSON hash so can save in a cookie or db-field\r
+ */\r
+, encodeJSON: function (JSON) {\r
+ return parse(JSON);\r
+ function parse (h) {\r
+ var D=[], i=0, k, v, t; // k = key, v = value\r
+ for (k in h) {\r
+ v = h[k];\r
+ t = typeof v;\r
+ if (t == 'string') // STRING - add quotes\r
+ v = '"'+ v +'"';\r
+ else if (t == 'object') // SUB-KEY - recurse into it\r
+ v = parse(v);\r
+ D[i++] = '"'+ k +'":'+ v;\r
+ }\r
+ return '{'+ D.join(',') +'}';\r
+ };\r
+ }\r
+\r
+ /**\r
+ * Convert stringified JSON back to a hash object\r
+ * @see $.parseJSON(), adding in jQuery 1.4.1\r
+ */\r
+, decodeJSON: function (str) {\r
+ try { return $.parseJSON ? $.parseJSON(str) : window["eval"]("("+ str +")") || {}; }\r
+ catch (e) { return {}; }\r
+ }\r
+\r
+\r
+, _create: function (inst) {\r
+ var _ = $.layout.state;\r
+ // ADD State-Management plugin methods to inst\r
+ $.extend( inst, {\r
+ // readCookie - update options from cookie - returns hash of cookie data\r
+ readCookie: function () { return _.readCookie(inst); }\r
+ // deleteCookie\r
+ , deleteCookie: function () { _.deleteCookie(inst); }\r
+ // saveCookie - optionally pass keys-list and cookie-options (hash)\r
+ , saveCookie: function (keys, cookieOpts) { return _.saveCookie(inst, keys, cookieOpts); }\r
+ // loadCookie - readCookie and use to loadState() - returns hash of cookie data\r
+ , loadCookie: function () { return _.loadCookie(inst); }\r
+ // loadState - pass a hash of state to use to update options\r
+ , loadState: function (stateData, animate) { _.loadState(inst, stateData, animate); }\r
+ // readState - returns hash of current layout-state\r
+ , readState: function (keys) { return _.readState(inst, keys); }\r
+ // add JSON utility methods too...\r
+ , encodeJSON: _.encodeJSON\r
+ , decodeJSON: _.decodeJSON\r
+ });\r
+\r
+ // init state.stateData key, even if plugin is initially disabled\r
+ inst.state.stateData = {};\r
+\r
+ // read and load cookie-data per options\r
+ var oS = inst.options.stateManagement;\r
+ if (oS.enabled) {\r
+ if (oS.autoLoad) // update the options from the cookie\r
+ inst.loadCookie();\r
+ else // don't modify options - just store cookie data in state.stateData\r
+ inst.state.stateData = inst.readCookie();\r
+ }\r
+ }\r
+\r
+, _unload: function (inst) {\r
+ var oS = inst.options.stateManagement;\r
+ if (oS.enabled) {\r
+ if (oS.autoSave) // save a state-cookie automatically\r
+ inst.saveCookie();\r
+ else // don't save a cookie, but do store state-data in state.stateData key\r
+ inst.state.stateData = inst.readState();\r
+ }\r
+ }\r
+\r
+};\r
+\r
+// add state initialization method to Layout's onCreate array of functions\r
+$.layout.onCreate.push( $.layout.state._create );\r
+$.layout.onUnload.push( $.layout.state._unload );\r
+\r
+\r
+\r
+\r
+/**\r
+ * jquery.layout.buttons 1.0\r
+ * $Date: 2011-07-16 08:00:00 (Sat, 16 July 2011) $\r
+ *\r
+ * Copyright (c) 2010 \r
+ * Kevin Dalman (http://allpro.net)\r
+ *\r
+ * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html)\r
+ * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses.\r
+ *\r
+ * @dependancies: UI Layout 1.3.0.rc30.1 or higher\r
+ *\r
+ * @support: http://groups.google.com/group/jquery-ui-layout\r
+ *\r
+ * Docs: [ to come ]\r
+ * Tips: [ to come ]\r
+ */\r
+\r
+// tell Layout that the state plugin is available\r
+$.layout.plugins.buttons = true;\r
+\r
+// Add buttons options to layout.defaults\r
+$.layout.defaults.autoBindCustomButtons = false;\r
+// Specify autoBindCustomButtons as a layout-option, NOT a pane-option\r
+$.layout.optionsMap.layout.push("autoBindCustomButtons");\r
+\r
+var lang = $.layout.language;\r
+\r
+/*\r
+ * Button methods\r
+ */\r
+$.layout.buttons = {\r
+\r
+ /**\r
+ * Searches for .ui-layout-button-xxx elements and auto-binds them as layout-buttons\r
+ *\r
+ * @see _create()\r
+ *\r
+ * @param {Object} inst Layout Instance object\r
+ */\r
+ init: function (inst) {\r
+ var pre = "ui-layout-button-"\r
+ , layout = inst.options.name || ""\r
+ , name;\r
+ $.each("toggle,open,close,pin,toggle-slide,open-slide".split(","), function (i, action) {\r
+ $.each($.layout.config.borderPanes, function (ii, pane) {\r
+ $("."+pre+action+"-"+pane).each(function(){\r
+ // if button was previously 'bound', data.layoutName was set, but is blank if layout has no 'name'\r
+ name = $(this).data("layoutName") || $(this).attr("layoutName");\r
+ if (name == undefined || name === layout)\r
+ inst.bindButton(this, action, pane);\r
+ });\r
+ });\r
+ });\r
+ }\r
+\r
+ /**\r
+ * Helper function to validate params received by addButton utilities\r
+ *\r
+ * Two classes are added to the element, based on the buttonClass...\r
+ * The type of button is appended to create the 2nd className:\r
+ * - ui-layout-button-pin // action btnClass\r
+ * - ui-layout-button-pin-west // action btnClass + pane\r
+ * - ui-layout-button-toggle\r
+ * - ui-layout-button-open\r
+ * - ui-layout-button-close\r
+ *\r
+ * @param {Object} inst Layout Instance object\r
+ * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"\r
+ * @param {string} pane Name of the pane the button is for: 'north', 'south', etc.\r
+ *\r
+ * @return {Array.<Object>} If both params valid, the element matching 'selector' in a jQuery wrapper - otherwise returns null\r
+ */\r
+, get: function (inst, selector, pane, action) {\r
+ var $E = $(selector)\r
+ , o = inst.options\r
+ , err = o.showErrorMessages\r
+ ;\r
+ if (!$E.length) { // element not found\r
+ if (err) $.layout.msg(lang.errButton + lang.selector +": "+ selector, true);\r
+ }\r
+ else if ($.inArray(pane, $.layout.config.borderPanes) < 0) { // invalid 'pane' sepecified\r
+ if (err) $.layout.msg(lang.errButton + lang.pane +": "+ pane, true);\r
+ $E = $(""); // NO BUTTON\r
+ }\r
+ else { // VALID\r
+ var btn = o[pane].buttonClass +"-"+ action;\r
+ $E .addClass( btn +" "+ btn +"-"+ pane )\r
+ .data("layoutName", o.name); // add layout identifier - even if blank!\r
+ }\r
+ return $E;\r
+ }\r
+\r
+\r
+ /**\r
+ * NEW syntax for binding layout-buttons - will eventually replace addToggle, addOpen, etc.\r
+ *\r
+ * @param {Object} inst Layout Instance object\r
+ * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"\r
+ * @param {string} action\r
+ * @param {string} pane\r
+ */\r
+, bind: function (inst, selector, action, pane) {\r
+ var _ = $.layout.buttons;\r
+ switch (action.toLowerCase()) {\r
+ case "toggle": _.addToggle (inst, selector, pane); break; \r
+ case "open": _.addOpen (inst, selector, pane); break;\r
+ case "close": _.addClose (inst, selector, pane); break;\r
+ case "pin": _.addPin (inst, selector, pane); break;\r
+ case "toggle-slide": _.addToggle (inst, selector, pane, true); break; \r
+ case "open-slide": _.addOpen (inst, selector, pane, true); break;\r
+ }\r
+ return inst;\r
+ }\r
+\r
+ /**\r
+ * Add a custom Toggler button for a pane\r
+ *\r
+ * @param {Object} inst Layout Instance object\r
+ * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"\r
+ * @param {string} pane Name of the pane the button is for: 'north', 'south', etc.\r
+ * @param {boolean=} slide true = slide-open, false = pin-open\r
+ */\r
+, addToggle: function (inst, selector, pane, slide) {\r
+ $.layout.buttons.get(inst, selector, pane, "toggle")\r
+ .click(function(evt){\r
+ inst.toggle(pane, !!slide);\r
+ evt.stopPropagation();\r
+ });\r
+ return inst;\r
+ }\r
+\r
+ /**\r
+ * Add a custom Open button for a pane\r
+ *\r
+ * @param {Object} inst Layout Instance object\r
+ * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"\r
+ * @param {string} pane Name of the pane the button is for: 'north', 'south', etc.\r
+ * @param {boolean=} slide true = slide-open, false = pin-open\r
+ */\r
+, addOpen: function (inst, selector, pane, slide) {\r
+ $.layout.buttons.get(inst, selector, pane, "open")\r
+ .attr("title", lang.Open)\r
+ .click(function (evt) {\r
+ inst.open(pane, !!slide);\r
+ evt.stopPropagation();\r
+ });\r
+ return inst;\r
+ }\r
+\r
+ /**\r
+ * Add a custom Close button for a pane\r
+ *\r
+ * @param {Object} inst Layout Instance object\r
+ * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"\r
+ * @param {string} pane Name of the pane the button is for: 'north', 'south', etc.\r
+ */\r
+, addClose: function (inst, selector, pane) {\r
+ $.layout.buttons.get(inst, selector, pane, "close")\r
+ .attr("title", lang.Close)\r
+ .click(function (evt) {\r
+ inst.close(pane);\r
+ evt.stopPropagation();\r
+ });\r
+ return inst;\r
+ }\r
+\r
+ /**\r
+ * Add a custom Pin button for a pane\r
+ *\r
+ * Four classes are added to the element, based on the paneClass for the associated pane...\r
+ * Assuming the default paneClass and the pin is 'up', these classes are added for a west-pane pin:\r
+ * - ui-layout-pane-pin\r
+ * - ui-layout-pane-west-pin\r
+ * - ui-layout-pane-pin-up\r
+ * - ui-layout-pane-west-pin-up\r
+ *\r
+ * @param {Object} inst Layout Instance object\r
+ * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"\r
+ * @param {string} pane Name of the pane the pin is for: 'north', 'south', etc.\r
+ */\r
+, addPin: function (inst, selector, pane) {\r
+ var _ = $.layout.buttons\r
+ , $E = _.get(inst, selector, pane, "pin");\r
+ if ($E.length) {\r
+ var s = inst.state[pane];\r
+ $E.click(function (evt) {\r
+ _.setPinState(inst, $(this), pane, (s.isSliding || s.isClosed));\r
+ if (s.isSliding || s.isClosed) inst.open( pane ); // change from sliding to open\r
+ else inst.close( pane ); // slide-closed\r
+ evt.stopPropagation();\r
+ });\r
+ // add up/down pin attributes and classes\r
+ _.setPinState(inst, $E, pane, (!s.isClosed && !s.isSliding));\r
+ // add this pin to the pane data so we can 'sync it' automatically\r
+ // PANE.pins key is an array so we can store multiple pins for each pane\r
+ s.pins.push( selector ); // just save the selector string\r
+ }\r
+ return inst;\r
+ }\r
+\r
+ /**\r
+ * Change the class of the pin button to make it look 'up' or 'down'\r
+ *\r
+ * @see addPin(), syncPins()\r
+ *\r
+ * @param {Object} inst Layout Instance object\r
+ * @param {Array.<Object>} $Pin The pin-span element in a jQuery wrapper\r
+ * @param {string} pane These are the params returned to callbacks by layout()\r
+ * @param {boolean} doPin true = set the pin 'down', false = set it 'up'\r
+ */\r
+, setPinState: function (inst, $Pin, pane, doPin) {\r
+ var updown = $Pin.attr("pin");\r
+ if (updown && doPin === (updown=="down")) return; // already in correct state\r
+ var\r
+ pin = inst.options[pane].buttonClass +"-pin"\r
+ , side = pin +"-"+ pane\r
+ , UP = pin +"-up "+ side +"-up"\r
+ , DN = pin +"-down "+side +"-down"\r
+ ;\r
+ $Pin\r
+ .attr("pin", doPin ? "down" : "up") // logic\r
+ .attr("title", doPin ? lang.Unpin : lang.Pin)\r
+ .removeClass( doPin ? UP : DN ) \r
+ .addClass( doPin ? DN : UP ) \r
+ ;\r
+ }\r
+\r
+ /**\r
+ * INTERNAL function to sync 'pin buttons' when pane is opened or closed\r
+ * Unpinned means the pane is 'sliding' - ie, over-top of the adjacent panes\r
+ *\r
+ * @see open(), close()\r
+ *\r
+ * @param {Object} inst Layout Instance object\r
+ * @param {string} pane These are the params returned to callbacks by layout()\r
+ * @param {boolean} doPin True means set the pin 'down', False means 'up'\r
+ */\r
+, syncPinBtns: function (inst, pane, doPin) {\r
+ // REAL METHOD IS _INSIDE_ LAYOUT - THIS IS HERE JUST FOR REFERENCE\r
+ $.each(state[pane].pins, function (i, selector) {\r
+ $.layout.buttons.setPinState(inst, $(selector), pane, doPin);\r
+ });\r
+ }\r
+\r
+\r
+, _load: function (inst) {\r
+ var _ = $.layout.buttons;\r
+ // ADD Button methods to Layout Instance\r
+ // Note: sel = jQuery Selector string\r
+ $.extend( inst, {\r
+ bindButton: function (sel, action, pane) { return _.bind(inst, sel, action, pane); }\r
+ // DEPRECATED METHODS\r
+ , addToggleBtn: function (sel, pane, slide) { return _.addToggle(inst, sel, pane, slide); }\r
+ , addOpenBtn: function (sel, pane, slide) { return _.addOpen(inst, sel, pane, slide); }\r
+ , addCloseBtn: function (sel, pane) { return _.addClose(inst, sel, pane); }\r
+ , addPinBtn: function (sel, pane) { return _.addPin(inst, sel, pane); }\r
+ });\r
+\r
+ // init state array to hold pin-buttons\r
+ for (var i=0; i<4; i++) {\r
+ var pane = $.layout.config.borderPanes[i];\r
+ inst.state[pane].pins = [];\r
+ }\r
+\r
+ // auto-init buttons onLoad if option is enabled\r
+ if ( inst.options.autoBindCustomButtons )\r
+ _.init(inst);\r
+ }\r
+\r
+, _unload: function (inst) {\r
+ // TODO: unbind all buttons???\r
+ }\r
+\r
+};\r
+\r
+// add initialization method to Layout's onLoad array of functions\r
+$.layout.onLoad.push( $.layout.buttons._load );\r
+//$.layout.onUnload.push( $.layout.buttons._unload );\r
+\r
+\r
+\r
+/**\r
+ * jquery.layout.browserZoom 1.0\r
+ * $Date: 2011-12-29 08:00:00 (Thu, 29 Dec 2011) $\r
+ *\r
+ * Copyright (c) 2012 \r
+ * Kevin Dalman (http://allpro.net)\r
+ *\r
+ * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html)\r
+ * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses.\r
+ *\r
+ * @dependancies: UI Layout 1.3.0.rc30.1 or higher\r
+ *\r
+ * @support: http://groups.google.com/group/jquery-ui-layout\r
+ *\r
+ * @todo: Extend logic to handle other problematic zooming in browsers\r
+ * @todo: Add hotkey/mousewheel bindings to _instantly_ respond to these zoom event\r
+ */\r
+\r
+// tell Layout that the plugin is available\r
+$.layout.plugins.browserZoom = true;\r
+\r
+$.layout.defaults.browserZoomCheckInterval = 1000;\r
+$.layout.optionsMap.layout.push("browserZoomCheckInterval");\r
+\r
+/*\r
+ * browserZoom methods\r
+ */\r
+$.layout.browserZoom = {\r
+\r
+ _init: function (inst) {\r
+ // abort if browser does not need this check\r
+ if ($.layout.browserZoom.ratio() !== false)\r
+ $.layout.browserZoom._setTimer(inst);\r
+ }\r
+\r
+, _setTimer: function (inst) {\r
+ // abort if layout destroyed or browser does not need this check\r
+ if (inst.destroyed) return;\r
+ var o = inst.options\r
+ , s = inst.state\r
+ // don't need check if inst has parentLayout, but check occassionally in case parent destroyed!\r
+ // MINIMUM 100ms interval, for performance\r
+ , ms = inst.hasParentLayout ? 5000 : Math.max( o.browserZoomCheckInterval, 100 )\r
+ ;\r
+ // set the timer\r
+ setTimeout(function(){\r
+ if (inst.destroyed || !o.resizeWithWindow) return;\r
+ var d = $.layout.browserZoom.ratio();\r
+ if (d !== s.browserZoom) {\r
+ s.browserZoom = d;\r
+ inst.resizeAll();\r
+ }\r
+ // set a NEW timeout\r
+ $.layout.browserZoom._setTimer(inst);\r
+ }\r
+ , ms );\r
+ }\r
+\r
+, ratio: function () {\r
+ var w = window\r
+ , s = screen\r
+ , d = document\r
+ , dE = d.documentElement || d.body\r
+ , b = $.layout.browser\r
+ , v = b.version\r
+ , r, sW, cW\r
+ ;\r
+ // we can ignore all browsers that fire window.resize event onZoom\r
+ if ((b.msie && v > 8)\r
+ || !b.msie\r
+ ) return false; // don't need to track zoom\r
+\r
+ if (s.deviceXDPI)\r
+ return calc(s.deviceXDPI, s.systemXDPI);\r
+ // everything below is just for future reference!\r
+ if (b.webkit && (r = d.body.getBoundingClientRect))\r
+ return calc((r.left - r.right), d.body.offsetWidth);\r
+ if (b.webkit && (sW = w.outerWidth))\r
+ return calc(sW, w.innerWidth);\r
+ if ((sW = s.width) && (cW = dE.clientWidth))\r
+ return calc(sW, cW);\r
+ return false; // no match, so cannot - or don't need to - track zoom\r
+\r
+ function calc (x,y) { return (parseInt(x,10) / parseInt(y,10) * 100).toFixed(); }\r
+ }\r
+\r
+};\r
+// add initialization method to Layout's onLoad array of functions\r
+$.layout.onReady.push( $.layout.browserZoom._init );\r
+\r
+\r
+\r
+})( jQuery );
\ No newline at end of file