4 * $Date: 2015/03/13 22:37:04 $
7 * Copyright (c) 2014 Kevin Dalman (http://jquery-dev.com)
8 * Based on work by Fabrizio Balliano (http://www.fabrizioballiano.net)
10 * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html)
11 * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses.
13 * SEE: http://layout.jquery-dev.com/LICENSE.txt
15 * Changelog: http://layout.jquery-dev.com/changelog.cfm
17 * Docs: http://layout.jquery-dev.com/documentation.html
18 * Tips: http://layout.jquery-dev.com/tips.html
19 * Help: http://groups.google.com/group/jquery-ui-layout
22 /* JavaDoc Info: http://code.google.com/closure/compiler/docs/js-for-compiler.html
23 * {!Object} non-nullable type (never NULL)
24 * {?string} nullable type (sometimes NULL) - default for {Object}
25 * {number=} optional parameter
29 * change .andSelf() to .addBack()
30 * check $.fn.disableSelection - this is in jQuery UI 1.9.x
33 // NOTE: For best readability, view with a fixed-width font and tabs equal to 4-chars
37 // alias Math methods - used a lot!
42 , isStr = function (v) { return $.type(v) === "string"; }
45 * @param {!Object} Instance
46 * @param {Array.<string>} a_fn
48 , runPluginCallbacks = function (Instance, a_fn) {
50 for (var i=0, c=a_fn.length; i<c; i++) {
53 if (isStr(fn)) // 'name' of a function
59 function g (f) { return f; }; // compiler hack
64 * GENERIC $.layout METHODS - used by all layouts
69 , revision: 1.0403 // eg: 1.4.1 final = 1.0401 - major(n+).minor(nn)+patch(nn+)
71 // $.layout.browser REPLACES $.browser
72 , browser: {} // set below
74 // *PREDEFINED* EFFECTS & DEFAULTS
75 // MUST list effect here - OR MUST set an fxSettings option (can be an empty hash: {})
78 // Pane Open/Close Animations
80 all: { duration: "fast" } // eg: duration: 1000, easing: "easeOutBounce"
81 , north: { direction: "up" }
82 , south: { direction: "down" }
83 , east: { direction: "right"}
84 , west: { direction: "left" }
87 all: { duration: "slow" }
88 , north: { direction: "up" }
89 , south: { direction: "down" }
90 , east: { direction: "right"}
91 , west: { direction: "left" }
94 all: { duration: "fast" }
96 // these are not recommended, but can be used
104 // Pane Resize Animations
106 all: { easing: "swing" }
110 // INTERNAL CONFIG DATA - DO NOT CHANGE THIS!
112 optionRootKeys: "effects,panes,north,south,west,east,center".split(",")
113 , allPanes: "north,south,west,east,center".split(",")
114 , borderPanes: "north,south,west,east".split(",")
122 , offscreenCSS: { left: "-99999px", right: "auto" } // used by hide/close if useOffscreenClose=true
123 , offscreenReset: "offscreenReset" // key used for data
124 // CSS used in multiple places
125 , hidden: { visibility: "hidden" }
126 , visible: { visibility: "visible" }
127 // layout element settings
134 , textAlign: "left" // to counter-act "center" alignment!
135 , overflow: "hidden" // prevent toggler-button from overflowing
136 // SEE $.layout.defaults.zIndexes.resizer_normal
138 , cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true
150 , textAlign: "center"
155 , cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true
161 position: "relative" /* contain floated or positioned elements */
163 , cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true
167 , cssDemoPane: { // DEMO CSS - REMOVE scrolling from 'pane' when it has a content-div
172 , panes: { // defaults for ALL panes - overridden by 'per-pane settings' below
176 // $.layout.defaults.zIndexes.pane_normal
178 , cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true
181 , border: "1px solid #BBB"
218 , top: "auto" // DYNAMIC
219 , bottom: "auto" // DYNAMIC
231 , top: "auto" // DYNAMIC
232 , bottom: "auto" // DYNAMIC
240 left: "auto" // DYNAMIC
241 , right: "auto" // DYNAMIC
242 , top: "auto" // DYNAMIC
243 , bottom: "auto" // DYNAMIC
250 // CALLBACK FUNCTION NAMESPACE - used to store reusable callback functions
253 , getParentPaneElem: function (el) {
254 // must pass either a container or pane element
256 , layout = $el.data("layout") || $el.data("parentLayout");
258 var $cont = layout.container;
259 // see if this container is directly-nested inside an outer-pane
260 if ($cont.data("layoutPane")) return $cont;
261 var $pane = $cont.closest("."+ $.layout.defaults.panes.paneClass);
262 // if a pane was found, return it
263 if ($pane.data("layoutPane")) return $pane;
268 , getParentPaneInstance: function (el) {
269 // must pass either a container or pane element
270 var $pane = $.layout.getParentPaneElem(el);
271 return $pane ? $pane.data("layoutPane") : null;
274 , getParentLayoutInstance: function (el) {
275 // must pass either a container or pane element
276 var $pane = $.layout.getParentPaneElem(el);
277 return $pane ? $pane.data("parentLayout") : null;
280 , getEventObject: function (evt) {
281 return typeof evt === "object" && evt.stopPropagation ? evt : null;
283 , parsePaneName: function (evt_or_pane) {
284 var evt = $.layout.getEventObject( evt_or_pane )
285 , pane = evt_or_pane;
287 // ALWAYS stop propagation of events triggered in Layout!
288 evt.stopPropagation();
289 pane = $(this).data("layoutEdge");
291 if (pane && !/^(west|east|north|south|center)$/.test(pane)) {
292 $.layout.msg('LAYOUT ERROR - Invalid pane-name: "'+ pane +'"');
299 // LAYOUT-PLUGIN REGISTRATION
300 // more plugins can added beyond this default list
302 draggable: !!$.fn.draggable // resizing
304 core: !!$.effects // animimations (specific effects tested by initOptions)
305 , slide: $.effects && ($.effects.slide || ($.effects.effect && $.effects.effect.slide)) // default effect
309 // arrays of plugin or other methods to be triggered for events in *each layout* - will be passed 'Instance'
310 , onCreate: [] // runs when layout is just starting to be created - right after options are set
311 , onLoad: [] // runs after layout container and global events init, but before initPanes is called
312 , onReady: [] // runs after initialization *completes* - ie, after initPanes completes successfully
313 , onDestroy: [] // runs after layout is destroyed
314 , onUnload: [] // runs after layout is destroyed OR when page unloads
315 , afterOpen: [] // runs after setAsOpen() completes
316 , afterClose: [] // runs after setAsClosed() completes
319 * GENERIC UTILITY METHODS
322 // calculate and return the scrollbar width, as an integer
323 , scrollbarWidth: function () { return window.scrollbarWidth || $.layout.getScrollbarSize('width'); }
324 , scrollbarHeight: function () { return window.scrollbarHeight || $.layout.getScrollbarSize('height'); }
325 , getScrollbarSize: function (dim) {
326 var $c = $('<div style="position: absolute; top: -10000px; left: -10000px; width: 100px; height: 100px; border: 0; overflow: scroll;"></div>').appendTo("body")
327 , d = { width: $c.outerWidth - $c[0].clientWidth, height: 100 - $c[0].clientHeight };
329 window.scrollbarWidth = d.width;
330 window.scrollbarHeight = d.height;
331 return dim.match(/^(width|height)$/) ? d[dim] : d;
335 , disableTextSelection: function () {
337 , s = 'textSelectionDisabled'
338 , x = 'textSelectionInitialized'
340 if ($.fn.disableSelection) {
341 if (!$d.data(x)) // document hasn't been initialized yet
342 $d.on('mouseup', $.layout.enableTextSelection ).data(x, true);
344 $d.disableSelection().data(s, true);
347 , enableTextSelection: function () {
349 , s = 'textSelectionDisabled';
350 if ($.fn.enableSelection && $d.data(s))
351 $d.enableSelection().data(s, false);
356 * Returns hash container 'display' and 'visibility'
358 * @see $.swap() - swaps CSS, runs callback, resets CSS
359 * @param {!Object} $E jQuery element
360 * @param {boolean=} [force=false] Run even if display != none
361 * @return {!Object} Returns current style props, if applicable
363 , showInvisibly: function ($E, force) {
364 if ($E && $E.length && (force || $E.css("display") === "none")) { // only if not *already hidden*
366 // save ONLY the 'style' props because that is what we must restore
367 , CSS = { display: s.display || '', visibility: s.visibility || '' };
368 // show element 'invisibly' so can be measured
369 $E.css({ display: "block", visibility: "hidden" });
376 * Returns data for setting size of an element (container or a pane).
378 * @see _create(), onWindowResize() for container, plus others for pane
379 * @return JSON Returns a hash of all dimensions: top, bottom, left, right, outerWidth, innerHeight, etc
381 , getElementDimensions: function ($E, inset) {
383 // dimensions hash - start with current data IF passed
384 d = { css: {}, inset: {} }
385 , x = d.css // CSS hash
386 , i = { bottom: 0 } // TEMP insets (bottom = complier hack)
387 , N = $.layout.cssNum
390 , b, p, ei // TEMP border, padding
392 d.offsetLeft = off.left;
393 d.offsetTop = off.top;
395 if (!inset) inset = {}; // simplify logic below
397 $.each("Left,Right,Top,Bottom".split(","), function (idx, e) { // e = edge
398 b = x["border" + e] = $.layout.borderWidth($E, e);
399 p = x["padding"+ e] = $.layout.cssNum($E, "padding"+e);
400 ei = e.toLowerCase();
401 d.inset[ei] = inset[ei] >= 0 ? inset[ei] : p; // any missing insetX value = paddingX
402 i[ei] = d.inset[ei] + b; // total offset of content from outer side
405 x.width = R($E.width());
406 x.height = R($E.height());
407 x.top = N($E,"top",true);
408 x.bottom = N($E,"bottom",true);
409 x.left = N($E,"left",true);
410 x.right = N($E,"right",true);
412 d.outerWidth = R($E.outerWidth());
413 d.outerHeight = R($E.outerHeight());
414 // calc the TRUE inner-dimensions, even in quirks-mode!
415 d.innerWidth = max(0, d.outerWidth - i.left - i.right);
416 d.innerHeight = max(0, d.outerHeight - i.top - i.bottom);
417 // layoutWidth/Height is used in calcs for manual resizing
418 // layoutW/H only differs from innerW/H when in quirks-mode - then is like outerW/H
419 d.layoutWidth = R($E.innerWidth());
420 d.layoutHeight = R($E.innerHeight());
422 //if ($E.prop('tagName') === 'BODY') { debugData( d, $E.prop('tagName') ); } // DEBUG
424 //d.visible = $E.is(":visible");// && x.width > 0 && x.height > 0;
429 , getElementStyles: function ($E, list) {
432 , style = $E[0].style
433 , props = list.split(",")
434 , sides = "Top,Bottom,Left,Right".split(",")
435 , attrs = "Color,Style,Width".split(",")
438 for (i=0; i < props.length; i++) {
440 if (p.match(/(border|padding|margin)$/))
441 for (j=0; j < 4; j++) {
444 for (k=0; k < 3; k++) {
446 CSS[p+s+a] = style[p+s+a];
449 CSS[p+s] = style[p+s];
458 * Return the innerWidth for the current browser/doctype
460 * @see initPanes(), sizeMidPanes(), initHandles(), sizeHandles()
461 * @param {Array.<Object>} $E Must pass a jQuery object - first element is processed
462 * @param {number=} outerWidth (optional) Can pass a width, allowing calculations BEFORE element is resized
463 * @return {number} Returns the innerWidth of the elem by subtracting padding and borders
465 , cssWidth: function ($E, outerWidth) {
466 // a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed
467 if (outerWidth <= 0) return 0;
469 var lb = $.layout.browser
470 , bs = !lb.boxModel ? "border-box" : lb.boxSizing ? $E.css("boxSizing") : "content-box"
471 , b = $.layout.borderWidth
472 , n = $.layout.cssNum
475 // strip border and/or padding from outerWidth to get CSS Width
476 if (bs !== "border-box")
477 W -= (b($E, "Left") + b($E, "Right"));
478 if (bs === "content-box")
479 W -= (n($E, "paddingLeft") + n($E, "paddingRight"));
484 * Return the innerHeight for the current browser/doctype
486 * @see initPanes(), sizeMidPanes(), initHandles(), sizeHandles()
487 * @param {Array.<Object>} $E Must pass a jQuery object - first element is processed
488 * @param {number=} outerHeight (optional) Can pass a width, allowing calculations BEFORE element is resized
489 * @return {number} Returns the innerHeight of the elem by subtracting padding and borders
491 , cssHeight: function ($E, outerHeight) {
492 // a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed
493 if (outerHeight <= 0) return 0;
495 var lb = $.layout.browser
496 , bs = !lb.boxModel ? "border-box" : lb.boxSizing ? $E.css("boxSizing") : "content-box"
497 , b = $.layout.borderWidth
498 , n = $.layout.cssNum
501 // strip border and/or padding from outerHeight to get CSS Height
502 if (bs !== "border-box")
503 H -= (b($E, "Top") + b($E, "Bottom"));
504 if (bs === "content-box")
505 H -= (n($E, "paddingTop") + n($E, "paddingBottom"));
510 * Returns the 'current CSS numeric value' for a CSS property - 0 if property does not exist
512 * @see Called by many methods
513 * @param {Array.<Object>} $E Must pass a jQuery object - first element is processed
514 * @param {string} prop The name of the CSS property, eg: top, width, etc.
515 * @param {boolean=} [allowAuto=false] true = return 'auto' if that is value; false = return 0
516 * @return {(string|number)} Usually used to get an integer value for position (top, left) or size (height, width)
518 , cssNum: function ($E, prop, allowAuto) {
519 if (!$E.jquery) $E = $($E);
520 var CSS = $.layout.showInvisibly($E)
521 , p = $.css($E[0], prop, true)
522 , v = allowAuto && p=="auto" ? p : Math.round(parseFloat(p) || 0);
523 $E.css( CSS ); // RESET
527 , borderWidth: function (el, side) {
528 if (el.jquery) el = el[0];
529 var b = "border"+ side.substr(0,1).toUpperCase() + side.substr(1); // left => Left
530 return $.css(el, b+"Style", true) === "none" ? 0 : Math.round(parseFloat($.css(el, b+"Width", true)) || 0);
534 * Mouse-tracking utility - FUTURE REFERENCE
536 * init: if (!window.mouse) {
537 * window.mouse = { x: 0, y: 0 };
538 * $(document).mousemove( $.layout.trackMouse );
541 * @param {Object} evt
543 , trackMouse: function (evt) {
544 window.mouse = { x: evt.clientX, y: evt.clientY };
549 * SUBROUTINE for preventPrematureSlideClose option
551 * @param {Object} evt
552 * @param {Object=} el
554 , isMouseOverElem: function (evt, el) {
560 , R = L + $E.outerWidth()
561 , B = T + $E.outerHeight()
562 , x = evt.pageX // evt.clientX ?
563 , y = evt.pageY // evt.clientY ?
565 // if X & Y are < 0, probably means is over an open SELECT
566 return ($.layout.browser.msie && x < 0 && y < 0) || ((x >= L && x <= R) && (y >= T && y <= B));
570 * Message/Logging Utility
572 * @example $.layout.msg("My message"); // log text
573 * @example $.layout.msg("My message", true); // alert text
574 * @example $.layout.msg({ foo: "bar" }, "Title"); // log hash-data, with custom title
575 * @example $.layout.msg({ foo: "bar" }, true, "Title", { sort: false }); -OR-
576 * @example $.layout.msg({ foo: "bar" }, "Title", { sort: false, display: true }); // alert hash-data
578 * @param {(Object|string)} info String message OR Hash/Array
579 * @param {(Boolean|string|Object)=} [popup=false] True means alert-box - can be skipped
580 * @param {(Object|string)=} [debugTitle=""] Title for Hash data - can be skipped
581 * @param {Object=} [debugOpts] Extra options for debug output
583 , msg: function (info, popup, debugTitle, debugOpts) {
584 if ($.isPlainObject(info) && window.debugData) {
585 if (typeof popup === "string") {
586 debugOpts = debugTitle;
589 else if (typeof debugTitle === "object") {
590 debugOpts = debugTitle;
593 var t = debugTitle || "log( <object> )"
594 , o = $.extend({ sort: false, returnHTML: false, display: false }, debugOpts);
595 if (popup === true || o.display)
596 debugData( info, t, o );
597 else if (window.console)
598 console.log(debugData( info, t, o ));
602 else if (window.console)
605 var id = "#layoutLogger"
609 $l.children("ul").append('<li style="padding: 4px 10px; margin: 0; border-top: 1px solid #CCC;">'+ info.replace(/\</g,"<").replace(/\>/g,">") +'</li>');
612 function createLog () {
613 var pos = $.support.fixedPosition ? 'fixed' : 'absolute'
614 , $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);">'
615 + '<div style="font-size: 13px; font-weight: bold; padding: 5px 10px; background: #F6F6F6; border-radius: 5px 5px 0 0; cursor: move;">'
616 + '<span style="float: right; padding-left: 7px; cursor: pointer;" title="Remove Console" onclick="$(this).closest(\'#layoutLogger\').remove()">X</span>Layout console.log</div>'
617 + '<ul style="font-size: 13px; font-weight: none; list-style: none; margin: 0; padding: 0 0 2px;"></ul>'
620 $e.css('left', $(window).width() - $e.outerWidth() - 5)
621 if ($.ui.draggable) $e.draggable({ handle: ':first-child' });
630 * $.layout.browser REPLACES removed $.browser, with extra data
631 * Parsing code here adapted from jQuery 1.8 $.browse
634 var u = navigator.userAgent.toLowerCase()
635 , m = /(chrome)[ \/]([\w.]+)/.exec( u )
636 || /(webkit)[ \/]([\w.]+)/.exec( u )
637 || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( u )
638 || /(msie) ([\w.]+)/.exec( u )
639 || u.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( u )
644 , cm = document.compatMode
646 , bs = $s.boxSizing !== undefined ? $s.boxSizing : $s.boxSizingReliable
647 , bm = !ie || !cm || cm === "CSS1Compat" || $s.boxModel || false
648 , lb = $.layout.browser = {
650 , safari: b === "webkit" // webkit (NOT chrome) = safari
651 , webkit: b === "chrome" // chrome = webkit
653 , isIE6: ie && v == 6
654 // ONLY IE reverts to old box-model - Note that compatMode was deprecated as of IE8
656 , boxSizing: !!(typeof bs === "function" ? bs() : bs)
659 if (b) lb[b] = true; // set CURRENT browser
660 /* OLD versions of jQuery only set $.support.boxModel after page is loaded
661 * so if this is IE, use support.boxModel to test for quirks-mode (ONLY IE changes boxModel) */
662 if (!bm && !cm) $(function(){ lb.boxModel = $s.boxModel; });
667 $.layout.defaults = {
669 * LAYOUT & LAYOUT-CONTAINER OPTIONS
670 * - none of these options are applicable to individual panes
672 name: "" // Not required, but useful for buttons and used for the state-cookie
673 , containerClass: "ui-layout-container" // layout-container element
674 , inset: null // custom container-inset values (override padding)
675 , scrollToBookmarkOnLoad: true // after creating a layout, scroll to bookmark in URL (.../page.htm#myBookmark)
676 , resizeWithWindow: true // bind thisLayout.resizeAll() to the window.resize event
677 , resizeWithWindowDelay: 200 // delay calling resizeAll because makes window resizing very jerky
678 , resizeWithWindowMaxDelay: 0 // 0 = none - force resize every XX ms while window is being resized
679 , maskPanesEarly: false // true = create pane-masks on resizer.mouseDown instead of waiting for resizer.dragstart
680 , onresizeall_start: null // CALLBACK when resizeAll() STARTS - NOT pane-specific
681 , onresizeall_end: null // CALLBACK when resizeAll() ENDS - NOT pane-specific
682 , onload_start: null // CALLBACK when Layout inits - after options initialized, but before elements
683 , onload_end: null // CALLBACK when Layout inits - after EVERYTHING has been initialized
684 , onunload_start: null // CALLBACK when Layout is destroyed OR onWindowUnload
685 , onunload_end: null // CALLBACK when Layout is destroyed OR onWindowUnload
686 , initPanes: true // false = DO NOT initialize the panes onLoad - will init later
687 , showErrorMessages: true // enables fatal error messages to warn developers of common errors
688 , showDebugMessages: false // display console-and-alert debug msgs - IF this Layout version _has_ debugging code!
689 // Changing this zIndex value will cause other zIndex values to automatically change
690 , zIndex: null // the PANE zIndex - resizers and masks will be +1
691 // DO NOT CHANGE the zIndex values below unless you clearly understand their relationships
692 , zIndexes: { // set _default_ z-index values here...
693 pane_normal: 0 // normal z-index for panes
694 , content_mask: 1 // applied to overlays used to mask content INSIDE panes during resizing
695 , resizer_normal: 2 // normal z-index for resizer-bars
696 , pane_sliding: 100 // applied to *BOTH* the pane and its resizer when a pane is 'slid open'
697 , pane_animate: 1000 // applied to the pane when being animated - not applied to the resizer
698 , resizer_drag: 10000 // applied to the CLONED resizer-bar when being 'dragged'
701 pane: "pane" // description of "layout pane element" - used only in error messages
702 , selector: "selector" // description of "jQuery-selector" - used only in error messages
703 , addButtonError: "Error Adding Button\nInvalid "
704 , containerMissing: "UI Layout Initialization Error\nThe specified layout-container does not exist."
705 , centerPaneMissing: "UI Layout Initialization Error\nThe center-pane element does not exist.\nThe center-pane is a required element."
706 , noContainerHeight: "UI Layout Initialization Warning\nThe layout-container \"CONTAINER\" has no height.\nTherefore the layout is 0-height and hence 'invisible'!"
707 , callbackError: "UI Layout Callback Error\nThe EVENT callback is not a valid function."
710 * PANE DEFAULT SETTINGS
711 * - settings under the 'panes' key become the default settings for *all panes*
712 * - ALL pane-options can also be set specifically for each panes, which will override these 'default values'
714 , panes: { // default options for 'all panes' - will be overridden by 'per-pane settings'
715 applyDemoStyles: false // NOTE: renamed from applyDefaultStyles for clarity
716 , closable: true // pane can open & close
717 , resizable: true // when open, pane can be resized
718 , slidable: true // when closed, pane can 'slide open' over other panes - closes on mouse-out
719 , initClosed: false // true = init pane as 'closed'
720 , initHidden: false // true = init pane as 'hidden' - no resizer-bar/spacing
722 //, paneSelector: "" // MUST be pane-specific - jQuery selector for pane
723 , contentSelector: ".ui-layout-content" // INNER div/element to auto-size so only it scrolls, not the entire pane!
724 , contentIgnoreSelector: ".ui-layout-ignore" // element(s) to 'ignore' when measuring 'content'
725 , findNestedContent: false // true = $P.find(contentSelector), false = $P.children(contentSelector)
726 // GENERIC ROOT-CLASSES - for auto-generated classNames
727 , paneClass: "ui-layout-pane" // Layout Pane
728 , resizerClass: "ui-layout-resizer" // Resizer Bar
729 , togglerClass: "ui-layout-toggler" // Toggler Button
730 , buttonClass: "ui-layout-button" // CUSTOM Buttons - eg: '[ui-layout-button]-toggle/-open/-close/-pin'
731 // ELEMENT SIZE & SPACING
732 //, size: 100 // MUST be pane-specific -initial size of pane
733 , minSize: 0 // when manually resizing a pane
734 , maxSize: 0 // ditto, 0 = no limit
735 , spacing_open: 6 // space between pane and adjacent panes - when pane is 'open'
736 , spacing_closed: 6 // ditto - when pane is 'closed'
737 , togglerLength_open: 50 // Length = WIDTH of toggler button on north/south sides - HEIGHT on east/west sides
738 , togglerLength_closed: 50 // 100% OR -1 means 'full height/width of resizer bar' - 0 means 'hidden'
739 , togglerAlign_open: "center" // top/left, bottom/right, center, OR...
740 , togglerAlign_closed: "center" // 1 => nn = offset from top/left, -1 => -nn == offset from bottom/right
741 , togglerContent_open: "" // text or HTML to put INSIDE the toggler
742 , togglerContent_closed: "" // ditto
744 , resizerDblClickToggle: true //
745 , autoResize: true // IF size is 'auto' or a percentage, then recalc 'pixel size' whenever the layout resizes
746 , autoReopen: true // IF a pane was auto-closed due to noRoom, reopen it when there is room? False = leave it closed
747 , resizerDragOpacity: 1 // option for ui.draggable
748 //, resizerCursor: "" // MUST be pane-specific - cursor when over resizer-bar
749 , maskContents: false // true = add DIV-mask over-or-inside this pane so can 'drag' over IFRAMES
750 , maskObjects: false // true = add IFRAME-mask over-or-inside this pane to cover objects/applets - content-mask will overlay this mask
751 , maskZindex: null // will override zIndexes.content_mask if specified - not applicable to iframe-panes
752 , resizingGrid: false // grid size that the resizers will snap-to during resizing, eg: [20,20]
753 , livePaneResizing: false // true = LIVE Resizing as resizer is dragged
754 , liveContentResizing: false // true = re-measure header/footer heights as resizer is dragged
755 , liveResizingTolerance: 1 // how many px change before pane resizes, to control performance
757 , sliderCursor: "pointer" // cursor when resizer-bar will trigger 'sliding'
758 , slideTrigger_open: "click" // click, dblclick, mouseenter
759 , slideTrigger_close: "mouseleave"// click, mouseleave
760 , slideDelay_open: 300 // applies only for mouseenter event - 0 = instant open
761 , slideDelay_close: 300 // applies only for mouseleave event (300ms is the minimum!)
762 , hideTogglerOnSlide: false // when pane is slid-open, should the toggler show?
763 , preventQuickSlideClose: $.layout.browser.webkit // Chrome triggers slideClosed as it is opening
764 , preventPrematureSlideClose: false // handle incorrect mouseleave trigger, like when over a SELECT-list in IE
765 // PANE-SPECIFIC TIPS & MESSAGES
767 Open: "Open" // eg: "Open Pane"
770 , Slide: "Slide Open"
773 , noRoomToOpen: "Not enough room to show this panel." // alert if user tries to open a pane that cannot
774 , minSizeWarning: "Panel has reached its minimum size" // displays in browser statusbar
775 , maxSizeWarning: "Panel has reached its maximum size" // ditto
778 , showOverflowOnHover: false // will bind allowOverflow() utility to pane.onMouseOver
779 , enableCursorHotkey: true // enabled 'cursor' hotkeys
780 //, customHotkey: "" // MUST be pane-specific - EITHER a charCode OR a character
781 , customHotkeyModifier: "SHIFT" // either 'SHIFT', 'CTRL' or 'CTRL+SHIFT' - NOT 'ALT'
783 // NOTE: fxSss_open, fxSss_close & fxSss_size options (eg: fxName_open) are auto-generated if not passed
784 , fxName: "slide" // ('none' or blank), slide, drop, scale -- only relevant to 'open' & 'close', NOT 'size'
785 , fxSpeed: null // slow, normal, fast, 200, nnn - if passed, will OVERRIDE fxSettings.duration
786 , fxSettings: {} // can be passed, eg: { easing: "easeOutBounce", duration: 1500 }
787 , fxOpacityFix: true // tries to fix opacity in IE to restore anti-aliasing after animation
788 , animatePaneSizing: false // true = animate resizing after dragging resizer-bar OR sizePane() is called
789 /* NOTE: Action-specific FX options are auto-generated from the options above if not specifically set:
790 fxName_open: "slide" // 'Open' pane animation
791 fnName_close: "slide" // 'Close' pane animation
792 fxName_size: "slide" // 'Size' pane animation - when animatePaneSizing = true
800 // CHILD/NESTED LAYOUTS
801 , children: null // Layout-options for nested/child layout - even {} is valid as options
802 , containerSelector: '' // if child is NOT 'directly nested', a selector to find it/them (can have more than one child layout!)
803 , initChildren: true // true = child layout will be created as soon as _this_ layout completes initialization
804 , destroyChildren: true // true = destroy child-layout if this pane is destroyed
805 , resizeChildren: true // true = trigger child-layout.resizeAll() when this pane is resized
807 , triggerEventsOnLoad: false // true = trigger onopen OR onclose callbacks when layout initializes
808 , triggerEventsDuringLiveResize: true // true = trigger onresize callback REPEATEDLY if livePaneResizing==true
810 , onshow_start: null // CALLBACK when pane STARTS to Show - BEFORE onopen/onhide_start
811 , onshow_end: null // CALLBACK when pane ENDS being Shown - AFTER onopen/onhide_end
812 , onhide_start: null // CALLBACK when pane STARTS to Close - BEFORE onclose_start
813 , onhide_end: null // CALLBACK when pane ENDS being Closed - AFTER onclose_end
814 , onopen_start: null // CALLBACK when pane STARTS to Open
815 , onopen_end: null // CALLBACK when pane ENDS being Opened
816 , onclose_start: null // CALLBACK when pane STARTS to Close
817 , onclose_end: null // CALLBACK when pane ENDS being Closed
818 , onresize_start: null // CALLBACK when pane STARTS being Resized ***FOR ANY REASON***
819 , onresize_end: null // CALLBACK when pane ENDS being Resized ***FOR ANY REASON***
820 , onsizecontent_start: null // CALLBACK when sizing of content-element STARTS
821 , onsizecontent_end: null // CALLBACK when sizing of content-element ENDS
822 , onswap_start: null // CALLBACK when pane STARTS to Swap
823 , onswap_end: null // CALLBACK when pane ENDS being Swapped
824 , ondrag_start: null // CALLBACK when pane STARTS being ***MANUALLY*** Resized
825 , ondrag_end: null // CALLBACK when pane ENDS being ***MANUALLY*** Resized
828 * PANE-SPECIFIC SETTINGS
829 * - options listed below MUST be specified per-pane - they CANNOT be set under 'panes'
830 * - all options under the 'panes' key can also be set specifically for any pane
831 * - most options under the 'panes' key apply only to 'border-panes' - NOT the the center-pane
834 paneSelector: ".ui-layout-north"
835 , size: "auto" // eg: "auto", "30%", .30, 200
836 , resizerCursor: "n-resize" // custom = url(myCursor.cur)
837 , customHotkey: "" // EITHER a charCode (43) OR a character ("o")
840 paneSelector: ".ui-layout-south"
841 , size: "50%"//"auto"
842 , resizerCursor: "s-resize"
847 paneSelector: ".ui-layout-east"
849 , resizerCursor: "e-resize"
853 paneSelector: ".ui-layout-west"
855 , resizerCursor: "w-resize"
860 paneSelector: ".ui-layout-center"
861 , size: "30%"//"auto"
867 $.layout.optionsMap = {
868 // layout/global options - NOT pane-options
869 layout: ("name,instanceKey,stateManagement,effects,inset,zIndexes,errors,"
870 + "zIndex,scrollToBookmarkOnLoad,showErrorMessages,maskPanesEarly,"
871 + "outset,resizeWithWindow,resizeWithWindowDelay,resizeWithWindowMaxDelay,"
872 + "onresizeall,onresizeall_start,onresizeall_end,onload,onload_start,onload_end,onunload,onunload_start,onunload_end").split(",")
873 // borderPanes: [ ALL options that are NOT specified as 'layout' ]
874 // default.panes options that apply to the center-pane (most options apply _only_ to border-panes)
875 , center: ("paneClass,contentSelector,contentIgnoreSelector,findNestedContent,applyDemoStyles,triggerEventsOnLoad,"
876 + "showOverflowOnHover,maskContents,maskObjects,liveContentResizing,"
877 + "containerSelector,children,initChildren,resizeChildren,destroyChildren,"
878 + "onresize,onresize_start,onresize_end,onsizecontent,onsizecontent_start,onsizecontent_end").split(",")
879 // options that MUST be specifically set 'per-pane' - CANNOT set in the panes (defaults) key
880 , noDefault: ("paneSelector,resizerCursor,customHotkey").split(",")
884 * Processes options passed in converts flat-format data into subkey (JSON) format
885 * In flat-format, subkeys are _currently_ separated with 2 underscores, like north__optName
886 * Plugins may also call this method so they can transform their own data
888 * @param {!Object} hash Data/options passed by user - may be a single level or nested levels
889 * @param {boolean=} [addKeys=false] Should the primary layout.options keys be added if they do not exist?
890 * @return {Object} Returns hash of minWidth & minHeight
892 $.layout.transformData = function (hash, addKeys) {
893 var json = addKeys ? { panes: {}, center: {} } : {} // init return object
894 , branch, optKey, keys, key, val, i, c;
896 if (typeof hash !== "object") return json; // no options passed
898 // convert all 'flat-keys' to 'sub-key' format
899 for (optKey in hash) {
901 val = hash[ optKey ];
902 keys = optKey.split("__"); // eg: west__size or north__fxSettings__duration
904 // convert underscore-delimited to subkeys
905 for (i=0; i <= c; i++) {
907 if (i === c) { // last key = value
908 if ($.isPlainObject( val ))
909 branch[key] = $.layout.transformData( val ); // RECURSE
915 branch[key] = {}; // create the subkey
916 // recurse to sub-key for next loop - if not done
917 branch = branch[key];
924 // INTERNAL CONFIG DATA - DO NOT CHANGE THIS!
925 $.layout.backwardCompatibility = {
926 // data used by renameOldOptions()
928 // OLD Option Name: NEW Option Name
929 applyDefaultStyles: "applyDemoStyles"
930 // CHILD/NESTED LAYOUTS
931 , childOptions: "children"
932 , initChildLayout: "initChildren"
933 , destroyChildLayout: "destroyChildren"
934 , resizeChildLayout: "resizeChildren"
935 , resizeNestedLayout: "resizeChildren"
937 , resizeWhileDragging: "livePaneResizing"
938 , resizeContentWhileDragging: "liveContentResizing"
939 , triggerEventsWhileDragging: "triggerEventsDuringLiveResize"
940 , maskIframesOnResize: "maskContents"
942 , useStateCookie: "stateManagement.enabled"
943 , "cookie.autoLoad": "stateManagement.autoLoad"
944 , "cookie.autoSave": "stateManagement.autoSave"
945 , "cookie.keys": "stateManagement.stateKeys"
946 , "cookie.name": "stateManagement.cookie.name"
947 , "cookie.domain": "stateManagement.cookie.domain"
948 , "cookie.path": "stateManagement.cookie.path"
949 , "cookie.expires": "stateManagement.cookie.expires"
950 , "cookie.secure": "stateManagement.cookie.secure"
951 // OLD Language options
952 , noRoomToOpenTip: "tips.noRoomToOpen"
953 , togglerTip_open: "tips.Close" // open = Close
954 , togglerTip_closed: "tips.Open" // closed = Open
955 , resizerTip: "tips.Resize"
956 , sliderTip: "tips.Slide"
960 * @param {Object} opts
962 , renameOptions: function (opts) {
963 var map = $.layout.backwardCompatibility.map
964 , oldData, newData, value
966 for (var itemPath in map) {
967 oldData = getBranch( itemPath );
968 value = oldData.branch[ oldData.key ];
969 if (value !== undefined) {
970 newData = getBranch( map[itemPath], true );
971 newData.branch[ newData.key ] = value;
972 delete oldData.branch[ oldData.key ];
977 * @param {string} path
978 * @param {boolean=} [create=false] Create path if does not exist
980 function getBranch (path, create) {
981 var a = path.split(".") // split keys into array
983 , D = { branch: opts, key: a[c] } // init branch at top & set key (last item)
985 for (; i<c; i++) { // skip the last key (data)
987 if (D.branch[ k ] == undefined) { // child-key does not exist
989 D.branch = D.branch[ k ] = {}; // create child-branch
991 else // can't go any farther
992 D.branch = {}; // branch is undefined
995 D.branch = D.branch[ k ]; // get child-branch
1002 * @param {Object} opts
1004 , renameAllOptions: function (opts) {
1005 var ren = $.layout.backwardCompatibility.renameOptions;
1006 // rename root (layout) options
1008 // rename 'defaults' to 'panes'
1009 if (opts.defaults) {
1010 if (typeof opts.panes !== "object")
1012 $.extend(true, opts.panes, opts.defaults);
1013 delete opts.defaults;
1015 // rename options in the the options.panes key
1016 if (opts.panes) ren( opts.panes );
1017 // rename options inside *each pane key*, eg: options.west
1018 $.each($.layout.config.allPanes, function (i, pane) {
1019 if (opts[pane]) ren( opts[pane] );
1028 /* ============================================================
1029 * BEGIN WIDGET: $( selector ).layout( {options} );
1030 * ============================================================
1032 $.fn.layout = function (opts) {
1035 // local aliases to global data
1036 browser = $.layout.browser
1037 , _c = $.layout.config
1039 // local aliases to utlity methods
1040 , cssW = $.layout.cssWidth
1041 , cssH = $.layout.cssHeight
1042 , elDims = $.layout.getElementDimensions
1043 , styles = $.layout.getElementStyles
1044 , evtObj = $.layout.getEventObject
1045 , evtPane = $.layout.parsePaneName
1048 * options - populated by initOptions()
1050 , options = $.extend(true, {}, $.layout.defaults)
1051 , effects = options.effects = $.extend(true, {}, $.layout.effects)
1054 * layout-state object
1057 // generate unique ID to use for event.namespace so can unbind only events added by 'this layout'
1058 id: "layout"+ $.now() // code uses alias: sID
1059 , initialized: false
1060 , paneResizing: false
1062 , container: { // list all keys referenced in code to avoid compiler error msgs
1070 , north: { childIdx: 0 }
1071 , south: { childIdx: 0 }
1072 , east: { childIdx: 0 }
1073 , west: { childIdx: 0 }
1074 , center: { childIdx: 0 }
1078 * parent/child-layout pointers
1080 //, hasParentLayout = false - exists ONLY inside Instance so can be set externally
1090 * ###########################
1091 * INTERNAL HELPER FUNCTIONS
1092 * ###########################
1096 * Manages all internal timers
1100 , set: function (s, fn, ms) { timer.clear(s); timer.data[s] = setTimeout(fn, ms); }
1101 , clear: function (s) { var t=timer.data; if (t[s]) {clearTimeout(t[s]); delete t[s];} }
1105 * Alert or console.log a message - IF option is enabled.
1107 * @param {(string|!Object)} msg Message (or debug-data) to display
1108 * @param {boolean=} [popup=false] True by default, means 'alert', false means use console.log
1109 * @param {boolean=} [debug=false] True means is a widget debugging message
1111 , _log = function (msg, popup, debug) {
1113 if ((o.showErrorMessages && !debug) || (debug && o.showDebugMessages))
1114 $.layout.msg( o.name +' / '+ msg, (popup !== false) );
1119 * Executes a Callback function after a trigger event, like resize, open or close
1121 * @param {string} evtName Name of the layout callback, eg "onresize_start"
1122 * @param {(string|boolean)=} [pane=""] This is passed only so we can pass the 'pane object' to the callback
1123 * @param {(string|boolean)=} [skipBoundEvents=false] True = do not run events bound to the elements - only the callbacks set in options
1125 , _runCallbacks = function (evtName, pane, skipBoundEvents) {
1126 var hasPane = pane && isStr(pane)
1127 , s = hasPane ? state[pane] : state
1128 , o = hasPane ? options[pane] : options
1129 , lName = options.name
1130 // names like onopen and onopen_end separate are interchangeable in options...
1131 , lng = evtName + (evtName.match(/_/) ? "" : "_end")
1132 , shrt = lng.match(/_end$/) ? lng.substr(0, lng.length - 4) : ""
1133 , fn = o[lng] || o[shrt]
1134 , retVal = "NC" // NC = No Callback
1136 , $P = hasPane ? $Ps[pane] : 0
1138 if (hasPane && !$P) // a pane is specified, but does not exist!
1140 if ( !hasPane && $.type(pane) === "boolean" ) {
1141 skipBoundEvents = pane; // allow pane param to be skipped for Layout callback
1145 // first trigger the callback set in the options
1148 // convert function name (string) to function object
1150 if (fn.match(/,/)) {
1151 // function name cannot contain a comma,
1152 // so must be a function name AND a parameter to pass
1153 args = fn.split(",")
1154 , fn = eval(args[0]);
1156 else // just the name of an external function?
1159 // execute the callback, if exists
1160 if ($.isFunction( fn )) {
1162 retVal = g(fn)(args[1]); // pass the argument parsed from 'list'
1164 // pass data: pane-name, pane-element, pane-state, pane-options, and layout-name
1165 retVal = g(fn)( pane, $Ps[pane], s, o, lName );
1166 else // must be a layout/container callback - pass suitable info
1167 retVal = g(fn)( Instance, s, o, lName );
1171 _log( options.errors.callbackError.replace(/EVENT/, $.trim((pane || "") +" "+ lng)), false );
1172 if ($.type(ex) === "string" && string.length)
1173 _log("Exception: "+ ex, false );
1177 // trigger additional events bound directly to the pane
1178 if (!skipBoundEvents && retVal !== false) {
1179 if ( hasPane ) { // PANE events can be bound to each pane-elements
1182 $P.triggerHandler("layoutpane"+ lng, [ pane, $P, s, o, lName ]);
1184 $P.triggerHandler("layoutpane"+ shrt, [ pane, $P, s, o, lName ]);
1186 else { // LAYOUT events can be bound to the container-element
1187 $N.triggerHandler("layout"+ lng, [ Instance, s, o, lName ]);
1189 $N.triggerHandler("layout"+ shrt, [ Instance, s, o, lName ]);
1193 // ALWAYS resizeChildren after an onresize_end event - even during initialization
1194 // IGNORE onsizecontent_end event because causes child-layouts to resize TWICE
1195 if (hasPane && evtName === "onresize_end") // BAD: || evtName === "onsizecontent_end"
1196 resizeChildren(pane+"", true); // compiler hack -force string
1200 function g (f) { return f; }; // compiler hack
1205 * cure iframe display issues in IE & other browsers
1207 , _fixIframe = function (pane) {
1208 if (browser.mozilla) return; // skip FireFox - it auto-refreshes iframes onShow
1210 // if the 'pane' is an iframe, do it
1211 if (state[pane].tagName === "IFRAME")
1212 $P.css(_c.hidden).css(_c.visible);
1213 else // ditto for any iframes INSIDE the pane
1214 $P.find('IFRAME').css(_c.hidden).css(_c.visible);
1218 * @param {string} pane Can accept ONLY a 'pane' (east, west, etc)
1219 * @param {number=} outerSize (optional) Can pass a width, allowing calculations BEFORE element is resized
1220 * @return {number} Returns the innerHeight/Width of el by subtracting padding and borders
1222 , cssSize = function (pane, outerSize) {
1223 var fn = _c[pane].dir=="horz" ? cssH : cssW;
1224 return fn($Ps[pane], outerSize);
1228 * @param {string} pane Can accept ONLY a 'pane' (east, west, etc)
1229 * @return {Object} Returns hash of minWidth & minHeight
1231 , cssMinDims = function (pane) {
1232 // minWidth/Height means CSS width/height = 1px
1234 , dir = _c[pane].dir
1236 minWidth: 1001 - cssW($P, 1000)
1237 , minHeight: 1001 - cssH($P, 1000)
1240 if (dir === "horz") d.minSize = d.minHeight;
1241 if (dir === "vert") d.minSize = d.minWidth;
1245 // TODO: see if these methods can be made more useful...
1246 // TODO: *maybe* return cssW/H from these so caller can use this info
1249 * @param {(string|!Object)} el
1250 * @param {number=} outerWidth
1251 * @param {boolean=} [autoHide=false]
1253 , setOuterWidth = function (el, outerWidth, autoHide) {
1255 if (isStr(el)) $E = $Ps[el]; // west
1256 else if (!el.jquery) $E = $(el);
1257 w = cssW($E, outerWidth);
1258 $E.css({ width: w });
1260 if (autoHide && $E.data('autoHidden') && $E.innerHeight() > 0) {
1261 $E.show().data('autoHidden', false);
1262 if (!browser.mozilla) // FireFox refreshes iframes - IE does not
1263 // make hidden, then visible to 'refresh' display after animation
1264 $E.css(_c.hidden).css(_c.visible);
1267 else if (autoHide && !$E.data('autoHidden'))
1268 $E.hide().data('autoHidden', true);
1272 * @param {(string|!Object)} el
1273 * @param {number=} outerHeight
1274 * @param {boolean=} [autoHide=false]
1276 , setOuterHeight = function (el, outerHeight, autoHide) {
1278 if (isStr(el)) $E = $Ps[el]; // west
1279 else if (!el.jquery) $E = $(el);
1280 h = cssH($E, outerHeight);
1281 $E.css({ height: h, visibility: "visible" }); // may have been 'hidden' by sizeContent
1282 if (h > 0 && $E.innerWidth() > 0) {
1283 if (autoHide && $E.data('autoHidden')) {
1284 $E.show().data('autoHidden', false);
1285 if (!browser.mozilla) // FireFox refreshes iframes - IE does not
1286 $E.css(_c.hidden).css(_c.visible);
1289 else if (autoHide && !$E.data('autoHidden'))
1290 $E.hide().data('autoHidden', true);
1295 * Converts any 'size' params to a pixel/integer size, if not already
1296 * If 'auto' or a decimal/percentage is passed as 'size', a pixel-size is calculated
1299 * @param {string} pane
1300 * @param {(string|number)=} size
1301 * @param {string=} [dir]
1304 , _parseSize = function (pane, size, dir) {
1305 if (!dir) dir = _c[pane].dir;
1307 if (isStr(size) && size.match(/%/))
1308 size = (size === '100%') ? -1 : parseInt(size, 10) / 100; // convert % to decimal
1313 return parseInt(size, 10);
1315 var o = options, avail = 0;
1316 if (dir=="horz") // north or south or center.minHeight
1317 avail = sC.innerHeight - ($Ps.north ? o.north.spacing_open : 0) - ($Ps.south ? o.south.spacing_open : 0);
1318 else if (dir=="vert") // east or west or center.minWidth
1319 avail = sC.innerWidth - ($Ps.west ? o.west.spacing_open : 0) - ($Ps.east ? o.east.spacing_open : 0);
1321 if (size === -1) // -1 == 100%
1323 else if (size > 0) // percentage, eg: .25
1324 return round(avail * size);
1325 else if (pane=="center")
1327 else { // size < 0 || size=='auto' || size==Missing || size==Invalid
1328 // auto-size the pane
1329 var dim = (dir === "horz" ? "height" : "width")
1331 , $C = dim === 'height' ? $Cs[pane] : false
1332 , vis = $.layout.showInvisibly($P) // show pane invisibly if hidden
1333 , szP = $P.css(dim) // SAVE current pane size
1334 , szC = $C ? $C.css(dim) : 0 // SAVE current content size
1336 $P.css(dim, "auto");
1337 if ($C) $C.css(dim, "auto");
1338 size = (dim === "height") ? $P.outerHeight() : $P.outerWidth(); // MEASURE
1339 $P.css(dim, szP).css(vis); // RESET size & visibility
1340 if ($C) $C.css(dim, szC);
1346 * Calculates current 'size' (outer-width or outer-height) of a border-pane - optionally with 'pane-spacing' added
1348 * @param {(string|!Object)} pane
1349 * @param {boolean=} [inclSpace=false]
1350 * @return {number} Returns EITHER Width for east/west panes OR Height for north/south panes
1352 , getPaneSize = function (pane, inclSpace) {
1357 , oSp = (inclSpace ? o.spacing_open : 0)
1358 , cSp = (inclSpace ? o.spacing_closed : 0)
1360 if (!$P || s.isHidden)
1362 else if (s.isClosed || (s.isSliding && inclSpace))
1364 else if (_c[pane].dir === "horz")
1365 return $P.outerHeight() + oSp;
1366 else // dir === "vert"
1367 return $P.outerWidth() + oSp;
1371 * Calculate min/max pane dimensions and limits for resizing
1373 * @param {string} pane
1374 * @param {boolean=} [slide=false]
1376 , setSizeLimits = function (pane, slide) {
1377 if (!isInitialized()) return;
1383 , type = c.sizeType.toLowerCase()
1384 , isSliding = (slide != undefined ? slide : s.isSliding) // only open() passes 'slide' param
1386 , paneSpacing = o.spacing_open
1387 // measure the pane on the *opposite side* from this pane
1388 , altPane = _c.oppositeEdge[pane]
1389 , altS = state[altPane]
1390 , $altP = $Ps[altPane]
1391 , altPaneSize = (!$altP || altS.isVisible===false || altS.isSliding ? 0 : (dir=="horz" ? $altP.outerHeight() : $altP.outerWidth()))
1392 , altPaneSpacing = ((!$altP || altS.isHidden ? 0 : options[altPane][ altS.isClosed !== false ? "spacing_closed" : "spacing_open" ]) || 0)
1393 // limitSize prevents this pane from 'overlapping' opposite pane
1394 , containerSize = (dir=="horz" ? sC.innerHeight : sC.innerWidth)
1395 , minCenterDims = cssMinDims("center")
1396 , minCenterSize = dir=="horz" ? max(options.center.minHeight, minCenterDims.minHeight) : max(options.center.minWidth, minCenterDims.minWidth)
1397 // if pane is 'sliding', then ignore center and alt-pane sizes - because 'overlays' them
1398 , limitSize = (containerSize - paneSpacing - (isSliding ? 0 : (_parseSize("center", minCenterSize, dir) + altPaneSize + altPaneSpacing)))
1399 , minSize = s.minSize = max( _parseSize(pane, o.minSize), cssMinDims(pane).minSize )
1400 , maxSize = s.maxSize = min( (o.maxSize ? _parseSize(pane, o.maxSize) : 100000), limitSize )
1401 , r = s.resizerPosition = {} // used to set resizing limits
1402 , top = sC.inset.top
1403 , left = sC.inset.left
1405 , H = sC.innerHeight
1406 , rW = o.spacing_open // subtract resizer-width to get top/left position for south/east
1409 case "north": r.min = top + minSize;
1410 r.max = top + maxSize;
1412 case "west": r.min = left + minSize;
1413 r.max = left + maxSize;
1415 case "south": r.min = top + H - maxSize - rW;
1416 r.max = top + H - minSize - rW;
1418 case "east": r.min = left + W - maxSize - rW;
1419 r.max = left + W - minSize - rW;
1425 * Returns data for setting the size/position of center pane. Also used to set Height for east/west panes
1427 * @return JSON Returns a hash of all dimensions: top, bottom, left, right, (outer) width and (outer) height
1429 , calcNewCenterPaneDims = function () {
1431 top: getPaneSize("north", true) // true = include 'spacing' value for pane
1432 , bottom: getPaneSize("south", true)
1433 , left: getPaneSize("west", true)
1434 , right: getPaneSize("east", true)
1439 // NOTE: sC = state.container
1440 // calc center-pane outer dimensions
1441 d.width = sC.innerWidth - d.left - d.right; // outerWidth
1442 d.height = sC.innerHeight - d.bottom - d.top; // outerHeight
1443 // add the 'container border/padding' to get final positions relative to the container
1444 d.top += sC.inset.top;
1445 d.bottom += sC.inset.bottom;
1446 d.left += sC.inset.left;
1447 d.right += sC.inset.right;
1454 * @param {!Object} el
1455 * @param {boolean=} [allStates=false]
1457 , getHoverClasses = function (el, allStates) {
1460 , type = $El.data("layoutRole")
1461 , pane = $El.data("layoutEdge")
1463 , root = o[type +"Class"]
1464 , _pane = "-"+ pane // eg: "-west"
1466 , _closed = "-closed"
1467 , _slide = "-sliding"
1468 , _hover = "-hover " // NOTE the trailing space
1469 , _state = $El.hasClass(root+_closed) ? _closed : _open
1470 , _alt = _state === _closed ? _open : _closed
1471 , classes = (root+_hover) + (root+_pane+_hover) + (root+_state+_hover) + (root+_pane+_state+_hover)
1473 if (allStates) // when 'removing' classes, also remove alternate-state classes
1474 classes += (root+_alt+_hover) + (root+_pane+_alt+_hover);
1476 if (type=="resizer" && $El.hasClass(root+_slide))
1477 classes += (root+_slide+_hover) + (root+_pane+_slide+_hover);
1479 return $.trim(classes);
1481 , addHover = function (evt, el) {
1482 var $E = $(el || this);
1483 if (evt && $E.data("layoutRole") === "toggler")
1484 evt.stopPropagation(); // prevent triggering 'slide' on Resizer-bar
1485 $E.addClass( getHoverClasses($E) );
1487 , removeHover = function (evt, el) {
1488 var $E = $(el || this);
1489 $E.removeClass( getHoverClasses($E, true) );
1492 , onResizerEnter = function (evt) { // ALSO called by toggler.mouseenter
1493 var pane = $(this).data("layoutEdge")
1497 // ignore closed-panes and mouse moving back & forth over resizer!
1498 // also ignore if ANY pane is currently resizing
1499 if ( s.isResizing || state.paneResizing ) return;
1501 if (options.maskPanesEarly)
1502 showMasks( pane, { resizing: true });
1504 , onResizerLeave = function (evt, el) {
1505 var e = el || this // el is only passed when called by the timer
1506 , pane = $(e).data("layoutEdge")
1507 , name = pane +"ResizerLeave"
1510 timer.clear(pane+"_openSlider"); // cancel slideOpen timer, if set
1511 timer.clear(name); // cancel enableSelection timer - may re/set below
1512 // this method calls itself on a timer because it needs to allow
1513 // enough time for dragging to kick-in and set the isResizing flag
1514 // dragging has a 100ms delay set, so this delay must be >100
1515 if (!el) // 1st call - mouseleave event
1516 timer.set(name, function(){ onResizerLeave(evt, e); }, 200);
1517 // if user is resizing, dragStop will reset everything, so skip it here
1518 else if (options.maskPanesEarly && !state.paneResizing) // 2nd call - by timer
1523 * ###########################
1524 * INITIALIZATION METHODS
1525 * ###########################
1529 * Initialize the layout - called automatically whenever an instance of layout is created
1531 * @see none - triggered onInit
1532 * @return mixed true = fully initialized | false = panes not initialized (yet) | 'cancel' = abort
1534 , _create = function () {
1535 // initialize config/options
1540 // TEMP state so isInitialized returns true during init process
1541 s.creatingLayout = true;
1543 // init plugins for this layout, if there are any (eg: stateManagement)
1544 runPluginCallbacks( Instance, $.layout.onCreate );
1546 // options & state have been initialized, so now run beforeLoad callback
1547 // onload will CANCEL layout creation if it returns false
1548 if (false === _runCallbacks("onload_start"))
1551 // initialize the container element
1554 // bind hotkey function - keyDown - if required
1557 // bind window.onunload
1558 $(window).bind("unload."+ sID, unload);
1560 // init plugins for this layout, if there are any (eg: customButtons)
1561 runPluginCallbacks( Instance, $.layout.onLoad );
1563 // if layout elements are hidden, then layout WILL NOT complete initialization!
1564 // initLayoutElements will set initialized=true and run the onload callback IF successful
1565 if (o.initPanes) _initLayoutElements();
1567 delete s.creatingLayout;
1569 return state.initialized;
1573 * Initialize the layout IF not already
1575 * @see All methods in Instance run this test
1576 * @return boolean true = layoutElements have been initialized | false = panes are not initialized (yet)
1578 , isInitialized = function () {
1579 if (state.initialized || state.creatingLayout) return true; // already initialized
1580 else return _initLayoutElements(); // try to init panes NOW
1584 * Initialize the layout - called automatically whenever an instance of layout is created
1586 * @see _create() & isInitialized
1587 * @param {boolean=} [retry=false] // indicates this is a 2nd try
1588 * @return An object pointer to the instance created
1590 , _initLayoutElements = function (retry) {
1591 // initialize config/options
1593 // CANNOT init panes inside a hidden container!
1594 if (!$N.is(":visible")) {
1595 // handle Chrome bug where popup window 'has no height'
1596 // if layout is BODY element, try again in 50ms
1597 // SEE: http://layout.jquery-dev.com/samples/test_popup_window.html
1598 if ( !retry && browser.webkit && $N[0].tagName === "BODY" )
1599 setTimeout(function(){ _initLayoutElements(true); }, 50);
1603 // a center pane is required, so make sure it exists
1604 if (!getPane("center").length) {
1605 return _log( o.errors.centerPaneMissing );
1608 // TEMP state so isInitialized returns true during init process
1609 state.creatingLayout = true;
1611 // update Container dims
1612 $.extend(sC, elDims( $N, o.inset )); // passing inset means DO NOT include insetX values
1614 // initialize all layout elements
1615 initPanes(); // size & position panes - calls initHandles() - which calls initResizable()
1617 if (o.scrollToBookmarkOnLoad) {
1618 var l = self.location;
1619 if (l.hash) l.replace( l.hash ); // scrollTo Bookmark
1622 // check to see if this layout 'nested' inside a pane
1623 if (Instance.hasParentLayout)
1624 o.resizeWithWindow = false;
1625 // bind resizeAll() for 'this layout instance' to window.resize event
1626 else if (o.resizeWithWindow)
1627 $(window).bind("resize."+ sID, windowResize);
1629 delete state.creatingLayout;
1630 state.initialized = true;
1632 // init plugins for this layout, if there are any
1633 runPluginCallbacks( Instance, $.layout.onReady );
1635 // now run the onload callback, if exists
1636 _runCallbacks("onload_end");
1638 return true; // elements initialized successfully
1642 * Initialize nested layouts for a specific pane - can optionally pass layout-options
1644 * @param {(string|Object)} evt_or_pane The pane being opened, ie: north, south, east, or west
1645 * @param {Object=} [opts] Layout-options - if passed, will OVERRRIDE options[pane].children
1646 * @return An object pointer to the layout instance created - or null
1648 , createChildren = function (evt_or_pane, opts) {
1649 var pane = evtPane.call(this, evt_or_pane)
1656 , sm = options.stateManagement || {}
1657 , cos = opts ? (o.children = opts) : o.children
1659 if ( $.isPlainObject( cos ) )
1660 cos = [ cos ]; // convert a hash to a 1-elem array
1661 else if (!cos || !$.isArray( cos ))
1664 $.each( cos, function (idx, co) {
1665 if ( !$.isPlainObject( co ) ) return;
1667 // determine which element is supposed to be the 'child container'
1668 // if pane has a 'containerSelector' OR a 'content-div', use those instead of the pane
1669 var $containers = co.containerSelector ? $P.find( co.containerSelector ) : ($C || $P);
1671 $containers.each(function(){
1673 , child = $cont.data("layout") // see if a child-layout ALREADY exists on this element
1675 // if no layout exists, but children are set, try to create the layout now
1677 // TODO: see about moving this to the stateManagement plugin, as a method
1678 // set a unique child-instance key for this layout, if not already set
1679 setInstanceKey({ container: $cont, options: co }, s );
1680 // If THIS layout has a hash in stateManagement.autoLoad,
1681 // then see if it also contains state-data for this child-layout
1682 // If so, copy the stateData to child.options.stateManagement.autoLoad
1683 if ( sm.includeChildren && state.stateData[pane] ) {
1684 // THIS layout's state was cached when its state was loaded
1685 var paneChildren = state.stateData[pane].children || {}
1686 , childState = paneChildren[ co.instanceKey ]
1687 , co_sm = co.stateManagement || (co.stateManagement = { autoLoad: true })
1689 // COPY the stateData into the autoLoad key
1690 if ( co_sm.autoLoad === true && childState ) {
1691 co_sm.autoSave = false; // disable autoSave because saving handled by parent-layout
1692 co_sm.includeChildren = true; // cascade option - FOR NOW
1693 co_sm.autoLoad = $.extend(true, {}, childState); // COPY the state-hash
1697 // create the layout
1698 child = $cont.layout( co );
1700 // if successful, update data
1702 // add the child and update all layout-pointers
1703 // MAY have already been done by child-layout calling parent.refreshChildren()
1704 refreshChildren( pane, child );
1711 , setInstanceKey = function (child, parentPaneState) {
1712 // create a named key for use in state and instance branches
1713 var $c = child.container
1715 , sm = o.stateManagement
1716 , key = o.instanceKey || $c.data("layoutInstanceKey")
1718 if (!key) key = (sm && sm.cookie ? sm.cookie.name : '') || o.name; // look for a name/key
1719 if (!key) key = "layout"+ (++parentPaneState.childIdx); // if no name/key found, generate one
1720 else key = key.replace(/[^\w-]/gi, '_').replace(/_{2,}/g, '_'); // ensure is valid as a hash key
1721 o.instanceKey = key;
1722 $c.data("layoutInstanceKey", key); // useful if layout is destroyed and then recreated
1727 * @param {string} pane The pane being opened, ie: north, south, east, or west
1728 * @param {Object=} newChild New child-layout Instance to add to this pane
1730 , refreshChildren = function (pane, newChild) {
1732 , pC = children[pane]
1736 // check for destroy()ed layouts and update the child pointers & arrays
1737 if ($.isPlainObject( pC )) {
1738 $.each( pC, function (key, child) {
1739 if (child.destroyed) delete pC[key]
1741 // if no more children, remove the children hash
1742 if ($.isEmptyObject( pC ))
1743 pC = children[pane] = null; // clear children hash
1746 // see if there is a directly-nested layout inside this pane
1747 // if there is, then there can be only ONE child-layout, so check that...
1748 if (!newChild && !pC) {
1749 newChild = $P.data("layout");
1752 // if a newChild instance was passed, add it to children[pane]
1754 // update child.state
1755 newChild.hasParentLayout = true; // set parent-flag in child
1756 // instanceKey is a key-name used in both state and children
1757 o = newChild.options;
1758 // set a unique child-instance key for this layout, if not already set
1759 setInstanceKey( newChild, s );
1760 // add pointer to pane.children hash
1761 if (!pC) pC = children[pane] = {}; // create an empty children hash
1762 pC[ o.instanceKey ] = newChild.container.data("layout"); // add childLayout instance
1765 // ALWAYS refresh the pane.children alias, even if null
1766 Instance[pane].children = children[pane];
1768 // if newChild was NOT passed - see if there is a child layout NOW
1770 createChildren(pane); // MAY create a child and re-call this method
1774 , windowResize = function () {
1776 , delay = Number(o.resizeWithWindowDelay);
1777 if (delay < 10) delay = 100; // MUST have a delay!
1778 // resizing uses a delay-loop because the resize event fires repeatly - except in FF, but delay anyway
1779 timer.clear("winResize"); // if already running
1780 timer.set("winResize", function(){
1781 timer.clear("winResize");
1782 timer.clear("winResizeRepeater");
1783 var dims = elDims( $N, o.inset );
1784 // only trigger resizeAll() if container has changed size
1785 if (dims.innerWidth !== sC.innerWidth || dims.innerHeight !== sC.innerHeight)
1788 // ALSO set fixed-delay timer, if not already running
1789 if (!timer.data["winResizeRepeater"]) setWindowResizeRepeater();
1792 , setWindowResizeRepeater = function () {
1793 var delay = Number(options.resizeWithWindowMaxDelay);
1795 timer.set("winResizeRepeater", function(){ setWindowResizeRepeater(); resizeAll(); }, delay);
1798 , unload = function () {
1801 _runCallbacks("onunload_start");
1803 // trigger plugin callabacks for this layout (eg: stateManagement)
1804 runPluginCallbacks( Instance, $.layout.onUnload );
1806 _runCallbacks("onunload_end");
1810 * Validate and initialize container CSS and events
1814 , _initContainer = function () {
1818 , tag = sC.tagName = N.tagName
1820 , cls = sC.className = N.className
1823 , props = "position,margin,padding,border"
1826 , hid = "hidden" // used A LOT!
1827 // see if this container is a 'pane' inside an outer-layout
1828 , parent = $N.data("parentLayout") // parent-layout Instance
1829 , pane = $N.data("layoutEdge") // pane-name in parent-layout
1830 , isChild = parent && pane
1831 , num = $.layout.cssNum
1834 // sC = state.container
1835 sC.selector = $N.selector.split(".slice")[0];
1836 sC.ref = (o.name ? o.name +' layout / ' : '') + tag + (id ? "#"+id : cls ? '.['+cls+']' : ''); // used in messages
1837 sC.isBody = (tag === "BODY");
1839 // try to find a parent-layout
1840 if (!isChild && !sC.isBody) {
1841 $parent = $N.closest("."+ $.layout.defaults.panes.paneClass);
1842 parent = $parent.data("parentLayout");
1843 pane = $parent.data("layoutEdge");
1844 isChild = parent && pane;
1849 , layoutContainer: sID // FLAG to indicate this is a layout-container - contains unique internal ID
1851 .addClass(o.containerClass)
1853 var layoutMethods = {
1856 , resizeAll: 'resizeAll'
1857 , resize: 'resizeAll'
1859 // loop hash and bind all methods - include layoutID namespacing
1860 for (name in layoutMethods) {
1861 $N.bind("layout"+ name.toLowerCase() +"."+ sID, Instance[ layoutMethods[name] || name ]);
1864 // if this container is another layout's 'pane', then set child/parent pointers
1866 // update parent flag
1867 Instance.hasParentLayout = true;
1868 // set pointers to THIS child-layout (Instance) in parent-layout
1869 parent.refreshChildren( pane, Instance );
1872 // SAVE original container CSS for use in destroy()
1873 if (!$N.data(css)) {
1874 // handle props like overflow different for BODY & HTML - has 'system default' values
1877 $N.data(css, $.extend( styles($N, props), {
1878 height: $N.css("height")
1879 , overflow: $N.css("overflow")
1880 , overflowX: $N.css("overflowX")
1881 , overflowY: $N.css("overflowY")
1883 // ALSO SAVE <HTML> CSS
1884 $H.data(css, $.extend( styles($H, 'padding'), {
1885 height: "auto" // FF would return a fixed px-size!
1886 , overflow: $H.css("overflow")
1887 , overflowX: $H.css("overflowX")
1888 , overflowY: $H.css("overflowY")
1891 else // handle props normally for non-body elements
1892 $N.data(css, styles($N, props+",top,bottom,left,right,width,height,overflow,overflowX,overflowY") );
1896 // common container CSS
1904 if (o.inset && !$.isPlainObject(o.inset)) {
1905 // can specify a single number for equal outset all-around
1906 n = parseInt(o.inset, 10) || 0
1915 // format html & body if this is a full page layout
1917 // if HTML has padding, use this as an outer-spacing around BODY
1919 // use padding from parent-elem (HTML) as outset
1921 top: num($H, "paddingTop")
1922 , bottom: num($H, "paddingBottom")
1923 , left: num($H, "paddingLeft")
1924 , right: num($H, "paddingRight")
1927 else if (!$.isPlainObject(o.outset)) {
1928 // can specify a single number for equal outset all-around
1929 n = parseInt(o.outset, 10) || 0
1940 , border: "none" // no border or padding allowed when using height = 100%
1941 , padding: 0 // ditto
1945 if (browser.isIE6) {
1946 // IE6 CANNOT use the trick of setting absolute positioning on all 4 sides - must have 'height'
1950 , border: "none" // no border or padding allowed when using height = 100%
1951 , padding: 0 // ditto
1953 , position: "relative"
1955 // convert body padding to an inset option - the border cannot be measured in IE6!
1956 if (!o.inset) o.inset = elDims( $N ).inset;
1958 else { // use absolute positioning for BODY to allow borders & padding without overflow
1963 , position: "absolute" // allows for border and padding on BODY
1965 // apply edge-positioning created above
1968 // set current layout-container dimensions
1969 $.extend(sC, elDims( $N, o.inset )); // passing inset means DO NOT include insetX values
1972 // container MUST have 'position'
1973 var p = $N.css("position");
1974 if (!p || !p.match(/(fixed|absolute|relative)/))
1975 $N.css("position","relative");
1977 // set current layout-container dimensions
1978 if ( $N.is(":visible") ) {
1979 $.extend(sC, elDims( $N, o.inset )); // passing inset means DO NOT change insetX (padding) values
1980 if (sC.innerHeight < 1) // container has no 'height' - warn developer
1981 _log( o.errors.noContainerHeight.replace(/CONTAINER/, sC.ref) );
1985 // if container has min-width/height, then enable scrollbar(s)
1986 if ( num($N, "minWidth") ) $N.parent().css("overflowX","auto");
1987 if ( num($N, "minHeight") ) $N.parent().css("overflowY","auto");
1993 * Bind layout hotkeys - if options enabled
1995 * @see _create() and addPane()
1996 * @param {string=} [panes=""] The edge(s) to process
1998 , initHotkeys = function (panes) {
1999 panes = panes ? panes.split(",") : _c.borderPanes;
2000 // bind keyDown to capture hotkeys, if option enabled for ANY pane
2001 $.each(panes, function (i, pane) {
2002 var o = options[pane];
2003 if (o.enableCursorHotkey || o.customHotkey) {
2004 $(document).bind("keydown."+ sID, keyDown); // only need to bind this ONCE
2005 return false; // BREAK - binding was done
2011 * Build final OPTIONS data
2015 , initOptions = function () {
2016 var data, d, pane, key, val, i, c, o;
2018 // reprocess user's layout-options to have correct options sub-key structure
2019 opts = $.layout.transformData( opts, true ); // panes = default subkey
2021 // auto-rename old options for backward compatibility
2022 opts = $.layout.backwardCompatibility.renameAllOptions( opts );
2024 // if user-options has 'panes' key (pane-defaults), clean it...
2025 if (!$.isEmptyObject(opts.panes)) {
2026 // REMOVE any pane-defaults that MUST be set per-pane
2027 data = $.layout.optionsMap.noDefault;
2028 for (i=0, c=data.length; i<c; i++) {
2030 delete opts.panes[key]; // OK if does not exist
2032 // REMOVE any layout-options specified under opts.panes
2033 data = $.layout.optionsMap.layout;
2034 for (i=0, c=data.length; i<c; i++) {
2036 delete opts.panes[key]; // OK if does not exist
2040 // MOVE any NON-layout-options from opts-root to opts.panes
2041 data = $.layout.optionsMap.layout;
2042 var rootKeys = $.layout.config.optionRootKeys;
2045 if ($.inArray(key, rootKeys) < 0 && $.inArray(key, data) < 0) {
2046 if (!opts.panes[key])
2047 opts.panes[key] = $.isPlainObject(val) ? $.extend(true, {}, val) : val;
2052 // START by updating ALL options from opts
2053 $.extend(true, options, opts);
2055 // CREATE final options (and config) for EACH pane
2056 $.each(_c.allPanes, function (i, pane) {
2058 // apply 'pane-defaults' to CONFIG.[PANE]
2059 _c[pane] = $.extend(true, {}, _c.panes, _c[pane]);
2064 // center-pane uses SOME keys in defaults.panes branch
2065 if (pane === 'center') {
2066 // ONLY copy keys from opts.panes listed in: $.layout.optionsMap.center
2067 data = $.layout.optionsMap.center; // list of 'center-pane keys'
2068 for (i=0, c=data.length; i<c; i++) { // loop the list...
2070 // only need to use pane-default if pane-specific value not set
2071 if (!opts.center[key] && (opts.panes[key] || !o[key]))
2072 o[key] = d[key]; // pane-default
2076 // border-panes use ALL keys in defaults.panes branch
2077 o = options[pane] = $.extend(true, {}, d, o); // re-apply pane-specific opts AFTER pane-defaults
2078 createFxOptions( pane );
2079 // ensure all border-pane-specific base-classes exist
2080 if (!o.resizerClass) o.resizerClass = "ui-layout-resizer";
2081 if (!o.togglerClass) o.togglerClass = "ui-layout-toggler";
2083 // ensure we have base pane-class (ALL panes)
2084 if (!o.paneClass) o.paneClass = "ui-layout-pane";
2087 // update options.zIndexes if a zIndex-option specified
2088 var zo = opts.zIndex
2089 , z = options.zIndexes;
2092 z.content_mask = max(zo+1, z.content_mask); // MIN = +1
2093 z.resizer_normal = max(zo+2, z.resizer_normal); // MIN = +2
2096 // DELETE 'panes' key now that we are done - values were copied to EACH pane
2097 delete options.panes;
2100 function createFxOptions ( pane ) {
2101 var o = options[pane]
2102 , d = options.panes;
2103 // ensure fxSettings key to avoid errors
2104 if (!o.fxSettings) o.fxSettings = {};
2105 if (!d.fxSettings) d.fxSettings = {};
2107 $.each(["_open","_close","_size"], function (i,n) {
2110 , sSpeed = "fxSpeed"+ n
2111 , sSettings = "fxSettings"+ n
2112 // recalculate fxName according to specificity rules
2113 , fxName = o[sName] =
2114 o[sName] // options.west.fxName_open
2115 || d[sName] // options.panes.fxName_open
2116 || o.fxName // options.west.fxName
2117 || d.fxName // options.panes.fxName
2118 || "none" // MEANS $.layout.defaults.panes.fxName == "" || false || null || 0
2119 , fxExists = $.effects && ($.effects[fxName] || ($.effects.effect && $.effects.effect[fxName]))
2121 // validate fxName to ensure is valid effect - MUST have effect-config data in options.effects
2122 if (fxName === "none" || !options.effects[fxName] || !fxExists)
2123 fxName = o[sName] = "none"; // effect not loaded OR unrecognized fxName
2125 // set vars for effects subkeys to simplify logic
2126 var fx = options.effects[fxName] || {} // effects.slide
2127 , fx_all = fx.all || null // effects.slide.all
2128 , fx_pane = fx[pane] || null // effects.slide.west
2130 // create fxSpeed[_open|_close|_size]
2132 o[sSpeed] // options.west.fxSpeed_open
2133 || d[sSpeed] // options.west.fxSpeed_open
2134 || o.fxSpeed // options.west.fxSpeed
2135 || d.fxSpeed // options.panes.fxSpeed
2136 || null // DEFAULT - let fxSetting.duration control speed
2138 // create fxSettings[_open|_close|_size]
2139 o[sSettings] = $.extend(
2142 , fx_all // effects.slide.all
2143 , fx_pane // effects.slide.west
2144 , d.fxSettings // options.panes.fxSettings
2145 , o.fxSettings // options.west.fxSettings
2146 , d[sSettings] // options.panes.fxSettings_open
2147 , o[sSettings] // options.west.fxSettings_open
2151 // DONE creating action-specific-settings for this pane,
2152 // so DELETE generic options - are no longer meaningful
2155 delete o.fxSettings;
2160 * Initialize module objects, styling, size and position for all panes
2162 * @see _initElements()
2163 * @param {string} pane The pane to process
2165 , getPane = function (pane) {
2166 var sel = options[pane].paneSelector
2167 if (sel.substr(0,1)==="#") // ID selector
2168 // NOTE: elements selected 'by ID' DO NOT have to be 'children'
2169 return $N.find(sel).eq(0);
2170 else { // class or other selector
2171 var $P = $N.children(sel).eq(0);
2172 // look for the pane nested inside a 'form' element
2173 return $P.length ? $P : $N.children("form:first").children(sel).eq(0);
2178 * @param {Object=} evt
2180 , initPanes = function (evt) {
2181 // stopPropagation if called by trigger("layoutinitpanes") - use evtPane utility
2184 // NOTE: do north & south FIRST so we can measure their height - do center LAST
2185 $.each(_c.allPanes, function (idx, pane) {
2186 addPane( pane, true );
2189 // init the pane-handles NOW in case we have to hide or close the pane below
2192 // now that all panes have been initialized and initially-sized,
2193 // make sure there is really enough space available for each pane
2194 $.each(_c.borderPanes, function (i, pane) {
2195 if ($Ps[pane] && state[pane].isVisible) { // pane is OPEN
2196 setSizeLimits(pane);
2197 makePaneFit(pane); // pane may be Closed, Hidden or Resized by makePaneFit()
2200 // size center-pane AGAIN in case we 'closed' a border-pane in loop above
2201 sizeMidPanes("center");
2203 // Chrome/Webkit sometimes fires callbacks BEFORE it completes resizing!
2204 // Before RC30.3, there was a 10ms delay here, but that caused layout
2205 // to load asynchrously, which is BAD, so try skipping delay for now
2207 // process pane contents and callbacks, and init/resize child-layout if exists
2208 $.each(_c.allPanes, function (idx, pane) {
2209 afterInitPane(pane);
2214 * Add a pane to the layout - subroutine of initPanes()
2217 * @param {string} pane The pane to process
2218 * @param {boolean=} [force=false] Size content after init
2220 , addPane = function (pane, force) {
2221 if ( !force && !isInitialized() ) return;
2228 , spacing = o.spacing_open || 0
2229 , isCenter = (pane === "center")
2232 , size, minSize, maxSize, child
2234 // if pane-pointer already exists, remove the old one first
2236 removePane( pane, false, true, false );
2238 $Cs[pane] = false; // init
2240 $P = $Ps[pane] = getPane(pane);
2242 $Ps[pane] = false; // logic
2246 // SAVE original Pane CSS
2247 if (!$P.data("layoutCSS")) {
2248 var props = "position,top,left,bottom,right,width,height,overflow,zIndex,display,backgroundColor,padding,margin,border";
2249 $P.data("layoutCSS", styles($P, props));
2252 // create alias for pane data in Instance - initHandles will add more
2256 , content: $Cs[pane]
2257 , options: options[pane]
2258 , state: state[pane]
2259 , children: children[pane]
2262 // add classes, attributes & events
2264 parentLayout: Instance // pointer to Layout Instance
2265 , layoutPane: Instance[pane] // NEW pointer to pane-alias-object
2267 , layoutRole: "pane"
2269 .css(c.cssReq).css("zIndex", options.zIndexes.pane_normal)
2270 .css(o.applyDemoStyles ? c.cssDemo : {}) // demo styles
2271 .addClass( o.paneClass +" "+ o.paneClass+"-"+pane ) // default = "ui-layout-pane ui-layout-pane-west" - may be a dupe of 'paneSelector'
2272 .bind("mouseenter."+ sID, addHover )
2273 .bind("mouseleave."+ sID, removeHover )
2285 , sizePane: 'sizePane'
2288 , enableClosable: ''
2289 , disableClosable: ''
2290 , enableSlideable: ''
2291 , disableSlideable: ''
2292 , enableResizable: ''
2293 , disableResizable: ''
2294 , swapPanes: 'swapPanes'
2297 , removePane: 'removePane'
2298 , remove: 'removePane'
2299 , createChildren: ''
2300 , resizeChildren: ''
2301 , resizeAll: 'resizeAll'
2302 , resizeLayout: 'resizeAll'
2305 // loop hash and bind all methods - include layoutID namespacing
2306 for (name in paneMethods) {
2307 $P.bind("layoutpane"+ name.toLowerCase() +"."+ sID, Instance[ paneMethods[name] || name ]);
2310 // see if this pane has a 'scrolling-content element'
2311 initContent(pane, false); // false = do NOT sizeContent() - called later
2314 // call _parseSize AFTER applying pane classes & styles - but before making visible (if hidden)
2315 // if o.size is auto or not valid, then MEASURE the pane and use that as its 'size'
2316 size = s.size = _parseSize(pane, o.size);
2317 minSize = _parseSize(pane,o.minSize) || 1;
2318 maxSize = _parseSize(pane,o.maxSize) || 100000;
2319 if (size > 0) size = max(min(size, maxSize), minSize);
2320 s.autoResize = o.autoResize; // used with percentage sizes
2322 // state for border-panes
2323 s.isClosed = false; // true = pane is closed
2324 s.isSliding = false; // true = pane is currently open by 'sliding' over adjacent panes
2325 s.isResizing= false; // true = pane is in process of being resized
2326 s.isHidden = false; // true = pane is hidden - no spacing, resizer or toggler is visible!
2328 // array for 'pin buttons' whose classNames are auto-updated on pane-open/-close
2329 if (!s.pins) s.pins = [];
2331 // states common to ALL panes
2332 s.tagName = $P[0].tagName;
2333 s.edge = pane; // useful if pane is (or about to be) 'swapped' - easy find out where it is (or is going)
2334 s.noRoom = false; // true = pane 'automatically' hidden due to insufficient room - will unhide automatically
2335 s.isVisible = true; // false = pane is invisible - closed OR hidden - simplify logic
2337 // init pane positioning
2338 setPanePosition( pane );
2340 // if pane is not visible,
2341 if (dir === "horz") // north or south pane
2342 CSS.height = cssH($P, size);
2343 else if (dir === "vert") // east or west pane
2344 CSS.width = cssW($P, size);
2345 //else if (isCenter) {}
2347 $P.css(CSS); // apply size -- top, bottom & height will be set by sizeMidPanes
2348 if (dir != "horz") sizeMidPanes(pane, true); // true = skipCallback
2350 // if manually adding a pane AFTER layout initialization, then...
2351 if (state.initialized) {
2352 initHandles( pane );
2353 initHotkeys( pane );
2356 // close or hide the pane if specified in settings
2357 if (o.initClosed && o.closable && !o.initHidden)
2358 close(pane, true, true); // true, true = force, noAnimation
2359 else if (o.initHidden || o.initClosed)
2360 hide(pane); // will be completely invisible - no resizer or spacing
2362 // make the pane visible - in case was initially hidden
2363 $P.css("display","block");
2364 // ELSE setAsOpen() - called later by initHandles()
2366 // RESET visibility now - pane will appear IF display:block
2367 $P.css("visibility","visible");
2369 // check option for auto-handling of pop-ups & drop-downs
2370 if (o.showOverflowOnHover)
2371 $P.hover( allowOverflow, resetOverflow );
2373 // if manually adding a pane AFTER layout initialization, then...
2374 if (state.initialized) {
2375 afterInitPane( pane );
2379 , afterInitPane = function (pane) {
2386 // see if there is a directly-nested layout inside this pane
2387 if ($P.data("layout"))
2388 refreshChildren( pane, $P.data("layout") );
2390 // process pane contents and callbacks, and init/resize child-layout if exists
2391 if (s.isVisible) { // pane is OPEN
2392 if (state.initialized) // this pane was added AFTER layout was created
2393 resizeAll(); // will also sizeContent
2397 if (o.triggerEventsOnLoad)
2398 _runCallbacks("onresize_end", pane);
2399 else // automatic if onresize called, otherwise call it specifically
2400 // resize child - IF inner-layout already exists (created before this layout)
2401 resizeChildren(pane, true); // a previously existing childLayout
2404 // init childLayouts - even if pane is not visible
2405 if (o.initChildren && o.children)
2406 createChildren(pane);
2410 * @param {string=} panes The pane(s) to process
2412 , setPanePosition = function (panes) {
2413 panes = panes ? panes.split(",") : _c.borderPanes;
2415 // create toggler DIVs for each pane, and set object pointers for them, eg: $R.north = north toggler DIV
2416 $.each(panes, function (i, pane) {
2421 , side = _c[pane].side
2424 if (!$P) return; // pane does not exist - skip
2426 // set css-position to account for container borders & padding
2428 case "north": CSS.top = sC.inset.top;
2429 CSS.left = sC.inset.left;
2430 CSS.right = sC.inset.right;
2432 case "south": CSS.bottom = sC.inset.bottom;
2433 CSS.left = sC.inset.left;
2434 CSS.right = sC.inset.right;
2436 case "west": CSS.left = sC.inset.left; // top, bottom & height set by sizeMidPanes()
2438 case "east": CSS.right = sC.inset.right; // ditto
2440 case "center": // top, left, width & height set by sizeMidPanes()
2445 // update resizer position
2446 if ($R && s.isClosed)
2447 $R.css(side, sC.inset[side]);
2448 else if ($R && !s.isHidden)
2449 $R.css(side, sC.inset[side] + getPaneSize(pane));
2454 * Initialize module objects, styling, size and position for all resize bars and toggler buttons
2457 * @param {string=} [panes=""] The edge(s) to process
2459 , initHandles = function (panes) {
2460 panes = panes ? panes.split(",") : _c.borderPanes;
2462 // create toggler DIVs for each pane, and set object pointers for them, eg: $R.north = north toggler DIV
2463 $.each(panes, function (i, pane) {
2465 $Rs[pane] = false; // INIT
2467 if (!$P) return; // pane does not exist - skip
2469 var o = options[pane]
2472 , paneId = o.paneSelector.substr(0,1) === "#" ? o.paneSelector.substr(1) : ""
2473 , rClass = o.resizerClass
2474 , tClass = o.togglerClass
2475 , spacing = (s.isVisible ? o.spacing_open : o.spacing_closed)
2476 , _pane = "-"+ pane // used for classNames
2477 , _state = (s.isVisible ? "-open" : "-closed") // used for classNames
2478 , I = Instance[pane]
2480 , $R = I.resizer = $Rs[pane] = $("<div></div>")
2481 // INIT TOGGLER BUTTON
2482 , $T = I.toggler = (o.closable ? $Ts[pane] = $("<div></div>") : false)
2485 //if (s.isVisible && o.resizable) ... handled by initResizable
2486 if (!s.isVisible && o.slidable)
2487 $R.attr("title", o.tips.Slide).css("cursor", o.sliderCursor);
2489 $R // if paneSelector is an ID, then create a matching ID for the resizer, eg: "#paneLeft" => "paneLeft-resizer"
2490 .attr("id", paneId ? paneId +"-resizer" : "" )
2492 parentLayout: Instance
2493 , layoutPane: Instance[pane] // NEW pointer to pane-alias-object
2495 , layoutRole: "resizer"
2497 .css(_c.resizers.cssReq).css("zIndex", options.zIndexes.resizer_normal)
2498 .css(o.applyDemoStyles ? _c.resizers.cssDemo : {}) // add demo styles
2499 .addClass(rClass +" "+ rClass+_pane)
2500 .hover(addHover, removeHover) // ALWAYS add hover-classes, even if resizing is not enabled - handle with CSS instead
2501 .hover(onResizerEnter, onResizerLeave) // ALWAYS NEED resizer.mouseleave to balance toggler.mouseenter
2502 .mousedown($.layout.disableTextSelection) // prevent text-selection OUTSIDE resizer
2503 .mouseup($.layout.enableTextSelection) // not really necessary, but just in case
2504 .appendTo($N) // append DIV to container
2506 if ($.fn.disableSelection)
2507 $R.disableSelection(); // prevent text-selection INSIDE resizer
2508 if (o.resizerDblClickToggle)
2509 $R.bind("dblclick."+ sID, toggle );
2512 $T // if paneSelector is an ID, then create a matching ID for the resizer, eg: "#paneLeft" => "#paneLeft-toggler"
2513 .attr("id", paneId ? paneId +"-toggler" : "" )
2515 parentLayout: Instance
2516 , layoutPane: Instance[pane] // NEW pointer to pane-alias-object
2518 , layoutRole: "toggler"
2520 .css(_c.togglers.cssReq) // add base/required styles
2521 .css(o.applyDemoStyles ? _c.togglers.cssDemo : {}) // add demo styles
2522 .addClass(tClass +" "+ tClass+_pane)
2523 .hover(addHover, removeHover) // ALWAYS add hover-classes, even if toggling is not enabled - handle with CSS instead
2524 .bind("mouseenter", onResizerEnter) // NEED toggler.mouseenter because mouseenter MAY NOT fire on resizer
2525 .appendTo($R) // append SPAN to resizer DIV
2527 // ADD INNER-SPANS TO TOGGLER
2528 if (o.togglerContent_open) // ui-layout-open
2529 $("<span>"+ o.togglerContent_open +"</span>")
2532 , layoutRole: "togglerContent"
2534 .data("layoutRole", "togglerContent")
2535 .data("layoutEdge", pane)
2536 .addClass("content content-open")
2537 .css("display","none")
2539 //.hover( addHover, removeHover ) // use ui-layout-toggler-west-hover .content-open instead!
2541 if (o.togglerContent_closed) // ui-layout-closed
2542 $("<span>"+ o.togglerContent_closed +"</span>")
2545 , layoutRole: "togglerContent"
2547 .addClass("content content-closed")
2548 .css("display","none")
2550 //.hover( addHover, removeHover ) // use ui-layout-toggler-west-hover .content-closed instead!
2552 // ADD TOGGLER.click/.hover
2553 enableClosable(pane);
2556 // add Draggable events
2557 initResizable(pane);
2559 // ADD CLASSNAMES & SLIDE-BINDINGS - eg: class="resizer resizer-west resizer-open"
2561 setAsOpen(pane); // onOpen will be called, but NOT onResize
2563 setAsClosed(pane); // onClose will be called
2564 bindStartSlidingEvents(pane, true); // will enable events IF option is set
2569 // SET ALL HANDLE DIMENSIONS
2575 * Initialize scrolling ui-layout-content div - if exists
2577 * @see initPane() - or externally after an Ajax injection
2578 * @param {string} pane The pane to process
2579 * @param {boolean=} [resize=true] Size content after init
2581 , initContent = function (pane, resize) {
2582 if (!isInitialized()) return;
2585 , sel = o.contentSelector
2586 , I = Instance[pane]
2590 if (sel) $C = I.content = $Cs[pane] = (o.findNestedContent)
2591 ? $P.find(sel).eq(0) // match 1-element only
2592 : $P.children(sel).eq(0)
2594 if ($C && $C.length) {
2595 $C.data("layoutRole", "content");
2596 // SAVE original Content CSS
2597 if (!$C.data("layoutCSS"))
2598 $C.data("layoutCSS", styles($C, "height"));
2599 $C.css( _c.content.cssReq );
2600 if (o.applyDemoStyles) {
2601 $C.css( _c.content.cssDemo ); // add padding & overflow: auto to content-div
2602 $P.css( _c.content.cssDemoPane ); // REMOVE padding/scrolling from pane
2604 // ensure no vertical scrollbar on pane - will mess up measurements
2605 if ($P.css("overflowX").match(/(scroll|auto)/)) {
2606 $P.css("overflow", "hidden");
2608 state[pane].content = {}; // init content state
2609 if (resize !== false) sizeContent(pane);
2610 // sizeContent() is called AFTER init of all elements
2613 I.content = $Cs[pane] = false;
2618 * Add resize-bars to all panes that specify it in options
2619 * -dependancy: $.fn.resizable - will skip if not found
2622 * @param {string=} [panes=""] The edge(s) to process
2624 , initResizable = function (panes) {
2625 var draggingAvailable = $.layout.plugins.draggable
2626 , side // set in start()
2628 panes = panes ? panes.split(",") : _c.borderPanes;
2630 $.each(panes, function (idx, pane) {
2631 var o = options[pane];
2632 if (!draggingAvailable || !$Ps[pane] || !o.resizable) {
2633 o.resizable = false;
2634 return true; // skip to next
2638 , z = options.zIndexes
2640 , side = c.dir=="horz" ? "top" : "left"
2643 , base = o.resizerClass
2644 , lastPos = 0 // used when live-resizing
2645 , r, live // set in start because may change
2646 // 'drag' classes are applied to the ORIGINAL resizer-bar while dragging is in process
2647 , resizerClass = base+"-drag" // resizer-drag
2648 , resizerPaneClass = base+"-"+pane+"-drag" // resizer-north-drag
2649 // 'helper' class is applied to the CLONED resizer-bar while it is being dragged
2650 , helperClass = base+"-dragging" // resizer-dragging
2651 , helperPaneClass = base+"-"+pane+"-dragging" // resizer-north-dragging
2652 , helperLimitClass = base+"-dragging-limit" // resizer-drag
2653 , helperPaneLimitClass = base+"-"+pane+"-dragging-limit" // resizer-north-drag
2654 , helperClassesSet = false // logic var
2658 $R.attr("title", o.tips.Resize)
2659 .css("cursor", o.resizerCursor); // n-resize, s-resize, etc
2662 containment: $N[0] // limit resizing to layout container
2663 , axis: (c.dir=="horz" ? "y" : "x") // limit resizing to horz or vert axis
2666 , grid: o.resizingGrid
2667 // basic format for helper - style it using class: .ui-draggable-dragging
2669 , opacity: o.resizerDragOpacity
2670 , addClasses: false // avoid ui-state-disabled class when disabled
2671 //, iframeFix: o.draggableIframeFix // TODO: consider using when bug is fixed
2672 , zIndex: z.resizer_drag
2674 , start: function (e, ui) {
2675 // REFRESH options & state pointers in case we used swapPanes
2679 live = o.livePaneResizing;
2681 // ondrag_start callback - will CANCEL hide if returns false
2682 // TODO: dragging CANNOT be cancelled like this, so see if there is a way?
2683 if (false === _runCallbacks("ondrag_start", pane)) return false;
2685 s.isResizing = true; // prevent pane from closing while resizing
2686 state.paneResizing = pane; // easy to see if ANY pane is resizing
2687 timer.clear(pane+"_closeSlider"); // just in case already triggered
2689 // SET RESIZER LIMITS - used in drag()
2690 setSizeLimits(pane); // update pane/resizer state
2691 r = s.resizerPosition;
2692 lastPos = ui.position[ side ]
2694 $R.addClass( resizerClass +" "+ resizerPaneClass ); // add drag classes
2695 helperClassesSet = false; // reset logic var - see drag()
2697 // MASK PANES CONTAINING IFRAMES, APPLETS OR OTHER TROUBLESOME ELEMENTS
2698 showMasks( pane, { resizing: true });
2701 , drag: function (e, ui) {
2702 if (!helperClassesSet) { // can only add classes after clone has been added to the DOM
2703 //$(".ui-draggable-dragging")
2705 .addClass( helperClass +" "+ helperPaneClass ) // add helper classes
2706 .css({ right: "auto", bottom: "auto" }) // fix dir="rtl" issue
2707 .children().css("visibility","hidden") // hide toggler inside dragged resizer-bar
2709 helperClassesSet = true;
2710 // draggable bug!? RE-SET zIndex to prevent E/W resize-bar showing through N/S pane!
2711 if (s.isSliding) $Ps[pane].css("zIndex", z.pane_sliding);
2713 // CONTAIN RESIZER-BAR TO RESIZING LIMITS
2715 if (ui.position[side] < r.min) {
2716 ui.position[side] = r.min;
2719 else if (ui.position[side] > r.max) {
2720 ui.position[side] = r.max;
2723 // ADD/REMOVE dragging-limit CLASS
2725 ui.helper.addClass( helperLimitClass +" "+ helperPaneLimitClass ); // at dragging-limit
2726 window.defaultStatus = (limit>0 && pane.match(/(north|west)/)) || (limit<0 && pane.match(/(south|east)/)) ? o.tips.maxSizeWarning : o.tips.minSizeWarning;
2729 ui.helper.removeClass( helperLimitClass +" "+ helperPaneLimitClass ); // not at dragging-limit
2730 window.defaultStatus = "";
2732 // DYNAMICALLY RESIZE PANES IF OPTION ENABLED
2733 // won't trigger unless resizer has actually moved!
2734 if (live && Math.abs(ui.position[side] - lastPos) >= o.liveResizingTolerance) {
2735 lastPos = ui.position[side];
2736 resizePanes(e, ui, pane)
2740 , stop: function (e, ui) {
2741 $('body').enableSelection(); // RE-ENABLE TEXT SELECTION
2742 window.defaultStatus = ""; // clear 'resizing limit' message from statusbar
2743 $R.removeClass( resizerClass +" "+ resizerPaneClass ); // remove drag classes from Resizer
2744 s.isResizing = false;
2745 state.paneResizing = false; // easy to see if ANY pane is resizing
2746 resizePanes(e, ui, pane, true); // true = resizingDone
2755 * Sub-routine called from stop() - and drag() if livePaneResizing
2757 * @param {!Object} evt
2758 * @param {!Object} ui
2759 * @param {string} pane
2760 * @param {boolean=} [resizingDone=false]
2762 var resizePanes = function (evt, ui, pane, resizingDone) {
2763 var dragPos = ui.position
2770 case "north": resizerPos = dragPos.top; break;
2771 case "west": resizerPos = dragPos.left; break;
2772 case "south": resizerPos = sC.layoutHeight - dragPos.top - o.spacing_open; break;
2773 case "east": resizerPos = sC.layoutWidth - dragPos.left - o.spacing_open; break;
2775 // remove container margin from resizer position to get the pane size
2776 var newSize = resizerPos - sC.inset[c.side];
2778 // Disable OR Resize Mask(s) created in drag.start
2779 if (!resizingDone) {
2780 // ensure we meet liveResizingTolerance criteria
2781 if (Math.abs(newSize - s.size) < o.liveResizingTolerance)
2782 return; // SKIP resize this time
2784 manualSizePane(pane, newSize, false, true); // true = noAnimation
2785 sizeMasks(); // resize all visible masks
2787 else { // resizingDone
2788 // ondrag_end callback
2789 if (false !== _runCallbacks("ondrag_end", pane))
2790 manualSizePane(pane, newSize, false, true); // true = noAnimation
2791 hideMasks(true); // true = force hiding all masks even if one is 'sliding'
2792 if (s.isSliding) // RE-SHOW 'object-masks' so objects won't show through sliding pane
2793 showMasks( pane, { resizing: true });
2801 * Needed to overlay a DIV over an IFRAME-pane because mask CANNOT be *inside* the pane
2802 * Called when mask created, and during livePaneResizing
2804 , sizeMask = function () {
2806 , pane = $M.data("layoutMask") // eg: "west"
2809 // only masks over an IFRAME-pane need manual resizing
2810 if (s.tagName == "IFRAME" && s.isVisible) // no need to mask closed/hidden panes
2813 , left: s.offsetLeft
2814 , width: s.outerWidth
2815 , height: s.outerHeight
2819 $M.css( $P.position() ).css({ width: $P[0].offsetWidth, height: $P[0].offsetHeight });
2822 , sizeMasks = function () {
2823 $Ms.each( sizeMask ); // resize all 'visible' masks
2827 * @param {string} pane The pane being resized, animated or isSliding
2828 * @param {Object=} [args] (optional) Options: which masks to apply, and to which panes
2830 , showMasks = function (pane, args) {
2832 , panes = ["center"]
2833 , z = options.zIndexes
2838 , sliding: state[pane].isSliding
2845 panes.push( _c.oppositeEdge[pane] ); // ADD the oppositeEdge-pane
2847 if (c.dir === "horz") {
2852 $.each(panes, function(i,p){
2855 if (s.isVisible && ( o.maskObjects || (!a.objectsOnly && o.maskContents) )) {
2856 getMasks(p).each(function(){
2857 sizeMask.call(this);
2858 this.style.zIndex = s.isSliding ? z.pane_sliding+1 : z.pane_normal+1
2859 this.style.display = "block";
2866 * @param {boolean=} force Hide masks even if a pane is sliding
2868 , hideMasks = function (force) {
2869 // ensure no pane is resizing - could be a timing issue
2870 if (force || !state.paneResizing) {
2871 $Ms.hide(); // hide ALL masks
2873 // if ANY pane is sliding, then DO NOT remove masks from panes with maskObjects enabled
2874 else if (!force && !$.isEmptyObject( state.panesSliding )) {
2875 var i = $Ms.length - 1
2877 for (; i >= 0; i--) {
2879 p = $M.data("layoutMask");
2880 if (!options[p].maskObjects) {
2888 * @param {string} pane
2890 , getMasks = function (pane) {
2892 , $M, i = 0, c = $Ms.length
2896 if ($M.data("layoutMask") === pane)
2897 $Masks = $Masks.add( $M );
2902 return createMasks(pane);
2908 * Generates both DIV (ALWAYS used) and IFRAME (optional) elements as masks
2909 * An IFRAME mask is created *under* the DIV when maskObjects=true, because a DIV cannot mask an applet
2911 * @param {string} pane
2913 , createMasks = function (pane) {
2918 , z = options.zIndexes
2919 , isIframe, el, $M, css, i
2921 if (!o.maskContents && !o.maskObjects) return $([]);
2922 // if o.maskObjects=true, then loop TWICE to create BOTH kinds of mask, else only create a DIV
2923 for (i=0; i < (o.maskObjects ? 2 : 1); i++) {
2924 isIframe = o.maskObjects && i==0;
2925 el = document.createElement( isIframe ? "iframe" : "div" );
2926 $M = $(el).data("layoutMask", pane); // add data to relate mask to pane
2927 el.className = "ui-layout-mask ui-layout-mask-"+ pane; // for user styling
2929 // Both DIVs and IFRAMES
2930 css.background = "#FFF";
2931 css.position = "absolute";
2932 css.display = "block";
2933 if (isIframe) { // IFRAME-only props
2934 el.src = "about:blank";
2938 css.filter = "Alpha(Opacity='0')";
2939 //el.allowTransparency = true; - for IE, but breaks masking ability!
2941 else { // DIV-only props
2942 css.opacity = 0.001;
2943 css.filter = "Alpha(Opacity='1')";
2945 // if pane IS an IFRAME, then must mask the pane itself
2946 if (s.tagName == "IFRAME") {
2947 // NOTE sizing done by a subroutine so can be called during live-resizing
2948 css.zIndex = z.pane_normal+1; // 1-higher than pane
2949 $N.append( el ); // append to LAYOUT CONTAINER
2951 // otherwise put masks *inside the pane* to mask its contents
2953 $M.addClass("ui-layout-mask-inside-pane");
2954 css.zIndex = o.maskZindex || z.content_mask; // usually 1, but customizable
2958 css.height = "100%";
2959 $P.append( el ); // append INSIDE pane element
2961 // add Mask to cached array so can be resized & reused
2962 $Ms = $Ms.add( el );
2969 * Destroy this layout and reset all elements
2971 * @param {boolean=} [destroyChildren=false] Destory Child-Layouts first?
2973 , destroy = function (evt_or_destroyChildren, destroyChildren) {
2974 // UNBIND layout events and remove global object
2975 $(window).unbind("."+ sID); // resize & unload
2976 $(document).unbind("."+ sID); // keyDown (hotkeys)
2978 if (typeof evt_or_destroyChildren === "object")
2979 // stopPropagation if called by trigger("layoutdestroy") - use evtPane utility
2980 evtPane(evt_or_destroyChildren);
2981 else // no event, so transfer 1st param to destroyChildren param
2982 destroyChildren = evt_or_destroyChildren;
2984 // need to look for parent layout BEFORE we remove the container data, else skips a level
2985 //var parentPane = Instance.hasParentLayout ? $.layout.getParentPaneInstance( $N ) : null;
2987 // reset layout-container
2989 .removeData("layout")
2990 .removeData("layoutContainer")
2991 .removeClass(options.containerClass)
2992 .unbind("."+ sID) // remove ALL Layout events
2995 // remove all mask elements that have been created
2998 // loop all panes to remove layout classes, attributes and bindings
2999 $.each(_c.allPanes, function (i, pane) {
3000 removePane( pane, false, true, destroyChildren ); // true = skipResize
3003 // do NOT reset container CSS if is a 'pane' (or 'content') in an outer-layout - ie, THIS layout is 'nested'
3004 var css = "layoutCSS";
3005 if ($N.data(css) && !$N.data("layoutRole")) // RESET CSS
3006 $N.css( $N.data(css) ).removeData(css);
3008 // for full-page layouts, also reset the <HTML> CSS
3009 if (sC.tagName === "BODY" && ($N = $("html")).data(css)) // RESET <HTML> CSS
3010 $N.css( $N.data(css) ).removeData(css);
3012 // trigger plugins for this layout, if there are any
3013 runPluginCallbacks( Instance, $.layout.onDestroy );
3015 // trigger state-management and onunload callback
3018 // clear the Instance of everything except for container & options (so could recreate)
3019 // RE-CREATE: myLayout = myLayout.container.layout( myLayout.options );
3020 for (var n in Instance)
3021 if (!n.match(/^(container|options)$/)) delete Instance[ n ];
3022 // add a 'destroyed' flag to make it easy to check
3023 Instance.destroyed = true;
3025 // if this is a child layout, CLEAR the child-pointer in the parent
3026 /* for now the pointer REMAINS, but with only container, options and destroyed keys
3028 var layout = parentPane.pane.data("parentLayout")
3029 , key = layout.options.instanceKey || 'error';
3030 // THIS SYNTAX MAY BE WRONG!
3031 parentPane.children[key] = layout.children[ parentPane.name ].children[key] = null;
3035 return Instance; // for coding convenience
3039 * Remove a pane from the layout - subroutine of destroy()
3042 * @param {(string|Object)} evt_or_pane The pane to process
3043 * @param {boolean=} [remove=false] Remove the DOM element?
3044 * @param {boolean=} [skipResize=false] Skip calling resizeAll()?
3045 * @param {boolean=} [destroyChild=true] Destroy Child-layouts? If not passed, obeys options setting
3047 , removePane = function (evt_or_pane, remove, skipResize, destroyChild) {
3048 if (!isInitialized()) return;
3049 var pane = evtPane.call(this, evt_or_pane)
3055 // NOTE: elements can still exist even after remove()
3056 // so check for missing data(), which is cleared by removed()
3057 if ($P && $.isEmptyObject( $P.data() )) $P = false;
3058 if ($C && $.isEmptyObject( $C.data() )) $C = false;
3059 if ($R && $.isEmptyObject( $R.data() )) $R = false;
3060 if ($T && $.isEmptyObject( $T.data() )) $T = false;
3062 if ($P) $P.stop(true, true);
3064 var o = options[pane]
3068 , pC = children[pane]
3069 , hasChildren = $.isPlainObject( pC ) && !$.isEmptyObject( pC )
3070 , destroy = destroyChild !== undefined ? destroyChild : o.destroyChildren
3072 // FIRST destroy the child-layout(s)
3073 if (hasChildren && destroy) {
3074 $.each( pC, function (key, child) {
3075 if (!child.destroyed)
3076 child.destroy(true);// tell child-layout to destroy ALL its child-layouts too
3077 if (child.destroyed) // destroy was successful
3080 // if no more children, remove the children hash
3081 if ($.isEmptyObject( pC )) {
3082 pC = children[pane] = null; // clear children hash
3083 hasChildren = false;
3087 // Note: can't 'remove' a pane element with non-destroyed children
3088 if ($P && remove && !hasChildren)
3089 $P.remove(); // remove the pane-element and everything inside it
3090 else if ($P && $P[0]) {
3091 // create list of ALL pane-classes that need to be removed
3092 var root = o.paneClass // default="ui-layout-pane"
3093 , pRoot = root +"-"+ pane // eg: "ui-layout-pane-west"
3095 , _sliding= "-sliding"
3096 , _closed = "-closed"
3097 , classes = [ root, root+_open, root+_closed, root+_sliding, // generic classes
3098 pRoot, pRoot+_open, pRoot+_closed, pRoot+_sliding ] // pane-specific classes
3100 $.merge(classes, getHoverClasses($P, true)); // ADD hover-classes
3101 // remove all Layout classes from pane-element
3102 $P .removeClass( classes.join(" ") ) // remove ALL pane-classes
3103 .removeData("parentLayout")
3104 .removeData("layoutPane")
3105 .removeData("layoutRole")
3106 .removeData("layoutEdge")
3107 .removeData("autoHidden") // in case set
3108 .unbind("."+ sID) // remove ALL Layout events
3109 // TODO: remove these extra unbind commands when jQuery is fixed
3110 //.unbind("mouseenter"+ sID)
3111 //.unbind("mouseleave"+ sID)
3113 // do NOT reset CSS if this pane/content is STILL the container of a nested layout!
3114 // the nested layout will reset its 'container' CSS when/if it is destroyed
3115 if (hasChildren && $C) {
3116 // a content-div may not have a specific width, so give it one to contain the Layout
3117 $C.width( $C.width() );
3118 $.each( pC, function (key, child) {
3119 child.resizeAll(); // resize the Layout
3123 $C.css( $C.data(css) ).removeData(css).removeData("layoutRole");
3124 // remove pane AFTER content in case there was a nested layout
3126 $P.css( $P.data(css) ).removeData(css);
3129 // REMOVE pane resizer and toggler elements
3130 if ($T) $T.remove();
3131 if ($R) $R.remove();
3133 // CLEAR all pointers and state data
3134 Instance[pane] = $Ps[pane] = $Cs[pane] = $Rs[pane] = $Ts[pane] = false;
3135 s = { removed: true };
3143 * ###########################
3145 * ###########################
3149 * @param {string} pane
3151 , _hidePane = function (pane) {
3156 if (o.useOffscreenClose) {
3157 if (!$P.data(_c.offscreenReset))
3158 $P.data(_c.offscreenReset, { left: s.left, right: s.right });
3159 $P.css( _c.offscreenCSS );
3162 $P.hide().removeData(_c.offscreenReset);
3166 * @param {string} pane
3168 , _showPane = function (pane) {
3171 , off = _c.offscreenCSS
3172 , old = $P.data(_c.offscreenReset)
3175 $P .show() // ALWAYS show, just in case
3176 .removeData(_c.offscreenReset);
3177 if (o.useOffscreenClose && old) {
3178 if (s.left == off.left)
3180 if (s.right == off.right)
3181 s.right = old.right;
3187 * Completely 'hides' a pane, including its spacing - as if it does not exist
3188 * The pane is not actually 'removed' from the source, so can use 'show' to un-hide it
3190 * @param {(string|Object)} evt_or_pane The pane being hidden, ie: north, south, east, or west
3191 * @param {boolean=} [noAnimation=false]
3193 , hide = function (evt_or_pane, noAnimation) {
3194 if (!isInitialized()) return;
3195 var pane = evtPane.call(this, evt_or_pane)
3201 if (pane === "center" || !$P || s.isHidden) return; // pane does not exist OR is already hidden
3203 // onhide_start callback - will CANCEL hide if returns false
3204 if (state.initialized && false === _runCallbacks("onhide_start", pane)) return;
3206 s.isSliding = false; // just in case
3207 delete state.panesSliding[pane];
3209 // now hide the elements
3210 if ($R) $R.hide(); // hide resizer-bar
3211 if (!state.initialized || s.isClosed) {
3212 s.isClosed = true; // to trigger open-animation on show()
3214 s.isVisible = false;
3215 if (!state.initialized)
3216 _hidePane(pane); // no animation when loading page
3217 sizeMidPanes(_c[pane].dir === "horz" ? "" : "center");
3218 if (state.initialized || o.triggerEventsOnLoad)
3219 _runCallbacks("onhide_end", pane);
3222 s.isHiding = true; // used by onclose
3223 close(pane, false, noAnimation); // adjust all panes to fit
3228 * Show a hidden pane - show as 'closed' by default unless openPane = true
3230 * @param {(string|Object)} evt_or_pane The pane being opened, ie: north, south, east, or west
3231 * @param {boolean=} [openPane=false]
3232 * @param {boolean=} [noAnimation=false]
3233 * @param {boolean=} [noAlert=false]
3235 , show = function (evt_or_pane, openPane, noAnimation, noAlert) {
3236 if (!isInitialized()) return;
3237 var pane = evtPane.call(this, evt_or_pane)
3243 if (pane === "center" || !$P || !s.isHidden) return; // pane does not exist OR is not hidden
3245 // onshow_start callback - will CANCEL show if returns false
3246 if (false === _runCallbacks("onshow_start", pane)) return;
3248 s.isShowing = true; // used by onopen/onclose
3249 //s.isHidden = false; - will be set by open/close - if not cancelled
3250 s.isSliding = false; // just in case
3251 delete state.panesSliding[pane];
3253 // now show the elements
3254 //if ($R) $R.show(); - will be shown by open/close
3255 if (openPane === false)
3256 close(pane, true); // true = force
3258 open(pane, false, noAnimation, noAlert); // adjust all panes to fit
3263 * Toggles a pane open/closed by calling either open or close
3265 * @param {(string|Object)} evt_or_pane The pane being toggled, ie: north, south, east, or west
3266 * @param {boolean=} [slide=false]
3268 , toggle = function (evt_or_pane, slide) {
3269 if (!isInitialized()) return;
3270 var evt = evtObj(evt_or_pane)
3271 , pane = evtPane.call(this, evt_or_pane)
3274 if (evt) // called from to $R.dblclick OR triggerPaneEvent
3275 evt.stopImmediatePropagation();
3277 show(pane); // will call 'open' after unhiding it
3278 else if (s.isClosed)
3279 open(pane, !!slide);
3286 * Utility method used during init or other auto-processes
3288 * @param {string} pane The pane being closed
3289 * @param {boolean=} [setHandles=false]
3291 , _closePane = function (pane, setHandles) {
3298 s.isVisible = false;
3299 if (setHandles) setAsClosed(pane);
3303 * Close the specified pane (animation optional), and resize all other panes as needed
3305 * @param {(string|Object)} evt_or_pane The pane being closed, ie: north, south, east, or west
3306 * @param {boolean=} [force=false]
3307 * @param {boolean=} [noAnimation=false]
3308 * @param {boolean=} [skipCallback=false]
3310 , close = function (evt_or_pane, force, noAnimation, skipCallback) {
3311 var pane = evtPane.call(this, evt_or_pane);
3312 if (pane === "center") return; // validate
3313 // if pane has been initialized, but NOT the complete layout, close pane instantly
3314 if (!state.initialized && $Ps[pane]) {
3315 _closePane(pane, true); // INIT pane as closed
3318 if (!isInitialized()) return;
3327 , doFX, isShowing, isHiding, wasSliding;
3329 // QUEUE in case another action/animation is in progress
3330 $N.queue(function( queueNext ){
3333 || (!o.closable && !s.isShowing && !s.isHiding) // invalid request // (!o.resizable && !o.closable) ???
3334 || (!force && s.isClosed && !s.isShowing) // already closed
3335 ) return queueNext();
3337 // onclose_start callback - will CANCEL hide if returns false
3338 // SKIP if just 'showing' a hidden pane as 'closed'
3339 var abort = !s.isShowing && false === _runCallbacks("onclose_start", pane);
3341 // transfer logic vars to temp vars
3342 isShowing = s.isShowing;
3343 isHiding = s.isHiding;
3344 wasSliding = s.isSliding;
3345 // now clear the logic vars (REQUIRED before aborting)
3349 if (abort) return queueNext();
3351 doFX = !noAnimation && !s.isClosed && (o.fxName_close != "none");
3354 s.isVisible = false;
3355 // update isHidden BEFORE sizing panes
3356 if (isHiding) s.isHidden = true;
3357 else if (isShowing) s.isHidden = false;
3359 if (s.isSliding) // pane is being closed, so UNBIND trigger events
3360 bindStopSlidingEvents(pane, false); // will set isSliding=false
3361 else // resize panes adjacent to this one
3362 sizeMidPanes(_c[pane].dir === "horz" ? "" : "center", false); // false = NOT skipCallback
3364 // if this pane has a resizer bar, move it NOW - before animation
3368 if (doFX) { // animate the close
3369 lockPaneForFX(pane, true); // need to set left/top so animation will work
3370 $P.hide( o.fxName_close, o.fxSettings_close, o.fxSpeed_close, function () {
3371 lockPaneForFX(pane, false); // undo
3372 if (s.isClosed) close_2();
3376 else { // hide the pane without animation
3384 function close_2 () {
3386 bindStartSlidingEvents(pane, true); // will enable if o.slidable = true
3388 // if opposite-pane was autoClosed, see if it can be autoOpened now
3389 var altPane = _c.oppositeEdge[pane];
3390 if (state[ altPane ].noRoom) {
3391 setSizeLimits( altPane );
3392 makePaneFit( altPane );
3395 if (!skipCallback && (state.initialized || o.triggerEventsOnLoad)) {
3396 // onclose callback - UNLESS just 'showing' a hidden pane as 'closed'
3397 if (!isShowing) _runCallbacks("onclose_end", pane);
3398 // onhide OR onshow callback
3399 if (isShowing) _runCallbacks("onshow_end", pane);
3400 if (isHiding) _runCallbacks("onhide_end", pane);
3406 * @param {string} pane The pane just closed, ie: north, south, east, or west
3408 , setAsClosed = function (pane) {
3409 if (!$Rs[pane]) return; // handles not initialized yet!
3416 , side = _c[pane].side
3417 , rClass = o.resizerClass
3418 , tClass = o.togglerClass
3419 , _pane = "-"+ pane // used for classNames
3421 , _sliding= "-sliding"
3422 , _closed = "-closed"
3425 .css(side, sC.inset[side]) // move the resizer
3426 .removeClass( rClass+_open +" "+ rClass+_pane+_open )
3427 .removeClass( rClass+_sliding +" "+ rClass+_pane+_sliding )
3428 .addClass( rClass+_closed +" "+ rClass+_pane+_closed )
3430 // handle already-hidden panes in case called by swap() or a similar method
3431 if (s.isHidden) $R.hide(); // hide resizer-bar
3433 // DISABLE 'resizing' when closed - do this BEFORE bindStartSlidingEvents?
3434 if (o.resizable && $.layout.plugins.draggable)
3436 .draggable("disable")
3437 .removeClass("ui-state-disabled") // do NOT apply disabled styling - not suitable here
3438 .css("cursor", "default")
3442 // if pane has a toggler button, adjust that too
3445 .removeClass( tClass+_open +" "+ tClass+_pane+_open )
3446 .addClass( tClass+_closed +" "+ tClass+_pane+_closed )
3447 .attr("title", o.tips.Open) // may be blank
3449 // toggler-content - if exists
3450 $T.children(".content-open").hide();
3451 $T.children(".content-closed").css("display","block");
3454 // sync any 'pin buttons'
3455 syncPinBtns(pane, false);
3457 if (state.initialized) {
3458 // resize 'length' and position togglers for adjacent panes
3464 * Open the specified pane (animation optional), and resize all other panes as needed
3466 * @param {(string|Object)} evt_or_pane The pane being opened, ie: north, south, east, or west
3467 * @param {boolean=} [slide=false]
3468 * @param {boolean=} [noAnimation=false]
3469 * @param {boolean=} [noAlert=false]
3471 , open = function (evt_or_pane, slide, noAnimation, noAlert) {
3472 if (!isInitialized()) return;
3473 var pane = evtPane.call(this, evt_or_pane)
3482 if (pane === "center") return; // validate
3483 // QUEUE in case another action/animation is in progress
3484 $N.queue(function( queueNext ){
3487 || (!o.resizable && !o.closable && !s.isShowing) // invalid request
3488 || (s.isVisible && !s.isSliding) // already open
3489 ) return queueNext();
3491 // pane can ALSO be unhidden by just calling show(), so handle this scenario
3492 if (s.isHidden && !s.isShowing) {
3493 queueNext(); // call before show() because it needs the queue free
3498 if (s.autoResize && s.size != o.size) // resize pane to original size set in options
3499 sizePane(pane, o.size, true, true, true); // true=skipCallback/noAnimation/forceResize
3501 // make sure there is enough space available to open the pane
3502 setSizeLimits(pane, slide);
3504 // onopen_start callback - will CANCEL open if returns false
3505 var cbReturn = _runCallbacks("onopen_start", pane);
3507 if (cbReturn === "abort")
3510 // update pane-state again in case options were changed in onopen_start
3511 if (cbReturn !== "NC") // NC = "No Callback"
3512 setSizeLimits(pane, slide);
3514 if (s.minSize > s.maxSize) { // INSUFFICIENT ROOM FOR PANE TO OPEN!
3515 syncPinBtns(pane, false); // make sure pin-buttons are reset
3516 if (!noAlert && o.tips.noRoomToOpen)
3517 alert(o.tips.noRoomToOpen);
3518 return queueNext(); // ABORT
3521 if (slide) // START Sliding - will set isSliding=true
3522 bindStopSlidingEvents(pane, true); // BIND trigger events to close sliding-pane
3523 else if (s.isSliding) // PIN PANE (stop sliding) - open pane 'normally' instead
3524 bindStopSlidingEvents(pane, false); // UNBIND trigger events - will set isSliding=false
3525 else if (o.slidable)
3526 bindStartSlidingEvents(pane, false); // UNBIND trigger events
3528 s.noRoom = false; // will be reset by makePaneFit if 'noRoom'
3531 // transfer logic var to temp var
3532 isShowing = s.isShowing;
3533 // now clear the logic var
3536 doFX = !noAnimation && s.isClosed && (o.fxName_open != "none");
3540 // update isHidden BEFORE sizing panes - WHY??? Old?
3541 if (isShowing) s.isHidden = false;
3543 if (doFX) { // ANIMATE
3544 // mask adjacent panes with objects
3545 lockPaneForFX(pane, true); // need to set left/top so animation will work
3546 $P.show( o.fxName_open, o.fxSettings_open, o.fxSpeed_open, function() {
3547 lockPaneForFX(pane, false); // undo
3548 if (s.isVisible) open_2(); // continue
3552 else { // no animation
3553 _showPane(pane);// just show pane and...
3554 open_2(); // continue
3560 function open_2 () {
3563 // cure iframe display issues
3566 // NOTE: if isSliding, then other panes are NOT 'resized'
3567 if (!s.isSliding) { // resize all panes adjacent to this one
3568 sizeMidPanes(_c[pane].dir=="vert" ? "center" : "", false); // false = NOT skipCallback
3571 // set classes, position handles and execute callbacks...
3578 * @param {string} pane The pane just opened, ie: north, south, east, or west
3579 * @param {boolean=} [skipCallback=false]
3581 , setAsOpen = function (pane, skipCallback) {
3588 , side = _c[pane].side
3589 , rClass = o.resizerClass
3590 , tClass = o.togglerClass
3591 , _pane = "-"+ pane // used for classNames
3593 , _closed = "-closed"
3594 , _sliding= "-sliding"
3597 .css(side, sC.inset[side] + getPaneSize(pane)) // move the resizer
3598 .removeClass( rClass+_closed +" "+ rClass+_pane+_closed )
3599 .addClass( rClass+_open +" "+ rClass+_pane+_open )
3602 $R.addClass( rClass+_sliding +" "+ rClass+_pane+_sliding )
3603 else // in case 'was sliding'
3604 $R.removeClass( rClass+_sliding +" "+ rClass+_pane+_sliding )
3606 removeHover( 0, $R ); // remove hover classes
3607 if (o.resizable && $.layout.plugins.draggable)
3608 $R .draggable("enable")
3609 .css("cursor", o.resizerCursor)
3610 .attr("title", o.tips.Resize);
3611 else if (!s.isSliding)
3612 $R.css("cursor", "default"); // n-resize, s-resize, etc
3614 // if pane also has a toggler button, adjust that too
3616 $T .removeClass( tClass+_closed +" "+ tClass+_pane+_closed )
3617 .addClass( tClass+_open +" "+ tClass+_pane+_open )
3618 .attr("title", o.tips.Close); // may be blank
3619 removeHover( 0, $T ); // remove hover classes
3620 // toggler-content - if exists
3621 $T.children(".content-closed").hide();
3622 $T.children(".content-open").css("display","block");
3625 // sync any 'pin buttons'
3626 syncPinBtns(pane, !s.isSliding);
3628 // update pane-state dimensions - BEFORE resizing content
3629 $.extend(s, elDims($P));
3631 if (state.initialized) {
3632 // resize resizer & toggler sizes for all panes
3634 // resize content every time pane opens - to be sure
3635 sizeContent(pane, true); // true = remeasure headers/footers, even if 'pane.isMoving'
3638 if (!skipCallback && (state.initialized || o.triggerEventsOnLoad) && $P.is(":visible")) {
3640 _runCallbacks("onopen_end", pane);
3641 // onshow callback - TODO: should this be here?
3642 if (s.isShowing) _runCallbacks("onshow_end", pane);
3644 // ALSO call onresize because layout-size *may* have changed while pane was closed
3645 if (state.initialized)
3646 _runCallbacks("onresize_end", pane);
3649 // TODO: Somehow sizePane("north") is being called after this point???
3654 * slideOpen / slideClose / slideToggle
3656 * Pass-though methods for sliding
3658 , slideOpen = function (evt_or_pane) {
3659 if (!isInitialized()) return;
3660 var evt = evtObj(evt_or_pane)
3661 , pane = evtPane.call(this, evt_or_pane)
3663 , delay = options[pane].slideDelay_open
3665 if (pane === "center") return; // validate
3666 // prevent event from triggering on NEW resizer binding created below
3667 if (evt) evt.stopImmediatePropagation();
3669 if (s.isClosed && evt && evt.type === "mouseenter" && delay > 0)
3670 // trigger = mouseenter - use a delay
3671 timer.set(pane+"_openSlider", open_NOW, delay);
3673 open_NOW(); // will unbind events if is already open
3676 * SUBROUTINE for timed open
3678 function open_NOW () {
3679 if (!s.isClosed) // skip if no longer closed!
3680 bindStopSlidingEvents(pane, true); // BIND trigger events to close sliding-pane
3681 else if (!s.isMoving)
3682 open(pane, true); // true = slide - open() will handle binding
3686 , slideClose = function (evt_or_pane) {
3687 if (!isInitialized()) return;
3688 var evt = evtObj(evt_or_pane)
3689 , pane = evtPane.call(this, evt_or_pane)
3692 , delay = s.isMoving ? 1000 : 300 // MINIMUM delay - option may override
3694 if (pane === "center") return; // validate
3695 if (s.isClosed || s.isResizing)
3696 return; // skip if already closed OR in process of resizing
3697 else if (o.slideTrigger_close === "click")
3698 close_NOW(); // close immediately onClick
3699 else if (o.preventQuickSlideClose && s.isMoving)
3700 return; // handle Chrome quick-close on slide-open
3701 else if (o.preventPrematureSlideClose && evt && $.layout.isMouseOverElem(evt, $Ps[pane]))
3702 return; // handle incorrect mouseleave trigger, like when over a SELECT-list in IE
3703 else if (evt) // trigger = mouseleave - use a delay
3704 // 1 sec delay if 'opening', else .3 sec
3705 timer.set(pane+"_closeSlider", close_NOW, max(o.slideDelay_close, delay));
3706 else // called programically
3710 * SUBROUTINE for timed close
3712 function close_NOW () {
3713 if (s.isClosed) // skip 'close' if already closed!
3714 bindStopSlidingEvents(pane, false); // UNBIND trigger events - TODO: is this needed here?
3715 else if (!s.isMoving)
3716 close(pane); // close will handle unbinding
3721 * @param {(string|Object)} evt_or_pane The pane being opened, ie: north, south, east, or west
3723 , slideToggle = function (evt_or_pane) {
3724 var pane = evtPane.call(this, evt_or_pane);
3730 * Must set left/top on East/South panes so animation will work properly
3732 * @param {string} pane The pane to lock, 'east' or 'south' - any other is ignored!
3733 * @param {boolean} doLock true = set left/top, false = remove
3735 , lockPaneForFX = function (pane, doLock) {
3739 , z = options.zIndexes
3742 showMasks( pane, { animation: true, objectsOnly: true });
3743 $P.css({ zIndex: z.pane_animate }); // overlay all elements during animation
3745 $P.css({ top: sC.inset.top + sC.innerHeight - $P.outerHeight() });
3746 else if (pane=="east")
3747 $P.css({ left: sC.inset.left + sC.innerWidth - $P.outerWidth() });
3749 else { // animation DONE - RESET CSS
3751 $P.css({ zIndex: (s.isSliding ? z.pane_sliding : z.pane_normal) });
3753 $P.css({ top: "auto" });
3754 // if pane is positioned 'off-screen', then DO NOT screw with it!
3755 else if (pane=="east" && !$P.css("left").match(/\-99999/))
3756 $P.css({ left: "auto" });
3757 // fix anti-aliasing in IE - only needed for animations that change opacity
3758 if (browser.msie && o.fxOpacityFix && o.fxName_open != "slide" && $P.css("filter") && $P.css("opacity") == 1)
3759 $P[0].style.removeAttribute('filter');
3765 * Toggle sliding functionality of a specific pane on/off by adding removing 'slide open' trigger
3767 * @see open(), close()
3768 * @param {string} pane The pane to enable/disable, 'north', 'south', etc.
3769 * @param {boolean} enable Enable or Disable sliding?
3771 , bindStartSlidingEvents = function (pane, enable) {
3772 var o = options[pane]
3775 , evtName = o.slideTrigger_open.toLowerCase()
3777 if (!$R || (enable && !o.slidable)) return;
3779 // make sure we have a valid event
3780 if (evtName.match(/mouseover/))
3781 evtName = o.slideTrigger_open = "mouseenter";
3782 else if (!evtName.match(/(click|dblclick|mouseenter)/))
3783 evtName = o.slideTrigger_open = "click";
3785 // must remove double-click-toggle when using dblclick-slide
3786 if (o.resizerDblClickToggle && evtName.match(/click/)) {
3787 $R[enable ? "unbind" : "bind"]('dblclick.'+ sID, toggle)
3791 // add or remove event
3792 [enable ? "bind" : "unbind"](evtName +'.'+ sID, slideOpen)
3793 // set the appropriate cursor & title/tip
3794 .css("cursor", enable ? o.sliderCursor : "default")
3795 .attr("title", enable ? o.tips.Slide : "")
3800 * Add or remove 'mouseleave' events to 'slide close' when pane is 'sliding' open or closed
3801 * Also increases zIndex when pane is sliding open
3802 * See bindStartSlidingEvents for code to control 'slide open'
3804 * @see slideOpen(), slideClose()
3805 * @param {string} pane The pane to process, 'north', 'south', etc.
3806 * @param {boolean} enable Enable or Disable events?
3808 , bindStopSlidingEvents = function (pane, enable) {
3809 var o = options[pane]
3812 , z = options.zIndexes
3813 , evtName = o.slideTrigger_close.toLowerCase()
3814 , action = (enable ? "bind" : "unbind")
3818 timer.clear(pane+"_closeSlider"); // just in case
3822 state.panesSliding[pane] = true;
3823 // remove 'slideOpen' event from resizer
3824 // ALSO will raise the zIndex of the pane & resizer
3825 bindStartSlidingEvents(pane, false);
3828 s.isSliding = false;
3829 delete state.panesSliding[pane];
3832 // RE/SET zIndex - increases when pane is sliding-open, resets to normal when not
3833 $P.css("zIndex", enable ? z.pane_sliding : z.pane_normal);
3834 $R.css("zIndex", enable ? z.pane_sliding+2 : z.resizer_normal); // NOTE: mask = pane_sliding+1
3836 // make sure we have a valid event
3837 if (!evtName.match(/(click|mouseleave)/))
3838 evtName = o.slideTrigger_close = "mouseleave"; // also catches 'mouseout'
3840 // add/remove slide triggers
3841 $R[action](evtName, slideClose); // base event on resize
3842 // need extra events for mouseleave
3843 if (evtName === "mouseleave") {
3844 // also close on pane.mouseleave
3845 $P[action]("mouseleave."+ sID, slideClose);
3846 // cancel timer when mouse moves between 'pane' and 'resizer'
3847 $R[action]("mouseenter."+ sID, cancelMouseOut);
3848 $P[action]("mouseenter."+ sID, cancelMouseOut);
3852 timer.clear(pane+"_closeSlider");
3853 else if (evtName === "click" && !o.resizable) {
3854 // IF pane is not resizable (which already has a cursor and tip)
3855 // then set the a cursor & title/tip on resizer when sliding
3856 $R.css("cursor", enable ? o.sliderCursor : "default");
3857 $R.attr("title", enable ? o.tips.Close : ""); // use Toggler-tip, eg: "Close Pane"
3860 // SUBROUTINE for mouseleave timer clearing
3861 function cancelMouseOut (evt) {
3862 timer.clear(pane+"_closeSlider");
3863 evt.stopPropagation();
3869 * Hides/closes a pane if there is insufficient room - reverses this when there is room again
3870 * MUST have already called setSizeLimits() before calling this method
3872 * @param {string} pane The pane being resized
3873 * @param {boolean=} [isOpening=false] Called from onOpen?
3874 * @param {boolean=} [skipCallback=false] Should the onresize callback be run?
3875 * @param {boolean=} [force=false]
3877 , makePaneFit = function (pane, isOpening, skipCallback, force) {
3878 var o = options[pane]
3883 , isSidePane = c.dir==="vert"
3886 // special handling for center & east/west panes
3887 if (pane === "center" || (isSidePane && s.noVerticalRoom)) {
3888 // see if there is enough room to display the pane
3889 // ERROR: hasRoom = s.minHeight <= s.maxHeight && (isSidePane || s.minWidth <= s.maxWidth);
3890 hasRoom = (s.maxHeight >= 0);
3891 if (hasRoom && s.noRoom) { // previously hidden due to noRoom, so show now
3896 if (isSidePane) s.noVerticalRoom = false;
3899 else if (!hasRoom && !s.noRoom) { // not currently hidden, so hide now
3902 s.isVisible = false;
3907 // see if there is enough room to fit the border-pane
3908 if (pane === "center") {
3909 // ignore center in this block
3911 else if (s.minSize <= s.maxSize) { // pane CAN fit
3913 if (s.size > s.maxSize) // pane is too big - shrink it
3914 sizePane(pane, s.maxSize, skipCallback, true, force); // true = noAnimation
3915 else if (s.size < s.minSize) // pane is too small - enlarge it
3916 sizePane(pane, s.minSize, skipCallback, true, force); // true = noAnimation
3917 // need s.isVisible because new pseudoClose method keeps pane visible, but off-screen
3918 else if ($R && s.isVisible && $P.is(":visible")) {
3919 // make sure resizer-bar is positioned correctly
3920 // handles situation where nested layout was 'hidden' when initialized
3921 var pos = s.size + sC.inset[c.side];
3922 if ($.layout.cssNum( $R, c.side ) != pos) $R.css( c.side, pos );
3925 // if was previously hidden due to noRoom, then RESET because NOW there is room
3927 // s.noRoom state will be set by open or show
3928 if (s.wasOpen && o.closable) {
3930 open(pane, false, true, true); // true = noAnimation, true = noAlert
3931 else // leave the pane closed, so just update state
3935 show(pane, s.wasOpen, true, true); // true = noAnimation, true = noAlert
3938 else { // !hasRoom - pane CANNOT fit
3939 if (!s.noRoom) { // pane not set as noRoom yet, so hide or close it now...
3940 s.noRoom = true; // update state
3941 s.wasOpen = !s.isClosed && !s.isSliding;
3942 if (s.isClosed){} // SKIP
3943 else if (o.closable) // 'close' if possible
3944 close(pane, true, true); // true = force, true = noAnimation
3945 else // 'hide' pane if cannot just be closed
3946 hide(pane, true); // true = noAnimation
3953 * manualSizePane is an exposed flow-through method allowing extra code when pane is 'manually resized'
3955 * @param {(string|Object)} evt_or_pane The pane being resized
3956 * @param {number} size The *desired* new size for this pane - will be validated
3957 * @param {boolean=} [skipCallback=false] Should the onresize callback be run?
3958 * @param {boolean=} [noAnimation=false]
3959 * @param {boolean=} [force=false] Force resizing even if does not seem necessary
3961 , manualSizePane = function (evt_or_pane, size, skipCallback, noAnimation, force) {
3962 if (!isInitialized()) return;
3963 var pane = evtPane.call(this, evt_or_pane)
3966 // if resizing callbacks have been delayed and resizing is now DONE, force resizing to complete...
3967 , forceResize = force || (o.livePaneResizing && !s.isResizing)
3969 if (pane === "center") return; // validate
3970 // ANY call to manualSizePane disables autoResize - ie, percentage sizing
3971 s.autoResize = false;
3973 sizePane(pane, size, skipCallback, noAnimation, forceResize); // will animate resize if option enabled
3977 * sizePane is called only by internal methods whenever a pane needs to be resized
3979 * @param {(string|Object)} evt_or_pane The pane being resized
3980 * @param {number} size The *desired* new size for this pane - will be validated
3981 * @param {boolean=} [skipCallback=false] Should the onresize callback be run?
3982 * @param {boolean=} [noAnimation=false]
3983 * @param {boolean=} [force=false] Force resizing even if does not seem necessary
3985 , sizePane = function (evt_or_pane, size, skipCallback, noAnimation, force) {
3986 if (!isInitialized()) return;
3987 var pane = evtPane.call(this, evt_or_pane) // probably NEVER called from event?
3992 , side = _c[pane].side
3993 , dimName = _c[pane].sizeType.toLowerCase()
3994 , skipResizeWhileDragging = s.isResizing && !o.triggerEventsDuringLiveResize
3995 , doFX = noAnimation !== true && o.animatePaneSizing
3998 if (pane === "center") return; // validate
3999 // QUEUE in case another action/animation is in progress
4000 $N.queue(function( queueNext ){
4001 // calculate 'current' min/max sizes
4002 setSizeLimits(pane); // update pane-state
4004 size = _parseSize(pane, size); // handle percentages & auto
4005 size = max(size, _parseSize(pane, o.minSize));
4006 size = min(size, s.maxSize);
4007 if (size < s.minSize) { // not enough room for pane!
4008 queueNext(); // call before makePaneFit() because it needs the queue free
4009 makePaneFit(pane, false, skipCallback); // will hide or close pane
4013 // IF newSize is same as oldSize, then nothing to do - abort
4014 if (!force && size === oldSize)
4019 // onresize_start callback CANNOT cancel resizing because this would break the layout!
4020 if (!skipCallback && state.initialized && s.isVisible)
4021 _runCallbacks("onresize_start", pane);
4023 // resize the pane, and make sure its visible
4024 newSize = cssSize(pane, size);
4026 if (doFX && $P.is(":visible")) { // ANIMATE
4027 var fx = $.layout.effects.size[pane] || $.layout.effects.size.all
4028 , easing = o.fxSettings_size.easing || fx.easing
4029 , z = options.zIndexes
4031 props[ dimName ] = newSize +'px';
4033 // overlay all elements during animation
4034 $P.css({ zIndex: z.pane_animate })
4035 .show().animate( props, o.fxSpeed_size, easing, function(){
4036 // reset zIndex after animation
4037 $P.css({ zIndex: (s.isSliding ? z.pane_sliding : z.pane_normal) });
4040 sizePane_2(); // continue
4044 else { // no animation
4045 $P.css( dimName, newSize ); // resize pane
4047 // if pane is visible, then
4048 if ($P.is(":visible"))
4049 sizePane_2(); // continue
4051 // pane is NOT VISIBLE, so just update state data...
4052 // when pane is *next opened*, it will have the new size
4053 s.size = size; // update state.size
4054 //$.extend(s, elDims($P)); // update state dimensions - CANNOT do this when not visible! }
4062 function sizePane_2 () {
4063 /* Panes are sometimes not sized precisely in some browsers!?
4064 * This code will resize the pane up to 3 times to nudge the pane to the correct size
4066 var actual = dimName==='width' ? $P.outerWidth() : $P.outerHeight()
4072 , correct: (size === actual)
4076 , lastTry = tries[0]
4078 , msg = 'Inaccurate size after resizing the '+ pane +'-pane.'
4080 while ( !lastTry.correct ) {
4081 thisTry = { pane: pane, count: lastTry.count+1, target: size };
4083 if (lastTry.actual > size)
4084 thisTry.attempt = max(0, lastTry.attempt - (lastTry.actual - size));
4085 else // lastTry.actual < size
4086 thisTry.attempt = max(0, lastTry.attempt + (size - lastTry.actual));
4088 thisTry.cssSize = cssSize(pane, thisTry.attempt);
4089 $P.css( dimName, thisTry.cssSize );
4091 thisTry.actual = dimName=='width' ? $P.outerWidth() : $P.outerHeight();
4092 thisTry.correct = (size === thisTry.actual);
4094 // log attempts and alert the user of this *non-fatal error* (if showDebugMessages)
4095 if ( tries.length === 1) {
4096 _log(msg, false, true);
4097 _log(lastTry, false, true);
4099 _log(thisTry, false, true);
4100 // after 4 tries, is as close as its gonna get!
4101 if (tries.length > 3) break;
4103 tries.push( thisTry );
4104 lastTry = tries[ tries.length - 1 ];
4108 // update pane-state dimensions
4110 $.extend(s, elDims($P));
4112 if (s.isVisible && $P.is(":visible")) {
4113 // reposition the resizer-bar
4114 if ($R) $R.css( side, size + sC.inset[side] );
4115 // resize the content-div
4119 if (!skipCallback && !skipResizeWhileDragging && state.initialized && s.isVisible)
4120 _runCallbacks("onresize_end", pane);
4122 // resize all the adjacent panes, and adjust their toggler buttons
4123 // when skipCallback passed, it means the controlling method will handle 'other panes'
4124 if (!skipCallback) {
4125 // also no callback if live-resize is in progress and NOT triggerEventsDuringLiveResize
4126 if (!s.isSliding) sizeMidPanes(_c[pane].dir=="horz" ? "" : "center", skipResizeWhileDragging, force);
4130 // if opposite-pane was autoClosed, see if it can be autoOpened now
4131 var altPane = _c.oppositeEdge[pane];
4132 if (size < oldSize && state[ altPane ].noRoom) {
4133 setSizeLimits( altPane );
4134 makePaneFit( altPane, false, skipCallback );
4137 // DEBUG - ALERT user/developer so they know there was a sizing problem
4138 if (tries.length > 1)
4139 _log(msg +'\nSee the Error Console for details.', true, true);
4144 * @see initPanes(), sizePane(), resizeAll(), open(), close(), hide()
4145 * @param {(Array.<string>|string)} panes The pane(s) being resized, comma-delmited string
4146 * @param {boolean=} [skipCallback=false] Should the onresize callback be run?
4147 * @param {boolean=} [force=false]
4149 , sizeMidPanes = function (panes, skipCallback, force) {
4150 panes = (panes ? panes : "east,west,center").split(",");
4152 $.each(panes, function (i, pane) {
4153 if (!$Ps[pane]) return; // NO PANE - skip
4159 , isCenter= (pane=="center")
4162 // if pane is not visible, show it invisibly NOW rather than for *each call* in this script
4163 , visCSS = $.layout.showInvisibly($P)
4165 , newCenter = calcNewCenterPaneDims()
4168 // update pane-state dimensions
4169 $.extend(s, elDims($P));
4171 if (pane === "center") {
4172 if (!force && s.isVisible && newCenter.width === s.outerWidth && newCenter.height === s.outerHeight) {
4174 return true; // SKIP - pane already the correct size
4176 // set state for makePaneFit() logic
4177 $.extend(s, cssMinDims(pane), {
4178 maxWidth: newCenter.width
4179 , maxHeight: newCenter.height
4182 s.newWidth = CSS.width;
4183 s.newHeight = CSS.height;
4184 // convert OUTER width/height to CSS width/height
4185 CSS.width = cssW($P, CSS.width);
4186 // NEW - allow pane to extend 'below' visible area rather than hide it
4187 CSS.height = cssH($P, CSS.height);
4188 hasRoom = CSS.width >= 0 && CSS.height >= 0; // height >= 0 = ALWAYS TRUE NOW
4190 // during layout init, try to shrink east/west panes to make room for center
4191 if (!state.initialized && o.minWidth > newCenter.width) {
4193 reqPx = o.minWidth - s.outerWidth
4194 , minE = options.east.minSize || 0
4195 , minW = options.west.minSize || 0
4196 , sizeE = state.east.size
4197 , sizeW = state.west.size
4201 if (reqPx > 0 && state.east.isVisible && sizeE > minE) {
4202 newE = max( sizeE-minE, sizeE-reqPx );
4203 reqPx -= sizeE-newE;
4205 if (reqPx > 0 && state.west.isVisible && sizeW > minW) {
4206 newW = max( sizeW-minW, sizeW-reqPx );
4207 reqPx -= sizeW-newW;
4209 // IF we found enough extra space, then resize the border panes as calculated
4211 if (sizeE && sizeE != minE)
4212 sizePane('east', newE, true, true, force); // true = skipCallback/noAnimation - initPanes will handle when done
4213 if (sizeW && sizeW != minW)
4214 sizePane('west', newW, true, true, force); // true = skipCallback/noAnimation
4216 sizeMidPanes('center', skipCallback, force);
4218 return; // abort this loop
4222 else { // for east and west, set only the height, which is same as center height
4223 // set state.min/maxWidth/Height for makePaneFit() logic
4224 if (s.isVisible && !s.noVerticalRoom)
4225 $.extend(s, elDims($P), cssMinDims(pane))
4226 if (!force && !s.noVerticalRoom && newCenter.height === s.outerHeight) {
4228 return true; // SKIP - pane already the correct size
4230 // east/west have same top, bottom & height as center
4231 CSS.top = newCenter.top;
4232 CSS.bottom = newCenter.bottom;
4233 s.newSize = newCenter.height
4234 // NEW - allow pane to extend 'below' visible area rather than hide it
4235 CSS.height = cssH($P, newCenter.height);
4236 s.maxHeight = CSS.height;
4237 hasRoom = (s.maxHeight >= 0); // ALWAYS TRUE NOW
4238 if (!hasRoom) s.noVerticalRoom = true; // makePaneFit() logic
4242 // resizeAll passes skipCallback because it triggers callbacks after ALL panes are resized
4243 if (!skipCallback && state.initialized)
4244 _runCallbacks("onresize_start", pane);
4246 $P.css(CSS); // apply the CSS to pane
4247 if (pane !== "center")
4248 sizeHandles(pane); // also update resizer length
4249 if (s.noRoom && !s.isClosed && !s.isHidden)
4250 makePaneFit(pane); // will re-open/show auto-closed/hidden pane
4252 $.extend(s, elDims($P)); // update pane dimensions
4253 if (state.initialized) sizeContent(pane); // also resize the contents, if exists
4256 else if (!s.noRoom && s.isVisible) // no room for pane
4257 makePaneFit(pane); // will hide or close pane
4259 // reset visibility, if necessary
4267 return true; // DONE - next pane
4270 * Extra CSS for IE6 or IE7 in Quirks-mode - add 'width' to NORTH/SOUTH panes
4271 * Normally these panes have only 'left' & 'right' positions so pane auto-sizes
4272 * ALSO required when pane is an IFRAME because will NOT default to 'full width'
4273 * TODO: Can I use width:100% for a north/south iframe?
4274 * TODO: Sounds like a job for $P.outerWidth( sC.innerWidth ) SETTER METHOD
4276 if (pane === "center") { // finished processing midPanes
4277 var fix = browser.isIE6 || !browser.boxModel;
4278 if ($Ps.north && (fix || state.north.tagName=="IFRAME"))
4279 $Ps.north.css("width", cssW($Ps.north, sC.innerWidth));
4280 if ($Ps.south && (fix || state.south.tagName=="IFRAME"))
4281 $Ps.south.css("width", cssW($Ps.south, sC.innerWidth));
4284 // resizeAll passes skipCallback because it triggers callbacks after ALL panes are resized
4285 if (!skipCallback && state.initialized)
4286 _runCallbacks("onresize_end", pane);
4292 * @see window.onresize(), callbacks or custom code
4293 * @param {(Object|boolean)=} evt_or_refresh If 'true', then also reset pane-positioning
4295 , resizeAll = function (evt_or_refresh) {
4296 var oldW = sC.innerWidth
4297 , oldH = sC.innerHeight
4299 // stopPropagation if called by trigger("layoutdestroy") - use evtPane utility
4300 evtPane(evt_or_refresh);
4302 // cannot size layout when 'container' is hidden or collapsed
4303 if (!$N.is(":visible")) return;
4305 if (!state.initialized) {
4306 _initLayoutElements();
4307 return; // no need to resize since we just initialized!
4310 if (evt_or_refresh === true && $.isPlainObject(options.outset)) {
4311 // update container CSS in case outset option has changed
4312 $N.css( options.outset );
4314 // UPDATE container dimensions
4315 $.extend(sC, elDims( $N, options.inset ));
4316 if (!sC.outerHeight) return;
4318 // if 'true' passed, refresh pane & handle positioning too
4319 if (evt_or_refresh === true) {
4323 // onresizeall_start will CANCEL resizing if returns false
4324 // state.container has already been set, so user can access this info for calcuations
4325 if (false === _runCallbacks("onresizeall_start")) return false;
4327 var // see if container is now 'smaller' than before
4328 shrunkH = (sC.innerHeight < oldH)
4329 , shrunkW = (sC.innerWidth < oldW)
4332 // NOTE special order for sizing: S-N-E-W
4333 $.each(["south","north","east","west"], function (i, pane) {
4334 if (!$Ps[pane]) return; // no pane - SKIP
4337 if (s.autoResize && s.size != o.size) // resize pane to original size set in options
4338 sizePane(pane, o.size, true, true, true); // true=skipCallback/noAnimation/forceResize
4340 setSizeLimits(pane);
4341 makePaneFit(pane, false, true, true); // true=skipCallback/forceResize
4345 sizeMidPanes("", true, true); // true=skipCallback/forceResize
4346 sizeHandles(); // reposition the toggler elements
4348 // trigger all individual pane callbacks AFTER layout has finished resizing
4349 $.each(_c.allPanes, function (i, pane) {
4351 if (!$P) return; // SKIP
4352 if (state[pane].isVisible) // undefined for non-existent panes
4353 _runCallbacks("onresize_end", pane); // callback - if exists
4356 _runCallbacks("onresizeall_end");
4357 //_triggerLayoutEvent(pane, 'resizeall');
4361 * Whenever a pane resizes or opens that has a nested layout, trigger resizeAll
4363 * @param {(string|Object)} evt_or_pane The pane just resized or opened
4365 , resizeChildren = function (evt_or_pane, skipRefresh) {
4366 var pane = evtPane.call(this, evt_or_pane);
4368 if (!options[pane].resizeChildren) return;
4370 // ensure the pane-children are up-to-date
4371 if (!skipRefresh) refreshChildren( pane );
4372 var pC = children[pane];
4373 if ($.isPlainObject( pC )) {
4374 // resize one or more children
4375 $.each( pC, function (key, child) {
4376 if (!child.destroyed) child.resizeAll();
4382 * IF pane has a content-div, then resize all elements inside pane to fit pane-height
4384 * @param {(string|Object)} evt_or_panes The pane(s) being resized
4385 * @param {boolean=} [remeasure=false] Should the content (header/footer) be remeasured?
4387 , sizeContent = function (evt_or_panes, remeasure) {
4388 if (!isInitialized()) return;
4390 var panes = evtPane.call(this, evt_or_panes);
4391 panes = panes ? panes.split(",") : _c.allPanes;
4393 $.each(panes, function (idx, pane) {
4399 , m = s.content // m = measurements
4401 if (!$P || !$C || !$P.is(":visible")) return true; // NOT VISIBLE - skip
4403 // if content-element was REMOVED, update OR remove the pointer
4405 initContent(pane, false); // false = do NOT sizeContent() - already there!
4406 if (!$C) return; // no replacement element found - pointer have been removed
4409 // onsizecontent_start will CANCEL resizing if returns false
4410 if (false === _runCallbacks("onsizecontent_start", pane)) return;
4412 // skip re-measuring offsets if live-resizing
4413 if ((!s.isMoving && !s.isResizing) || o.liveContentResizing || remeasure || m.top == undefined) {
4415 // if any footers are below pane-bottom, they may not measure correctly,
4416 // so allow pane overflow and re-measure
4417 if (m.hiddenFooters > 0 && $P.css("overflow") === "hidden") {
4418 $P.css("overflow", "visible");
4419 _measure(); // remeasure while overflowing
4420 $P.css("overflow", "hidden");
4423 // NOTE: spaceAbove/Below *includes* the pane paddingTop/Bottom, but not pane.borders
4424 var newH = s.innerHeight - (m.spaceAbove - s.css.paddingTop) - (m.spaceBelow - s.css.paddingBottom);
4426 if (!$C.is(":visible") || m.height != newH) {
4427 // size the Content element to fit new pane-size - will autoHide if not enough room
4428 setOuterHeight($C, newH, true); // true=autoHide
4429 m.height = newH; // save new height
4432 if (state.initialized)
4433 _runCallbacks("onsizecontent_end", pane);
4435 function _below ($E) {
4436 return max(s.css.paddingBottom, (parseInt($E.css("marginBottom"), 10) || 0));
4439 function _measure () {
4441 ignore = options[pane].contentIgnoreSelector
4442 , $Fs = $C.nextAll().not(".ui-layout-mask").not(ignore || ":lt(0)") // not :lt(0) = ALL
4443 , $Fs_vis = $Fs.filter(':visible')
4444 , $F = $Fs_vis.filter(':last')
4447 top: $C[0].offsetTop
4448 , height: $C.outerHeight()
4449 , numFooters: $Fs.length
4450 , hiddenFooters: $Fs.length - $Fs_vis.length
4451 , spaceBelow: 0 // correct if no content footer ($E)
4453 m.spaceAbove = m.top; // just for state - not used in calc
4454 m.bottom = m.top + m.height;
4456 //spaceBelow = (LastFooter.top + LastFooter.height) [footerBottom] - Content.bottom + max(LastFooter.marginBottom, pane.paddingBotom)
4457 m.spaceBelow = ($F[0].offsetTop + $F.outerHeight()) - m.bottom + _below($F);
4458 else // no footer - check marginBottom on Content element itself
4459 m.spaceBelow = _below($C);
4466 * Called every time a pane is opened, closed, or resized to slide the togglers to 'center' and adjust their length if necessary
4468 * @see initHandles(), open(), close(), resizeAll()
4469 * @param {(string|Object)=} evt_or_panes The pane(s) being resized
4471 , sizeHandles = function (evt_or_panes) {
4472 var panes = evtPane.call(this, evt_or_panes)
4473 panes = panes ? panes.split(",") : _c.borderPanes;
4475 $.each(panes, function (i, pane) {
4484 if (!$P || !$R) return;
4488 , _state = (s.isClosed ? "_closed" : "_open")
4489 , spacing = o["spacing"+ _state]
4490 , togAlign = o["togglerAlign"+ _state]
4491 , togLen = o["togglerLength"+ _state]
4498 if (spacing === 0) {
4502 else if (!s.noRoom && !s.isHidden) // skip if resizer was hidden for any reason
4503 $R.show(); // in case was previously hidden
4505 // Resizer Bar is ALWAYS same width/height of pane it is attached to
4506 if (dir === "horz") { // north/south
4507 //paneLen = $P.outerWidth(); // s.outerWidth ||
4508 paneLen = sC.innerWidth; // handle offscreen-panes
4509 s.resizerLength = paneLen;
4510 left = $.layout.cssNum($P, "left")
4512 width: cssW($R, paneLen) // account for borders & padding
4513 , height: cssH($R, spacing) // ditto
4514 , left: left > -9999 ? left : sC.inset.left // handle offscreen-panes
4518 paneLen = $P.outerHeight(); // s.outerHeight ||
4519 s.resizerLength = paneLen;
4521 height: cssH($R, paneLen) // account for borders & padding
4522 , width: cssW($R, spacing) // ditto
4523 , top: sC.inset.top + getPaneSize("north", true) // TODO: what if no North pane?
4524 //, top: $.layout.cssNum($Ps["center"], "top")
4528 // remove hover classes
4529 removeHover( o, $R );
4532 if (togLen === 0 || (s.isSliding && o.hideTogglerOnSlide)) {
4533 $T.hide(); // always HIDE the toggler when 'sliding'
4537 $T.show(); // in case was previously hidden
4539 if (!(togLen > 0) || togLen === "100%" || togLen > paneLen) {
4543 else { // calculate 'offset' based on options.PANE.togglerAlign_open/closed
4544 if (isStr(togAlign)) {
4547 case "left": offset = 0;
4550 case "right": offset = paneLen - togLen;
4554 default: offset = round((paneLen - togLen) / 2); // 'default' catches typos
4557 else { // togAlign = number
4558 var x = parseInt(togAlign, 10); //
4559 if (togAlign >= 0) offset = x;
4560 else offset = paneLen - togLen + x; // NOTE: x is negative!
4564 if (dir === "horz") { // north/south
4565 var width = cssW($T, togLen);
4567 width: width // account for borders & padding
4568 , height: cssH($T, spacing) // ditto
4569 , left: offset // TODO: VERIFY that toggler positions correctly for ALL values
4572 // CENTER the toggler content SPAN
4573 $T.children(".content").each(function(){
4575 $TC.css("marginLeft", round((width-$TC.outerWidth())/2)); // could be negative
4579 var height = cssH($T, togLen);
4581 height: height // account for borders & padding
4582 , width: cssW($T, spacing) // ditto
4583 , top: offset // POSITION the toggler
4586 // CENTER the toggler content SPAN
4587 $T.children(".content").each(function(){
4589 $TC.css("marginTop", round((height-$TC.outerHeight())/2)); // could be negative
4593 // remove ALL hover classes
4594 removeHover( 0, $T );
4597 // DONE measuring and sizing this resizer/toggler, so can be 'hidden' now
4598 if (!state.initialized && (o.initHidden || s.isHidden)) {
4607 * @param {(string|Object)} evt_or_pane
4609 , enableClosable = function (evt_or_pane) {
4610 if (!isInitialized()) return;
4611 var pane = evtPane.call(this, evt_or_pane)
4617 $T .bind("click."+ sID, function(evt){ evt.stopPropagation(); toggle(pane); })
4618 .css("visibility", "visible")
4619 .css("cursor", "pointer")
4620 .attr("title", state[pane].isClosed ? o.tips.Open : o.tips.Close) // may be blank
4624 * @param {(string|Object)} evt_or_pane
4625 * @param {boolean=} [hide=false]
4627 , disableClosable = function (evt_or_pane, hide) {
4628 if (!isInitialized()) return;
4629 var pane = evtPane.call(this, evt_or_pane)
4633 options[pane].closable = false;
4634 // is closable is disable, then pane MUST be open!
4635 if (state[pane].isClosed) open(pane, false, true);
4636 $T .unbind("."+ sID)
4637 .css("visibility", hide ? "hidden" : "visible") // instead of hide(), which creates logic issues
4638 .css("cursor", "default")
4644 * @param {(string|Object)} evt_or_pane
4646 , enableSlidable = function (evt_or_pane) {
4647 if (!isInitialized()) return;
4648 var pane = evtPane.call(this, evt_or_pane)
4651 if (!$R || !$R.data('draggable')) return;
4652 options[pane].slidable = true;
4653 if (state[pane].isClosed)
4654 bindStartSlidingEvents(pane, true);
4657 * @param {(string|Object)} evt_or_pane
4659 , disableSlidable = function (evt_or_pane) {
4660 if (!isInitialized()) return;
4661 var pane = evtPane.call(this, evt_or_pane)
4665 options[pane].slidable = false;
4666 if (state[pane].isSliding)
4667 close(pane, false, true);
4669 bindStartSlidingEvents(pane, false);
4670 $R .css("cursor", "default")
4672 removeHover(null, $R[0]); // in case currently hovered
4678 * @param {(string|Object)} evt_or_pane
4680 , enableResizable = function (evt_or_pane) {
4681 if (!isInitialized()) return;
4682 var pane = evtPane.call(this, evt_or_pane)
4686 if (!$R || !$R.data('draggable')) return;
4688 $R.draggable("enable");
4689 if (!state[pane].isClosed)
4690 $R .css("cursor", o.resizerCursor)
4691 .attr("title", o.tips.Resize);
4694 * @param {(string|Object)} evt_or_pane
4696 , disableResizable = function (evt_or_pane) {
4697 if (!isInitialized()) return;
4698 var pane = evtPane.call(this, evt_or_pane)
4701 if (!$R || !$R.data('draggable')) return;
4702 options[pane].resizable = false;
4703 $R .draggable("disable")
4704 .css("cursor", "default")
4706 removeHover(null, $R[0]); // in case currently hovered
4711 * Move a pane from source-side (eg, west) to target-side (eg, east)
4712 * If pane exists on target-side, move that to source-side, ie, 'swap' the panes
4714 * @param {(string|Object)} evt_or_pane1 The pane/edge being swapped
4715 * @param {string} pane2 ditto
4717 , swapPanes = function (evt_or_pane1, pane2) {
4718 if (!isInitialized()) return;
4719 var pane1 = evtPane.call(this, evt_or_pane1);
4720 // change state.edge NOW so callbacks can know where pane is headed...
4721 state[pane1].edge = pane2;
4722 state[pane2].edge = pane1;
4723 // run these even if NOT state.initialized
4724 if (false === _runCallbacks("onswap_start", pane1)
4725 || false === _runCallbacks("onswap_start", pane2)
4727 state[pane1].edge = pane1; // reset
4728 state[pane2].edge = pane2;
4733 oPane1 = copy( pane1 )
4734 , oPane2 = copy( pane2 )
4737 sizes[pane1] = oPane1 ? oPane1.state.size : 0;
4738 sizes[pane2] = oPane2 ? oPane2.state.size : 0;
4740 // clear pointers & state
4746 // ALWAYS remove the resizer & toggler elements
4747 if ($Ts[pane1]) $Ts[pane1].remove();
4748 if ($Ts[pane2]) $Ts[pane2].remove();
4749 if ($Rs[pane1]) $Rs[pane1].remove();
4750 if ($Rs[pane2]) $Rs[pane2].remove();
4751 $Rs[pane1] = $Rs[pane2] = $Ts[pane1] = $Ts[pane2] = false;
4753 // transfer element pointers and data to NEW Layout keys
4754 move( oPane1, pane2 );
4755 move( oPane2, pane1 );
4758 oPane1 = oPane2 = sizes = null;
4760 // make panes 'visible' again
4761 if ($Ps[pane1]) $Ps[pane1].css(_c.visible);
4762 if ($Ps[pane2]) $Ps[pane2].css(_c.visible);
4764 // fix any size discrepancies caused by swap
4767 // run these even if NOT state.initialized
4768 _runCallbacks("onswap_end", pane1);
4769 _runCallbacks("onswap_end", pane2);
4773 function copy (n) { // n = pane
4778 return !$P ? false : {
4780 , P: $P ? $P[0] : false
4781 , C: $C ? $C[0] : false
4782 , state: $.extend(true, {}, state[n])
4783 , options: $.extend(true, {}, options[n])
4787 function move (oPane, pane) {
4792 , oldPane = oPane.pane
4794 // save pane-options that should be retained
4795 , s = $.extend(true, {}, state[pane])
4797 // RETAIN side-specific FX Settings - more below
4798 , fx = { resizerCursor: o.resizerCursor }
4801 $.each("fxName,fxSpeed,fxSettings".split(","), function (i, k) {
4802 fx[k +"_open"] = o[k +"_open"];
4803 fx[k +"_close"] = o[k +"_close"];
4804 fx[k +"_size"] = o[k +"_size"];
4807 // update object pointers and attributes
4810 layoutPane: Instance[pane] // NEW pointer to pane-alias-object
4816 $Cs[pane] = C ? $(C) : false;
4818 // set options and state
4819 options[pane] = $.extend(true, {}, oPane.options, fx);
4820 state[pane] = $.extend(true, {}, oPane.state);
4822 // change classNames on the pane, eg: ui-layout-pane-east ==> ui-layout-pane-west
4823 re = new RegExp(o.paneClass +"-"+ oldPane, "g");
4824 P.className = P.className.replace(re, o.paneClass +"-"+ pane);
4826 // ALWAYS regenerate the resizer & toggler elements
4827 initHandles(pane); // create the required resizer & toggler
4829 // if moving to different orientation, then keep 'target' pane size
4830 if (c.dir != _c[oldPane].dir) {
4831 size = sizes[pane] || 0;
4832 setSizeLimits(pane); // update pane-state
4833 size = max(size, state[pane].minSize);
4834 // use manualSizePane to disable autoResize - not useful after panes are swapped
4835 manualSizePane(pane, size, true, true); // true/true = skipCallback/noAnimation
4837 else // move the resizer here
4838 $Rs[pane].css(c.side, sC.inset[c.side] + (state[pane].isVisible ? getPaneSize(pane) : 0));
4841 // ADD CLASSNAMES & SLIDE-BINDINGS
4842 if (oPane.state.isVisible && !s.isVisible)
4843 setAsOpen(pane, true); // true = skipCallback
4846 bindStartSlidingEvents(pane, true); // will enable events IF option is set
4849 // DESTROY the object
4856 * INTERNAL method to sync pin-buttons when pane is opened or closed
4857 * Unpinned means the pane is 'sliding' - ie, over-top of the adjacent panes
4859 * @see open(), setAsOpen(), setAsClosed()
4860 * @param {string} pane These are the params returned to callbacks by layout()
4861 * @param {boolean} doPin True means set the pin 'down', False means 'up'
4863 , syncPinBtns = function (pane, doPin) {
4864 if ($.layout.plugins.buttons)
4865 $.each(state[pane].pins, function (i, selector) {
4866 $.layout.buttons.setPinState(Instance, $(selector), pane, doPin);
4870 ; // END var DECLARATIONS
4873 * Capture keys when enableCursorHotkey - toggle pane if hotkey pressed
4875 * @see document.keydown()
4877 function keyDown (evt) {
4878 if (!evt) return true;
4879 var code = evt.keyCode;
4880 if (code < 33) return true; // ignore special keys: ENTER, TAB, etc
4884 38: "north" // Up Cursor - $.ui.keyCode.UP
4885 , 40: "south" // Down Cursor - $.ui.keyCode.DOWN
4886 , 37: "west" // Left Cursor - $.ui.keyCode.LEFT
4887 , 39: "east" // Right Cursor - $.ui.keyCode.RIGHT
4889 , ALT = evt.altKey // no worky!
4890 , SHIFT = evt.shiftKey
4891 , CTRL = evt.ctrlKey
4892 , CURSOR = (CTRL && code >= 37 && code <= 40)
4896 if (CURSOR && options[PANE[code]].enableCursorHotkey) // valid cursor-hotkey
4898 else if (CTRL || SHIFT) // check to see if this matches a custom-hotkey
4899 $.each(_c.borderPanes, function (i, p) { // loop each pane to check its hotkey
4902 m = o.customHotkeyModifier; // if missing or invalid, treated as "CTRL+SHIFT"
4903 if ((SHIFT && m=="SHIFT") || (CTRL && m=="CTRL") || (CTRL && SHIFT)) { // Modifier matches
4904 if (k && code === (isNaN(k) || k <= 9 ? k.toUpperCase().charCodeAt(0) : k)) { // Key matches
4906 return false; // BREAK
4912 if (!pane || !$Ps[pane] || !options[pane].closable || state[pane].isHidden)
4917 evt.stopPropagation();
4918 evt.returnValue = false; // CANCEL key
4924 * ######################################
4926 * called externally or by initButtons
4927 * ######################################
4931 * Change/reset a pane overflow setting & zIndex to allow popups/drop-downs to work
4933 * @param {Object=} [el] (optional) Can also be 'bound' to a click, mouseOver, or other event
4935 function allowOverflow (el) {
4936 if (!isInitialized()) return;
4937 if (this && this.tagName) el = this; // BOUND to element
4941 else if ($(el).data("layoutRole"))
4944 $(el).parents().each(function(){
4945 if ($(this).data("layoutRole")) {
4947 return false; // BREAK
4950 if (!$P || !$P.length) return; // INVALID
4953 pane = $P.data("layoutEdge")
4957 // if pane is already raised, then reset it before doing it again!
4958 // this would happen if allowOverflow is attached to BOTH the pane and an element
4960 resetOverflow(pane); // reset previous CSS before continuing
4962 // if pane is raised by sliding or resizing, or its closed, then abort
4963 if (s.isSliding || s.isResizing || s.isClosed) {
4969 newCSS = { zIndex: (options.zIndexes.resizer_normal + 1) }
4971 , of = $P.css("overflow")
4972 , ofX = $P.css("overflowX")
4973 , ofY = $P.css("overflowY")
4975 // determine which, if any, overflow settings need to be changed
4976 if (of != "visible") {
4977 curCSS.overflow = of;
4978 newCSS.overflow = "visible";
4980 if (ofX && !ofX.match(/(visible|auto)/)) {
4981 curCSS.overflowX = ofX;
4982 newCSS.overflowX = "visible";
4984 if (ofY && !ofY.match(/(visible|auto)/)) {
4985 curCSS.overflowY = ofX;
4986 newCSS.overflowY = "visible";
4989 // save the current overflow settings - even if blank!
4990 s.cssSaved = curCSS;
4992 // apply new CSS to raise zIndex and, if necessary, make overflow 'visible'
4995 // make sure the zIndex of all other panes is normal
4996 $.each(_c.allPanes, function(i, p) {
4997 if (p != pane) resetOverflow(p);
5002 * @param {Object=} [el] (optional) Can also be 'bound' to a click, mouseOver, or other event
5004 function resetOverflow (el) {
5005 if (!isInitialized()) return;
5006 if (this && this.tagName) el = this; // BOUND to element
5010 else if ($(el).data("layoutRole"))
5013 $(el).parents().each(function(){
5014 if ($(this).data("layoutRole")) {
5016 return false; // BREAK
5019 if (!$P || !$P.length) return; // INVALID
5022 pane = $P.data("layoutEdge")
5024 , CSS = s.cssSaved || {}
5027 if (!s.isSliding && !s.isResizing)
5028 $P.css("zIndex", options.zIndexes.pane_normal);
5030 // reset Overflow - if necessary
5038 * #####################
5039 * CREATE/RETURN LAYOUT
5040 * #####################
5043 // validate that container exists
5044 var $N = $(this).eq(0); // FIRST matching Container element
5046 return _log( options.errors.containerMissing );
5049 // Users retrieve Instance of a layout with: $N.layout() OR $N.data("layout")
5050 // return the Instance-pointer if layout has already been initialized
5051 if ($N.data("layoutContainer") && $N.data("layout"))
5052 return $N.data("layout"); // cached pointer
5056 $Ps = {} // Panes x5 - set in initPanes()
5057 , $Cs = {} // Content x5 - set in initPanes()
5058 , $Rs = {} // Resizers x4 - set in initHandles()
5059 , $Ts = {} // Togglers x4 - set in initHandles()
5060 , $Ms = $([]) // Masks - up to 2 masks per pane (IFRAME + DIV)
5061 // aliases for code brevity
5062 , sC = state.container // alias for easy access to 'container dimensions'
5063 , sID = state.id // alias for unique layout ID/namespace - eg: "layout435"
5066 // create Instance object to expose data & option Properties, and primary action Methods
5069 options: options // property - options hash
5070 , state: state // property - dimensions hash
5072 , container: $N // property - object pointers for layout container
5073 , panes: $Ps // property - object pointers for ALL Panes: panes.north, panes.center
5074 , contents: $Cs // property - object pointers for ALL Content: contents.north, contents.center
5075 , resizers: $Rs // property - object pointers for ALL Resizers, eg: resizers.north
5076 , togglers: $Ts // property - object pointers for ALL Togglers, eg: togglers.north
5077 // border-pane open/close
5078 , hide: hide // method - ditto
5079 , show: show // method - ditto
5080 , toggle: toggle // method - pass a 'pane' ("north", "west", etc)
5081 , open: open // method - ditto
5082 , close: close // method - ditto
5083 , slideOpen: slideOpen // method - ditto
5084 , slideClose: slideClose // method - ditto
5085 , slideToggle: slideToggle // method - ditto
5087 , setSizeLimits: setSizeLimits // method - pass a 'pane' - update state min/max data
5088 , _sizePane: sizePane // method -intended for user by plugins only!
5089 , sizePane: manualSizePane // method - pass a 'pane' AND an 'outer-size' in pixels or percent, or 'auto'
5090 , sizeContent: sizeContent // method - pass a 'pane'
5091 , swapPanes: swapPanes // method - pass TWO 'panes' - will swap them
5092 , showMasks: showMasks // method - pass a 'pane' OR list of panes - default = all panes with mask option set
5093 , hideMasks: hideMasks // method - ditto'
5094 // pane element methods
5095 , initContent: initContent // method - ditto
5096 , addPane: addPane // method - pass a 'pane'
5097 , removePane: removePane // method - pass a 'pane' to remove from layout, add 'true' to delete the pane-elem
5098 , createChildren: createChildren // method - pass a 'pane' and (optional) layout-options (OVERRIDES options[pane].children
5099 , refreshChildren: refreshChildren // method - pass a 'pane' and a layout-instance
5100 // special pane option setting
5101 , enableClosable: enableClosable // method - pass a 'pane'
5102 , disableClosable: disableClosable // method - ditto
5103 , enableSlidable: enableSlidable // method - ditto
5104 , disableSlidable: disableSlidable // method - ditto
5105 , enableResizable: enableResizable // method - ditto
5106 , disableResizable: disableResizable// method - ditto
5107 // utility methods for panes
5108 , allowOverflow: allowOverflow // utility - pass calling element (this)
5109 , resetOverflow: resetOverflow // utility - ditto
5111 , destroy: destroy // method - no parameters
5112 , initPanes: isInitialized // method - no parameters
5113 , resizeAll: resizeAll // method - no parameters
5114 // callback triggering
5115 , runCallbacks: _runCallbacks // method - pass evtName & pane (if a pane-event), eg: trigger("onopen", "west")
5116 // alias collections of options, state and children - created in addPane and extended elsewhere
5117 , hasParentLayout: false // set by initContainer()
5118 , children: children // pointers to child-layouts, eg: Instance.children.west.layoutName
5119 , north: false // alias group: { name: pane, pane: $Ps[pane], options: options[pane], state: state[pane], children: children[pane] }
5120 , south: false // ditto
5121 , west: false // ditto
5122 , east: false // ditto
5123 , center: false // ditto
5126 // create the border layout NOW
5127 if (_create() === 'cancel') // onload_start callback returned false to CANCEL layout creation
5129 else // true OR false -- if layout-elements did NOT init (hidden or do not exist), can auto-init later
5130 return Instance; // return the Instance object
5141 * jquery.layout.state 1.2
5142 * $Date: 2015/03/13 22:37:04 $
5144 * Copyright (c) 2014
5145 * Kevin Dalman (http://allpro.net)
5147 * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html)
5148 * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses.
5150 * @requires: UI Layout 1.4.0 or higher
5151 * @requires: $.ui.cookie (above)
5153 * @see: http://groups.google.com/group/jquery-ui-layout
5157 if (!$.layout) return;
5163 * A $.cookie OR $.ui.cookie namespace *should be standard*, but until then...
5164 * This creates $.ui.cookie so Layout does not need the cookie.jquery.js plugin
5165 * NOTE: This utility is REQUIRED by the layout.state plugin
5167 * Cookie methods in Layout are created as part of State Management
5169 if (!$.ui) $.ui = {};
5172 // cookieEnabled is not in DOM specs, but DOES works in all browsers,including IE6
5173 acceptsCookies: !!navigator.cookieEnabled
5175 , read: function (name) {
5178 , cs = c ? c.split(';') : []
5181 for (i=0; pair=cs[i]; i++) {
5182 data = $.trim(pair).split('='); // name=value => [ name, value ]
5183 if (data[0] == name) // found the layout cookie
5184 return decodeURIComponent(data[1]);
5189 , write: function (name, val, cookieOpts) {
5193 , o = cookieOpts || {}
5194 , x = o.expires || null
5199 else if (t === "string" && x > 0) {
5203 if (t === "number") {
5206 date.setDate(date.getDate() + x);
5208 date.setFullYear(1970);
5212 if (date) params += ";expires="+ date.toUTCString();
5213 if (o.path) params += ";path="+ o.path;
5214 if (o.domain) params += ";domain="+ o.domain;
5215 if (o.secure) params += ";secure";
5216 document.cookie = name +"="+ (clear ? "" : encodeURIComponent( val )) + params; // write or clear cookie
5219 , clear: function (name) {
5220 $.ui.cookie.write(name, "", {expires: -1});
5224 // if cookie.jquery.js is not loaded, create an alias to replicate it
5225 // this may be useful to other plugins or code dependent on that plugin
5226 if (!$.cookie) $.cookie = function (k, v, o) {
5227 var C = $.ui.cookie;
5230 else if (v === undefined)
5239 * State-management options stored in options.stateManagement, which includes a .cookie hash
5240 * Default options saves ALL KEYS for ALL PANES, ie: pane.size, pane.isClosed, pane.isHidden
5242 * // STATE/COOKIE OPTIONS
5243 * @example $(el).layout({
5246 , stateKeys: "east.size,west.size,east.isClosed,west.isClosed"
5247 , cookie: { name: "appLayout", path: "/" }
5250 * @example $(el).layout({ stateManagement__enabled: true }) // enable auto-state-management using cookies
5251 * @example $(el).layout({ stateManagement__cookie: { name: "appLayout", path: "/" } })
5252 * @example $(el).layout({ stateManagement__cookie__name: "appLayout", stateManagement__cookie__path: "/" })
5254 * // STATE/COOKIE METHODS
5255 * @example myLayout.saveCookie( "west.isClosed,north.size,south.isHidden", {expires: 7} );
5256 * @example myLayout.loadCookie();
5257 * @example myLayout.deleteCookie();
5258 * @example var JSON = myLayout.readState(); // CURRENT Layout State
5259 * @example var JSON = myLayout.readCookie(); // SAVED Layout State (from cookie)
5260 * @example var JSON = myLayout.state.stateData; // LAST LOADED Layout State (cookie saved in layout.state hash)
5262 * CUSTOM STATE-MANAGEMENT (eg, saved in a database)
5263 * @example var JSON = myLayout.readState( "west.isClosed,north.size,south.isHidden" );
5264 * @example myLayout.loadState( JSON );
5267 // tell Layout that the state plugin is available
5268 $.layout.plugins.stateManagement = true;
5270 // Add State-Management options to layout.defaults
5271 $.layout.defaults.stateManagement = {
5272 enabled: false // true = enable state-management, even if not using cookies
5273 , autoSave: true // Save a state-cookie when page exits?
5274 , autoLoad: true // Load the state-cookie when Layout inits?
5275 , animateLoad: true // animate panes when loading state into an active layout
5276 , includeChildren: true // recurse into child layouts to include their state as well
5277 // List state-data to save - must be pane-specific
5278 , stateKeys: "north.size,south.size,east.size,west.size,"+
5279 "north.isClosed,south.isClosed,east.isClosed,west.isClosed,"+
5280 "north.isHidden,south.isHidden,east.isHidden,west.isHidden"
5282 name: "" // If not specified, will use Layout.name, else just "Layout"
5283 , domain: "" // blank = current domain
5284 , path: "" // blank = current page, "/" = entire website
5285 , expires: "" // 'days' to keep cookie - leave blank for 'session cookie'
5290 // Set stateManagement as a 'layout-option', NOT a 'pane-option'
5291 $.layout.optionsMap.layout.push("stateManagement");
5292 // Update config so layout does not move options into the pane-default branch (panes)
5293 $.layout.config.optionRootKeys.push("stateManagement");
5296 * State Management methods
5301 * Get the current layout state and save it to a cookie
5303 * myLayout.saveCookie( keys, cookieOpts )
5305 * @param {Object} inst
5306 * @param {(string|Array)=} keys
5307 * @param {Object=} cookieOpts
5309 saveCookie: function (inst, keys, cookieOpts) {
5310 var o = inst.options
5311 , sm = o.stateManagement
5312 , oC = $.extend(true, {}, sm.cookie, cookieOpts || null)
5313 , data = inst.state.stateData = inst.readState( keys || sm.stateKeys ) // read current panes-state
5315 $.ui.cookie.write( oC.name || o.name || "Layout", $.layout.state.encodeJSON(data), oC );
5316 return $.extend(true, {}, data); // return COPY of state.stateData data
5320 * Remove the state cookie
5322 * @param {Object} inst
5324 , deleteCookie: function (inst) {
5325 var o = inst.options;
5326 $.ui.cookie.clear( o.stateManagement.cookie.name || o.name || "Layout" );
5330 * Read & return data from the cookie - as JSON
5332 * @param {Object} inst
5334 , readCookie: function (inst) {
5335 var o = inst.options;
5336 var c = $.ui.cookie.read( o.stateManagement.cookie.name || o.name || "Layout" );
5337 // convert cookie string back to a hash and return it
5338 return c ? $.layout.state.decodeJSON(c) : {};
5342 * Get data from the cookie and USE IT to loadState
5344 * @param {Object} inst
5346 , loadCookie: function (inst) {
5347 var c = $.layout.state.readCookie(inst); // READ the cookie
5348 if (c && !$.isEmptyObject( c )) {
5349 inst.state.stateData = $.extend(true, {}, c); // SET state.stateData
5350 inst.loadState(c); // LOAD the retrieved state
5356 * Update layout options from the cookie, if one exists
5358 * @param {Object} inst
5359 * @param {Object=} stateData
5360 * @param {boolean=} animate
5362 , loadState: function (inst, data, opts) {
5363 if (!$.isPlainObject( data ) || $.isEmptyObject( data )) return;
5365 // normalize data & cache in the state object
5366 data = inst.state.stateData = $.layout.transformData( data ); // panes = default subkey
5368 // add missing/default state-restore options
5369 var smo = inst.options.stateManagement;
5371 animateLoad: false //smo.animateLoad
5372 , includeChildren: smo.includeChildren
5375 if (!inst.state.initialized) {
5377 * layout NOT initialized, so just update its options
5379 // MUST remove pane.children keys before applying to options
5380 // use a copy so we don't remove keys from original data
5381 var o = $.extend(true, {}, data);
5382 //delete o.center; // center has no state-data - only children
5383 $.each($.layout.config.allPanes, function (idx, pane) {
5384 if (o[pane]) delete o[pane].children;
5386 // update CURRENT layout-options with saved state data
5387 $.extend(true, inst.options, o);
5391 * layout already initialized, so modify layout's configuration
5393 var noAnimate = !opts.animateLoad
5394 , o, c, h, state, open
5396 $.each($.layout.config.borderPanes, function (idx, pane) {
5398 if (!$.isPlainObject( o )) return; // no key, skip pane
5404 state = inst.state[pane];
5405 open = state.isVisible;
5409 state.autoResize = ar;
5410 // resize BEFORE opening
5412 inst._sizePane(pane, s, false, false, false); // false=skipCallback/noAnimation/forceResize
5413 // open/close as necessary - DO NOT CHANGE THIS ORDER!
5414 if (h === true) inst.hide(pane, noAnimate);
5415 else if (c === true) inst.close(pane, false, noAnimate);
5416 else if (c === false) inst.open (pane, false, noAnimate);
5417 else if (h === false) inst.show (pane, false, noAnimate);
5418 // resize AFTER any other actions
5420 inst._sizePane(pane, s, false, false, noAnimate); // animate resize if option passed
5424 * RECURSE INTO CHILD-LAYOUTS
5426 if (opts.includeChildren) {
5427 var paneStateChildren, childState;
5428 $.each(inst.children, function (pane, paneChildren) {
5429 paneStateChildren = data[pane] ? data[pane].children : 0;
5430 if (paneStateChildren && paneChildren) {
5431 $.each(paneChildren, function (stateKey, child) {
5432 childState = paneStateChildren[stateKey];
5433 if (child && childState)
5434 child.loadState( childState );
5443 * Get the *current layout state* and return it as a hash
5445 * @param {Object=} inst // Layout instance to get state for
5446 * @param {object=} [opts] // State-Managements override options
5448 , readState: function (inst, opts) {
5449 // backward compatility
5450 if ($.type(opts) === 'string') opts = { keys: opts };
5451 if (!opts) opts = {};
5452 var sm = inst.options.stateManagement
5453 , ic = opts.includeChildren
5454 , recurse = ic !== undefined ? ic : sm.includeChildren
5455 , keys = opts.stateKeys || sm.stateKeys
5456 , alt = { isClosed: 'initClosed', isHidden: 'initHidden' }
5457 , state = inst.state
5458 , panes = $.layout.config.allPanes
5460 , pair, pane, key, val
5461 , ps, pC, child, array, count, branch
5463 if ($.isArray(keys)) keys = keys.join(",");
5464 // convert keys to an array and change delimiters from '__' to '.'
5465 keys = keys.replace(/__/g, ".").split(',');
5466 // loop keys and create a data hash
5467 for (var i=0, n=keys.length; i < n; i++) {
5468 pair = keys[i].split(".");
5471 if ($.inArray(pane, panes) < 0) continue; // bad pane!
5472 val = state[ pane ][ key ];
5473 if (val == undefined) continue;
5474 if (key=="isClosed" && state[pane]["isSliding"])
5475 val = true; // if sliding, then *really* isClosed
5476 ( data[pane] || (data[pane]={}) )[ alt[key] ? alt[key] : key ] = val;
5479 // recurse into the child-layouts for each pane
5481 $.each(panes, function (idx, pane) {
5482 pC = inst.children[pane];
5483 ps = state.stateData[pane];
5484 if ($.isPlainObject( pC ) && !$.isEmptyObject( pC )) {
5485 // ensure a key exists for this 'pane', eg: branch = data.center
5486 branch = data[pane] || (data[pane] = {});
5487 if (!branch.children) branch.children = {};
5488 $.each( pC, function (key, child) {
5489 // ONLY read state from an initialize layout
5490 if ( child.state.initialized )
5491 branch.children[ key ] = $.layout.state.readState( child );
5492 // if we have PREVIOUS (onLoad) state for this child-layout, KEEP IT!
5493 else if ( ps && ps.children && ps.children[ key ] ) {
5494 branch.children[ key ] = $.extend(true, {}, ps.children[ key ] );
5505 * Stringify a JSON hash so can save in a cookie or db-field
5507 , encodeJSON: function (json) {
5508 var local = window.JSON || {};
5509 return (local.stringify || stringify)(json);
5511 function stringify (h) {
5512 var D=[], i=0, k, v, t // k = key, v = value
5518 if (t == 'string') // STRING - add quotes
5520 else if (t == 'object') // SUB-KEY - recurse into it
5522 D[i++] = (!a ? '"'+ k +'":' : '') + v;
5524 return (a ? '[' : '{') + D.join(',') + (a ? ']' : '}');
5529 * Convert stringified JSON back to a hash object
5530 * @see $.parseJSON(), adding in jQuery 1.4.1
5532 , decodeJSON: function (str) {
5533 try { return $.parseJSON ? $.parseJSON(str) : window["eval"]("("+ str +")") || {}; }
5534 catch (e) { return {}; }
5538 , _create: function (inst) {
5539 var s = $.layout.state
5541 , sm = o.stateManagement
5543 // ADD State-Management plugin methods to inst
5545 // readCookie - update options from cookie - returns hash of cookie data
5546 readCookie: function () { return s.readCookie(inst); }
5548 , deleteCookie: function () { s.deleteCookie(inst); }
5549 // saveCookie - optionally pass keys-list and cookie-options (hash)
5550 , saveCookie: function (keys, cookieOpts) { return s.saveCookie(inst, keys, cookieOpts); }
5551 // loadCookie - readCookie and use to loadState() - returns hash of cookie data
5552 , loadCookie: function () { return s.loadCookie(inst); }
5553 // loadState - pass a hash of state to use to update options
5554 , loadState: function (stateData, opts) { s.loadState(inst, stateData, opts); }
5555 // readState - returns hash of current layout-state
5556 , readState: function (keys) { return s.readState(inst, keys); }
5557 // add JSON utility methods too...
5558 , encodeJSON: s.encodeJSON
5559 , decodeJSON: s.decodeJSON
5562 // init state.stateData key, even if plugin is initially disabled
5563 inst.state.stateData = {};
5565 // autoLoad MUST BE one of: data-array, data-hash, callback-function, or TRUE
5566 if ( !sm.autoLoad ) return;
5568 // When state-data exists in the autoLoad key USE IT,
5569 // even if stateManagement.enabled == false
5570 if ($.isPlainObject( sm.autoLoad )) {
5571 if (!$.isEmptyObject( sm.autoLoad )) {
5572 inst.loadState( sm.autoLoad );
5575 else if ( sm.enabled ) {
5576 // update the options from cookie or callback
5577 // if options is a function, call it to get stateData
5578 if ($.isFunction( sm.autoLoad )) {
5581 d = sm.autoLoad( inst, inst.state, inst.options, inst.options.name || '' ); // try to get data from fn
5583 if (d && $.isPlainObject( d ) && !$.isEmptyObject( d ))
5586 else // any other truthy value will trigger loadCookie
5591 , _unload: function (inst) {
5592 var sm = inst.options.stateManagement;
5593 if (sm.enabled && sm.autoSave) {
5594 // if options is a function, call it to save the stateData
5595 if ($.isFunction( sm.autoSave )) {
5597 sm.autoSave( inst, inst.state, inst.options, inst.options.name || '' ); // try to get data from fn
5600 else // any truthy value will trigger saveCookie
5607 // add state initialization method to Layout's onCreate array of functions
5608 $.layout.onCreate.push( $.layout.state._create );
5609 $.layout.onUnload.push( $.layout.state._unload );
5616 * @preserve jquery.layout.buttons 1.0
5617 * $Date: 2015/03/13 22:37:04 $
5619 * Copyright (c) 2011
5620 * Kevin Dalman (http://allpro.net)
5622 * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html)
5623 * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses.
5625 * @dependancies: UI Layout 1.3.0.rc30.1 or higher
5627 * @support: http://groups.google.com/group/jquery-ui-layout
5634 if (!$.layout) return;
5637 // tell Layout that the state plugin is available
5638 $.layout.plugins.buttons = true;
5640 // Add State-Management options to layout.defaults
5641 $.layout.defaults.autoBindCustomButtons = false;
5642 // Set stateManagement as a layout-option, NOT a pane-option
5643 $.layout.optionsMap.layout.push("autoBindCustomButtons");
5645 var lang = $.layout.language;
5650 $.layout.buttons = {
5651 // set data used by multiple methods below
5653 borderPanes: "north,south,west,east"
5657 * Searches for .ui-layout-button-xxx elements and auto-binds them as layout-buttons
5661 , init: function (inst) {
5662 var pre = "ui-layout-button-"
5663 , layout = inst.options.name || ""
5665 $.each("toggle,open,close,pin,toggle-slide,open-slide".split(","), function (i, action) {
5666 $.each($.layout.buttons.config.borderPanes.split(","), function (ii, pane) {
5667 $("."+pre+action+"-"+pane).each(function(){
5668 // if button was previously 'bound', data.layoutName was set, but is blank if layout has no 'name'
5669 name = $(this).data("layoutName") || $(this).attr("layoutName");
5670 if (name == undefined || name === layout)
5671 inst.bindButton(this, action, pane);
5678 * Helper function to validate params received by addButton utilities
5680 * Two classes are added to the element, based on the buttonClass...
5681 * The type of button is appended to create the 2nd className:
5682 * - ui-layout-button-pin
5683 * - ui-layout-pane-button-toggle
5684 * - ui-layout-pane-button-open
5685 * - ui-layout-pane-button-close
5687 * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
5688 * @param {string} pane Name of the pane the button is for: 'north', 'south', etc.
5689 * @return {Array.<Object>} If both params valid, the element matching 'selector' in a jQuery wrapper - otherwise returns null
5691 , get: function (inst, selector, pane, action) {
5692 var $E = $(selector)
5694 , err = o.showErrorMessages
5696 if (!$E.length) { // element not found
5697 if (err) alert(lang.errButton + lang.selector +": "+ selector);
5699 else if ($.layout.buttons.config.borderPanes.indexOf(pane) === -1) { // invalid 'pane' sepecified
5700 if (err) alert(lang.errButton + lang.pane +": "+ pane);
5701 $E = $(""); // NO BUTTON
5704 var btn = o[pane].buttonClass +"-"+ action;
5705 $E .addClass( btn +" "+ btn +"-"+ pane )
5706 .data("layoutName", o.name); // add layout identifier - even if blank!
5713 * NEW syntax for binding layout-buttons - will eventually replace addToggle, addOpen, etc.
5715 * @param {(string|!Object)} sel jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
5716 * @param {string} action
5717 * @param {string} pane
5719 , bind: function (inst, sel, action, pane) {
5720 var _ = $.layout.buttons;
5721 switch (action.toLowerCase()) {
5722 case "toggle": _.addToggle (inst, sel, pane); break;
5723 case "open": _.addOpen (inst, sel, pane); break;
5724 case "close": _.addClose (inst, sel, pane); break;
5725 case "pin": _.addPin (inst, sel, pane); break;
5726 case "toggle-slide": _.addToggle (inst, sel, pane, true); break;
5727 case "open-slide": _.addOpen (inst, sel, pane, true); break;
5733 * Add a custom Toggler button for a pane
5735 * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
5736 * @param {string} pane Name of the pane the button is for: 'north', 'south', etc.
5737 * @param {boolean=} slide true = slide-open, false = pin-open
5739 , addToggle: function (inst, selector, pane, slide) {
5740 $.layout.buttons.get(inst, selector, pane, "toggle")
5741 .click(function(evt){
5742 inst.toggle(pane, !!slide);
5743 evt.stopPropagation();
5749 * Add a custom Open button for a pane
5751 * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
5752 * @param {string} pane Name of the pane the button is for: 'north', 'south', etc.
5753 * @param {boolean=} slide true = slide-open, false = pin-open
5755 , addOpen: function (inst, selector, pane, slide) {
5756 $.layout.buttons.get(inst, selector, pane, "open")
5757 .attr("title", lang.Open)
5758 .click(function (evt) {
5759 inst.open(pane, !!slide);
5760 evt.stopPropagation();
5766 * Add a custom Close button for a pane
5768 * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
5769 * @param {string} pane Name of the pane the button is for: 'north', 'south', etc.
5771 , addClose: function (inst, selector, pane) {
5772 $.layout.buttons.get(inst, selector, pane, "close")
5773 .attr("title", lang.Close)
5774 .click(function (evt) {
5776 evt.stopPropagation();
5782 * Add a custom Pin button for a pane
5784 * Four classes are added to the element, based on the paneClass for the associated pane...
5785 * Assuming the default paneClass and the pin is 'up', these classes are added for a west-pane pin:
5786 * - ui-layout-pane-pin
5787 * - ui-layout-pane-west-pin
5788 * - ui-layout-pane-pin-up
5789 * - ui-layout-pane-west-pin-up
5791 * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
5792 * @param {string} pane Name of the pane the pin is for: 'north', 'south', etc.
5794 , addPin: function (inst, selector, pane) {
5795 var $E = $.layout.buttons.get(inst, selector, pane, "pin");
5797 var s = inst.state[pane];
5798 $E.click(function (evt) {
5799 $.layout.buttons.setPinState(inst, $(this), pane, (s.isSliding || s.isClosed));
5800 if (s.isSliding || s.isClosed) inst.open( pane ); // change from sliding to open
5801 else inst.close( pane ); // slide-closed
5802 evt.stopPropagation();
5804 // add up/down pin attributes and classes
5805 $.layout.buttons.setPinState(inst, $E, pane, (!s.isClosed && !s.isSliding));
5806 // add this pin to the pane data so we can 'sync it' automatically
5807 // PANE.pins key is an array so we can store multiple pins for each pane
5808 s.pins.push( selector ); // just save the selector string
5814 * Change the class of the pin button to make it look 'up' or 'down'
5816 * @see addPin(), syncPins()
5817 * @param {Array.<Object>} $Pin The pin-span element in a jQuery wrapper
5818 * @param {string} pane These are the params returned to callbacks by layout()
5819 * @param {boolean} doPin true = set the pin 'down', false = set it 'up'
5821 , setPinState: function (inst, $Pin, pane, doPin) {
5822 var updown = $Pin.attr("pin");
5823 if (updown && doPin === (updown=="down")) return; // already in correct state
5825 pin = inst.options[pane].buttonClass +"-pin"
5826 , side = pin +"-"+ pane
5827 , UP = pin +"-up "+ side +"-up"
5828 , DN = pin +"-down "+side +"-down"
5831 .attr("pin", doPin ? "down" : "up") // logic
5832 .attr("title", doPin ? lang.Unpin : lang.Pin)
5833 .removeClass( doPin ? UP : DN )
5834 .addClass( doPin ? DN : UP )
5839 * INTERNAL function to sync 'pin buttons' when pane is opened or closed
5840 * Unpinned means the pane is 'sliding' - ie, over-top of the adjacent panes
5842 * @see open(), close()
5843 * @param {string} pane These are the params returned to callbacks by layout()
5844 * @param {boolean} doPin True means set the pin 'down', False means 'up'
5846 , syncPinBtns: function (inst, pane, doPin) {
5847 // REAL METHOD IS _INSIDE_ LAYOUT - THIS IS HERE JUST FOR REFERENCE
5848 $.each(state[pane].pins, function (i, selector) {
5849 $.layout.buttons.setPinState(inst, $(selector), pane, doPin);
5854 , _load: function (inst) {
5855 // ADD Button methods to Layout Instance
5857 bindButton: function (selector, action, pane) { return $.layout.buttons.bind(inst, selector, action, pane); }
5858 // DEPRECATED METHODS...
5859 , addToggleBtn: function (selector, pane, slide) { return $.layout.buttons.addToggle(inst, selector, pane, slide); }
5860 , addOpenBtn: function (selector, pane, slide) { return $.layout.buttons.addOpen(inst, selector, pane, slide); }
5861 , addCloseBtn: function (selector, pane) { return $.layout.buttons.addClose(inst, selector, pane); }
5862 , addPinBtn: function (selector, pane) { return $.layout.buttons.addPin(inst, selector, pane); }
5865 // init state array to hold pin-buttons
5866 for (var i=0; i<4; i++) {
5867 var pane = $.layout.buttons.config.borderPanes[i];
5868 inst.state[pane].pins = [];
5871 // auto-init buttons onLoad if option is enabled
5872 if ( inst.options.autoBindCustomButtons )
5873 $.layout.buttons.init(inst);
5876 , _unload: function (inst) {
5877 // TODO: unbind all buttons???
5882 // add initialization method to Layout's onLoad array of functions
5883 $.layout.onLoad.push( $.layout.buttons._load );
5884 //$.layout.onUnload.push( $.layout.buttons._unload );
5892 * jquery.layout.browserZoom 1.0
5893 * $Date: 2015/03/13 22:37:04 $
5895 * Copyright (c) 2012
5896 * Kevin Dalman (http://allpro.net)
5898 * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html)
5899 * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses.
5901 * @requires: UI Layout 1.3.0.rc30.1 or higher
5903 * @see: http://groups.google.com/group/jquery-ui-layout
5905 * TODO: Extend logic to handle other problematic zooming in browsers
5906 * TODO: Add hotkey/mousewheel bindings to _instantly_ respond to these zoom event
5910 // tell Layout that the plugin is available
5911 $.layout.plugins.browserZoom = true;
5913 $.layout.defaults.browserZoomCheckInterval = 1000;
5914 $.layout.optionsMap.layout.push("browserZoomCheckInterval");
5917 * browserZoom methods
5919 $.layout.browserZoom = {
5921 _init: function (inst) {
5922 // abort if browser does not need this check
5923 if ($.layout.browserZoom.ratio() !== false)
5924 $.layout.browserZoom._setTimer(inst);
5927 , _setTimer: function (inst) {
5928 // abort if layout destroyed or browser does not need this check
5929 if (inst.destroyed) return;
5930 var o = inst.options
5932 // don't need check if inst has parentLayout, but check occassionally in case parent destroyed!
5933 // MINIMUM 100ms interval, for performance
5934 , ms = inst.hasParentLayout ? 5000 : Math.max( o.browserZoomCheckInterval, 100 )
5937 setTimeout(function(){
5938 if (inst.destroyed || !o.resizeWithWindow) return;
5939 var d = $.layout.browserZoom.ratio();
5940 if (d !== s.browserZoom) {
5944 // set a NEW timeout
5945 $.layout.browserZoom._setTimer(inst);
5950 , ratio: function () {
5954 , dE = d.documentElement || d.body
5955 , b = $.layout.browser
5959 // we can ignore all browsers that fire window.resize event onZoom
5960 if (!b.msie || v > 8)
5961 return false; // don't need to track zoom
5962 if (s.deviceXDPI && s.systemXDPI) // syntax compiler hack
5963 return calc(s.deviceXDPI, s.systemXDPI);
5964 // everything below is just for future reference!
5965 if (b.webkit && (r = d.body.getBoundingClientRect))
5966 return calc((r.left - r.right), d.body.offsetWidth);
5967 if (b.webkit && (sW = w.outerWidth))
5968 return calc(sW, w.innerWidth);
5969 if ((sW = s.width) && (cW = dE.clientWidth))
5970 return calc(sW, cW);
5971 return false; // no match, so cannot - or don't need to - track zoom
5973 function calc (x,y) { return (parseInt(x,10) / parseInt(y,10) * 100).toFixed(); }
5977 // add initialization method to Layout's onLoad array of functions
5978 $.layout.onReady.push( $.layout.browserZoom._init );
5987 * UI Layout Plugin: Slide-Offscreen Animation
5989 * Prevent panes from being 'hidden' so that an iframes/objects
5990 * does not reload/refresh when pane 'opens' again.
5991 * This plug-in adds a new animation called "slideOffscreen".
5992 * It is identical to the normal "slide" effect, but avoids hiding the element
5994 * Requires Layout 1.3.0.RC30.1 or later for Close offscreen
5995 * Requires Layout 1.3.0.RC30.5 or later for Hide, initClosed & initHidden offscreen
5997 * Version: 1.1 - 2012-11-18
5998 * Author: Kevin Dalman (kevin@jquery-dev.com)
5999 * @preserve jquery.layout.slideOffscreen-1.1.js
6003 // Add a new "slideOffscreen" effect
6006 // add an option so initClosed and initHidden will work
6007 $.layout.defaults.panes.useOffscreenClose = false; // user must enable when needed
6008 /* set the new animation as the default for all panes
6009 $.layout.defaults.panes.fxName = "slideOffscreen";
6012 if ($.layout.plugins)
6013 $.layout.plugins.effects.slideOffscreen = true;
6015 // dupe 'slide' effect defaults as new effect defaults
6016 $.layout.effects.slideOffscreen = $.extend(true, {}, $.layout.effects.slide);
6018 // add new effect to jQuery UI
6019 $.effects.slideOffscreen = function(o) {
6020 return this.queue(function(){
6025 , pane = $el.data('layoutEdge')
6026 , state = $el.data('parentLayout').state
6027 , dist = state[pane].size
6029 , props = ['top','bottom','left','right']
6031 , mode = fx.setMode($el, opt.mode || 'show') // Set Mode
6032 , show = (mode == 'show')
6033 , dir = opt.direction || 'left' // Default Direction
6034 , ref = (dir == 'up' || dir == 'down') ? 'top' : 'left'
6035 , pos = (dir == 'up' || dir == 'left')
6036 , offscrn = $.layout.config.offscreenCSS || {}
6037 , keyLR = $.layout.config.offscreenReset
6038 , keyTB = 'offscreenResetTop' // only used internally
6041 // Animation settings
6042 animation[ref] = (show ? (pos ? '+=' : '-=') : (pos ? '-=' : '+=')) + dist;
6044 if (show) { // show() animation, so save top/bottom but retain left/right set when 'hidden'
6045 $el.data(keyTB, { top: s.top, bottom: s.bottom });
6047 // set the top or left offset in preparation for animation
6048 // Note: ALL animations work by shifting the top or left edges
6049 if (pos) { // top (north) or left (west)
6050 $el.css(ref, isNaN(dist) ? "-" + dist : -dist); // Shift outside the left/top edge
6052 else { // bottom (south) or right (east) - shift all the way across container
6053 if (dir === 'right')
6054 $el.css({ left: state.container.layoutWidth, right: 'auto' });
6055 else // dir === bottom
6056 $el.css({ top: state.container.layoutHeight, bottom: 'auto' });
6058 // restore the left/right setting if is a top/bottom animation
6060 $el.css( $el.data( keyLR ) || {} );
6062 else { // hide() animation, so save ALL CSS
6063 $el.data(keyTB, { top: s.top, bottom: s.bottom });
6064 $el.data(keyLR, { left: s.left, right: s.right });
6068 $el.show().animate(animation, { queue: false, duration: o.duration, easing: opt.easing, complete: function(){
6069 // Restore top/bottom
6070 if ($el.data( keyTB ))
6071 $el.css($el.data( keyTB )).removeData( keyTB );
6072 if (show) // Restore left/right too
6073 $el.css($el.data( keyLR ) || {}).removeData( keyLR );
6074 else // Move the pane off-screen (left: -99999, right: 'auto')
6077 if (o.callback) o.callback.apply(this, arguments); // Callback