PageSourceSearch

https://canadatattooshows.com/cms2t/res/js/mw.windows.js

js canadatattooshows.com collected 2026-10-09 22:41:38 UTC 40,692 bytes, 1,482 lines download raw bytes

1/** //** ----= CLASS mwWinManager	=------------------------------------------------------------------------------\**//** \
2*
3* 	Morweb windows manager class
4*
5* 	@package	VIT-Lib
6* 	@subpackage	Tools
7* 	@category	Helper
8*
9\**//** ---------------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
10var mwWinManager = {
11
12	Windows		: {},			// All windows are stored here.
13	Layers		: [],			// Visible layers list.
14	
15	Overlay		: false,		// jQuery shortcut to overlay.
16	OverlayZ	: 3000,			// Overlay z-index.
17	
18	Container	: false,		// Windows container
19
20	/** //** ----= init	=--------------------------------------------------------------------------------------\**//** \
21	*
22	* 	Initiates manager, creates shortucts to usefull elements.
23	*
24	*	@return	SELF		
25	*
26	\**//** -------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
27	init	: function () {
28		
29		var $this = this;
30		
31		// Checking if need to initiate at all
32		if ( this.Container ) 
33			return this;
34			
35		this.Container	= jQuery('#mwSectionWindows');
36		this.Overlay	= jQuery('#mwWindowsOverlay');
37
38		// Binding self to browser resize
39		jQuery(window).resize( function () {
40			$this.updatePoistions();
41		}); //jQuery.onResize
42
43		// Listening for escape button
44		jQuery(window).keyup( function ($event) {
45
46			// Esc			
47			if ( $event.which == '27' ) {
48
49				var $w = $this.getTop();
50				
51				if ( !$w || !$w.Visible || !$w.escClose )
52					return;
53
54				$w.hide();
55
56			} //IF Esc pressed
57			
58		}); //jQuery.keyup
59
60		return this;
61	}, //FUNC init
62		
63	/** //** ----= updateOverlay	=------------------------------------------------------------------------------\**//** \
64	*
65	* 	Updates overlay, depending on visible layers state.
66	*
67	*	@return	SELF		
68	*
69	\**//** -------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
70	updateOverlay	: function () {
71
72		// Making sure it is initiated
73		// ToDo: need better way to call init only once, though it is fast already
74		this.init();
75
76	/*/
77		// If overlay is not searched yet - it's right time to do so
78		if ( !this.Overlay )
79			this.Overlay = jQuery('#sysOverlay');
80	/**/
81
82		// Searching for modal windows in layers.
83		var state = false;
84		for ( var i = 0; i < this.Layers.length; i++ ) {
85			if ( this.Layers[i].Modal ) {
86				state = true;
87				break;
88			} //IF modal found
89		} //FOR each layer
90
91		// Showing or hiding, based on modals presence
92		if ( state )
93			mwShow( this.Overlay );
94		else
95			mwHide( this.Overlay );
96
97		return this;
98	}, //FUNC updateOverlay
99
100	/** //** ----= updatePoistions	=------------------------------------------------------------------------------\**//** \
101	*
102	* 	Updates layers windows positions and dimensions.
103	*
104	*	@return	SELF		
105	*
106	\**//** -------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
107	updatePoistions	: function () {
108		
109		// If there are no layers - there is nothing to do
110		if ( !this.Layers.length )
111			return this;
112
113		// Looping through layers and updating windows		
114		for ( var i = 0; i < this.Layers.length; i++ ) {
115
116
117			var wobj = this.Layers[i];	// Just shortcut
118
119			// Ignoring werid items, and extensions
120			if ( !wobj || isFunction(wobj) ) continue;
121
122			// Making sure to work only with visible windows
123			if ( !wobj.Visible ) continue;
124			
125			// Giving slight delay for windows to apply their math
126			setTimeout( function () {
127				wobj.align();
128			}, 1);
129
130		} //FOR each layer
131		
132		return this;
133	}, //FUNC updatePoistions
134	
135	/** //** ----= addLayer	=--------------------------------------------------------------------------------------\**//** \
136	*
137	* 	Adds window to top of visible layers.
138	*
139	* 	@param	object(mwWindow)	window	- Window to add as visible.
140	* 
141	*	@return	SELF		
142	*
143	\**//** -------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
144	addLayer	: function (window) {
145		
146		// Removing window from layers (if was there before), to move window on top
147		this.removeLayer(window);
148
149		this.Layers.push(window);
150		
151		return this;
152	}, //FUNC addLayer
153
154	/** //** ----= removeLayer	=------------------------------------------------------------------------------\**//** \
155	*
156	* 	Removes window from visible layers list.
157	*
158	* 	@param	object(mwWindow)	window	- Window to add as visible.
159	* 
160	*	@return	SELF		
161	*
162	\**//** -------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
163	removeLayer	: function (window) {
164
165		// Looking up for window in layers list
166		var vp = this.Layers.indexOf(window);
167		
168		if ( vp >= 0 )
169			this.Layers.splice(vp, 1);
170		
171		return this;
172	}, //FUNC removeLayer
173
174	/** //** ----= updateLayers	=------------------------------------------------------------------------------\**//** \
175	*
176	* 	Updates visible layers, setting proper z-index to each window.
177	*
178	*	@return	SELF		
179	*
180	\**//** -------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
181	updateLayers	: function () {
182		
183		// If somehow at this point there are no layers - nothing to do.
184		if ( !this.Layers.length )
185			return this;
186		
187		// Calcualting lowest layer z-index, which should be below overlay
188		var top = this.OverlayZ - this.Layers.length;
189		
190		// Looping through all layers, setting z-index, decrementing it
191		// Skipping top one, which will be above overlay in any case
192		for ( var i = 0; i < this.Layers.length - 1; i++ ) {
193
194			var wobj = this.Layers[i];	// Just shortcut
195
196			// Ignoring werid items, and extensions
197			if ( !wobj || isFunction(wobj) ) continue;
198
199			// Setting z-index, top windows will be stick above overlay
200			wobj.Window.css('z-index', wobj.AlwaysOnTop ? this.OverlayZ + 2 + i : top + i);
201			
202		} //FOR each layer
203
204		// i should contain top layer index now, setting z-index to it 
205		this.Layers[i].Window.css('z-index', this.OverlayZ + 1);
206		
207		return this;
208	}, //FUNC updateLayers
209
210	/** //** ----= getTop	=--------------------------------------------------------------------------------------\**//** \
211	*
212	* 	Returns top visible window.
213	*
214	*	@todo	Take always on top into account.
215	*
216	*	@param	bool	[$modal]	- Set TRUE to check only modals.
217	*
218	*	@return	object(mwWindow)	- Top window.		
219	*
220	\**//** -------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
221	getTop	: function ($modal) {
222		
223	 	// If no active layers - returning nothing
224	 	if ( !this.Layers.length )
225	 		return false;
226		
227		// If modal is not required - returning just top
228		if ( !$modal )
229			return this.Layers[this.Layers.length - 1];
230			
231		// Need to loop through all windows to find top modal
232		for ( var $i = this.Layers.length; $i > 0; $i-- ) {
233			
234			var $w = this.Layers[$i-1];
235			
236			// First modal found this way is what we need
237			if ( $w.Modal )
238				return $w;
239			
240		} //FOR each window
241		
242		// Nothing found, try next time
243		return false;
244	} //FUNC getTop
245
246} //OBJECT mwWinManager
247
248/** //** ----= mwWindow		 =----------------------------------------------\**//** \
249*
250* 	Returns window object. If specified window does not eixists, creates new one.
251*
252*	@param	string	id	- Window ID to return.
253*
254\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
255function mwWindow (id) {
256	
257	// Making sure winManager is initiated
258	mwWinManager.init();
259
260	if ( !mwWinManager.Windows[id] )
261		mwWinManager.Windows[id] = new mwWindowObject(id);
262	
263	return mwWinManager.Windows[id];
264} //FUNC mwWindow
265
266/** //** ----= CLASS mwWindowObject	 =----------------------------------------------\**//** \
267*
268* 	Window manipulation class.
269*
270* 	@package	MorwebManager
271* 	@subpackage	core
272* 	@category	java-tools
273*
274\**//** --------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
275var mwWindowObject = function (id) {
276	if ( id ) this.ID = id;
277} //CONSTRUCTOR mwWindowObject
278
279mwWindowObject.prototype = {
280
281// ---- Meta Options ----
282	
283	ID		: '',				// Internal Window ID
284
285// ---- Common elements ----
286	
287	Window		: false,			// jQuery Window element, points to window element
288	Body		: false,			// jQuery window body element. Usually source element.
289
290	winHeader	: false,			// jQuery pointer to window header element.
291	winFooter	: false,			// jQuery pointer to window footer element.
292
293// ---- Appearance ----
294	
295	winClass	: 'mwWindow',			// Window class.
296	winTitle	: '',				// Stores current window title.
297	
298	Modal		: true,				// Modal window (if TRUE will add overlay and prevent actions outside window)
299	AlwaysOnTop	: false,			// Force this window to stay on top of others anyway. Useful for loaders/debug etc.
300	
301	addHedaer	: true,				// Specifies if need to add header elements.
302	addControls	: true,				// Specifies if need to add window controls, like close button.
303	addFooter	: true,				// Specifies if need to add footer elements.
304	addFooterEx	: true,				// Specifies if need to add extra footer elements, like loader and status placeholder.
305
306// ---- Auto align options ----
307
308	AlignAt		: 'center',			// By default aligns at descktop center. For possible options see VIT-Lib align() function.
309	Margin		: 30,				// Whitespace to leave around window on align calculations.
310
311	limitHeight	: 0,				// Allows to set height limit for window
312	limitWidth	: true,				// Allows to set width limit for window according to screen size.
313	
314// ---- Misc ----	
315	
316	Visible		: false,			// Visible indicator
317	Concurrent	: {},				// Affected concurrent windows and their z-indexes
318
319	/** //** ----= WinID		 =----------------------------------------------\**//** \
320	*
321	* 	Returns ID of window element.
322	*
323	*	@return	string		- Window ID.
324	*
325	\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
326	WinID	: function () {
327		return 'w_' + this.ID;
328	}, //FUNC WinID
329	
330// ==== INITIATION ==== 	
331
332	/** //** ----= Source		 =----------------------------------------------\**//** \
333	*
334	* 	Sets up window using specified source. Can be either content or element.
335	*
336	*	@param	MIXED	s	- Valid content or element source.
337	*
338	*	@return	SELF
339	*
340	\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
341	Source		: function (s) {
342		
343		// If nothing given - doing nothing
344		if ( s === undefined ) return this;
345		
346		// If jQuery or DOM object - passing using as element
347		if ( s instanceof jQuery ) return this.Element(s);
348		if ( typeof(s) == 'object' ) return this.Element(s);
349		
350		// If contetns looks more like jQuery selector - still passing to set as element
351		if ( typeof(s) == 'string' && (s.length < 50) && s.match(/[#\.]{1}[A-Za-z]{2,}/) ) return this.Element(s);
352		
353		// Otherwise this is just content, passing it to Content() which will make element from it.
354		return this.Content(s);
355	}, //FUNC Source
356	
357	/** //** ----= Content		 =----------------------------------------------\**//** \
358	*
359	* 	Sets up window using specified content.
360	*
361	*	@param	MIXED	c	- Content as HTML string or callback function to call 
362	*				  content from.
363	*
364	*	@return	SELF
365	*
366	\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
367	Content		: function (c) {
368		
369		if ( typeof(c) == 'function' ) c = c();
370			
371		var el = jQuery('<div class="winEl" id="' + this.ID + '">' + c + '</div>').appendTo(mwWinManager.Container);
372		
373		return this.Element(el);
374
375	}, //FUNC Content
376	
377	/** //** ----= Element		 =----------------------------------------------\**//** \
378	*
379	* 	Sets up window using specified element.
380	*
381	*	@param	object	el	- jQuery selector, object or DOM element. 
382	*
383	*	@return	SELF
384	*
385	\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
386	Element		: function (el) {
387		
388		if ( !(el instanceof jQuery) )
389			el = jQuery(el);
390		
391		this.Body = el;
392		
393		return this._create();
394		
395	}, //FUNC Element
396
397	/** //** ----= _create		 =----------------------------------------------\**//** \
398	*
399	* 	Initiates window based on parameters set. Should not be called directly.
400	*
401	*	@return	SELF
402	*
403	\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
404	_create	: function () {
405		
406		var id	= this.ID;
407		var wid	= this.WinID();
408		var el	= this.Body; 
409		
410		if ( !el ) throw 'Invalid window setup on initiation (' + this.ID + ')';
411
412		// Initiating form elements anyway, just to ensure all elements are styled
413		styleDialog(this.Body.find('.mwDialog'));
414
415		// Checks if window is initiated already
416		if ( el.hasClass('winBody') ) return this;
417
418	// ---- BODY ----
419	
420		el.addClass('winBody');
421
422	// ---- TITLE ----
423	
424		var title = el.attr('title');
425
426		if ( title ) {
427			
428			this.winTitle = title;
429			
430			el.removeAttr('title');
431			
432		} //IF title set
433
434	// ---- WINDOW ----
435
436		// Checking for parent wrapper
437		// If that's already window, then need just reinit it
438		if ( el.parent().is('.'+this.winClass) ) {
439
440			el.show();
441			
442		} //IF already window
443		else {
444
445			el.wrapAll('<div class="' + this.winClass + '" id="' + wid + '"></div>');
446			el.show();
447			
448		} //IF new window
449
450		var wnd = this.Window = jQuery('#'+wid);
451
452	// ---- HEADER ----
453		
454		// We need to have smth there to do not collapse title. Can be reassigned later anyway.
455		if ( !this.winTitle )
456			this.winTitle = '&nbsp;';
457			
458		if ( this.addHedaer && !el.find('.winHeader').length )
459			el.prepend('<div class="winHeader">' + this.winTitle + '</div>');
460		
461		// Saving header element for future
462		this.winHeader = el.find('.winHeader');
463		
464		if ( this.winHeader.length && wnd.draggable )
465			wnd.draggable({ 
466				handle	: '.winHeader',
467				drag	: function () {
468					if ( typeof(mwHelp) !== 'undefined' ) {
469						if ( mwHelp.visible )
470							mwHelp.update();
471					} //IF help enabled
472				} //FUNC draggable.drag
473			});
473 //OBJECT draggable.options
474		
475	// ---- CONTROLS ----
476		
477		if ( this.addControls && !el.find('.winTool.close').length )
478			wnd.append('<div class="winTool close winCloseClick"></div>');
479	/*/
480		if ( this.addControls && mwHelp.Data[id] && !el.find('.winHelp').length )
481			wnd.append('<div class="winHelp winHelpClick"></div>');
482	/**/
483	// ---- FOOTER ----
484
485		if ( this.addFooter && !el.find('.winFooter').length )
486			el.append('<div class="winFooter"><a class="winCloseClick">Close</a></div>');
487
488		// Saving footer element for future
489		this.winFooter = el.find('.winFooter');
490
491		if ( this.addFooter && this.addFooterEx ) {
492			
493			var foot = this.winFooter;
494
495			foot.children().wrapAll('<div class="winSubmit"></div>');
496			
497			foot.append('<div class="winStatus"></div>');
498			foot.append('<div class="Clear"></div>');
499			foot.append('<div class="winLoader absoluteFill"></div>');
500			
501		} //IF adding extra
502
503		// Adding close click
504		wnd.find('.winCloseClick')
505			.off('click.winTool.close')
506			.on('click.winTool.close', function () {
507				
508				// Any kind of help is closed if user decides to cancel
509				if ( typeof(mwHelp) !== 'undefined' ) {
510					mwHelp.hide();
511				} //IF help is enabled
512				
513				mwWindow(id).hide();
514			}); //FUNC onClick	
515
516	// ---- Hints ----
517	
518	//	if ( window.setHintElements )
519	//		setHintElements('#' + id + ' [title], #' + id + ' [hint], #' + id + ' [error]' , id);
520
521		if ( window.mwWatchHints )
522			mwWatchHints(el, id);
523
524	// ---- Help ----
525	
526		if ( typeof(mwHelp) !== 'undefined' ) {
527
528			// Supporting simplified element syntax, so need to create standalone HTML copy, to wrap propertly with required elements (book/page)
529			var $help_html = '';
530			
531			// All .winHelp and .winHelpPage immideate descedants are help hints
532			// Difference is that all .winHelp hints are combined into first page of window book, 
533			// but .winHelpPage elmeents are standalone pages
534			// Marking all them with .helpHint
535			el.find('.winHelp>*, .winHelpPage>*').addClass('helpHint');
536
537			// Searching hints inside window	
538			var $hints = el.find('.winHelp');
539			$hints.each( function () {
540				var $hel = jQuery(this);
541
542				// Skipping ones, which are wrapped into pages already
543				if ( $hel.parent().is('.helpPage, .winHelpPage') )
544					return;
545				
546				$help_html += $hel.html();
547			}); //jQuery.each
548
549			// Wrapping hints with window default inline page
550			if ( $help_html )
551				$help_html = '<div class="helpPage" data-overlay="0">' + $help_html + '</div>';
552			
553			// Searching help pages
554			var $pages = el.find('.winHelpPage');
555			$pages.each( function () {
556				var $pel = jQuery(this);
557				
558				// Pages should be marked so
559				$pel.addClass('helpPage');
560				
561				// Not using overlay inside windows
562				$pel.attr('data-overlay', '0');
563			
564				$help_html += getOuterHTML($pel.get(0));
565			}); //jQuery.each
566
567			// Wrapping all pages into a window inline book and initiating it
568
569			if ( $help_html ) {
570				
571				// Adding wrapper div, becase .fromHtml() takes wrapper and searches withing.
572				// Ideally window boddy should be passed, but in this case simplified syntax is used
573				$help_html = '<div><div class="helpBook" data-type="inline" data-name="' + id + '">' + $help_html + '</div></div>';
574				
575				mwHelp.fromHtml($help_html);				
576
577				// Adding help click
578				wnd.append('<div class="winTool help winHelpClick"></div>');
579			} //IF hints found
580
581		} //IF help present
582
583		// Initiating all help clicks, supporting custom ones
584		wnd.find('.winHelpClick')
585			.off('click.winTool.help')
586			.on('click.winTool.help', function () {
587				// Toggling help
588				if ( mwHelp.visible )
589					mwHelp.hide();
590				else
591					mwHelp.show('inline', id);
592			}); //FUNC onClick	
593		
594		return this;
595	}, //FUNC _create
596
597	/** //** ----= _destory		 =----------------------------------------------\**//** \
598	*
599	* 	Inverts changes done by _create. I.E. Makes given element back as regular element.
600	*
601	*	@return	SELF
602	*
603	\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
604	_destory	: function () {
605		
606		var id	= this.WinID();
607		var el	= this.Body; 
608		
609	}, //FUNC _destory
610
611	/** //** ----= init		 =----------------------------------------------\**//** \
612	*
613	* 	Takes set of options as parameters and initiates object based on them. Allows 
614	*	setup with methods.
615	*
616	*	@param	object	options	- Options to support.
617	*
618	*	@return	SELF
619	*
620	\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
621	init	: function (options) {
622
623	// ---- Setting value parameters ----
624
625		for ( var op in options ) {
626
627			if ( this[op] === undefined ) continue;
628			if ( typeof(this[op]) == 'function' ) continue;
629			
630			this[op] = options[op];
631
632		} //FOR each option
633
634	// ---- Calling function parameters ----
635	
636		// Calling manually each to force correct order.
637		
638		var m = ['Content', 'Element', 'Source', 'Title', 'Class'];
639		
640		for ( var op in m ) {
641			
642			var option = m[op];
643			
644			if ( options[option] )
645				this[option](options[option]);
646			
647		} //FOR each allowed method
648
649		return this;	
650	}, //FUNC init
651
652// ==== MANIPULATION FUNCITONS ====
653	
654	/** //** ----= adjustFlexChilds	 =----------------------------------------------\**//** \
655	*
656	* 	Adjusts given row flexible childs heights.
657	*
658	*	@param	jQuery	row	- Content row to adjust
659	*
660	*	@return	SELF
661	*
662	\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
663	adjustFlexChilds	: function (row) {
664
665		var self = this;
666
667		// Limiting flex rows heights
668		row.find('.winRow.flex, .winContent.flex, .winContainer.flex').each( function () {
669			
670			var flex	= jQuery(this);
671			
672			// Calculating heights of neighbouring elements
673			// ToDo: do smth with other flexes on same level (which is not recommended though)
674			var sib		= flex.siblings('HR, .winHDivider, .winContent, .winContainer, .winRow').not('.flex');
675			
676			var sib_height	= 0;
677			sib.each( function () {
678				sib_height += jQuery(this).outerHeight(true);
679			}); //jQuery each sibling
680			
681			// Getting max height: assuming parent conent, otherwise - getting from body. 
682			// Getting lowest of height/max-height
683			var parent	= flex.parent().closest('.winContent, .winContainer');
684			
685			var max		= parseInt( parent.css('max-height') ) || parseInt( self.Body.css('max-height') );
686			var hgt		= parseInt( parent.css('height') );
687			
688			var max		= Math.min(max, hgt) || max; 
689			
690			if ( flex.hasClass('winRow') ) {
691
692				// Applying it children contents if row or self if content
693				flex.children('.winContent, .winContainer').each( function () {
694					
695					var el		= jQuery(this);
696					
697					// Setting counting outeer pads
698					var pads	= el.outerHeight(true) - el.height();
699					var h 		= max - sib_height - pads;
700					el.css('max-height', h);
701
702				}); //jQuery each child
703
704			} else { //IF row
705
706				// Setting counting outeer pads
707				var pads	= flex.outerHeight(true) - flex.height();
708				var h 		= max - sib_height - pads;
709				flex.css('max-height', h);	
710
711				// Correcting height for full height areas, those will always have full possible height 
712				// Correction is for chrome: it does not handles max-height over height for childs with 100% height
713				if ( flex.hasClass('full') )
714					flex.height(h);
715
716			} //IF content
717			
718		}); //FUNC jQuery each flex row
719
720	}, //FUNC adjustFlexChilds
721	
722	/** //** ----= adjustColumns	 =----------------------------------------------\**//** \
723	*
724	* 	Adjusts floating columns to have same widths, for proper scrolling.
725	*
726	*	@param	jQuery	row	- Content row to adjust
727	*
728	*	@return	SELF
729	*
730	\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
731	adjustColumns	: function (row) {
732	}, //FUNC adjustColumns
733	
734	/** //** ----= adjustHeights	 =----------------------------------------------\**//** \
735	*
736	* 	Adjusts window content heights based on window settings.
737	*
738	*	@param	jQuery	context	- Custom conxext to adjust. Allows partial 
739	*				  heights adjustments.
740	*
741	*	@return	SELF
742	*
743	\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
744	adjustHeights		: function (context) {
745
746		context = context || this.Body; 
747		
748		// Adding clear to rows to compensate floats
749		// This will allow to rely on row height for childs 
750		context.find('.winRow').each( function () {
751
752			var row = jQuery(this);
753			
754			// Removing if there was some
755			row.children('.Clear').remove();
756			// Adding clear
757			row.append('<div class="Clear"></div>');
758			
759		}); //jQuery each row
760
761		// Before calculating heights have to remove all old values
762		context.find('.winRow, .winContent, .winVDivider, .winContainer').each( function () {
763		
764			var el	= jQuery(this);
765
766			el.css('max-height', '');
767			el.css('min-height', '');
768
769			if ( el.hasClass('full') )
770				el.css('height', '');
771			
772		}); //FUNC each.callback
773
774		this.adjustFlexChilds(context);
775		
776		context.find('.winRow').each( function () {
777			
778			var row = jQuery(this);
779			
780			// Will collect widths necessary for columns
781			var w = 0;
782			
783			// Now row have height and we can adjust child columns
784			row.children('.winContent, .winContainer, .winVDivider').each( function () {
785				
786				var col		= jQuery(this);
787				var pads	= col.outerHeight(true) - col.height();
788				
789				var hgt		= row.height() - pads;
790				var mhgt	= parseInt( col.css('max-height') );
791				
792				if ( mhgt && hgt > mhgt )
793					hgt = mhgt;
794				
795				col.css('min-height', hgt);	
796				
797				w += col.outerWidth(true);
798				
799			}); //FUNC jQuery each child row
800		
801			// Fixing row width, to prevent collapsing if less space available
802			row.css('min-width', w);
803			
804		}); //jQuery each row
805	
806	// ---- Scrolls ----
807	
808		// Updating scroll with slight delay in case forms/heights are not updated just yet
809		setTimeout( function () {
810			mwUpdateScrolls();
811		}, 50);
812	
813	}, //FUNC adjustHeights
814	
815	/** //** ----= align		 =----------------------------------------------\**//** \
816	*
817	* 	Positions window on screen according to properties set.
818	*
819	*	@return	SELF
820	*
821	\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
822	align		: function () {
823
824		var $this	= this;
825
826		// No need adjust invisible window
827		if ( !this.Visible ) return;
828
829		if ( !this.Body || !this.Window ) return;
830
831		// Aliases for callbacks
832		var Body	= this.Body; 
833		var Window	= this.Window;
834		
835		// Generally limiting body height
836		var screen	= screenSize();
837		
838		// No margin for small screens
839		var mrg		= (screen.width > 950 && screen.height > 480) ? this.Margin : 0;
840
841		// Border taken from wrapper padding
842		var brd		= parseInt(Window.css('padding-top'));
843		
844		var wheight	= screen.height - mrg*2 - brd * 2 - this.winHeader.outerHeight() - this.winFooter.outerHeight();
845		
846		if ( this.limitHeight && this.limitHeight < wheight )
847			wheight = this.limitHeight;
848		
849		Body.css('max-height', wheight);
850
851		// Adjusting heights in widnow
852		this.adjustHeights();
853
854		Window.css('margin', mrg);
855
856		Window.align(this.AlignAt);
857
858		return this;
859	}, //FUNC align
860		
861	/** //** ----= show		 =----------------------------------------------\**//** \
862	*
863	* 	Shows window.
864	*
865	*	@param	function	[callback]	- Callback to call on finish.	
866	*
867	*	@return	SELF
868	*
869	\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
870	show		: function (callback) {
871
872		// No need to show twice
873		if ( this.Visible ) return;
874
875		if ( !this.Body || !this.Window ) return;
876
877		var $this	= this;
878
879		// Aliases for callbacks
880		var Body	= this.Body; 
881		var Window	= this.Window; 
882		
883		// Hiding help if it was open
884		// Reinitiating dialog forms, to ensure new elements are styled
885		// Safe and fast to call - styles elements will be skipped
886		styleDialog(Body.find('.mwDialog'));
887
888	// ---- Updating states and displaying ----
889
890		this.Visible = true;
891
892		// Adding self to visible layers
893		mwWinManager.addLayer(this);
894		
895		// Updating layers
896		mwWinManager.updateLayers();
897
898		// Modals affect overlay
899		if ( this.Modal ) {
900			mwWinManager.updateOverlay();
901		} //IF modal window
902		
903		// Resetting state
904		Body.find('.winSubmit').show();
905		Body.find('.winLoader').hide();
906		Body.find('.winStatus').html('');
907
908	// ---- Displaying ----
909	
910		// Starting show before positioning to have all sizes calculatable	
911		mwShow(Window);
912
913	// ---- Positioning and adjusting ---
914
915		this.align();	
916
917	// ---- Dialogs and forms ----
918	
919		// Adding autosubmit to forms in window	
920		setFormsSubmit(Body);
921
922		// Resetting validations
923		setValidations(Body, {});		
924
925	// ---- Correcting focus ---- 
926
927		// Moving focus to marked input or to first input on form
928		var def = Body.find('.defaultInput').find('INPUT, TEXTAREA, SELECT');
929		if ( def.length )
930			def.first().focus();
931		else
932			Body.find('INPUT, TEXTAREA, SELECT').not('[type=hidden]').first().focus();
933
934	// ---- Issuing callback ----	
935		
936		// Giving small delay to allow browser to update all dimensions
937		setTimeout( function () {
938			
939			// Checking if there is help page avaialble to show
940		//	mwHelp.check($this.ID);
941			
942			if ( callback )	
943				callback();
944				
945		}, 30);
946
947	// ---- mwHelp ----
948		
949		if ( typeof(mwHelp) != 'undefined' ) {
950
951			// Desiding what to do with help
952			// ToDo: This should be implemented as help tools
953			// No autoactions in tour
954			if ( mwHelp.activeType != 'tour' ) {
955			
956				// Checking if inline is active and window book is available
957				// If is - showing inline help, if not - hiding it finally
958				if ( mwHelp.activeType == 'inline' && mwHelp.isBook('inline', this.ID) )
959					mwHelp.inline();
960				else
961					mwHelp.hide();
962					
963			} //If not tour actions
964			
965		} //If help avaialbe
966		
967		return this;
968	}, //FUNC show
969
970	/** //** ----= hide		 =----------------------------------------------\**//** \
971	*
972	* 	Hides window
973	*
974	*	@param	function	[callback]	- Callback to call on finish.	
975	*
976	*	@return	SELF
977	*
978	\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
979	hide		: function (callback) {
980
981		// No need to hide twice
982		if ( !this.Visible ) return;
983
984	// ---- Updating states ----
985
986		this.Visible = false;
987
988		// Adding self to visible layers
989		mwWinManager.removeLayer(this);
990		
991		// Updating layers
992		mwWinManager.updateLayers();
993
994		// Modals affect overlay
995		if ( this.Modal ) {
996			mwWinManager.updateOverlay();
997		} //IF modal window
998
999		mwHide(this.Window, callback);
1000
1001		// Making sure help closes too, if not in tour
1002		if ( typeof(mwHelp) != 'undefined' && mwHelp.activeType != 'tour' )
1003			mwHelp.hide();
1004
1005		return this;
1006	}, //FUNC hide
1007	
1008// ==== MODIFICATION FUNCTIONS ====	
1009	
1010	/** //** ----= Class		 =----------------------------------------------\**//** \
1011	*
1012	* 	Applies given class to window.
1013	*
1014	*	@return	SELF
1015	*
1016	\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
1017	Class	: function (c) {
1018
1019		if ( this.Window ) {
1020
1021			var el = this.Window.get(0);
1022			if ( el ) {
1023				this.Window.addClass(c);
1024				this.winClass = el.className;
1025			} //IF element set
1026
1027		} else { //IF initiated
1028
1029			this.winClass += ' ' + c;
1030
1031		} //IF not initiated yet
1032		
1033		return this;
1034	}, //FUNC Class
1035	
1036	/** //** ----= Title		 =----------------------------------------------\**//** \
1037	*
1038	* 	Applies new title to window.
1039	*
1040	*	@return	SELF
1041	*
1042	\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
1043	Title		: function (t) {
1044
1045		this.winTitle = t;
1046
1047		if ( this.Window )
1048			this.Window.find('.winHeader').html(t);
1049
1050		return this;
1051	}, //FUNC Title
1052
1053// ==== STATUS FUNCTIONS ====	
1054
1055	/** //** ----= State		 =----------------------------------------------\**//** \
1056	*
1057	* 	Sets operation state using dialog status/loader elements.
1058	*
1059	*	@param	MIXED	state
1060	*		bool		- TRUE for loading indication, FALSE - idle.
1061	*		string		- Status message for idle state (usually operation result)
1062	*
1063	*	@return	SELF
1064	*
1065	\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
1066	State		: function (s) {
1067
1068		var footer	= this.Body.find('.winFooter'); 
1069		var loader	= footer.find('.winLoader');
1070		var status	= footer.find('.winStatus');
1071
1072		if ( s === true ) {
1073		// ---- Displaying loader ----
1074
1075			mwShow(loader);
1076			
1077			// Cleaning last state
1078			status.html('');
1079			
1080		} else { //IF loading
1081		// ---- Hiding loader ----
1082
1083			mwHide(loader);
1084
1085			// If s contains html it will be added to status
1086			status.html(s);
1087			
1088			// If there was textual status, we need to update heights to match.
1089			if ( s ) {
1090				// ToDo: make this more integrated and less tricky
1091
1092				// First unfixing heights
1093				this.Body.css('margin-bottom', '');
1094				status.css('height', '');
1095
1096				// Updating window footer placement to match multiline text (if any).
1097				this.Body.css('margin-bottom', footer.outerHeight());
1098				
1099				// Fixing footer height
1100				status.css('height', footer.height());
1101			} //IF text
1102						
1103		} //IF idle
1104
1105		return this;
1106	} //FUNC State
1107
1108} //CLASS mwWindowObject
1109
1110/** //** ----= mwWizard		 =----------------------------------------------\**//** \
1111*
1112* 	Returns wizard object. If wizard does not eixists, creates new one.
1113*
1114*	@param	string	id	- Wizard ID to return.
1115*
1116\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
1117var mwWizards	= {
1118};
1119
1120function mwWizard (id) {
1121
1122	if ( !mwWizards[id] )
1123		mwWizards[id] = mwWizardObject(id);
1124	
1125	return mwWizards[id];
1126} //FUNC mwWizard
1127
1128/** //** ----= OBJECT mwWizardObject	 =--------------------------------------\**//** \
1129*
1130* 	Object for wizard creation and handling.
1131*
1132*	@param	string	id	- Wizard system ID.
1133*
1134\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
1135function mwWizardObject (_id) {
1136
1137	// Creating basic object with events assigned
1138	return vEventObject(['onFinish'], {
1139	
1140		ID		: _id,				// Wizard id. Will be used to name internal resources.
1141		
1142		Steps		: {},				// Will store all information about steps.
1143		StepsIndex	: [],				// Steps index as array of ids.
1144
1145		DefaultStep	: '',				// Step to show on load. 
1146		CurrentStep	: '',				// Current step pointer in Steps array. 
1147		  
1148		StepCaption	: false,			// jQuery pointer to current step title element.
1149		StepsControls	: false,			// jQuery pointer to steps control bar.
1150
1151		Window		: false,			// Stores window used.
1152
1153		/** //** ----= init	 =------------------------------------------------------\**//** \
1154		*
1155		* 	Initiates wizard.
1156		*	
1157		*	@param	object	options	- Object containg wizard steps parameters.
1158		*
1159		*	@return SELF  
1160		*
1161		\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
1162		init	: function (options) {
1163			
1164			this.Window		= mwWindow(this.ID);
1165
1166			// Some aliases
1167			var self	= this;
1168			var body	= this.Window.Body;
1169
1170			self.Steps	= {};
1171			self.StepsIndex	= [];
1172
1173			// Looking for steps
1174			body.find('.wizardStep').each( function () {
1175				
1176				// Not named steps are not used
1177				var id = this.id;
1178				if ( !id ) return;
1179				
1180				var title	= this.title || '';
1181				this.title	= '';
1182				
1183				// Saving found
1184				self.Steps[id] = {
1185					'el'	: jQuery(this),
1186					'title' : title
1187				};
1188				
1189			}); //jQuery each step
1190
1191			// Adding options
1192			jQuery.extend(true, self.Steps, options);
1193
1194			// Adding head controls
1195			var head		= body.find('.winHeader');
1196			
1197			var cap 		= head.html();
1198			head.html('<div id="wizTitle" style="display: inline-block;">
1198' + cap + '</div> ');
1199			
1200			self.StepCaption	= jQuery('<span class="wizCaption"></span>').appendTo(head);
1201			self.StepsControls	= jQuery('<div class="wizStepsControls"></div>').appendTo(head);
1202			
1203			// Adding step switch buttons and indexing steps
1204			for ( var i in self.Steps ) {
1205	
1206				// Indexing found steps for prev, next operations
1207				self.StepsIndex.push(i);
1208				
1209				// Creaating buttons
1210				var bttn = jQuery('<a class="wizStep" hint="' + self.Steps[i].title + '" rel="' + i + '" onclick="mwWizard(\'' + self.ID + '\').step(\'' + i + '\')"></a>');
1211				bttn.appendTo(self.StepsControls);
1212				
1213			} //FOR each step
1214
1215			// Setting up footer controls
1216			body.find('.wizardNext').click( function () { self.next(); } );
1217			body.find('.wizardBack').click( function () { self.prev(); } );
1218
1219			return self;
1220		}, //FUNC init
1221
1222		/** //** ----= title	 =------------------------------------------------------\**//** \
1223		*
1224		* 	Sets new wizard title
1225		*	
1226		*	@param	string	t	- New title.
1227		*
1228		*	@return	SELF  
1229		*
1230		\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
1231		Title	: function (t) {
1232			
1233			this.Window.Body.find('#wizTitle').html(t);
1234			
1235			return this;
1236		}, //FUNC Title
1237		
1238		/** //** ----= show	 =------------------------------------------------------\**//** \
1239		*
1240		* 	Displays wizard dialog. Resetting it to first step.
1241		*	
1242		\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
1243		show	: function () {
1244			
1245			// Disabling animaitons while showing
1246			// ToDo: add animation options to system
1247			
1248			var anim = getCookie('G_Animate', 1);
1249			setCookie('G_Animate', 0);
1250			
1251			this.step( this.DefaultStep || this.StepsIndex[0] );
1252			
1253			setCookie('G_Animate', anim);
1254			
1255			this.Window.show();
1256			
1257		}, //FUNC show
1258
1259		/** //** ----= step	 =------------------------------------------------------\**//** \
1260		*
1261		* 	Switches to step specified.
1262		*	
1263		*	@param	string	step	- Step ID to switch to.  
1264		*
1265		\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
1266		step	: function (step) {
1267			
1268			var self	= this;
1269			var body	= this.Window.Body;
1270			var doleave	= true;
1271			
1272			if ( !self.Steps[step] ) return;
1273			if ( self.CurrentStep == step ) return;
1274			
1275			if ( !self.CurrentStep ) {
1276			
1277				self.CurrentStep = this.DefaultStep || this.StepsIndex[0];
1278				
1279				doleave = false;		
1280			
1281			} //IF first enter
1282
1283			// Calling beforeLeave, breaking if false returned
1284			if ( doleave && typeof(self.Steps[self.CurrentStep].beforeLeave) == 'function' 
1285				&& self.Steps[self.CurrentStep].beforeLeave() === false) 
1286					return false; 
1287
1288			
1289			mwHide( body.find('.wizCaption') );
1290			mwHide( self.Steps[self.CurrentStep].el, function () {
1291
1292			// ---- Callbacks ----
1293
1294				// ToDo: less copy-paste on callbacks
1295
1296				// Calling onLeave, breaking if false returned
1297				if ( doleave &&  typeof(self.Steps[self.CurrentStep].onLeave) == 'function' 
1298					&& self.Steps[self.CurrentStep].onLeave() === false) {
1299						
1300						// If false we shold show hidden elements back
1301						
1302						mwShow( body.find('.wizCaption') );
1303						mwShow( self.Steps[self.CurrentStep].el );
1304						
1305						return false;
1306					} //IF false returned
1307
1308				// Calling beforeEnter, breaking if false returned
1309				if ( typeof(self.Steps[step].beforeEnter) == 'function' 
1310					&& self.Steps[step].beforeEnter() === false) {
1311						
1312						// If false we shold show hidden elements back
1313						
1314						mwShow( body.find('.wizCaption') );
1315						mwShow( self.Steps[self.CurrentStep].el );
1316
1317						return false;
1318					} //IF false returned
1319
1320			// ---- Checking final button ----
1321
1322				istep = self.StepsIndex.indexOf(step);
1323				if ( istep == self.StepsIndex.length - 1 ) {
1324					
1325					body.find('.wizardNext').hide();
1326					body.find('.wizardFinish').show();
1327					
1328				} else { //IF last step
1329				
1330					body.find('.wizardNext').show();
1331					body.find('.wizardFinish').hide();
1332				
1333				} //IF not last
1334			
1335			// ---- Marking selected control ----
1336				
1337				self.StepsControls.find('.Selected').removeClass('Selected');
1338				self.StepsControls.find('[rel='+step+']').addClass('Selected');
1339
1340			// ---- Setting caption ----	
1341				
1342				body.find('.wizCaption').html(self.Steps[step].title);
1343				mwShow( body.find('.wizCaption') );
1344				
1345			// ---- Showing step ----
1346				
1347				mwShow( self.Steps[step].el );
1348
1349			// ---- Adjusting contents ----
1350				
1351				self.Window.adjustHeights();
1352				
1353			/**/ // ToDo: Werid behavior. Envistigate more and redo.	
1354			// ---- Realign step ----
1355			
1356				// Not all aligment was possible while step was hidden
1357				// Small timeout to allow animation start
1358				setTimeout( function () {
1359					
1360				// ---- Centering step contents ----
1361					
1362					var el	= self.Steps[step].el;
1363					
1364					if ( el.hasClass('valign') ) {
1365
1366						// Cleaning old anyway
1367						el.css('padding-top', null);
1368						el.css('padding-bottom', null);
1369						
1370						var hgt		= el.height();
1371						var phgt	= el.parent().height();
1372	
1373						if ( phgt > hgt ) {
1374						
1375							var pad = Math.ceil( (phgt - hgt) / 2 );
1376							
1377							el.css('padding-top', pad - 1);
1378							el.css('padding-bottom', pad);
1379								
1380						} //IF height is less than parent 
1381							
1382					} //IF el should align childs	
1383					
1384					// Calling onEnter to allow post setup
1385					if ( typeof(self.Steps[step].onEnter) == 'function' ) 
1386						self.Steps[step].onEnter(); 
1387
1388					self.CurrentStep = step;
1389				}, 1);	
1390
1391			}); //FUNC mwHide.callback		
1392
1393			return false;
1394		}, //FUNC step
1395
1396		/** //** ----= next	 =------------------------------------------------------\**//** \
1397		*
1398		* 	Switches to next step.
1399		*	
1400		*	@param	jQuery	el	- Step button element.  
1401		*
1402		\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
1403		next	: function () {
1404			
1405			var istep = this.StepsIndex.indexOf( this.CurrentStep ) + 1;
1406			
1407			if ( istep > this.Steps.length - 1 ) return;
1408			
1409			this.step(this.StepsIndex[istep]);
1410		}, //FUNC step
1411
1412		/** //** ----= next	 =------------------------------------------------------\**//** \
1413		*
1414		* 	Switches to next step.
1415		*	
1416		*	@param	jQuery	el	- Step button element.  
1417		*
1418		\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
1419		prev	: function () {
1420			
1421			var istep = this.StepsIndex.indexOf( this.CurrentStep ) - 1;
1422			
1423			if ( istep < 0 ) return;
1424			
1425			this.step(this.StepsIndex[istep]);
1426		} //FUNC step
1427
1428	}); //OBJECT mwWizardObject
1429
1430} //CONSTRUCTOR mwWizardObject
1431
1432function mwSwitchTab (el, align) {
1433	
1434	var el		= _jq(el);
1435
1436	// Searching if in window
1437	var win		= el.closest('.winBody');
1438	var win_id	= win.attr('id');
1439	var context	= win.length ? win : false;
1440
1441// ---- Sellecting tab ----
1442
1443	var top		= el.closest('.mwWinTabs');
1444
1445	top.find('.Selected, .selected').removeClass('Selected selected');	
1446	el.addClass('Selected selected');
1447
1448// ---- Switching tab ----
1449	
1450	var rel		= el.attr('rel') || el.attr('data-rel');
1451	
1452	// If no relate - just quit
1453	if ( !rel ) return false;
1454	
1455	// Looking for related content, using context if available to speedup search
1456	var content	= jQuery('#' + rel, context);
1457	
1458	if ( !content.length ) return false;
1459
1460	// Hiding content siblings 
1461	// Also usefull for initiating tabs
1462	mwHide( content.siblings(), function () {
1463
1464		// After hided showing selected
1465		mwShow(content); 
1466
1467		// Forsing complex containment window to readjust heights
1468		// We can get window object name by winBody element
1469		if ( !win ) return;
1470
1471		// Giving small delay, for content to start appear
1472	//	setTimeout( function () {
1473			if ( align )
1474				mwWindow(win_id).align();
1475			else
1476				mwWindow(win_id).adjustHeights(content);
1477	//	}, 1);
1478
1479	}); //FUNC mwHide.callback
1480
1481	return false;
1482} //FUNC mwSwitchTab

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.