source: stylesheets/lfs-xsl/docbook-xsl-1.78.1/webhelp/docs/common/jquery/layout/jquery.layout.js@ b1a51ac1

7.5-systemd 7.6-systemd 7.7-systemd 7.8-systemd 7.9-systemd
Last change on this file since b1a51ac1 was b1a51ac1, checked in by Krejzi <krejzi@…>, 11 years ago

Import new branch

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/systemd/BOOK@10389 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 186.0 KB
Line 
1/**
2 * @preserve jquery.layout 1.3.0 - Release Candidate 30.51
3 * $Date$
4 * $Rev: 303005 $
5 *
6 * Copyright (c) 2012
7 * Fabrizio Balliano (http://www.fabrizioballiano.net)
8 * Kevin Dalman (http://allpro.net)
9 *
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.
12 *
13 * Changelog: http://layout.jquery-dev.net/changelog.cfm#1.3.0.rc30.5
14 *
15 * Docs: http://layout.jquery-dev.net/documentation.html
16 * Tips: http://layout.jquery-dev.net/tips.html
17 * Help: http://groups.google.com/group/jquery-ui-layout
18 */
19
20/* JavaDoc Info: http://code.google.com/closure/compiler/docs/js-for-compiler.html
21 * {!Object} non-nullable type (never NULL)
22 * {?string} nullable type (sometimes NULL) - default for {Object}
23 * {number=} optional parameter
24 * {*} ALL types
25 */
26
27// NOTE: For best readability, view with a fixed-width font and tabs equal to 4-chars
28
29;(function ($) {
30
31// alias Math methods - used a lot!
32var min = Math.min
33, max = Math.max
34, round = Math.floor
35;
36function isStr (v) { return $.type(v) === "string"; }
37
38function runPluginCallbacks (Instance, a_fn) {
39 if ($.isArray(a_fn))
40 for (var i=0, c=a_fn.length; i<c; i++) {
41 var fn = a_fn[i];
42 try {
43 if (isStr(fn)) // 'name' of a function
44 fn = eval(fn);
45 if ($.isFunction(fn))
46 fn( Instance );
47 } catch (ex) {}
48 }
49};
50
51
52
53/*
54 * GENERIC $.layout METHODS - used by all layouts
55 */
56$.layout = {
57
58 version: "1.3.rc30.51"
59, revision: 0.033005 // 1.3.0 final = 1.0300 - major(n+).minor(nn)+patch(nn+)
60
61 // LANGUAGE CUSTOMIZATION
62, language: {
63 // Tips and messages for resizers, togglers, custom buttons, etc.
64 Open: "Open" // eg: "Open Pane"
65 , Close: "Close"
66 , Resize: "Resize"
67 , Slide: "Slide Open"
68 , Pin: "Pin"
69 , Unpin: "Un-Pin"
70 , noRoomToOpenTip: "Not enough room to show this pane."
71 , minSizeWarning: "Panel has reached its minimum size"
72 , maxSizeWarning: "Panel has reached its maximum size"
73 // Developer error messages
74 , pane: "pane" // description of "layout pane element"
75 , selector: "selector" // description of "jQuery-selector"
76 , errButton: "Error Adding Button \n\nInvalid "
77 , errContainerMissing: "UI Layout Initialization Error\n\nThe specified layout-container does not exist."
78 , errCenterPaneMissing: "UI Layout Initialization Error\n\nThe center-pane element does not exist.\n\nThe center-pane is a required element."
79 , errContainerHeight: "UI Layout Initialization Warning\n\nThe layout-container \"CONTAINER\" has no height.\n\nTherefore the layout is 0-height and hence 'invisible'!"
80 }
81
82 // can update code here if $.browser is phased out
83, browser: {
84 mozilla: !!$.browser.mozilla
85 , webkit: !!$.browser.webkit || !!$.browser.safari // webkit = jQ 1.4
86 , msie: !!$.browser.msie
87 , isIE6: !!$.browser.msie && $.browser.version == 6
88 , version: $.browser.version // not used in Layout core, but may be used by plugins
89 }
90
91 // *PREDEFINED* EFFECTS & DEFAULTS
92 // MUST list effect here - OR MUST set an fxSettings option (can be an empty hash: {})
93, effects: {
94
95 // Pane Open/Close Animations
96 slide: {
97 all: { duration: "fast" } // eg: duration: 1000, easing: "easeOutBounce"
98 , north: { direction: "up" }
99 , south: { direction: "down" }
100 , east: { direction: "right"}
101 , west: { direction: "left" }
102 }
103 , drop: {
104 all: { duration: "slow" }
105 , north: { direction: "up" }
106 , south: { direction: "down" }
107 , east: { direction: "right"}
108 , west: { direction: "left" }
109 }
110 , scale: {
111 all: { duration: "fast" }
112 }
113 // these are not recommended, but can be used
114 , blind: {}
115 , clip: {}
116 , explode: {}
117 , fade: {}
118 , fold: {}
119 , puff: {}
120
121 // Pane Resize Animations
122 , size: {
123 all: { easing: "swing" }
124 }
125 }
126
127 // INTERNAL CONFIG DATA - DO NOT CHANGE THIS!
128, config: {
129 optionRootKeys: "effects,panes,north,south,west,east,center".split(",")
130 , allPanes: "north,south,west,east,center".split(",")
131 , borderPanes: "north,south,west,east".split(",")
132 , oppositeEdge: {
133 north: "south"
134 , south: "north"
135 , east: "west"
136 , west: "east"
137 }
138 // offscreen data
139 , offscreenCSS: { left: "-99999px", right: "auto" } // used by hide/close if useOffscreenClose=true
140 , offscreenReset: "offscreenReset" // key used for data
141 // CSS used in multiple places
142 , hidden: { visibility: "hidden" }
143 , visible: { visibility: "visible" }
144 // layout element settings
145 , resizers: {
146 cssReq: {
147 position: "absolute"
148 , padding: 0
149 , margin: 0
150 , fontSize: "1px"
151 , textAlign: "left" // to counter-act "center" alignment!
152 , overflow: "hidden" // prevent toggler-button from overflowing
153 // SEE $.layout.defaults.zIndexes.resizer_normal
154 }
155 , cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true
156 background: "#DDD"
157 , border: "none"
158 }
159 }
160 , togglers: {
161 cssReq: {
162 position: "absolute"
163 , display: "block"
164 , padding: 0
165 , margin: 0
166 , overflow: "hidden"
167 , textAlign: "center"
168 , fontSize: "1px"
169 , cursor: "pointer"
170 , zIndex: 1
171 }
172 , cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true
173 background: "#AAA"
174 }
175 }
176 , content: {
177 cssReq: {
178 position: "relative" /* contain floated or positioned elements */
179 }
180 , cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true
181 overflow: "auto"
182 , padding: "10px"
183 }
184 , cssDemoPane: { // DEMO CSS - REMOVE scrolling from 'pane' when it has a content-div
185 overflow: "hidden"
186 , padding: 0
187 }
188 }
189 , panes: { // defaults for ALL panes - overridden by 'per-pane settings' below
190 cssReq: {
191 position: "absolute"
192 , margin: 0
193 // $.layout.defaults.zIndexes.pane_normal
194 }
195 , cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true
196 padding: "10px"
197 , background: "#FFF"
198 , border: "1px solid #BBB"
199 , overflow: "auto"
200 }
201 }
202 , north: {
203 side: "Top"
204 , sizeType: "Height"
205 , dir: "horz"
206 , cssReq: {
207 top: 0
208 , bottom: "auto"
209 , left: 0
210 , right: 0
211 , width: "auto"
212 // height: DYNAMIC
213 }
214 }
215 , south: {
216 side: "Bottom"
217 , sizeType: "Height"
218 , dir: "horz"
219 , cssReq: {
220 top: "auto"
221 , bottom: 0
222 , left: 0
223 , right: 0
224 , width: "auto"
225 // height: DYNAMIC
226 }
227 }
228 , east: {
229 side: "Right"
230 , sizeType: "Width"
231 , dir: "vert"
232 , cssReq: {
233 left: "auto"
234 , right: 0
235 , top: "auto" // DYNAMIC
236 , bottom: "auto" // DYNAMIC
237 , height: "auto"
238 // width: DYNAMIC
239 }
240 }
241 , west: {
242 side: "Left"
243 , sizeType: "Width"
244 , dir: "vert"
245 , cssReq: {
246 left: 0
247 , right: "auto"
248 , top: "auto" // DYNAMIC
249 , bottom: "auto" // DYNAMIC
250 , height: "auto"
251 // width: DYNAMIC
252 }
253 }
254 , center: {
255 dir: "center"
256 , cssReq: {
257 left: "auto" // DYNAMIC
258 , right: "auto" // DYNAMIC
259 , top: "auto" // DYNAMIC
260 , bottom: "auto" // DYNAMIC
261 , height: "auto"
262 , width: "auto"
263 }
264 }
265 }
266
267 // CALLBACK FUNCTION NAMESPACE - used to store reusable callback functions
268, callbacks: {}
269
270, getParentPaneElem: function (el) {
271 // must pass either a container or pane element
272 var $el = $(el)
273 , layout = $el.data("layout") || $el.data("parentLayout");
274 if (layout) {
275 var $cont = layout.container;
276 // see if this container is directly-nested inside an outer-pane
277 if ($cont.data("layoutPane")) return $cont;
278 var $pane = $cont.closest("."+ $.layout.defaults.panes.paneClass);
279 // if a pane was found, return it
280 if ($pane.data("layoutPane")) return $pane;
281 }
282 return null;
283 }
284
285, getParentPaneInstance: function (el) {
286 // must pass either a container or pane element
287 var $pane = $.layout.getParentPaneElem(el);
288 return $pane ? $pane.data("layoutPane") : null;
289 }
290
291, getParentLayoutInstance: function (el) {
292 // must pass either a container or pane element
293 var $pane = $.layout.getParentPaneElem(el);
294 return $pane ? $pane.data("parentLayout") : null;
295 }
296
297, getEventObject: function (evt) {
298 return typeof evt === "object" && evt.stopPropagation ? evt : null;
299 }
300, parsePaneName: function (evt_or_pane) {
301 // getEventObject() automatically calls .stopPropagation(), WHICH MUST BE DONE!
302 var evt = $.layout.getEventObject( evt_or_pane );
303 if (evt) {
304 // ALWAYS stop propagation of events triggered in Layout!
305 evt.stopPropagation();
306 return $(this).data("layoutEdge");
307 }
308 else
309 return evt_or_pane;
310 }
311
312
313 // LAYOUT-PLUGIN REGISTRATION
314 // more plugins can added beyond this default list
315, plugins: {
316 draggable: !!$.fn.draggable // resizing
317 , effects: {
318 core: !!$.effects // animimations (specific effects tested by initOptions)
319 , slide: $.effects && $.effects.slide // default effect
320 }
321 }
322
323// arrays of plugin or other methods to be triggered for events in *each layout* - will be passed 'Instance'
324, onCreate: [] // runs when layout is just starting to be created - right after options are set
325, onLoad: [] // runs after layout container and global events init, but before initPanes is called
326, onReady: [] // runs after initialization *completes* - ie, after initPanes completes successfully
327, onDestroy: [] // runs after layout is destroyed
328, onUnload: [] // runs after layout is destroyed OR when page unloads
329, afterOpen: [] // runs after setAsOpen() completes
330, afterClose: [] // runs after setAsClosed() completes
331
332 /*
333 * GENERIC UTILITY METHODS
334 */
335
336 // calculate and return the scrollbar width, as an integer
337, scrollbarWidth: function () { return window.scrollbarWidth || $.layout.getScrollbarSize('width'); }
338, scrollbarHeight: function () { return window.scrollbarHeight || $.layout.getScrollbarSize('height'); }
339, getScrollbarSize: function (dim) {
340 var $c = $('<div style="position: absolute; top: -10000px; left: -10000px; width: 100px; height: 100px; overflow: scroll;"></div>').appendTo("body");
341 var d = { width: $c.width() - $c[0].clientWidth, height: $c.height() - $c[0].clientHeight };
342 $c.remove();
343 window.scrollbarWidth = d.width;
344 window.scrollbarHeight = d.height;
345 return dim.match(/^(width|height)$/) ? d[dim] : d;
346 }
347
348
349 /**
350 * Returns hash container 'display' and 'visibility'
351 *
352 * @see $.swap() - swaps CSS, runs callback, resets CSS
353 */
354, showInvisibly: function ($E, force) {
355 if (!$E) return {};
356 if (!$E.jquery) $E = $($E);
357 var CSS = {
358 display: $E.css('display')
359 , visibility: $E.css('visibility')
360 };
361 if (force || CSS.display === "none") { // only if not *already hidden*
362 $E.css({ display: "block", visibility: "hidden" }); // show element 'invisibly' so can be measured
363 return CSS;
364 }
365 else return {};
366 }
367
368 /**
369 * Returns data for setting size of an element (container or a pane).
370 *
371 * @see _create(), onWindowResize() for container, plus others for pane
372 * @return JSON Returns a hash of all dimensions: top, bottom, left, right, outerWidth, innerHeight, etc
373 */
374, getElementDimensions: function ($E) {
375 var
376 d = {} // dimensions hash
377 , x = d.css = {} // CSS hash
378 , i = {} // TEMP insets
379 , b, p // TEMP border, padding
380 , N = $.layout.cssNum
381 , off = $E.offset()
382 ;
383 d.offsetLeft = off.left;
384 d.offsetTop = off.top;
385
386 $.each("Left,Right,Top,Bottom".split(","), function (idx, e) { // e = edge
387 b = x["border" + e] = $.layout.borderWidth($E, e);
388 p = x["padding"+ e] = $.layout.cssNum($E, "padding"+e);
389 i[e] = b + p; // total offset of content from outer side
390 d["inset"+ e] = p;
391 });
392
393 d.offsetWidth = $E.innerWidth(); // offsetWidth is used in calc when doing manual resize
394 d.offsetHeight = $E.innerHeight(); // ditto
395 d.outerWidth = $E.outerWidth();
396 d.outerHeight = $E.outerHeight();
397 d.innerWidth = max(0, d.outerWidth - i.Left - i.Right);
398 d.innerHeight = max(0, d.outerHeight - i.Top - i.Bottom);
399
400 x.width = $E.width();
401 x.height = $E.height();
402 x.top = N($E,"top",true);
403 x.bottom = N($E,"bottom",true);
404 x.left = N($E,"left",true);
405 x.right = N($E,"right",true);
406
407 //d.visible = $E.is(":visible");// && x.width > 0 && x.height > 0;
408
409 return d;
410 }
411
412, getElementCSS: function ($E, list) {
413 var
414 CSS = {}
415 , style = $E[0].style
416 , props = list.split(",")
417 , sides = "Top,Bottom,Left,Right".split(",")
418 , attrs = "Color,Style,Width".split(",")
419 , p, s, a, i, j, k
420 ;
421 for (i=0; i < props.length; i++) {
422 p = props[i];
423 if (p.match(/(border|padding|margin)$/))
424 for (j=0; j < 4; j++) {
425 s = sides[j];
426 if (p === "border")
427 for (k=0; k < 3; k++) {
428 a = attrs[k];
429 CSS[p+s+a] = style[p+s+a];
430 }
431 else
432 CSS[p+s] = style[p+s];
433 }
434 else
435 CSS[p] = style[p];
436 };
437 return CSS
438 }
439
440 /**
441 * Return the innerWidth for the current browser/doctype
442 *
443 * @see initPanes(), sizeMidPanes(), initHandles(), sizeHandles()
444 * @param {Array.<Object>} $E Must pass a jQuery object - first element is processed
445 * @param {number=} outerWidth (optional) Can pass a width, allowing calculations BEFORE element is resized
446 * @return {number} Returns the innerWidth of the elem by subtracting padding and borders
447 */
448, cssWidth: function ($E, outerWidth) {
449 var
450 b = $.layout.borderWidth
451 , n = $.layout.cssNum
452 ;
453 // a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed
454 if (outerWidth <= 0) return 0;
455
456 if (!$.support.boxModel) return outerWidth;
457
458 // strip border and padding from outerWidth to get CSS Width
459 var W = outerWidth
460 - b($E, "Left")
461 - b($E, "Right")
462 - n($E, "paddingLeft")
463 - n($E, "paddingRight")
464 ;
465
466 return max(0,W);
467 }
468
469 /**
470 * Return the innerHeight for the current browser/doctype
471 *
472 * @see initPanes(), sizeMidPanes(), initHandles(), sizeHandles()
473 * @param {Array.<Object>} $E Must pass a jQuery object - first element is processed
474 * @param {number=} outerHeight (optional) Can pass a width, allowing calculations BEFORE element is resized
475 * @return {number} Returns the innerHeight of the elem by subtracting padding and borders
476 */
477, cssHeight: function ($E, outerHeight) {
478 var
479 b = $.layout.borderWidth
480 , n = $.layout.cssNum
481 ;
482 // a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed
483 if (outerHeight <= 0) return 0;
484
485 if (!$.support.boxModel) return outerHeight;
486
487 // strip border and padding from outerHeight to get CSS Height
488 var H = outerHeight
489 - b($E, "Top")
490 - b($E, "Bottom")
491 - n($E, "paddingTop")
492 - n($E, "paddingBottom")
493 ;
494
495 return max(0,H);
496 }
497
498 /**
499 * Returns the 'current CSS numeric value' for a CSS property - 0 if property does not exist
500 *
501 * @see Called by many methods
502 * @param {Array.<Object>} $E Must pass a jQuery object - first element is processed
503 * @param {string} prop The name of the CSS property, eg: top, width, etc.
504 * @param {boolean=} [allowAuto=false] true = return 'auto' if that is value; false = return 0
505 * @return {(string|number)} Usually used to get an integer value for position (top, left) or size (height, width)
506 */
507, cssNum: function ($E, prop, allowAuto) {
508 if (!$E.jquery) $E = $($E);
509 var CSS = $.layout.showInvisibly($E)
510 , p = $.curCSS($E[0], prop, true)
511 , v = allowAuto && p=="auto" ? p : (parseInt(p, 10) || 0);
512 $E.css( CSS ); // RESET
513 return v;
514 }
515
516, borderWidth: function (el, side) {
517 if (el.jquery) el = el[0];
518 var b = "border"+ side.substr(0,1).toUpperCase() + side.substr(1); // left => Left
519 return $.curCSS(el, b+"Style", true) === "none" ? 0 : (parseInt($.curCSS(el, b+"Width", true), 10) || 0);
520 }
521
522 /**
523 * Mouse-tracking utility - FUTURE REFERENCE
524 *
525 * init: if (!window.mouse) {
526 * window.mouse = { x: 0, y: 0 };
527 * $(document).mousemove( $.layout.trackMouse );
528 * }
529 *
530 * @param {Object} evt
531 *
532, trackMouse: function (evt) {
533 window.mouse = { x: evt.clientX, y: evt.clientY };
534 }
535 */
536
537 /**
538 * SUBROUTINE for preventPrematureSlideClose option
539 *
540 * @param {Object} evt
541 * @param {Object=} el
542 */
543, isMouseOverElem: function (evt, el) {
544 var
545 $E = $(el || this)
546 , d = $E.offset()
547 , T = d.top
548 , L = d.left
549 , R = L + $E.outerWidth()
550 , B = T + $E.outerHeight()
551 , x = evt.pageX // evt.clientX ?
552 , y = evt.pageY // evt.clientY ?
553 ;
554 // if X & Y are < 0, probably means is over an open SELECT
555 return ($.layout.browser.msie && x < 0 && y < 0) || ((x >= L && x <= R) && (y >= T && y <= B));
556 }
557
558 /**
559 * Message/Logging Utility
560 *
561 * @example $.layout.msg("My message"); // log text
562 * @example $.layout.msg("My message", true); // alert text
563 * @example $.layout.msg({ foo: "bar" }, "Title"); // log hash-data, with custom title
564 * @example $.layout.msg({ foo: "bar" }, true, "Title", { sort: false }); -OR-
565 * @example $.layout.msg({ foo: "bar" }, "Title", { sort: false, display: true }); // alert hash-data
566 *
567 * @param {(Object|string)} info String message OR Hash/Array
568 * @param {(Boolean|string|Object)=} [popup=false] True means alert-box - can be skipped
569 * @param {(Object|string)=} [debugTitle=""] Title for Hash data - can be skipped
570 * @param {Object=} [debutOpts={}] Extra options for debug output
571 */
572, msg: function (info, popup, debugTitle, debugOpts) {
573 if ($.isPlainObject(info) && window.debugData) {
574 if (typeof popup === "string") {
575 debugOpts = debugTitle;
576 debugTitle = popup;
577 }
578 else if (typeof debugTitle === "object") {
579 debugOpts = debugTitle;
580 debugTitle = null;
581 }
582 var t = debugTitle || "log( <object> )"
583 , o = $.extend({ sort: false, returnHTML: false, display: false }, debugOpts);
584 if (popup === true || o.display)
585 debugData( info, t, o );
586 else if (window.console)
587 console.log(debugData( info, t, o ));
588 }
589 else if (popup)
590 alert(info);
591 else if (window.console)
592 console.log(info);
593 else {
594 var id = "#layoutLogger"
595 , $l = $(id);
596 if (!$l.length)
597 $l = createLog();
598 $l.children("ul").append('<li style="padding: 4px 10px; margin: 0; border-top: 1px solid #CCC;">'+ info.replace(/\</g,"&lt;").replace(/\>/g,"&gt;") +'</li>');
599 }
600
601 function createLog () {
602 var pos = $.support.fixedPosition ? 'fixed' : 'absolute'
603 , $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);">'
604 + '<div style="font-size: 13px; font-weight: bold; padding: 5px 10px; background: #F6F6F6; border-radius: 5px 5px 0 0; cursor: move;">'
605 + '<span style="float: right; padding-left: 7px; cursor: pointer;" title="Remove Console" onclick="$(this).closest(\'#layoutLogger\').remove()">X</span>Layout console.log</div>'
606 + '<ul style="font-size: 13px; font-weight: none; list-style: none; margin: 0; padding: 0 0 2px;"></ul>'
607 + '</div>'
608 ).appendTo("body");
609 $e.css('left', $(window).width() - $e.outerWidth() - 5)
610 if ($.ui.draggable) $e.draggable({ handle: ':first-child' });
611 return $e;
612 };
613 }
614
615};
616
617var lang = $.layout.language; // alias used in defaults...
618
619// DEFAULT OPTIONS - CHANGE IF DESIRED
620$.layout.defaults = {
621/*
622 * LAYOUT & LAYOUT-CONTAINER OPTIONS
623 * - none of these options are applicable to individual panes
624 */
625 name: "" // Not required, but useful for buttons and used for the state-cookie
626, containerSelector: "" // ONLY used when specifying a childOptions - to find container-element that is NOT directly-nested
627, containerClass: "ui-layout-container" // layout-container element
628, scrollToBookmarkOnLoad: true // after creating a layout, scroll to bookmark in URL (.../page.htm#myBookmark)
629, resizeWithWindow: true // bind thisLayout.resizeAll() to the window.resize event
630, resizeWithWindowDelay: 200 // delay calling resizeAll because makes window resizing very jerky
631, resizeWithWindowMaxDelay: 0 // 0 = none - force resize every XX ms while window is being resized
632, onresizeall_start: null // CALLBACK when resizeAll() STARTS - NOT pane-specific
633, onresizeall_end: null // CALLBACK when resizeAll() ENDS - NOT pane-specific
634, onload_start: null // CALLBACK when Layout inits - after options initialized, but before elements
635, onload_end: null // CALLBACK when Layout inits - after EVERYTHING has been initialized
636, onunload_start: null // CALLBACK when Layout is destroyed OR onWindowUnload
637, onunload_end: null // CALLBACK when Layout is destroyed OR onWindowUnload
638, autoBindCustomButtons: false // search for buttons with ui-layout-button class and auto-bind them
639, initPanes: true // false = DO NOT initialize the panes onLoad - will init later
640, showErrorMessages: true // enables fatal error messages to warn developers of common errors
641, showDebugMessages: false // display console-and-alert debug msgs - IF this Layout version _has_ debugging code!
642// Changing this zIndex value will cause other zIndex values to automatically change
643, zIndex: null // the PANE zIndex - resizers and masks will be +1
644// DO NOT CHANGE the zIndex values below unless you clearly understand their relationships
645, zIndexes: { // set _default_ z-index values here...
646 pane_normal: 0 // normal z-index for panes
647 , content_mask: 1 // applied to overlays used to mask content INSIDE panes during resizing
648 , resizer_normal: 2 // normal z-index for resizer-bars
649 , pane_sliding: 100 // applied to *BOTH* the pane and its resizer when a pane is 'slid open'
650 , pane_animate: 1000 // applied to the pane when being animated - not applied to the resizer
651 , resizer_drag: 10000 // applied to the CLONED resizer-bar when being 'dragged'
652 }
653/*
654 * PANE DEFAULT SETTINGS
655 * - settings under the 'panes' key become the default settings for *all panes*
656 * - ALL pane-options can also be set specifically for each panes, which will override these 'default values'
657 */
658, panes: { // default options for 'all panes' - will be overridden by 'per-pane settings'
659 applyDemoStyles: false // NOTE: renamed from applyDefaultStyles for clarity
660 , closable: true // pane can open & close
661 , resizable: true // when open, pane can be resized
662 , slidable: true // when closed, pane can 'slide open' over other panes - closes on mouse-out
663 , initClosed: false // true = init pane as 'closed'
664 , initHidden: false // true = init pane as 'hidden' - no resizer-bar/spacing
665 // SELECTORS
666 //, paneSelector: "" // MUST be pane-specific - jQuery selector for pane
667 , contentSelector: ".ui-layout-content" // INNER div/element to auto-size so only it scrolls, not the entire pane!
668 , contentIgnoreSelector: ".ui-layout-ignore" // element(s) to 'ignore' when measuring 'content'
669 , findNestedContent: false // true = $P.find(contentSelector), false = $P.children(contentSelector)
670 // GENERIC ROOT-CLASSES - for auto-generated classNames
671 , paneClass: "ui-layout-pane" // Layout Pane
672 , resizerClass: "ui-layout-resizer" // Resizer Bar
673 , togglerClass: "ui-layout-toggler" // Toggler Button
674 , buttonClass: "ui-layout-button" // CUSTOM Buttons - eg: '[ui-layout-button]-toggle/-open/-close/-pin'
675 // ELEMENT SIZE & SPACING
676 //, size: 100 // MUST be pane-specific -initial size of pane
677 , minSize: 0 // when manually resizing a pane
678 , maxSize: 0 // ditto, 0 = no limit
679 , spacing_open: 6 // space between pane and adjacent panes - when pane is 'open'
680 , spacing_closed: 6 // ditto - when pane is 'closed'
681 , togglerLength_open: 50 // Length = WIDTH of toggler button on north/south sides - HEIGHT on east/west sides
682 , togglerLength_closed: 50 // 100% OR -1 means 'full height/width of resizer bar' - 0 means 'hidden'
683 , togglerAlign_open: "center" // top/left, bottom/right, center, OR...
684 , togglerAlign_closed: "center" // 1 => nn = offset from top/left, -1 => -nn == offset from bottom/right
685 , togglerTip_open: lang.Close // Toggler tool-tip (title)
686 , togglerTip_closed: lang.Open // ditto
687 , togglerContent_open: "" // text or HTML to put INSIDE the toggler
688 , togglerContent_closed: "" // ditto
689 // RESIZING OPTIONS
690 , resizerDblClickToggle: true //
691 , autoResize: true // IF size is 'auto' or a percentage, then recalc 'pixel size' whenever the layout resizes
692 , autoReopen: true // IF a pane was auto-closed due to noRoom, reopen it when there is room? False = leave it closed
693 , resizerDragOpacity: 1 // option for ui.draggable
694 //, resizerCursor: "" // MUST be pane-specific - cursor when over resizer-bar
695 , maskContents: false // true = add DIV-mask over-or-inside this pane so can 'drag' over IFRAMES
696 , maskObjects: false // true = add IFRAME-mask over-or-inside this pane to cover objects/applets - content-mask will overlay this mask
697 , maskZindex: null // will override zIndexes.content_mask if specified - not applicable to iframe-panes
698 , resizingGrid: false // grid size that the resizers will snap-to during resizing, eg: [20,20]
699 , livePaneResizing: false // true = LIVE Resizing as resizer is dragged
700 , liveContentResizing: false // true = re-measure header/footer heights as resizer is dragged
701 , liveResizingTolerance: 1 // how many px change before pane resizes, to control performance
702 // TIPS & MESSAGES - also see lang object
703 , noRoomToOpenTip: lang.noRoomToOpenTip
704 , resizerTip: lang.Resize // Resizer tool-tip (title)
705 , sliderTip: lang.Slide // resizer-bar triggers 'sliding' when pane is closed
706 , sliderCursor: "pointer" // cursor when resizer-bar will trigger 'sliding'
707 , slideTrigger_open: "click" // click, dblclick, mouseenter
708 , slideTrigger_close: "mouseleave"// click, mouseleave
709 , slideDelay_open: 300 // applies only for mouseenter event - 0 = instant open
710 , slideDelay_close: 300 // applies only for mouseleave event (300ms is the minimum!)
711 , hideTogglerOnSlide: false // when pane is slid-open, should the toggler show?
712 , preventQuickSlideClose: $.layout.browser.webkit // Chrome triggers slideClosed as it is opening
713 , preventPrematureSlideClose: false // handle incorrect mouseleave trigger, like when over a SELECT-list in IE
714 // HOT-KEYS & MISC
715 , showOverflowOnHover: false // will bind allowOverflow() utility to pane.onMouseOver
716 , enableCursorHotkey: true // enabled 'cursor' hotkeys
717 //, customHotkey: "" // MUST be pane-specific - EITHER a charCode OR a character
718 , customHotkeyModifier: "SHIFT" // either 'SHIFT', 'CTRL' or 'CTRL+SHIFT' - NOT 'ALT'
719 // PANE ANIMATION
720 // NOTE: fxSss_open, fxSss_close & fxSss_size options (eg: fxName_open) are auto-generated if not passed
721 , fxName: "slide" // ('none' or blank), slide, drop, scale -- only relevant to 'open' & 'close', NOT 'size'
722 , fxSpeed: null // slow, normal, fast, 200, nnn - if passed, will OVERRIDE fxSettings.duration
723 , fxSettings: {} // can be passed, eg: { easing: "easeOutBounce", duration: 1500 }
724 , fxOpacityFix: true // tries to fix opacity in IE to restore anti-aliasing after animation
725 , animatePaneSizing: false // true = animate resizing after dragging resizer-bar OR sizePane() is called
726 /* NOTE: Action-specific FX options are auto-generated from the options above if not specifically set:
727 fxName_open: "slide" // 'Open' pane animation
728 fnName_close: "slide" // 'Close' pane animation
729 fxName_size: "slide" // 'Size' pane animation - when animatePaneSizing = true
730 fxSpeed_open: null
731 fxSpeed_close: null
732 fxSpeed_size: null
733 fxSettings_open: {}
734 fxSettings_close: {}
735 fxSettings_size: {}
736 */
737 // CHILD/NESTED LAYOUTS
738 , childOptions: null // Layout-options for nested/child layout - even {} is valid as options
739 , initChildLayout: true // true = child layout will be created as soon as _this_ layout completes initialization
740 , destroyChildLayout: true // true = destroy child-layout if this pane is destroyed
741 , resizeChildLayout: true // true = trigger child-layout.resizeAll() when this pane is resized
742 // PANE CALLBACKS
743 , triggerEventsOnLoad: false // true = trigger onopen OR onclose callbacks when layout initializes
744 , triggerEventsDuringLiveResize: true // true = trigger onresize callback REPEATEDLY if livePaneResizing==true
745 , onshow_start: null // CALLBACK when pane STARTS to Show - BEFORE onopen/onhide_start
746 , onshow_end: null // CALLBACK when pane ENDS being Shown - AFTER onopen/onhide_end
747 , onhide_start: null // CALLBACK when pane STARTS to Close - BEFORE onclose_start
748 , onhide_end: null // CALLBACK when pane ENDS being Closed - AFTER onclose_end
749 , onopen_start: null // CALLBACK when pane STARTS to Open
750 , onopen_end: null // CALLBACK when pane ENDS being Opened
751 , onclose_start: null // CALLBACK when pane STARTS to Close
752 , onclose_end: null // CALLBACK when pane ENDS being Closed
753 , onresize_start: null // CALLBACK when pane STARTS being Resized ***FOR ANY REASON***
754 , onresize_end: null // CALLBACK when pane ENDS being Resized ***FOR ANY REASON***
755 , onsizecontent_start: null // CALLBACK when sizing of content-element STARTS
756 , onsizecontent_end: null // CALLBACK when sizing of content-element ENDS
757 , onswap_start: null // CALLBACK when pane STARTS to Swap
758 , onswap_end: null // CALLBACK when pane ENDS being Swapped
759 , ondrag_start: null // CALLBACK when pane STARTS being ***MANUALLY*** Resized
760 , ondrag_end: null // CALLBACK when pane ENDS being ***MANUALLY*** Resized
761 }
762/*
763 * PANE-SPECIFIC SETTINGS
764 * - options listed below MUST be specified per-pane - they CANNOT be set under 'panes'
765 * - all options under the 'panes' key can also be set specifically for any pane
766 * - most options under the 'panes' key apply only to 'border-panes' - NOT the the center-pane
767 */
768, north: {
769 paneSelector: ".ui-layout-north"
770 , size: "auto" // eg: "auto", "30%", .30, 200
771 , resizerCursor: "n-resize" // custom = url(myCursor.cur)
772 , customHotkey: "" // EITHER a charCode (43) OR a character ("o")
773 }
774, south: {
775 paneSelector: ".ui-layout-south"
776 , size: "auto"
777 , resizerCursor: "s-resize"
778 , customHotkey: ""
779 }
780, east: {
781 paneSelector: ".ui-layout-east"
782 , size: 200
783 , resizerCursor: "e-resize"
784 , customHotkey: ""
785 }
786, west: {
787 paneSelector: ".ui-layout-west"
788 , size: 200
789 , resizerCursor: "w-resize"
790 , customHotkey: ""
791 }
792, center: {
793 paneSelector: ".ui-layout-center"
794 , minWidth: 0
795 , minHeight: 0
796 }
797};
798
799$.layout.optionsMap = {
800 // layout/global options - NOT pane-options
801 layout: ("stateManagement,effects,zIndexes,"
802 + "name,zIndex,scrollToBookmarkOnLoad,showErrorMessages,"
803 + "resizeWithWindow,resizeWithWindowDelay,resizeWithWindowMaxDelay,"
804 + "onresizeall,onresizeall_start,onresizeall_end,onload,onunload,autoBindCustomButtons").split(",")
805// borderPanes: [ ALL options that are NOT specified as 'layout' ]
806 // default.panes options that apply to the center-pane (most options apply _only_ to border-panes)
807, center: ("paneClass,contentSelector,contentIgnoreSelector,findNestedContent,applyDemoStyles,triggerEventsOnLoad,"
808 + "showOverflowOnHover,maskContents,maskObjects,liveContentResizing,"
809 + "childOptions,initChildLayout,resizeChildLayout,destroyChildLayout,"
810 + "onresize,onresize_start,onresize_end,onsizecontent,onsizecontent_start,onsizecontent_end").split(",")
811 // options that MUST be specifically set 'per-pane' - CANNOT set in the panes (defaults) key
812, noDefault: ("paneSelector,resizerCursor,customHotkey").split(",")
813};
814
815/**
816 * Processes options passed in converts flat-format data into subkey (JSON) format
817 * In flat-format, subkeys are _currently_ separated with 2 underscores, like north__optName
818 * Plugins may also call this method so they can transform their own data
819 *
820 * @param {!Object} hash Data/options passed by user - may be a single level or nested levels
821 * @return {Object} Returns hash of minWidth & minHeight
822 */
823$.layout.transformData = function (hash) {
824 var json = { panes: {}, center: {} } // init return object
825 , data, branch, optKey, keys, key, val, i, c;
826
827 if (typeof hash !== "object") return json; // no options passed
828
829 // convert all 'flat-keys' to 'sub-key' format
830 for (optKey in hash) {
831 branch = json;
832 data = $.layout.optionsMap.layout;
833 val = hash[ optKey ];
834 keys = optKey.split("__"); // eg: west__size or north__fxSettings__duration
835 c = keys.length - 1;
836 // convert underscore-delimited to subkeys
837 for (i=0; i <= c; i++) {
838 key = keys[i];
839 if (i === c)
840 branch[key] = val;
841 else if (!branch[key])
842 branch[key] = {}; // create the subkey
843 // recurse to sub-key for next loop - if not done
844 branch = branch[key];
845 }
846 }
847
848 return json;
849}
850
851// INTERNAL CONFIG DATA - DO NOT CHANGE THIS!
852$.layout.backwardCompatibility = {
853 // data used by renameOldOptions()
854 map: {
855 // OLD Option Name: NEW Option Name
856 applyDefaultStyles: "applyDemoStyles"
857 , resizeNestedLayout: "resizeChildLayout"
858 , resizeWhileDragging: "livePaneResizing"
859 , resizeContentWhileDragging: "liveContentResizing"
860 , triggerEventsWhileDragging: "triggerEventsDuringLiveResize"
861 , maskIframesOnResize: "maskContents"
862 , useStateCookie: "stateManagement.enabled"
863 , "cookie.autoLoad": "stateManagement.autoLoad"
864 , "cookie.autoSave": "stateManagement.autoSave"
865 , "cookie.keys": "stateManagement.stateKeys"
866 , "cookie.name": "stateManagement.cookie.name"
867 , "cookie.domain": "stateManagement.cookie.domain"
868 , "cookie.path": "stateManagement.cookie.path"
869 , "cookie.expires": "stateManagement.cookie.expires"
870 , "cookie.secure": "stateManagement.cookie.secure"
871 }
872 /**
873 * @param {Object} opts
874 */
875, renameOptions: function (opts) {
876 var map = $.layout.backwardCompatibility.map
877 , oldData, newData, value
878 ;
879 for (var itemPath in map) {
880 oldData = getBranch( itemPath );
881 value = oldData.branch[ oldData.key ]
882 if (value !== undefined) {
883 newData = getBranch( map[itemPath], true )
884 newData.branch[ newData.key ] = value;
885 delete oldData.branch[ oldData.key ];
886 }
887 }
888
889 /**
890 * @param {string} path
891 * @param {boolean=} [create=false] Create path if does not exist
892 */
893 function getBranch (path, create) {
894 var a = path.split(".") // split keys into array
895 , c = a.length - 1
896 , D = { branch: opts, key: a[c] } // init branch at top & set key (last item)
897 , i = 0, k, undef;
898 for (; i<c; i++) { // skip the last key (data)
899 k = a[i];
900 if (D.branch[ k ] == undefined) { // child-key does not exist
901 if (create) {
902 D.branch = D.branch[ k ] = {}; // create child-branch
903 }
904 else // can't go any farther
905 D.branch = {}; // branch is undefined
906 }
907 else
908 D.branch = D.branch[ k ]; // get child-branch
909 }
910 return D;
911 };
912 }
913 /**
914 * @param {Object} opts
915 */
916, renameAllOptions: function (opts) {
917 var ren = $.layout.backwardCompatibility.renameOptions;
918 // rename root (layout) options
919 ren( opts );
920 // rename 'defaults' to 'panes'
921 if (opts.defaults) {
922 if (typeof opts.panes !== "object")
923 opts.panes = {};
924 $.extend(true, opts.panes, opts.defaults);
925 delete opts.defaults;
926 }
927 // rename options in the the options.panes key
928 if (opts.panes) ren( opts.panes );
929 // rename options inside *each pane key*, eg: options.west
930 $.each($.layout.config.allPanes, function (i, pane) {
931 if (opts[pane]) ren( opts[pane] );
932 });
933 return opts;
934 }
935};
936
937
938
939/* ============================================================
940 * BEGIN WIDGET: $( selector ).layout( {options} );
941 * ============================================================
942 */
943$.fn.layout = function (opts) {
944 var
945
946 // local aliases to global data
947 browser = $.layout.browser
948, lang = $.layout.language // internal alias
949, _c = $.layout.config
950
951 // local aliases to utlity methods
952, cssW = $.layout.cssWidth
953, cssH = $.layout.cssHeight
954, elDims = $.layout.getElementDimensions
955, elCSS = $.layout.getElementCSS
956, evtObj = $.layout.getEventObject
957, evtPane = $.layout.parsePaneName
958
959/**
960 * options - populated by initOptions()
961 */
962, options = $.extend(true, {}, $.layout.defaults)
963, effects = options.effects = $.extend(true, {}, $.layout.effects)
964
965/**
966 * layout-state object
967 */
968, state = {
969 // generate unique ID to use for event.namespace so can unbind only events added by 'this layout'
970 id: "layout"+ $.now() // code uses alias: sID
971 , initialized: false
972 , container: {} // init all keys
973 , north: {}
974 , south: {}
975 , east: {}
976 , west: {}
977 , center: {}
978 }
979
980/**
981 * parent/child-layout pointers
982 */
983//, hasParentLayout = false - exists ONLY inside Instance so can be set externally
984, children = {
985 north: null
986 , south: null
987 , east: null
988 , west: null
989 , center: null
990 }
991
992/*
993 * ###########################
994 * INTERNAL HELPER FUNCTIONS
995 * ###########################
996 */
997
998 /**
999 * Manages all internal timers
1000 */
1001, timer = {
1002 data: {}
1003 , set: function (s, fn, ms) { timer.clear(s); timer.data[s] = setTimeout(fn, ms); }
1004 , clear: function (s) { var t=timer.data; if (t[s]) {clearTimeout(t[s]); delete t[s];} }
1005 }
1006
1007, _log = function (msg, popup) {
1008 $.layout.msg( options.name +' / '+ msg, (popup && options.showErrorMessages) );
1009 }
1010
1011 /**
1012 * Executes a Callback function after a trigger event, like resize, open or close
1013 *
1014 * @param {string} evtName Name of the layout callback, eg "onresize_start"
1015 * @param {?string} pane This is passed only so we can pass the 'pane object' to the callback
1016 * @param {?boolean} skipBoundEvents Accepts a function name, OR a comma-delimited array: [0]=function name, [1]=argument
1017 */
1018, _runCallbacks = function (evtName, pane, skipBoundEvents) {
1019 var o = pane ? options[pane] : options
1020 // names like onopen and onopen_end separate are interchangeable in options...
1021 , lng = evtName + (evtName.match(/_/) ? "" : "_end")
1022 , shrt = lng.match(/_end$/) ? lng.substr(0, lng.length - 4) : ""
1023 , fn = o[lng]
1024 , retVal = "NC" // NC = No Callback
1025 , args = []
1026 ;
1027 if (!fn && shrt)
1028 fn = o[shrt];
1029
1030 // first trigger the callback set in the options
1031 if (fn) {
1032 //try {
1033 // convert function name (string) to function object
1034 if (isStr( fn )) {
1035 if (fn.match(/,/)) {
1036 // function name cannot contain a comma,
1037 // so must be a function name AND a parameter to pass
1038 args = fn.split(",")
1039 , fn = eval(args[0]);
1040 }
1041 else // just the name of an external function?
1042 fn = eval(fn);
1043 }
1044 // execute the callback, if exists
1045 if ($.isFunction( fn )) {
1046 if (args.length)
1047 retVal = fn(args[1]); // pass the argument parsed from 'list'
1048 else if (pane && $Ps[pane])
1049 // pass data: pane-name, pane-element, pane-state, pane-options, and layout-name
1050 retVal = fn( pane, $Ps[pane], state[pane], options[pane], options.name );
1051 else // must be a layout/container callback - pass suitable info
1052 retVal = fn( Instance, state, options, options.name );
1053 }
1054 //}
1055 //catch (ex) {}
1056 }
1057
1058 // trigger additional events bound directly to the pane
1059 if (!skipBoundEvents && retVal !== false) {
1060 if (pane) { // PANE events can be bound to each pane-elements
1061 $Ps[pane].triggerHandler('layoutpane'+ lng, [ pane, $Ps[pane], state[pane], options[pane], options.name ]);
1062 if (shrt)
1063 $Ps[pane].triggerHandler('layoutpane'+ shrt, [ pane, $Ps[pane], state[pane], options[pane], options.name ]);
1064 }
1065 else // LAYOUT events can be bound to the container-element
1066 $N.triggerHandler('layout'+ lng, [ pane, $Ps[pane], state[pane], options[pane], options.name ]);
1067 }
1068
1069 // ALWAYS resizeChildLayout after a resize event - even during initialization
1070 if (evtName === "onresize_end" || evtName === "onsizecontent_end")
1071 resizeChildLayout(pane);
1072
1073 return retVal;
1074 }
1075
1076
1077 /**
1078 * cure iframe display issues in IE & other browsers
1079 */
1080, _fixIframe = function (pane) {
1081 if (browser.mozilla) return; // skip FireFox - it auto-refreshes iframes onShow
1082 var $P = $Ps[pane];
1083 // if the 'pane' is an iframe, do it
1084 if (state[pane].tagName === "IFRAME")
1085 $P.css(_c.hidden).css(_c.visible);
1086 else // ditto for any iframes INSIDE the pane
1087 $P.find('IFRAME').css(_c.hidden).css(_c.visible);
1088 }
1089
1090 /**
1091 * @param {string} pane Can accept ONLY a 'pane' (east, west, etc)
1092 * @param {number=} outerSize (optional) Can pass a width, allowing calculations BEFORE element is resized
1093 * @return {number} Returns the innerHeight/Width of el by subtracting padding and borders
1094 */
1095, cssSize = function (pane, outerSize) {
1096 var fn = _c[pane].dir=="horz" ? cssH : cssW;
1097 return fn($Ps[pane], outerSize);
1098 }
1099
1100 /**
1101 * @param {string} pane Can accept ONLY a 'pane' (east, west, etc)
1102 * @return {Object} Returns hash of minWidth & minHeight
1103 */
1104, cssMinDims = function (pane) {
1105 // minWidth/Height means CSS width/height = 1px
1106 var $P = $Ps[pane]
1107 , dir = _c[pane].dir
1108 , d = {
1109 minWidth: 1001 - cssW($P, 1000)
1110 , minHeight: 1001 - cssH($P, 1000)
1111 }
1112 ;
1113 if (dir === "horz") d.minSize = d.minHeight;
1114 if (dir === "vert") d.minSize = d.minWidth;
1115 return d;
1116 }
1117
1118 // TODO: see if these methods can be made more useful...
1119 // TODO: *maybe* return cssW/H from these so caller can use this info
1120
1121 /**
1122 * @param {(string|!Object)} el
1123 * @param {number=} outerWidth
1124 * @param {boolean=} [autoHide=false]
1125 */
1126, setOuterWidth = function (el, outerWidth, autoHide) {
1127 var $E = el, w;
1128 if (isStr(el)) $E = $Ps[el]; // west
1129 else if (!el.jquery) $E = $(el);
1130 w = cssW($E, outerWidth);
1131 $E.css({ width: w });
1132 if (w > 0) {
1133 if (autoHide && $E.data('autoHidden') && $E.innerHeight() > 0) {
1134 $E.show().data('autoHidden', false);
1135 if (!browser.mozilla) // FireFox refreshes iframes - IE does not
1136 // make hidden, then visible to 'refresh' display after animation
1137 $E.css(_c.hidden).css(_c.visible);
1138 }
1139 }
1140 else if (autoHide && !$E.data('autoHidden'))
1141 $E.hide().data('autoHidden', true);
1142 }
1143
1144 /**
1145 * @param {(string|!Object)} el
1146 * @param {number=} outerHeight
1147 * @param {boolean=} [autoHide=false]
1148 */
1149, setOuterHeight = function (el, outerHeight, autoHide) {
1150 var $E = el, h;
1151 if (isStr(el)) $E = $Ps[el]; // west
1152 else if (!el.jquery) $E = $(el);
1153 h = cssH($E, outerHeight);
1154 $E.css({ height: h, visibility: "visible" }); // may have been 'hidden' by sizeContent
1155 if (h > 0 && $E.innerWidth() > 0) {
1156 if (autoHide && $E.data('autoHidden')) {
1157 $E.show().data('autoHidden', false);
1158 if (!browser.mozilla) // FireFox refreshes iframes - IE does not
1159 $E.css(_c.hidden).css(_c.visible);
1160 }
1161 }
1162 else if (autoHide && !$E.data('autoHidden'))
1163 $E.hide().data('autoHidden', true);
1164 }
1165
1166 /**
1167 * @param {(string|!Object)} el
1168 * @param {number=} outerSize
1169 * @param {boolean=} [autoHide=false]
1170 */
1171, setOuterSize = function (el, outerSize, autoHide) {
1172 if (_c[pane].dir=="horz") // pane = north or south
1173 setOuterHeight(el, outerSize, autoHide);
1174 else // pane = east or west
1175 setOuterWidth(el, outerSize, autoHide);
1176 }
1177
1178
1179 /**
1180 * Converts any 'size' params to a pixel/integer size, if not already
1181 * If 'auto' or a decimal/percentage is passed as 'size', a pixel-size is calculated
1182 *
1183 /**
1184 * @param {string} pane
1185 * @param {(string|number)=} size
1186 * @param {string=} [dir]
1187 * @return {number}
1188 */
1189, _parseSize = function (pane, size, dir) {
1190 if (!dir) dir = _c[pane].dir;
1191
1192 if (isStr(size) && size.match(/%/))
1193 size = (size === '100%') ? -1 : parseInt(size, 10) / 100; // convert % to decimal
1194
1195 if (size === 0)
1196 return 0;
1197 else if (size >= 1)
1198 return parseInt(size, 10);
1199
1200 var o = options, avail = 0;
1201 if (dir=="horz") // north or south or center.minHeight
1202 avail = sC.innerHeight - ($Ps.north ? o.north.spacing_open : 0) - ($Ps.south ? o.south.spacing_open : 0);
1203 else if (dir=="vert") // east or west or center.minWidth
1204 avail = sC.innerWidth - ($Ps.west ? o.west.spacing_open : 0) - ($Ps.east ? o.east.spacing_open : 0);
1205
1206 if (size === -1) // -1 == 100%
1207 return avail;
1208 else if (size > 0) // percentage, eg: .25
1209 return round(avail * size);
1210 else if (pane=="center")
1211 return 0;
1212 else { // size < 0 || size=='auto' || size==Missing || size==Invalid
1213 // auto-size the pane
1214 var dim = (dir === "horz" ? "height" : "width")
1215 , $P = $Ps[pane]
1216 , $C = dim === 'height' ? $Cs[pane] : false
1217 , vis = $.layout.showInvisibly($P) // show pane invisibly if hidden
1218 , szP = $P.css(dim) // SAVE current pane size
1219 , szC = $C ? $C.css(dim) : 0 // SAVE current content size
1220 ;
1221 $P.css(dim, "auto");
1222 if ($C) $C.css(dim, "auto");
1223 size = (dim === "height") ? $P.outerHeight() : $P.outerWidth(); // MEASURE
1224 $P.css(dim, szP).css(vis); // RESET size & visibility
1225 if ($C) $C.css(dim, szC);
1226 return size;
1227 }
1228 }
1229
1230 /**
1231 * Calculates current 'size' (outer-width or outer-height) of a border-pane - optionally with 'pane-spacing' added
1232 *
1233 * @param {(string|!Object)} pane
1234 * @param {boolean=} [inclSpace=false]
1235 * @return {number} Returns EITHER Width for east/west panes OR Height for north/south panes - adjusted for boxModel & browser
1236 */
1237, getPaneSize = function (pane, inclSpace) {
1238 var
1239 $P = $Ps[pane]
1240 , o = options[pane]
1241 , s = state[pane]
1242 , oSp = (inclSpace ? o.spacing_open : 0)
1243 , cSp = (inclSpace ? o.spacing_closed : 0)
1244 ;
1245 if (!$P || s.isHidden)
1246 return 0;
1247 else if (s.isClosed || (s.isSliding && inclSpace))
1248 return cSp;
1249 else if (_c[pane].dir === "horz")
1250 return $P.outerHeight() + oSp;
1251 else // dir === "vert"
1252 return $P.outerWidth() + oSp;
1253 }
1254
1255 /**
1256 * Calculate min/max pane dimensions and limits for resizing
1257 *
1258 * @param {string} pane
1259 * @param {boolean=} [slide=false]
1260 */
1261, setSizeLimits = function (pane, slide) {
1262 if (!isInitialized()) return;
1263 var
1264 o = options[pane]
1265 , s = state[pane]
1266 , c = _c[pane]
1267 , dir = c.dir
1268 , side = c.side.toLowerCase()
1269 , type = c.sizeType.toLowerCase()
1270 , isSliding = (slide != undefined ? slide : s.isSliding) // only open() passes 'slide' param
1271 , $P = $Ps[pane]
1272 , paneSpacing = o.spacing_open
1273 // measure the pane on the *opposite side* from this pane
1274 , altPane = _c.oppositeEdge[pane]
1275 , altS = state[altPane]
1276 , $altP = $Ps[altPane]
1277 , altPaneSize = (!$altP || altS.isVisible===false || altS.isSliding ? 0 : (dir=="horz" ? $altP.outerHeight() : $altP.outerWidth()))
1278 , altPaneSpacing = ((!$altP || altS.isHidden ? 0 : options[altPane][ altS.isClosed !== false ? "spacing_closed" : "spacing_open" ]) || 0)
1279 // limitSize prevents this pane from 'overlapping' opposite pane
1280 , containerSize = (dir=="horz" ? sC.innerHeight : sC.innerWidth)
1281 , minCenterDims = cssMinDims("center")
1282 , minCenterSize = dir=="horz" ? max(options.center.minHeight, minCenterDims.minHeight) : max(options.center.minWidth, minCenterDims.minWidth)
1283 // if pane is 'sliding', then ignore center and alt-pane sizes - because 'overlays' them
1284 , limitSize = (containerSize - paneSpacing - (isSliding ? 0 : (_parseSize("center", minCenterSize, dir) + altPaneSize + altPaneSpacing)))
1285 , minSize = s.minSize = max( _parseSize(pane, o.minSize), cssMinDims(pane).minSize )
1286 , maxSize = s.maxSize = min( (o.maxSize ? _parseSize(pane, o.maxSize) : 100000), limitSize )
1287 , r = s.resizerPosition = {} // used to set resizing limits
1288 , top = sC.insetTop
1289 , left = sC.insetLeft
1290 , W = sC.innerWidth
1291 , H = sC.innerHeight
1292 , rW = o.spacing_open // subtract resizer-width to get top/left position for south/east
1293 ;
1294 switch (pane) {
1295 case "north": r.min = top + minSize;
1296 r.max = top + maxSize;
1297 break;
1298 case "west": r.min = left + minSize;
1299 r.max = left + maxSize;
1300 break;
1301 case "south": r.min = top + H - maxSize - rW;
1302 r.max = top + H - minSize - rW;
1303 break;
1304 case "east": r.min = left + W - maxSize - rW;
1305 r.max = left + W - minSize - rW;
1306 break;
1307 };
1308 }
1309
1310 /**
1311 * Returns data for setting the size/position of center pane. Also used to set Height for east/west panes
1312 *
1313 * @return JSON Returns a hash of all dimensions: top, bottom, left, right, (outer) width and (outer) height
1314 */
1315, calcNewCenterPaneDims = function () {
1316 var d = {
1317 top: getPaneSize("north", true) // true = include 'spacing' value for pane
1318 , bottom: getPaneSize("south", true)
1319 , left: getPaneSize("west", true)
1320 , right: getPaneSize("east", true)
1321 , width: 0
1322 , height: 0
1323 };
1324
1325 // NOTE: sC = state.container
1326 // calc center-pane outer dimensions
1327 d.width = sC.innerWidth - d.left - d.right; // outerWidth
1328 d.height = sC.innerHeight - d.bottom - d.top; // outerHeight
1329 // add the 'container border/padding' to get final positions relative to the container
1330 d.top += sC.insetTop;
1331 d.bottom += sC.insetBottom;
1332 d.left += sC.insetLeft;
1333 d.right += sC.insetRight;
1334
1335 return d;
1336 }
1337
1338
1339 /**
1340 * @param {!Object} el
1341 * @param {boolean=} [allStates=false]
1342 */
1343, getHoverClasses = function (el, allStates) {
1344 var
1345 $El = $(el)
1346 , type = $El.data("layoutRole")
1347 , pane = $El.data("layoutEdge")
1348 , o = options[pane]
1349 , root = o[type +"Class"]
1350 , _pane = "-"+ pane // eg: "-west"
1351 , _open = "-open"
1352 , _closed = "-closed"
1353 , _slide = "-sliding"
1354 , _hover = "-hover " // NOTE the trailing space
1355 , _state = $El.hasClass(root+_closed) ? _closed : _open
1356 , _alt = _state === _closed ? _open : _closed
1357 , classes = (root+_hover) + (root+_pane+_hover) + (root+_state+_hover) + (root+_pane+_state+_hover)
1358 ;
1359 if (allStates) // when 'removing' classes, also remove alternate-state classes
1360 classes += (root+_alt+_hover) + (root+_pane+_alt+_hover);
1361
1362 if (type=="resizer" && $El.hasClass(root+_slide))
1363 classes += (root+_slide+_hover) + (root+_pane+_slide+_hover);
1364
1365 return $.trim(classes);
1366 }
1367, addHover = function (evt, el) {
1368 var $E = $(el || this);
1369 if (evt && $E.data("layoutRole") === "toggler")
1370 evt.stopPropagation(); // prevent triggering 'slide' on Resizer-bar
1371 $E.addClass( getHoverClasses($E) );
1372 }
1373, removeHover = function (evt, el) {
1374 var $E = $(el || this);
1375 $E.removeClass( getHoverClasses($E, true) );
1376 }
1377
1378, onResizerEnter = function (evt) { // ALSO called by toggler.mouseenter
1379 if ($.fn.disableSelection)
1380 $("body").disableSelection();
1381 }
1382, onResizerLeave = function (evt, el) {
1383 var
1384 e = el || this // el is only passed when called by the timer
1385 , pane = $(e).data("layoutEdge")
1386 , name = pane +"ResizerLeave"
1387 ;
1388 timer.clear(pane+"_openSlider"); // cancel slideOpen timer, if set
1389 timer.clear(name); // cancel enableSelection timer - may re/set below
1390 // this method calls itself on a timer because it needs to allow
1391 // enough time for dragging to kick-in and set the isResizing flag
1392 // dragging has a 100ms delay set, so this delay must be >100
1393 if (!el) // 1st call - mouseleave event
1394 timer.set(name, function(){ onResizerLeave(evt, e); }, 200);
1395 // if user is resizing, then dragStop will enableSelection(), so can skip it here
1396 else if (!state[pane].isResizing && $.fn.enableSelection) // 2nd call - by timer
1397 $("body").enableSelection();
1398 }
1399
1400/*
1401 * ###########################
1402 * INITIALIZATION METHODS
1403 * ###########################
1404 */
1405
1406 /**
1407 * Initialize the layout - called automatically whenever an instance of layout is created
1408 *
1409 * @see none - triggered onInit
1410 * @return mixed true = fully initialized | false = panes not initialized (yet) | 'cancel' = abort
1411 */
1412, _create = function () {
1413 // initialize config/options
1414 initOptions();
1415 var o = options;
1416
1417 // TEMP state so isInitialized returns true during init process
1418 state.creatingLayout = true;
1419
1420 // init plugins for this layout, if there are any (eg: stateManagement)
1421 runPluginCallbacks( Instance, $.layout.onCreate );
1422
1423 // options & state have been initialized, so now run beforeLoad callback
1424 // onload will CANCEL layout creation if it returns false
1425 if (false === _runCallbacks("onload_start"))
1426 return 'cancel';
1427
1428 // initialize the container element
1429 _initContainer();
1430
1431 // bind hotkey function - keyDown - if required
1432 initHotkeys();
1433
1434 // bind window.onunload
1435 $(window).bind("unload."+ sID, unload);
1436
1437 // init plugins for this layout, if there are any (eg: customButtons)
1438 runPluginCallbacks( Instance, $.layout.onLoad );
1439
1440 // if layout elements are hidden, then layout WILL NOT complete initialization!
1441 // initLayoutElements will set initialized=true and run the onload callback IF successful
1442 if (o.initPanes) _initLayoutElements();
1443
1444 delete state.creatingLayout;
1445
1446 return state.initialized;
1447 }
1448
1449 /**
1450 * Initialize the layout IF not already
1451 *
1452 * @see All methods in Instance run this test
1453 * @return boolean true = layoutElements have been initialized | false = panes are not initialized (yet)
1454 */
1455, isInitialized = function () {
1456 if (state.initialized || state.creatingLayout) return true; // already initialized
1457 else return _initLayoutElements(); // try to init panes NOW
1458 }
1459
1460 /**
1461 * Initialize the layout - called automatically whenever an instance of layout is created
1462 *
1463 * @see _create() & isInitialized
1464 * @return An object pointer to the instance created
1465 */
1466, _initLayoutElements = function (retry) {
1467 // initialize config/options
1468 var o = options;
1469
1470 // CANNOT init panes inside a hidden container!
1471 if (!$N.is(":visible")) {
1472 // handle Chrome bug where popup window 'has no height'
1473 // if layout is BODY element, try again in 50ms
1474 // SEE: http://layout.jquery-dev.net/samples/test_popup_window.html
1475 if ( !retry && browser.webkit && $N[0].tagName === "BODY" )
1476 setTimeout(function(){ _initLayoutElements(true); }, 50);
1477 return false;
1478 }
1479
1480 // a center pane is required, so make sure it exists
1481 if (!getPane("center").length) {
1482 if (options.showErrorMessages)
1483 _log( lang.errCenterPaneMissing, true );
1484 return false;
1485 }
1486
1487 // TEMP state so isInitialized returns true during init process
1488 state.creatingLayout = true;
1489
1490 // update Container dims
1491 $.extend(sC, elDims( $N ));
1492
1493 // initialize all layout elements
1494 initPanes(); // size & position panes - calls initHandles() - which calls initResizable()
1495
1496 if (o.scrollToBookmarkOnLoad) {
1497 var l = self.location;
1498 if (l.hash) l.replace( l.hash ); // scrollTo Bookmark
1499 }
1500
1501 // check to see if this layout 'nested' inside a pane
1502 if (Instance.hasParentLayout)
1503 o.resizeWithWindow = false;
1504 // bind resizeAll() for 'this layout instance' to window.resize event
1505 else if (o.resizeWithWindow)
1506 $(window).bind("resize."+ sID, windowResize);
1507
1508 delete state.creatingLayout;
1509 state.initialized = true;
1510
1511 // init plugins for this layout, if there are any
1512 runPluginCallbacks( Instance, $.layout.onReady );
1513
1514 // now run the onload callback, if exists
1515 _runCallbacks("onload_end");
1516
1517 return true; // elements initialized successfully
1518 }
1519
1520 /**
1521 * Initialize nested layouts - called when _initLayoutElements completes
1522 *
1523 * NOT CURRENTLY USED
1524 *
1525 * @see _initLayoutElements
1526 * @return An object pointer to the instance created
1527 */
1528, _initChildLayouts = function () {
1529 $.each(_c.allPanes, function (idx, pane) {
1530 if (options[pane].initChildLayout)
1531 createChildLayout( pane );
1532 });
1533 }
1534
1535 /**
1536 * Initialize nested layouts for a specific pane - can optionally pass layout-options
1537 *
1538 * @see _initChildLayouts
1539 * @param {string} pane The pane being opened, ie: north, south, east, or west
1540 * @param {Object=} [opts] Layout-options - if passed, will OVERRRIDE options[pane].childOptions
1541 * @return An object pointer to the layout instance created - or null
1542 */
1543, createChildLayout = function (evt_or_pane, opts) {
1544 var pane = evtPane.call(this, evt_or_pane)
1545 , $P = $Ps[pane]
1546 , C = children
1547 ;
1548 if ($P) {
1549 var $C = $Cs[pane]
1550 , o = opts || options[pane].childOptions
1551 , d = "layout"
1552 // determine which element is supposed to be the 'child container'
1553 // if pane has a 'containerSelector' OR a 'content-div', use those instead of the pane
1554 , $Cont = o.containerSelector ? $P.find( o.containerSelector ) : ($C || $P)
1555 , containerFound = $Cont.length
1556 // see if a child-layout ALREADY exists on this element
1557 , child = containerFound ? (C[pane] = $Cont.data(d) || null) : null
1558 ;
1559 // if no layout exists, but childOptions are set, try to create the layout now
1560 if (!child && containerFound && o)
1561 child = C[pane] = $Cont.eq(0).layout(o) || null;
1562 if (child)
1563 child.hasParentLayout = true; // set parent-flag in child
1564 }
1565 Instance[pane].child = C[pane]; // ALWAYS set pane-object pointer, even if null
1566 }
1567
1568, windowResize = function () {
1569 var delay = Number(options.resizeWithWindowDelay);
1570 if (delay < 10) delay = 100; // MUST have a delay!
1571 // resizing uses a delay-loop because the resize event fires repeatly - except in FF, but delay anyway
1572 timer.clear("winResize"); // if already running
1573 timer.set("winResize", function(){
1574 timer.clear("winResize");
1575 timer.clear("winResizeRepeater");
1576 var dims = elDims( $N );
1577 // only trigger resizeAll() if container has changed size
1578 if (dims.innerWidth !== sC.innerWidth || dims.innerHeight !== sC.innerHeight)
1579 resizeAll();
1580 }, delay);
1581 // ALSO set fixed-delay timer, if not already running
1582 if (!timer.data["winResizeRepeater"]) setWindowResizeRepeater();
1583 }
1584
1585, setWindowResizeRepeater = function () {
1586 var delay = Number(options.resizeWithWindowMaxDelay);
1587 if (delay > 0)
1588 timer.set("winResizeRepeater", function(){ setWindowResizeRepeater(); resizeAll(); }, delay);
1589 }
1590
1591, unload = function () {
1592 var o = options;
1593
1594 _runCallbacks("onunload_start");
1595
1596 // trigger plugin callabacks for this layout (eg: stateManagement)
1597 runPluginCallbacks( Instance, $.layout.onUnload );
1598
1599 _runCallbacks("onunload_end");
1600 }
1601
1602 /**
1603 * Validate and initialize container CSS and events
1604 *
1605 * @see _create()
1606 */
1607, _initContainer = function () {
1608 var
1609 N = $N[0]
1610 , tag = sC.tagName = N.tagName
1611 , id = sC.id = N.id
1612 , cls = sC.className = N.className
1613 , o = options
1614 , name = o.name
1615 , fullPage= (tag === "BODY")
1616 , props = "overflow,position,margin,padding,border"
1617 , css = "layoutCSS"
1618 , CSS = {}
1619 , hid = "hidden" // used A LOT!
1620 // see if this container is a 'pane' inside an outer-layout
1621 , parent = $N.data("parentLayout") // parent-layout Instance
1622 , pane = $N.data("layoutEdge") // pane-name in parent-layout
1623 , isChild = parent && pane
1624 ;
1625 // sC -> state.container
1626 sC.selector = $N.selector.split(".slice")[0];
1627 sC.ref = (o.name ? o.name +' layout / ' : '') + tag + (id ? "#"+id : cls ? '.['+cls+']' : ''); // used in messages
1628
1629 $N .data({
1630 layout: Instance
1631 , layoutContainer: sID // FLAG to indicate this is a layout-container - contains unique internal ID
1632 })
1633 .addClass(o.containerClass)
1634 ;
1635 var layoutMethods = {
1636 destroy: ''
1637 , initPanes: ''
1638 , resizeAll: 'resizeAll'
1639 , resize: 'resizeAll'
1640 }
1641 , name;
1642 // loop hash and bind all methods - include layoutID namespacing
1643 for (name in layoutMethods) {
1644 $N.bind("layout"+ name.toLowerCase() +"."+ sID, Instance[ layoutMethods[name] || name ]);
1645 }
1646
1647 // if this container is another layout's 'pane', then set child/parent pointers
1648 if (isChild) {
1649 // update parent flag
1650 Instance.hasParentLayout = true;
1651 // set pointers to THIS child-layout (Instance) in parent-layout
1652 // NOTE: parent.PANE.child is an ALIAS to parent.children.PANE
1653 parent[pane].child = parent.children[pane] = $N.data("layout");
1654 }
1655
1656 // SAVE original container CSS for use in destroy()
1657 if (!$N.data(css)) {
1658 // handle props like overflow different for BODY & HTML - has 'system default' values
1659 if (fullPage) {
1660 CSS = $.extend( elCSS($N, props), {
1661 height: $N.css("height")
1662 , overflow: $N.css("overflow")
1663 , overflowX: $N.css("overflowX")
1664 , overflowY: $N.css("overflowY")
1665 });
1666 // ALSO SAVE <HTML> CSS
1667 var $H = $("html");
1668 $H.data(css, {
1669 height: "auto" // FF would return a fixed px-size!
1670 , overflow: $H.css("overflow")
1671 , overflowX: $H.css("overflowX")
1672 , overflowY: $H.css("overflowY")
1673 });
1674 }
1675 else // handle props normally for non-body elements
1676 CSS = elCSS($N, props+",top,bottom,left,right,width,height,overflow,overflowX,overflowY");
1677
1678 $N.data(css, CSS);
1679 }
1680
1681 try { // format html/body if this is a full page layout
1682 if (fullPage) {
1683 $("html").css({
1684 height: "100%"
1685 , overflow: hid
1686 , overflowX: hid
1687 , overflowY: hid
1688 });
1689 $("body").css({
1690 position: "relative"
1691 , height: "100%"
1692 , overflow: hid
1693 , overflowX: hid
1694 , overflowY: hid
1695 , margin: 0
1696 , padding: 0 // TODO: test whether body-padding could be handled?
1697 , border: "none" // a body-border creates problems because it cannot be measured!
1698 });
1699
1700 // set current layout-container dimensions
1701 $.extend(sC, elDims( $N ));
1702 }
1703 else { // set required CSS for overflow and position
1704 // ENSURE container will not 'scroll'
1705 CSS = { overflow: hid, overflowX: hid, overflowY: hid }
1706 var
1707 p = $N.css("position")
1708 , h = $N.css("height")
1709 ;
1710 // if this is a NESTED layout, then container/outer-pane ALREADY has position and height
1711 if (!isChild) {
1712 if (!p || !p.match(/fixed|absolute|relative/))
1713 CSS.position = "relative"; // container MUST have a 'position'
1714 /*
1715 if (!h || h=="auto")
1716 CSS.height = "100%"; // container MUST have a 'height'
1717 */
1718 }
1719 $N.css( CSS );
1720
1721 // set current layout-container dimensions
1722 if ( $N.is(":visible") ) {
1723 $.extend(sC, elDims( $N ));
1724 if (o.showErrorMessages && sC.innerHeight < 1)
1725 _log( lang.errContainerHeight.replace(/CONTAINER/, sC.ref), true );
1726 }
1727 }
1728 } catch (ex) {}
1729 }
1730
1731 /**
1732 * Bind layout hotkeys - if options enabled
1733 *
1734 * @see _create() and addPane()
1735 * @param {string=} [panes=""] The edge(s) to process
1736 */
1737, initHotkeys = function (panes) {
1738 panes = panes ? panes.split(",") : _c.borderPanes;
1739 // bind keyDown to capture hotkeys, if option enabled for ANY pane
1740 $.each(panes, function (i, pane) {
1741 var o = options[pane];
1742 if (o.enableCursorHotkey || o.customHotkey) {
1743 $(document).bind("keydown."+ sID, keyDown); // only need to bind this ONCE
1744 return false; // BREAK - binding was done
1745 }
1746 });
1747 }
1748
1749 /**
1750 * Build final OPTIONS data
1751 *
1752 * @see _create()
1753 */
1754, initOptions = function () {
1755 var data, d, pane, key, val, i, c, o;
1756
1757 // reprocess user's layout-options to have correct options sub-key structure
1758 opts = $.layout.transformData( opts ); // panes = default subkey
1759
1760 // auto-rename old options for backward compatibility
1761 opts = $.layout.backwardCompatibility.renameAllOptions( opts );
1762
1763 // if user-options has 'panes' key (pane-defaults), process it...
1764 if (!$.isEmptyObject(opts.panes)) {
1765 // REMOVE any pane-defaults that MUST be set per-pane
1766 data = $.layout.optionsMap.noDefault;
1767 for (i=0, c=data.length; i<c; i++) {
1768 key = data[i];
1769 delete opts.panes[key]; // OK if does not exist
1770 }
1771 // REMOVE any layout-options specified under opts.panes
1772 data = $.layout.optionsMap.layout;
1773 for (i=0, c=data.length; i<c; i++) {
1774 key = data[i];
1775 delete opts.panes[key]; // OK if does not exist
1776 }
1777 }
1778
1779 // MOVE any NON-layout-options to opts.panes
1780 data = $.layout.optionsMap.layout;
1781 var rootKeys = $.layout.config.optionRootKeys;
1782 for (key in opts) {
1783 val = opts[key];
1784 if ($.inArray(key, rootKeys) < 0 && $.inArray(key, data) < 0) {
1785 if (!opts.panes[key])
1786 opts.panes[key] = $.isPlainObject(val) ? $.extend(true, {}, val) : val;
1787 delete opts[key]
1788 }
1789 }
1790
1791 // START by updating ALL options from opts
1792 $.extend(true, options, opts);
1793
1794 // CREATE final options (and config) for EACH pane
1795 $.each(_c.allPanes, function (i, pane) {
1796
1797 // apply 'pane-defaults' to CONFIG.[PANE]
1798 _c[pane] = $.extend( true, {}, _c.panes, _c[pane] );
1799
1800 d = options.panes;
1801 o = options[pane];
1802
1803 // center-pane uses SOME keys in defaults.panes branch
1804 if (pane === 'center') {
1805 // ONLY copy keys from opts.panes listed in: $.layout.optionsMap.center
1806 data = $.layout.optionsMap.center; // list of 'center-pane keys'
1807 for (i=0, c=data.length; i<c; i++) { // loop the list...
1808 key = data[i];
1809 // only need to use pane-default if pane-specific value not set
1810 if (!opts.center[key] && (opts.panes[key] || !o[key]))
1811 o[key] = d[key]; // pane-default
1812 }
1813 }
1814 else {
1815 // border-panes use ALL keys in defaults.panes branch
1816 o = options[pane] = $.extend({}, d, o); // re-apply pane-specific opts AFTER pane-defaults
1817 createFxOptions( pane );
1818 // ensure all border-pane-specific base-classes exist
1819 if (!o.resizerClass) o.resizerClass = "ui-layout-resizer";
1820 if (!o.togglerClass) o.togglerClass = "ui-layout-toggler";
1821 }
1822 // ensure we have base pane-class (ALL panes)
1823 if (!o.paneClass) o.paneClass = "ui-layout-pane";
1824 });
1825
1826 // update options.zIndexes if a zIndex-option specified
1827 var zo = opts.zIndex
1828 , z = options.zIndexes;
1829 if (zo > 0) {
1830 z.pane_normal = zo;
1831 z.content_mask = max(zo+1, z.content_mask); // MIN = +1
1832 z.resizer_normal = max(zo+2, z.resizer_normal); // MIN = +2
1833 }
1834
1835 function createFxOptions ( pane ) {
1836 var o = options[pane]
1837 , d = options.panes;
1838 // ensure fxSettings key to avoid errors
1839 if (!o.fxSettings) o.fxSettings = {};
1840 if (!d.fxSettings) d.fxSettings = {};
1841
1842 $.each(["_open","_close","_size"], function (i,n) {
1843 var
1844 sName = "fxName"+ n
1845 , sSpeed = "fxSpeed"+ n
1846 , sSettings = "fxSettings"+ n
1847 // recalculate fxName according to specificity rules
1848 , fxName = o[sName] =
1849 o[sName] // options.west.fxName_open
1850 || d[sName] // options.panes.fxName_open
1851 || o.fxName // options.west.fxName
1852 || d.fxName // options.panes.fxName
1853 || "none" // MEANS $.layout.defaults.panes.fxName == "" || false || null || 0
1854 ;
1855 // validate fxName to ensure is valid effect - MUST have effect-config data in options.effects
1856 if (fxName === "none" || !$.effects || !$.effects[fxName] || !options.effects[fxName])
1857 fxName = o[sName] = "none"; // effect not loaded OR unrecognized fxName
1858
1859 // set vars for effects subkeys to simplify logic
1860 var fx = options.effects[fxName] || {} // effects.slide
1861 , fx_all = fx.all || null // effects.slide.all
1862 , fx_pane = fx[pane] || null // effects.slide.west
1863 ;
1864 // create fxSpeed[_open|_close|_size]
1865 o[sSpeed] =
1866 o[sSpeed] // options.west.fxSpeed_open
1867 || d[sSpeed] // options.west.fxSpeed_open
1868 || o.fxSpeed // options.west.fxSpeed
1869 || d.fxSpeed // options.panes.fxSpeed
1870 || null // DEFAULT - let fxSetting.duration control speed
1871 ;
1872 // create fxSettings[_open|_close|_size]
1873 o[sSettings] = $.extend(
1874 {}
1875 , fx_all // effects.slide.all
1876 , fx_pane // effects.slide.west
1877 , d.fxSettings // options.panes.fxSettings
1878 , o.fxSettings // options.west.fxSettings
1879 , d[sSettings] // options.panes.fxSettings_open
1880 , o[sSettings] // options.west.fxSettings_open
1881 );
1882 });
1883
1884 // DONE creating action-specific-settings for this pane,
1885 // so DELETE generic options - are no longer meaningful
1886 delete o.fxName;
1887 delete o.fxSpeed;
1888 delete o.fxSettings;
1889 }
1890
1891 // DELETE 'panes' key now that we are done - values were copied to EACH pane
1892 delete options.panes;
1893 }
1894
1895 /**
1896 * Initialize module objects, styling, size and position for all panes
1897 *
1898 * @see _initElements()
1899 * @param {string} pane The pane to process
1900 */
1901, getPane = function (pane) {
1902 var sel = options[pane].paneSelector
1903 if (sel.substr(0,1)==="#") // ID selector
1904 // NOTE: elements selected 'by ID' DO NOT have to be 'children'
1905 return $N.find(sel).eq(0);
1906 else { // class or other selector
1907 var $P = $N.children(sel).eq(0);
1908 // look for the pane nested inside a 'form' element
1909 return $P.length ? $P : $N.children("form:first").children(sel).eq(0);
1910 }
1911 }
1912
1913, initPanes = function () {
1914 // NOTE: do north & south FIRST so we can measure their height - do center LAST
1915 $.each(_c.allPanes, function (idx, pane) {
1916 addPane( pane, true );
1917 });
1918
1919 // init the pane-handles NOW in case we have to hide or close the pane below
1920 initHandles();
1921
1922 // now that all panes have been initialized and initially-sized,
1923 // make sure there is really enough space available for each pane
1924 $.each(_c.borderPanes, function (i, pane) {
1925 if ($Ps[pane] && state[pane].isVisible) { // pane is OPEN
1926 setSizeLimits(pane);
1927 makePaneFit(pane); // pane may be Closed, Hidden or Resized by makePaneFit()
1928 }
1929 });
1930 // size center-pane AGAIN in case we 'closed' a border-pane in loop above
1931 sizeMidPanes("center");
1932
1933 // Chrome/Webkit sometimes fires callbacks BEFORE it completes resizing!
1934 // Before RC30.3, there was a 10ms delay here, but that caused layout
1935 // to load asynchrously, which is BAD, so try skipping delay for now
1936
1937 // process pane contents and callbacks, and init/resize child-layout if exists
1938 $.each(_c.allPanes, function (i, pane) {
1939 var o = options[pane];
1940 if ($Ps[pane]) {
1941 if (state[pane].isVisible) { // pane is OPEN
1942 sizeContent(pane);
1943 // trigger pane.onResize if triggerEventsOnLoad = true
1944 if (o.triggerEventsOnLoad)
1945 _runCallbacks("onresize_end", pane);
1946 else // automatic if onresize called, otherwise call it specifically
1947 // resize child - IF inner-layout already exists (created before this layout)
1948 resizeChildLayout(pane);
1949 }
1950 // init childLayout - even if pane is not visible
1951 if (o.initChildLayout && o.childOptions)
1952 createChildLayout(pane);
1953 }
1954 });
1955 }
1956
1957 /**
1958 * Add a pane to the layout - subroutine of initPanes()
1959 *
1960 * @see initPanes()
1961 * @param {string} pane The pane to process
1962 * @param {boolean=} [force=false] Size content after init
1963 */
1964, addPane = function (pane, force) {
1965 if (!force && !isInitialized()) return;
1966 var
1967 o = options[pane]
1968 , s = state[pane]
1969 , c = _c[pane]
1970 , fx = s.fx
1971 , dir = c.dir
1972 , spacing = o.spacing_open || 0
1973 , isCenter = (pane === "center")
1974 , CSS = {}
1975 , $P = $Ps[pane]
1976 , size, minSize, maxSize
1977 ;
1978 // if pane-pointer already exists, remove the old one first
1979 if ($P)
1980 removePane( pane, false, true, false );
1981 else
1982 $Cs[pane] = false; // init
1983
1984 $P = $Ps[pane] = getPane(pane);
1985 if (!$P.length) {
1986 $Ps[pane] = false; // logic
1987 return;
1988 }
1989
1990 // SAVE original Pane CSS
1991 if (!$P.data("layoutCSS")) {
1992 var props = "position,top,left,bottom,right,width,height,overflow,zIndex,display,backgroundColor,padding,margin,border";
1993 $P.data("layoutCSS", elCSS($P, props));
1994 }
1995
1996 // create alias for pane data in Instance - initHandles will add more
1997 Instance[pane] = { name: pane, pane: $Ps[pane], content: $Cs[pane], options: options[pane], state: state[pane], child: children[pane] };
1998
1999 // add classes, attributes & events
2000 $P .data({
2001 parentLayout: Instance // pointer to Layout Instance
2002 , layoutPane: Instance[pane] // NEW pointer to pane-alias-object
2003 , layoutEdge: pane
2004 , layoutRole: "pane"
2005 })
2006 .css(c.cssReq).css("zIndex", options.zIndexes.pane_normal)
2007 .css(o.applyDemoStyles ? c.cssDemo : {}) // demo styles
2008 .addClass( o.paneClass +" "+ o.paneClass+"-"+pane ) // default = "ui-layout-pane ui-layout-pane-west" - may be a dupe of 'paneSelector'
2009 .bind("mouseenter."+ sID, addHover )
2010 .bind("mouseleave."+ sID, removeHover )
2011 ;
2012 var paneMethods = {
2013 hide: ''
2014 , show: ''
2015 , toggle: ''
2016 , close: ''
2017 , open: ''
2018 , slideOpen: ''
2019 , slideClose: ''
2020 , slideToggle: ''
2021 , size: 'manualSizePane'
2022 , sizePane: 'manualSizePane'
2023 , sizeContent: ''
2024 , sizeHandles: ''
2025 , enableClosable: ''
2026 , disableClosable: ''
2027 , enableSlideable: ''
2028 , disableSlideable: ''
2029 , enableResizable: ''
2030 , disableResizable: ''
2031 , swapPanes: 'swapPanes'
2032 , swap: 'swapPanes'
2033 , move: 'swapPanes'
2034 , removePane: 'removePane'
2035 , remove: 'removePane'
2036 , createChildLayout: ''
2037 , resizeChildLayout: ''
2038 , resizeAll: 'resizeAll'
2039 , resizeLayout: 'resizeAll'
2040 }
2041 , name;
2042 // loop hash and bind all methods - include layoutID namespacing
2043 for (name in paneMethods) {
2044 $P.bind("layoutpane"+ name.toLowerCase() +"."+ sID, Instance[ paneMethods[name] || name ]);
2045 }
2046
2047 // see if this pane has a 'scrolling-content element'
2048 initContent(pane, false); // false = do NOT sizeContent() - called later
2049
2050 if (!isCenter) {
2051 // call _parseSize AFTER applying pane classes & styles - but before making visible (if hidden)
2052 // if o.size is auto or not valid, then MEASURE the pane and use that as its 'size'
2053 size = s.size = _parseSize(pane, o.size);
2054 minSize = _parseSize(pane,o.minSize) || 1;
2055 maxSize = _parseSize(pane,o.maxSize) || 100000;
2056 if (size > 0) size = max(min(size, maxSize), minSize);
2057
2058 // state for border-panes
2059 s.isClosed = false; // true = pane is closed
2060 s.isSliding = false; // true = pane is currently open by 'sliding' over adjacent panes
2061 s.isResizing= false; // true = pane is in process of being resized
2062 s.isHidden = false; // true = pane is hidden - no spacing, resizer or toggler is visible!
2063
2064 // array for 'pin buttons' whose classNames are auto-updated on pane-open/-close
2065 if (!s.pins) s.pins = [];
2066 }
2067 // states common to ALL panes
2068 s.tagName = $P[0].tagName;
2069 s.edge = pane; // useful if pane is (or about to be) 'swapped' - easy find out where it is (or is going)
2070 s.noRoom = false; // true = pane 'automatically' hidden due to insufficient room - will unhide automatically
2071 s.isVisible = true; // false = pane is invisible - closed OR hidden - simplify logic
2072
2073 // set css-position to account for container borders & padding
2074 switch (pane) {
2075 case "north": CSS.top = sC.insetTop;
2076 CSS.left = sC.insetLeft;
2077 CSS.right = sC.insetRight;
2078 break;
2079 case "south": CSS.bottom = sC.insetBottom;
2080 CSS.left = sC.insetLeft;
2081 CSS.right = sC.insetRight;
2082 break;
2083 case "west": CSS.left = sC.insetLeft; // top, bottom & height set by sizeMidPanes()
2084 break;
2085 case "east": CSS.right = sC.insetRight; // ditto
2086 break;
2087 case "center": // top, left, width & height set by sizeMidPanes()
2088 }
2089
2090 if (dir === "horz") // north or south pane
2091 CSS.height = cssH($P, size);
2092 else if (dir === "vert") // east or west pane
2093 CSS.width = cssW($P, size);
2094 //else if (isCenter) {}
2095
2096 $P.css(CSS); // apply size -- top, bottom & height will be set by sizeMidPanes
2097 if (dir != "horz") sizeMidPanes(pane, true); // true = skipCallback
2098
2099 // close or hide the pane if specified in settings
2100 if (o.initClosed && o.closable && !o.initHidden)
2101 close(pane, true, true); // true, true = force, noAnimation
2102 else if (o.initHidden || o.initClosed)
2103 hide(pane); // will be completely invisible - no resizer or spacing
2104 else if (!s.noRoom)
2105 // make the pane visible - in case was initially hidden
2106 $P.css("display","block");
2107 // ELSE setAsOpen() - called later by initHandles()
2108
2109 // RESET visibility now - pane will appear IF display:block
2110 $P.css("visibility","visible");
2111
2112 // check option for auto-handling of pop-ups & drop-downs
2113 if (o.showOverflowOnHover)
2114 $P.hover( allowOverflow, resetOverflow );
2115
2116 // if manually adding a pane AFTER layout initialization, then...
2117 if (state.initialized) {
2118 initHandles( pane );
2119 initHotkeys( pane );
2120 resizeAll(); // will sizeContent if pane is visible
2121 if (s.isVisible) { // pane is OPEN
2122 if (o.triggerEventsOnLoad)
2123 _runCallbacks("onresize_end", pane);
2124 else // automatic if onresize called, otherwise call it specifically
2125 // resize child - IF inner-layout already exists (created before this layout)
2126 resizeChildLayout(pane); // a previously existing childLayout
2127 }
2128 if (o.initChildLayout && o.childOptions)
2129 createChildLayout(pane);
2130 }
2131 }
2132
2133 /**
2134 * Initialize module objects, styling, size and position for all resize bars and toggler buttons
2135 *
2136 * @see _create()
2137 * @param {string=} [panes=""] The edge(s) to process
2138 */
2139, initHandles = function (panes) {
2140 panes = panes ? panes.split(",") : _c.borderPanes;
2141
2142 // create toggler DIVs for each pane, and set object pointers for them, eg: $R.north = north toggler DIV
2143 $.each(panes, function (i, pane) {
2144 var $P = $Ps[pane];
2145 $Rs[pane] = false; // INIT
2146 $Ts[pane] = false;
2147 if (!$P) return; // pane does not exist - skip
2148
2149 var
2150 o = options[pane]
2151 , s = state[pane]
2152 , c = _c[pane]
2153 , rClass = o.resizerClass
2154 , tClass = o.togglerClass
2155 , side = c.side.toLowerCase()
2156 , spacing = (s.isVisible ? o.spacing_open : o.spacing_closed)
2157 , _pane = "-"+ pane // used for classNames
2158 , _state = (s.isVisible ? "-open" : "-closed") // used for classNames
2159 , I = Instance[pane]
2160 // INIT RESIZER BAR
2161 , $R = I.resizer = $Rs[pane] = $("<div></div>")
2162 // INIT TOGGLER BUTTON
2163 , $T = I.toggler = (o.closable ? $Ts[pane] = $("<div></div>") : false)
2164 ;
2165
2166 //if (s.isVisible && o.resizable) ... handled by initResizable
2167 if (!s.isVisible && o.slidable)
2168 $R.attr("title", o.sliderTip).css("cursor", o.sliderCursor);
2169
2170 $R // if paneSelector is an ID, then create a matching ID for the resizer, eg: "#paneLeft" => "paneLeft-resizer"
2171 .attr("id", (o.paneSelector.substr(0,1)=="#" ? o.paneSelector.substr(1) + "-resizer" : ""))
2172 .data({
2173 parentLayout: Instance
2174 , layoutPane: Instance[pane] // NEW pointer to pane-alias-object
2175 , layoutEdge: pane
2176 , layoutRole: "resizer"
2177 })
2178 .css(_c.resizers.cssReq).css("zIndex", options.zIndexes.resizer_normal)
2179 .css(o.applyDemoStyles ? _c.resizers.cssDemo : {}) // add demo styles
2180 .addClass(rClass +" "+ rClass+_pane)
2181 .hover(addHover, removeHover) // ALWAYS add hover-classes, even if resizing is not enabled - handle with CSS instead
2182 .hover(onResizerEnter, onResizerLeave) // ALWAYS NEED resizer.mouseleave to balance toggler.mouseenter
2183 .appendTo($N) // append DIV to container
2184 ;
2185
2186 if ($T) {
2187 $T // if paneSelector is an ID, then create a matching ID for the resizer, eg: "#paneLeft" => "#paneLeft-toggler"
2188 .attr("id", (o.paneSelector.substr(0,1)=="#" ? o.paneSelector.substr(1) + "-toggler" : ""))
2189 .data({
2190 parentLayout: Instance
2191 , layoutPane: Instance[pane] // NEW pointer to pane-alias-object
2192 , layoutEdge: pane
2193 , layoutRole: "toggler"
2194 })
2195 .css(_c.togglers.cssReq) // add base/required styles
2196 .css(o.applyDemoStyles ? _c.togglers.cssDemo : {}) // add demo styles
2197 .addClass(tClass +" "+ tClass+_pane)
2198 .hover(addHover, removeHover) // ALWAYS add hover-classes, even if toggling is not enabled - handle with CSS instead
2199 .bind("mouseenter", onResizerEnter) // NEED toggler.mouseenter because mouseenter MAY NOT fire on resizer
2200 .appendTo($R) // append SPAN to resizer DIV
2201 ;
2202 // ADD INNER-SPANS TO TOGGLER
2203 if (o.togglerContent_open) // ui-layout-open
2204 $("<span>"+ o.togglerContent_open +"</span>")
2205 .data({
2206 layoutEdge: pane
2207 , layoutRole: "togglerContent"
2208 })
2209 .data("layoutRole", "togglerContent")
2210 .data("layoutEdge", pane)
2211 .addClass("content content-open")
2212 .css("display","none")
2213 .appendTo( $T )
2214 //.hover( addHover, removeHover ) // use ui-layout-toggler-west-hover .content-open instead!
2215 ;
2216 if (o.togglerContent_closed) // ui-layout-closed
2217 $("<span>"+ o.togglerContent_closed +"</span>")
2218 .data({
2219 layoutEdge: pane
2220 , layoutRole: "togglerContent"
2221 })
2222 .addClass("content content-closed")
2223 .css("display","none")
2224 .appendTo( $T )
2225 //.hover( addHover, removeHover ) // use ui-layout-toggler-west-hover .content-closed instead!
2226 ;
2227 // ADD TOGGLER.click/.hover
2228 enableClosable(pane);
2229 }
2230
2231 // add Draggable events
2232 initResizable(pane);
2233
2234 // ADD CLASSNAMES & SLIDE-BINDINGS - eg: class="resizer resizer-west resizer-open"
2235 if (s.isVisible)
2236 setAsOpen(pane); // onOpen will be called, but NOT onResize
2237 else {
2238 setAsClosed(pane); // onClose will be called
2239 bindStartSlidingEvent(pane, true); // will enable events IF option is set
2240 }
2241
2242 });
2243
2244 // SET ALL HANDLE DIMENSIONS
2245 sizeHandles();
2246 }
2247
2248
2249 /**
2250 * Initialize scrolling ui-layout-content div - if exists
2251 *
2252 * @see initPane() - or externally after an Ajax injection
2253 * @param {string} [pane] The pane to process
2254 * @param {boolean=} [resize=true] Size content after init
2255 */
2256, initContent = function (pane, resize) {
2257 if (!isInitialized()) return;
2258 var
2259 o = options[pane]
2260 , sel = o.contentSelector
2261 , I = Instance[pane]
2262 , $P = $Ps[pane]
2263 , $C
2264 ;
2265 if (sel) $C = I.content = $Cs[pane] = (o.findNestedContent)
2266 ? $P.find(sel).eq(0) // match 1-element only
2267 : $P.children(sel).eq(0)
2268 ;
2269 if ($C && $C.length) {
2270 $C.data("layoutRole", "content");
2271 // SAVE original Pane CSS
2272 if (!$C.data("layoutCSS"))
2273 $C.data("layoutCSS", elCSS($C, "height"));
2274 $C.css( _c.content.cssReq );
2275 if (o.applyDemoStyles) {
2276 $C.css( _c.content.cssDemo ); // add padding & overflow: auto to content-div
2277 $P.css( _c.content.cssDemoPane ); // REMOVE padding/scrolling from pane
2278 }
2279 state[pane].content = {}; // init content state
2280 if (resize !== false) sizeContent(pane);
2281 // sizeContent() is called AFTER init of all elements
2282 }
2283 else
2284 I.content = $Cs[pane] = false;
2285 }
2286
2287
2288 /**
2289 * Add resize-bars to all panes that specify it in options
2290 * -dependancy: $.fn.resizable - will skip if not found
2291 *
2292 * @see _create()
2293 * @param {string=} [panes=""] The edge(s) to process
2294 */
2295, initResizable = function (panes) {
2296 var draggingAvailable = $.layout.plugins.draggable
2297 , side // set in start()
2298 ;
2299 panes = panes ? panes.split(",") : _c.borderPanes;
2300
2301 $.each(panes, function (idx, pane) {
2302 var o = options[pane];
2303 if (!draggingAvailable || !$Ps[pane] || !o.resizable) {
2304 o.resizable = false;
2305 return true; // skip to next
2306 }
2307
2308 var s = state[pane]
2309 , z = options.zIndexes
2310 , c = _c[pane]
2311 , side = c.dir=="horz" ? "top" : "left"
2312 , opEdge = _c.oppositeEdge[pane]
2313 , masks = pane +",center,"+ opEdge + (c.dir=="horz" ? ",west,east" : "")
2314 , $P = $Ps[pane]
2315 , $R = $Rs[pane]
2316 , base = o.resizerClass
2317 , lastPos = 0 // used when live-resizing
2318 , r, live // set in start because may change
2319 // 'drag' classes are applied to the ORIGINAL resizer-bar while dragging is in process
2320 , resizerClass = base+"-drag" // resizer-drag
2321 , resizerPaneClass = base+"-"+pane+"-drag" // resizer-north-drag
2322 // 'helper' class is applied to the CLONED resizer-bar while it is being dragged
2323 , helperClass = base+"-dragging" // resizer-dragging
2324 , helperPaneClass = base+"-"+pane+"-dragging" // resizer-north-dragging
2325 , helperLimitClass = base+"-dragging-limit" // resizer-drag
2326 , helperPaneLimitClass = base+"-"+pane+"-dragging-limit" // resizer-north-drag
2327 , helperClassesSet = false // logic var
2328 ;
2329
2330 if (!s.isClosed)
2331 $R.attr("title", o.resizerTip)
2332 .css("cursor", o.resizerCursor); // n-resize, s-resize, etc
2333
2334 $R.draggable({
2335 containment: $N[0] // limit resizing to layout container
2336 , axis: (c.dir=="horz" ? "y" : "x") // limit resizing to horz or vert axis
2337 , delay: 0
2338 , distance: 1
2339 , grid: o.resizingGrid
2340 // basic format for helper - style it using class: .ui-draggable-dragging
2341 , helper: "clone"
2342 , opacity: o.resizerDragOpacity
2343 , addClasses: false // avoid ui-state-disabled class when disabled
2344 //, iframeFix: o.draggableIframeFix // TODO: consider using when bug is fixed
2345 , zIndex: z.resizer_drag
2346
2347 , start: function (e, ui) {
2348 // REFRESH options & state pointers in case we used swapPanes
2349 o = options[pane];
2350 s = state[pane];
2351 // re-read options
2352 live = o.livePaneResizing;
2353
2354 // ondrag_start callback - will CANCEL hide if returns false
2355 // TODO: dragging CANNOT be cancelled like this, so see if there is a way?
2356 if (false === _runCallbacks("ondrag_start", pane)) return false;
2357
2358 s.isResizing = true; // prevent pane from closing while resizing
2359 timer.clear(pane+"_closeSlider"); // just in case already triggered
2360
2361 // SET RESIZER LIMITS - used in drag()
2362 setSizeLimits(pane); // update pane/resizer state
2363 r = s.resizerPosition;
2364 lastPos = ui.position[ side ]
2365
2366 $R.addClass( resizerClass +" "+ resizerPaneClass ); // add drag classes
2367 helperClassesSet = false; // reset logic var - see drag()
2368
2369 // DISABLE TEXT SELECTION (probably already done by resizer.mouseOver)
2370 $('body').disableSelection();
2371
2372 // MASK PANES CONTAINING IFRAMES, APPLETS OR OTHER TROUBLESOME ELEMENTS
2373 showMasks( masks );
2374 }
2375
2376 , drag: function (e, ui) {
2377 if (!helperClassesSet) { // can only add classes after clone has been added to the DOM
2378 //$(".ui-draggable-dragging")
2379 ui.helper
2380 .addClass( helperClass +" "+ helperPaneClass ) // add helper classes
2381 .css({ right: "auto", bottom: "auto" }) // fix dir="rtl" issue
2382 .children().css("visibility","hidden") // hide toggler inside dragged resizer-bar
2383 ;
2384 helperClassesSet = true;
2385 // draggable bug!? RE-SET zIndex to prevent E/W resize-bar showing through N/S pane!
2386 if (s.isSliding) $Ps[pane].css("zIndex", z.pane_sliding);
2387 }
2388 // CONTAIN RESIZER-BAR TO RESIZING LIMITS
2389 var limit = 0;
2390 if (ui.position[side] < r.min) {
2391 ui.position[side] = r.min;
2392 limit = -1;
2393 }
2394 else if (ui.position[side] > r.max) {
2395 ui.position[side] = r.max;
2396 limit = 1;
2397 }
2398 // ADD/REMOVE dragging-limit CLASS
2399 if (limit) {
2400 ui.helper.addClass( helperLimitClass +" "+ helperPaneLimitClass ); // at dragging-limit
2401 window.defaultStatus = (limit>0 && pane.match(/north|west/)) || (limit<0 && pane.match(/south|east/)) ? lang.maxSizeWarning : lang.minSizeWarning;
2402 }
2403 else {
2404 ui.helper.removeClass( helperLimitClass +" "+ helperPaneLimitClass ); // not at dragging-limit
2405 window.defaultStatus = "";
2406 }
2407 // DYNAMICALLY RESIZE PANES IF OPTION ENABLED
2408 // won't trigger unless resizer has actually moved!
2409 if (live && Math.abs(ui.position[side] - lastPos) >= o.liveResizingTolerance) {
2410 lastPos = ui.position[side];
2411 resizePanes(e, ui, pane)
2412 }
2413 }
2414
2415 , stop: function (e, ui) {
2416 $('body').enableSelection(); // RE-ENABLE TEXT SELECTION
2417 window.defaultStatus = ""; // clear 'resizing limit' message from statusbar
2418 $R.removeClass( resizerClass +" "+ resizerPaneClass ); // remove drag classes from Resizer
2419 s.isResizing = false;
2420 resizePanes(e, ui, pane, true, masks); // true = resizingDone
2421 }
2422
2423 });
2424 });
2425
2426 /**
2427 * resizePanes
2428 *
2429 * Sub-routine called from stop() - and drag() if livePaneResizing
2430 *
2431 * @param {!Object} evt
2432 * @param {!Object} ui
2433 * @param {string} pane
2434 * @param {boolean=} [resizingDone=false]
2435 */
2436 var resizePanes = function (evt, ui, pane, resizingDone, masks) {
2437 var dragPos = ui.position
2438 , c = _c[pane]
2439 , o = options[pane]
2440 , s = state[pane]
2441 , resizerPos
2442 ;
2443 switch (pane) {
2444 case "north": resizerPos = dragPos.top; break;
2445 case "west": resizerPos = dragPos.left; break;
2446 case "south": resizerPos = sC.offsetHeight - dragPos.top - o.spacing_open; break;
2447 case "east": resizerPos = sC.offsetWidth - dragPos.left - o.spacing_open; break;
2448 };
2449 // remove container margin from resizer position to get the pane size
2450 var newSize = resizerPos - sC["inset"+ c.side];
2451
2452 // Disable OR Resize Mask(s) created in drag.start
2453 if (!resizingDone) {
2454 // ensure we meet liveResizingTolerance criteria
2455 if (Math.abs(newSize - s.size) < o.liveResizingTolerance)
2456 return; // SKIP resize this time
2457 // resize the pane
2458 manualSizePane(pane, newSize, false, true); // true = noAnimation
2459 sizeMasks(); // resize all visible masks
2460 }
2461 else { // resizingDone
2462 // ondrag_end callback
2463 if (false !== _runCallbacks("ondrag_end", pane))
2464 manualSizePane(pane, newSize, false, true); // true = noAnimation
2465 hideMasks(); // hide all masks, which include panes with 'content/iframe-masks'
2466 if (s.isSliding && masks) // RE-SHOW only 'object-masks' so objects won't show through sliding pane
2467 showMasks( masks, true ); // true = onlyForObjects
2468 }
2469 };
2470 }
2471
2472 /**
2473 * sizeMask
2474 *
2475 * Needed to overlay a DIV over an IFRAME-pane because mask CANNOT be *inside* the pane
2476 * Called when mask created, and during livePaneResizing
2477 */
2478, sizeMask = function () {
2479 var $M = $(this)
2480 , pane = $M.data("layoutMask") // eg: "west"
2481 , s = state[pane]
2482 ;
2483 // only masks over an IFRAME-pane need manual resizing
2484 if (s.tagName == "IFRAME" && s.isVisible) // no need to mask closed/hidden panes
2485 $M.css({
2486 top: s.offsetTop
2487 , left: s.offsetLeft
2488 , width: s.outerWidth
2489 , height: s.outerHeight
2490 });
2491 /* ALT Method...
2492 var $P = $Ps[pane];
2493 $M.css( $P.position() ).css({ width: $P[0].offsetWidth, height: $P[0].offsetHeight });
2494 */
2495 }
2496, sizeMasks = function () {
2497 $Ms.each( sizeMask ); // resize all 'visible' masks
2498 }
2499
2500, showMasks = function (panes, onlyForObjects) {
2501 var a = panes ? panes.split(",") : $.layout.config.allPanes
2502 , z = options.zIndexes
2503 , o, s;
2504 $.each(a, function(i,p){
2505 s = state[p];
2506 o = options[p];
2507 if (s.isVisible && ( (!onlyForObjects && o.maskContents) || o.maskObjects )) {
2508 getMasks(p).each(function(){
2509 sizeMask.call(this);
2510 this.style.zIndex = s.isSliding ? z.pane_sliding+1 : z.pane_normal+1
2511 this.style.display = "block";
2512 });
2513 }
2514 });
2515 }
2516
2517, hideMasks = function () {
2518 // ensure no pane is resizing - could be a timing issue
2519 var skip;
2520 $.each( $.layout.config.borderPanes, function(i,p){
2521 if (state[p].isResizing) {
2522 skip = true;
2523 return false; // BREAK
2524 }
2525 });
2526 if (!skip)
2527 $Ms.hide(); // hide ALL masks
2528 }
2529
2530, getMasks = function (pane) {
2531 var $Masks = $([])
2532 , $M, i = 0, c = $Ms.length
2533 ;
2534 for (; i<c; i++) {
2535 $M = $Ms.eq(i);
2536 if ($M.data("layoutMask") === pane)
2537 $Masks = $Masks.add( $M );
2538 }
2539 if ($Masks.length)
2540 return $Masks;
2541 else
2542 return createMasks(pane);
2543 }
2544
2545 /**
2546 * createMasks
2547 *
2548 * Generates both DIV (ALWAYS used) and IFRAME (optional) elements as masks
2549 * An IFRAME mask is created *under* the DIV when maskObjects=true, because a DIV cannot mask an applet
2550 */
2551, createMasks = function (pane) {
2552 var
2553 $P = $Ps[pane]
2554 , s = state[pane]
2555 , o = options[pane]
2556 , z = options.zIndexes
2557 //, objMask = o.maskObjects && s.tagName != "IFRAME" // check for option
2558 , $Masks = $([])
2559 , isIframe, el, $M, css, i
2560 ;
2561 if (!o.maskContents && !o.maskObjects) return $Masks;
2562 // if o.maskObjects=true, then loop TWICE to create BOTH kinds of mask, else only create a DIV
2563 for (i=0; i < (o.maskObjects ? 2 : 1); i++) {
2564 isIframe = o.maskObjects && i==0;
2565 el = document.createElement( isIframe ? "iframe" : "div" );
2566 $M = $(el).data("layoutMask", pane); // add data to relate mask to pane
2567 el.className = "ui-layout-mask ui-layout-mask-"+ pane; // for user styling
2568 css = el.style;
2569 // styles common to both DIVs and IFRAMES
2570 css.display = "block";
2571 css.position = "absolute";
2572 if (isIframe) { // IFRAME-only props
2573 el.frameborder = 0;
2574 el.src = "about:blank";
2575 css.opacity = 0;
2576 css.filter = "Alpha(Opacity='0')";
2577 css.border = 0;
2578 }
2579 // if pane is an IFRAME, then must mask the pane itself
2580 if (s.tagName == "IFRAME") {
2581 // NOTE sizing done by a subroutine so can be called during live-resizing
2582 css.zIndex = z.pane_normal+1; // 1-higher than pane
2583 $N.append( el ); // append to LAYOUT CONTAINER
2584 }
2585 // otherwise put masks *inside the pane* to mask its contents
2586 else {
2587 $M.addClass("ui-layout-mask-inside-pane");
2588 css.zIndex = o.maskZindex || z.content_mask; // usually 1, but customizable
2589 css.top = 0;
2590 css.left = 0;
2591 css.width = "100%";
2592 css.height = "100%";
2593 $P.append( el ); // append INSIDE pane element
2594 }
2595 // add to return object
2596 $Masks = $Masks.add( el );
2597 // add Mask to cached array so can be resized & reused
2598 $Ms = $Ms.add( el );
2599 }
2600 return $Masks;
2601 }
2602
2603
2604 /**
2605 * Destroy this layout and reset all elements
2606 *
2607 * @param {boolean=} [destroyChildren=false] Destory Child-Layouts first?
2608 */
2609, destroy = function (destroyChildren) {
2610 // UNBIND layout events and remove global object
2611 $(window).unbind("."+ sID); // resize & unload
2612 $(document).unbind("."+ sID); // keyDown (hotkeys)
2613
2614 // need to look for parent layout BEFORE we remove the container data, else skips a level
2615 //var parentPane = Instance.hasParentLayout ? $.layout.getParentPaneInstance( $N ) : null;
2616
2617 // reset layout-container
2618 $N .clearQueue()
2619 .removeData("layout")
2620 .removeData("layoutContainer")
2621 .removeClass(options.containerClass)
2622 .unbind("."+ sID) // remove ALL Layout events
2623 ;
2624
2625 // remove all mask elements that have been created
2626 $Ms.remove();
2627
2628 // loop all panes to remove layout classes, attributes and bindings
2629 $.each(_c.allPanes, function (i, pane) {
2630 removePane( pane, false, true, destroyChildren ); // true = skipResize
2631 });
2632
2633 // do NOT reset container CSS if is a 'pane' (or 'content') in an outer-layout - ie, THIS layout is 'nested'
2634 var css = "layoutCSS";
2635 if ($N.data(css) && !$N.data("layoutRole")) // RESET CSS
2636 $N.css( $N.data(css) ).removeData(css);
2637
2638 // for full-page layouts, also reset the <HTML> CSS
2639 if (sC.tagName === "BODY" && ($N = $("html")).data(css)) // RESET <HTML> CSS
2640 $N.css( $N.data(css) ).removeData(css);
2641
2642 // trigger plugins for this layout, if there are any
2643 runPluginCallbacks( Instance, $.layout.onDestroy );
2644
2645 // trigger state-management and onunload callback
2646 unload();
2647
2648 // clear the Instance of everything except for container & options (so could recreate)
2649 // RE-CREATE: myLayout = myLayout.container.layout( myLayout.options );
2650 for (n in Instance)
2651 if (!n.match(/^(container|options)$/)) delete Instance[ n ];
2652 // add a 'destroyed' flag to make it easy to check
2653 Instance.destroyed = true;
2654
2655 // if this is a child layout, CLEAR the child-pointer in the parent
2656 /* for now the pointer REMAINS, but with only container, options and destroyed keys
2657 if (parentPane) {
2658 var layout = parentPane.pane.data("parentLayout");
2659 parentPane.child = layout.children[ parentPane.name ] = null;
2660 }
2661 */
2662
2663 return Instance; // for coding convenience
2664 }
2665
2666 /**
2667 * Remove a pane from the layout - subroutine of destroy()
2668 *
2669 * @see destroy()
2670 * @param {string} pane The pane to process
2671 * @param {boolean=} [remove=false] Remove the DOM element?
2672 * @param {boolean=} [skipResize=false] Skip calling resizeAll()?
2673 */
2674, removePane = function (evt_or_pane, remove, skipResize, destroyChild) {
2675 if (!isInitialized()) return;
2676 var pane = evtPane.call(this, evt_or_pane)
2677 , $P = $Ps[pane]
2678 , $C = $Cs[pane]
2679 , $R = $Rs[pane]
2680 , $T = $Ts[pane]
2681 ;
2682 //alert( '$P.length = '+ $P.length );
2683 // NOTE: elements can still exist even after remove()
2684 // so check for missing data(), which is cleared by removed()
2685 if ($P && $.isEmptyObject( $P.data() )) $P = false;
2686 if ($C && $.isEmptyObject( $C.data() )) $C = false;
2687 if ($R && $.isEmptyObject( $R.data() )) $R = false;
2688 if ($T && $.isEmptyObject( $T.data() )) $T = false;
2689
2690 if ($P) $P.stop(true, true);
2691
2692 // check for a child layout
2693 var o = options[pane]
2694 , s = state[pane]
2695 , d = "layout"
2696 , css = "layoutCSS"
2697 , child = children[pane] || ($P ? $P.data(d) : 0) || ($C ? $C.data(d) : 0) || null
2698 , destroy = destroyChild !== undefined ? destroyChild : o.destroyChildLayout
2699 ;
2700
2701 // FIRST destroy the child-layout(s)
2702 if (destroy && child && !child.destroyed) {
2703 child.destroy(true); // tell child-layout to destroy ALL its child-layouts too
2704 if (child.destroyed) // destroy was successful
2705 child = null; // clear pointer for logic below
2706 }
2707
2708 if ($P && remove && !child)
2709 $P.remove();
2710 else if ($P && $P[0]) {
2711 // create list of ALL pane-classes that need to be removed
2712 var root = o.paneClass // default="ui-layout-pane"
2713 , pRoot = root +"-"+ pane // eg: "ui-layout-pane-west"
2714 , _open = "-open"
2715 , _sliding= "-sliding"
2716 , _closed = "-closed"
2717 , classes = [ root, root+_open, root+_closed, root+_sliding, // generic classes
2718 pRoot, pRoot+_open, pRoot+_closed, pRoot+_sliding ] // pane-specific classes
2719 ;
2720 $.merge(classes, getHoverClasses($P, true)); // ADD hover-classes
2721 // remove all Layout classes from pane-element
2722 $P .removeClass( classes.join(" ") ) // remove ALL pane-classes
2723 .removeData("parentLayout")
2724 .removeData("layoutPane")
2725 .removeData("layoutRole")
2726 .removeData("layoutEdge")
2727 .removeData("autoHidden") // in case set
2728 .unbind("."+ sID) // remove ALL Layout events
2729 // TODO: remove these extra unbind commands when jQuery is fixed
2730 //.unbind("mouseenter"+ sID)
2731 //.unbind("mouseleave"+ sID)
2732 ;
2733 // do NOT reset CSS if this pane/content is STILL the container of a nested layout!
2734 // the nested layout will reset its 'container' CSS when/if it is destroyed
2735 if ($C && $C.data(d)) {
2736 // a content-div may not have a specific width, so give it one to contain the Layout
2737 $C.width( $C.width() );
2738 child.resizeAll(); // now resize the Layout
2739 }
2740 else if ($C)
2741 $C.css( $C.data(css) ).removeData(css).removeData("layoutRole");
2742 // remove pane AFTER content in case there was a nested layout
2743 if (!$P.data(d))
2744 $P.css( $P.data(css) ).removeData(css);
2745 }
2746
2747 // REMOVE pane resizer and toggler elements
2748 if ($T) $T.remove();
2749 if ($R) $R.remove();
2750
2751 // CLEAR all pointers and state data
2752 Instance[pane] = $Ps[pane] = $Cs[pane] = $Rs[pane] = $Ts[pane] = children[pane] = false;
2753 s = { removed: true };
2754
2755 if (!skipResize)
2756 resizeAll();
2757 }
2758
2759
2760/*
2761 * ###########################
2762 * ACTION METHODS
2763 * ###########################
2764 */
2765
2766, _hidePane = function (pane) {
2767 var $P = $Ps[pane]
2768 , o = options[pane]
2769 , s = $P[0].style
2770 ;
2771 if (o.useOffscreenClose) {
2772 if (!$P.data(_c.offscreenReset))
2773 $P.data(_c.offscreenReset, { left: s.left, right: s.right });
2774 $P.css( _c.offscreenCSS );
2775 }
2776 else
2777 $P.hide().removeData(_c.offscreenReset);
2778 }
2779
2780, _showPane = function (pane) {
2781 var $P = $Ps[pane]
2782 , o = options[pane]
2783 , off = _c.offscreenCSS
2784 , old = $P.data(_c.offscreenReset)
2785 , s = $P[0].style
2786 ;
2787 $P .show() // ALWAYS show, just in case
2788 .removeData(_c.offscreenReset);
2789 if (o.useOffscreenClose && old) {
2790 if (s.left == off.left)
2791 s.left = old.left;
2792 if (s.right == off.right)
2793 s.right = old.right;
2794 }
2795 }
2796
2797
2798 /**
2799 * Completely 'hides' a pane, including its spacing - as if it does not exist
2800 * The pane is not actually 'removed' from the source, so can use 'show' to un-hide it
2801 *
2802 * @param {string} pane The pane being hidden, ie: north, south, east, or west
2803 * @param {boolean=} [noAnimation=false]
2804 */
2805, hide = function (evt_or_pane, noAnimation) {
2806 if (!isInitialized()) return;
2807 var pane = evtPane.call(this, evt_or_pane)
2808 , o = options[pane]
2809 , s = state[pane]
2810 , $P = $Ps[pane]
2811 , $R = $Rs[pane]
2812 ;
2813 if (!$P || s.isHidden) return; // pane does not exist OR is already hidden
2814
2815 // onhide_start callback - will CANCEL hide if returns false
2816 if (state.initialized && false === _runCallbacks("onhide_start", pane)) return;
2817
2818 s.isSliding = false; // just in case
2819
2820 // now hide the elements
2821 if ($R) $R.hide(); // hide resizer-bar
2822 if (!state.initialized || s.isClosed) {
2823 s.isClosed = true; // to trigger open-animation on show()
2824 s.isHidden = true;
2825 s.isVisible = false;
2826 if (!state.initialized)
2827 _hidePane(pane); // no animation when loading page
2828 sizeMidPanes(_c[pane].dir === "horz" ? "" : "center");
2829 if (state.initialized || o.triggerEventsOnLoad)
2830 _runCallbacks("onhide_end", pane);
2831 }
2832 else {
2833 s.isHiding = true; // used by onclose
2834 close(pane, false, noAnimation); // adjust all panes to fit
2835 }
2836 }
2837
2838 /**
2839 * Show a hidden pane - show as 'closed' by default unless openPane = true
2840 *
2841 * @param {string} pane The pane being opened, ie: north, south, east, or west
2842 * @param {boolean=} [openPane=false]
2843 * @param {boolean=} [noAnimation=false]
2844 * @param {boolean=} [noAlert=false]
2845 */
2846, show = function (evt_or_pane, openPane, noAnimation, noAlert) {
2847 if (!isInitialized()) return;
2848 var pane = evtPane.call(this, evt_or_pane)
2849 , o = options[pane]
2850 , s = state[pane]
2851 , $P = $Ps[pane]
2852 , $R = $Rs[pane]
2853 ;
2854 if (!$P || !s.isHidden) return; // pane does not exist OR is not hidden
2855
2856 // onshow_start callback - will CANCEL show if returns false
2857 if (false === _runCallbacks("onshow_start", pane)) return;
2858
2859 s.isSliding = false; // just in case
2860 s.isShowing = true; // used by onopen/onclose
2861 //s.isHidden = false; - will be set by open/close - if not cancelled
2862
2863 // now show the elements
2864 //if ($R) $R.show(); - will be shown by open/close
2865 if (openPane === false)
2866 close(pane, true); // true = force
2867 else
2868 open(pane, false, noAnimation, noAlert); // adjust all panes to fit
2869 }
2870
2871
2872 /**
2873 * Toggles a pane open/closed by calling either open or close
2874 *
2875 * @param {string} pane The pane being toggled, ie: north, south, east, or west
2876 * @param {boolean=} [slide=false]
2877 */
2878, toggle = function (evt_or_pane, slide) {
2879 if (!isInitialized()) return;
2880 var evt = evtObj(evt_or_pane)
2881 , pane = evtPane.call(this, evt_or_pane)
2882 , s = state[pane]
2883 ;
2884 if (evt) // called from to $R.dblclick OR triggerPaneEvent
2885 evt.stopImmediatePropagation();
2886 if (s.isHidden)
2887 show(pane); // will call 'open' after unhiding it
2888 else if (s.isClosed)
2889 open(pane, !!slide);
2890 else
2891 close(pane);
2892 }
2893
2894
2895 /**
2896 * Utility method used during init or other auto-processes
2897 *
2898 * @param {string} pane The pane being closed
2899 * @param {boolean=} [setHandles=false]
2900 */
2901, _closePane = function (pane, setHandles) {
2902 var
2903 $P = $Ps[pane]
2904 , s = state[pane]
2905 ;
2906 _hidePane(pane);
2907 s.isClosed = true;
2908 s.isVisible = false;
2909 // UNUSED: if (setHandles) setAsClosed(pane, true); // true = force
2910 }
2911
2912 /**
2913 * Close the specified pane (animation optional), and resize all other panes as needed
2914 *
2915 * @param {string} pane The pane being closed, ie: north, south, east, or west
2916 * @param {boolean=} [force=false]
2917 * @param {boolean=} [noAnimation=false]
2918 * @param {boolean=} [skipCallback=false]
2919 */
2920, close = function (evt_or_pane, force, noAnimation, skipCallback) {
2921 var pane = evtPane.call(this, evt_or_pane);
2922 // if pane has been initialized, but NOT the complete layout, close pane instantly
2923 if (!state.initialized && $Ps[pane]) {
2924 _closePane(pane); // INIT pane as closed
2925 return;
2926 }
2927 if (!isInitialized()) return;
2928
2929 var
2930 $P = $Ps[pane]
2931 , $R = $Rs[pane]
2932 , $T = $Ts[pane]
2933 , o = options[pane]
2934 , s = state[pane]
2935 , c = _c[pane]
2936 , doFX, isShowing, isHiding, wasSliding;
2937
2938 // QUEUE in case another action/animation is in progress
2939 $N.queue(function( queueNext ){
2940
2941 if ( !$P
2942 || (!o.closable && !s.isShowing && !s.isHiding) // invalid request // (!o.resizable && !o.closable) ???
2943 || (!force && s.isClosed && !s.isShowing) // already closed
2944 ) return queueNext();
2945
2946 // onclose_start callback - will CANCEL hide if returns false
2947 // SKIP if just 'showing' a hidden pane as 'closed'
2948 var abort = !s.isShowing && false === _runCallbacks("onclose_start", pane);
2949
2950 // transfer logic vars to temp vars
2951 isShowing = s.isShowing;
2952 isHiding = s.isHiding;
2953 wasSliding = s.isSliding;
2954 // now clear the logic vars (REQUIRED before aborting)
2955 delete s.isShowing;
2956 delete s.isHiding;
2957
2958 if (abort) return queueNext();
2959
2960 doFX = !noAnimation && !s.isClosed && (o.fxName_close != "none");
2961 s.isMoving = true;
2962 s.isClosed = true;
2963 s.isVisible = false;
2964 // update isHidden BEFORE sizing panes
2965 if (isHiding) s.isHidden = true;
2966 else if (isShowing) s.isHidden = false;
2967
2968 if (s.isSliding) // pane is being closed, so UNBIND trigger events
2969 bindStopSlidingEvents(pane, false); // will set isSliding=false
2970 else // resize panes adjacent to this one
2971 sizeMidPanes(_c[pane].dir === "horz" ? "" : "center", false); // false = NOT skipCallback
2972
2973 // if this pane has a resizer bar, move it NOW - before animation
2974 setAsClosed(pane);
2975
2976 // CLOSE THE PANE
2977 if (doFX) { // animate the close
2978 // mask panes with objects
2979 var masks = "center"+ (c.dir=="horz" ? ",west,east" : "");
2980 showMasks( masks, true ); // true = ONLY mask panes with maskObjects=true
2981 lockPaneForFX(pane, true); // need to set left/top so animation will work
2982 $P.hide( o.fxName_close, o.fxSettings_close, o.fxSpeed_close, function () {
2983 lockPaneForFX(pane, false); // undo
2984 if (s.isClosed) close_2();
2985 queueNext();
2986 });
2987 }
2988 else { // hide the pane without animation
2989 _hidePane(pane);
2990 close_2();
2991 queueNext();
2992 };
2993 });
2994
2995 // SUBROUTINE
2996 function close_2 () {
2997 s.isMoving = false;
2998 bindStartSlidingEvent(pane, true); // will enable if o.slidable = true
2999
3000 // if opposite-pane was autoClosed, see if it can be autoOpened now
3001 var altPane = _c.oppositeEdge[pane];
3002 if (state[ altPane ].noRoom) {
3003 setSizeLimits( altPane );
3004 makePaneFit( altPane );
3005 }
3006
3007 // hide any masks shown while closing
3008 hideMasks();
3009
3010 if (!skipCallback && (state.initialized || o.triggerEventsOnLoad)) {
3011 // onclose callback - UNLESS just 'showing' a hidden pane as 'closed'
3012 if (!isShowing) _runCallbacks("onclose_end", pane);
3013 // onhide OR onshow callback
3014 if (isShowing) _runCallbacks("onshow_end", pane);
3015 if (isHiding) _runCallbacks("onhide_end", pane);
3016 }
3017 }
3018 }
3019
3020 /**
3021 * @param {string} pane The pane just closed, ie: north, south, east, or west
3022 */
3023, setAsClosed = function (pane) {
3024 var
3025 $P = $Ps[pane]
3026 , $R = $Rs[pane]
3027 , $T = $Ts[pane]
3028 , o = options[pane]
3029 , s = state[pane]
3030 , side = _c[pane].side.toLowerCase()
3031 , inset = "inset"+ _c[pane].side
3032 , rClass = o.resizerClass
3033 , tClass = o.togglerClass
3034 , _pane = "-"+ pane // used for classNames
3035 , _open = "-open"
3036 , _sliding= "-sliding"
3037 , _closed = "-closed"
3038 ;
3039 $R
3040 .css(side, sC[inset]) // move the resizer
3041 .removeClass( rClass+_open +" "+ rClass+_pane+_open )
3042 .removeClass( rClass+_sliding +" "+ rClass+_pane+_sliding )
3043 .addClass( rClass+_closed +" "+ rClass+_pane+_closed )
3044 .unbind("dblclick."+ sID)
3045 ;
3046 // DISABLE 'resizing' when closed - do this BEFORE bindStartSlidingEvent?
3047 if (o.resizable && $.layout.plugins.draggable)
3048 $R
3049 .draggable("disable")
3050 .removeClass("ui-state-disabled") // do NOT apply disabled styling - not suitable here
3051 .css("cursor", "default")
3052 .attr("title","")
3053 ;
3054
3055 // if pane has a toggler button, adjust that too
3056 if ($T) {
3057 $T
3058 .removeClass( tClass+_open +" "+ tClass+_pane+_open )
3059 .addClass( tClass+_closed +" "+ tClass+_pane+_closed )
3060 .attr("title", o.togglerTip_closed) // may be blank
3061 ;
3062 // toggler-content - if exists
3063 $T.children(".content-open").hide();
3064 $T.children(".content-closed").css("display","block");
3065 }
3066
3067 // sync any 'pin buttons'
3068 syncPinBtns(pane, false);
3069
3070 if (state.initialized) {
3071 // resize 'length' and position togglers for adjacent panes
3072 sizeHandles();
3073 }
3074 }
3075
3076 /**
3077 * Open the specified pane (animation optional), and resize all other panes as needed
3078 *
3079 * @param {string} pane The pane being opened, ie: north, south, east, or west
3080 * @param {boolean=} [slide=false]
3081 * @param {boolean=} [noAnimation=false]
3082 * @param {boolean=} [noAlert=false]
3083 */
3084, open = function (evt_or_pane, slide, noAnimation, noAlert) {
3085 if (!isInitialized()) return;
3086 var pane = evtPane.call(this, evt_or_pane)
3087 , $P = $Ps[pane]
3088 , $R = $Rs[pane]
3089 , $T = $Ts[pane]
3090 , o = options[pane]
3091 , s = state[pane]
3092 , c = _c[pane]
3093 , doFX, isShowing
3094 ;
3095 // QUEUE in case another action/animation is in progress
3096 $N.queue(function( queueNext ){
3097
3098 if ( !$P
3099 || (!o.resizable && !o.closable && !s.isShowing) // invalid request
3100 || (s.isVisible && !s.isSliding) // already open
3101 ) return queueNext();
3102
3103 // pane can ALSO be unhidden by just calling show(), so handle this scenario
3104 if (s.isHidden && !s.isShowing) {
3105 queueNext(); // call before show() because it needs the queue free
3106 show(pane, true);
3107 return;
3108 }
3109
3110 if (o.autoResize && s.size != o.size) // resize pane to original size set in options
3111 sizePane(pane, o.size, true, true, true); // true=skipCallback/forceResize/noAnimation
3112 else
3113 // make sure there is enough space available to open the pane
3114 setSizeLimits(pane, slide);
3115
3116 // onopen_start callback - will CANCEL open if returns false
3117 var cbReturn = _runCallbacks("onopen_start", pane);
3118
3119 if (cbReturn === "abort")
3120 return queueNext();
3121
3122 // update pane-state again in case options were changed in onopen_start
3123 if (cbReturn !== "NC") // NC = "No Callback"
3124 setSizeLimits(pane, slide);
3125
3126 if (s.minSize > s.maxSize) { // INSUFFICIENT ROOM FOR PANE TO OPEN!
3127 syncPinBtns(pane, false); // make sure pin-buttons are reset
3128 if (!noAlert && o.noRoomToOpenTip)
3129 alert(o.noRoomToOpenTip);
3130 return queueNext(); // ABORT
3131 }
3132
3133 if (slide) // START Sliding - will set isSliding=true
3134 bindStopSlidingEvents(pane, true); // BIND trigger events to close sliding-pane
3135 else if (s.isSliding) // PIN PANE (stop sliding) - open pane 'normally' instead
3136 bindStopSlidingEvents(pane, false); // UNBIND trigger events - will set isSliding=false
3137 else if (o.slidable)
3138 bindStartSlidingEvent(pane, false); // UNBIND trigger events
3139
3140 s.noRoom = false; // will be reset by makePaneFit if 'noRoom'
3141 makePaneFit(pane);
3142
3143 // transfer logic var to temp var
3144 isShowing = s.isShowing;
3145 // now clear the logic var
3146 delete s.isShowing;
3147
3148 doFX = !noAnimation && s.isClosed && (o.fxName_open != "none");
3149 s.isMoving = true;
3150 s.isVisible = true;
3151 s.isClosed = false;
3152 // update isHidden BEFORE sizing panes - WHY??? Old?
3153 if (isShowing) s.isHidden = false;
3154
3155 if (doFX) { // ANIMATE
3156 // mask panes with objects
3157 var masks = "center"+ (c.dir=="horz" ? ",west,east" : "");
3158 if (s.isSliding) masks += ","+ _c.oppositeEdge[pane];
3159 showMasks( masks, true ); // true = ONLY mask panes with maskObjects=true
3160 lockPaneForFX(pane, true); // need to set left/top so animation will work
3161 $P.show( o.fxName_open, o.fxSettings_open, o.fxSpeed_open, function() {
3162 lockPaneForFX(pane, false); // undo
3163 if (s.isVisible) open_2(); // continue
3164 queueNext();
3165 });
3166 }
3167 else { // no animation
3168 _showPane(pane);// just show pane and...
3169 open_2(); // continue
3170 queueNext();
3171 };
3172 });
3173
3174 // SUBROUTINE
3175 function open_2 () {
3176 s.isMoving = false;
3177
3178 // cure iframe display issues
3179 _fixIframe(pane);
3180
3181 // NOTE: if isSliding, then other panes are NOT 'resized'
3182 if (!s.isSliding) { // resize all panes adjacent to this one
3183 hideMasks(); // remove any masks shown while opening
3184 sizeMidPanes(_c[pane].dir=="vert" ? "center" : "", false); // false = NOT skipCallback
3185 }
3186
3187 // set classes, position handles and execute callbacks...
3188 setAsOpen(pane);
3189 };
3190
3191 }
3192
3193 /**
3194 * @param {string} pane The pane just opened, ie: north, south, east, or west
3195 * @param {boolean=} [skipCallback=false]
3196 */
3197, setAsOpen = function (pane, skipCallback) {
3198 var
3199 $P = $Ps[pane]
3200 , $R = $Rs[pane]
3201 , $T = $Ts[pane]
3202 , o = options[pane]
3203 , s = state[pane]
3204 , side = _c[pane].side.toLowerCase()
3205 , inset = "inset"+ _c[pane].side
3206 , rClass = o.resizerClass
3207 , tClass = o.togglerClass
3208 , _pane = "-"+ pane // used for classNames
3209 , _open = "-open"
3210 , _closed = "-closed"
3211 , _sliding= "-sliding"
3212 ;
3213 $R
3214 .css(side, sC[inset] + getPaneSize(pane)) // move the resizer
3215 .removeClass( rClass+_closed +" "+ rClass+_pane+_closed )
3216 .addClass( rClass+_open +" "+ rClass+_pane+_open )
3217 ;
3218 if (s.isSliding)
3219 $R.addClass( rClass+_sliding +" "+ rClass+_pane+_sliding )
3220 else // in case 'was sliding'
3221 $R.removeClass( rClass+_sliding +" "+ rClass+_pane+_sliding )
3222
3223 if (o.resizerDblClickToggle)
3224 $R.bind("dblclick", toggle );
3225 removeHover( 0, $R ); // remove hover classes
3226 if (o.resizable && $.layout.plugins.draggable)
3227 $R .draggable("enable")
3228 .css("cursor", o.resizerCursor)
3229 .attr("title", o.resizerTip);
3230 else if (!s.isSliding)
3231 $R.css("cursor", "default"); // n-resize, s-resize, etc
3232
3233 // if pane also has a toggler button, adjust that too
3234 if ($T) {
3235 $T .removeClass( tClass+_closed +" "+ tClass+_pane+_closed )
3236 .addClass( tClass+_open +" "+ tClass+_pane+_open )
3237 .attr("title", o.togglerTip_open); // may be blank
3238 removeHover( 0, $T ); // remove hover classes
3239 // toggler-content - if exists
3240 $T.children(".content-closed").hide();
3241 $T.children(".content-open").css("display","block");
3242 }
3243
3244 // sync any 'pin buttons'
3245 syncPinBtns(pane, !s.isSliding);
3246
3247 // update pane-state dimensions - BEFORE resizing content
3248 $.extend(s, elDims($P));
3249
3250 if (state.initialized) {
3251 // resize resizer & toggler sizes for all panes
3252 sizeHandles();
3253 // resize content every time pane opens - to be sure
3254 sizeContent(pane, true); // true = remeasure headers/footers, even if 'pane.isMoving'
3255 }
3256
3257 if (!skipCallback && (state.initialized || o.triggerEventsOnLoad) && $P.is(":visible")) {
3258 // onopen callback
3259 _runCallbacks("onopen_end", pane);
3260 // onshow callback - TODO: should this be here?
3261 if (s.isShowing) _runCallbacks("onshow_end", pane);
3262
3263 // ALSO call onresize because layout-size *may* have changed while pane was closed
3264 if (state.initialized)
3265 _runCallbacks("onresize_end", pane);
3266 }
3267
3268 // TODO: Somehow sizePane("north") is being called after this point???
3269 }
3270
3271
3272 /**
3273 * slideOpen / slideClose / slideToggle
3274 *
3275 * Pass-though methods for sliding
3276 */
3277, slideOpen = function (evt_or_pane) {
3278 if (!isInitialized()) return;
3279 var evt = evtObj(evt_or_pane)
3280 , pane = evtPane.call(this, evt_or_pane)
3281 , s = state[pane]
3282 , delay = options[pane].slideDelay_open
3283 ;
3284 // prevent event from triggering on NEW resizer binding created below
3285 if (evt) evt.stopImmediatePropagation();
3286
3287 if (s.isClosed && evt && evt.type === "mouseenter" && delay > 0)
3288 // trigger = mouseenter - use a delay
3289 timer.set(pane+"_openSlider", open_NOW, delay);
3290 else
3291 open_NOW(); // will unbind events if is already open
3292
3293 /**
3294 * SUBROUTINE for timed open
3295 */
3296 function open_NOW () {
3297 if (!s.isClosed) // skip if no longer closed!
3298 bindStopSlidingEvents(pane, true); // BIND trigger events to close sliding-pane
3299 else if (!s.isMoving)
3300 open(pane, true); // true = slide - open() will handle binding
3301 };
3302 }
3303
3304, slideClose = function (evt_or_pane) {
3305 if (!isInitialized()) return;
3306 var evt = evtObj(evt_or_pane)
3307 , pane = evtPane.call(this, evt_or_pane)
3308 , o = options[pane]
3309 , s = state[pane]
3310 , delay = s.isMoving ? 1000 : 300 // MINIMUM delay - option may override
3311 ;
3312 if (s.isClosed || s.isResizing)
3313 return; // skip if already closed OR in process of resizing
3314 else if (o.slideTrigger_close === "click")
3315 close_NOW(); // close immediately onClick
3316 else if (o.preventQuickSlideClose && s.isMoving)
3317 return; // handle Chrome quick-close on slide-open
3318 else if (o.preventPrematureSlideClose && evt && $.layout.isMouseOverElem(evt, $Ps[pane]))
3319 return; // handle incorrect mouseleave trigger, like when over a SELECT-list in IE
3320 else if (evt) // trigger = mouseleave - use a delay
3321 // 1 sec delay if 'opening', else .3 sec
3322 timer.set(pane+"_closeSlider", close_NOW, max(o.slideDelay_close, delay));
3323 else // called programically
3324 close_NOW();
3325
3326 /**
3327 * SUBROUTINE for timed close
3328 */
3329 function close_NOW () {
3330 if (s.isClosed) // skip 'close' if already closed!
3331 bindStopSlidingEvents(pane, false); // UNBIND trigger events - TODO: is this needed here?
3332 else if (!s.isMoving)
3333 close(pane); // close will handle unbinding
3334 };
3335 }
3336
3337 /**
3338 * @param {string} pane The pane being opened, ie: north, south, east, or west
3339 */
3340, slideToggle = function (evt_or_pane) {
3341 var pane = evtPane.call(this, evt_or_pane);
3342 toggle(pane, true);
3343 }
3344
3345
3346 /**
3347 * Must set left/top on East/South panes so animation will work properly
3348 *
3349 * @param {string} pane The pane to lock, 'east' or 'south' - any other is ignored!
3350 * @param {boolean} doLock true = set left/top, false = remove
3351 */
3352, lockPaneForFX = function (pane, doLock) {
3353 var $P = $Ps[pane]
3354 , s = state[pane]
3355 , o = options[pane]
3356 , z = options.zIndexes
3357 ;
3358 if (doLock) {
3359 $P.css({ zIndex: z.pane_animate }); // overlay all elements during animation
3360 if (pane=="south")
3361 $P.css({ top: sC.insetTop + sC.innerHeight - $P.outerHeight() });
3362 else if (pane=="east")
3363 $P.css({ left: sC.insetLeft + sC.innerWidth - $P.outerWidth() });
3364 }
3365 else { // animation DONE - RESET CSS
3366 // TODO: see if this can be deleted. It causes a quick-close when sliding in Chrome
3367 $P.css({ zIndex: (s.isSliding ? z.pane_sliding : z.pane_normal) });
3368 if (pane=="south")
3369 $P.css({ top: "auto" });
3370 // if pane is positioned 'off-screen', then DO NOT screw with it!
3371 else if (pane=="east" && !$P.css("left").match(/\-99999/))
3372 $P.css({ left: "auto" });
3373 // fix anti-aliasing in IE - only needed for animations that change opacity
3374 if (browser.msie && o.fxOpacityFix && o.fxName_open != "slide" && $P.css("filter") && $P.css("opacity") == 1)
3375 $P[0].style.removeAttribute('filter');
3376 }
3377 }
3378
3379
3380 /**
3381 * Toggle sliding functionality of a specific pane on/off by adding removing 'slide open' trigger
3382 *
3383 * @see open(), close()
3384 * @param {string} pane The pane to enable/disable, 'north', 'south', etc.
3385 * @param {boolean} enable Enable or Disable sliding?
3386 */
3387, bindStartSlidingEvent = function (pane, enable) {
3388 var o = options[pane]
3389 , $P = $Ps[pane]
3390 , $R = $Rs[pane]
3391 , evtName = o.slideTrigger_open.toLowerCase()
3392 ;
3393 if (!$R || (enable && !o.slidable)) return;
3394
3395 // make sure we have a valid event
3396 if (evtName.match(/mouseover/))
3397 evtName = o.slideTrigger_open = "mouseenter";
3398 else if (!evtName.match(/click|dblclick|mouseenter/))
3399 evtName = o.slideTrigger_open = "click";
3400
3401 $R
3402 // add or remove event
3403 [enable ? "bind" : "unbind"](evtName +'.'+ sID, slideOpen)
3404 // set the appropriate cursor & title/tip
3405 .css("cursor", enable ? o.sliderCursor : "default")
3406 .attr("title", enable ? o.sliderTip : "")
3407 ;
3408 }
3409
3410 /**
3411 * Add or remove 'mouseleave' events to 'slide close' when pane is 'sliding' open or closed
3412 * Also increases zIndex when pane is sliding open
3413 * See bindStartSlidingEvent for code to control 'slide open'
3414 *
3415 * @see slideOpen(), slideClose()
3416 * @param {string} pane The pane to process, 'north', 'south', etc.
3417 * @param {boolean} enable Enable or Disable events?
3418 */
3419, bindStopSlidingEvents = function (pane, enable) {
3420 var o = options[pane]
3421 , s = state[pane]
3422 , c = _c[pane]
3423 , z = options.zIndexes
3424 , evtName = o.slideTrigger_close.toLowerCase()
3425 , action = (enable ? "bind" : "unbind")
3426 , $P = $Ps[pane]
3427 , $R = $Rs[pane]
3428 ;
3429 s.isSliding = enable; // logic
3430 timer.clear(pane+"_closeSlider"); // just in case
3431
3432 // remove 'slideOpen' event from resizer
3433 // ALSO will raise the zIndex of the pane & resizer
3434 if (enable) bindStartSlidingEvent(pane, false);
3435
3436 // RE/SET zIndex - increases when pane is sliding-open, resets to normal when not
3437 $P.css("zIndex", enable ? z.pane_sliding : z.pane_normal);
3438 $R.css("zIndex", enable ? z.pane_sliding+2 : z.resizer_normal); // NOTE: mask = pane_sliding+1
3439
3440 // make sure we have a valid event
3441 if (!evtName.match(/click|mouseleave/))
3442 evtName = o.slideTrigger_close = "mouseleave"; // also catches 'mouseout'
3443
3444 // add/remove slide triggers
3445 $R[action](evtName, slideClose); // base event on resize
3446 // need extra events for mouseleave
3447 if (evtName === "mouseleave") {
3448 // also close on pane.mouseleave
3449 $P[action]("mouseleave."+ sID, slideClose);
3450 // cancel timer when mouse moves between 'pane' and 'resizer'
3451 $R[action]("mouseenter."+ sID, cancelMouseOut);
3452 $P[action]("mouseenter."+ sID, cancelMouseOut);
3453 }
3454
3455 if (!enable)
3456 timer.clear(pane+"_closeSlider");
3457 else if (evtName === "click" && !o.resizable) {
3458 // IF pane is not resizable (which already has a cursor and tip)
3459 // then set the a cursor & title/tip on resizer when sliding
3460 $R.css("cursor", enable ? o.sliderCursor : "default");
3461 $R.attr("title", enable ? o.togglerTip_open : ""); // use Toggler-tip, eg: "Close Pane"
3462 }
3463
3464 // SUBROUTINE for mouseleave timer clearing
3465 function cancelMouseOut (evt) {
3466 timer.clear(pane+"_closeSlider");
3467 evt.stopPropagation();
3468 }
3469 }
3470
3471
3472 /**
3473 * Hides/closes a pane if there is insufficient room - reverses this when there is room again
3474 * MUST have already called setSizeLimits() before calling this method
3475 *
3476 * @param {string} pane The pane being resized
3477 * @param {boolean=} [isOpening=false] Called from onOpen?
3478 * @param {boolean=} [skipCallback=false] Should the onresize callback be run?
3479 * @param {boolean=} [force=false]
3480 */
3481, makePaneFit = function (pane, isOpening, skipCallback, force) {
3482 var
3483 o = options[pane]
3484 , s = state[pane]
3485 , c = _c[pane]
3486 , $P = $Ps[pane]
3487 , $R = $Rs[pane]
3488 , isSidePane = c.dir==="vert"
3489 , hasRoom = false
3490 ;
3491 // special handling for center & east/west panes
3492 if (pane === "center" || (isSidePane && s.noVerticalRoom)) {
3493 // see if there is enough room to display the pane
3494 // ERROR: hasRoom = s.minHeight <= s.maxHeight && (isSidePane || s.minWidth <= s.maxWidth);
3495 hasRoom = (s.maxHeight >= 0);
3496 if (hasRoom && s.noRoom) { // previously hidden due to noRoom, so show now
3497 _showPane(pane);
3498 if ($R) $R.show();
3499 s.isVisible = true;
3500 s.noRoom = false;
3501 if (isSidePane) s.noVerticalRoom = false;
3502 _fixIframe(pane);
3503 }
3504 else if (!hasRoom && !s.noRoom) { // not currently hidden, so hide now
3505 _hidePane(pane);
3506 if ($R) $R.hide();
3507 s.isVisible = false;
3508 s.noRoom = true;
3509 }
3510 }
3511
3512 // see if there is enough room to fit the border-pane
3513 if (pane === "center") {
3514 // ignore center in this block
3515 }
3516 else if (s.minSize <= s.maxSize) { // pane CAN fit
3517 hasRoom = true;
3518 if (s.size > s.maxSize) // pane is too big - shrink it
3519 sizePane(pane, s.maxSize, skipCallback, force, true); // true = noAnimation
3520 else if (s.size < s.minSize) // pane is too small - enlarge it
3521 sizePane(pane, s.minSize, skipCallback, force, true);
3522 // need s.isVisible because new pseudoClose method keeps pane visible, but off-screen
3523 else if ($R && s.isVisible && $P.is(":visible")) {
3524 // make sure resizer-bar is positioned correctly
3525 // handles situation where nested layout was 'hidden' when initialized
3526 var side = c.side.toLowerCase()
3527 , pos = s.size + sC["inset"+ c.side]
3528 ;
3529 if ($.layout.cssNum($R, side) != pos) $R.css( side, pos );
3530 }
3531
3532 // if was previously hidden due to noRoom, then RESET because NOW there is room
3533 if (s.noRoom) {
3534 // s.noRoom state will be set by open or show
3535 if (s.wasOpen && o.closable) {
3536 if (o.autoReopen)
3537 open(pane, false, true, true); // true = noAnimation, true = noAlert
3538 else // leave the pane closed, so just update state
3539 s.noRoom = false;
3540 }
3541 else
3542 show(pane, s.wasOpen, true, true); // true = noAnimation, true = noAlert
3543 }
3544 }
3545 else { // !hasRoom - pane CANNOT fit
3546 if (!s.noRoom) { // pane not set as noRoom yet, so hide or close it now...
3547 s.noRoom = true; // update state
3548 s.wasOpen = !s.isClosed && !s.isSliding;
3549 if (s.isClosed){} // SKIP
3550 else if (o.closable) // 'close' if possible
3551 close(pane, true, true); // true = force, true = noAnimation
3552 else // 'hide' pane if cannot just be closed
3553 hide(pane, true); // true = noAnimation
3554 }
3555 }
3556 }
3557
3558
3559 /**
3560 * sizePane / manualSizePane
3561 * sizePane is called only by internal methods whenever a pane needs to be resized
3562 * manualSizePane is an exposed flow-through method allowing extra code when pane is 'manually resized'
3563 *
3564 * @param {string} pane The pane being resized
3565 * @param {number} size The *desired* new size for this pane - will be validated
3566 * @param {boolean=} [skipCallback=false] Should the onresize callback be run?
3567 * @param {boolean=} [noAnimation=false]
3568 */
3569, manualSizePane = function (evt_or_pane, size, skipCallback, noAnimation) {
3570 if (!isInitialized()) return;
3571 var pane = evtPane.call(this, evt_or_pane)
3572 , o = options[pane]
3573 , s = state[pane]
3574 // if resizing callbacks have been delayed and resizing is now DONE, force resizing to complete...
3575 , forceResize = o.livePaneResizing && !s.isResizing
3576 ;
3577 // ANY call to manualSizePane disables autoResize - ie, percentage sizing
3578 o.autoResize = false;
3579 // flow-through...
3580 sizePane(pane, size, skipCallback, forceResize, noAnimation); // will animate resize if option enabled
3581 }
3582
3583 /**
3584 * @param {string} pane The pane being resized
3585 * @param {number} size The *desired* new size for this pane - will be validated
3586 * @param {boolean=} [skipCallback=false] Should the onresize callback be run?
3587 * @param {boolean=} [force=false] Force resizing even if does not seem necessary
3588 * @param {boolean=} [noAnimation=false]
3589 */
3590, sizePane = function (evt_or_pane, size, skipCallback, force, noAnimation) {
3591 if (!isInitialized()) return;
3592 var pane = evtPane.call(this, evt_or_pane) // probably NEVER called from event?
3593 , o = options[pane]
3594 , s = state[pane]
3595 , $P = $Ps[pane]
3596 , $R = $Rs[pane]
3597 , side = _c[pane].side.toLowerCase()
3598 , dimName = _c[pane].sizeType.toLowerCase()
3599 , inset = "inset"+ _c[pane].side
3600 , skipResizeWhileDragging = s.isResizing && !o.triggerEventsDuringLiveResize
3601 , doFX = noAnimation !== true && o.animatePaneSizing
3602 , oldSize, newSize
3603 ;
3604 // QUEUE in case another action/animation is in progress
3605 $N.queue(function( queueNext ){
3606 // calculate 'current' min/max sizes
3607 setSizeLimits(pane); // update pane-state
3608 oldSize = s.size;
3609 size = _parseSize(pane, size); // handle percentages & auto
3610 size = max(size, _parseSize(pane, o.minSize));
3611 size = min(size, s.maxSize);
3612 if (size < s.minSize) { // not enough room for pane!
3613 queueNext(); // call before makePaneFit() because it needs the queue free
3614 makePaneFit(pane, false, skipCallback); // will hide or close pane
3615 return;
3616 }
3617
3618 // IF newSize is same as oldSize, then nothing to do - abort
3619 if (!force && size === oldSize)
3620 return queueNext();
3621
3622 // onresize_start callback CANNOT cancel resizing because this would break the layout!
3623 if (!skipCallback && state.initialized && s.isVisible)
3624 _runCallbacks("onresize_start", pane);
3625
3626 // resize the pane, and make sure its visible
3627 newSize = cssSize(pane, size);
3628
3629 if (doFX && $P.is(":visible")) { // ANIMATE
3630 var fx = $.layout.effects.size[pane] || $.layout.effects.size.all
3631 , easing = o.fxSettings_size.easing || fx.easing
3632 , z = options.zIndexes
3633 , props = {};
3634 props[ dimName ] = newSize +'px';
3635 s.isMoving = true;
3636 // overlay all elements during animation
3637 $P.css({ zIndex: z.pane_animate })
3638 .show().animate( props, o.fxSpeed_size, easing, function(){
3639 // reset zIndex after animation
3640 $P.css({ zIndex: (s.isSliding ? z.pane_sliding : z.pane_normal) });
3641 s.isMoving = false;
3642 sizePane_2(); // continue
3643 queueNext();
3644 });
3645 }
3646 else { // no animation
3647 $P.css( dimName, newSize ); // resize pane
3648 // if pane is visible, then
3649 if ($P.is(":visible"))
3650 sizePane_2(); // continue
3651 else {
3652 // pane is NOT VISIBLE, so just update state data...
3653 // when pane is *next opened*, it will have the new size
3654 s.size = size; // update state.size
3655 $.extend(s, elDims($P)); // update state dimensions
3656 }
3657 queueNext();
3658 };
3659
3660 });
3661
3662 // SUBROUTINE
3663 function sizePane_2 () {
3664 /* Panes are sometimes not sized precisely in some browsers!?
3665 * This code will resize the pane up to 3 times to nudge the pane to the correct size
3666 */
3667 var actual = dimName==='width' ? $P.outerWidth() : $P.outerHeight()
3668 , tries = [{
3669 pane: pane
3670 , count: 1
3671 , target: size
3672 , actual: actual
3673 , correct: (size === actual)
3674 , attempt: size
3675 , cssSize: newSize
3676 }]
3677 , lastTry = tries[0]
3678 , msg = 'Inaccurate size after resizing the '+ pane +'-pane.'
3679 ;
3680 while ( !lastTry.correct ) {
3681 thisTry = { pane: pane, count: lastTry.count+1, target: size };
3682
3683 if (lastTry.actual > size)
3684 thisTry.attempt = max(0, lastTry.attempt - (lastTry.actual - size));
3685 else // lastTry.actual < size
3686 thisTry.attempt = max(0, lastTry.attempt + (size - lastTry.actual));
3687
3688 thisTry.cssSize = cssSize(pane, thisTry.attempt);
3689 $P.css( dimName, thisTry.cssSize );
3690
3691 thisTry.actual = dimName=='width' ? $P.outerWidth() : $P.outerHeight();
3692 thisTry.correct = (size === thisTry.actual);
3693
3694 // if showDebugMessages, log attempts and alert the user of this *non-fatal error*
3695 if (options.showDebugMessages) {
3696 if ( tries.length === 1) {
3697 _log(msg, false);
3698 _log(lastTry, false);
3699 }
3700 _log(thisTry, false);
3701 }
3702
3703 // after 4 tries, is as close as its gonna get!
3704 if (tries.length > 3) break;
3705
3706 tries.push( thisTry );
3707 lastTry = tries[ tries.length - 1 ];
3708 }
3709 // END TESTING CODE
3710
3711 // update pane-state dimensions
3712 s.size = size;
3713 $.extend(s, elDims($P));
3714
3715 if (s.isVisible && $P.is(":visible")) {
3716 // reposition the resizer-bar
3717 if ($R) $R.css( side, size + sC[inset] );
3718 // resize the content-div
3719 sizeContent(pane);
3720 }
3721
3722 if (!skipCallback && !skipResizeWhileDragging && state.initialized && s.isVisible)
3723 _runCallbacks("onresize_end", pane);
3724
3725 // resize all the adjacent panes, and adjust their toggler buttons
3726 // when skipCallback passed, it means the controlling method will handle 'other panes'
3727 if (!skipCallback) {
3728 // also no callback if live-resize is in progress and NOT triggerEventsDuringLiveResize
3729 if (!s.isSliding) sizeMidPanes(_c[pane].dir=="horz" ? "" : "center", skipResizeWhileDragging, force);
3730 sizeHandles();
3731 }
3732
3733 // if opposite-pane was autoClosed, see if it can be autoOpened now
3734 var altPane = _c.oppositeEdge[pane];
3735 if (size < oldSize && state[ altPane ].noRoom) {
3736 setSizeLimits( altPane );
3737 makePaneFit( altPane, false, skipCallback );
3738 }
3739
3740 // DEBUG - ALERT user/developer so they know there was a sizing problem
3741 if (options.showDebugMessages && tries.length > 1)
3742 _log(msg +'\nSee the Error Console for details.', true);
3743 }
3744 }
3745
3746 /**
3747 * @see initPanes(), sizePane(), resizeAll(), open(), close(), hide()
3748 * @param {string} panes The pane(s) being resized, comma-delmited string
3749 * @param {boolean=} [skipCallback=false] Should the onresize callback be run?
3750 * @param {boolean=} [force=false]
3751 */
3752, sizeMidPanes = function (panes, skipCallback, force) {
3753 panes = (panes ? panes : "east,west,center").split(",");
3754
3755 $.each(panes, function (i, pane) {
3756 if (!$Ps[pane]) return; // NO PANE - skip
3757 var
3758 o = options[pane]
3759 , s = state[pane]
3760 , $P = $Ps[pane]
3761 , $R = $Rs[pane]
3762 , isCenter= (pane=="center")
3763 , hasRoom = true
3764 , CSS = {}
3765 , newCenter = calcNewCenterPaneDims()
3766 ;
3767 // update pane-state dimensions
3768 $.extend(s, elDims($P));
3769
3770 if (pane === "center") {
3771 if (!force && s.isVisible && newCenter.width === s.outerWidth && newCenter.height === s.outerHeight)
3772 return true; // SKIP - pane already the correct size
3773 // set state for makePaneFit() logic
3774 $.extend(s, cssMinDims(pane), {
3775 maxWidth: newCenter.width
3776 , maxHeight: newCenter.height
3777 });
3778 CSS = newCenter;
3779 // convert OUTER width/height to CSS width/height
3780 CSS.width = cssW($P, CSS.width);
3781 // NEW - allow pane to extend 'below' visible area rather than hide it
3782 CSS.height = cssH($P, CSS.height);
3783 hasRoom = CSS.width >= 0 && CSS.height >= 0; // height >= 0 = ALWAYS TRUE NOW
3784 // during layout init, try to shrink east/west panes to make room for center
3785 if (!state.initialized && o.minWidth > s.outerWidth) {
3786 var
3787 reqPx = o.minWidth - s.outerWidth
3788 , minE = options.east.minSize || 0
3789 , minW = options.west.minSize || 0
3790 , sizeE = state.east.size
3791 , sizeW = state.west.size
3792 , newE = sizeE
3793 , newW = sizeW
3794 ;
3795 if (reqPx > 0 && state.east.isVisible && sizeE > minE) {
3796 newE = max( sizeE-minE, sizeE-reqPx );
3797 reqPx -= sizeE-newE;
3798 }
3799 if (reqPx > 0 && state.west.isVisible && sizeW > minW) {
3800 newW = max( sizeW-minW, sizeW-reqPx );
3801 reqPx -= sizeW-newW;
3802 }
3803 // IF we found enough extra space, then resize the border panes as calculated
3804 if (reqPx === 0) {
3805 if (sizeE != minE)
3806 sizePane('east', newE, true, force, true); // true = skipCallback/noAnimation - initPanes will handle when done
3807 if (sizeW != minW)
3808 sizePane('west', newW, true, force, true);
3809 // now start over!
3810 sizeMidPanes('center', skipCallback, force);
3811 return; // abort this loop
3812 }
3813 }
3814 }
3815 else { // for east and west, set only the height, which is same as center height
3816 // set state.min/maxWidth/Height for makePaneFit() logic
3817 if (s.isVisible && !s.noVerticalRoom)
3818 $.extend(s, elDims($P), cssMinDims(pane))
3819 if (!force && !s.noVerticalRoom && newCenter.height === s.outerHeight)
3820 return true; // SKIP - pane already the correct size
3821 // east/west have same top, bottom & height as center
3822 CSS.top = newCenter.top;
3823 CSS.bottom = newCenter.bottom;
3824 // NEW - allow pane to extend 'below' visible area rather than hide it
3825 CSS.height = cssH($P, newCenter.height);
3826 s.maxHeight = CSS.height;
3827 hasRoom = (s.maxHeight >= 0); // ALWAYS TRUE NOW
3828 if (!hasRoom) s.noVerticalRoom = true; // makePaneFit() logic
3829 }
3830
3831 if (hasRoom) {
3832 // resizeAll passes skipCallback because it triggers callbacks after ALL panes are resized
3833 if (!skipCallback && state.initialized)
3834 _runCallbacks("onresize_start", pane);
3835
3836 $P.css(CSS); // apply the CSS to pane
3837 sizeHandles(pane); // also update resizer length
3838 if (s.noRoom && !s.isClosed && !s.isHidden)
3839 makePaneFit(pane); // will re-open/show auto-closed/hidden pane
3840 if (s.isVisible) {
3841 $.extend(s, elDims($P)); // update pane dimensions
3842 if (state.initialized) sizeContent(pane); // also resize the contents, if exists
3843 }
3844 }
3845 else if (!s.noRoom && s.isVisible) // no room for pane
3846 makePaneFit(pane); // will hide or close pane
3847
3848 if (!s.isVisible)
3849 return true; // DONE - next pane
3850
3851 /*
3852 * Extra CSS for IE6 or IE7 in Quirks-mode - add 'width' to NORTH/SOUTH panes
3853 * Normally these panes have only 'left' & 'right' positions so pane auto-sizes
3854 * ALSO required when pane is an IFRAME because will NOT default to 'full width'
3855 */
3856 if (pane === "center") { // finished processing midPanes
3857 var b = $.layout.browser;
3858 var fix = b.isIE6 || (b.msie && !$.support.boxModel);
3859 if ($Ps.north && (fix || state.north.tagName=="IFRAME"))
3860 $Ps.north.css("width", cssW($Ps.north, sC.innerWidth));
3861 if ($Ps.south && (fix || state.south.tagName=="IFRAME"))
3862 $Ps.south.css("width", cssW($Ps.south, sC.innerWidth));
3863 }
3864
3865 // resizeAll passes skipCallback because it triggers callbacks after ALL panes are resized
3866 if (!skipCallback && state.initialized)
3867 _runCallbacks("onresize_end", pane);
3868 });
3869 }
3870
3871
3872 /**
3873 * @see window.onresize(), callbacks or custom code
3874 */
3875, resizeAll = function () {
3876 if (!state.initialized) {
3877 _initLayoutElements();
3878 return; // no need to resize since we just initialized!
3879 }
3880 var oldW = sC.innerWidth
3881 , oldH = sC.innerHeight
3882 ;
3883 // cannot size layout when 'container' is hidden or collapsed
3884 if (!$N.is(":visible:") ) return;
3885 $.extend( state.container, elDims( $N ) ); // UPDATE container dimensions
3886 if (!sC.outerHeight) return;
3887
3888 // onresizeall_start will CANCEL resizing if returns false
3889 // state.container has already been set, so user can access this info for calcuations
3890 if (false === _runCallbacks("onresizeall_start")) return false;
3891
3892 var // see if container is now 'smaller' than before
3893 shrunkH = (sC.innerHeight < oldH)
3894 , shrunkW = (sC.innerWidth < oldW)
3895 , $P, o, s, dir
3896 ;
3897 // NOTE special order for sizing: S-N-E-W
3898 $.each(["south","north","east","west"], function (i, pane) {
3899 if (!$Ps[pane]) return; // no pane - SKIP
3900 s = state[pane];
3901 o = options[pane];
3902 dir = _c[pane].dir;
3903
3904 if (o.autoResize && s.size != o.size) // resize pane to original size set in options
3905 sizePane(pane, o.size, true, true, true); // true=skipCallback/forceResize/noAnimation
3906 else {
3907 setSizeLimits(pane);
3908 makePaneFit(pane, false, true, true); // true=skipCallback/forceResize
3909 }
3910 });
3911
3912 sizeMidPanes("", true, true); // true=skipCallback, true=forceResize
3913 sizeHandles(); // reposition the toggler elements
3914
3915 // trigger all individual pane callbacks AFTER layout has finished resizing
3916 o = options; // reuse alias
3917 $.each(_c.allPanes, function (i, pane) {
3918 $P = $Ps[pane];
3919 if (!$P) return; // SKIP
3920 if (state[pane].isVisible) // undefined for non-existent panes
3921 _runCallbacks("onresize_end", pane); // callback - if exists
3922 });
3923
3924 _runCallbacks("onresizeall_end");
3925 //_triggerLayoutEvent(pane, 'resizeall');
3926 }
3927
3928 /**
3929 * Whenever a pane resizes or opens that has a nested layout, trigger resizeAll
3930 *
3931 * @param {string} pane The pane just resized or opened
3932 */
3933, resizeChildLayout = function (evt_or_pane) {
3934 var pane = evtPane.call(this, evt_or_pane);
3935 if (!options[pane].resizeChildLayout) return;
3936 var $P = $Ps[pane]
3937 , $C = $Cs[pane]
3938 , d = "layout"
3939 , P = Instance[pane]
3940 , L = children[pane]
3941 ;
3942 // user may have manually set EITHER instance pointer, so handle that
3943 if (P.child && !L) {
3944 // have to reverse the pointers!
3945 var el = P.child.container;
3946 L = children[pane] = (el ? el.data(d) : 0) || null; // set pointer _directly_ to layout instance
3947 }
3948
3949 // if a layout-pointer exists, see if child has been destroyed
3950 if (L && L.destroyed)
3951 L = children[pane] = null; // clear child pointers
3952 // no child layout pointer is set - see if there is a child layout NOW
3953 if (!L) L = children[pane] = $P.data(d) || ($C ? $C.data(d) : 0) || null; // set/update child pointers
3954
3955 // ALWAYS refresh the pane.child alias
3956 P.child = children[pane];
3957
3958 if (L) L.resizeAll();
3959 }
3960
3961
3962 /**
3963 * IF pane has a content-div, then resize all elements inside pane to fit pane-height
3964 *
3965 * @param {string=} [panes=""] The pane(s) being resized
3966 * @param {boolean=} [remeasure=false] Should the content (header/footer) be remeasured?
3967 */
3968, sizeContent = function (evt_or_panes, remeasure) {
3969 if (!isInitialized()) return;
3970
3971 var panes = evtPane.call(this, evt_or_panes);
3972 panes = panes ? panes.split(",") : _c.allPanes;
3973
3974 $.each(panes, function (idx, pane) {
3975 var
3976 $P = $Ps[pane]
3977 , $C = $Cs[pane]
3978 , o = options[pane]
3979 , s = state[pane]
3980 , m = s.content // m = measurements
3981 ;
3982 if (!$P || !$C || !$P.is(":visible")) return true; // NOT VISIBLE - skip
3983
3984 // if content-element was REMOVED, update OR remove the pointer
3985 if (!$C.length) {
3986 initContent(pane, false); // false = do NOT sizeContent() - already there!
3987 if (!$C) return; // no replacement element found - pointer have been removed
3988 }
3989
3990 // onsizecontent_start will CANCEL resizing if returns false
3991 if (false === _runCallbacks("onsizecontent_start", pane)) return;
3992
3993 // skip re-measuring offsets if live-resizing
3994 if ((!s.isMoving && !s.isResizing) || o.liveContentResizing || remeasure || m.top == undefined) {
3995 _measure();
3996 // if any footers are below pane-bottom, they may not measure correctly,
3997 // so allow pane overflow and re-measure
3998 if (m.hiddenFooters > 0 && $P.css("overflow") === "hidden") {
3999 $P.css("overflow", "visible");
4000 _measure(); // remeasure while overflowing
4001 $P.css("overflow", "hidden");
4002 }
4003 }
4004 // NOTE: spaceAbove/Below *includes* the pane paddingTop/Bottom, but not pane.borders
4005 var newH = s.innerHeight - (m.spaceAbove - s.css.paddingTop) - (m.spaceBelow - s.css.paddingBottom);
4006
4007 if (!$C.is(":visible") || m.height != newH) {
4008 // size the Content element to fit new pane-size - will autoHide if not enough room
4009 setOuterHeight($C, newH, true); // true=autoHide
4010 m.height = newH; // save new height
4011 };
4012
4013 if (state.initialized)
4014 _runCallbacks("onsizecontent_end", pane);
4015
4016 function _below ($E) {
4017 return max(s.css.paddingBottom, (parseInt($E.css("marginBottom"), 10) || 0));
4018 };
4019
4020 function _measure () {
4021 var
4022 ignore = options[pane].contentIgnoreSelector
4023 , $Fs = $C.nextAll().not(ignore || ':lt(0)') // not :lt(0) = ALL
4024 , $Fs_vis = $Fs.filter(':visible')
4025 , $F = $Fs_vis.filter(':last')
4026 ;
4027 m = {
4028 top: $C[0].offsetTop
4029 , height: $C.outerHeight()
4030 , numFooters: $Fs.length
4031 , hiddenFooters: $Fs.length - $Fs_vis.length
4032 , spaceBelow: 0 // correct if no content footer ($E)
4033 }
4034 m.spaceAbove = m.top; // just for state - not used in calc
4035 m.bottom = m.top + m.height;
4036 if ($F.length)
4037 //spaceBelow = (LastFooter.top + LastFooter.height) [footerBottom] - Content.bottom + max(LastFooter.marginBottom, pane.paddingBotom)
4038 m.spaceBelow = ($F[0].offsetTop + $F.outerHeight()) - m.bottom + _below($F);
4039 else // no footer - check marginBottom on Content element itself
4040 m.spaceBelow = _below($C);
4041 };
4042 });
4043 }
4044
4045
4046 /**
4047 * Called every time a pane is opened, closed, or resized to slide the togglers to 'center' and adjust their length if necessary
4048 *
4049 * @see initHandles(), open(), close(), resizeAll()
4050 * @param {string=} [panes=""] The pane(s) being resized
4051 */
4052, sizeHandles = function (evt_or_panes) {
4053 var panes = evtPane.call(this, evt_or_panes)
4054 panes = panes ? panes.split(",") : _c.borderPanes;
4055
4056 $.each(panes, function (i, pane) {
4057 var
4058 o = options[pane]
4059 , s = state[pane]
4060 , $P = $Ps[pane]
4061 , $R = $Rs[pane]
4062 , $T = $Ts[pane]
4063 , $TC
4064 ;
4065 if (!$P || !$R) return;
4066
4067 var
4068 dir = _c[pane].dir
4069 , _state = (s.isClosed ? "_closed" : "_open")
4070 , spacing = o["spacing"+ _state]
4071 , togAlign = o["togglerAlign"+ _state]
4072 , togLen = o["togglerLength"+ _state]
4073 , paneLen
4074 , left
4075 , offset
4076 , CSS = {}
4077 ;
4078
4079 if (spacing === 0) {
4080 $R.hide();
4081 return;
4082 }
4083 else if (!s.noRoom && !s.isHidden) // skip if resizer was hidden for any reason
4084 $R.show(); // in case was previously hidden
4085
4086 // Resizer Bar is ALWAYS same width/height of pane it is attached to
4087 if (dir === "horz") { // north/south
4088 //paneLen = $P.outerWidth(); // s.outerWidth ||
4089 paneLen = sC.innerWidth; // handle offscreen-panes
4090 s.resizerLength = paneLen;
4091 left = $.layout.cssNum($P, "left")
4092 $R.css({
4093 width: cssW($R, paneLen) // account for borders & padding
4094 , height: cssH($R, spacing) // ditto
4095 , left: left > -9999 ? left : sC.insetLeft // handle offscreen-panes
4096 });
4097 }
4098 else { // east/west
4099 paneLen = $P.outerHeight(); // s.outerHeight ||
4100 s.resizerLength = paneLen;
4101 $R.css({
4102 height: cssH($R, paneLen) // account for borders & padding
4103 , width: cssW($R, spacing) // ditto
4104 , top: sC.insetTop + getPaneSize("north", true) // TODO: what if no North pane?
4105 //, top: $.layout.cssNum($Ps["center"], "top")
4106 });
4107 }
4108
4109 // remove hover classes
4110 removeHover( o, $R );
4111
4112 if ($T) {
4113 if (togLen === 0 || (s.isSliding && o.hideTogglerOnSlide)) {
4114 $T.hide(); // always HIDE the toggler when 'sliding'
4115 return;
4116 }
4117 else
4118 $T.show(); // in case was previously hidden
4119
4120 if (!(togLen > 0) || togLen === "100%" || togLen > paneLen) {
4121 togLen = paneLen;
4122 offset = 0;
4123 }
4124 else { // calculate 'offset' based on options.PANE.togglerAlign_open/closed
4125 if (isStr(togAlign)) {
4126 switch (togAlign) {
4127 case "top":
4128 case "left": offset = 0;
4129 break;
4130 case "bottom":
4131 case "right": offset = paneLen - togLen;
4132 break;
4133 case "middle":
4134 case "center":
4135 default: offset = round((paneLen - togLen) / 2); // 'default' catches typos
4136 }
4137 }
4138 else { // togAlign = number
4139 var x = parseInt(togAlign, 10); //
4140 if (togAlign >= 0) offset = x;
4141 else offset = paneLen - togLen + x; // NOTE: x is negative!
4142 }
4143 }
4144
4145 if (dir === "horz") { // north/south
4146 var width = cssW($T, togLen);
4147 $T.css({
4148 width: width // account for borders & padding
4149 , height: cssH($T, spacing) // ditto
4150 , left: offset // TODO: VERIFY that toggler positions correctly for ALL values
4151 , top: 0
4152 });
4153 // CENTER the toggler content SPAN
4154 $T.children(".content").each(function(){
4155 $TC = $(this);
4156 $TC.css("marginLeft", round((width-$TC.outerWidth())/2)); // could be negative
4157 });
4158 }
4159 else { // east/west
4160 var height = cssH($T, togLen);
4161 $T.css({
4162 height: height // account for borders & padding
4163 , width: cssW($T, spacing) // ditto
4164 , top: offset // POSITION the toggler
4165 , left: 0
4166 });
4167 // CENTER the toggler content SPAN
4168 $T.children(".content").each(function(){
4169 $TC = $(this);
4170 $TC.css("marginTop", round((height-$TC.outerHeight())/2)); // could be negative
4171 });
4172 }
4173
4174 // remove ALL hover classes
4175 removeHover( 0, $T );
4176 }
4177
4178 // DONE measuring and sizing this resizer/toggler, so can be 'hidden' now
4179 if (!state.initialized && (o.initHidden || s.noRoom)) {
4180 $R.hide();
4181 if ($T) $T.hide();
4182 }
4183 });
4184 }
4185
4186
4187 /**
4188 * @param {string} pane
4189 */
4190, enableClosable = function (evt_or_pane) {
4191 if (!isInitialized()) return;
4192 var pane = evtPane.call(this, evt_or_pane)
4193 , $T = $Ts[pane]
4194 , o = options[pane]
4195 ;
4196 if (!$T) return;
4197 o.closable = true;
4198 $T .bind("click."+ sID, function(evt){ evt.stopPropagation(); toggle(pane); })
4199 .css("visibility", "visible")
4200 .css("cursor", "pointer")
4201 .attr("title", state[pane].isClosed ? o.togglerTip_closed : o.togglerTip_open) // may be blank
4202 .show();
4203 }
4204 /**
4205 * @param {string} pane
4206 * @param {boolean=} [hide=false]
4207 */
4208, disableClosable = function (evt_or_pane, hide) {
4209 if (!isInitialized()) return;
4210 var pane = evtPane.call(this, evt_or_pane)
4211 , $T = $Ts[pane]
4212 ;
4213 if (!$T) return;
4214 options[pane].closable = false;
4215 // is closable is disable, then pane MUST be open!
4216 if (state[pane].isClosed) open(pane, false, true);
4217 $T .unbind("."+ sID)
4218 .css("visibility", hide ? "hidden" : "visible") // instead of hide(), which creates logic issues
4219 .css("cursor", "default")
4220 .attr("title", "");
4221 }
4222
4223
4224 /**
4225 * @param {string} pane
4226 */
4227, enableSlidable = function (evt_or_pane) {
4228 if (!isInitialized()) return;
4229 var pane = evtPane.call(this, evt_or_pane)
4230 , $R = $Rs[pane]
4231 ;
4232 if (!$R || !$R.data('draggable')) return;
4233 options[pane].slidable = true;
4234 if (s.isClosed)
4235 bindStartSlidingEvent(pane, true);
4236 }
4237 /**
4238 * @param {string} pane
4239 */
4240, disableSlidable = function (evt_or_pane) {
4241 if (!isInitialized()) return;
4242 var pane = evtPane.call(this, evt_or_pane)
4243 , $R = $Rs[pane]
4244 ;
4245 if (!$R) return;
4246 options[pane].slidable = false;
4247 if (state[pane].isSliding)
4248 close(pane, false, true);
4249 else {
4250 bindStartSlidingEvent(pane, false);
4251 $R .css("cursor", "default")
4252 .attr("title", "");
4253 removeHover(null, $R[0]); // in case currently hovered
4254 }
4255 }
4256
4257
4258 /**
4259 * @param {string} pane
4260 */
4261, enableResizable = function (evt_or_pane) {
4262 if (!isInitialized()) return;
4263 var pane = evtPane.call(this, evt_or_pane)
4264 , $R = $Rs[pane]
4265 , o = options[pane]
4266 ;
4267 if (!$R || !$R.data('draggable')) return;
4268 o.resizable = true;
4269 $R.draggable("enable");
4270 if (!state[pane].isClosed)
4271 $R .css("cursor", o.resizerCursor)
4272 .attr("title", o.resizerTip);
4273 }
4274 /**
4275 * @param {string} pane
4276 */
4277, disableResizable = function (evt_or_pane) {
4278 if (!isInitialized()) return;
4279 var pane = evtPane.call(this, evt_or_pane)
4280 , $R = $Rs[pane]
4281 ;
4282 if (!$R || !$R.data('draggable')) return;
4283 options[pane].resizable = false;
4284 $R .draggable("disable")
4285 .css("cursor", "default")
4286 .attr("title", "");
4287 removeHover(null, $R[0]); // in case currently hovered
4288 }
4289
4290
4291 /**
4292 * Move a pane from source-side (eg, west) to target-side (eg, east)
4293 * If pane exists on target-side, move that to source-side, ie, 'swap' the panes
4294 *
4295 * @param {string} pane1 The pane/edge being swapped
4296 * @param {string} pane2 ditto
4297 */
4298, swapPanes = function (evt_or_pane1, pane2) {
4299 if (!isInitialized()) return;
4300 var pane1 = evtPane.call(this, evt_or_pane1);
4301 // change state.edge NOW so callbacks can know where pane is headed...
4302 state[pane1].edge = pane2;
4303 state[pane2].edge = pane1;
4304 // run these even if NOT state.initialized
4305 if (false === _runCallbacks("onswap_start", pane1)
4306 || false === _runCallbacks("onswap_start", pane2)
4307 ) {
4308 state[pane1].edge = pane1; // reset
4309 state[pane2].edge = pane2;
4310 return;
4311 }
4312
4313 var
4314 oPane1 = copy( pane1 )
4315 , oPane2 = copy( pane2 )
4316 , sizes = {}
4317 ;
4318 sizes[pane1] = oPane1 ? oPane1.state.size : 0;
4319 sizes[pane2] = oPane2 ? oPane2.state.size : 0;
4320
4321 // clear pointers & state
4322 $Ps[pane1] = false;
4323 $Ps[pane2] = false;
4324 state[pane1] = {};
4325 state[pane2] = {};
4326
4327 // ALWAYS remove the resizer & toggler elements
4328 if ($Ts[pane1]) $Ts[pane1].remove();
4329 if ($Ts[pane2]) $Ts[pane2].remove();
4330 if ($Rs[pane1]) $Rs[pane1].remove();
4331 if ($Rs[pane2]) $Rs[pane2].remove();
4332 $Rs[pane1] = $Rs[pane2] = $Ts[pane1] = $Ts[pane2] = false;
4333
4334 // transfer element pointers and data to NEW Layout keys
4335 move( oPane1, pane2 );
4336 move( oPane2, pane1 );
4337
4338 // cleanup objects
4339 oPane1 = oPane2 = sizes = null;
4340
4341 // make panes 'visible' again
4342 if ($Ps[pane1]) $Ps[pane1].css(_c.visible);
4343 if ($Ps[pane2]) $Ps[pane2].css(_c.visible);
4344
4345 // fix any size discrepancies caused by swap
4346 resizeAll();
4347
4348 // run these even if NOT state.initialized
4349 _runCallbacks("onswap_end", pane1);
4350 _runCallbacks("onswap_end", pane2);
4351
4352 return;
4353
4354 function copy (n) { // n = pane
4355 var
4356 $P = $Ps[n]
4357 , $C = $Cs[n]
4358 ;
4359 return !$P ? false : {
4360 pane: n
4361 , P: $P ? $P[0] : false
4362 , C: $C ? $C[0] : false
4363 , state: $.extend(true, {}, state[n])
4364 , options: $.extend(true, {}, options[n])
4365 }
4366 };
4367
4368 function move (oPane, pane) {
4369 if (!oPane) return;
4370 var
4371 P = oPane.P
4372 , C = oPane.C
4373 , oldPane = oPane.pane
4374 , c = _c[pane]
4375 , side = c.side.toLowerCase()
4376 , inset = "inset"+ c.side
4377 // save pane-options that should be retained
4378 , s = $.extend({}, state[pane])
4379 , o = options[pane]
4380 // RETAIN side-specific FX Settings - more below
4381 , fx = { resizerCursor: o.resizerCursor }
4382 , re, size, pos
4383 ;
4384 $.each("fxName,fxSpeed,fxSettings".split(","), function (i, k) {
4385 fx[k +"_open"] = o[k +"_open"];
4386 fx[k +"_close"] = o[k +"_close"];
4387 fx[k +"_size"] = o[k +"_size"];
4388 });
4389
4390 // update object pointers and attributes
4391 $Ps[pane] = $(P)
4392 .data({
4393 layoutPane: Instance[pane] // NEW pointer to pane-alias-object
4394 , layoutEdge: pane
4395 })
4396 .css(_c.hidden)
4397 .css(c.cssReq)
4398 ;
4399 $Cs[pane] = C ? $(C) : false;
4400
4401 // set options and state
4402 options[pane] = $.extend({}, oPane.options, fx);
4403 state[pane] = $.extend({}, oPane.state);
4404
4405 // change classNames on the pane, eg: ui-layout-pane-east ==> ui-layout-pane-west
4406 re = new RegExp(o.paneClass +"-"+ oldPane, "g");
4407 P.className = P.className.replace(re, o.paneClass +"-"+ pane);
4408
4409 // ALWAYS regenerate the resizer & toggler elements
4410 initHandles(pane); // create the required resizer & toggler
4411
4412 // if moving to different orientation, then keep 'target' pane size
4413 if (c.dir != _c[oldPane].dir) {
4414 size = sizes[pane] || 0;
4415 setSizeLimits(pane); // update pane-state
4416 size = max(size, state[pane].minSize);
4417 // use manualSizePane to disable autoResize - not useful after panes are swapped
4418 manualSizePane(pane, size, true, true); // true/true = skipCallback/noAnimation
4419 }
4420 else // move the resizer here
4421 $Rs[pane].css(side, sC[inset] + (state[pane].isVisible ? getPaneSize(pane) : 0));
4422
4423
4424 // ADD CLASSNAMES & SLIDE-BINDINGS
4425 if (oPane.state.isVisible && !s.isVisible)
4426 setAsOpen(pane, true); // true = skipCallback
4427 else {
4428 setAsClosed(pane);
4429 bindStartSlidingEvent(pane, true); // will enable events IF option is set
4430 }
4431
4432 // DESTROY the object
4433 oPane = null;
4434 };
4435 }
4436
4437
4438 /**
4439 * INTERNAL method to sync pin-buttons when pane is opened or closed
4440 * Unpinned means the pane is 'sliding' - ie, over-top of the adjacent panes
4441 *
4442 * @see open(), setAsOpen(), setAsClosed()
4443 * @param {string} pane These are the params returned to callbacks by layout()
4444 * @param {boolean} doPin True means set the pin 'down', False means 'up'
4445 */
4446, syncPinBtns = function (pane, doPin) {
4447 if ($.layout.plugins.buttons)
4448 $.each(state[pane].pins, function (i, selector) {
4449 $.layout.buttons.setPinState(Instance, $(selector), pane, doPin);
4450 });
4451 }
4452
4453; // END var DECLARATIONS
4454
4455 /**
4456 * Capture keys when enableCursorHotkey - toggle pane if hotkey pressed
4457 *
4458 * @see document.keydown()
4459 */
4460 function keyDown (evt) {
4461 if (!evt) return true;
4462 var code = evt.keyCode;
4463 if (code < 33) return true; // ignore special keys: ENTER, TAB, etc
4464
4465 var
4466 PANE = {
4467 38: "north" // Up Cursor - $.ui.keyCode.UP
4468 , 40: "south" // Down Cursor - $.ui.keyCode.DOWN
4469 , 37: "west" // Left Cursor - $.ui.keyCode.LEFT
4470 , 39: "east" // Right Cursor - $.ui.keyCode.RIGHT
4471 }
4472 , ALT = evt.altKey // no worky!
4473 , SHIFT = evt.shiftKey
4474 , CTRL = evt.ctrlKey
4475 , CURSOR = (CTRL && code >= 37 && code <= 40)
4476 , o, k, m, pane
4477 ;
4478
4479 if (CURSOR && options[PANE[code]].enableCursorHotkey) // valid cursor-hotkey
4480 pane = PANE[code];
4481 else if (CTRL || SHIFT) // check to see if this matches a custom-hotkey
4482 $.each(_c.borderPanes, function (i, p) { // loop each pane to check its hotkey
4483 o = options[p];
4484 k = o.customHotkey;
4485 m = o.customHotkeyModifier; // if missing or invalid, treated as "CTRL+SHIFT"
4486 if ((SHIFT && m=="SHIFT") || (CTRL && m=="CTRL") || (CTRL && SHIFT)) { // Modifier matches
4487 if (k && code === (isNaN(k) || k <= 9 ? k.toUpperCase().charCodeAt(0) : k)) { // Key matches
4488 pane = p;
4489 return false; // BREAK
4490 }
4491 }
4492 });
4493
4494 // validate pane
4495 if (!pane || !$Ps[pane] || !options[pane].closable || state[pane].isHidden)
4496 return true;
4497
4498 toggle(pane);
4499
4500 evt.stopPropagation();
4501 evt.returnValue = false; // CANCEL key
4502 return false;
4503 };
4504
4505
4506/*
4507 * ######################################
4508 * UTILITY METHODS
4509 * called externally or by initButtons
4510 * ######################################
4511 */
4512
4513 /**
4514 * Change/reset a pane overflow setting & zIndex to allow popups/drop-downs to work
4515 *
4516 * @param {Object=} [el] (optional) Can also be 'bound' to a click, mouseOver, or other event
4517 */
4518 function allowOverflow (el) {
4519 if (!isInitialized()) return;
4520 if (this && this.tagName) el = this; // BOUND to element
4521 var $P;
4522 if (isStr(el))
4523 $P = $Ps[el];
4524 else if ($(el).data("layoutRole"))
4525 $P = $(el);
4526 else
4527 $(el).parents().each(function(){
4528 if ($(this).data("layoutRole")) {
4529 $P = $(this);
4530 return false; // BREAK
4531 }
4532 });
4533 if (!$P || !$P.length) return; // INVALID
4534
4535 var
4536 pane = $P.data("layoutEdge")
4537 , s = state[pane]
4538 ;
4539
4540 // if pane is already raised, then reset it before doing it again!
4541 // this would happen if allowOverflow is attached to BOTH the pane and an element
4542 if (s.cssSaved)
4543 resetOverflow(pane); // reset previous CSS before continuing
4544
4545 // if pane is raised by sliding or resizing, or its closed, then abort
4546 if (s.isSliding || s.isResizing || s.isClosed) {
4547 s.cssSaved = false;
4548 return;
4549 }
4550
4551 var
4552 newCSS = { zIndex: (options.zIndexes.resizer_normal + 1) }
4553 , curCSS = {}
4554 , of = $P.css("overflow")
4555 , ofX = $P.css("overflowX")
4556 , ofY = $P.css("overflowY")
4557 ;
4558 // determine which, if any, overflow settings need to be changed
4559 if (of != "visible") {
4560 curCSS.overflow = of;
4561 newCSS.overflow = "visible";
4562 }
4563 if (ofX && !ofX.match(/visible|auto/)) {
4564 curCSS.overflowX = ofX;
4565 newCSS.overflowX = "visible";
4566 }
4567 if (ofY && !ofY.match(/visible|auto/)) {
4568 curCSS.overflowY = ofX;
4569 newCSS.overflowY = "visible";
4570 }
4571
4572 // save the current overflow settings - even if blank!
4573 s.cssSaved = curCSS;
4574
4575 // apply new CSS to raise zIndex and, if necessary, make overflow 'visible'
4576 $P.css( newCSS );
4577
4578 // make sure the zIndex of all other panes is normal
4579 $.each(_c.allPanes, function(i, p) {
4580 if (p != pane) resetOverflow(p);
4581 });
4582
4583 };
4584 /**
4585 * @param {Object=} [el] (optional) Can also be 'bound' to a click, mouseOver, or other event
4586 */
4587 function resetOverflow (el) {
4588 if (!isInitialized()) return;
4589 if (this && this.tagName) el = this; // BOUND to element
4590 var $P;
4591 if (isStr(el))
4592 $P = $Ps[el];
4593 else if ($(el).data("layoutRole"))
4594 $P = $(el);
4595 else
4596 $(el).parents().each(function(){
4597 if ($(this).data("layoutRole")) {
4598 $P = $(this);
4599 return false; // BREAK
4600 }
4601 });
4602 if (!$P || !$P.length) return; // INVALID
4603
4604 var
4605 pane = $P.data("layoutEdge")
4606 , s = state[pane]
4607 , CSS = s.cssSaved || {}
4608 ;
4609 // reset the zIndex
4610 if (!s.isSliding && !s.isResizing)
4611 $P.css("zIndex", options.zIndexes.pane_normal);
4612
4613 // reset Overflow - if necessary
4614 $P.css( CSS );
4615
4616 // clear var
4617 s.cssSaved = false;
4618 };
4619
4620/*
4621 * #####################
4622 * CREATE/RETURN LAYOUT
4623 * #####################
4624 */
4625
4626 // validate that container exists
4627 var $N = $(this).eq(0); // FIRST matching Container element
4628 if (!$N.length) {
4629 if (options.showErrorMessages)
4630 _log( lang.errContainerMissing, true );
4631 return null;
4632 };
4633
4634 // Users retrieve Instance of a layout with: $N.layout() OR $N.data("layout")
4635 // return the Instance-pointer if layout has already been initialized
4636 if ($N.data("layoutContainer") && $N.data("layout"))
4637 return $N.data("layout"); // cached pointer
4638
4639 // init global vars
4640 var
4641 $Ps = {} // Panes x5 - set in initPanes()
4642 , $Cs = {} // Content x5 - set in initPanes()
4643 , $Rs = {} // Resizers x4 - set in initHandles()
4644 , $Ts = {} // Togglers x4 - set in initHandles()
4645 , $Ms = $([]) // Masks - up to 2 masks per pane (IFRAME + DIV)
4646 // aliases for code brevity
4647 , sC = state.container // alias for easy access to 'container dimensions'
4648 , sID = state.id // alias for unique layout ID/namespace - eg: "layout435"
4649 ;
4650
4651 // create Instance object to expose data & option Properties, and primary action Methods
4652 var Instance = {
4653 // layout data
4654 options: options // property - options hash
4655 , state: state // property - dimensions hash
4656 // object pointers
4657 , container: $N // property - object pointers for layout container
4658 , panes: $Ps // property - object pointers for ALL Panes: panes.north, panes.center
4659 , contents: $Cs // property - object pointers for ALL Content: contents.north, contents.center
4660 , resizers: $Rs // property - object pointers for ALL Resizers, eg: resizers.north
4661 , togglers: $Ts // property - object pointers for ALL Togglers, eg: togglers.north
4662 // border-pane open/close
4663 , hide: hide // method - ditto
4664 , show: show // method - ditto
4665 , toggle: toggle // method - pass a 'pane' ("north", "west", etc)
4666 , open: open // method - ditto
4667 , close: close // method - ditto
4668 , slideOpen: slideOpen // method - ditto
4669 , slideClose: slideClose // method - ditto
4670 , slideToggle: slideToggle // method - ditto
4671 // pane actions
4672 , setSizeLimits: setSizeLimits // method - pass a 'pane' - update state min/max data
4673 , _sizePane: sizePane // method -intended for user by plugins only!
4674 , sizePane: manualSizePane // method - pass a 'pane' AND an 'outer-size' in pixels or percent, or 'auto'
4675 , sizeContent: sizeContent // method - pass a 'pane'
4676 , swapPanes: swapPanes // method - pass TWO 'panes' - will swap them
4677 // pane element methods
4678 , initContent: initContent // method - ditto
4679 , addPane: addPane // method - pass a 'pane'
4680 , removePane: removePane // method - pass a 'pane' to remove from layout, add 'true' to delete the pane-elem
4681 , createChildLayout: createChildLayout// method - pass a 'pane' and (optional) layout-options (OVERRIDES options[pane].childOptions
4682 // special pane option setting
4683 , enableClosable: enableClosable // method - pass a 'pane'
4684 , disableClosable: disableClosable // method - ditto
4685 , enableSlidable: enableSlidable // method - ditto
4686 , disableSlidable: disableSlidable // method - ditto
4687 , enableResizable: enableResizable // method - ditto
4688 , disableResizable: disableResizable// method - ditto
4689 // utility methods for panes
4690 , allowOverflow: allowOverflow // utility - pass calling element (this)
4691 , resetOverflow: resetOverflow // utility - ditto
4692 // layout control
4693 , destroy: destroy // method - no parameters
4694 , initPanes: isInitialized // method - no parameters
4695 , resizeAll: resizeAll // method - no parameters
4696 // callback triggering
4697 , runCallbacks: _runCallbacks // method - pass evtName & pane (if a pane-event), eg: trigger("onopen", "west")
4698 // alias collections of options, state and children - created in addPane and extended elsewhere
4699 , hasParentLayout: false // set by initContainer()
4700 , children: children // pointers to child-layouts, eg: Instance.children["west"]
4701 , north: false // alias group: { name: pane, pane: $Ps[pane], options: options[pane], state: state[pane], child: children[pane] }
4702 , south: false // ditto
4703 , west: false // ditto
4704 , east: false // ditto
4705 , center: false // ditto
4706 };
4707
4708 // create the border layout NOW
4709 if (_create() === 'cancel') // onload_start callback returned false to CANCEL layout creation
4710 return null;
4711 else // true OR false -- if layout-elements did NOT init (hidden or do not exist), can auto-init later
4712 return Instance; // return the Instance object
4713
4714}
4715
4716
4717
4718
4719/**
4720 * jquery.layout.state 1.0
4721 * $Date$
4722 *
4723 * Copyright (c) 2010
4724 * Kevin Dalman (http://allpro.net)
4725 *
4726 * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html)
4727 * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses.
4728 *
4729 * @dependancies: UI Layout 1.3.0.rc30.1 or higher
4730 * @dependancies: $.ui.cookie (above)
4731 *
4732 * @support: http://groups.google.com/group/jquery-ui-layout
4733 */
4734/*
4735 * State-management options stored in options.stateManagement, which includes a .cookie hash
4736 * Default options saves ALL KEYS for ALL PANES, ie: pane.size, pane.isClosed, pane.isHidden
4737 *
4738 * // STATE/COOKIE OPTIONS
4739 * @example $(el).layout({
4740 stateManagement: {
4741 enabled: true
4742 , stateKeys: "east.size,west.size,east.isClosed,west.isClosed"
4743 , cookie: { name: "appLayout", path: "/" }
4744 }
4745 })
4746 * @example $(el).layout({ stateManagement__enabled: true }) // enable auto-state-management using cookies
4747 * @example $(el).layout({ stateManagement__cookie: { name: "appLayout", path: "/" } })
4748 * @example $(el).layout({ stateManagement__cookie__name: "appLayout", stateManagement__cookie__path: "/" })
4749 *
4750 * // STATE/COOKIE METHODS
4751 * @example myLayout.saveCookie( "west.isClosed,north.size,south.isHidden", {expires: 7} );
4752 * @example myLayout.loadCookie();
4753 * @example myLayout.deleteCookie();
4754 * @example var JSON = myLayout.readState(); // CURRENT Layout State
4755 * @example var JSON = myLayout.readCookie(); // SAVED Layout State (from cookie)
4756 * @example var JSON = myLayout.state.stateData; // LAST LOADED Layout State (cookie saved in layout.state hash)
4757 *
4758 * CUSTOM STATE-MANAGEMENT (eg, saved in a database)
4759 * @example var JSON = myLayout.readState( "west.isClosed,north.size,south.isHidden" );
4760 * @example myLayout.loadState( JSON );
4761 */
4762
4763/**
4764 * UI COOKIE UTILITY
4765 *
4766 * A $.cookie OR $.ui.cookie namespace *should be standard*, but until then...
4767 * This creates $.ui.cookie so Layout does not need the cookie.jquery.js plugin
4768 * NOTE: This utility is REQUIRED by the layout.state plugin
4769 *
4770 * Cookie methods in Layout are created as part of State Management
4771 */
4772if (!$.ui) $.ui = {};
4773$.ui.cookie = {
4774
4775 // cookieEnabled is not in DOM specs, but DOES works in all browsers,including IE6
4776 acceptsCookies: !!navigator.cookieEnabled
4777
4778, read: function (name) {
4779 var
4780 c = document.cookie
4781 , cs = c ? c.split(';') : []
4782 , pair // loop var
4783 ;
4784 for (var i=0, n=cs.length; i < n; i++) {
4785 pair = $.trim(cs[i]).split('='); // name=value pair
4786 if (pair[0] == name) // found the layout cookie
4787 return decodeURIComponent(pair[1]);
4788
4789 }
4790 return null;
4791 }
4792
4793, write: function (name, val, cookieOpts) {
4794 var
4795 params = ''
4796 , date = ''
4797 , clear = false
4798 , o = cookieOpts || {}
4799 , x = o.expires
4800 ;
4801 if (x && x.toUTCString)
4802 date = x;
4803 else if (x === null || typeof x === 'number') {
4804 date = new Date();
4805 if (x > 0)
4806 date.setDate(date.getDate() + x);
4807 else {
4808 date.setFullYear(1970);
4809 clear = true;
4810 }
4811 }
4812 if (date) params += ';expires='+ date.toUTCString();
4813 if (o.path) params += ';path='+ o.path;
4814 if (o.domain) params += ';domain='+ o.domain;
4815 if (o.secure) params += ';secure';
4816 document.cookie = name +'='+ (clear ? "" : encodeURIComponent( val )) + params; // write or clear cookie
4817 }
4818
4819, clear: function (name) {
4820 $.ui.cookie.write(name, '', {expires: -1});
4821 }
4822
4823};
4824// if cookie.jquery.js is not loaded, create an alias to replicate it
4825// this may be useful to other plugins or code dependent on that plugin
4826if (!$.cookie) $.cookie = function (k, v, o) {
4827 var C = $.ui.cookie;
4828 if (v === null)
4829 C.clear(k);
4830 else if (v === undefined)
4831 return C.read(k);
4832 else
4833 C.write(k, v, o);
4834};
4835
4836
4837// tell Layout that the state plugin is available
4838$.layout.plugins.stateManagement = true;
4839
4840// Add State-Management options to layout.defaults
4841$.layout.config.optionRootKeys.push("stateManagement");
4842$.layout.defaults.stateManagement = {
4843 enabled: false // true = enable state-management, even if not using cookies
4844, autoSave: true // Save a state-cookie when page exits?
4845, autoLoad: true // Load the state-cookie when Layout inits?
4846 // List state-data to save - must be pane-specific
4847, stateKeys: "north.size,south.size,east.size,west.size,"+
4848 "north.isClosed,south.isClosed,east.isClosed,west.isClosed,"+
4849 "north.isHidden,south.isHidden,east.isHidden,west.isHidden"
4850, cookie: {
4851 name: "" // If not specified, will use Layout.name, else just "Layout"
4852 , domain: "" // blank = current domain
4853 , path: "" // blank = current page, '/' = entire website
4854 , expires: "" // 'days' to keep cookie - leave blank for 'session cookie'
4855 , secure: false
4856 }
4857};
4858// Set stateManagement as a layout-option, NOT a pane-option
4859$.layout.optionsMap.layout.push("stateManagement");
4860
4861/*
4862 * State Management methods
4863 */
4864$.layout.state = {
4865
4866 /**
4867 * Get the current layout state and save it to a cookie
4868 *
4869 * myLayout.saveCookie( keys, cookieOpts )
4870 *
4871 * @param {Object} inst
4872 * @param {(string|Array)=} keys
4873 * @param {Object=} opts
4874 */
4875 saveCookie: function (inst, keys, cookieOpts) {
4876 var o = inst.options
4877 , oS = o.stateManagement
4878 , oC = $.extend(true, {}, oS.cookie, cookieOpts || null)
4879 , data = inst.state.stateData = inst.readState( keys || oS.stateKeys ) // read current panes-state
4880 ;
4881 $.ui.cookie.write( oC.name || o.name || "Layout", $.layout.state.encodeJSON(data), oC );
4882 return $.extend(true, {}, data); // return COPY of state.stateData data
4883 }
4884
4885 /**
4886 * Remove the state cookie
4887 *
4888 * @param {Object} inst
4889 */
4890, deleteCookie: function (inst) {
4891 var o = inst.options;
4892 $.ui.cookie.clear( o.stateManagement.cookie.name || o.name || "Layout" );
4893 }
4894
4895 /**
4896 * Read & return data from the cookie - as JSON
4897 *
4898 * @param {Object} inst
4899 */
4900, readCookie: function (inst) {
4901 var o = inst.options;
4902 var c = $.ui.cookie.read( o.stateManagement.cookie.name || o.name || "Layout" );
4903 // convert cookie string back to a hash and return it
4904 return c ? $.layout.state.decodeJSON(c) : {};
4905 }
4906
4907 /**
4908 * Get data from the cookie and USE IT to loadState
4909 *
4910 * @param {Object} inst
4911 */
4912, loadCookie: function (inst) {
4913 var c = $.layout.state.readCookie(inst); // READ the cookie
4914 if (c) {
4915 inst.state.stateData = $.extend(true, {}, c); // SET state.stateData
4916 inst.loadState(c); // LOAD the retrieved state
4917 }
4918 return c;
4919 }
4920
4921 /**
4922 * Update layout options from the cookie, if one exists
4923 *
4924 * @param {Object} inst
4925 * @param {Object=} stateData
4926 * @param {boolean=} animate
4927 */
4928, loadState: function (inst, stateData, animate) {
4929 stateData = $.layout.transformData( stateData ); // panes = default subkey
4930 if ($.isEmptyObject( stateData )) return;
4931 $.extend(true, inst.options, stateData); // update layout options
4932 // if layout has already been initialized, then UPDATE layout state
4933 if (inst.state.initialized) {
4934 var pane, vis, o, s, h, c
4935 , noAnimate = (animate===false)
4936 ;
4937 $.each($.layout.config.borderPanes, function (idx, pane) {
4938 state = inst.state[pane];
4939 o = stateData[ pane ];
4940 if (typeof o != 'object') return; // no key, continue
4941 s = o.size;
4942 c = o.initClosed;
4943 h = o.initHidden;
4944 vis = state.isVisible;
4945 // resize BEFORE opening
4946 if (!vis)
4947 inst.sizePane(pane, s, false, false);
4948 if (h === true) inst.hide(pane, noAnimate);
4949 else if (c === false) inst.open (pane, false, noAnimate);
4950 else if (c === true) inst.close(pane, false, noAnimate);
4951 else if (h === false) inst.show (pane, false, noAnimate);
4952 // resize AFTER any other actions
4953 if (vis)
4954 inst.sizePane(pane, s, false, noAnimate); // animate resize if option passed
4955 });
4956 };
4957 }
4958
4959 /**
4960 * Get the *current layout state* and return it as a hash
4961 *
4962 * @param {Object=} inst
4963 * @param {(string|Array)=} keys
4964 */
4965, readState: function (inst, keys) {
4966 var
4967 data = {}
4968 , alt = { isClosed: 'initClosed', isHidden: 'initHidden' }
4969 , state = inst.state
4970 , panes = $.layout.config.allPanes
4971 , pair, pane, key, val
4972 ;
4973 if (!keys) keys = inst.options.stateManagement.stateKeys; // if called by user
4974 if ($.isArray(keys)) keys = keys.join(",");
4975 // convert keys to an array and change delimiters from '__' to '.'
4976 keys = keys.replace(/__/g, ".").split(',');
4977 // loop keys and create a data hash
4978 for (var i=0, n=keys.length; i < n; i++) {
4979 pair = keys[i].split(".");
4980 pane = pair[0];
4981 key = pair[1];
4982 if ($.inArray(pane, panes) < 0) continue; // bad pane!
4983 val = state[ pane ][ key ];
4984 if (val == undefined) continue;
4985 if (key=="isClosed" && state[pane]["isSliding"])
4986 val = true; // if sliding, then *really* isClosed
4987 ( data[pane] || (data[pane]={}) )[ alt[key] ? alt[key] : key ] = val;
4988 }
4989 return data;
4990 }
4991
4992 /**
4993 * Stringify a JSON hash so can save in a cookie or db-field
4994 */
4995, encodeJSON: function (JSON) {
4996 return parse(JSON);
4997 function parse (h) {
4998 var D=[], i=0, k, v, t; // k = key, v = value
4999 for (k in h) {
5000 v = h[k];
5001 t = typeof v;
5002 if (t == 'string') // STRING - add quotes
5003 v = '"'+ v +'"';
5004 else if (t == 'object') // SUB-KEY - recurse into it
5005 v = parse(v);
5006 D[i++] = '"'+ k +'":'+ v;
5007 }
5008 return '{'+ D.join(',') +'}';
5009 };
5010 }
5011
5012 /**
5013 * Convert stringified JSON back to a hash object
5014 * @see $.parseJSON(), adding in jQuery 1.4.1
5015 */
5016, decodeJSON: function (str) {
5017 try { return $.parseJSON ? $.parseJSON(str) : window["eval"]("("+ str +")") || {}; }
5018 catch (e) { return {}; }
5019 }
5020
5021
5022, _create: function (inst) {
5023 var _ = $.layout.state;
5024 // ADD State-Management plugin methods to inst
5025 $.extend( inst, {
5026 // readCookie - update options from cookie - returns hash of cookie data
5027 readCookie: function () { return _.readCookie(inst); }
5028 // deleteCookie
5029 , deleteCookie: function () { _.deleteCookie(inst); }
5030 // saveCookie - optionally pass keys-list and cookie-options (hash)
5031 , saveCookie: function (keys, cookieOpts) { return _.saveCookie(inst, keys, cookieOpts); }
5032 // loadCookie - readCookie and use to loadState() - returns hash of cookie data
5033 , loadCookie: function () { return _.loadCookie(inst); }
5034 // loadState - pass a hash of state to use to update options
5035 , loadState: function (stateData, animate) { _.loadState(inst, stateData, animate); }
5036 // readState - returns hash of current layout-state
5037 , readState: function (keys) { return _.readState(inst, keys); }
5038 // add JSON utility methods too...
5039 , encodeJSON: _.encodeJSON
5040 , decodeJSON: _.decodeJSON
5041 });
5042
5043 // init state.stateData key, even if plugin is initially disabled
5044 inst.state.stateData = {};
5045
5046 // read and load cookie-data per options
5047 var oS = inst.options.stateManagement;
5048 if (oS.enabled) {
5049 if (oS.autoLoad) // update the options from the cookie
5050 inst.loadCookie();
5051 else // don't modify options - just store cookie data in state.stateData
5052 inst.state.stateData = inst.readCookie();
5053 }
5054 }
5055
5056, _unload: function (inst) {
5057 var oS = inst.options.stateManagement;
5058 if (oS.enabled) {
5059 if (oS.autoSave) // save a state-cookie automatically
5060 inst.saveCookie();
5061 else // don't save a cookie, but do store state-data in state.stateData key
5062 inst.state.stateData = inst.readState();
5063 }
5064 }
5065
5066};
5067
5068// add state initialization method to Layout's onCreate array of functions
5069$.layout.onCreate.push( $.layout.state._create );
5070$.layout.onUnload.push( $.layout.state._unload );
5071
5072
5073
5074
5075/**
5076 * jquery.layout.buttons 1.0
5077 * $Date$
5078 *
5079 * Copyright (c) 2010
5080 * Kevin Dalman (http://allpro.net)
5081 *
5082 * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html)
5083 * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses.
5084 *
5085 * @dependancies: UI Layout 1.3.0.rc30.1 or higher
5086 *
5087 * @support: http://groups.google.com/group/jquery-ui-layout
5088 *
5089 * Docs: [ to come ]
5090 * Tips: [ to come ]
5091 */
5092
5093// tell Layout that the state plugin is available
5094$.layout.plugins.buttons = true;
5095
5096// Add buttons options to layout.defaults
5097$.layout.defaults.autoBindCustomButtons = false;
5098// Specify autoBindCustomButtons as a layout-option, NOT a pane-option
5099$.layout.optionsMap.layout.push("autoBindCustomButtons");
5100
5101var lang = $.layout.language;
5102
5103/*
5104 * Button methods
5105 */
5106$.layout.buttons = {
5107
5108 /**
5109 * Searches for .ui-layout-button-xxx elements and auto-binds them as layout-buttons
5110 *
5111 * @see _create()
5112 *
5113 * @param {Object} inst Layout Instance object
5114 */
5115 init: function (inst) {
5116 var pre = "ui-layout-button-"
5117 , layout = inst.options.name || ""
5118 , name;
5119 $.each("toggle,open,close,pin,toggle-slide,open-slide".split(","), function (i, action) {
5120 $.each($.layout.config.borderPanes, function (ii, pane) {
5121 $("."+pre+action+"-"+pane).each(function(){
5122 // if button was previously 'bound', data.layoutName was set, but is blank if layout has no 'name'
5123 name = $(this).data("layoutName") || $(this).attr("layoutName");
5124 if (name == undefined || name === layout)
5125 inst.bindButton(this, action, pane);
5126 });
5127 });
5128 });
5129 }
5130
5131 /**
5132 * Helper function to validate params received by addButton utilities
5133 *
5134 * Two classes are added to the element, based on the buttonClass...
5135 * The type of button is appended to create the 2nd className:
5136 * - ui-layout-button-pin // action btnClass
5137 * - ui-layout-button-pin-west // action btnClass + pane
5138 * - ui-layout-button-toggle
5139 * - ui-layout-button-open
5140 * - ui-layout-button-close
5141 *
5142 * @param {Object} inst Layout Instance object
5143 * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
5144 * @param {string} pane Name of the pane the button is for: 'north', 'south', etc.
5145 *
5146 * @return {Array.<Object>} If both params valid, the element matching 'selector' in a jQuery wrapper - otherwise returns null
5147 */
5148, get: function (inst, selector, pane, action) {
5149 var $E = $(selector)
5150 , o = inst.options
5151 , err = o.showErrorMessages
5152 ;
5153 if (!$E.length) { // element not found
5154 if (err) $.layout.msg(lang.errButton + lang.selector +": "+ selector, true);
5155 }
5156 else if ($.inArray(pane, $.layout.config.borderPanes) < 0) { // invalid 'pane' sepecified
5157 if (err) $.layout.msg(lang.errButton + lang.pane +": "+ pane, true);
5158 $E = $(""); // NO BUTTON
5159 }
5160 else { // VALID
5161 var btn = o[pane].buttonClass +"-"+ action;
5162 $E .addClass( btn +" "+ btn +"-"+ pane )
5163 .data("layoutName", o.name); // add layout identifier - even if blank!
5164 }
5165 return $E;
5166 }
5167
5168
5169 /**
5170 * NEW syntax for binding layout-buttons - will eventually replace addToggle, addOpen, etc.
5171 *
5172 * @param {Object} inst Layout Instance object
5173 * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
5174 * @param {string} action
5175 * @param {string} pane
5176 */
5177, bind: function (inst, selector, action, pane) {
5178 var _ = $.layout.buttons;
5179 switch (action.toLowerCase()) {
5180 case "toggle": _.addToggle (inst, selector, pane); break;
5181 case "open": _.addOpen (inst, selector, pane); break;
5182 case "close": _.addClose (inst, selector, pane); break;
5183 case "pin": _.addPin (inst, selector, pane); break;
5184 case "toggle-slide": _.addToggle (inst, selector, pane, true); break;
5185 case "open-slide": _.addOpen (inst, selector, pane, true); break;
5186 }
5187 return inst;
5188 }
5189
5190 /**
5191 * Add a custom Toggler button for a pane
5192 *
5193 * @param {Object} inst Layout Instance object
5194 * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
5195 * @param {string} pane Name of the pane the button is for: 'north', 'south', etc.
5196 * @param {boolean=} slide true = slide-open, false = pin-open
5197 */
5198, addToggle: function (inst, selector, pane, slide) {
5199 $.layout.buttons.get(inst, selector, pane, "toggle")
5200 .click(function(evt){
5201 inst.toggle(pane, !!slide);
5202 evt.stopPropagation();
5203 });
5204 return inst;
5205 }
5206
5207 /**
5208 * Add a custom Open button for a pane
5209 *
5210 * @param {Object} inst Layout Instance object
5211 * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
5212 * @param {string} pane Name of the pane the button is for: 'north', 'south', etc.
5213 * @param {boolean=} slide true = slide-open, false = pin-open
5214 */
5215, addOpen: function (inst, selector, pane, slide) {
5216 $.layout.buttons.get(inst, selector, pane, "open")
5217 .attr("title", lang.Open)
5218 .click(function (evt) {
5219 inst.open(pane, !!slide);
5220 evt.stopPropagation();
5221 });
5222 return inst;
5223 }
5224
5225 /**
5226 * Add a custom Close button for a pane
5227 *
5228 * @param {Object} inst Layout Instance object
5229 * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
5230 * @param {string} pane Name of the pane the button is for: 'north', 'south', etc.
5231 */
5232, addClose: function (inst, selector, pane) {
5233 $.layout.buttons.get(inst, selector, pane, "close")
5234 .attr("title", lang.Close)
5235 .click(function (evt) {
5236 inst.close(pane);
5237 evt.stopPropagation();
5238 });
5239 return inst;
5240 }
5241
5242 /**
5243 * Add a custom Pin button for a pane
5244 *
5245 * Four classes are added to the element, based on the paneClass for the associated pane...
5246 * Assuming the default paneClass and the pin is 'up', these classes are added for a west-pane pin:
5247 * - ui-layout-pane-pin
5248 * - ui-layout-pane-west-pin
5249 * - ui-layout-pane-pin-up
5250 * - ui-layout-pane-west-pin-up
5251 *
5252 * @param {Object} inst Layout Instance object
5253 * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
5254 * @param {string} pane Name of the pane the pin is for: 'north', 'south', etc.
5255 */
5256, addPin: function (inst, selector, pane) {
5257 var _ = $.layout.buttons
5258 , $E = _.get(inst, selector, pane, "pin");
5259 if ($E.length) {
5260 var s = inst.state[pane];
5261 $E.click(function (evt) {
5262 _.setPinState(inst, $(this), pane, (s.isSliding || s.isClosed));
5263 if (s.isSliding || s.isClosed) inst.open( pane ); // change from sliding to open
5264 else inst.close( pane ); // slide-closed
5265 evt.stopPropagation();
5266 });
5267 // add up/down pin attributes and classes
5268 _.setPinState(inst, $E, pane, (!s.isClosed && !s.isSliding));
5269 // add this pin to the pane data so we can 'sync it' automatically
5270 // PANE.pins key is an array so we can store multiple pins for each pane
5271 s.pins.push( selector ); // just save the selector string
5272 }
5273 return inst;
5274 }
5275
5276 /**
5277 * Change the class of the pin button to make it look 'up' or 'down'
5278 *
5279 * @see addPin(), syncPins()
5280 *
5281 * @param {Object} inst Layout Instance object
5282 * @param {Array.<Object>} $Pin The pin-span element in a jQuery wrapper
5283 * @param {string} pane These are the params returned to callbacks by layout()
5284 * @param {boolean} doPin true = set the pin 'down', false = set it 'up'
5285 */
5286, setPinState: function (inst, $Pin, pane, doPin) {
5287 var updown = $Pin.attr("pin");
5288 if (updown && doPin === (updown=="down")) return; // already in correct state
5289 var
5290 pin = inst.options[pane].buttonClass +"-pin"
5291 , side = pin +"-"+ pane
5292 , UP = pin +"-up "+ side +"-up"
5293 , DN = pin +"-down "+side +"-down"
5294 ;
5295 $Pin
5296 .attr("pin", doPin ? "down" : "up") // logic
5297 .attr("title", doPin ? lang.Unpin : lang.Pin)
5298 .removeClass( doPin ? UP : DN )
5299 .addClass( doPin ? DN : UP )
5300 ;
5301 }
5302
5303 /**
5304 * INTERNAL function to sync 'pin buttons' when pane is opened or closed
5305 * Unpinned means the pane is 'sliding' - ie, over-top of the adjacent panes
5306 *
5307 * @see open(), close()
5308 *
5309 * @param {Object} inst Layout Instance object
5310 * @param {string} pane These are the params returned to callbacks by layout()
5311 * @param {boolean} doPin True means set the pin 'down', False means 'up'
5312 */
5313, syncPinBtns: function (inst, pane, doPin) {
5314 // REAL METHOD IS _INSIDE_ LAYOUT - THIS IS HERE JUST FOR REFERENCE
5315 $.each(state[pane].pins, function (i, selector) {
5316 $.layout.buttons.setPinState(inst, $(selector), pane, doPin);
5317 });
5318 }
5319
5320
5321, _load: function (inst) {
5322 var _ = $.layout.buttons;
5323 // ADD Button methods to Layout Instance
5324 // Note: sel = jQuery Selector string
5325 $.extend( inst, {
5326 bindButton: function (sel, action, pane) { return _.bind(inst, sel, action, pane); }
5327 // DEPRECATED METHODS
5328 , addToggleBtn: function (sel, pane, slide) { return _.addToggle(inst, sel, pane, slide); }
5329 , addOpenBtn: function (sel, pane, slide) { return _.addOpen(inst, sel, pane, slide); }
5330 , addCloseBtn: function (sel, pane) { return _.addClose(inst, sel, pane); }
5331 , addPinBtn: function (sel, pane) { return _.addPin(inst, sel, pane); }
5332 });
5333
5334 // init state array to hold pin-buttons
5335 for (var i=0; i<4; i++) {
5336 var pane = $.layout.config.borderPanes[i];
5337 inst.state[pane].pins = [];
5338 }
5339
5340 // auto-init buttons onLoad if option is enabled
5341 if ( inst.options.autoBindCustomButtons )
5342 _.init(inst);
5343 }
5344
5345, _unload: function (inst) {
5346 // TODO: unbind all buttons???
5347 }
5348
5349};
5350
5351// add initialization method to Layout's onLoad array of functions
5352$.layout.onLoad.push( $.layout.buttons._load );
5353//$.layout.onUnload.push( $.layout.buttons._unload );
5354
5355
5356
5357/**
5358 * jquery.layout.browserZoom 1.0
5359 * $Date$
5360 *
5361 * Copyright (c) 2012
5362 * Kevin Dalman (http://allpro.net)
5363 *
5364 * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html)
5365 * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses.
5366 *
5367 * @dependancies: UI Layout 1.3.0.rc30.1 or higher
5368 *
5369 * @support: http://groups.google.com/group/jquery-ui-layout
5370 *
5371 * @todo: Extend logic to handle other problematic zooming in browsers
5372 * @todo: Add hotkey/mousewheel bindings to _instantly_ respond to these zoom event
5373 */
5374
5375// tell Layout that the plugin is available
5376$.layout.plugins.browserZoom = true;
5377
5378$.layout.defaults.browserZoomCheckInterval = 1000;
5379$.layout.optionsMap.layout.push("browserZoomCheckInterval");
5380
5381/*
5382 * browserZoom methods
5383 */
5384$.layout.browserZoom = {
5385
5386 _init: function (inst) {
5387 // abort if browser does not need this check
5388 if ($.layout.browserZoom.ratio() !== false)
5389 $.layout.browserZoom._setTimer(inst);
5390 }
5391
5392, _setTimer: function (inst) {
5393 // abort if layout destroyed or browser does not need this check
5394 if (inst.destroyed) return;
5395 var o = inst.options
5396 , s = inst.state
5397 // don't need check if inst has parentLayout, but check occassionally in case parent destroyed!
5398 // MINIMUM 100ms interval, for performance
5399 , ms = inst.hasParentLayout ? 5000 : Math.max( o.browserZoomCheckInterval, 100 )
5400 ;
5401 // set the timer
5402 setTimeout(function(){
5403 if (inst.destroyed || !o.resizeWithWindow) return;
5404 var d = $.layout.browserZoom.ratio();
5405 if (d !== s.browserZoom) {
5406 s.browserZoom = d;
5407 inst.resizeAll();
5408 }
5409 // set a NEW timeout
5410 $.layout.browserZoom._setTimer(inst);
5411 }
5412 , ms );
5413 }
5414
5415, ratio: function () {
5416 var w = window
5417 , s = screen
5418 , d = document
5419 , dE = d.documentElement || d.body
5420 , b = $.layout.browser
5421 , v = b.version
5422 , r, sW, cW
5423 ;
5424 // we can ignore all browsers that fire window.resize event onZoom
5425 if ((b.msie && v > 8)
5426 || !b.msie
5427 ) return false; // don't need to track zoom
5428
5429 if (s.deviceXDPI)
5430 return calc(s.deviceXDPI, s.systemXDPI);
5431 // everything below is just for future reference!
5432 if (b.webkit && (r = d.body.getBoundingClientRect))
5433 return calc((r.left - r.right), d.body.offsetWidth);
5434 if (b.webkit && (sW = w.outerWidth))
5435 return calc(sW, w.innerWidth);
5436 if ((sW = s.width) && (cW = dE.clientWidth))
5437 return calc(sW, cW);
5438 return false; // no match, so cannot - or don't need to - track zoom
5439
5440 function calc (x,y) { return (parseInt(x,10) / parseInt(y,10) * 100).toFixed(); }
5441 }
5442
5443};
5444// add initialization method to Layout's onLoad array of functions
5445$.layout.onReady.push( $.layout.browserZoom._init );
5446
5447
5448
5449})( jQuery );
Note: See TracBrowser for help on using the repository browser.