root / tei / js / jquery.js @ 2
Historique | Voir | Annoter | Télécharger (138,5 ko)
1 |
/**
|
---|---|
2 |
* @preserve jquery.layout 1.3.0 - Release Candidate 29.7
|
3 |
* $Date: 2010-09-17 08:00:00 (Fri, 17 Sep 2010) $
|
4 |
* $Rev: 30297 $
|
5 |
*
|
6 |
* Copyright (c) 2010
|
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 |
* Docs: http://layout.jquery-dev.net/documentation.html
|
14 |
* Tips: http://layout.jquery-dev.net/tips.html
|
15 |
* Help: http://groups.google.com/group/jquery-ui-layout
|
16 |
*/
|
17 |
|
18 |
// NOTE: For best readability, view with a fixed-width font and tabs equal to 4-chars
|
19 |
|
20 |
;(function ($) { |
21 |
|
22 |
var $b = $.browser; |
23 |
|
24 |
/*
|
25 |
* GENERIC $.layout METHODS - used by all layouts
|
26 |
*/
|
27 |
$.layout = {
|
28 |
|
29 |
// can update code here if $.browser is phased out
|
30 |
browser: {
|
31 |
mozilla: $b.mozilla |
32 |
, webkit: $b.webkit || $b.safari || false // webkit = jQ 1.4 |
33 |
, msie: $b.msie |
34 |
, isIE6: $b.msie && $b.version == 6 |
35 |
, boxModel: false // page must load first, so will be updated set by _create |
36 |
//, version: $b.version - not used
|
37 |
} |
38 |
|
39 |
/*
|
40 |
* USER UTILITIES
|
41 |
*/
|
42 |
|
43 |
// calculate and return the scrollbar width, as an integer
|
44 |
, scrollbarWidth: function () { return window.scrollbarWidth || $.layout.getScrollbarSize('width'); } |
45 |
, scrollbarHeight: function () { return window.scrollbarHeight || $.layout.getScrollbarSize('height'); } |
46 |
, getScrollbarSize: function (dim) { |
47 |
var $c = $('<div style="position: absolute; top: -10000px; left: -10000px; width: 100px; height: 100px; overflow: scroll;"></div>').appendTo("body"); |
48 |
var d = { width: $c.width() - $c[0].clientWidth, height: $c.height() - $c[0].clientHeight }; |
49 |
$c.remove();
|
50 |
window.scrollbarWidth = d.width; |
51 |
window.scrollbarHeight = d.height; |
52 |
return dim.match(/^(width|height)$/i) ? d[dim] : d; |
53 |
} |
54 |
|
55 |
|
56 |
/**
|
57 |
* Returns hash container 'display' and 'visibility'
|
58 |
*
|
59 |
* @see $.swap() - swaps CSS, runs callback, resets CSS
|
60 |
*/
|
61 |
, showInvisibly: function ($E, force) { |
62 |
if (!$E) return {}; |
63 |
if (!$E.jquery) $E = $($E); |
64 |
var CSS = {
|
65 |
display: $E.css('display') |
66 |
, visibility: $E.css('visibility') |
67 |
}; |
68 |
if (force || CSS.display == "none") { // only if not *already hidden* |
69 |
$E.css({ display: "block", visibility: "hidden" }); // show element 'invisibly' so can be measured |
70 |
return CSS;
|
71 |
} |
72 |
else return {}; |
73 |
} |
74 |
|
75 |
/**
|
76 |
* Returns data for setting size of an element (container or a pane).
|
77 |
*
|
78 |
* @see _create(), onWindowResize() for container, plus others for pane
|
79 |
* @return JSON Returns a hash of all dimensions: top, bottom, left, right, outerWidth, innerHeight, etc
|
80 |
*/
|
81 |
, getElemDims: function ($E) { |
82 |
var
|
83 |
d = {} // dimensions hash
|
84 |
, x = d.css = {} // CSS hash
|
85 |
, i = {} // TEMP insets
|
86 |
, b, p // TEMP border, padding
|
87 |
, off = $E.offset()
|
88 |
; |
89 |
d.offsetLeft = off.left; |
90 |
d.offsetTop = off.top; |
91 |
|
92 |
$.each("Left,Right,Top,Bottom".split(","), function (idx, e) { // e = edge |
93 |
b = x["border" + e] = $.layout.borderWidth($E, e); |
94 |
p = x["padding"+ e] = $.layout.cssNum($E, "padding"+e); |
95 |
i[e] = b + p; // total offset of content from outer side
|
96 |
d["inset"+ e] = p;
|
97 |
/* WRONG ???
|
98 |
// if BOX MODEL, then 'position' = PADDING (ignore borderWidth)
|
99 |
if ($E == $Container)
|
100 |
d["inset"+ e] = (browser.boxModel ? p : 0);
|
101 |
*/
|
102 |
}); |
103 |
|
104 |
d.offsetWidth = $E.innerWidth();
|
105 |
d.offsetHeight = $E.innerHeight();
|
106 |
d.outerWidth = $E.outerWidth();
|
107 |
d.outerHeight = $E.outerHeight();
|
108 |
d.innerWidth = d.outerWidth - i.Left - i.Right; |
109 |
d.innerHeight = d.outerHeight - i.Top - i.Bottom; |
110 |
|
111 |
// TESTING
|
112 |
x.width = $E.width();
|
113 |
x.height = $E.height();
|
114 |
|
115 |
return d;
|
116 |
} |
117 |
|
118 |
, getElemCSS: function ($E, list) { |
119 |
var
|
120 |
CSS = {} |
121 |
, style = $E[0].style |
122 |
, props = list.split(",")
|
123 |
, sides = "Top,Bottom,Left,Right".split(",") |
124 |
, attrs = "Color,Style,Width".split(",") |
125 |
, p, s, a, i, j, k |
126 |
; |
127 |
for (i=0; i < props.length; i++) { |
128 |
p = props[i]; |
129 |
if (p.match(/(border|padding|margin)$/)) |
130 |
for (j=0; j < 4; j++) { |
131 |
s = sides[j]; |
132 |
if (p == "border") |
133 |
for (k=0; k < 3; k++) { |
134 |
a = attrs[k]; |
135 |
CSS[p+s+a] = style[p+s+a]; |
136 |
} |
137 |
else
|
138 |
CSS[p+s] = style[p+s]; |
139 |
} |
140 |
else
|
141 |
CSS[p] = style[p]; |
142 |
}; |
143 |
return CSS
|
144 |
} |
145 |
|
146 |
/**
|
147 |
* Contains logic to check boxModel & browser, and return the correct width/height for the current browser/doctype
|
148 |
*
|
149 |
* @see initPanes(), sizeMidPanes(), initHandles(), sizeHandles()
|
150 |
* @param {Array.<Object>} $E Must pass a jQuery object - first element is processed
|
151 |
* @param {number=} outerWidth/outerHeight (optional) Can pass a width, allowing calculations BEFORE element is resized
|
152 |
* @return {number} Returns the innerWidth/Height of the elem by subtracting padding and borders
|
153 |
*/
|
154 |
, cssWidth: function ($E, outerWidth) { |
155 |
var
|
156 |
b = $.layout.borderWidth
|
157 |
, n = $.layout.cssNum
|
158 |
; |
159 |
// a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed
|
160 |
if (outerWidth <= 0) return 0; |
161 |
|
162 |
if (!$.layout.browser.boxModel) return outerWidth; |
163 |
|
164 |
// strip border and padding from outerWidth to get CSS Width
|
165 |
var W = outerWidth
|
166 |
- b($E, "Left") |
167 |
- b($E, "Right") |
168 |
- n($E, "paddingLeft") |
169 |
- n($E, "paddingRight") |
170 |
; |
171 |
|
172 |
return W > 0 ? W : 0; |
173 |
} |
174 |
|
175 |
, cssHeight: function ($E, outerHeight) { |
176 |
var
|
177 |
b = $.layout.borderWidth
|
178 |
, n = $.layout.cssNum
|
179 |
; |
180 |
// a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed
|
181 |
if (outerHeight <= 0) return 0; |
182 |
|
183 |
if (!$.layout.browser.boxModel) return outerHeight; |
184 |
|
185 |
// strip border and padding from outerHeight to get CSS Height
|
186 |
var H = outerHeight
|
187 |
- b($E, "Top") |
188 |
- b($E, "Bottom") |
189 |
- n($E, "paddingTop") |
190 |
- n($E, "paddingBottom") |
191 |
; |
192 |
|
193 |
return H > 0 ? H : 0; |
194 |
} |
195 |
|
196 |
/**
|
197 |
* Returns the 'current CSS numeric value' for an element - returns 0 if property does not exist
|
198 |
*
|
199 |
* @see Called by many methods
|
200 |
* @param {Array.<Object>} $E Must pass a jQuery object - first element is processed
|
201 |
* @param {string} prop The name of the CSS property, eg: top, width, etc.
|
202 |
* @return {*} Usually is used to get an integer value for position (top, left) or size (height, width)
|
203 |
*/
|
204 |
, cssNum: function ($E, prop) { |
205 |
if (!$E.jquery) $E = $($E); |
206 |
var CSS = $.layout.showInvisibly($E); |
207 |
var val = parseInt($.curCSS($E[0], prop, true), 10) || 0; |
208 |
$E.css( CSS ); // RESET |
209 |
return val;
|
210 |
} |
211 |
|
212 |
, borderWidth: function (el, side) { |
213 |
if (el.jquery) el = el[0]; |
214 |
var b = "border"+ side.substr(0,1).toUpperCase() + side.substr(1); // left => Left |
215 |
return $.curCSS(el, b+"Style", true) == "none" ? 0 : (parseInt($.curCSS(el, b+"Width", true), 10) || 0); |
216 |
} |
217 |
|
218 |
}; |
219 |
|
220 |
$.fn.layout = function (opts) { |
221 |
|
222 |
/*
|
223 |
* ###########################
|
224 |
* WIDGET CONFIG & OPTIONS
|
225 |
* ###########################
|
226 |
*/
|
227 |
|
228 |
// LANGUAGE CUSTOMIZATION - will be *externally customizable* in next version
|
229 |
var lang = {
|
230 |
Pane: "Pane" |
231 |
, Open: "Open" // eg: "Open Pane" |
232 |
, Close: "Close" |
233 |
, Resize: "Resize" |
234 |
, Slide: "Slide Open" |
235 |
, Pin: "Pin" |
236 |
, Unpin: "Un-Pin" |
237 |
, selector: "selector" |
238 |
, msgNoRoom: "Not enough room to show this pane." |
239 |
, errContainerMissing: "UI Layout Initialization Error\n\nThe specified layout-container does not exist." |
240 |
, errCenterPaneMissing: "UI Layout Initialization Error\n\nThe center-pane element does not exist.\n\nThe center-pane is a required element." |
241 |
, errContainerHeight: "UI Layout Initialization Warning\n\nThe layout-container \"CONTAINER\" has no height.\n\nTherefore the layout is 0-height and hence 'invisible'!" |
242 |
, errButton: "Error Adding Button \n\nInvalid " |
243 |
}; |
244 |
|
245 |
// DEFAULT OPTIONS - CHANGE IF DESIRED
|
246 |
var options = {
|
247 |
name: "" // Not required, but useful for buttons and used for the state-cookie |
248 |
, scrollToBookmarkOnLoad: true // after creating a layout, scroll to bookmark in URL (.../page.htm#myBookmark) |
249 |
, resizeWithWindow: true // bind thisLayout.resizeAll() to the window.resize event |
250 |
, resizeWithWindowDelay: 200 // delay calling resizeAll because makes window resizing very jerky |
251 |
, resizeWithWindowMaxDelay: 0 // 0 = none - force resize every XX ms while window is being resized |
252 |
, onresizeall_start: null // CALLBACK when resizeAll() STARTS - NOT pane-specific |
253 |
, onresizeall_end: null // CALLBACK when resizeAll() ENDS - NOT pane-specific |
254 |
, onload: null // CALLBACK when Layout inits - after options initialized, but before elements |
255 |
, onunload: null // CALLBACK when Layout is destroyed OR onWindowUnload |
256 |
, autoBindCustomButtons: false // search for buttons with ui-layout-button class and auto-bind them |
257 |
, zIndex: null // the PANE zIndex - resizers and masks will be +1 |
258 |
// PANE SETTINGS
|
259 |
, defaults: { // default options for 'all panes' - will be overridden by 'per-pane settings' |
260 |
applyDemoStyles: false // NOTE: renamed from applyDefaultStyles for clarity |
261 |
, closable: true // pane can open & close |
262 |
, resizable: true // when open, pane can be resized |
263 |
, slidable: true // when closed, pane can 'slide open' over other panes - closes on mouse-out |
264 |
, initClosed: false // true = init pane as 'closed' |
265 |
, initHidden: false // true = init pane as 'hidden' - no resizer-bar/spacing |
266 |
// SELECTORS
|
267 |
//, paneSelector: "" // MUST be pane-specific - jQuery selector for pane
|
268 |
, contentSelector: ".ui-layout-content" // INNER div/element to auto-size so only it scrolls, not the entire pane! |
269 |
, contentIgnoreSelector: ".ui-layout-ignore" // element(s) to 'ignore' when measuring 'content' |
270 |
, findNestedContent: false // true = $P.find(contentSelector), false = $P.children(contentSelector) |
271 |
// GENERIC ROOT-CLASSES - for auto-generated classNames
|
272 |
, paneClass: "ui-layout-pane" // border-Pane - default: 'ui-layout-pane' |
273 |
, resizerClass: "ui-layout-resizer" // Resizer Bar - default: 'ui-layout-resizer' |
274 |
, togglerClass: "ui-layout-toggler" // Toggler Button - default: 'ui-layout-toggler' |
275 |
, buttonClass: "ui-layout-button" // CUSTOM Buttons - default: 'ui-layout-button-toggle/-open/-close/-pin' |
276 |
// ELEMENT SIZE & SPACING
|
277 |
//, size: 100 // MUST be pane-specific -initial size of pane
|
278 |
, minSize: 0 // when manually resizing a pane |
279 |
, maxSize: 0 // ditto, 0 = no limit |
280 |
, spacing_open: 6 // space between pane and adjacent panes - when pane is 'open' |
281 |
, spacing_closed: 6 // ditto - when pane is 'closed' |
282 |
, togglerLength_open: 50 // Length = WIDTH of toggler button on north/south sides - HEIGHT on east/west sides |
283 |
, togglerLength_closed: 50 // 100% OR -1 means 'full height/width of resizer bar' - 0 means 'hidden' |
284 |
, togglerAlign_open: "center" // top/left, bottom/right, center, OR... |
285 |
, togglerAlign_closed: "center" // 1 => nn = offset from top/left, -1 => -nn == offset from bottom/right |
286 |
, togglerTip_open: lang.Close // Toggler tool-tip (title) |
287 |
, togglerTip_closed: lang.Open // ditto |
288 |
, togglerContent_open: "" // text or HTML to put INSIDE the toggler |
289 |
, togglerContent_closed: "" // ditto |
290 |
// RESIZING OPTIONS
|
291 |
, resizerDblClickToggle: true // |
292 |
, autoResize: true // IF size is 'auto' or a percentage, then recalc 'pixel size' whenever the layout resizes |
293 |
, autoReopen: true // IF a pane was auto-closed due to noRoom, reopen it when there is room? False = leave it closed |
294 |
, resizerDragOpacity: 1 // option for ui.draggable |
295 |
//, resizerCursor: "" // MUST be pane-specific - cursor when over resizer-bar
|
296 |
, maskIframesOnResize: true // true = all iframes OR = iframe-selector(s) - adds masking-div during resizing/dragging |
297 |
, resizeNestedLayout: true // true = trigger nested.resizeAll() when a 'pane' of this layout is the 'container' for another |
298 |
, resizeWhileDragging: false // true = LIVE Resizing as resizer is dragged |
299 |
, resizeContentWhileDragging: false // true = re-measure header/footer heights as resizer is dragged |
300 |
// TIPS & MESSAGES - also see lang object
|
301 |
, noRoomToOpenTip: lang.msgNoRoom
|
302 |
, resizerTip: lang.Resize // Resizer tool-tip (title) |
303 |
, sliderTip: lang.Slide // resizer-bar triggers 'sliding' when pane is closed |
304 |
, sliderCursor: "pointer" // cursor when resizer-bar will trigger 'sliding' |
305 |
, slideTrigger_open: "click" // click, dblclick, mouseenter |
306 |
, slideTrigger_close: "mouseleave"// click, mouseleave |
307 |
, hideTogglerOnSlide: false // when pane is slid-open, should the toggler show? |
308 |
, preventQuickSlideClose: !!($.browser.webkit || $.browser.safari) // Chrome triggers slideClosed as is opening |
309 |
// HOT-KEYS & MISC
|
310 |
, showOverflowOnHover: false // will bind allowOverflow() utility to pane.onMouseOver |
311 |
, enableCursorHotkey: true // enabled 'cursor' hotkeys |
312 |
//, customHotkey: "" // MUST be pane-specific - EITHER a charCode OR a character
|
313 |
, customHotkeyModifier: "SHIFT" // either 'SHIFT', 'CTRL' or 'CTRL+SHIFT' - NOT 'ALT' |
314 |
// PANE ANIMATION
|
315 |
// NOTE: fxSss_open & fxSss_close options (eg: fxName_open) are auto-generated if not passed
|
316 |
, fxName: "slide" // ('none' or blank), slide, drop, scale |
317 |
, fxSpeed: null // slow, normal, fast, 200, nnn - if passed, will OVERRIDE fxSettings.duration |
318 |
, fxSettings: {} // can be passed, eg: { easing: "easeOutBounce", duration: 1500 } |
319 |
, fxOpacityFix: true // tries to fix opacity in IE to restore anti-aliasing after animation |
320 |
// CALLBACKS
|
321 |
, triggerEventsOnLoad: false // true = trigger onopen OR onclose callbacks when layout initializes |
322 |
, triggerEventsWhileDragging: true // true = trigger onresize callback REPEATEDLY if resizeWhileDragging==true |
323 |
, onshow_start: null // CALLBACK when pane STARTS to Show - BEFORE onopen/onhide_start |
324 |
, onshow_end: null // CALLBACK when pane ENDS being Shown - AFTER onopen/onhide_end |
325 |
, onhide_start: null // CALLBACK when pane STARTS to Close - BEFORE onclose_start |
326 |
, onhide_end: null // CALLBACK when pane ENDS being Closed - AFTER onclose_end |
327 |
, onopen_start: null // CALLBACK when pane STARTS to Open |
328 |
, onopen_end: null // CALLBACK when pane ENDS being Opened |
329 |
, onclose_start: null // CALLBACK when pane STARTS to Close |
330 |
, onclose_end: null // CALLBACK when pane ENDS being Closed |
331 |
, onresize_start: null // CALLBACK when pane STARTS being Resized ***FOR ANY REASON*** |
332 |
, onresize_end: null // CALLBACK when pane ENDS being Resized ***FOR ANY REASON*** |
333 |
, onsizecontent_start: null // CALLBACK when sizing of content-element STARTS |
334 |
, onsizecontent_end: null // CALLBACK when sizing of content-element ENDS |
335 |
, onswap_start: null // CALLBACK when pane STARTS to Swap |
336 |
, onswap_end: null // CALLBACK when pane ENDS being Swapped |
337 |
, ondrag_start: null // CALLBACK when pane STARTS being ***MANUALLY*** Resized |
338 |
, ondrag_end: null // CALLBACK when pane ENDS being ***MANUALLY*** Resized |
339 |
} |
340 |
, north: {
|
341 |
paneSelector: ".ui-layout-north" |
342 |
, size: "auto" // eg: "auto", "30%", 200 |
343 |
, resizerCursor: "n-resize" // custom = url(myCursor.cur) |
344 |
, customHotkey: "" // EITHER a charCode OR a character |
345 |
} |
346 |
, south: {
|
347 |
paneSelector: ".ui-layout-south" |
348 |
, size: "auto" |
349 |
, resizerCursor: "s-resize" |
350 |
, customHotkey: "" |
351 |
} |
352 |
, east: {
|
353 |
paneSelector: ".ui-layout-east" |
354 |
, size: 200 |
355 |
, resizerCursor: "e-resize" |
356 |
, customHotkey: "" |
357 |
} |
358 |
, west: {
|
359 |
paneSelector: ".ui-layout-west" |
360 |
, size: 200 |
361 |
, resizerCursor: "w-resize" |
362 |
, customHotkey: "" |
363 |
} |
364 |
, center: {
|
365 |
paneSelector: ".ui-layout-center" |
366 |
, minWidth: 0 |
367 |
, minHeight: 0 |
368 |
} |
369 |
|
370 |
// STATE MANAGMENT
|
371 |
, useStateCookie: false // Enable cookie-based state-management - can fine-tune with cookie.autoLoad/autoSave |
372 |
, cookie: {
|
373 |
name: "" // If not specified, will use Layout.name, else just "Layout" |
374 |
, autoSave: true // Save a state cookie when page exits? |
375 |
, autoLoad: true // Load the state cookie when Layout inits? |
376 |
// Cookie Options
|
377 |
, domain: "" |
378 |
, path: "" |
379 |
, expires: "" // 'days' to keep cookie - leave blank for 'session cookie' |
380 |
, secure: false |
381 |
// List of options to save in the cookie - must be pane-specific
|
382 |
, keys: "north.size,south.size,east.size,west.size,"+ |
383 |
"north.isClosed,south.isClosed,east.isClosed,west.isClosed,"+
|
384 |
"north.isHidden,south.isHidden,east.isHidden,west.isHidden"
|
385 |
} |
386 |
}; |
387 |
|
388 |
|
389 |
// PREDEFINED EFFECTS / DEFAULTS
|
390 |
var effects = { // LIST *PREDEFINED EFFECTS* HERE, even if effect has no settings |
391 |
slide: {
|
392 |
all: { duration: "fast" } // eg: duration: 1000, easing: "easeOutBounce" |
393 |
, north: { direction: "up" } |
394 |
, south: { direction: "down" } |
395 |
, east: { direction: "right"} |
396 |
, west: { direction: "left" } |
397 |
} |
398 |
, drop: {
|
399 |
all: { duration: "slow" } // eg: duration: 1000, easing: "easeOutQuint" |
400 |
, north: { direction: "up" } |
401 |
, south: { direction: "down" } |
402 |
, east: { direction: "right"} |
403 |
, west: { direction: "left" } |
404 |
} |
405 |
, scale: {
|
406 |
all: { duration: "fast" } |
407 |
} |
408 |
}; |
409 |
|
410 |
|
411 |
// DYNAMIC DATA - IS READ-ONLY EXTERNALLY!
|
412 |
var state = {
|
413 |
// generate unique ID to use for event.namespace so can unbind only events added by 'this layout'
|
414 |
id: "layout"+ new Date().getTime() // code uses alias: sID |
415 |
, initialized: false |
416 |
, container: {} // init all keys |
417 |
, north: {}
|
418 |
, south: {}
|
419 |
, east: {}
|
420 |
, west: {}
|
421 |
, center: {}
|
422 |
, cookie: {} // State Managment data storage |
423 |
}; |
424 |
|
425 |
|
426 |
// INTERNAL CONFIG DATA - DO NOT CHANGE THIS!
|
427 |
var _c = {
|
428 |
allPanes: "north,south,west,east,center" |
429 |
, borderPanes: "north,south,west,east" |
430 |
, altSide: {
|
431 |
north: "south" |
432 |
, south: "north" |
433 |
, east: "west" |
434 |
, west: "east" |
435 |
} |
436 |
// CSS used in multiple places
|
437 |
, hidden: { visibility: "hidden" } |
438 |
, visible: { visibility: "visible" } |
439 |
// layout element settings
|
440 |
, zIndex: { // set z-index values here |
441 |
pane_normal: 1 // normal z-index for panes |
442 |
, resizer_normal: 2 // normal z-index for resizer-bars |
443 |
, iframe_mask: 2 // overlay div used to mask pane(s) during resizing |
444 |
, pane_sliding: 100 // applied to *BOTH* the pane and its resizer when a pane is 'slid open' |
445 |
, pane_animate: 1000 // applied to the pane when being animated - not applied to the resizer |
446 |
, resizer_drag: 10000 // applied to the CLONED resizer-bar when being 'dragged' |
447 |
} |
448 |
, resizers: {
|
449 |
cssReq: {
|
450 |
position: "absolute" |
451 |
, padding: 0 |
452 |
, margin: 0 |
453 |
, fontSize: "1px" |
454 |
, textAlign: "left" // to counter-act "center" alignment! |
455 |
, overflow: "hidden" // prevent toggler-button from overflowing |
456 |
// SEE c.zIndex.resizer_normal
|
457 |
} |
458 |
, cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true |
459 |
background: "#DDD" |
460 |
, border: "none" |
461 |
} |
462 |
} |
463 |
, togglers: {
|
464 |
cssReq: {
|
465 |
position: "absolute" |
466 |
, display: "block" |
467 |
, padding: 0 |
468 |
, margin: 0 |
469 |
, overflow: "hidden" |
470 |
, textAlign: "center" |
471 |
, fontSize: "1px" |
472 |
, cursor: "pointer" |
473 |
, zIndex: 1 |
474 |
} |
475 |
, cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true |
476 |
background: "#AAA" |
477 |
} |
478 |
} |
479 |
, content: {
|
480 |
cssReq: {
|
481 |
position: "relative" /* contain floated or positioned elements */ |
482 |
} |
483 |
, cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true |
484 |
overflow: "auto" |
485 |
, padding: "10px" |
486 |
} |
487 |
, cssDemoPane: { // DEMO CSS - REMOVE scrolling from 'pane' when it has a content-div |
488 |
overflow: "hidden" |
489 |
, padding: 0 |
490 |
} |
491 |
} |
492 |
, panes: { // defaults for ALL panes - overridden by 'per-pane settings' below |
493 |
cssReq: {
|
494 |
position: "absolute" |
495 |
, margin: 0 |
496 |
// SEE c.zIndex.pane_normal
|
497 |
} |
498 |
, cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true |
499 |
padding: "10px" |
500 |
, background: "#FFF" |
501 |
, border: "1px solid #BBB" |
502 |
, overflow: "auto" |
503 |
} |
504 |
} |
505 |
, north: {
|
506 |
side: "Top" |
507 |
, sizeType: "Height" |
508 |
, dir: "horz" |
509 |
, cssReq: {
|
510 |
top: 0 |
511 |
, bottom: "auto" |
512 |
, left: 0 |
513 |
, right: 0 |
514 |
, width: "auto" |
515 |
// height: DYNAMIC
|
516 |
} |
517 |
, pins: [] // array of 'pin buttons' to be auto-updated on open/close (classNames) |
518 |
} |
519 |
, south: {
|
520 |
side: "Bottom" |
521 |
, sizeType: "Height" |
522 |
, dir: "horz" |
523 |
, cssReq: {
|
524 |
top: "auto" |
525 |
, bottom: 0 |
526 |
, left: 0 |
527 |
, right: 0 |
528 |
, width: "auto" |
529 |
// height: DYNAMIC
|
530 |
} |
531 |
, pins: []
|
532 |
} |
533 |
, east: {
|
534 |
side: "Right" |
535 |
, sizeType: "Width" |
536 |
, dir: "vert" |
537 |
, cssReq: {
|
538 |
left: "auto" |
539 |
, right: 0 |
540 |
, top: "auto" // DYNAMIC |
541 |
, bottom: "auto" // DYNAMIC |
542 |
, height: "auto" |
543 |
// width: DYNAMIC
|
544 |
} |
545 |
, pins: []
|
546 |
} |
547 |
, west: {
|
548 |
side: "Left" |
549 |
, sizeType: "Width" |
550 |
, dir: "vert" |
551 |
, cssReq: {
|
552 |
left: 0 |
553 |
, right: "auto" |
554 |
, top: "auto" // DYNAMIC |
555 |
, bottom: "auto" // DYNAMIC |
556 |
, height: "auto" |
557 |
// width: DYNAMIC
|
558 |
} |
559 |
, pins: []
|
560 |
} |
561 |
, center: {
|
562 |
dir: "center" |
563 |
, cssReq: {
|
564 |
left: "auto" // DYNAMIC |
565 |
, right: "auto" // DYNAMIC |
566 |
, top: "auto" // DYNAMIC |
567 |
, bottom: "auto" // DYNAMIC |
568 |
, height: "auto" |
569 |
, width: "auto" |
570 |
} |
571 |
} |
572 |
}; |
573 |
|
574 |
|
575 |
/*
|
576 |
* ###########################
|
577 |
* INTERNAL HELPER FUNCTIONS
|
578 |
* ###########################
|
579 |
*/
|
580 |
|
581 |
/**
|
582 |
* Manages all internal timers
|
583 |
*/
|
584 |
var timer = {
|
585 |
data: {}
|
586 |
, set: function (s, fn, ms) { timer.clear(s); timer.data[s] = setTimeout(fn, ms); } |
587 |
, clear: function (s) { var t=timer.data; if (t[s]) {clearTimeout(t[s]); delete t[s];} } |
588 |
}; |
589 |
|
590 |
/**
|
591 |
* Returns true if passed param is EITHER a simple string OR a 'string object' - otherwise returns false
|
592 |
*/
|
593 |
var isStr = function (o) { |
594 |
try { return typeof o == "string" |
595 |
|| (typeof o == "object" && o.constructor.toString().match(/string/i) !== null); } |
596 |
catch (e) { return false; } |
597 |
}; |
598 |
|
599 |
/**
|
600 |
* Returns a simple string if passed EITHER a simple string OR a 'string object',
|
601 |
* else returns the original object
|
602 |
*/
|
603 |
var str = function (o) { // trim converts 'String object' to a simple string |
604 |
return isStr(o) ? $.trim(o) : o == undefined || o == null ? "" : o; |
605 |
}; |
606 |
|
607 |
/**
|
608 |
* min / max
|
609 |
*
|
610 |
* Aliases for Math methods to simplify coding
|
611 |
*/
|
612 |
var min = function (x,y) { return Math.min(x,y); }; |
613 |
var max = function (x,y) { return Math.max(x,y); }; |
614 |
|
615 |
/**
|
616 |
* Processes the options passed in and transforms them into the format used by layout()
|
617 |
* Missing keys are added, and converts the data if passed in 'flat-format' (no sub-keys)
|
618 |
* In flat-format, pane-specific-settings are prefixed like: north__optName (2-underscores)
|
619 |
* To update effects, options MUST use nested-keys format, with an effects key ???
|
620 |
*
|
621 |
* @see initOptions()
|
622 |
* @param {Object} d Data/options passed by user - may be a single level or nested levels
|
623 |
* @return {Object} Creates a data struture that perfectly matches 'options', ready to be imported
|
624 |
*/
|
625 |
var _transformData = function (d) { |
626 |
var a, json = { cookie:{}, defaults:{fxSettings:{}}, north:{fxSettings:{}}, south:{fxSettings:{}}, east:{fxSettings:{}}, west:{fxSettings:{}}, center:{fxSettings:{}} }; |
627 |
d = d || {}; |
628 |
if (d.effects || d.cookie || d.defaults || d.north || d.south || d.west || d.east || d.center)
|
629 |
json = $.extend( true, json, d ); // already in json format - add to base keys |
630 |
else
|
631 |
// convert 'flat' to 'nest-keys' format - also handles 'empty' user-options
|
632 |
$.each( d, function (key,val) { |
633 |
a = key.split("__");
|
634 |
if (!a[1] || json[a[0]]) // check for invalid keys |
635 |
json[ a[1] ? a[0] : "defaults" ][ a[1] ? a[1] : a[0] ] = val; |
636 |
}); |
637 |
return json;
|
638 |
}; |
639 |
|
640 |
/**
|
641 |
* Set an INTERNAL callback to avoid simultaneous animation
|
642 |
* Runs only if needed and only if all callbacks are not 'already set'
|
643 |
* Called by open() and close() when isLayoutBusy=true
|
644 |
*
|
645 |
* @param {string} action Either 'open' or 'close'
|
646 |
* @param {string} pane A valid border-pane name, eg 'west'
|
647 |
* @param {boolean=} param Extra param for callback (optional)
|
648 |
*/
|
649 |
var _queue = function (action, pane, param) { |
650 |
var tried = [];
|
651 |
|
652 |
// if isLayoutBusy, then some pane must be 'moving'
|
653 |
$.each(_c.borderPanes.split(","), function (i, p) { |
654 |
if (_c[p].isMoving) {
|
655 |
bindCallback(p); // TRY to bind a callback
|
656 |
return false; // BREAK |
657 |
} |
658 |
}); |
659 |
|
660 |
// if pane does NOT have a callback, then add one, else follow the callback chain...
|
661 |
function bindCallback (p) { |
662 |
var c = _c[p];
|
663 |
if (!c.doCallback) {
|
664 |
c.doCallback = true;
|
665 |
c.callback = action +","+ pane +","+ (param ? 1 : 0); |
666 |
} |
667 |
else { // try to 'chain' this callback |
668 |
tried.push(p); |
669 |
var cbPane = c.callback.split(",")[1]; // 2nd param of callback is 'pane' |
670 |
// ensure callback target NOT 'itself' and NOT 'target pane' and NOT already tried (avoid loop)
|
671 |
if (cbPane != pane && !$.inArray(cbPane, tried) >= 0) |
672 |
bindCallback(cbPane); // RECURSE
|
673 |
} |
674 |
} |
675 |
}; |
676 |
|
677 |
/**
|
678 |
* RUN the INTERNAL callback for this pane - if one exists
|
679 |
*
|
680 |
* @param {string} pane A valid border-pane name, eg 'west'
|
681 |
*/
|
682 |
var _dequeue = function (pane) { |
683 |
var c = _c[pane];
|
684 |
|
685 |
// RESET flow-control flags
|
686 |
_c.isLayoutBusy = false;
|
687 |
delete c.isMoving;
|
688 |
if (!c.doCallback || !c.callback) return; |
689 |
|
690 |
c.doCallback = false; // RESET logic flag |
691 |
|
692 |
// EXECUTE the callback
|
693 |
var
|
694 |
cb = c.callback.split(",")
|
695 |
, param = (cb[2] > 0 ? true : false) |
696 |
; |
697 |
if (cb[0] == "open") |
698 |
open( cb[1], param );
|
699 |
else if (cb[0] == "close") |
700 |
close( cb[1], param );
|
701 |
|
702 |
if (!c.doCallback) c.callback = null; // RESET - unless callback above enabled it again! |
703 |
}; |
704 |
|
705 |
/**
|
706 |
* Executes a Callback function after a trigger event, like resize, open or close
|
707 |
*
|
708 |
* @param {?string} pane This is passed only so we can pass the 'pane object' to the callback
|
709 |
* @param {(string|function())} v_fn Accepts a function name, OR a comma-delimited array: [0]=function name, [1]=argument
|
710 |
*/
|
711 |
var _execCallback = function (pane, v_fn) { |
712 |
if (!v_fn) return; |
713 |
var fn;
|
714 |
try {
|
715 |
if (typeof v_fn == "function") |
716 |
fn = v_fn; |
717 |
else if (!isStr(v_fn)) |
718 |
return;
|
719 |
else if (v_fn.match(/,/)) { |
720 |
// function name cannot contain a comma, so must be a function name AND a 'name' parameter
|
721 |
var args = v_fn.split(","); |
722 |
fn = eval(args[0]);
|
723 |
if (typeof fn=="function" && args.length > 1) |
724 |
return fn(args[1]); // pass the argument parsed from 'list' |
725 |
} |
726 |
else // just the name of an external function? |
727 |
fn = eval(v_fn); |
728 |
|
729 |
if (typeof fn=="function") { |
730 |
if (pane && $Ps[pane]) |
731 |
// pass data: pane-name, pane-element, pane-state (copy), pane-options, and layout-name
|
732 |
return fn( pane, $Ps[pane], $.extend({},state[pane]), options[pane], options.name ); |
733 |
else // must be a layout/container callback - pass suitable info |
734 |
return fn( Instance, $.extend({},state), options, options.name ); |
735 |
} |
736 |
} |
737 |
catch (ex) {}
|
738 |
}; |
739 |
|
740 |
/**
|
741 |
* Returns hash container 'display' and 'visibility'
|
742 |
*
|
743 |
* @see $.swap() - swaps CSS, runs callback, resets CSS
|
744 |
* @param {!Object} $E
|
745 |
* @param {boolean=} force
|
746 |
*/
|
747 |
var _showInvisibly = function ($E, force) { |
748 |
if (!$E) return {}; |
749 |
if (!$E.jquery) $E = $($E); |
750 |
var CSS = {
|
751 |
display: $E.css('display') |
752 |
, visibility: $E.css('visibility') |
753 |
}; |
754 |
if (force || CSS.display == "none") { // only if not *already hidden* |
755 |
$E.css({ display: "block", visibility: "hidden" }); // show element 'invisibly' so can be measured |
756 |
return CSS;
|
757 |
} |
758 |
else return {}; |
759 |
}; |
760 |
|
761 |
/**
|
762 |
* cure iframe display issues in IE & other browsers
|
763 |
*/
|
764 |
var _fixIframe = function (pane) { |
765 |
if (state.browser.mozilla) return; // skip FireFox - it auto-refreshes iframes onShow |
766 |
var $P = $Ps[pane]; |
767 |
// if the 'pane' is an iframe, do it
|
768 |
if (state[pane].tagName == "IFRAME") |
769 |
$P.css(_c.hidden).css(_c.visible);
|
770 |
else // ditto for any iframes INSIDE the pane |
771 |
$P.find('IFRAME').css(_c.hidden).css(_c.visible); |
772 |
}; |
773 |
|
774 |
/**
|
775 |
* Returns the 'current CSS numeric value' for a CSS property - 0 if property does not exist
|
776 |
*
|
777 |
* @see Called by many methods
|
778 |
* @param {Array.<Object>} $E Must pass a jQuery object - first element is processed
|
779 |
* @param {string} prop The name of the CSS property, eg: top, width, etc.
|
780 |
* @return {(string|number)} Usually used to get an integer value for position (top, left) or size (height, width)
|
781 |
*/
|
782 |
var _cssNum = function ($E, prop) { |
783 |
if (!$E.jquery) $E = $($E); |
784 |
var CSS = _showInvisibly($E); |
785 |
var val = parseInt($.curCSS($E[0], prop, true), 10) || 0; |
786 |
$E.css( CSS ); // RESET |
787 |
return val;
|
788 |
}; |
789 |
|
790 |
/**
|
791 |
* @param {!Object} E Can accept a 'pane' (east, west, etc) OR a DOM object OR a jQuery object
|
792 |
* @param {string} side Which border (top, left, etc.) is resized
|
793 |
* @return {number} Returns the borderWidth
|
794 |
*/
|
795 |
var _borderWidth = function (E, side) { |
796 |
if (E.jquery) E = E[0]; |
797 |
var b = "border"+ side.substr(0,1).toUpperCase() + side.substr(1); // left => Left |
798 |
return $.curCSS(E, b+"Style", true) == "none" ? 0 : (parseInt($.curCSS(E, b+"Width", true), 10) || 0); |
799 |
}; |
800 |
|
801 |
/**
|
802 |
* cssW / cssH / cssSize / cssMinDims
|
803 |
*
|
804 |
* Contains logic to check boxModel & browser, and return the correct width/height for the current browser/doctype
|
805 |
*
|
806 |
* @see initPanes(), sizeMidPanes(), initHandles(), sizeHandles()
|
807 |
* @param {(string|!Object)} el Can accept a 'pane' (east, west, etc) OR a DOM object OR a jQuery object
|
808 |
* @param {number=} outerWidth (optional) Can pass a width, allowing calculations BEFORE element is resized
|
809 |
* @return {number} Returns the innerWidth of el by subtracting padding and borders
|
810 |
*/
|
811 |
var cssW = function (el, outerWidth) { |
812 |
var
|
813 |
str = isStr(el) |
814 |
, $E = str ? $Ps[el] : $(el) |
815 |
; |
816 |
if (isNaN(outerWidth)) // not specified |
817 |
outerWidth = str ? getPaneSize(el) : $E.outerWidth();
|
818 |
|
819 |
// a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed
|
820 |
if (outerWidth <= 0) return 0; |
821 |
|
822 |
if (!state.browser.boxModel) return outerWidth; |
823 |
|
824 |
// strip border and padding from outerWidth to get CSS Width
|
825 |
var W = outerWidth
|
826 |
- _borderWidth($E, "Left") |
827 |
- _borderWidth($E, "Right") |
828 |
- _cssNum($E, "paddingLeft") |
829 |
- _cssNum($E, "paddingRight") |
830 |
; |
831 |
|
832 |
return W > 0 ? W : 0; |
833 |
}; |
834 |
|
835 |
/**
|
836 |
* @param {(string|!Object)} el Can accept a 'pane' (east, west, etc) OR a DOM object OR a jQuery object
|
837 |
* @param {number=} outerHeight (optional) Can pass a width, allowing calculations BEFORE element is resized
|
838 |
* @return {number} Returns the innerHeight el by subtracting padding and borders
|
839 |
*/
|
840 |
var cssH = function (el, outerHeight) { |
841 |
var
|
842 |
str = isStr(el) |
843 |
, $E = str ? $Ps[el] : $(el) |
844 |
; |
845 |
if (isNaN(outerHeight)) // not specified |
846 |
outerHeight = str ? getPaneSize(el) : $E.outerHeight();
|
847 |
|
848 |
// a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed
|
849 |
if (outerHeight <= 0) return 0; |
850 |
|
851 |
if (!state.browser.boxModel) return outerHeight; |
852 |
|
853 |
// strip border and padding from outerHeight to get CSS Height
|
854 |
var H = outerHeight
|
855 |
- _borderWidth($E, "Top") |
856 |
- _borderWidth($E, "Bottom") |
857 |
- _cssNum($E, "paddingTop") |
858 |
- _cssNum($E, "paddingBottom") |
859 |
; |
860 |
|
861 |
return H > 0 ? H : 0; |
862 |
}; |
863 |
|
864 |
/**
|
865 |
* @param {string} pane Can accept ONLY a 'pane' (east, west, etc)
|
866 |
* @param {number=} outerSize (optional) Can pass a width, allowing calculations BEFORE element is resized
|
867 |
* @return {number} Returns the innerHeight/Width of el by subtracting padding and borders
|
868 |
*/
|
869 |
var cssSize = function (pane, outerSize) { |
870 |
if (_c[pane].dir=="horz") // pane = north or south |
871 |
return cssH(pane, outerSize);
|
872 |
else // pane = east or west |
873 |
return cssW(pane, outerSize);
|
874 |
}; |
875 |
|
876 |
var cssMinDims = function (pane) { |
877 |
// minWidth/Height means CSS width/height = 1px
|
878 |
var
|
879 |
dir = _c[pane].dir |
880 |
, d = { |
881 |
minWidth: 1001 - cssW(pane, 1000) |
882 |
, minHeight: 1001 - cssH(pane, 1000) |
883 |
} |
884 |
; |
885 |
if (dir == "horz") d.minSize = d.minHeight; |
886 |
if (dir == "vert") d.minSize = d.minWidth; |
887 |
return d;
|
888 |
}; |
889 |
|
890 |
// TODO: see if these methods can be made more useful...
|
891 |
// TODO: *maybe* return cssW/H from these so caller can use this info
|
892 |
|
893 |
/**
|
894 |
* @param {(string|!Object)} el
|
895 |
* @param {number=} outerWidth
|
896 |
* @param {boolean=} autoHide
|
897 |
*/
|
898 |
var setOuterWidth = function (el, outerWidth, autoHide) { |
899 |
var $E = el, w; |
900 |
if (isStr(el)) $E = $Ps[el]; // west |
901 |
else if (!el.jquery) $E = $(el); |
902 |
w = cssW($E, outerWidth);
|
903 |
$E.css({ width: w }); |
904 |
if (w > 0) { |
905 |
if (autoHide && $E.data('autoHidden') && $E.innerHeight() > 0) { |
906 |
$E.show().data('autoHidden', false); |
907 |
if (!state.browser.mozilla) // FireFox refreshes iframes - IE doesn't |
908 |
// make hidden, then visible to 'refresh' display after animation
|
909 |
$E.css(_c.hidden).css(_c.visible);
|
910 |
} |
911 |
} |
912 |
else if (autoHide && !$E.data('autoHidden')) |
913 |
$E.hide().data('autoHidden', true); |
914 |
}; |
915 |
|
916 |
/**
|
917 |
* @param {(string|!Object)} el
|
918 |
* @param {number=} outerHeight
|
919 |
* @param {boolean=} autoHide
|
920 |
*/
|
921 |
var setOuterHeight = function (el, outerHeight, autoHide) { |
922 |
var $E = el, h; |
923 |
if (isStr(el)) $E = $Ps[el]; // west |
924 |
else if (!el.jquery) $E = $(el); |
925 |
h = cssH($E, outerHeight);
|
926 |
$E.css({ height: h, visibility: "visible" }); // may have been 'hidden' by sizeContent |
927 |
if (h > 0 && $E.innerWidth() > 0) { |
928 |
if (autoHide && $E.data('autoHidden')) { |
929 |
$E.show().data('autoHidden', false); |
930 |
if (!state.browser.mozilla) // FireFox refreshes iframes - IE doesn't |
931 |
$E.css(_c.hidden).css(_c.visible);
|
932 |
} |
933 |
} |
934 |
else if (autoHide && !$E.data('autoHidden')) |
935 |
$E.hide().data('autoHidden', true); |
936 |
}; |
937 |
|
938 |
/**
|
939 |
* @param {(string|!Object)} el
|
940 |
* @param {number=} outerSize
|
941 |
* @param {boolean=} autoHide
|
942 |
*/
|
943 |
var setOuterSize = function (el, outerSize, autoHide) { |
944 |
if (_c[pane].dir=="horz") // pane = north or south |
945 |
setOuterHeight(el, outerSize, autoHide); |
946 |
else // pane = east or west |
947 |
setOuterWidth(el, outerSize, autoHide); |
948 |
}; |
949 |
|
950 |
|
951 |
/**
|
952 |
* Converts any 'size' params to a pixel/integer size, if not already
|
953 |
* If 'auto' or a decimal/percentage is passed as 'size', a pixel-size is calculated
|
954 |
*
|
955 |
/**
|
956 |
* @param {string} pane
|
957 |
* @param {(string|number)=} size
|
958 |
* @param {string=} dir
|
959 |
* @return {number}
|
960 |
*/
|
961 |
var _parseSize = function (pane, size, dir) { |
962 |
if (!dir) dir = _c[pane].dir;
|
963 |
|
964 |
if (isStr(size) && size.match(/%/)) |
965 |
size = parseInt(size, 10) / 100; // convert % to decimal |
966 |
|
967 |
if (size === 0) |
968 |
return 0; |
969 |
else if (size >= 1) |
970 |
return parseInt(size, 10); |
971 |
else if (size > 0) { // percentage, eg: .25 |
972 |
var o = options, avail;
|
973 |
if (dir=="horz") // north or south or center.minHeight |
974 |
avail = sC.innerHeight - ($Ps.north ? o.north.spacing_open : 0) - ($Ps.south ? o.south.spacing_open : 0); |
975 |
else if (dir=="vert") // east or west or center.minWidth |
976 |
avail = sC.innerWidth - ($Ps.west ? o.west.spacing_open : 0) - ($Ps.east ? o.east.spacing_open : 0); |
977 |
return Math.floor(avail * size);
|
978 |
} |
979 |
else if (pane=="center") |
980 |
return 0; |
981 |
else { // size < 0 || size=='auto' || size==Missing || size==Invalid |
982 |
// auto-size the pane
|
983 |
var
|
984 |
$P = $Ps[pane] |
985 |
, dim = (dir == "horz" ? "height" : "width") |
986 |
, vis = _showInvisibly($P) // show pane invisibly if hidden |
987 |
, s = $P.css(dim); // SAVE current size |
988 |
; |
989 |
$P.css(dim, "auto"); |
990 |
size = (dim == "height") ? $P.outerHeight() : $P.outerWidth(); // MEASURE |
991 |
$P.css(dim, s).css(vis); // RESET size & visibility |
992 |
return size;
|
993 |
} |
994 |
}; |
995 |
|
996 |
/**
|
997 |
* Calculates current 'size' (outer-width or outer-height) of a border-pane - optionally with 'pane-spacing' added
|
998 |
*
|
999 |
* @param {(string|!Object)} pane
|
1000 |
* @param {boolean=} inclSpace
|
1001 |
* @return {number} Returns EITHER Width for east/west panes OR Height for north/south panes - adjusted for boxModel & browser
|
1002 |
*/
|
1003 |
var getPaneSize = function (pane, inclSpace) { |
1004 |
var
|
1005 |
$P = $Ps[pane] |
1006 |
, o = options[pane] |
1007 |
, s = state[pane] |
1008 |
, oSp = (inclSpace ? o.spacing_open : 0)
|
1009 |
, cSp = (inclSpace ? o.spacing_closed : 0)
|
1010 |
; |
1011 |
if (!$P || s.isHidden) |
1012 |
return 0; |
1013 |
else if (s.isClosed || (s.isSliding && inclSpace)) |
1014 |
return cSp;
|
1015 |
else if (_c[pane].dir == "horz") |
1016 |
return $P.outerHeight() + oSp; |
1017 |
else // dir == "vert" |
1018 |
return $P.outerWidth() + oSp; |
1019 |
}; |
1020 |
|
1021 |
/**
|
1022 |
* Calculate min/max pane dimensions and limits for resizing
|
1023 |
*
|
1024 |
* @param {string} pane
|
1025 |
* @param {boolean=} slide
|
1026 |
*/
|
1027 |
var setSizeLimits = function (pane, slide) { |
1028 |
var
|
1029 |
o = options[pane] |
1030 |
, s = state[pane] |
1031 |
, c = _c[pane] |
1032 |
, dir = c.dir |
1033 |
, side = c.side.toLowerCase() |
1034 |
, type = c.sizeType.toLowerCase() |
1035 |
, isSliding = (slide != undefined ? slide : s.isSliding) // only open() passes 'slide' param |
1036 |
, $P = $Ps[pane] |
1037 |
, paneSpacing = o.spacing_open |
1038 |
// measure the pane on the *opposite side* from this pane
|
1039 |
, altPane = _c.altSide[pane] |
1040 |
, altS = state[altPane] |
1041 |
, $altP = $Ps[altPane] |
1042 |
, altPaneSize = (!$altP || altS.isVisible===false || altS.isSliding ? 0 : (dir=="horz" ? $altP.outerHeight() : $altP.outerWidth())) |
1043 |
, altPaneSpacing = ((!$altP || altS.isHidden ? 0 : options[altPane][ altS.isClosed !== false ? "spacing_closed" : "spacing_open" ]) || 0) |
1044 |
// limitSize prevents this pane from 'overlapping' opposite pane
|
1045 |
, containerSize = (dir=="horz" ? sC.innerHeight : sC.innerWidth)
|
1046 |
, minCenterDims = cssMinDims("center")
|
1047 |
, minCenterSize = dir=="horz" ? max(options.center.minHeight, minCenterDims.minHeight) : max(options.center.minWidth, minCenterDims.minWidth)
|
1048 |
// if pane is 'sliding', then ignore center and alt-pane sizes - because 'overlays' them
|
1049 |
, limitSize = (containerSize - paneSpacing - (isSliding ? 0 : (_parseSize("center", minCenterSize, dir) + altPaneSize + altPaneSpacing))) |
1050 |
, minSize = s.minSize = max( _parseSize(pane, o.minSize), cssMinDims(pane).minSize ) |
1051 |
, maxSize = s.maxSize = min( (o.maxSize ? _parseSize(pane, o.maxSize) : 100000), limitSize )
|
1052 |
, r = s.resizerPosition = {} // used to set resizing limits
|
1053 |
, top = sC.insetTop |
1054 |
, left = sC.insetLeft |
1055 |
, W = sC.innerWidth |
1056 |
, H = sC.innerHeight |
1057 |
, rW = o.spacing_open // subtract resizer-width to get top/left position for south/east
|
1058 |
; |
1059 |
switch (pane) {
|
1060 |
case "north": r.min = top + minSize; |
1061 |
r.max = top + maxSize; |
1062 |
break;
|
1063 |
case "west": r.min = left + minSize; |
1064 |
r.max = left + maxSize; |
1065 |
break;
|
1066 |
case "south": r.min = top + H - maxSize - rW; |
1067 |
r.max = top + H - minSize - rW; |
1068 |
break;
|
1069 |
case "east": r.min = left + W - maxSize - rW; |
1070 |
r.max = left + W - minSize - rW; |
1071 |
break;
|
1072 |
}; |
1073 |
}; |
1074 |
|
1075 |
/**
|
1076 |
* Returns data for setting the size/position of center pane. Also used to set Height for east/west panes
|
1077 |
*
|
1078 |
* @return JSON Returns a hash of all dimensions: top, bottom, left, right, (outer) width and (outer) height
|
1079 |
*/
|
1080 |
var calcNewCenterPaneDims = function () { |
1081 |
var d = {
|
1082 |
top: getPaneSize("north", true) // true = include 'spacing' value for pane |
1083 |
, bottom: getPaneSize("south", true) |
1084 |
, left: getPaneSize("west", true) |
1085 |
, right: getPaneSize("east", true) |
1086 |
, width: 0 |
1087 |
, height: 0 |
1088 |
}; |
1089 |
|
1090 |
// NOTE: sC = state.container
|
1091 |
// calc center-pane's outer dimensions
|
1092 |
d.width = sC.innerWidth - d.left - d.right; // outerWidth
|
1093 |
d.height = sC.innerHeight - d.bottom - d.top; // outerHeight
|
1094 |
// add the 'container border/padding' to get final positions relative to the container
|
1095 |
d.top += sC.insetTop; |
1096 |
d.bottom += sC.insetBottom; |
1097 |
d.left += sC.insetLeft; |
1098 |
d.right += sC.insetRight; |
1099 |
|
1100 |
return d;
|
1101 |
}; |
1102 |
|
1103 |
|
1104 |
/**
|
1105 |
* Returns data for setting size of an element (container or a pane).
|
1106 |
*
|
1107 |
* @see _create(), onWindowResize() for container, plus others for pane
|
1108 |
* @return JSON Returns a hash of all dimensions: top, bottom, left, right, outerWidth, innerHeight, etc
|
1109 |
*/
|
1110 |
var getElemDims = function ($E) { |
1111 |
var
|
1112 |
d = {} // dimensions hash
|
1113 |
, x = d.css = {} // CSS hash
|
1114 |
, i = {} // TEMP insets
|
1115 |
, b, p // TEMP border, padding
|
1116 |
, off = $E.offset()
|
1117 |
; |
1118 |
d.offsetLeft = off.left; |
1119 |
d.offsetTop = off.top; |
1120 |
|
1121 |
$.each("Left,Right,Top,Bottom".split(","), function (idx, e) { |
1122 |
b = x["border" + e] = _borderWidth($E, e); |
1123 |
p = x["padding"+ e] = _cssNum($E, "padding"+e); |
1124 |
i[e] = b + p; // total offset of content from outer side
|
1125 |
d["inset"+ e] = p;
|
1126 |
/* WRONG ???
|
1127 |
// if BOX MODEL, then 'position' = PADDING (ignore borderWidth)
|
1128 |
if ($E == $Container)
|
1129 |
d["inset"+ e] = (state.browser.boxModel ? p : 0);
|
1130 |
*/
|
1131 |
}); |
1132 |
|
1133 |
d.offsetWidth = $E.innerWidth(); // true=include Padding |
1134 |
d.offsetHeight = $E.innerHeight();
|
1135 |
d.outerWidth = $E.outerWidth();
|
1136 |
d.outerHeight = $E.outerHeight();
|
1137 |
d.innerWidth = d.outerWidth - i.Left - i.Right; |
1138 |
d.innerHeight = d.outerHeight - i.Top - i.Bottom; |
1139 |
|
1140 |
// TESTING
|
1141 |
x.width = $E.width();
|
1142 |
x.height = $E.height();
|
1143 |
|
1144 |
return d;
|
1145 |
}; |
1146 |
|
1147 |
var getElemCSS = function ($E, list) { |
1148 |
var
|
1149 |
CSS = {} |
1150 |
, style = $E[0].style |
1151 |
, props = list.split(",")
|
1152 |
, sides = "Top,Bottom,Left,Right".split(",") |
1153 |
, attrs = "Color,Style,Width".split(",") |
1154 |
, p, s, a, i, j, k |
1155 |
; |
1156 |
for (i=0; i < props.length; i++) { |
1157 |
p = props[i]; |
1158 |
if (p.match(/(border|padding|margin)$/)) |
1159 |
for (j=0; j < 4; j++) { |
1160 |
s = sides[j]; |
1161 |
if (p == "border") |
1162 |
for (k=0; k < 3; k++) { |
1163 |
a = attrs[k]; |
1164 |
CSS[p+s+a] = style[p+s+a]; |
1165 |
} |
1166 |
else
|
1167 |
CSS[p+s] = style[p+s]; |
1168 |
} |
1169 |
else
|
1170 |
CSS[p] = style[p]; |
1171 |
}; |
1172 |
return CSS
|
1173 |
}; |
1174 |
|
1175 |
|
1176 |
/**
|
1177 |
* @param {!Object} el
|
1178 |
* @param {boolean=} allStates
|
1179 |
*/
|
1180 |
var getHoverClasses = function (el, allStates) { |
1181 |
var
|
1182 |
$El = $(el) |
1183 |
, type = $El.data("layoutRole") |
1184 |
, pane = $El.data("layoutEdge") |
1185 |
, o = options[pane] |
1186 |
, root = o[type +"Class"]
|
1187 |
, _pane = "-"+ pane // eg: "-west" |
1188 |
, _open = "-open"
|
1189 |
, _closed = "-closed"
|
1190 |
, _slide = "-sliding"
|
1191 |
, _hover = "-hover " // NOTE the trailing space |
1192 |
, _state = $El.hasClass(root+_closed) ? _closed : _open
|
1193 |
, _alt = _state == _closed ? _open : _closed |
1194 |
, classes = (root+_hover) + (root+_pane+_hover) + (root+_state+_hover) + (root+_pane+_state+_hover) |
1195 |
; |
1196 |
if (allStates) // when 'removing' classes, also remove alternate-state classes |
1197 |
classes += (root+_alt+_hover) + (root+_pane+_alt+_hover); |
1198 |
|
1199 |
if (type=="resizer" && $El.hasClass(root+_slide)) |
1200 |
classes += (root+_slide+_hover) + (root+_pane+_slide+_hover); |
1201 |
|
1202 |
return $.trim(classes); |
1203 |
}; |
1204 |
var addHover = function (evt, el) { |
1205 |
var e = el || this; |
1206 |
$(e).addClass( getHoverClasses(e) );
|
1207 |
//if (evt && $(e).data("layoutRole") == "toggler") evt.stopPropagation();
|
1208 |
}; |
1209 |
var removeHover = function (evt, el) { |
1210 |
var e = el || this; |
1211 |
$(e).removeClass( getHoverClasses(e, true) ); |
1212 |
}; |
1213 |
|
1214 |
var onResizerEnter = function (evt) { |
1215 |
$('body').disableSelection(); |
1216 |
addHover(evt, this);
|
1217 |
}; |
1218 |
var onResizerLeave = function (evt, el) { |
1219 |
var
|
1220 |
e = el || this // el is only passed when called by the timer |
1221 |
, pane = $(e).data("layoutEdge") |
1222 |
, name = pane +"ResizerLeave"
|
1223 |
; |
1224 |
timer.clear(name); |
1225 |
if (!el) { // 1st call - mouseleave event |
1226 |
removeHover(evt, this); // do this on initial call |
1227 |
// this method calls itself on a timer because it needs to allow
|
1228 |
// enough time for dragging to kick-in and set the isResizing flag
|
1229 |
// dragging has a 100ms delay set, so this delay must be higher
|
1230 |
timer.set(name, function(){ onResizerLeave(evt, e); }, 200); |
1231 |
} |
1232 |
// if user is resizing, then dragStop will enableSelection() when done
|
1233 |
else if (!state[pane].isResizing) // 2nd call - by timer |
1234 |
$('body').enableSelection(); |
1235 |
}; |
1236 |
|
1237 |
/*
|
1238 |
* ###########################
|
1239 |
* INITIALIZATION METHODS
|
1240 |
* ###########################
|
1241 |
*/
|
1242 |
|
1243 |
/**
|
1244 |
* Initialize the layout - called automatically whenever an instance of layout is created
|
1245 |
*
|
1246 |
* @see none - triggered onInit
|
1247 |
* @return An object pointer to the instance created
|
1248 |
*/
|
1249 |
var _create = function () { |
1250 |
// initialize config/options
|
1251 |
initOptions(); |
1252 |
var o = options;
|
1253 |
|
1254 |
// onload will CANCEL resizing if returns false
|
1255 |
if (false === _execCallback(null, o.onload)) return false; |
1256 |
|
1257 |
// a center pane is required, so make sure it exists
|
1258 |
if (!getPane('center').length) { |
1259 |
alert( lang.errCenterPaneMissing ); |
1260 |
return null; |
1261 |
} |
1262 |
|
1263 |
// update options with saved state, if option enabled
|
1264 |
if (o.useStateCookie && o.cookie.autoLoad)
|
1265 |
loadCookie(); // Update options from state-cookie
|
1266 |
|
1267 |
// set environment - can update code here if $.browser is phased out
|
1268 |
state.browser = { |
1269 |
mozilla: $.browser.mozilla |
1270 |
, webkit: $.browser.webkit || $.browser.safari |
1271 |
, msie: $.browser.msie |
1272 |
, isIE6: $.browser.msie && $.browser.version == 6 |
1273 |
, boxModel: $.support.boxModel |
1274 |
//, version: $.browser.version - not used
|
1275 |
}; |
1276 |
|
1277 |
// initialize all layout elements
|
1278 |
initContainer(); // set CSS as needed and init state.container dimensions
|
1279 |
initPanes(); // size & position all panes - calls initHandles()
|
1280 |
//initHandles(); // create and position all resize bars & togglers buttons
|
1281 |
initResizable(); // activate resizing on all panes where resizable=true
|
1282 |
sizeContent(); // AFTER panes & handles have been initialized, size 'content' divs
|
1283 |
|
1284 |
if (o.scrollToBookmarkOnLoad) {
|
1285 |
var l = self.location;
|
1286 |
if (l.hash) l.replace( l.hash ); // scrollTo Bookmark |
1287 |
} |
1288 |
|
1289 |
// search for and bind custom-buttons
|
1290 |
if (o.autoBindCustomButtons) initButtons();
|
1291 |
|
1292 |
// bind hotkey function - keyDown - if required
|
1293 |
initHotkeys(); |
1294 |
|
1295 |
// bind resizeAll() for 'this layout instance' to window.resize event
|
1296 |
if (o.resizeWithWindow && !$Container.data("layoutRole")) // skip if 'nested' inside a pane |
1297 |
$(window).bind("resize."+ sID, windowResize); |
1298 |
|
1299 |
// bind window.onunload
|
1300 |
$(window).bind("unload."+ sID, unload); |
1301 |
|
1302 |
state.initialized = true;
|
1303 |
}; |
1304 |
|
1305 |
var windowResize = function () { |
1306 |
var delay = Number(options.resizeWithWindowDelay) || 100; // there MUST be some delay! |
1307 |
if (delay > 0) { |
1308 |
// resizing uses a delay-loop because the resize event fires repeatly - except in FF, but delay anyway
|
1309 |
timer.clear("winResize"); // if already running |
1310 |
timer.set("winResize", function(){ timer.clear("winResize"); timer.clear("winResizeRepeater"); resizeAll(); }, delay); |
1311 |
// ALSO set fixed-delay timer, if not already running
|
1312 |
if (!timer.data["winResizeRepeater"]) setWindowResizeRepeater(); |
1313 |
} |
1314 |
}; |
1315 |
|
1316 |
var setWindowResizeRepeater = function () { |
1317 |
var delay = Number(options.resizeWithWindowMaxDelay);
|
1318 |
if (delay > 0) |
1319 |
timer.set("winResizeRepeater", function(){ setWindowResizeRepeater(); resizeAll(); }, delay); |
1320 |
}; |
1321 |
|
1322 |
var unload = function () { |
1323 |
var o = options;
|
1324 |
state.cookie = getState(); // save state in case onunload has custom state-management
|
1325 |
if (o.useStateCookie && o.cookie.autoSave) saveCookie();
|
1326 |
|
1327 |
_execCallback(null, o.onunload);
|
1328 |
}; |
1329 |
|
1330 |
/**
|
1331 |
* Validate and initialize container CSS and events
|
1332 |
*
|
1333 |
* @see _create()
|
1334 |
*/
|
1335 |
var initContainer = function () { |
1336 |
var
|
1337 |
$C = $Container // alias |
1338 |
, tag = sC.tagName = $C.attr("tagName") |
1339 |
, fullPage= (tag == "BODY")
|
1340 |
, props = "position,margin,padding,border"
|
1341 |
, CSS = {} |
1342 |
; |
1343 |
sC.selector = $C.selector.split(".slice")[0]; |
1344 |
sC.ref = tag +"/"+ sC.selector; // used in messages |
1345 |
|
1346 |
// the layoutContainer key is used to store the unique layoutID
|
1347 |
$C
|
1348 |
.data("layoutContainer", sID) // unique identifier for internal use |
1349 |
.data("layoutName", options.name) // add user's layout-name - even if blank! |
1350 |
; |
1351 |
|
1352 |
// SAVE original container CSS for use in destroy()
|
1353 |
if (!$C.data("layoutCSS")) { |
1354 |
// handle props like overflow different for BODY & HTML - has 'system default' values
|
1355 |
if (fullPage) {
|
1356 |
CSS = $.extend( getElemCSS($C, props), { |
1357 |
height: $C.css("height") |
1358 |
, overflow: $C.css("overflow") |
1359 |
, overflowX: $C.css("overflowX") |
1360 |
, overflowY: $C.css("overflowY") |
1361 |
}); |
1362 |
// ALSO SAVE <HTML> CSS
|
1363 |
var $H = $("html"); |
1364 |
$H.data("layoutCSS", { |
1365 |
height: "auto" // FF would return a fixed px-size! |
1366 |
, overflow: $H.css("overflow") |
1367 |
, overflowX: $H.css("overflowX") |
1368 |
, overflowY: $H.css("overflowY") |
1369 |
}); |
1370 |
} |
1371 |
else // handle props normally for non-body elements |
1372 |
CSS = getElemCSS($C, props+",top,bottom,left,right,width,height,overflow,overflowX,overflowY"); |
1373 |
|
1374 |
$C.data("layoutCSS", CSS); |
1375 |
} |
1376 |
|
1377 |
try { // format html/body if this is a full page layout |
1378 |
if (fullPage) {
|
1379 |
$("html").css({ |
1380 |
height: "100%" |
1381 |
, overflow: "hidden" |
1382 |
, overflowX: "hidden" |
1383 |
, overflowY: "hidden" |
1384 |
}); |
1385 |
$("body").css({ |
1386 |
position: "relative" |
1387 |
, height: "100%" |
1388 |
, overflow: "hidden" |
1389 |
, overflowX: "hidden" |
1390 |
, overflowY: "hidden" |
1391 |
, margin: 0 |
1392 |
, padding: 0 // TODO: test whether body-padding could be handled? |
1393 |
, border: "none" // a body-border creates problems because it cannot be measured! |
1394 |
}); |
1395 |
} |
1396 |
else { // set required CSS for overflow and position |
1397 |
CSS = { overflow: "hidden" } // make sure container will not 'scroll' |
1398 |
var
|
1399 |
p = $C.css("position") |
1400 |
, h = $C.css("height") |
1401 |
; |
1402 |
// if this is a NESTED layout, then container/outer-pane ALREADY has position and height
|
1403 |
if (!$C.data("layoutRole")) { |
1404 |
if (!p || !p.match(/fixed|absolute|relative/)) |
1405 |
CSS.position = "relative"; // container MUST have a 'position' |
1406 |
/*
|
1407 |
if (!h || h=="auto")
|
1408 |
CSS.height = "100%"; // container MUST have a 'height'
|
1409 |
*/
|
1410 |
} |
1411 |
$C.css( CSS );
|
1412 |
|
1413 |
if ($C.is(":visible") && $C.innerHeight() < 2) |
1414 |
alert( lang.errContainerHeight.replace(/CONTAINER/, sC.ref) );
|
1415 |
} |
1416 |
} catch (ex) {}
|
1417 |
|
1418 |
// set current layout-container dimensions
|
1419 |
$.extend(state.container, getElemDims( $C )); |
1420 |
}; |
1421 |
|
1422 |
/**
|
1423 |
* Bind layout hotkeys - if options enabled
|
1424 |
*
|
1425 |
* @see _create()
|
1426 |
*/
|
1427 |
var initHotkeys = function () { |
1428 |
// bind keyDown to capture hotkeys, if option enabled for ANY pane
|
1429 |
$.each(_c.borderPanes.split(","), function (i, pane) { |
1430 |
var o = options[pane];
|
1431 |
if (o.enableCursorHotkey || o.customHotkey) {
|
1432 |
$(document).bind("keydown."+ sID, keyDown); // only need to bind this ONCE |
1433 |
return false; // BREAK - binding was done |
1434 |
} |
1435 |
}); |
1436 |
}; |
1437 |
|
1438 |
/**
|
1439 |
* Build final OPTIONS data
|
1440 |
*
|
1441 |
* @see _create()
|
1442 |
*/
|
1443 |
var initOptions = function () { |
1444 |
// simplify logic by making sure passed 'opts' var has basic keys
|
1445 |
opts = _transformData( opts ); |
1446 |
|
1447 |
// TODO: create a compatibility add-on for new UI widget that will transform old option syntax
|
1448 |
var newOpts = {
|
1449 |
applyDefaultStyles: "applyDemoStyles" |
1450 |
}; |
1451 |
renameOpts(opts.defaults); |
1452 |
$.each(_c.allPanes.split(","), function (i, pane) { |
1453 |
renameOpts(opts[pane]); |
1454 |
}); |
1455 |
|
1456 |
// update default effects, if case user passed key
|
1457 |
if (opts.effects) {
|
1458 |
$.extend( effects, opts.effects );
|
1459 |
delete opts.effects;
|
1460 |
} |
1461 |
$.extend( options.cookie, opts.cookie );
|
1462 |
|
1463 |
// see if any 'global options' were specified
|
1464 |
var globals = "name,zIndex,scrollToBookmarkOnLoad,resizeWithWindow,resizeWithWindowDelay,resizeWithWindowMaxDelay,"+ |
1465 |
"onresizeall,onresizeall_start,onresizeall_end,onload,onunload,autoBindCustomButtons,useStateCookie";
|
1466 |
$.each(globals.split(","), function (i, key) { |
1467 |
if (opts[key] !== undefined) |
1468 |
options[key] = opts[key]; |
1469 |
else if (opts.defaults[key] !== undefined) { |
1470 |
options[key] = opts.defaults[key]; |
1471 |
delete opts.defaults[key];
|
1472 |
} |
1473 |
}); |
1474 |
|
1475 |
// remove any 'defaults' that MUST be set 'per-pane'
|
1476 |
$.each("paneSelector,resizerCursor,customHotkey".split(","), |
1477 |
function (i, key) { delete opts.defaults[key]; } // is OK if key does not exist |
1478 |
); |
1479 |
|
1480 |
// now update options.defaults
|
1481 |
$.extend( true, options.defaults, opts.defaults ); |
1482 |
|
1483 |
// merge config for 'center-pane' - border-panes handled in the loop below
|
1484 |
_c.center = $.extend( true, {}, _c.panes, _c.center ); |
1485 |
// update config.zIndex values if zIndex option specified
|
1486 |
var z = options.zIndex;
|
1487 |
if (z === 0 || z > 0) { |
1488 |
_c.zIndex.pane_normal = z; |
1489 |
_c.zIndex.resizer_normal = z+1;
|
1490 |
_c.zIndex.iframe_mask = z+1;
|
1491 |
} |
1492 |
|
1493 |
// merge options for 'center-pane' - border-panes handled in the loop below
|
1494 |
$.extend( options.center, opts.center );
|
1495 |
// Most 'default options' do not apply to 'center', so add only those that DO
|
1496 |
var o_Center = $.extend( true, {}, options.defaults, opts.defaults, options.center ); // TEMP data |
1497 |
var optionsCenter = ("paneClass,contentSelector,applyDemoStyles,triggerEventsOnLoad,showOverflowOnHover," |
1498 |
+ "onresize,onresize_start,onresize_end,resizeNestedLayout,resizeContentWhileDragging,"
|
1499 |
+ "onsizecontent,onsizecontent_start,onsizecontent_end").split(","); |
1500 |
$.each(optionsCenter,
|
1501 |
function (i, key) { options.center[key] = o_Center[key]; }
|
1502 |
); |
1503 |
|
1504 |
var o, defs = options.defaults;
|
1505 |
|
1506 |
// create a COMPLETE set of options for EACH border-pane
|
1507 |
$.each(_c.borderPanes.split(","), function (i, pane) { |
1508 |
|
1509 |
// apply 'pane-defaults' to CONFIG.[PANE]
|
1510 |
_c[pane] = $.extend( true, {}, _c.panes, _c[pane] ); |
1511 |
|
1512 |
// apply 'pane-defaults' + user-options to OPTIONS.PANE
|
1513 |
o = options[pane] = $.extend( true, {}, options.defaults, options[pane], opts.defaults, opts[pane] ); |
1514 |
|
1515 |
// make sure we have base-classes
|
1516 |
if (!o.paneClass) o.paneClass = "ui-layout-pane"; |
1517 |
if (!o.resizerClass) o.resizerClass = "ui-layout-resizer"; |
1518 |
if (!o.togglerClass) o.togglerClass = "ui-layout-toggler"; |
1519 |
|
1520 |
// create FINAL fx options for each pane, ie: options.PANE.fxName/fxSpeed/fxSettings[_open|_close]
|
1521 |
$.each(["_open","_close",""], function (i,n) { |
1522 |
var
|
1523 |
sName = "fxName"+n
|
1524 |
, sSpeed = "fxSpeed"+n
|
1525 |
, sSettings = "fxSettings"+n
|
1526 |
; |
1527 |
// recalculate fxName according to specificity rules
|
1528 |
o[sName] = |
1529 |
opts[pane][sName] // opts.west.fxName_open
|
1530 |
|| opts[pane].fxName // opts.west.fxName
|
1531 |
|| opts.defaults[sName] // opts.defaults.fxName_open
|
1532 |
|| opts.defaults.fxName // opts.defaults.fxName
|
1533 |
|| o[sName] // options.west.fxName_open
|
1534 |
|| o.fxName // options.west.fxName
|
1535 |
|| defs[sName] // options.defaults.fxName_open
|
1536 |
|| defs.fxName // options.defaults.fxName
|
1537 |
|| "none"
|
1538 |
; |
1539 |
// validate fxName to be sure is a valid effect
|
1540 |
var fxName = o[sName];
|
1541 |
if (fxName == "none" || !$.effects || !$.effects[fxName] || (!effects[fxName] && !o[sSettings] && !o.fxSettings)) |
1542 |
fxName = o[sName] = "none"; // effect not loaded, OR undefined FX AND fxSettings not passed |
1543 |
// set vars for effects subkeys to simplify logic
|
1544 |
var
|
1545 |
fx = effects[fxName] || {} // effects.slide
|
1546 |
, fx_all = fx.all || {} // effects.slide.all
|
1547 |
, fx_pane = fx[pane] || {} // effects.slide.west
|
1548 |
; |
1549 |
// RECREATE the fxSettings[_open|_close] keys using specificity rules
|
1550 |
o[sSettings] = $.extend(
|
1551 |
{} |
1552 |
, fx_all // effects.slide.all
|
1553 |
, fx_pane // effects.slide.west
|
1554 |
, defs.fxSettings || {} // options.defaults.fxSettings
|
1555 |
, defs[sSettings] || {} // options.defaults.fxSettings_open
|
1556 |
, o.fxSettings // options.west.fxSettings
|
1557 |
, o[sSettings] // options.west.fxSettings_open
|
1558 |
, opts.defaults.fxSettings // opts.defaults.fxSettings
|
1559 |
, opts.defaults[sSettings] || {} // opts.defaults.fxSettings_open
|
1560 |
, opts[pane].fxSettings // opts.west.fxSettings
|
1561 |
, opts[pane][sSettings] || {} // opts.west.fxSettings_open
|
1562 |
); |
1563 |
// recalculate fxSpeed according to specificity rules
|
1564 |
o[sSpeed] = |
1565 |
opts[pane][sSpeed] // opts.west.fxSpeed_open
|
1566 |
|| opts[pane].fxSpeed // opts.west.fxSpeed (pane-default)
|
1567 |
|| opts.defaults[sSpeed] // opts.defaults.fxSpeed_open
|
1568 |
|| opts.defaults.fxSpeed // opts.defaults.fxSpeed
|
1569 |
|| o[sSpeed] // options.west.fxSpeed_open
|
1570 |
|| o[sSettings].duration // options.west.fxSettings_open.duration
|
1571 |
|| o.fxSpeed // options.west.fxSpeed
|
1572 |
|| o.fxSettings.duration // options.west.fxSettings.duration
|
1573 |
|| defs.fxSpeed // options.defaults.fxSpeed
|
1574 |
|| defs.fxSettings.duration// options.defaults.fxSettings.duration
|
1575 |
|| fx_pane.duration // effects.slide.west.duration
|
1576 |
|| fx_all.duration // effects.slide.all.duration
|
1577 |
|| "normal" // DEFAULT |
1578 |
; |
1579 |
}); |
1580 |
|
1581 |
}); |
1582 |
|
1583 |
function renameOpts (O) { |
1584 |
for (var key in newOpts) { |
1585 |
if (O[key] != undefined) { |
1586 |
O[newOpts[key]] = O[key]; |
1587 |
delete O[key];
|
1588 |
} |
1589 |
} |
1590 |
} |
1591 |
}; |
1592 |
|
1593 |
/**
|
1594 |
* Initialize module objects, styling, size and position for all panes
|
1595 |
*
|
1596 |
* @see _create()
|
1597 |
*/
|
1598 |
var getPane = function (pane) { |
1599 |
var sel = options[pane].paneSelector
|
1600 |
if (sel.substr(0,1)==="#") // ID selector |
1601 |
// NOTE: elements selected 'by ID' DO NOT have to be 'children'
|
1602 |
return $Container.find(sel).eq(0); |
1603 |
else { // class or other selector |
1604 |
var $P = $Container.children(sel).eq(0); |
1605 |
// look for the pane nested inside a 'form' element
|
1606 |
return $P.length ? $P : $Container.children("form:first").children(sel).eq(0); |
1607 |
} |
1608 |
}; |
1609 |
var initPanes = function () { |
1610 |
// NOTE: do north & south FIRST so we can measure their height - do center LAST
|
1611 |
$.each(_c.allPanes.split(","), function (idx, pane) { |
1612 |
var
|
1613 |
o = options[pane] |
1614 |
, s = state[pane] |
1615 |
, c = _c[pane] |
1616 |
, fx = s.fx |
1617 |
, dir = c.dir |
1618 |
, spacing = o.spacing_open || 0
|
1619 |
, isCenter = (pane == "center")
|
1620 |
, CSS = {} |
1621 |
, $P, $C |
1622 |
, size, minSize, maxSize |
1623 |
; |
1624 |
$Cs[pane] = false; // init |
1625 |
|
1626 |
$P = $Ps[pane] = getPane(pane); |
1627 |
if (!$P.length) { |
1628 |
$Ps[pane] = false; // logic |
1629 |
return true; // SKIP to next |
1630 |
} |
1631 |
|
1632 |
// SAVE original Pane CSS
|
1633 |
if (!$P.data("layoutCSS")) { |
1634 |
var props = "position,top,left,bottom,right,width,height,overflow,zIndex,display,backgroundColor,padding,margin,border"; |
1635 |
$P.data("layoutCSS", getElemCSS($P, props)); |
1636 |
} |
1637 |
|
1638 |
// add basic classes & attributes
|
1639 |
$P
|
1640 |
.data("layoutName", options.name) // add user's layout-name - even if blank! |
1641 |
.data("layoutRole", "pane") |
1642 |
.data("layoutEdge", pane)
|
1643 |
.css(c.cssReq).css("zIndex", _c.zIndex.pane_normal)
|
1644 |
.css(o.applyDemoStyles ? c.cssDemo : {}) // demo styles
|
1645 |
.addClass( o.paneClass +" "+ o.paneClass+"-"+pane ) // default = "ui-layout-pane ui-layout-pane-west" - may be a dupe of 'paneSelector' |
1646 |
.bind("mouseenter."+ sID, addHover )
|
1647 |
.bind("mouseleave."+ sID, removeHover )
|
1648 |
; |
1649 |
|
1650 |
// see if this pane has a 'scrolling-content element'
|
1651 |
initContent(pane, false); // false = do NOT sizeContent() - called later |
1652 |
|
1653 |
if (!isCenter) {
|
1654 |
// call _parseSize AFTER applying pane classes & styles - but before making visible (if hidden)
|
1655 |
// if o.size is auto or not valid, then MEASURE the pane and use that as it's 'size'
|
1656 |
size = s.size = _parseSize(pane, o.size); |
1657 |
minSize = _parseSize(pane,o.minSize) || 1;
|
1658 |
maxSize = _parseSize(pane,o.maxSize) || 100000;
|
1659 |
if (size > 0) size = max(min(size, maxSize), minSize); |
1660 |
} |
1661 |
|
1662 |
// init pane-logic vars
|
1663 |
s.tagName = $P.attr("tagName"); |
1664 |
s.edge = pane // useful if pane is (or about to be) 'swapped' - easy find out where it is (or is going)
|
1665 |
s.noRoom = false; // true = pane 'automatically' hidden due to insufficient room - will unhide automatically |
1666 |
s.isVisible = true; // false = pane is invisible - closed OR hidden - simplify logic |
1667 |
if (!isCenter) {
|
1668 |
s.isClosed = false; // true = pane is closed |
1669 |
s.isSliding = false; // true = pane is currently open by 'sliding' over adjacent panes |
1670 |
s.isResizing= false; // true = pane is in process of being resized |
1671 |
s.isHidden = false; // true = pane is hidden - no spacing, resizer or toggler is visible! |
1672 |
} |
1673 |
|
1674 |
// set css-position to account for container borders & padding
|
1675 |
switch (pane) {
|
1676 |
case "north": CSS.top = sC.insetTop; |
1677 |
CSS.left = sC.insetLeft; |
1678 |
CSS.right = sC.insetRight; |
1679 |
break;
|
1680 |
case "south": CSS.bottom = sC.insetBottom; |
1681 |
CSS.left = sC.insetLeft; |
1682 |
CSS.right = sC.insetRight; |
1683 |
break;
|
1684 |
case "west": CSS.left = sC.insetLeft; // top, bottom & height set by sizeMidPanes() |
1685 |
break;
|
1686 |
case "east": CSS.right = sC.insetRight; // ditto |
1687 |
break;
|
1688 |
case "center": // top, left, width & height set by sizeMidPanes() |
1689 |
} |
1690 |
|
1691 |
if (dir == "horz") // north or south pane |
1692 |
CSS.height = max(1, cssH(pane, size));
|
1693 |
else if (dir == "vert") // east or west pane |
1694 |
CSS.width = max(1, cssW(pane, size));
|
1695 |
//else if (isCenter) {}
|
1696 |
|
1697 |
$P.css(CSS); // apply size -- top, bottom & height will be set by sizeMidPanes |
1698 |
if (dir != "horz") sizeMidPanes(pane, true); // true = skipCallback |
1699 |
|
1700 |
// NOW make the pane visible - in case was initially hidden
|
1701 |
$P.css({ visibility: "visible", display: "block" }); |
1702 |
|
1703 |
// close or hide the pane if specified in settings
|
1704 |
if (o.initClosed && o.closable)
|
1705 |
close(pane, true, true); // true, true = force, noAnimation |
1706 |
else if (o.initHidden || o.initClosed) |
1707 |
hide(pane); // will be completely invisible - no resizer or spacing
|
1708 |
// ELSE setAsOpen() - called later by initHandles()
|
1709 |
|
1710 |
// check option for auto-handling of pop-ups & drop-downs
|
1711 |
if (o.showOverflowOnHover)
|
1712 |
$P.hover( allowOverflow, resetOverflow );
|
1713 |
}); |
1714 |
|
1715 |
/*
|
1716 |
* init the pane-handles NOW in case we have to hide or close the pane below
|
1717 |
*/
|
1718 |
initHandles(); |
1719 |
|
1720 |
// now that all panes have been initialized and initially-sized,
|
1721 |
// make sure there is really enough space available for each pane
|
1722 |
$.each(_c.borderPanes.split(","), function (i, pane) { |
1723 |
if ($Ps[pane] && state[pane].isVisible) { // pane is OPEN |
1724 |
setSizeLimits(pane); |
1725 |
makePaneFit(pane); // pane may be Closed, Hidden or Resized by makePaneFit()
|
1726 |
} |
1727 |
}); |
1728 |
// size center-pane AGAIN in case we 'closed' a border-pane in loop above
|
1729 |
sizeMidPanes("center");
|
1730 |
|
1731 |
// trigger onResize callbacks for all panes with triggerEventsOnLoad = true
|
1732 |
$.each(_c.allPanes.split(","), function (i, pane) { |
1733 |
var o = options[pane];
|
1734 |
if ($Ps[pane] && o.triggerEventsOnLoad && state[pane].isVisible) // pane is OPEN |
1735 |
_execCallback(pane, o.onresize_end || o.onresize); // call onresize
|
1736 |
}); |
1737 |
|
1738 |
if ($Container.innerHeight() < 2) |
1739 |
alert( lang.errContainerHeight.replace(/CONTAINER/, sC.ref) );
|
1740 |
}; |
1741 |
|
1742 |
/**
|
1743 |
* Initialize module objects, styling, size and position for all resize bars and toggler buttons
|
1744 |
*
|
1745 |
* @see _create()
|
1746 |
* @param {string=} panes The edge(s) to process, blank = all
|
1747 |
*/
|
1748 |
var initHandles = function (panes) { |
1749 |
if (!panes || panes == "all") panes = _c.borderPanes; |
1750 |
|
1751 |
// create toggler DIVs for each pane, and set object pointers for them, eg: $R.north = north toggler DIV
|
1752 |
$.each(panes.split(","), function (i, pane) { |
1753 |
var $P = $Ps[pane]; |
1754 |
$Rs[pane] = false; // INIT |
1755 |
$Ts[pane] = false; |
1756 |
if (!$P) return; // pane does not exist - skip |
1757 |
|
1758 |
var
|
1759 |
o = options[pane] |
1760 |
, s = state[pane] |
1761 |
, c = _c[pane] |
1762 |
, rClass = o.resizerClass |
1763 |
, tClass = o.togglerClass |
1764 |
, side = c.side.toLowerCase() |
1765 |
, spacing = (s.isVisible ? o.spacing_open : o.spacing_closed) |
1766 |
, _pane = "-"+ pane // used for classNames |
1767 |
, _state = (s.isVisible ? "-open" : "-closed") // used for classNames |
1768 |
// INIT RESIZER BAR
|
1769 |
, $R = $Rs[pane] = $("<div></div>") |
1770 |
// INIT TOGGLER BUTTON
|
1771 |
, $T = (o.closable ? $Ts[pane] = $("<div></div>") : false) |
1772 |
; |
1773 |
|
1774 |
//if (s.isVisible && o.resizable) ... handled by initResizable
|
1775 |
if (!s.isVisible && o.slidable)
|
1776 |
$R.attr("title", o.sliderTip).css("cursor", o.sliderCursor); |
1777 |
|
1778 |
$R
|
1779 |
// if paneSelector is an ID, then create a matching ID for the resizer, eg: "#paneLeft" => "paneLeft-resizer"
|
1780 |
.attr("id", (o.paneSelector.substr(0,1)=="#" ? o.paneSelector.substr(1) + "-resizer" : "")) |
1781 |
.data("layoutRole", "resizer") |
1782 |
.data("layoutEdge", pane)
|
1783 |
.css(_c.resizers.cssReq).css("zIndex", _c.zIndex.resizer_normal)
|
1784 |
.css(o.applyDemoStyles ? _c.resizers.cssDemo : {}) // add demo styles
|
1785 |
.addClass(rClass +" "+ rClass+_pane)
|
1786 |
.appendTo($Container) // append DIV to container |
1787 |
; |
1788 |
|
1789 |
if ($T) { |
1790 |
$T
|
1791 |
// if paneSelector is an ID, then create a matching ID for the resizer, eg: "#paneLeft" => "#paneLeft-toggler"
|
1792 |
.attr("id", (o.paneSelector.substr(0,1)=="#" ? o.paneSelector.substr(1) + "-toggler" : "")) |
1793 |
.data("layoutRole", "toggler") |
1794 |
.data("layoutEdge", pane)
|
1795 |
.css(_c.togglers.cssReq) // add base/required styles
|
1796 |
.css(o.applyDemoStyles ? _c.togglers.cssDemo : {}) // add demo styles
|
1797 |
.addClass(tClass +" "+ tClass+_pane)
|
1798 |
.appendTo($R) // append SPAN to resizer DIV |
1799 |
.click(function(evt){ toggle(pane); evt.stopPropagation(); })
|
1800 |
.hover( addHover, removeHover ) |
1801 |
; |
1802 |
// ADD INNER-SPANS TO TOGGLER
|
1803 |
if (o.togglerContent_open) // ui-layout-open |
1804 |
$("<span>"+ o.togglerContent_open +"</span>") |
1805 |
.data("layoutRole", "togglerContent") |
1806 |
.data("layoutEdge", pane)
|
1807 |
.addClass("content content-open")
|
1808 |
.css("display","none") |
1809 |
.appendTo( $T )
|
1810 |
.hover( addHover, removeHover ) |
1811 |
; |
1812 |
if (o.togglerContent_closed) // ui-layout-closed |
1813 |
$("<span>"+ o.togglerContent_closed +"</span>") |
1814 |
.data("layoutRole", "togglerContent") |
1815 |
.data("layoutEdge", pane)
|
1816 |
.addClass("content content-closed")
|
1817 |
.css("display","none") |
1818 |
.appendTo( $T )
|
1819 |
.hover( addHover, removeHover ) |
1820 |
; |
1821 |
} |
1822 |
|
1823 |
// ADD CLASSNAMES & SLIDE-BINDINGS - eg: class="resizer resizer-west resizer-open"
|
1824 |
if (s.isVisible)
|
1825 |
setAsOpen(pane); // onOpen will be called, but NOT onResize
|
1826 |
else {
|
1827 |
setAsClosed(pane); // onClose will be called
|
1828 |
bindStartSlidingEvent(pane, true); // will enable events IF option is set |
1829 |
} |
1830 |
|
1831 |
}); |
1832 |
|
1833 |
// SET ALL HANDLE DIMENSIONS
|
1834 |
sizeHandles("all");
|
1835 |
}; |
1836 |
|
1837 |
|
1838 |
/**
|
1839 |
* Initialize scrolling ui-layout-content div - if exists
|
1840 |
*
|
1841 |
* @see initPane() - or externally after an Ajax injection
|
1842 |
* @param {string} pane The pane to process
|
1843 |
* @param {boolean=} resize Size content after init, default = true
|
1844 |
*/
|
1845 |
var initContent = function (pane, resize) { |
1846 |
var
|
1847 |
o = options[pane] |
1848 |
, sel = o.contentSelector |
1849 |
, $P = $Ps[pane] |
1850 |
, $C
|
1851 |
; |
1852 |
if (sel) $C = $Cs[pane] = (o.findNestedContent) |
1853 |
? $P.find(sel).eq(0) // match 1-element only |
1854 |
: $P.children(sel).eq(0) |
1855 |
; |
1856 |
if ($C && $C.length) { |
1857 |
$C.css( _c.content.cssReq );
|
1858 |
if (o.applyDemoStyles) {
|
1859 |
$C.css( _c.content.cssDemo ); // add padding & overflow: auto to content-div |
1860 |
$P.css( _c.content.cssDemoPane ); // REMOVE padding/scrolling from pane |
1861 |
} |
1862 |
state[pane].content = {}; // init content state
|
1863 |
if (resize !== false) sizeContent(pane); |
1864 |
// sizeContent() is called AFTER init of all elements
|
1865 |
} |
1866 |
else
|
1867 |
$Cs[pane] = false; |
1868 |
}; |
1869 |
|
1870 |
|
1871 |
/**
|
1872 |
* Searches for .ui-layout-button-xxx elements and auto-binds them as layout-buttons
|
1873 |
*
|
1874 |
* @see _create()
|
1875 |
*/
|
1876 |
var initButtons = function () { |
1877 |
var pre = "ui-layout-button-", name; |
1878 |
$.each("toggle,open,close,pin,toggle-slide,open-slide".split(","), function (i, action) { |
1879 |
$.each(_c.borderPanes.split(","), function (ii, pane) { |
1880 |
$("."+pre+action+"-"+pane).each(function(){ |
1881 |
// if button was previously 'bound', data.layoutName was set, but is blank if layout has no 'name'
|
1882 |
name = $(this).data("layoutName") || $(this).attr("layoutName"); |
1883 |
if (name == undefined || name == options.name) |
1884 |
bindButton(this, action, pane);
|
1885 |
}); |
1886 |
}); |
1887 |
}); |
1888 |
}; |
1889 |
|
1890 |
/**
|
1891 |
* Add resize-bars to all panes that specify it in options
|
1892 |
* -dependancy: $.fn.resizable - will skip if not found
|
1893 |
*
|
1894 |
* @see _create()
|
1895 |
* @param {string=} panes The edge(s) to process, blank = all
|
1896 |
*/
|
1897 |
var initResizable = function (panes) { |
1898 |
var
|
1899 |
draggingAvailable = (typeof $.fn.draggable == "function") |
1900 |
, $Frames, side // set in start() |
1901 |
; |
1902 |
if (!panes || panes == "all") panes = _c.borderPanes; |
1903 |
|
1904 |
$.each(panes.split(","), function (idx, pane) { |
1905 |
var
|
1906 |
o = options[pane] |
1907 |
, s = state[pane] |
1908 |
, c = _c[pane] |
1909 |
, side = (c.dir=="horz" ? "top" : "left") |
1910 |
, r, live // set in start because may change
|
1911 |
; |
1912 |
if (!draggingAvailable || !$Ps[pane] || !o.resizable) { |
1913 |
o.resizable = false;
|
1914 |
return true; // skip to next |
1915 |
} |
1916 |
|
1917 |
var
|
1918 |
$P = $Ps[pane] |
1919 |
, $R = $Rs[pane] |
1920 |
, base = o.resizerClass |
1921 |
// 'drag' classes are applied to the ORIGINAL resizer-bar while dragging is in process
|
1922 |
, resizerClass = base+"-drag" // resizer-drag |
1923 |
, resizerPaneClass = base+"-"+pane+"-drag" // resizer-north-drag |
1924 |
// 'helper' class is applied to the CLONED resizer-bar while it is being dragged
|
1925 |
, helperClass = base+"-dragging" // resizer-dragging |
1926 |
, helperPaneClass = base+"-"+pane+"-dragging" // resizer-north-dragging |
1927 |
, helperLimitClass = base+"-dragging-limit" // resizer-drag |
1928 |
, helperClassesSet = false // logic var |
1929 |
; |
1930 |
|
1931 |
if (!s.isClosed)
|
1932 |
$R
|
1933 |
.attr("title", o.resizerTip)
|
1934 |
.css("cursor", o.resizerCursor) // n-resize, s-resize, etc |
1935 |
; |
1936 |
|
1937 |
$R.hover( onResizerEnter, onResizerLeave );
|
1938 |
|
1939 |
$R.draggable({
|
1940 |
containment: $Container[0] // limit resizing to layout container |
1941 |
, axis: (c.dir=="horz" ? "y" : "x") // limit resizing to horz or vert axis |
1942 |
, delay: 0 |
1943 |
, distance: 1 |
1944 |
// basic format for helper - style it using class: .ui-draggable-dragging
|
1945 |
, helper: "clone" |
1946 |
, opacity: o.resizerDragOpacity
|
1947 |
, addClasses: false // avoid ui-state-disabled class when disabled |
1948 |
//, iframeFix: o.draggableIframeFix // TODO: consider using when bug is fixed
|
1949 |
, zIndex: _c.zIndex.resizer_drag
|
1950 |
|
1951 |
, start: function (e, ui) { |
1952 |
// REFRESH options & state pointers in case we used swapPanes
|
1953 |
o = options[pane]; |
1954 |
s = state[pane]; |
1955 |
// re-read options
|
1956 |
live = o.resizeWhileDragging; |
1957 |
|
1958 |
// ondrag_start callback - will CANCEL hide if returns false
|
1959 |
// TODO: dragging CANNOT be cancelled like this, so see if there is a way?
|
1960 |
if (false === _execCallback(pane, o.ondrag_start)) return false; |
1961 |
|
1962 |
_c.isLayoutBusy = true; // used by sizePane() logic during a liveResize |
1963 |
s.isResizing = true; // prevent pane from closing while resizing |
1964 |
timer.clear(pane+"_closeSlider"); // just in case already triggered |
1965 |
|
1966 |
// SET RESIZER LIMITS - used in drag()
|
1967 |
setSizeLimits(pane); // update pane/resizer state
|
1968 |
r = s.resizerPosition; |
1969 |
|
1970 |
$R.addClass( resizerClass +" "+ resizerPaneClass ); // add drag classes |
1971 |
helperClassesSet = false; // reset logic var - see drag() |
1972 |
|
1973 |
// MASK PANES WITH IFRAMES OR OTHER TROUBLESOME ELEMENTS
|
1974 |
$Frames = $(o.maskIframesOnResize === true ? "iframe" : o.maskIframesOnResize).filter(":visible"); |
1975 |
var id, i=0; // ID incrementer - used when 'resizing' masks during dynamic resizing |
1976 |
$Frames.each(function() { |
1977 |
id = "ui-layout-mask-"+ (++i);
|
1978 |
$(this).data("layoutMaskID", id); // tag iframe with corresponding maskID |
1979 |
$('<div id="'+ id +'" class="ui-layout-mask ui-layout-mask-'+ pane +'"/>') |
1980 |
.css({ |
1981 |
background: "#fff" |
1982 |
, opacity: "0.001" |
1983 |
, zIndex: _c.zIndex.iframe_mask
|
1984 |
, position: "absolute" |
1985 |
, width: this.offsetWidth+"px" |
1986 |
, height: this.offsetHeight+"px" |
1987 |
}) |
1988 |
.css($(this).position()) // top & left -- changed from offset() |
1989 |
.appendTo(this.parentNode) // put mask-div INSIDE pane to avoid zIndex issues |
1990 |
; |
1991 |
}); |
1992 |
|
1993 |
// DISABLE TEXT SELECTION (though probably was already by resizer.mouseOver)
|
1994 |
$('body').disableSelection(); |
1995 |
} |
1996 |
|
1997 |
, drag: function (e, ui) { |
1998 |
if (!helperClassesSet) { // can only add classes after clone has been added to the DOM |
1999 |
//$(".ui-draggable-dragging")
|
2000 |
ui.helper |
2001 |
.addClass( helperClass +" "+ helperPaneClass ) // add helper classes |
2002 |
.children().css("visibility","hidden") // hide toggler inside dragged resizer-bar |
2003 |
; |
2004 |
helperClassesSet = true;
|
2005 |
// draggable bug!? RE-SET zIndex to prevent E/W resize-bar showing through N/S pane!
|
2006 |
if (s.isSliding) $Ps[pane].css("zIndex", _c.zIndex.pane_sliding); |
2007 |
} |
2008 |
// CONTAIN RESIZER-BAR TO RESIZING LIMITS
|
2009 |
var limit = 0; |
2010 |
if (ui.position[side] < r.min) {
|
2011 |
ui.position[side] = r.min; |
2012 |
limit = -1;
|
2013 |
} |
2014 |
else if (ui.position[side] > r.max) { |
2015 |
ui.position[side] = r.max; |
2016 |
limit = 1;
|
2017 |
} |
2018 |
// ADD/REMOVE dragging-limit CLASS
|
2019 |
if (limit) {
|
2020 |
ui.helper.addClass( helperLimitClass ); // at dragging-limit
|
2021 |
window.defaultStatus = "Panel has reached its " +
|
2022 |
((limit>0 && pane.match(/north|west/)) || (limit<0 && pane.match(/south|east/)) ? "maximum" : "minimum") +" size"; |
2023 |
} |
2024 |
else {
|
2025 |
ui.helper.removeClass( helperLimitClass ); // not at dragging-limit
|
2026 |
window.defaultStatus = "";
|
2027 |
} |
2028 |
// DYNAMICALLY RESIZE PANES IF OPTION ENABLED
|
2029 |
if (live) resizePanes(e, ui, pane);
|
2030 |
} |
2031 |
|
2032 |
, stop: function (e, ui) { |
2033 |
// RE-ENABLE TEXT SELECTION
|
2034 |
$('body').enableSelection(); |
2035 |
window.defaultStatus = ""; // clear 'resizing limit' message from statusbar |
2036 |
$R.removeClass( resizerClass +" "+ resizerPaneClass +" "+ helperLimitClass ); // remove drag classes from Resizer |
2037 |
s.isResizing = false;
|
2038 |
_c.isLayoutBusy = false; // set BEFORE resizePanes so other logic can pick it up |
2039 |
resizePanes(e, ui, pane, true); // true = resizingDone |
2040 |
} |
2041 |
|
2042 |
}); |
2043 |
|
2044 |
/**
|
2045 |
* resizePanes
|
2046 |
*
|
2047 |
* Sub-routine called from stop() and optionally drag()
|
2048 |
*
|
2049 |
* @param {!Object} evt
|
2050 |
* @param {!Object} ui
|
2051 |
* @param {string} pane
|
2052 |
* @param {boolean=} resizingDone
|
2053 |
*/
|
2054 |
var resizePanes = function (evt, ui, pane, resizingDone) { |
2055 |
var
|
2056 |
dragPos = ui.position |
2057 |
, c = _c[pane] |
2058 |
, resizerPos, newSize |
2059 |
, i = 0 // ID incrementer |
2060 |
; |
2061 |
switch (pane) {
|
2062 |
case "north": resizerPos = dragPos.top; break; |
2063 |
case "west": resizerPos = dragPos.left; break; |
2064 |
case "south": resizerPos = sC.offsetHeight - dragPos.top - o.spacing_open; break; |
2065 |
case "east": resizerPos = sC.offsetWidth - dragPos.left - o.spacing_open; break; |
2066 |
}; |
2067 |
|
2068 |
if (resizingDone) {
|
2069 |
// Remove OR Resize MASK(S) created in drag.start
|
2070 |
$("div.ui-layout-mask").each(function() { this.parentNode.removeChild(this); }); |
2071 |
//$("div.ui-layout-mask").remove(); // TODO: Is this less efficient?
|
2072 |
|
2073 |
// ondrag_start callback - will CANCEL hide if returns false
|
2074 |
if (false === _execCallback(pane, o.ondrag_end || o.ondrag)) return false; |
2075 |
} |
2076 |
else
|
2077 |
$Frames.each(function() { |
2078 |
$("#"+ $(this).data("layoutMaskID")) // get corresponding mask by ID |
2079 |
.css($(this).position()) // update top & left |
2080 |
.css({ // update width & height
|
2081 |
width: this.offsetWidth +"px" |
2082 |
, height: this.offsetHeight+"px" |
2083 |
}) |
2084 |
; |
2085 |
}); |
2086 |
|
2087 |
// remove container margin from resizer position to get the pane size
|
2088 |
newSize = resizerPos - sC["inset"+ c.side];
|
2089 |
manualSizePane(pane, newSize); |
2090 |
} |
2091 |
}); |
2092 |
}; |
2093 |
|
2094 |
|
2095 |
/**
|
2096 |
* Destroy this layout and reset all elements
|
2097 |
*/
|
2098 |
var destroy = function () { |
2099 |
// UNBIND layout events and remove global object
|
2100 |
$(window).unbind("."+ sID); |
2101 |
$(document).unbind("."+ sID); |
2102 |
window[ sID ] = null;
|
2103 |
|
2104 |
var
|
2105 |
fullPage= (sC.tagName == "BODY")
|
2106 |
// create list of ALL pane-classes that need to be removed
|
2107 |
, _open = "-open"
|
2108 |
, _sliding= "-sliding"
|
2109 |
, _closed = "-closed"
|
2110 |
, $P, root, pRoot, pClasses // loop vars |
2111 |
; |
2112 |
// loop all panes to remove layout classes, attributes and bindings
|
2113 |
$.each(_c.allPanes.split(","), function (i, pane) { |
2114 |
$P = $Ps[pane]; |
2115 |
if (!$P) return true; // no pane - SKIP |
2116 |
|
2117 |
// REMOVE pane's resizer and toggler elements
|
2118 |
if (pane != "center") { |
2119 |
if ($Ts[pane]) $Ts[pane].remove(); |
2120 |
$Rs[pane].remove();
|
2121 |
} |
2122 |
|
2123 |
root = options[pane].paneClass; // default="ui-layout-pane"
|
2124 |
pRoot = root +"-"+ pane; // eg: "ui-layout-pane-west" |
2125 |
pClasses = [ root, root+_open, root+_closed, root+_sliding, // generic classes
|
2126 |
pRoot, pRoot+_open, pRoot+_closed, pRoot+_sliding // pane-specific classes
|
2127 |
]; |
2128 |
$.merge(pClasses, getHoverClasses($P, true)); // ADD hover-classes |
2129 |
|
2130 |
$P
|
2131 |
.removeClass( pClasses.join(" ") ) // remove ALL pane-classes |
2132 |
.removeData("layoutRole")
|
2133 |
.removeData("layoutEdge")
|
2134 |
.unbind("."+ sID) // remove ALL Layout events |
2135 |
// TODO: remove these extra unbind commands when jQuery is fixed
|
2136 |
.unbind("mouseenter")
|
2137 |
.unbind("mouseleave")
|
2138 |
; |
2139 |
|
2140 |
// do NOT reset CSS if this pane is STILL the container of a nested layout!
|
2141 |
// the nested layout will reset its 'container' when/if it is destroyed
|
2142 |
if (!$P.data("layoutContainer")) |
2143 |
$P.css( $P.data("layoutCSS") ); |
2144 |
}); |
2145 |
|
2146 |
// reset layout-container
|
2147 |
$Container.removeData("layoutContainer"); |
2148 |
|
2149 |
// do NOT reset container CSS if is a 'pane' in an outer-layout - ie, THIS layout is 'nested'
|
2150 |
if (!$Container.data("layoutEdge")) |
2151 |
$Container.css( $Container.data("layoutCSS") ); // RESET CSS |
2152 |
// for full-page layouts, must also reset the <HTML> CSS
|
2153 |
if (fullPage)
|
2154 |
$("html").css( $("html").data("layoutCSS") ); // RESET CSS |
2155 |
|
2156 |
// trigger state-management and onunload callback
|
2157 |
unload(); |
2158 |
|
2159 |
var n = options.name; // layout-name |
2160 |
if (n && window[n]) window[n] = null; // clear window object, if exists |
2161 |
}; |
2162 |
|
2163 |
|
2164 |
/*
|
2165 |
* ###########################
|
2166 |
* ACTION METHODS
|
2167 |
* ###########################
|
2168 |
*/
|
2169 |
|
2170 |
/**
|
2171 |
* Completely 'hides' a pane, including its spacing - as if it does not exist
|
2172 |
* The pane is not actually 'removed' from the source, so can use 'show' to un-hide it
|
2173 |
*
|
2174 |
* @param {string} pane The pane being hidden, ie: north, south, east, or west
|
2175 |
* @param {boolean=} noAnimation
|
2176 |
*/
|
2177 |
var hide = function (pane, noAnimation) { |
2178 |
var
|
2179 |
o = options[pane] |
2180 |
, s = state[pane] |
2181 |
, $P = $Ps[pane] |
2182 |
, $R = $Rs[pane] |
2183 |
; |
2184 |
if (!$P || s.isHidden) return; // pane does not exist OR is already hidden |
2185 |
|
2186 |
// onhide_start callback - will CANCEL hide if returns false
|
2187 |
if (state.initialized && false === _execCallback(pane, o.onhide_start)) return; |
2188 |
|
2189 |
s.isSliding = false; // just in case |
2190 |
|
2191 |
// now hide the elements
|
2192 |
if ($R) $R.hide(); // hide resizer-bar |
2193 |
if (!state.initialized || s.isClosed) {
|
2194 |
s.isClosed = true; // to trigger open-animation on show() |
2195 |
s.isHidden = true;
|
2196 |
s.isVisible = false;
|
2197 |
$P.hide(); // no animation when loading page |
2198 |
sizeMidPanes(_c[pane].dir == "horz" ? "all" : "center"); |
2199 |
if (state.initialized || o.triggerEventsOnLoad)
|
2200 |
_execCallback(pane, o.onhide_end || o.onhide); |
2201 |
} |
2202 |
else {
|
2203 |
s.isHiding = true; // used by onclose |
2204 |
close(pane, false, noAnimation); // adjust all panes to fit |
2205 |
} |
2206 |
}; |
2207 |
|
2208 |
/**
|
2209 |
* Show a hidden pane - show as 'closed' by default unless openPane = true
|
2210 |
*
|
2211 |
* @param {string} pane The pane being opened, ie: north, south, east, or west
|
2212 |
* @param {boolean=} openPane
|
2213 |
* @param {boolean=} noAnimation
|
2214 |
* @param {boolean=} noAlert
|
2215 |
*/
|
2216 |
var show = function (pane, openPane, noAnimation, noAlert) { |
2217 |
var
|
2218 |
o = options[pane] |
2219 |
, s = state[pane] |
2220 |
, $P = $Ps[pane] |
2221 |
, $R = $Rs[pane] |
2222 |
; |
2223 |
if (!$P || !s.isHidden) return; // pane does not exist OR is not hidden |
2224 |
|
2225 |
// onshow_start callback - will CANCEL show if returns false
|
2226 |
if (false === _execCallback(pane, o.onshow_start)) return; |
2227 |
|
2228 |
s.isSliding = false; // just in case |
2229 |
s.isShowing = true; // used by onopen/onclose |
2230 |
//s.isHidden = false; - will be set by open/close - if not cancelled
|
2231 |
|
2232 |
// now show the elements
|
2233 |
//if ($R) $R.show(); - will be shown by open/close
|
2234 |
if (openPane === false) |
2235 |
close(pane, true); // true = force |
2236 |
else
|
2237 |
open(pane, false, noAnimation, noAlert); // adjust all panes to fit |
2238 |
}; |
2239 |
|
2240 |
|
2241 |
/**
|
2242 |
* Toggles a pane open/closed by calling either open or close
|
2243 |
*
|
2244 |
* @param {string} pane The pane being toggled, ie: north, south, east, or west
|
2245 |
* @param {boolean=} slide
|
2246 |
*/
|
2247 |
var toggle = function (pane, slide) { |
2248 |
if (!isStr(pane)) {
|
2249 |
pane.stopImmediatePropagation(); // pane = event
|
2250 |
pane = $(this).data("layoutEdge"); // bound to $R.dblclick |
2251 |
} |
2252 |
var s = state[str(pane)];
|
2253 |
if (s.isHidden)
|
2254 |
show(pane); // will call 'open' after unhiding it
|
2255 |
else if (s.isClosed) |
2256 |
open(pane, !!slide); |
2257 |
else
|
2258 |
close(pane); |
2259 |
}; |
2260 |
|
2261 |
|
2262 |
/**
|
2263 |
* Utility method used during init or other auto-processes
|
2264 |
*
|
2265 |
* @param {string} pane The pane being closed
|
2266 |
* @param {boolean=} setHandles
|
2267 |
*/
|
2268 |
var _closePane = function (pane, setHandles) { |
2269 |
var
|
2270 |
$P = $Ps[pane] |
2271 |
, s = state[pane] |
2272 |
; |
2273 |
$P.hide();
|
2274 |
s.isClosed = true;
|
2275 |
s.isVisible = false;
|
2276 |
// UNUSED: if (setHandles) setAsClosed(pane, true); // true = force
|
2277 |
}; |
2278 |
|
2279 |
/**
|
2280 |
* Close the specified pane (animation optional), and resize all other panes as needed
|
2281 |
*
|
2282 |
* @param {string} pane The pane being closed, ie: north, south, east, or west
|
2283 |
* @param {boolean=} force
|
2284 |
* @param {boolean=} noAnimation
|
2285 |
* @param {boolean=} skipCallback
|
2286 |
*/
|
2287 |
var close = function (pane, force, noAnimation, skipCallback) { |
2288 |
if (!state.initialized) {
|
2289 |
_closePane(pane) |
2290 |
return;
|
2291 |
} |
2292 |
var
|
2293 |
$P = $Ps[pane] |
2294 |
, $R = $Rs[pane] |
2295 |
, $T = $Ts[pane] |
2296 |
, o = options[pane] |
2297 |
, s = state[pane] |
2298 |
, doFX = !noAnimation && !s.isClosed && (o.fxName_close != "none")
|
2299 |
// transfer logic vars to temp vars
|
2300 |
, isShowing = s.isShowing |
2301 |
, isHiding = s.isHiding |
2302 |
, wasSliding = s.isSliding |
2303 |
; |
2304 |
// now clear the logic vars
|
2305 |
delete s.isShowing;
|
2306 |
delete s.isHiding;
|
2307 |
|
2308 |
if (!$P || !o.closable) return; // invalid request // (!o.resizable && !o.closable) ??? |
2309 |
else if (!force && s.isClosed && !isShowing) return; // already closed |
2310 |
|
2311 |
if (_c.isLayoutBusy) { // layout is 'busy' - probably with an animation |
2312 |
_queue("close", pane, force); // set a callback for this action, if possible |
2313 |
return; // ABORT |
2314 |
} |
2315 |
|
2316 |
// onclose_start callback - will CANCEL hide if returns false
|
2317 |
// SKIP if just 'showing' a hidden pane as 'closed'
|
2318 |
if (!isShowing && false === _execCallback(pane, o.onclose_start)) return; |
2319 |
|
2320 |
// SET flow-control flags
|
2321 |
_c[pane].isMoving = true;
|
2322 |
_c.isLayoutBusy = true;
|
2323 |
|
2324 |
s.isClosed = true;
|
2325 |
s.isVisible = false;
|
2326 |
// update isHidden BEFORE sizing panes
|
2327 |
if (isHiding) s.isHidden = true; |
2328 |
else if (isShowing) s.isHidden = false; |
2329 |
|
2330 |
if (s.isSliding) // pane is being closed, so UNBIND trigger events |
2331 |
bindStopSlidingEvents(pane, false); // will set isSliding=false |
2332 |
else // resize panes adjacent to this one |
2333 |
sizeMidPanes(_c[pane].dir == "horz" ? "all" : "center", false); // false = NOT skipCallback |
2334 |
|
2335 |
// if this pane has a resizer bar, move it NOW - before animation
|
2336 |
setAsClosed(pane); |
2337 |
|
2338 |
// CLOSE THE PANE
|
2339 |
if (doFX) { // animate the close |
2340 |
lockPaneForFX(pane, true); // need to set left/top so animation will work |
2341 |
$P.hide( o.fxName_close, o.fxSettings_close, o.fxSpeed_close, function () { |
2342 |
lockPaneForFX(pane, false); // undo |
2343 |
close_2(); |
2344 |
}); |
2345 |
} |
2346 |
else { // hide the pane without animation |
2347 |
$P.hide();
|
2348 |
close_2(); |
2349 |
}; |
2350 |
|
2351 |
// SUBROUTINE
|
2352 |
function close_2 () { |
2353 |
if (s.isClosed) { // make sure pane was not 'reopened' before animation finished! |
2354 |
|
2355 |
bindStartSlidingEvent(pane, true); // will enable if o.slidable = true |
2356 |
|
2357 |
// if opposite-pane was autoClosed, see if it can be autoOpened now
|
2358 |
var altPane = _c.altSide[pane];
|
2359 |
if (state[ altPane ].noRoom) {
|
2360 |
setSizeLimits( altPane ); |
2361 |
makePaneFit( altPane ); |
2362 |
} |
2363 |
|
2364 |
if (!skipCallback && (state.initialized || o.triggerEventsOnLoad)) {
|
2365 |
// onclose callback - UNLESS just 'showing' a hidden pane as 'closed'
|
2366 |
if (!isShowing) _execCallback(pane, o.onclose_end || o.onclose);
|
2367 |
// onhide OR onshow callback
|
2368 |
if (isShowing) _execCallback(pane, o.onshow_end || o.onshow);
|
2369 |
if (isHiding) _execCallback(pane, o.onhide_end || o.onhide);
|
2370 |
} |
2371 |
} |
2372 |
// execute internal flow-control callback
|
2373 |
_dequeue(pane); |
2374 |
} |
2375 |
}; |
2376 |
|
2377 |
/**
|
2378 |
* @param {string} pane The pane just closed, ie: north, south, east, or west
|
2379 |
*/
|
2380 |
var setAsClosed = function (pane) { |
2381 |
var
|
2382 |
$P = $Ps[pane] |
2383 |
, $R = $Rs[pane] |
2384 |
, $T = $Ts[pane] |
2385 |
, o = options[pane] |
2386 |
, s = state[pane] |
2387 |
, side = _c[pane].side.toLowerCase() |
2388 |
, inset = "inset"+ _c[pane].side
|
2389 |
, rClass = o.resizerClass |
2390 |
, tClass = o.togglerClass |
2391 |
, _pane = "-"+ pane // used for classNames |
2392 |
, _open = "-open"
|
2393 |
, _sliding= "-sliding"
|
2394 |
, _closed = "-closed"
|
2395 |
; |
2396 |
$R
|
2397 |
.css(side, sC[inset]) // move the resizer
|
2398 |
.removeClass( rClass+_open +" "+ rClass+_pane+_open )
|
2399 |
.removeClass( rClass+_sliding +" "+ rClass+_pane+_sliding )
|
2400 |
.addClass( rClass+_closed +" "+ rClass+_pane+_closed )
|
2401 |
.unbind("dblclick."+ sID)
|
2402 |
; |
2403 |
// DISABLE 'resizing' when closed - do this BEFORE bindStartSlidingEvent?
|
2404 |
if (o.resizable && typeof $.fn.draggable == "function") |
2405 |
$R
|
2406 |
.draggable("disable")
|
2407 |
.removeClass("ui-state-disabled") // do NOT apply disabled styling - not suitable here |
2408 |
.css("cursor", "default") |
2409 |
.attr("title","") |
2410 |
; |
2411 |
|
2412 |
// if pane has a toggler button, adjust that too
|
2413 |
if ($T) { |
2414 |
$T
|
2415 |
.removeClass( tClass+_open +" "+ tClass+_pane+_open )
|
2416 |
.addClass( tClass+_closed +" "+ tClass+_pane+_closed )
|
2417 |
.attr("title", o.togglerTip_closed) // may be blank |
2418 |
; |
2419 |
// toggler-content - if exists
|
2420 |
$T.children(".content-open").hide(); |
2421 |
$T.children(".content-closed").css("display","block"); |
2422 |
} |
2423 |
|
2424 |
// sync any 'pin buttons'
|
2425 |
syncPinBtns(pane, false);
|
2426 |
|
2427 |
if (state.initialized) {
|
2428 |
// resize 'length' and position togglers for adjacent panes
|
2429 |
sizeHandles("all");
|
2430 |
} |
2431 |
}; |
2432 |
|
2433 |
/**
|
2434 |
* Open the specified pane (animation optional), and resize all other panes as needed
|
2435 |
*
|
2436 |
* @param {string} pane The pane being opened, ie: north, south, east, or west
|
2437 |
* @param {boolean=} slide
|
2438 |
* @param {boolean=} noAnimation
|
2439 |
* @param {boolean=} noAlert
|
2440 |
*/
|
2441 |
var open = function (pane, slide, noAnimation, noAlert) { |
2442 |
var
|
2443 |
$P = $Ps[pane] |
2444 |
, $R = $Rs[pane] |
2445 |
, $T = $Ts[pane] |
2446 |
, o = options[pane] |
2447 |
, s = state[pane] |
2448 |
, doFX = !noAnimation && s.isClosed && (o.fxName_open != "none")
|
2449 |
// transfer logic var to temp var
|
2450 |
, isShowing = s.isShowing |
2451 |
; |
2452 |
// now clear the logic var
|
2453 |
delete s.isShowing;
|
2454 |
|
2455 |
if (!$P || (!o.resizable && !o.closable)) return; // invalid request |
2456 |
else if (s.isVisible && !s.isSliding) return; // already open |
2457 |
|
2458 |
// pane can ALSO be unhidden by just calling show(), so handle this scenario
|
2459 |
if (s.isHidden && !isShowing) {
|
2460 |
show(pane, true);
|
2461 |
return;
|
2462 |
} |
2463 |
|
2464 |
if (_c.isLayoutBusy) { // layout is 'busy' - probably with an animation |
2465 |
_queue("open", pane, slide); // set a callback for this action, if possible |
2466 |
return; // ABORT |
2467 |
} |
2468 |
|
2469 |
// onopen_start callback - will CANCEL hide if returns false
|
2470 |
if (false === _execCallback(pane, o.onopen_start)) return; |
2471 |
|
2472 |
// make sure there is enough space available to open the pane
|
2473 |
setSizeLimits(pane, slide); // update pane-state
|
2474 |
if (s.minSize > s.maxSize) { // INSUFFICIENT ROOM FOR PANE TO OPEN! |
2475 |
syncPinBtns(pane, false); // make sure pin-buttons are reset |
2476 |
if (!noAlert && o.noRoomToOpenTip) alert(o.noRoomToOpenTip);
|
2477 |
return; // ABORT |
2478 |
} |
2479 |
|
2480 |
// SET flow-control flags
|
2481 |
_c[pane].isMoving = true;
|
2482 |
_c.isLayoutBusy = true;
|
2483 |
|
2484 |
if (slide) // START Sliding - will set isSliding=true |
2485 |
bindStopSlidingEvents(pane, true); // BIND trigger events to close sliding-pane |
2486 |
else if (s.isSliding) // PIN PANE (stop sliding) - open pane 'normally' instead |
2487 |
bindStopSlidingEvents(pane, false); // UNBIND trigger events - will set isSliding=false |
2488 |
else if (o.slidable) |
2489 |
bindStartSlidingEvent(pane, false); // UNBIND trigger events |
2490 |
|
2491 |
s.noRoom = false; // will be reset by makePaneFit if 'noRoom' |
2492 |
makePaneFit(pane); |
2493 |
|
2494 |
s.isVisible = true;
|
2495 |
s.isClosed = false;
|
2496 |
// update isHidden BEFORE sizing panes - WHY??? Old?
|
2497 |
if (isShowing) s.isHidden = false; |
2498 |
|
2499 |
if (doFX) { // ANIMATE |
2500 |
lockPaneForFX(pane, true); // need to set left/top so animation will work |
2501 |
$P.show( o.fxName_open, o.fxSettings_open, o.fxSpeed_open, function() { |
2502 |
lockPaneForFX(pane, false); // undo |
2503 |
open_2(); // continue
|
2504 |
}); |
2505 |
} |
2506 |
else {// no animation |
2507 |
$P.show(); // just show pane and... |
2508 |
open_2(); // continue
|
2509 |
}; |
2510 |
|
2511 |
// SUBROUTINE
|
2512 |
function open_2 () { |
2513 |
if (s.isVisible) { // make sure pane was not closed or hidden before animation finished! |
2514 |
|
2515 |
// cure iframe display issues
|
2516 |
_fixIframe(pane); |
2517 |
|
2518 |
// NOTE: if isSliding, then other panes are NOT 'resized'
|
2519 |
if (!s.isSliding) // resize all panes adjacent to this one |
2520 |
sizeMidPanes(_c[pane].dir=="vert" ? "center" : "all", false); // false = NOT skipCallback |
2521 |
|
2522 |
// set classes, position handles and execute callbacks...
|
2523 |
setAsOpen(pane); |
2524 |
} |
2525 |
|
2526 |
// internal flow-control callback
|
2527 |
_dequeue(pane); |
2528 |
}; |
2529 |
|
2530 |
}; |
2531 |
|
2532 |
/**
|
2533 |
* @param {string} pane The pane just opened, ie: north, south, east, or west
|
2534 |
* @param {boolean=} skipCallback
|
2535 |
*/
|
2536 |
var setAsOpen = function (pane, skipCallback) { |
2537 |
var
|
2538 |
$P = $Ps[pane] |
2539 |
, $R = $Rs[pane] |
2540 |
, $T = $Ts[pane] |
2541 |
, o = options[pane] |
2542 |
, s = state[pane] |
2543 |
, side = _c[pane].side.toLowerCase() |
2544 |
, inset = "inset"+ _c[pane].side
|
2545 |
, rClass = o.resizerClass |
2546 |
, tClass = o.togglerClass |
2547 |
, _pane = "-"+ pane // used for classNames |
2548 |
, _open = "-open"
|
2549 |
, _closed = "-closed"
|
2550 |
, _sliding= "-sliding"
|
2551 |
; |
2552 |
$R
|
2553 |
.css(side, sC[inset] + getPaneSize(pane)) // move the resizer
|
2554 |
.removeClass( rClass+_closed +" "+ rClass+_pane+_closed )
|
2555 |
.addClass( rClass+_open +" "+ rClass+_pane+_open )
|
2556 |
; |
2557 |
if (s.isSliding)
|
2558 |
$R.addClass( rClass+_sliding +" "+ rClass+_pane+_sliding ) |
2559 |
else // in case 'was sliding' |
2560 |
$R.removeClass( rClass+_sliding +" "+ rClass+_pane+_sliding ) |
2561 |
|
2562 |
if (o.resizerDblClickToggle)
|
2563 |
$R.bind("dblclick", toggle ); |
2564 |
removeHover( 0, $R ); // remove hover classes |
2565 |
if (state.initialized && o.resizable && typeof $.fn.draggable == "function") |
2566 |
$R
|
2567 |
.draggable("enable")
|
2568 |
.css("cursor", o.resizerCursor)
|
2569 |
.attr("title", o.resizerTip)
|
2570 |
; |
2571 |
else if (!s.isSliding) |
2572 |
$R.css("cursor", "default"); // n-resize, s-resize, etc |
2573 |
|
2574 |
// if pane also has a toggler button, adjust that too
|
2575 |
if ($T) { |
2576 |
$T
|
2577 |
.removeClass( tClass+_closed +" "+ tClass+_pane+_closed )
|
2578 |
.addClass( tClass+_open +" "+ tClass+_pane+_open )
|
2579 |
.attr("title", o.togglerTip_open) // may be blank |
2580 |
; |
2581 |
removeHover( 0, $T ); // remove hover classes |
2582 |
// toggler-content - if exists
|
2583 |
$T.children(".content-closed").hide(); |
2584 |
$T.children(".content-open").css("display","block"); |
2585 |
} |
2586 |
|
2587 |
// sync any 'pin buttons'
|
2588 |
syncPinBtns(pane, !s.isSliding); |
2589 |
|
2590 |
// update pane-state dimensions - BEFORE resizing content
|
2591 |
$.extend(s, getElemDims($P)); |
2592 |
|
2593 |
if (state.initialized) {
|
2594 |
// resize resizer & toggler sizes for all panes
|
2595 |
sizeHandles("all");
|
2596 |
// resize content every time pane opens - to be sure
|
2597 |
sizeContent(pane, true); // true = remeasure headers/footers, even if 'isLayoutBusy' |
2598 |
} |
2599 |
|
2600 |
if (!skipCallback && (state.initialized || o.triggerEventsOnLoad) && $P.is(":visible")) { |
2601 |
// onopen callback
|
2602 |
_execCallback(pane, o.onopen_end || o.onopen); |
2603 |
// onshow callback - TODO: should this be here?
|
2604 |
if (s.isShowing) _execCallback(pane, o.onshow_end || o.onshow);
|
2605 |
// ALSO call onresize because layout-size *may* have changed while pane was closed
|
2606 |
if (state.initialized) {
|
2607 |
_execCallback(pane, o.onresize_end || o.onresize); |
2608 |
resizeNestedLayout(pane); |
2609 |
} |
2610 |
} |
2611 |
}; |
2612 |
|
2613 |
|
2614 |
/**
|
2615 |
* slideOpen / slideClose / slideToggle
|
2616 |
*
|
2617 |
* Pass-though methods for sliding
|
2618 |
*/
|
2619 |
var slideOpen = function (evt_or_pane) { |
2620 |
var
|
2621 |
type = typeof evt_or_pane
|
2622 |
, pane = (type == "string" ? evt_or_pane : $(this).data("layoutEdge")) |
2623 |
; |
2624 |
// prevent event from triggering on NEW resizer binding created below
|
2625 |
if (type == "object") { evt_or_pane.stopImmediatePropagation(); } |
2626 |
|
2627 |
if (state[pane].isClosed)
|
2628 |
open(pane, true); // true = slide - ie, called from here! |
2629 |
else // skip 'open' if already open! // TODO: does this use-case make sense??? |
2630 |
bindStopSlidingEvents(pane, true); // BIND trigger events to close sliding-pane |
2631 |
}; |
2632 |
|
2633 |
var slideClose = function (evt_or_pane) { |
2634 |
var
|
2635 |
$E = (isStr(evt_or_pane) ? $Ps[evt_or_pane] : $(this)) |
2636 |
, pane= $E.data("layoutEdge") |
2637 |
, o = options[pane] |
2638 |
, s = state[pane] |
2639 |
, $P = $Ps[pane] |
2640 |
; |
2641 |
|
2642 |
if (s.isClosed || s.isResizing)
|
2643 |
return; // skip if already closed OR in process of resizing |
2644 |
else if (o.slideTrigger_close == "click") |
2645 |
close_NOW(); // close immediately onClick
|
2646 |
else if (o.preventQuickSlideClose && _c.isLayoutBusy) |
2647 |
return; // handle Chrome quick-close on slide-open |
2648 |
else // trigger = mouseleave - use a delay |
2649 |
timer.set(pane+"_closeSlider", close_NOW, 300); // .3 sec delay |
2650 |
|
2651 |
/**
|
2652 |
* SUBROUTINE for timed close
|
2653 |
*
|
2654 |
* @param {Object=} evt
|
2655 |
*/
|
2656 |
function close_NOW (evt) { |
2657 |
if (s.isClosed) // skip 'close' if already closed! |
2658 |
bindStopSlidingEvents(pane, false); // UNBIND trigger events |
2659 |
else
|
2660 |
close(pane); // close will handle unbinding
|
2661 |
} |
2662 |
}; |
2663 |
|
2664 |
var slideToggle = function (pane) { toggle(pane, true); }; |
2665 |
|
2666 |
|
2667 |
/**
|
2668 |
* Must set left/top on East/South panes so animation will work properly
|
2669 |
*
|
2670 |
* @param {string} pane The pane to lock, 'east' or 'south' - any other is ignored!
|
2671 |
* @param {boolean} doLock true = set left/top, false = remove
|
2672 |
*/
|
2673 |
var lockPaneForFX = function (pane, doLock) { |
2674 |
var $P = $Ps[pane]; |
2675 |
if (doLock) {
|
2676 |
$P.css({ zIndex: _c.zIndex.pane_animate }); // overlay all elements during animation |
2677 |
if (pane=="south") |
2678 |
$P.css({ top: sC.insetTop + sC.innerHeight - $P.outerHeight() }); |
2679 |
else if (pane=="east") |
2680 |
$P.css({ left: sC.insetLeft + sC.innerWidth - $P.outerWidth() }); |
2681 |
} |
2682 |
else { // animation DONE - RESET CSS |
2683 |
// TODO: see if this can be deleted. It causes a quick-close when sliding in Chrome
|
2684 |
$P.css({ zIndex: (state[pane].isSliding ? _c.zIndex.pane_sliding : _c.zIndex.pane_normal) }); |
2685 |
if (pane=="south") |
2686 |
$P.css({ top: "auto" }); |
2687 |
else if (pane=="east") |
2688 |
$P.css({ left: "auto" }); |
2689 |
// fix anti-aliasing in IE - only needed for animations that change opacity
|
2690 |
var o = options[pane];
|
2691 |
if (state.browser.msie && o.fxOpacityFix && o.fxName_open != "slide" && $P.css("filter") && $P.css("opacity") == 1) |
2692 |
$P[0].style.removeAttribute('filter'); |
2693 |
} |
2694 |
}; |
2695 |
|
2696 |
|
2697 |
/**
|
2698 |
* Toggle sliding functionality of a specific pane on/off by adding removing 'slide open' trigger
|
2699 |
*
|
2700 |
* @see open(), close()
|
2701 |
* @param {string} pane The pane to enable/disable, 'north', 'south', etc.
|
2702 |
* @param {boolean} enable Enable or Disable sliding?
|
2703 |
*/
|
2704 |
var bindStartSlidingEvent = function (pane, enable) { |
2705 |
var
|
2706 |
o = options[pane] |
2707 |
, $P = $Ps[pane] |
2708 |
, $R = $Rs[pane] |
2709 |
, trigger = o.slideTrigger_open |
2710 |
; |
2711 |
if (!$R || !o.slidable) return; |
2712 |
|
2713 |
// make sure we have a valid event
|
2714 |
if (trigger.match(/mouseover/)) |
2715 |
trigger = o.slideTrigger_open = "mouseenter";
|
2716 |
else if (!trigger.match(/click|dblclick|mouseenter/)) |
2717 |
trigger = o.slideTrigger_open = "click";
|
2718 |
|
2719 |
$R
|
2720 |
// add or remove trigger event
|
2721 |
[enable ? "bind" : "unbind"](trigger +'.'+ sID, slideOpen) |
2722 |
// set the appropriate cursor & title/tip
|
2723 |
.css("cursor", enable ? o.sliderCursor : "default") |
2724 |
.attr("title", enable ? o.sliderTip : "") |
2725 |
; |
2726 |
}; |
2727 |
|
2728 |
/**
|
2729 |
* Add or remove 'mouseleave' events to 'slide close' when pane is 'sliding' open or closed
|
2730 |
* Also increases zIndex when pane is sliding open
|
2731 |
* See bindStartSlidingEvent for code to control 'slide open'
|
2732 |
*
|
2733 |
* @see slideOpen(), slideClose()
|
2734 |
* @param {string} pane The pane to process, 'north', 'south', etc.
|
2735 |
* @param {boolean} enable Enable or Disable events?
|
2736 |
*/
|
2737 |
var bindStopSlidingEvents = function (pane, enable) { |
2738 |
var
|
2739 |
o = options[pane] |
2740 |
, s = state[pane] |
2741 |
, z = _c.zIndex |
2742 |
, trigger = o.slideTrigger_close |
2743 |
, action = (enable ? "bind" : "unbind") |
2744 |
, $P = $Ps[pane] |
2745 |
, $R = $Rs[pane] |
2746 |
; |
2747 |
s.isSliding = enable; // logic
|
2748 |
timer.clear(pane+"_closeSlider"); // just in case |
2749 |
|
2750 |
// remove 'slideOpen' trigger event from resizer
|
2751 |
// ALSO will raise the zIndex of the pane & resizer
|
2752 |
if (enable) bindStartSlidingEvent(pane, false); |
2753 |
|
2754 |
// RE/SET zIndex - increases when pane is sliding-open, resets to normal when not
|
2755 |
$P.css("zIndex", enable ? z.pane_sliding : z.pane_normal); |
2756 |
$R.css("zIndex", enable ? z.pane_sliding : z.resizer_normal); |
2757 |
|
2758 |
// make sure we have a valid event
|
2759 |
if (!trigger.match(/click|mouseleave/)) |
2760 |
trigger = o.slideTrigger_close = "mouseleave"; // also catches 'mouseout' |
2761 |
|
2762 |
// add/remove slide triggers
|
2763 |
$R[action](trigger, slideClose); // base event on resize |
2764 |
// need extra events for mouseleave
|
2765 |
if (trigger == "mouseleave") { |
2766 |
// also close on pane.mouseleave
|
2767 |
$P[action]("mouseleave."+ sID, slideClose); |
2768 |
// cancel timer when mouse moves between 'pane' and 'resizer'
|
2769 |
$R[action]("mouseenter."+ sID, cancelMouseOut); |
2770 |
$P[action]("mouseenter."+ sID, cancelMouseOut); |
2771 |
} |
2772 |
|
2773 |
if (!enable)
|
2774 |
timer.clear(pane+"_closeSlider");
|
2775 |
else if (trigger == "click" && !o.resizable) { |
2776 |
// IF pane is not resizable (which already has a cursor and tip)
|
2777 |
// then set the a cursor & title/tip on resizer when sliding
|
2778 |
$R.css("cursor", enable ? o.sliderCursor : "default"); |
2779 |
$R.attr("title", enable ? o.togglerTip_open : ""); // use Toggler-tip, eg: "Close Pane" |
2780 |
} |
2781 |
|
2782 |
// SUBROUTINE for mouseleave timer clearing
|
2783 |
function cancelMouseOut (evt) { |
2784 |
timer.clear(pane+"_closeSlider");
|
2785 |
evt.stopPropagation(); |
2786 |
} |
2787 |
}; |
2788 |
|
2789 |
|
2790 |
/**
|
2791 |
* Hides/closes a pane if there is insufficient room - reverses this when there is room again
|
2792 |
* MUST have already called setSizeLimits() before calling this method
|
2793 |
*
|
2794 |
* @param {string} pane The pane being resized
|
2795 |
* @param {boolean=} isOpening Called from onOpen?
|
2796 |
* @param {boolean=} skipCallback Should the onresize callback be run?
|
2797 |
* @param {boolean=} force
|
2798 |
*/
|
2799 |
var makePaneFit = function (pane, isOpening, skipCallback, force) { |
2800 |
var
|
2801 |
o = options[pane] |
2802 |
, s = state[pane] |
2803 |
, c = _c[pane] |
2804 |
, $P = $Ps[pane] |
2805 |
, $R = $Rs[pane] |
2806 |
, isSidePane = c.dir=="vert"
|
2807 |
, hasRoom = false
|
2808 |
; |
2809 |
|
2810 |
// special handling for center pane
|
2811 |
if (pane == "center" || (isSidePane && s.noVerticalRoom)) { |
2812 |
// see if there is enough room to display the center-pane
|
2813 |
hasRoom = s.minHeight <= s.maxHeight && (isSidePane || s.minWidth <= s.maxWidth); |
2814 |
if (hasRoom && s.noRoom) { // previously hidden due to noRoom, so show now |
2815 |
$P.show();
|
2816 |
if ($R) $R.show(); |
2817 |
s.isVisible = true;
|
2818 |
s.noRoom = false;
|
2819 |
if (isSidePane) s.noVerticalRoom = false; |
2820 |
_fixIframe(pane); |
2821 |
} |
2822 |
else if (!hasRoom && !s.noRoom) { // not currently hidden, so hide now |
2823 |
$P.hide();
|
2824 |
if ($R) $R.hide(); |
2825 |
s.isVisible = false;
|
2826 |
s.noRoom = true;
|
2827 |
} |
2828 |
} |
2829 |
|
2830 |
// see if there is enough room to fit the border-pane
|
2831 |
if (pane == "center") { |
2832 |
// ignore center in this block
|
2833 |
} |
2834 |
else if (s.minSize <= s.maxSize) { // pane CAN fit |
2835 |
hasRoom = true;
|
2836 |
if (s.size > s.maxSize) // pane is too big - shrink it |
2837 |
sizePane(pane, s.maxSize, skipCallback, force); |
2838 |
else if (s.size < s.minSize) // pane is too small - enlarge it |
2839 |
sizePane(pane, s.minSize, skipCallback, force); |
2840 |
else if ($R && $P.is(":visible")) { |
2841 |
// make sure resizer-bar is positioned correctly
|
2842 |
// handles situation where nested layout was 'hidden' when initialized
|
2843 |
var
|
2844 |
side = c.side.toLowerCase() |
2845 |
, pos = s.size + sC["inset"+ c.side]
|
2846 |
; |
2847 |
if (_cssNum($R, side) != pos) $R.css( side, pos ); |
2848 |
} |
2849 |
|
2850 |
// if was previously hidden due to noRoom, then RESET because NOW there is room
|
2851 |
if (s.noRoom) {
|
2852 |
// s.noRoom state will be set by open or show
|
2853 |
if (s.wasOpen && o.closable) {
|
2854 |
if (o.autoReopen)
|
2855 |
open(pane, false, true, true); // true = noAnimation, true = noAlert |
2856 |
else // leave the pane closed, so just update state |
2857 |
s.noRoom = false;
|
2858 |
} |
2859 |
else
|
2860 |
show(pane, s.wasOpen, true, true); // true = noAnimation, true = noAlert |
2861 |
} |
2862 |
} |
2863 |
else { // !hasRoom - pane CANNOT fit |
2864 |
if (!s.noRoom) { // pane not set as noRoom yet, so hide or close it now... |
2865 |
s.noRoom = true; // update state |
2866 |
s.wasOpen = !s.isClosed && !s.isSliding; |
2867 |
if (o.closable) // 'close' if possible |
2868 |
close(pane, true, true); // true = force, true = noAnimation |
2869 |
else // 'hide' pane if cannot just be closed |
2870 |
hide(pane, true); // true = noAnimation |
2871 |
} |
2872 |
} |
2873 |
}; |
2874 |
|
2875 |
|
2876 |
/**
|
2877 |
* sizePane / manualSizePane
|
2878 |
* sizePane is called only by internal methods whenever a pane needs to be resized
|
2879 |
* manualSizePane is an exposed flow-through method allowing extra code when pane is 'manually resized'
|
2880 |
*
|
2881 |
* @param {string} pane The pane being resized
|
2882 |
* @param {number} size The *desired* new size for this pane - will be validated
|
2883 |
* @param {boolean=} skipCallback Should the onresize callback be run?
|
2884 |
*/
|
2885 |
var manualSizePane = function (pane, size, skipCallback) { |
2886 |
// ANY call to sizePane will disabled autoResize
|
2887 |
var
|
2888 |
o = options[pane] |
2889 |
// if resizing callbacks have been delayed and resizing is now DONE, force resizing to complete...
|
2890 |
, forceResize = o.resizeWhileDragging && !_c.isLayoutBusy // && !o.triggerEventsWhileDragging
|
2891 |
; |
2892 |
o.autoResize = false;
|
2893 |
// flow-through...
|
2894 |
sizePane(pane, size, skipCallback, forceResize); |
2895 |
} |
2896 |
|
2897 |
/**
|
2898 |
* @param {string} pane The pane being resized
|
2899 |
* @param {number} size The *desired* new size for this pane - will be validated
|
2900 |
* @param {boolean=} skipCallback Should the onresize callback be run?
|
2901 |
* @param {boolean=} force Force resizing even if does not seem necessary
|
2902 |
*/
|
2903 |
var sizePane = function (pane, size, skipCallback, force) { |
2904 |
var
|
2905 |
o = options[pane] |
2906 |
, s = state[pane] |
2907 |
, $P = $Ps[pane] |
2908 |
, $R = $Rs[pane] |
2909 |
, side = _c[pane].side.toLowerCase() |
2910 |
, inset = "inset"+ _c[pane].side
|
2911 |
, skipResizeWhileDragging = _c.isLayoutBusy && !o.triggerEventsWhileDragging |
2912 |
, oldSize |
2913 |
; |
2914 |
// calculate 'current' min/max sizes
|
2915 |
setSizeLimits(pane); // update pane-state
|
2916 |
oldSize = s.size; |
2917 |
|
2918 |
size = _parseSize(pane, size); // handle percentages & auto
|
2919 |
size = max(size, _parseSize(pane, o.minSize)); |
2920 |
size = min(size, s.maxSize); |
2921 |
if (size < s.minSize) { // not enough room for pane! |
2922 |
makePaneFit(pane, false, skipCallback); // will hide or close pane |
2923 |
return;
|
2924 |
} |
2925 |
|
2926 |
// IF newSize is same as oldSize, then nothing to do - abort
|
2927 |
if (!force && size == oldSize) return; |
2928 |
|
2929 |
// onresize_start callback CANNOT cancel resizing because this would break the layout!
|
2930 |
if (!skipCallback && state.initialized && s.isVisible)
|
2931 |
_execCallback(pane, o.onresize_start); |
2932 |
|
2933 |
// resize the pane, and make sure its visible
|
2934 |
$P.css( _c[pane].sizeType.toLowerCase(), max(1, cssSize(pane, size)) ); |
2935 |
|
2936 |
// update pane-state dimensions
|
2937 |
s.size = size; |
2938 |
$.extend(s, getElemDims($P)); |
2939 |
|
2940 |
// reposition the resizer-bar
|
2941 |
if ($R && $P.is(":visible")) $R.css( side, size + sC[inset] ); |
2942 |
|
2943 |
sizeContent(pane); |
2944 |
|
2945 |
if (!skipCallback && !skipResizeWhileDragging && state.initialized && s.isVisible) {
|
2946 |
_execCallback(pane, o.onresize_end || o.onresize); |
2947 |
resizeNestedLayout(pane); |
2948 |
} |
2949 |
|
2950 |
// resize all the adjacent panes, and adjust their toggler buttons
|
2951 |
// when skipCallback passed, it means the controlling method will handle 'other panes'
|
2952 |
if (!skipCallback) {
|
2953 |
// also no callback if live-resize is in progress and NOT triggerEventsWhileDragging
|
2954 |
if (!s.isSliding) sizeMidPanes(_c[pane].dir=="horz" ? "all" : "center", skipResizeWhileDragging, force); |
2955 |
sizeHandles("all");
|
2956 |
} |
2957 |
|
2958 |
// if opposite-pane was autoClosed, see if it can be autoOpened now
|
2959 |
var altPane = _c.altSide[pane];
|
2960 |
if (size < oldSize && state[ altPane ].noRoom) {
|
2961 |
setSizeLimits( altPane ); |
2962 |
makePaneFit( altPane, false, skipCallback );
|
2963 |
} |
2964 |
}; |
2965 |
|
2966 |
/**
|
2967 |
* @see initPanes(), sizePane(), resizeAll(), open(), close(), hide()
|
2968 |
* @param {string} panes The pane(s) being resized, comma-delmited string
|
2969 |
* @param {boolean=} skipCallback Should the onresize callback be run?
|
2970 |
* @param {boolean=} force
|
2971 |
*/
|
2972 |
var sizeMidPanes = function (panes, skipCallback, force) { |
2973 |
if (!panes || panes == "all") panes = "east,west,center"; |
2974 |
|
2975 |
$.each(panes.split(","), function (i, pane) { |
2976 |
if (!$Ps[pane]) return; // NO PANE - skip |
2977 |
var
|
2978 |
o = options[pane] |
2979 |
, s = state[pane] |
2980 |
, $P = $Ps[pane] |
2981 |
, $R = $Rs[pane] |
2982 |
, isCenter= (pane=="center")
|
2983 |
, hasRoom = true
|
2984 |
, CSS = {} |
2985 |
, d = calcNewCenterPaneDims() |
2986 |
; |
2987 |
// update pane-state dimensions
|
2988 |
$.extend(s, getElemDims($P)); |
2989 |
|
2990 |
if (pane == "center") { |
2991 |
if (!force && s.isVisible && d.width == s.outerWidth && d.height == s.outerHeight)
|
2992 |
return true; // SKIP - pane already the correct size |
2993 |
// set state for makePaneFit() logic
|
2994 |
$.extend(s, cssMinDims(pane), {
|
2995 |
maxWidth: d.width
|
2996 |
, maxHeight: d.height
|
2997 |
}); |
2998 |
CSS = d; |
2999 |
// convert OUTER width/height to CSS width/height
|
3000 |
CSS.width = cssW(pane, d.width); |
3001 |
CSS.height = cssH(pane, d.height); |
3002 |
hasRoom = CSS.width > 0 && CSS.height > 0; |
3003 |
|
3004 |
// during layout init, try to shrink east/west panes to make room for center
|
3005 |
if (!hasRoom && !state.initialized && o.minWidth > 0) { |
3006 |
var
|
3007 |
reqPx = o.minWidth - s.outerWidth |
3008 |
, minE = options.east.minSize || 0
|
3009 |
, minW = options.west.minSize || 0
|
3010 |
, sizeE = state.east.size |
3011 |
, sizeW = state.west.size |
3012 |
, newE = sizeE |
3013 |
, newW = sizeW |
3014 |
; |
3015 |
if (reqPx > 0 && state.east.isVisible && sizeE > minE) { |
3016 |
newE = max( sizeE-minE, sizeE-reqPx ); |
3017 |
reqPx -= sizeE-newE; |
3018 |
} |
3019 |
if (reqPx > 0 && state.west.isVisible && sizeW > minW) { |
3020 |
newW = max( sizeW-minW, sizeW-reqPx ); |
3021 |
reqPx -= sizeW-newW; |
3022 |
} |
3023 |
// IF we found enough extra space, then resize the border panes as calculated
|
3024 |
if (reqPx == 0) { |
3025 |
if (sizeE != minE)
|
3026 |
sizePane('east', newE, true); // true = skipCallback - initPanes will handle when done |
3027 |
if (sizeW != minW)
|
3028 |
sizePane('west', newW, true); |
3029 |
// now start over!
|
3030 |
sizeMidPanes('center', skipCallback, force);
|
3031 |
return; // abort this loop |
3032 |
} |
3033 |
} |
3034 |
} |
3035 |
else { // for east and west, set only the height, which is same as center height |
3036 |
// set state.min/maxWidth/Height for makePaneFit() logic
|
3037 |
$.extend(s, getElemDims($P), cssMinDims(pane)) |
3038 |
if (!force && !s.noVerticalRoom && d.height == s.outerHeight)
|
3039 |
return true; // SKIP - pane already the correct size |
3040 |
CSS.top = d.top; |
3041 |
CSS.bottom = d.bottom; |
3042 |
CSS.height = cssH(pane, d.height); |
3043 |
s.maxHeight = max(0, CSS.height);
|
3044 |
hasRoom = (s.maxHeight > 0);
|
3045 |
if (!hasRoom) s.noVerticalRoom = true; // makePaneFit() logic |
3046 |
} |
3047 |
|
3048 |
if (hasRoom) {
|
3049 |
// resizeAll passes skipCallback because it triggers callbacks after ALL panes are resized
|
3050 |
if (!skipCallback && state.initialized)
|
3051 |
_execCallback(pane, o.onresize_start); |
3052 |
|
3053 |
$P.css(CSS); // apply the CSS to pane |
3054 |
$.extend(s, getElemDims($P)); // update pane dimensions |
3055 |
if (s.noRoom) makePaneFit(pane); // will re-open/show auto-closed/hidden pane |
3056 |
if (state.initialized) sizeContent(pane); // also resize the contents, if exists |
3057 |
} |
3058 |
else if (!s.noRoom && s.isVisible) // no room for pane |
3059 |
makePaneFit(pane); // will hide or close pane
|
3060 |
|
3061 |
/*
|
3062 |
* Extra CSS for IE6 or IE7 in Quirks-mode - add 'width' to NORTH/SOUTH panes
|
3063 |
* Normally these panes have only 'left' & 'right' positions so pane auto-sizes
|
3064 |
* ALSO required when pane is an IFRAME because will NOT default to 'full width'
|
3065 |
*/
|
3066 |
if (pane == "center") { // finished processing midPanes |
3067 |
var b = state.browser;
|
3068 |
var fix = b.isIE6 || (b.msie && !b.boxModel);
|
3069 |
if ($Ps.north && (fix || state.north.tagName=="IFRAME")) |
3070 |
$Ps.north.css("width", cssW($Ps.north, sC.innerWidth)); |
3071 |
if ($Ps.south && (fix || state.south.tagName=="IFRAME")) |
3072 |
$Ps.south.css("width", cssW($Ps.south, sC.innerWidth)); |
3073 |
} |
3074 |
|
3075 |
// resizeAll passes skipCallback because it triggers callbacks after ALL panes are resized
|
3076 |
if (!skipCallback && state.initialized && s.isVisible) {
|
3077 |
_execCallback(pane, o.onresize_end || o.onresize); |
3078 |
resizeNestedLayout(pane); |
3079 |
} |
3080 |
}); |
3081 |
}; |
3082 |
|
3083 |
|
3084 |
/**
|
3085 |
* @see window.onresize(), callbacks or custom code
|
3086 |
*/
|
3087 |
var resizeAll = function () { |
3088 |
var
|
3089 |
oldW = sC.innerWidth |
3090 |
, oldH = sC.innerHeight |
3091 |
; |
3092 |
$.extend( state.container, getElemDims( $Container ) ); // UPDATE container dimensions |
3093 |
if (!sC.outerHeight) return; // cannot size layout when 'container' is hidden or collapsed |
3094 |
|
3095 |
// onresizeall_start will CANCEL resizing if returns false
|
3096 |
// state.container has already been set, so user can access this info for calcuations
|
3097 |
if (false === _execCallback(null, options.onresizeall_start)) return false; |
3098 |
|
3099 |
var
|
3100 |
// see if container is now 'smaller' than before
|
3101 |
shrunkH = (sC.innerHeight < oldH) |
3102 |
, shrunkW = (sC.innerWidth < oldW) |
3103 |
, $P, o, s, dir
|
3104 |
; |
3105 |
// NOTE special order for sizing: S-N-E-W
|
3106 |
$.each(["south","north","east","west"], function (i, pane) { |
3107 |
if (!$Ps[pane]) return; // no pane - SKIP |
3108 |
s = state[pane]; |
3109 |
o = options[pane]; |
3110 |
dir = _c[pane].dir; |
3111 |
|
3112 |
if (o.autoResize && s.size != o.size) // resize pane to original size set in options |
3113 |
sizePane(pane, o.size, true, true); // true=skipCallback, true=forceResize |
3114 |
else {
|
3115 |
setSizeLimits(pane); |
3116 |
makePaneFit(pane, false, true, true); // true=skipCallback, true=forceResize |
3117 |
} |
3118 |
}); |
3119 |
|
3120 |
sizeMidPanes("all", true, true); // true=skipCallback, true=forceResize |
3121 |
sizeHandles("all"); // reposition the toggler elements |
3122 |
|
3123 |
// trigger all individual pane callbacks AFTER layout has finished resizing
|
3124 |
o = options; // reuse alias
|
3125 |
$.each(_c.allPanes.split(","), function (i, pane) { |
3126 |
$P = $Ps[pane]; |
3127 |
if (!$P) return; // SKIP |
3128 |
if (state[pane].isVisible) // undefined for non-existent panes |
3129 |
_execCallback(pane, o[pane].onresize_end || o[pane].onresize); // callback - if exists
|
3130 |
resizeNestedLayout(pane); |
3131 |
}); |
3132 |
|
3133 |
_execCallback(null, o.onresizeall_end || o.onresizeall); // onresizeall callback, if exists |
3134 |
}; |
3135 |
|
3136 |
|
3137 |
/**
|
3138 |
* Whenever a pane resizes or opens that has a nested layout, trigger resizeAll
|
3139 |
*
|
3140 |
* @param {string} pane The pane just resized or opened
|
3141 |
*/
|
3142 |
var resizeNestedLayout = function (pane) { |
3143 |
var
|
3144 |
$P = $Ps[pane] |
3145 |
, $C = $Cs[pane] |
3146 |
, d = "layoutContainer"
|
3147 |
; |
3148 |
if (options[pane].resizeNestedLayout) {
|
3149 |
if ($P.data( d )) |
3150 |
$P.layout().resizeAll();
|
3151 |
else if ($C && $C.data( d )) |
3152 |
$C.layout().resizeAll();
|
3153 |
} |
3154 |
}; |
3155 |
|
3156 |
|
3157 |
/**
|
3158 |
* IF pane has a content-div, then resize all elements inside pane to fit pane-height
|
3159 |
*
|
3160 |
* @param {string=} panes The pane(s) being resized
|
3161 |
* @param {boolean=} remeasure Should the content (header/footer) be remeasured?
|
3162 |
*/
|
3163 |
var sizeContent = function (panes, remeasure) { |
3164 |
if (!panes || panes == "all") panes = _c.allPanes; |
3165 |
$.each(panes.split(","), function (idx, pane) { |
3166 |
var
|
3167 |
$P = $Ps[pane] |
3168 |
, $C = $Cs[pane] |
3169 |
, o = options[pane] |
3170 |
, s = state[pane] |
3171 |
, m = s.content // m = measurements
|
3172 |
; |
3173 |
if (!$P || !$C || !$P.is(":visible")) return true; // NOT VISIBLE - skip |
3174 |
|
3175 |
// onsizecontent_start will CANCEL resizing if returns false
|
3176 |
if (false === _execCallback(null, o.onsizecontent_start)) return; |
3177 |
|
3178 |
// skip re-measuring offsets if live-resizing
|
3179 |
if (!_c.isLayoutBusy || m.top == undefined || remeasure || o.resizeContentWhileDragging) { |
3180 |
_measure(); |
3181 |
// if any footers are below pane-bottom, they may not measure correctly,
|
3182 |
// so allow pane overflow and re-measure
|
3183 |
if (m.hiddenFooters > 0 && $P.css("overflow") == "hidden") { |
3184 |
$P.css("overflow", "visible"); |
3185 |
_measure(); // remeasure while overflowing
|
3186 |
$P.css("overflow", "hidden"); |
3187 |
} |
3188 |
} |
3189 |
// NOTE: spaceAbove/Below *includes* the pane's paddingTop/Bottom, but not pane.borders
|
3190 |
var newH = s.innerHeight - (m.spaceAbove - s.css.paddingTop) - (m.spaceBelow - s.css.paddingBottom);
|
3191 |
if (!$C.is(":visible") || m.height != newH) { |
3192 |
// size the Content element to fit new pane-size - will autoHide if not enough room
|
3193 |
setOuterHeight($C, newH, true); // true=autoHide |
3194 |
m.height = newH; // save new height
|
3195 |
}; |
3196 |
|
3197 |
if (state.initialized) {
|
3198 |
_execCallback(pane, o.onsizecontent_end || o.onsizecontent); |
3199 |
resizeNestedLayout(pane); |
3200 |
} |
3201 |
|
3202 |
|
3203 |
function _below ($E) { |
3204 |
return max(s.css.paddingBottom, (parseInt($E.css("marginBottom"), 10) || 0)); |
3205 |
}; |
3206 |
|
3207 |
function _measure () { |
3208 |
var
|
3209 |
ignore = options[pane].contentIgnoreSelector |
3210 |
, $Fs = $C.nextAll().not(ignore || ':lt(0)') // not :lt(0) = ALL |
3211 |
, $Fs_vis = $Fs.filter(':visible') |
3212 |
, $F = $Fs_vis.filter(':last') |
3213 |
; |
3214 |
m = { |
3215 |
top: $C[0].offsetTop |
3216 |
, height: $C.outerHeight() |
3217 |
, numFooters: $Fs.length |
3218 |
, hiddenFooters: $Fs.length - $Fs_vis.length |
3219 |
, spaceBelow: 0 // correct if no content footer ($E) |
3220 |
} |
3221 |
m.spaceAbove = m.top; // just for state - not used in calc
|
3222 |
m.bottom = m.top + m.height; |
3223 |
if ($F.length) |
3224 |
//spaceBelow = (LastFooter.top + LastFooter.height) [footerBottom] - Content.bottom + max(LastFooter.marginBottom, pane.paddingBotom)
|
3225 |
m.spaceBelow = ($F[0].offsetTop + $F.outerHeight()) - m.bottom + _below($F); |
3226 |
else // no footer - check marginBottom on Content element itself |
3227 |
m.spaceBelow = _below($C);
|
3228 |
}; |
3229 |
}); |
3230 |
}; |
3231 |
|
3232 |
|
3233 |
/**
|
3234 |
* Called every time a pane is opened, closed, or resized to slide the togglers to 'center' and adjust their length if necessary
|
3235 |
*
|
3236 |
* @see initHandles(), open(), close(), resizeAll()
|
3237 |
* @param {string=} panes The pane(s) being resized
|
3238 |
*/
|
3239 |
var sizeHandles = function (panes) { |
3240 |
if (!panes || panes == "all") panes = _c.borderPanes; |
3241 |
|
3242 |
$.each(panes.split(","), function (i, pane) { |
3243 |
var
|
3244 |
o = options[pane] |
3245 |
, s = state[pane] |
3246 |
, $P = $Ps[pane] |
3247 |
, $R = $Rs[pane] |
3248 |
, $T = $Ts[pane] |
3249 |
, $TC
|
3250 |
; |
3251 |
if (!$P || !$R) return; |
3252 |
|
3253 |
var
|
3254 |
dir = _c[pane].dir |
3255 |
, _state = (s.isClosed ? "_closed" : "_open") |
3256 |
, spacing = o["spacing"+ _state]
|
3257 |
, togAlign = o["togglerAlign"+ _state]
|
3258 |
, togLen = o["togglerLength"+ _state]
|
3259 |
, paneLen |
3260 |
, offset |
3261 |
, CSS = {} |
3262 |
; |
3263 |
|
3264 |
if (spacing == 0) { |
3265 |
$R.hide();
|
3266 |
return;
|
3267 |
} |
3268 |
else if (!s.noRoom && !s.isHidden) // skip if resizer was hidden for any reason |
3269 |
$R.show(); // in case was previously hidden |
3270 |
|
3271 |
// Resizer Bar is ALWAYS same width/height of pane it is attached to
|
3272 |
if (dir == "horz") { // north/south |
3273 |
paneLen = $P.outerWidth(); // s.outerWidth || |
3274 |
s.resizerLength = paneLen; |
3275 |
$R.css({
|
3276 |
width: max(1, cssW($R, paneLen)) // account for borders & padding |
3277 |
, height: max(0, cssH($R, spacing)) // ditto |
3278 |
, left: _cssNum($P, "left") |
3279 |
}); |
3280 |
} |
3281 |
else { // east/west |
3282 |
paneLen = $P.outerHeight(); // s.outerHeight || |
3283 |
s.resizerLength = paneLen; |
3284 |
$R.css({
|
3285 |
height: max(1, cssH($R, paneLen)) // account for borders & padding |
3286 |
, width: max(0, cssW($R, spacing)) // ditto |
3287 |
, top: sC.insetTop + getPaneSize("north", true) // TODO: what if no North pane? |
3288 |
//, top: _cssNum($Ps["center"], "top")
|
3289 |
}); |
3290 |
} |
3291 |
|
3292 |
// remove hover classes
|
3293 |
removeHover( o, $R );
|
3294 |
|
3295 |
if ($T) { |
3296 |
if (togLen == 0 || (s.isSliding && o.hideTogglerOnSlide)) { |
3297 |
$T.hide(); // always HIDE the toggler when 'sliding' |
3298 |
return;
|
3299 |
} |
3300 |
else
|
3301 |
$T.show(); // in case was previously hidden |
3302 |
|
3303 |
if (!(togLen > 0) || togLen == "100%" || togLen > paneLen) { |
3304 |
togLen = paneLen; |
3305 |
offset = 0;
|
3306 |
} |
3307 |
else { // calculate 'offset' based on options.PANE.togglerAlign_open/closed |
3308 |
if (isStr(togAlign)) {
|
3309 |
switch (togAlign) {
|
3310 |
case "top": |
3311 |
case "left": offset = 0; |
3312 |
break;
|
3313 |
case "bottom": |
3314 |
case "right": offset = paneLen - togLen; |
3315 |
break;
|
3316 |
case "middle": |
3317 |
case "center": |
3318 |
default: offset = Math.floor((paneLen - togLen) / 2); // 'default' catches typos |
3319 |
} |
3320 |
} |
3321 |
else { // togAlign = number |
3322 |
var x = parseInt(togAlign, 10); // |
3323 |
if (togAlign >= 0) offset = x; |
3324 |
else offset = paneLen - togLen + x; // NOTE: x is negative! |
3325 |
} |
3326 |
} |
3327 |
|
3328 |
if (dir == "horz") { // north/south |
3329 |
var width = cssW($T, togLen); |
3330 |
$T.css({
|
3331 |
width: max(0, width) // account for borders & padding |
3332 |
, height: max(1, cssH($T, spacing)) // ditto |
3333 |
, left: offset // TODO: VERIFY that toggler positions correctly for ALL values |
3334 |
, top: 0 |
3335 |
}); |
3336 |
// CENTER the toggler content SPAN
|
3337 |
$T.children(".content").each(function(){ |
3338 |
$TC = $(this); |
3339 |
$TC.css("marginLeft", Math.floor((width-$TC.outerWidth())/2)); // could be negative |
3340 |
}); |
3341 |
} |
3342 |
else { // east/west |
3343 |
var height = cssH($T, togLen); |
3344 |
$T.css({
|
3345 |
height: max(0, height) // account for borders & padding |
3346 |
, width: max(1, cssW($T, spacing)) // ditto |
3347 |
, top: offset // POSITION the toggler |
3348 |
, left: 0 |
3349 |
}); |
3350 |
// CENTER the toggler content SPAN
|
3351 |
$T.children(".content").each(function(){ |
3352 |
$TC = $(this); |
3353 |
$TC.css("marginTop", Math.floor((height-$TC.outerHeight())/2)); // could be negative |
3354 |
}); |
3355 |
} |
3356 |
|
3357 |
// remove ALL hover classes
|
3358 |
removeHover( 0, $T ); |
3359 |
} |
3360 |
|
3361 |
// DONE measuring and sizing this resizer/toggler, so can be 'hidden' now
|
3362 |
if (!state.initialized && o.initHidden) {
|
3363 |
$R.hide();
|
3364 |
if ($T) $T.hide(); |
3365 |
} |
3366 |
}); |
3367 |
}; |
3368 |
|
3369 |
|
3370 |
/**
|
3371 |
* Move a pane from source-side (eg, west) to target-side (eg, east)
|
3372 |
* If pane exists on target-side, move that to source-side, ie, 'swap' the panes
|
3373 |
*
|
3374 |
* @param {string} pane1 The pane/edge being swapped
|
3375 |
* @param {string} pane2 ditto
|
3376 |
*/
|
3377 |
var swapPanes = function (pane1, pane2) { |
3378 |
// change state.edge NOW so callbacks can know where pane is headed...
|
3379 |
state[pane1].edge = pane2; |
3380 |
state[pane2].edge = pane1; |
3381 |
// run these even if NOT state.initialized
|
3382 |
var cancelled = false; |
3383 |
if (false === _execCallback(pane1, options[pane1].onswap_start)) cancelled = true; |
3384 |
if (!cancelled && false === _execCallback(pane2, options[pane2].onswap_start)) cancelled = true; |
3385 |
if (cancelled) {
|
3386 |
state[pane1].edge = pane1; // reset
|
3387 |
state[pane2].edge = pane2; |
3388 |
return;
|
3389 |
} |
3390 |
|
3391 |
var
|
3392 |
oPane1 = copy( pane1 ) |
3393 |
, oPane2 = copy( pane2 ) |
3394 |
, sizes = {} |
3395 |
; |
3396 |
sizes[pane1] = oPane1 ? oPane1.state.size : 0;
|
3397 |
sizes[pane2] = oPane2 ? oPane2.state.size : 0;
|
3398 |
|
3399 |
// clear pointers & state
|
3400 |
$Ps[pane1] = false; |
3401 |
$Ps[pane2] = false; |
3402 |
state[pane1] = {}; |
3403 |
state[pane2] = {}; |
3404 |
|
3405 |
// ALWAYS remove the resizer & toggler elements
|
3406 |
if ($Ts[pane1]) $Ts[pane1].remove(); |
3407 |
if ($Ts[pane2]) $Ts[pane2].remove(); |
3408 |
if ($Rs[pane1]) $Rs[pane1].remove(); |
3409 |
if ($Rs[pane2]) $Rs[pane2].remove(); |
3410 |
$Rs[pane1] = $Rs[pane2] = $Ts[pane1] = $Ts[pane2] = false; |
3411 |
|
3412 |
// transfer element pointers and data to NEW Layout keys
|
3413 |
move( oPane1, pane2 ); |
3414 |
move( oPane2, pane1 ); |
3415 |
|
3416 |
// cleanup objects
|
3417 |
oPane1 = oPane2 = sizes = null;
|
3418 |
|
3419 |
// make panes 'visible' again
|
3420 |
if ($Ps[pane1]) $Ps[pane1].css(_c.visible); |
3421 |
if ($Ps[pane2]) $Ps[pane2].css(_c.visible); |
3422 |
|
3423 |
// fix any size discrepancies caused by swap
|
3424 |
resizeAll(); |
3425 |
|
3426 |
// run these even if NOT state.initialized
|
3427 |
_execCallback(pane1, options[pane1].onswap_end || options[pane1].onswap); |
3428 |
_execCallback(pane2, options[pane2].onswap_end || options[pane2].onswap); |
3429 |
|
3430 |
return;
|
3431 |
|
3432 |
function copy (n) { // n = pane |
3433 |
var
|
3434 |
$P = $Ps[n] |
3435 |
, $C = $Cs[n] |
3436 |
; |
3437 |
return !$P ? false : { |
3438 |
pane: n
|
3439 |
, P: $P ? $P[0] : false |
3440 |
, C: $C ? $C[0] : false |
3441 |
, state: $.extend({}, state[n]) |
3442 |
, options: $.extend({}, options[n]) |
3443 |
} |
3444 |
}; |
3445 |
|
3446 |
function move (oPane, pane) { |
3447 |
if (!oPane) return; |
3448 |
var
|
3449 |
P = oPane.P |
3450 |
, C = oPane.C |
3451 |
, oldPane = oPane.pane |
3452 |
, c = _c[pane] |
3453 |
, side = c.side.toLowerCase() |
3454 |
, inset = "inset"+ c.side
|
3455 |
// save pane-options that should be retained
|
3456 |
, s = $.extend({}, state[pane])
|
3457 |
, o = options[pane] |
3458 |
// RETAIN side-specific FX Settings - more below
|
3459 |
, fx = { resizerCursor: o.resizerCursor }
|
3460 |
, re, size, pos |
3461 |
; |
3462 |
$.each("fxName,fxSpeed,fxSettings".split(","), function (i, k) { |
3463 |
fx[k] = o[k]; |
3464 |
fx[k +"_open"] = o[k +"_open"]; |
3465 |
fx[k +"_close"] = o[k +"_close"]; |
3466 |
}); |
3467 |
|
3468 |
// update object pointers and attributes
|
3469 |
$Ps[pane] = $(P) |
3470 |
.data("layoutEdge", pane)
|
3471 |
.css(_c.hidden) |
3472 |
.css(c.cssReq) |
3473 |
; |
3474 |
$Cs[pane] = C ? $(C) : false; |
3475 |
|
3476 |
// set options and state
|
3477 |
options[pane] = $.extend({}, oPane.options, fx);
|
3478 |
state[pane] = $.extend({}, oPane.state);
|
3479 |
|
3480 |
// change classNames on the pane, eg: ui-layout-pane-east ==> ui-layout-pane-west
|
3481 |
re = new RegExp(o.paneClass +"-"+ oldPane, "g"); |
3482 |
P.className = P.className.replace(re, o.paneClass +"-"+ pane);
|
3483 |
|
3484 |
// ALWAYS regenerate the resizer & toggler elements
|
3485 |
initHandles(pane); // create the required resizer & toggler
|
3486 |
initResizable(pane); |
3487 |
|
3488 |
// if moving to different orientation, then keep 'target' pane size
|
3489 |
if (c.dir != _c[oldPane].dir) {
|
3490 |
size = sizes[pane] || 0;
|
3491 |
setSizeLimits(pane); // update pane-state
|
3492 |
size = max(size, state[pane].minSize); |
3493 |
// use manualSizePane to disable autoResize - not useful after panes are swapped
|
3494 |
manualSizePane(pane, size, true); // true = skipCallback |
3495 |
} |
3496 |
else // move the resizer here |
3497 |
$Rs[pane].css(side, sC[inset] + (state[pane].isVisible ? getPaneSize(pane) : 0)); |
3498 |
|
3499 |
|
3500 |
// ADD CLASSNAMES & SLIDE-BINDINGS
|
3501 |
if (oPane.state.isVisible && !s.isVisible)
|
3502 |
setAsOpen(pane, true); // true = skipCallback |
3503 |
else {
|
3504 |
setAsClosed(pane); |
3505 |
bindStartSlidingEvent(pane, true); // will enable events IF option is set |
3506 |
} |
3507 |
|
3508 |
// DESTROY the object
|
3509 |
oPane = null;
|
3510 |
}; |
3511 |
}; |
3512 |
|
3513 |
|
3514 |
/**
|
3515 |
* Capture keys when enableCursorHotkey - toggle pane if hotkey pressed
|
3516 |
*
|
3517 |
* @see document.keydown()
|
3518 |
*/
|
3519 |
function keyDown (evt) { |
3520 |
if (!evt) return true; |
3521 |
var code = evt.keyCode;
|
3522 |
if (code < 33) return true; // ignore special keys: ENTER, TAB, etc |
3523 |
|
3524 |
var
|
3525 |
PANE = { |
3526 |
38: "north" // Up Cursor - $.ui.keyCode.UP |
3527 |
, 40: "south" // Down Cursor - $.ui.keyCode.DOWN |
3528 |
, 37: "west" // Left Cursor - $.ui.keyCode.LEFT |
3529 |
, 39: "east" // Right Cursor - $.ui.keyCode.RIGHT |
3530 |
} |
3531 |
, ALT = evt.altKey // no worky!
|
3532 |
, SHIFT = evt.shiftKey |
3533 |
, CTRL = evt.ctrlKey |
3534 |
, CURSOR = (CTRL && code >= 37 && code <= 40) |
3535 |
, o, k, m, pane |
3536 |
; |
3537 |
|
3538 |
if (CURSOR && options[PANE[code]].enableCursorHotkey) // valid cursor-hotkey |
3539 |
pane = PANE[code]; |
3540 |
else if (CTRL || SHIFT) // check to see if this matches a custom-hotkey |
3541 |
$.each(_c.borderPanes.split(","), function (i, p) { // loop each pane to check its hotkey |
3542 |
o = options[p]; |
3543 |
k = o.customHotkey; |
3544 |
m = o.customHotkeyModifier; // if missing or invalid, treated as "CTRL+SHIFT"
|
3545 |
if ((SHIFT && m=="SHIFT") || (CTRL && m=="CTRL") || (CTRL && SHIFT)) { // Modifier matches |
3546 |
if (k && code == (isNaN(k) || k <= 9 ? k.toUpperCase().charCodeAt(0) : k)) { // Key matches |
3547 |
pane = p; |
3548 |
return false; // BREAK |
3549 |
} |
3550 |
} |
3551 |
}); |
3552 |
|
3553 |
// validate pane
|
3554 |
if (!pane || !$Ps[pane] || !options[pane].closable || state[pane].isHidden) |
3555 |
return true; |
3556 |
|
3557 |
toggle(pane); |
3558 |
|
3559 |
evt.stopPropagation(); |
3560 |
evt.returnValue = false; // CANCEL key |
3561 |
return false; |
3562 |
}; |
3563 |
|
3564 |
|
3565 |
/*
|
3566 |
* ######################################
|
3567 |
* UTILITY METHODS
|
3568 |
* called externally or by initButtons
|
3569 |
* ######################################
|
3570 |
*/
|
3571 |
|
3572 |
/**
|
3573 |
* Change/reset a pane's overflow setting & zIndex to allow popups/drop-downs to work
|
3574 |
*
|
3575 |
* @param {Object=} el (optional) Can also be 'bound' to a click, mouseOver, or other event
|
3576 |
*/
|
3577 |
function allowOverflow (el) { |
3578 |
if (this && this.tagName) el = this; // BOUND to element |
3579 |
var $P; |
3580 |
if (isStr(el))
|
3581 |
$P = $Ps[el]; |
3582 |
else if ($(el).data("layoutRole")) |
3583 |
$P = $(el); |
3584 |
else
|
3585 |
$(el).parents().each(function(){ |
3586 |
if ($(this).data("layoutRole")) { |
3587 |
$P = $(this); |
3588 |
return false; // BREAK |
3589 |
} |
3590 |
}); |
3591 |
if (!$P || !$P.length) return; // INVALID |
3592 |
|
3593 |
var
|
3594 |
pane = $P.data("layoutEdge") |
3595 |
, s = state[pane] |
3596 |
; |
3597 |
|
3598 |
// if pane is already raised, then reset it before doing it again!
|
3599 |
// this would happen if allowOverflow is attached to BOTH the pane and an element
|
3600 |
if (s.cssSaved)
|
3601 |
resetOverflow(pane); // reset previous CSS before continuing
|
3602 |
|
3603 |
// if pane is raised by sliding or resizing, or it's closed, then abort
|
3604 |
if (s.isSliding || s.isResizing || s.isClosed) {
|
3605 |
s.cssSaved = false;
|
3606 |
return;
|
3607 |
} |
3608 |
|
3609 |
var
|
3610 |
newCSS = { zIndex: (_c.zIndex.pane_normal + 2) } |
3611 |
, curCSS = {} |
3612 |
, of = $P.css("overflow") |
3613 |
, ofX = $P.css("overflowX") |
3614 |
, ofY = $P.css("overflowY") |
3615 |
; |
3616 |
// determine which, if any, overflow settings need to be changed
|
3617 |
if (of != "visible") { |
3618 |
curCSS.overflow = of; |
3619 |
newCSS.overflow = "visible";
|
3620 |
} |
3621 |
if (ofX && !ofX.match(/visible|auto/)) { |
3622 |
curCSS.overflowX = ofX; |
3623 |
newCSS.overflowX = "visible";
|
3624 |
} |
3625 |
if (ofY && !ofY.match(/visible|auto/)) { |
3626 |
curCSS.overflowY = ofX; |
3627 |
newCSS.overflowY = "visible";
|
3628 |
} |
3629 |
|
3630 |
// save the current overflow settings - even if blank!
|
3631 |
s.cssSaved = curCSS; |
3632 |
|
3633 |
// apply new CSS to raise zIndex and, if necessary, make overflow 'visible'
|
3634 |
$P.css( newCSS );
|
3635 |
|
3636 |
// make sure the zIndex of all other panes is normal
|
3637 |
$.each(_c.allPanes.split(","), function(i, p) { |
3638 |
if (p != pane) resetOverflow(p);
|
3639 |
}); |
3640 |
|
3641 |
}; |
3642 |
|
3643 |
function resetOverflow (el) { |
3644 |
if (this && this.tagName) el = this; // BOUND to element |
3645 |
var $P; |
3646 |
if (isStr(el))
|
3647 |
$P = $Ps[el]; |
3648 |
else if ($(el).data("layoutRole")) |
3649 |
$P = $(el); |
3650 |
else
|
3651 |
$(el).parents().each(function(){ |
3652 |
if ($(this).data("layoutRole")) { |
3653 |
$P = $(this); |
3654 |
return false; // BREAK |
3655 |
} |
3656 |
}); |
3657 |
if (!$P || !$P.length) return; // INVALID |
3658 |
|
3659 |
var
|
3660 |
pane = $P.data("layoutEdge") |
3661 |
, s = state[pane] |
3662 |
, CSS = s.cssSaved || {} |
3663 |
; |
3664 |
// reset the zIndex
|
3665 |
if (!s.isSliding && !s.isResizing)
|
3666 |
$P.css("zIndex", _c.zIndex.pane_normal); |
3667 |
|
3668 |
// reset Overflow - if necessary
|
3669 |
$P.css( CSS );
|
3670 |
|
3671 |
// clear var
|
3672 |
s.cssSaved = false;
|
3673 |
}; |
3674 |
|
3675 |
|
3676 |
/**
|
3677 |
* Helper function to validate params received by addButton utilities
|
3678 |
*
|
3679 |
* Two classes are added to the element, based on the buttonClass...
|
3680 |
* The type of button is appended to create the 2nd className:
|
3681 |
* - ui-layout-button-pin
|
3682 |
* - ui-layout-pane-button-toggle
|
3683 |
* - ui-layout-pane-button-open
|
3684 |
* - ui-layout-pane-button-close
|
3685 |
*
|
3686 |
* @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
|
3687 |
* @param {string} pane Name of the pane the button is for: 'north', 'south', etc.
|
3688 |
* @return {Array.<Object>} If both params valid, the element matching 'selector' in a jQuery wrapper - otherwise returns null
|
3689 |
*/
|
3690 |
function getBtn (selector, pane, action) { |
3691 |
var $E = $(selector); |
3692 |
if (!$E.length) // element not found |
3693 |
alert(lang.errButton + lang.selector +": "+ selector);
|
3694 |
else if (_c.borderPanes.indexOf(pane) == -1) // invalid 'pane' sepecified |
3695 |
alert(lang.errButton + lang.Pane.toLowerCase() +": "+ pane);
|
3696 |
else { // VALID |
3697 |
var btn = options[pane].buttonClass +"-"+ action; |
3698 |
$E
|
3699 |
.addClass( btn +" "+ btn +"-"+ pane ) |
3700 |
.data("layoutName", options.name) // add layout identifier - even if blank! |
3701 |
; |
3702 |
return $E; |
3703 |
} |
3704 |
return null; // INVALID |
3705 |
}; |
3706 |
|
3707 |
|
3708 |
/**
|
3709 |
* NEW syntax for binding layout-buttons - will eventually replace addToggleBtn, addOpenBtn, etc.
|
3710 |
*
|
3711 |
* @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
|
3712 |
* @param {string} action
|
3713 |
* @param {string} pane
|
3714 |
*/
|
3715 |
function bindButton (selector, action, pane) { |
3716 |
switch (action.toLowerCase()) {
|
3717 |
case "toggle": addToggleBtn(selector, pane); break; |
3718 |
case "open": addOpenBtn(selector, pane); break; |
3719 |
case "close": addCloseBtn(selector, pane); break; |
3720 |
case "pin": addPinBtn(selector, pane); break; |
3721 |
case "toggle-slide": addToggleBtn(selector, pane, true); break; |
3722 |
case "open-slide": addOpenBtn(selector, pane, true); break; |
3723 |
} |
3724 |
}; |
3725 |
|
3726 |
/**
|
3727 |
* Add a custom Toggler button for a pane
|
3728 |
*
|
3729 |
* @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
|
3730 |
* @param {string} pane Name of the pane the button is for: 'north', 'south', etc.
|
3731 |
* @param {boolean=} slide true = slide-open, false = pin-open
|
3732 |
*/
|
3733 |
function addToggleBtn (selector, pane, slide) { |
3734 |
var $E = getBtn(selector, pane, "toggle"); |
3735 |
if ($E) |
3736 |
$E.click(function (evt) { |
3737 |
toggle(pane, !!slide); |
3738 |
evt.stopPropagation(); |
3739 |
}); |
3740 |
}; |
3741 |
|
3742 |
/**
|
3743 |
* Add a custom Open button for a pane
|
3744 |
*
|
3745 |
* @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
|
3746 |
* @param {string} pane Name of the pane the button is for: 'north', 'south', etc.
|
3747 |
* @param {boolean=} slide true = slide-open, false = pin-open
|
3748 |
*/
|
3749 |
function addOpenBtn (selector, pane, slide) { |
3750 |
var $E = getBtn(selector, pane, "open"); |
3751 |
if ($E) |
3752 |
$E
|
3753 |
.attr("title", lang.Open)
|
3754 |
.click(function (evt) {
|
3755 |
open(pane, !!slide); |
3756 |
evt.stopPropagation(); |
3757 |
}) |
3758 |
; |
3759 |
}; |
3760 |
|
3761 |
/**
|
3762 |
* Add a custom Close button for a pane
|
3763 |
*
|
3764 |
* @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
|
3765 |
* @param {string} pane Name of the pane the button is for: 'north', 'south', etc.
|
3766 |
*/
|
3767 |
function addCloseBtn (selector, pane) { |
3768 |
var $E = getBtn(selector, pane, "close"); |
3769 |
if ($E) |
3770 |
$E
|
3771 |
.attr("title", lang.Close)
|
3772 |
.click(function (evt) {
|
3773 |
close(pane); |
3774 |
evt.stopPropagation(); |
3775 |
}) |
3776 |
; |
3777 |
}; |
3778 |
|
3779 |
/**
|
3780 |
* addPinBtn
|
3781 |
*
|
3782 |
* Add a custom Pin button for a pane
|
3783 |
*
|
3784 |
* Four classes are added to the element, based on the paneClass for the associated pane...
|
3785 |
* Assuming the default paneClass and the pin is 'up', these classes are added for a west-pane pin:
|
3786 |
* - ui-layout-pane-pin
|
3787 |
* - ui-layout-pane-west-pin
|
3788 |
* - ui-layout-pane-pin-up
|
3789 |
* - ui-layout-pane-west-pin-up
|
3790 |
*
|
3791 |
* @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
|
3792 |
* @param {string} pane Name of the pane the pin is for: 'north', 'south', etc.
|
3793 |
*/
|
3794 |
function addPinBtn (selector, pane) { |
3795 |
var $E = getBtn(selector, pane, "pin"); |
3796 |
if ($E) { |
3797 |
var s = state[pane];
|
3798 |
$E.click(function (evt) { |
3799 |
setPinState($(this), pane, (s.isSliding || s.isClosed)); |
3800 |
if (s.isSliding || s.isClosed) open( pane ); // change from sliding to open |
3801 |
else close( pane ); // slide-closed |
3802 |
evt.stopPropagation(); |
3803 |
}); |
3804 |
// add up/down pin attributes and classes
|
3805 |
setPinState($E, pane, (!s.isClosed && !s.isSliding));
|
3806 |
// add this pin to the pane data so we can 'sync it' automatically
|
3807 |
// PANE.pins key is an array so we can store multiple pins for each pane
|
3808 |
_c[pane].pins.push( selector ); // just save the selector string
|
3809 |
} |
3810 |
}; |
3811 |
|
3812 |
/**
|
3813 |
* INTERNAL function to sync 'pin buttons' when pane is opened or closed
|
3814 |
* Unpinned means the pane is 'sliding' - ie, over-top of the adjacent panes
|
3815 |
*
|
3816 |
* @see open(), close()
|
3817 |
* @param {string} pane These are the params returned to callbacks by layout()
|
3818 |
* @param {boolean} doPin True means set the pin 'down', False means 'up'
|
3819 |
*/
|
3820 |
function syncPinBtns (pane, doPin) { |
3821 |
$.each(_c[pane].pins, function (i, selector) { |
3822 |
setPinState($(selector), pane, doPin);
|
3823 |
}); |
3824 |
}; |
3825 |
|
3826 |
/**
|
3827 |
* Change the class of the pin button to make it look 'up' or 'down'
|
3828 |
*
|
3829 |
* @see addPinBtn(), syncPinBtns()
|
3830 |
* @param {Array.<Object>} $Pin The pin-span element in a jQuery wrapper
|
3831 |
* @param {string} pane These are the params returned to callbacks by layout()
|
3832 |
* @param {boolean} doPin true = set the pin 'down', false = set it 'up'
|
3833 |
*/
|
3834 |
function setPinState ($Pin, pane, doPin) { |
3835 |
var updown = $Pin.attr("pin"); |
3836 |
if (updown && doPin == (updown=="down")) return; // already in correct state |
3837 |
var
|
3838 |
pin = options[pane].buttonClass +"-pin"
|
3839 |
, side = pin +"-"+ pane
|
3840 |
, UP = pin +"-up "+ side +"-up" |
3841 |
, DN = pin +"-down "+side +"-down" |
3842 |
; |
3843 |
$Pin
|
3844 |
.attr("pin", doPin ? "down" : "up") // logic |
3845 |
.attr("title", doPin ? lang.Unpin : lang.Pin)
|
3846 |
.removeClass( doPin ? UP : DN ) |
3847 |
.addClass( doPin ? DN : UP ) |
3848 |
; |
3849 |
}; |
3850 |
|
3851 |
|
3852 |
/*
|
3853 |
* LAYOUT STATE MANAGEMENT
|
3854 |
*
|
3855 |
* @example .layout({ cookie: { name: "myLayout", keys: "west.isClosed,east.isClosed" } })
|
3856 |
* @example .layout({ cookie__name: "myLayout", cookie__keys: "west.isClosed,east.isClosed" })
|
3857 |
* @example myLayout.getState( "west.isClosed,north.size,south.isHidden" );
|
3858 |
* @example myLayout.saveCookie( "west.isClosed,north.size,south.isHidden", {expires: 7} );
|
3859 |
* @example myLayout.deleteCookie();
|
3860 |
* @example myLayout.loadCookie();
|
3861 |
* @example var hSaved = myLayout.state.cookie;
|
3862 |
*/
|
3863 |
|
3864 |
function isCookiesEnabled () { |
3865 |
// TODO: is the cookieEnabled property common enough to be useful???
|
3866 |
return (navigator.cookieEnabled != 0); |
3867 |
}; |
3868 |
|
3869 |
/**
|
3870 |
* Read & return data from the cookie - as JSON
|
3871 |
*
|
3872 |
* @param {Object=} opts
|
3873 |
*/
|
3874 |
function getCookie (opts) { |
3875 |
var
|
3876 |
o = $.extend( {}, options.cookie, opts || {} )
|
3877 |
, name = o.name || options.name || "Layout"
|
3878 |
, c = document.cookie |
3879 |
, cs = c ? c.split(';') : []
|
3880 |
, pair // loop var
|
3881 |
; |
3882 |
for (var i=0, n=cs.length; i < n; i++) { |
3883 |
pair = $.trim(cs[i]).split('='); // name=value pair |
3884 |
if (pair[0] == name) // found the layout cookie |
3885 |
// convert cookie string back to a hash
|
3886 |
return decodeJSON( decodeURIComponent(pair[1]) ); |
3887 |
} |
3888 |
return ""; |
3889 |
}; |
3890 |
|
3891 |
/**
|
3892 |
* Get the current layout state and save it to a cookie
|
3893 |
*
|
3894 |
* @param {(string|Array)=} keys
|
3895 |
* @param {Object=} opts
|
3896 |
*/
|
3897 |
function saveCookie (keys, opts) { |
3898 |
var
|
3899 |
o = $.extend( {}, options.cookie, opts || {} )
|
3900 |
, name = o.name || options.name || "Layout"
|
3901 |
, params = ''
|
3902 |
, date = ''
|
3903 |
, clear = false
|
3904 |
; |
3905 |
if (o.expires.toUTCString)
|
3906 |
date = o.expires; |
3907 |
else if (typeof o.expires == 'number') { |
3908 |
date = new Date();
|
3909 |
if (o.expires > 0) |
3910 |
date.setDate(date.getDate() + o.expires); |
3911 |
else {
|
3912 |
date.setYear(1970);
|
3913 |
clear = true;
|
3914 |
} |
3915 |
} |
3916 |
if (date) params += ';expires='+ date.toUTCString(); |
3917 |
if (o.path) params += ';path='+ o.path; |
3918 |
if (o.domain) params += ';domain='+ o.domain; |
3919 |
if (o.secure) params += ';secure'; |
3920 |
|
3921 |
if (clear) {
|
3922 |
state.cookie = {}; // clear data
|
3923 |
document.cookie = name +'='+ params; // expire the cookie |
3924 |
} |
3925 |
else {
|
3926 |
state.cookie = getState(keys || o.keys); // read current panes-state
|
3927 |
document.cookie = name +'='+ encodeURIComponent( encodeJSON(state.cookie) ) + params; // write cookie |
3928 |
} |
3929 |
|
3930 |
return $.extend({}, state.cookie); // return COPY of state.cookie |
3931 |
}; |
3932 |
|
3933 |
/**
|
3934 |
* Remove the state cookie
|
3935 |
*/
|
3936 |
function deleteCookie () { |
3937 |
saveCookie('', { expires: -1 }); |
3938 |
}; |
3939 |
|
3940 |
/**
|
3941 |
* Get data from the cookie and USE IT to loadState
|
3942 |
*
|
3943 |
* @param {Object=} opts
|
3944 |
*/
|
3945 |
function loadCookie (opts) { |
3946 |
var o = getCookie(opts); // READ the cookie |
3947 |
if (o) {
|
3948 |
state.cookie = $.extend({}, o); // SET state.cookie |
3949 |
loadState(o); // LOAD the retrieved state
|
3950 |
} |
3951 |
return o;
|
3952 |
}; |
3953 |
|
3954 |
/**
|
3955 |
* Update layout options from the cookie, if one exists
|
3956 |
*
|
3957 |
* @param {Object=} opts
|
3958 |
*/
|
3959 |
function loadState (opts) { |
3960 |
$.extend( true, options, opts ); // update layout options |
3961 |
}; |
3962 |
|
3963 |
/**
|
3964 |
* Get the *current layout state* and return it as a hash
|
3965 |
*
|
3966 |
* @param {(string|Array)=} keys
|
3967 |
*/
|
3968 |
function getState (keys) { |
3969 |
var
|
3970 |
data = {} |
3971 |
, alt = { isClosed: 'initClosed', isHidden: 'initHidden' } |
3972 |
, pair, pane, key, val |
3973 |
; |
3974 |
if (!keys) keys = options.cookie.keys; // if called by user |
3975 |
if ($.isArray(keys)) keys = keys.join(","); |
3976 |
// convert keys to an array and change delimiters from '__' to '.'
|
3977 |
keys = keys.replace(/__/g, ".").split(','); |
3978 |
// loop keys and create a data hash
|
3979 |
for (var i=0,n=keys.length; i < n; i++) { |
3980 |
pair = keys[i].split(".");
|
3981 |
pane = pair[0];
|
3982 |
key = pair[1];
|
3983 |
if (_c.allPanes.indexOf(pane) < 0) continue; // bad pane! |
3984 |
val = state[ pane ][ key ]; |
3985 |
if (val == undefined) continue; |
3986 |
if (key=="isClosed" && state[pane]["isSliding"]) |
3987 |
val = true; // if sliding, then *really* isClosed |
3988 |
( data[pane] || (data[pane]={}) )[ alt[key] ? alt[key] : key ] = val; |
3989 |
} |
3990 |
return data;
|
3991 |
}; |
3992 |
|
3993 |
/**
|
3994 |
* Stringify a JSON hash so can save in a cookie or db-field
|
3995 |
*/
|
3996 |
function encodeJSON (JSON) { |
3997 |
return parse( JSON );
|
3998 |
function parse (h) { |
3999 |
var D=[], i=0, k, v, t; // k = key, v = value |
4000 |
for (k in h) { |
4001 |
v = h[k]; |
4002 |
t = typeof v;
|
4003 |
if (t == 'string') // STRING - add quotes |
4004 |
v = '"'+ v +'"'; |
4005 |
else if (t == 'object') // SUB-KEY - recurse into it |
4006 |
v = parse(v); |
4007 |
D[i++] = '"'+ k +'":'+ v; |
4008 |
} |
4009 |
return "{"+ D.join(",") +"}"; |
4010 |
}; |
4011 |
}; |
4012 |
|
4013 |
/**
|
4014 |
* Convert stringified JSON back to a hash object
|
4015 |
*/
|
4016 |
function decodeJSON (str) { |
4017 |
try { return window["eval"]("("+ str +")") || {}; } |
4018 |
catch (e) { return {}; } |
4019 |
}; |
4020 |
|
4021 |
|
4022 |
/*
|
4023 |
* #####################
|
4024 |
* CREATE/RETURN LAYOUT
|
4025 |
* #####################
|
4026 |
*/
|
4027 |
|
4028 |
// validate that container exists
|
4029 |
var $Container = $(this).eq(0); // FIRST matching Container element |
4030 |
if (!$Container.length) { |
4031 |
//alert( lang.errContainerMissing );
|
4032 |
return null; |
4033 |
}; |
4034 |
// return Instance (saved in window[state.id]) if layout has already been initialized
|
4035 |
if ($Container.data("layoutContainer")) |
4036 |
return $.extend( {}, window[ $Container.data("layoutContainer") ] ); |
4037 |
|
4038 |
// init global vars
|
4039 |
var
|
4040 |
$Ps = {} // Panes x5 - set in initPanes() |
4041 |
, $Cs = {} // Content x5 - set in initPanes() |
4042 |
, $Rs = {} // Resizers x4 - set in initHandles() |
4043 |
, $Ts = {} // Togglers x4 - set in initHandles() |
4044 |
// aliases for code brevity
|
4045 |
, sC = state.container // alias for easy access to 'container dimensions'
|
4046 |
, sID = state.id // alias for unique layout ID/namespace - eg: "layout435"
|
4047 |
; |
4048 |
|
4049 |
// create the border layout NOW
|
4050 |
_create(); |
4051 |
|
4052 |
// create Instance object to expose data & option Properties, and primary action Methods
|
4053 |
var Instance = {
|
4054 |
options: options // property - options hash |
4055 |
, state: state // property - dimensions hash |
4056 |
, container: $Container // property - object pointers for layout container |
4057 |
, panes: $Ps // property - object pointers for ALL Panes: panes.north, panes.center |
4058 |
, contents: $Cs // property - object pointers for ALL Content: content.north, content.center |
4059 |
, resizers: $Rs // property - object pointers for ALL Resizers, eg: resizers.north |
4060 |
, togglers: $Ts // property - object pointers for ALL Togglers, eg: togglers.north |
4061 |
, toggle: toggle // method - pass a 'pane' ("north", "west", etc) |
4062 |
, hide: hide // method - ditto |
4063 |
, show: show // method - ditto |
4064 |
, open: open // method - ditto |
4065 |
, close: close // method - ditto |
4066 |
, slideOpen: slideOpen // method - ditto |
4067 |
, slideClose: slideClose // method - ditto |
4068 |
, slideToggle: slideToggle // method - ditto |
4069 |
, initContent: initContent // method - ditto |
4070 |
, sizeContent: sizeContent // method - pass a 'pane' |
4071 |
, sizePane: manualSizePane // method - pass a 'pane' AND an 'outer-size' in pixels or percent, or 'auto' |
4072 |
, swapPanes: swapPanes // method - pass TWO 'panes' - will swap them |
4073 |
, resizeAll: resizeAll // method - no parameters |
4074 |
, destroy: destroy // method - no parameters |
4075 |
, setSizeLimits: setSizeLimits // method - pass a 'pane' - update state min/max data |
4076 |
, bindButton: bindButton // utility - pass element selector, 'action' and 'pane' (E, "toggle", "west") |
4077 |
, addToggleBtn: addToggleBtn // utility - pass element selector and 'pane' (E, "west") |
4078 |
, addOpenBtn: addOpenBtn // utility - ditto |
4079 |
, addCloseBtn: addCloseBtn // utility - ditto |
4080 |
, addPinBtn: addPinBtn // utility - ditto |
4081 |
, allowOverflow: allowOverflow // utility - pass calling element (this) |
4082 |
, resetOverflow: resetOverflow // utility - ditto |
4083 |
, encodeJSON: encodeJSON // method - pass a JSON object |
4084 |
, decodeJSON: decodeJSON // method - pass a string of encoded JSON |
4085 |
, getState: getState // method - returns hash of current layout-state |
4086 |
, getCookie: getCookie // method - update options from cookie - returns hash of cookie data |
4087 |
, saveCookie: saveCookie // method - optionally pass keys-list and cookie-options (hash) |
4088 |
, deleteCookie: deleteCookie // method |
4089 |
, loadCookie: loadCookie // method - update options from cookie - returns hash of cookie data |
4090 |
, loadState: loadState // method - pass a hash of state to use to update options |
4091 |
, cssWidth: cssW // utility - pass element and target outerWidth |
4092 |
, cssHeight: cssH // utility - ditto |
4093 |
}; |
4094 |
|
4095 |
// create a global instance pointer
|
4096 |
window[ sID ] = Instance; |
4097 |
|
4098 |
// return the Instance object
|
4099 |
return Instance;
|
4100 |
|
4101 |
} |
4102 |
})( jQuery ); |