PageSourceSearch

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

js canadatattooshows.com collected 2026-10-09 22:41:15 UTC 24,408 bytes, 944 lines download raw bytes

1//ToDo: Redo everything!!!
2
3// Simple cache to do not monitor same values
4var upload_procesing_cache = {};
5
6/** //** ----= setFormsSubmit	 =----------------------------------------------\**//** \
7*
8* 	Sets forms to have submit control. Applies to forms with set onsubmit attribute.
9*
10* 	@param	MIXED element	- jQuery selector to search forms within 
11*				  (set to speed up search).
12*
13* 	@return	bool		- Always FALSE.
14*
15\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
16function setFormsSubmit ( element ) {
17	
18	if ( element && !(element instanceof jQuery) )
19		element = jQuery(element);
20	
21	// Searching for forms, only with onsubmit attribute
22	var forms = ( element )? jQuery(element).find('FORM[onsubmit]') : jQuery('FORM[onsubmit]');
23
24	// Processing each form for submit control
25	forms.each( function() {
26		
27		var form	= jQuery(this);
28		var form_id	= form.attr('id');
29		
30		// Checking if form has no submit already
31		// ToDo: More complex check
32		if ( form.find('[type=submit]').length ) return;
33
34		// If still here - form have no submit, but have onsubmit attribute
35		// So adding hidden submit control
36		// Adding on top, to do not mess with winContents and layout
37		form.prepend('<input type="submit" style="display: none;" />');
38
39		if ( !form_id ) return;
40
41		// If element is window with footer buttons related to form (by id) - set them to submit form too.
42		element.find('.winFooter A[rel=' + form_id + ']')
43			.addClass('Hi')
44			.unbind('click')
45			.click( function () {
46				
47				jQuery('#' + form_id).submit();
48				
49				return false;
50			} ); //FUNC onClick
51		
52	}); //FUNC each form
53
54	return false;	
55} //FUNC setFormsSubmit
56
57/** //** ----= mwUpdateSelector	=--------------------------------------------------------------------------------------\**//** \
58*
59*	Updates selector options with items given. Optionally marks certain items as selected. 
60*
61\**//** ---------------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
62function mwUpdateSelector (input, options, selected) {
63
64	input = _jq(input);
65
66	// Removing all styles from selector
67	var sel = unstyleInput(input);
68	
69	// Cleanning old options
70	sel.find('OPTION').remove();
71	
72	// Adding given options
73	for ( var i in options )
74		jQuery('<option value="' + i + '">' + options[i] + '</option>').appendTo(sel);
75
76	// Setting selected values if given some
77	if ( selected )
78		setValue_Select(sel.get(0), selected);
79	
80	// Restyling input back
81	styleDialog( sel.parent() );
82	
83	return false;
84} //FUNC mwUpdateSelector
85
86/** //** ----= filterSelect	 =----------------------------------------------\**//** \
87*
88* 	Filters styled selector with values.
89*
90* 	@param	MIXED	select	- Valid jQuery element selector. 
91* 				  Sould point to .mwinput.List control.
92* 
93* 	@param	string	filter	- Comma separated filters.
94* 	@return	bool		- Always FALSE.
95*
96\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
97function filterSelect ( select, filter ) {
98
99	if ( !filter ) {
100//		jQuery(select).find('.Item').fadeIn(200);
101		jQuery(select).find('.Item').show();
102		return false;
103	} //IF empty filter
104
105	// Trimming filters, and composing regex
106	var filter	= strToArray(filter, ',');
107	var reg		= new RegExp('(' + filter.join('|') + ')', 'i');
108	
109	jQuery(select + ' .Item').each( function () {
110		var el		= jQuery(this);
111		
112		var title	= el.find('div').first().html();
113
114		if ( reg.test(title) )
115			el.show();
116		else
117			el.hide();
118
119	}); //jQuery each
120	
121	return false;
122} //FUNC filterSelect
123
124/** //** ----= selectAddItem	 =----------------------------------------------\**//** \
125*
126* 	Adds items to target styled selector.
127*
128* 	@param	MIXED	select	- Valid jQuery element selector.
129* 	@param	string	values	- Comma separated values.
130* 	@return	bool		- Always FALSE.
131*
132\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
133function selectAddItem ( select, values, checked ) {
134	
135	if ( !values ) return false;
136
137	var select	= _jq(select);
138	
139	checked = ( checked )? ' selected="selected"' : ''; 
140
141	// If input given as value, it should be cleaned after all	
142	var relate = false; 
143	if ( values instanceof jQuery ) {
144		relate = values;
145		values = relate.val();
146	} //IF parent element given
147	
148	if ( isStr(values) ) {
149		var tmp	= strToArray(values, ',');
150		
151		// Reindexing to have meaningfull keys to use as values
152		// Normally associated arrays or objects should be passed
153		values = {};
154		
155		for ( var i in tmp )
156			values[tmp[i]] = tmp[i];
157			
158	} //IF string given
159
160	// Before have to save selected inputs, cuz unstyle will reset all to beginning
161	var checks	= []; 
162	select.find('input:checked').each( function () {
163		checks.push( jQuery(this).val() );
164	}); //FUNC each.callback
165
166	// Destyling select for easy add new inputs	
167	select = unstyleInput(select);
168	
169	// Resetting options to to new setting
170	select.find('option').each( function () {
171		
172		var el = jQuery(this);
173		if ( checks.indexOf( el.val() ) != -1 )
174			el.attr('selected', 'selected');
175		else	
176			el.removeAttr('selected');
177			
178	}); //FUNC each.callback
179	
180	for ( var i in values ) {
181		select.prepend('<option value="' + i + '"' + checked + '>' + values[i] + '</option>');		
182	} //FOR each value
183
184	// Styling input back again
185	styleDialog(select.parent());
186
187	return false;
188} //FUNC selectAddItem
189
190/** //** ----= inputClassString	 =----------------------------------------------\**//** \
191*
192* 	Takes source element, and type classes. Prepares full class and style attributes.
193*
194* 	@param	object	el		- Source input jQuery object.
195* 	@param	string	typeClass	- Additional classes to add.
196* 	@return	string			- Attributes to add to element.
197		bool			- FALSE if no modification necessary.
198*
199\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
200function inputClassString(el, typeClass) {
201
202	// If already styled - nothing to do again
203	if ( el.hasClass('mw') ) return false;
204
205	// Saving source to allow fast unstyle
206	el.data('source', getOuterHTML( el.get(0) ));
207
208	// Getting existing attributes
209	var cls		= el.attr('class');
210	
211	// Getting other transferrable attributes
212	var $attr	= {'class' : ''};
213	var $aList	= ['style', 'size', 'data-prefix', 'data-suffix'];
214	for ( var $i in $aList ) 
215		$attr[ $aList[$i] ] = el.attr($aList[$i]);
216
217	var styles	= el.attr('style');
218		
219	// Composing classes
220	var ctmp	= ['mwInput', typeClass, cls];
221	
222	var name	= el.attr('name');
223	if ( name ) {
224		name	= name.replace(/[\[\]]/g, '');
225		ctmp.push('name-'+name);
226	} //IF name
227	
228	// Storing class as attribute
229	$attr['class'] = ctmp.join(' ').trim();
230
231	// Processing results
232	var $res = '';
233	for ( var $i in $attr ) 
234		if ( !isEmpty($attr[$i]) )
235			$res += ' '+$i+'="'+$attr[$i]+'"';
236
237	// Cleaning source attributes
238	el[0].className = '';
239	
240	for ( var $i in $aList ) 
241		el.removeAttr($aList[$i]);
242
243	// Adding styled marker
244	el.addClass('mw');
245	
246	return $res;
247} //FUNC inputClassString
248
249/** //** ----= styleDialog	 =----------------------------------------------\**//** \
250*
251* 	Applies style to all inputs childs to specified element.
252*
253* 	@param	MIXED	el	- Valid jQuery element selector.
254* 	@return	bool		- Always FALSE.
255*
256\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
257function styleDialog ( dialog ) {
258
259	dialog = _jq(dialog);
260
261// ---- TEXT ---- 
262	
263	dialog.find('INPUT[type=text], INPUT[type=search], INPUT[type=password], INPUT[type=email], INPUT[type=date], INPUT[type=number], INPUT[type=tel], INPUT[type=url]').each( function () {
264		
265		var el		= jQuery(this);
266		
267		// Cleaning errors state on load
268		//el.closest('.mwInput').removeClass('Error');
269		
270		// Checking if some of subcontrol classes are set
271		var subs	= el.is('.Plus, .Go');
272		
273		var tclass	= 'Text';
274		if ( subs ) tclass += ' wSub';
275		
276		var attr	= inputClassString(el, tclass);
277		if ( !attr ) return;
278
279		var wrap = jQuery('<div ' + attr + '></div>');
280		el.wrapAll(wrap);
281
282		// Adding some common subcontrols if set
283		if ( subs ) {
284			
285			var sub		= jQuery('<div class="SubControl Hi"><div></div></div>').insertBefore(el);
286			var click	= el.attr('onclick');
287			
288			if ( click )
289				sub.attr('onclick', click);
290			
291			el.removeAttr('onclick');
292		} //IF is Plus
293
294		// Initiating date picker
295		Date.format = 'yyyy-mm-dd';
296		if ( wrap.is('.Date') ) {
297			el.datePicker({
298				clickInput	: true, 
299				createButton	: false, 
300				verticalOffset	: 26,
301				startDate	: '2000-01-01'
302			});
303		} //IF date input
304
305		// Text inputs should select on forcus
306		el.focus( function () { this.select() } );
307
308		/*/
309		// Adding required check
310		if ( wrap.hasClass('required') ) {
311			
312			el.keyup( function () {
313				var e = jQuery(this);
314				if ( e.val().trim() ) 
315					e.closest('.mwInput').removeClass('Error');
316				else
317					e.closest('.mwInput').addClass('Error');
318			});
319			
320		} //IF required
321		/**/
322		
323	}); //jQuery each text input
324	
325// ---- TEXTAREA ---- 
326	
327	dialog.find('TEXTAREA').not('.mw, .tinyMCE, .mwTinyMCE, .RichEdit').each( function () {
328		var el = jQuery(this);
329		
330		var attr = inputClassString(el, 'Textarea');
331		if ( !attr ) return;
332
333		el.wrapAll('<div ' + attr + '></div>');
334	}); //jQuery each textarea input
335
336	dialog.find('TEXTAREA.RichEdit').not('.mw').each( function () {
337		
338		// Doing nothing if no tinyMCE defined on page
339		// No fallbacks, as developer should see that smth went wrong
340		if ( typeof(tinyMCE) == 'undefined' )
341			return; 
342		
343		var el = jQuery(this);
344		
345		// Marking element as initiated
346		el.addClass('mw');
347		
348		mwTinyMCE().init(el);
349	}); //jQuery each textarea input
350	
351// ---- BUTTONS ---- 
352	
353	dialog.find('INPUT[type=button], INPUT[type=submit]').each( function () {
354		var el = jQuery(this);
355		
356		var attr = inputClassString(el, 'Button');
357		if ( !attr ) return;
358
359		el.wrapAll('<div ' + attr + '></div>');
360		
361		// Sumulating active for parent
362		el
363			.bind('mousedown', function () {
364				jQuery(this).parent().addClass('Active');
365			}) //FUNC onMouseDown
366			.bind('mouseup', function () {
367				jQuery(this).parent().removeClass('Active');
368			}) //FUNC onMouseUp
369		; //jQuery element
370	}); //jQuery each textarea input
371
372	dialog.find('INPUT[type=image]').each( function () {
373		var el = jQuery(this);
374		
375		var attr = inputClassString(el, 'Button Image');
376		if ( !attr ) return;
377
378		el.wrapAll('<div ' + attr + '></div>');
379		
380		// Sumulating active for parent
381		el
382			.bind('mousedown', function () {
383				jQuery(this).parent().addClass('Active');
384			}) //FUNC onMouseDown
385			.bind('mouseup', function () {
386				jQuery(this).parent().removeClass('Active');
387			}) //FUNC onMouseUp
388		; //jQuery element
389	}); //jQuery each textarea input
390	
391// ---- SELECT ---- 
392	
393	dialog.find('SELECT').not('[multiple]').not('.CheckList, .RadioList').each( function () {
394		var el = jQuery(this);
395		
396		var nowidth = el.hasClass('nowidth');
397		
398		var attr = inputClassString(el, 'Select');
399		if ( !attr ) return;
400
401	// ---- Calculating selector min width ----
402
403		var width = '';
404
405		if ( !nowidth ) {
406			var tmp = el.clone();
407			// Fix for 100% width from css, need to get real width, caused by options
408			tmp.css('width:auto !important');
409			tmp.appendTo('BODY');
410			width = tmp.width() + 30;
411			tmp.remove();
412			width = ' style="min-width : ' + width + 'px"';
413		} //IF need width 
414		
415		el.wrapAll('<div ' + attr + '></div>');
416		el.addClass('Hidden');
417		
418		var val = el.find('OPTION:selected').text();
419		
420		el.before('<div class="SubControl"></div>');
421		el.before('<div class="Value"' + width + '>' + val + '</div>');
422
423		el.change( function () {
424			el.prev('.Value').html( el.find('OPTION:selected').text() )
425		}); //jQuery onChange
426
427	}); //jQuery each select input
428
429// ---- MULTISELECT ---- 
430	
431	dialog.find('SELECT[multiple], SELECT[size]').not('.CheckList, .RadioList').each( function () {
432		var el = jQuery(this);
433		
434		var attr = inputClassString(el, 'Multiple');
435		if ( !attr ) return;
436
437		el.wrapAll('<div ' + attr + '></div>');
438	}); //jQuery each multiselect input
439
440// ---- CHECKLIST and RADIOLIST ---- 
441
442	dialog.find('SELECT.CheckList, SELECT.RadioList').each( function () {
443
444		var sel = jQuery(this);
445		
446		var attr = inputClassString(sel, 'List');
447		if ( !attr ) return;
448
449	// ---- Creating container and subcontainer elements ----
450	
451		var el		= jQuery('<div ' + attr + '><div class="Items"></div></div>');
452		var items	= el.find('.Items');
453
454	// ---- Saving source ----
455	
456		// Selector itself will be replaced, so we need to save source in separate hidden element which will not affect nothing
457		
458		var source_data	= sel.data('source');
459		
460		var source	= jQuery('<input type="hidden" class="mw">');
461		source.data('source', source_data);
462		source.appendTo(el);
463
464	// ---- Transferring hint ----
465	
466		var hint	= sel.attr('hint');
467		if ( hint )
468			items.attr('hint', hint);
469
470	// ---- Composing common attributes ----
471
472		var radio	= el.hasClass('RadioList'); 
473		var name	= sel.attr('name');
474		
475		// Checkboxes should be arrays
476		if ( !radio ) name += '[]';
477		
478		// Input type
479		var type = ( radio )? 'radio' : 'checkbox';
480		
481	// ---- Processing sub controls ----		
482
483		sel.find('OPTION').each( function () {
484		
485			var op		= jQuery(this);
486			var title	= op.html();
487
488		// ---- Parsing title for special things ----
489
490			// Column		
491			var col		= '';
492			var d		= title.indexOf('|');
493			if ( d >= 0 ) {
494				col = title.substr(d + 1);
495				title = title.substr(0, d) + '<div class="col">' + col + '</div>';
496			}
496 //IF divider come
497			
498			var $icon	= op.attr('data-icon');
499			if ( $icon )
500				$icon = '<div class="icon" style="background-image: url(' + $icon + ');"></div>';				
501
502			// Making sure icon exists (some libs brake attribute)
503			$icon		= $icon || '';
504
505			// Value/checked
506			var val		= op.val();
507			var checked	= op.attr('selected'); 
508
509			title		= $icon + '<div class="title' + (checked ? ' Selected' : '') + '">' + title + '</div>';			
510
511			var titem	= jQuery(title);
512		//	if ( checked ) titem.addClass('Selected');
513
514			var input	= jQuery('<input type="' + type + '" class="meta" name="' + name + '" value="' + val + '" />');
515			if ( checked ) input.attr('checked', 'checked');
516
517			// Setting up actions
518			var actions	= ['onclick', 'onchange', 'ondblclick']; 
519			for ( var i in actions )
520				input.attr(actions[i], sel.attr(actions[i]) );
521			  
522			input.change( function () {
523				
524				var check = this.checked;
525				
526				var el = jQuery(this);
527				
528				if ( check ) {
529					el.prev().addClass('Selected');
530				} else { //IF checked
531					el.prev().removeClass('Selected')	
532				} //IF not checked
533		
534				if ( this.type == 'radio') {
535					if ( this.checked ) {
536						jQuery(this)
537							.parents('.mwInput.List')				// Searching parent container
538							.find('INPUT[type="radio"][name="' + this.name + '"]')	// Searching all items
539							.not(this)						// Excluding self
540							.each( function () {					// Triggering change on each
541								jQuery(this).change();
542							}); //each radio
543					} //IF got cheked state
544				} //IF radio
545		
546			}); //jQuery onChange
547
548			var $itemClass	= 'Item';
549			var $itemStyle	= '';
550/*/
551			var $src	= op.attr('data-icon');
552			if ( $src ) {
553				$itemClass += ' icon';
554				$itemStyle = 'background-image: url(' + $src + ');';
555			} //IF class
556/**/
557			
558			$itemClass = $itemClass ? ' class="' + $itemClass + '"' : '';
559			$itemStyle = $itemStyle ? ' style="' + $itemStyle + '"' : '';
560
561			var item	= jQuery('<div' + $itemClass + $itemStyle + '></div>');
562			item.append(titem).append(input);
563			
564			item.appendTo(items);
565		}); //jQuery each option
566
567		sel.replaceWith(el);
568	}); //jQuery each multiselect input
569
570	// ---- CHECKBOX and RADIO ---- 
571	
572	dialog.find('INPUT[type="checkbox"], INPUT[type="radio"]').not('.meta').each( function () {
573
574		var el		= jQuery(this);
575		
576		// Checking if custom titles are set
577		var custom	= el.attr('cap');
578		
579		var attr = inputClassString(el, 'Checkbox' + ((custom)? ' Custom' : ''));
580		if ( !attr ) return;
581
582// ---- Processing custom titles ----	
583		
584		// Webkit browsers require smth to have inside to propertly align, so setting nbsp as default
585		var on		= '&nbsp;';
586		var off		= '&nbsp;';
587		
588		if ( custom ) {
589			
590			el.removeAttr('cap');
591	
592			custom = custom.split('|');
593	
594			var on	= custom[0];
595			var off	= (custom[1])? custom[1] : custom[0];
596		
597		} //IF title set
598
599	// ---- Wrapping layout structure ----
600		
601		el.wrapAll('<div ' + attr + '></div>');
602		el.addClass('Hidden');
603		
604		el.before('<div>_</div>');
605				
606	// ---- Applying change function ----	
607	
608		el.change( function () {
609			
610			var check = this.checked;
611			
612			if ( check ) {
613				el.prev().addClass('Checked');
614				el.prev().html(on);
615				el.addClass('checked');
616			} else { //IF checked
617				el.prev().removeClass('Checked')	
618				el.prev().html(off);
619				el.removeClass('checked');
620			} //IF not checked
621
622		}); //jQuery onChange
623
624		// Initiating first time
625		el.change();
626		
627	// ---- Radio buttins refresh fix ----	
628		
629		if ( this.type == 'radio' ) {
630			
631			el.change( function () {
632
633				var radio = jQuery(this);
634
635				if ( this.checked ) {
636					
637					// Searching neighbours via closest parent form. Fastest way. Usually there is form around.
638					radio.closest('FORM')
639						.find('INPUT[type="radio"][name="' + this.name + '"].checked')
640							.not(this).change();
641					
642				} //IF got cheked state
643				
644			}); //jQuery onChange
645			
646		} //IF radio button
647
648	}); //jQuery each checbox and radio input
649
650// ---- FILES ---- 
651	
652	dialog.find('INPUT[type=file]').each( function () {
653		var el = jQuery(this);
654		
655		var attr = inputClassString(el, 'File');
656		if ( !attr ) return;
657		
658		// Detecting SN if set, and applying it as uBar
659		var fid = el.attr('sn') || '';
660		
661		if ( fid )
662			fid = ' uBar_' + fid;
663
664		// Detecting value is present, and using as visual title
665		var title = el.attr('value') || el.attr('src') || el.attr('img') || 'Select file...';
666		
667		el.wrapAll('<div ' + attr + '></div>');
668
669		el.before('<div class="SubControl Hi Fill progressFill' + fid + '"></div>');
670		el.before('<div class="FileName">' + title + '</div>');
671		el.before('<div class="Num progressNum' + fid + '">&nbsp;</div>');
672		el.before('<div class="SubControl Hi"><div></div></div>');
673
674		el.change( function () {
675			var file = fileName(this.value);
676			if ( !file ) file = 'Select file...';
677			
678			jQuery(this).parent().find('.FileName').html( file );
679		}); //jQuery onChange
680
681	}); //jQuery each select input
682
683// ---- TABLE ---- 
684
685	dialog.find('input[data-input="table"]').each( function () {
686
687		var $el		= jQuery(this);
688		var $name	= $el.attr('name');
689
690		var $attr	= inputClassString($el, 'table');
691		if ( !$attr )
692			return;
693			
694		$el.wrapAll('<div ' + $attr + '></div>');
695
696		// Researching wrapper
697		var $wrap	= $el.closest('div'); 
698
699		// Reading columns
700		var $cols	= strToArray($el.data('columns'));
701		
702		// Generating table, replacing old one
703		function tGen ($data) {
704			
705			var $table	= $wrap.find('table').remove();
706
707			// Will try to recognize some values format
708			var $cClass	= {};
709		
710			// Rendering rows and headers in separate vars
711			// Cols are rendered first, to collect data format info
712			// Which then will allow to format headers
713			// in the end all will be put together as table
714			var $headHtml	= '';
715			var $rowsHtml	= '';
716		
717			// Rendering rows
718			for (var $r in $data ) {
719				var $row = $data[$r];
720			
721				$rowsHtml += '<tr>';
722				for (var $i in $cols ) {
723					
724					var $col = $cols[$i];
725					var $val = $row[$col];
726					
727					if ( isNumeric($val) )
728						$cClass[$col] = 'num'; 
729
730					// Checking if some classes are present
731					var $class	= $cClass[$col] || '';
732					if ( !isEmpty($class) )
733						$class = ' class="'+$class+'"';
734					
735					$rowsHtml += '<td'+$class+'>'+$val+'</td>';
736				} //FOR each column
737				$rowsHtml += '</tr>';
738
739			} //FOR each data row
740
741			// Rendering headers
742			$headHtml += '<tr>';
743			for (var $i in $cols ) {
744				
745				var $col	= $cols[$i];
746
747				// Checking if some classes are present
748				var $class	= $cClass[$col] || '';
749				if ( !isEmpty($class) )
750					$class = ' class="'+$class+'"';
751				
752				$headHtml += '<th'+$class+'>'+ucfirst($cols[$i])+'</th>';
753			} //FOR each column
754			$headHtml += '</tr>';
755
756			var $html = '<table>'+$headHtml+$rowsHtml+'</table>';
757			
758			return jQuery($html).appendTo($wrap);
759		} //FUNC tGen
760		
761		tGen({});
762
763		// Hiding source input
764		$el.hide();
765		
766		// Updating table on input change
767		$el.change( function () {
768			var $input	= jQuery(this);
769			var $data	= JSON.parse($input.val() || '{}');
770
771			tGen($data);
772
773		}); //FUNC input.change
774		
775	}); //jQuery each select input
776
777
778// ---- COMMON ----
779	
780	// Tracking hovers/focus via java and classes to have extra styling options.
781
782	dialog.find('.mwInput')
783	
784		.unbind('mouseenter')		
785		.unbind('mouseleave')		
786		.hover( function() {
787			jQuery(this).addClass('Hover');
788		}, //mouseenter
789		function() {
790			jQuery(this).removeClass('Hover');
791		}) //mouseleave
792	
793		.unbind('focusin')		
794		.focusin( function() {
795			jQuery(this).addClass('Focus');
796		}) //focusin
797	
798		.unbind('focusout')		
799		.focusout( function() {
800			jQuery(this).removeClass('Focus');
801		}) //focusout
802	; //jQuery mwInput
803
804	return false;	
805} //FUNC styleDialog
806
807/** //** ----= unstyleInput	 =----------------------------------------------\**//** \
808*
809* 	Removes styles from input given.
810*
811* 	@param	jQuery	input	- Valid jQuery input element selector.
812* 	@return	jQuery		- New input element.
813*
814\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
815function unstyleInput ( input ) {
816
817	// All styled inputs have .mw class.
818	// Source is stored under jQuery's .data().
819	input = _jq(input);
820	
821	// Making sure that we are pointing to input itself
822/*/
823	if ( !input.is('.mw') )
824		input = input.find('.mw');
825	
826	var source	= input.data('source');
827/*/
828	var source	= input.find('.mw').data('source');
829/**/
830
831	if ( source ) {
832		source = jQuery(source);
833		input.replaceWith(source);
834		return source;
835	} //IF source was stored
836		
837	return input;
838} //FUNC unstyleInput
839
840/** //** ----= unstyleDialog	 =----------------------------------------------\**//** \
841*
842* 	Removes styles from inputs in given element.
843*
844* 	@param	MIXED	el	- Valid jQuery element selector.
845* 	@return	bool		- Always FALSE.
846*
847\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
848function unstyleDialog ( dialog ) {
849
850	// All styled inputs have .mw class.
851	// Source is stored under jQuery's .data().
852	dialog.find('.mw').each( function () {
853		
854		var el		= jQuery(this);
855		
856		var source	= el.data('source');
857
858		if ( source )
859			el.closest('.mwInput', dialog).replaceWith(source);
860		
861	}); //jQuery each .mw 
862	
863	return false;
864} //FUNC unstyleDialog
865
866function setValidations (dialog, validations) {
867	
868	if ( !dialog )
869		return;
870	
871	dialog.find('INPUT, SELECT, TEXTAREA')
872		.each( function () {
873			
874			// Shortcuts to input and it's parent (morweb forms)
875			var input	= jQuery(this);
876			var parent	= input.closest('.mwInput');
877			if ( !parent.length )
878				parent = input;
879			
880			// Input should have name to be validatable
881			var name	= input.attr('name');
882			if ( !name ) return; 
883			
884			// Shortcut to messages array to simplify code
885			var msgs	= validations[name];
886
887			// TinyMCE support
888			// Marking tinyEditor instead of input itself
889			if ( input.is('.mwTinyMCE') ) {
890
891				// If it's tinyMCE input - there should be sibling mceEditor input
892				input	= input.siblings('.mceEditor');
893				parent	= input;
894				
895				// If none - smth went wrong
896				if ( !input.length )
897					return;
898		 	} //IF tinyMCE input
899			
900			// Removing errors attribute if no messages
901			if ( !msgs ) {
902				
903				input.removeAttr('error');
904				
905				// Class for parent
906				parent.removeClass('error');								
907
908				return;									
909			} //IF no messages
910			
911			// Compiling messages, very simple br can be stored inside attribute
912			var msg = implode('<br />', msgs);
913
914			// Setting error
915			input.attr('error', msg);								
916
917			// Class for parent
918			parent.addClass('error');								
919			
920		}); //jQuery.each.callback
921	
922	return;
923} //FUNC setValidations
924
925/** //** ----= 	fillViews	 =----------------------------------------------\**//** \
926*
927* 	Fills fileds views within specified element.
928*
929*	@param	jQuery	el	- Context element.
930*	@param	object	obj	- Data object to pull views from.
931*	
932* 	@return	bool		- Always FALSE.
933*
934\**//** ------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
935function fillViews (el, obj) {
936
937	el = _jq(el);
938
939	for ( var i in obj ) {
940		el.find('.view-' + i).html(obj[i]);
941	} //FOR each field
942
943	return false;
944} //FUNC fillViews

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.