PageSourceSearch

https://mycadmium.com/myCadmium2/includes/js/mycadmium.js?_=08.17.2022.20.48

js mycadmium.com collected 2026-10-07 21:52:30 UTC 50,518 bytes, 1,801 lines download raw bytes

1/*
2========================================================================================================================
3========================================================================================================================
4
5  MYCADMIUM 2.0 ADMIN PORTAL JS 
6  Created By: Devin Madden - 09/02/2015	
7  Last Edited By: Devin Madden - 10/07/2015	      				
8										
9  Notes: - we override the underscore template settings because the default 
10  		   delimiter for template variables is: <% =VARIABLE%>.  
11  		   We now use: {{VARIABLE}}
12  
13========================================================================================================================				
14========================================================================================================================
15*/
16
17// Override the underscore templating setting
18_.templateSettings = {
19	interpolate: /\{\{(.+?)\}\}/g
20};
21
22// Object to hold standard regular expressions
23var regExp = {
24	url: /((http|ftp|https):\/\/)?[\w-]+(\.[\w-]+)+([\w.,@?^=%&amp;:\/~+#-]*[\w@?^=%&amp;\/~+#-])?/
25}
26
27// Message while the page is rendering
28Pace.on('start', function(){
29	$('body').prepend('<div id="loadTxt" class="text-muted text-lg">Rendering Data...</div>');
30});
31
32
33/*
34Pace.on('hide', function(e){
35	$('[autofocus]').focus();
36});
37*/
38			
39// Focus the omnisearch once the pace bar is done
40Pace.on('hide', function(e){
41	// Focus the tools page search first.  If the tools page search does no exist on the page, focus the omnisearch
42	var focus = $('.tp-search-input').length ? $('.tp-search-input') : $('#SearchFilterAjax');
43	//If this JS file is on a page without OmniSearch or the tools page, focus on the first element with autofocus
44	if(focus.length == 0) focus = $("[autofocus]:first");
45	
46	setTimeout(function(){
47		focus.focus();
48	}, 500);
49});
50
51/*
52=====================================================================
53Object to detect mobile devices
54=====================================================================
55*/
56
57var isMobile = {
58    Android: function() {
59        return navigator.userAgent.match(/Android/i);
60    },
61    BlackBerry: function() {
62        return navigator.userAgent.match(/BlackBerry/i);
63    },
64    iOS: function() {
65        return navigator.userAgent.match(/iPhone|iPad|iPod/i);
66    },
67    Opera: function() {
68        return navigator.userAgent.match(/Opera Mini/i);
69    },
70    Windows: function() {
71        return navigator.userAgent.match(/IEMobile/i) || navigator.userAgent.match(/WPDesktop/i);
72    },
73    any: function() {
74        return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
75    }
76};
77
78		
79/*
80=====================================================================
81CODE TO RUN ON PAGE LOAD
82=====================================================================
83*/
84
85var myCad;	
86	
87$(function(){
88	
89	
90	/*
91	=====================================================================
92	Initialize
93	=====================================================================
94	*/
95	
96	// Create the main navigation object
97	myCad = new myCadmium();
98	
99	
100	/*
101	=====================================================================
102	Thoughtstream fly out menu
103	=====================================================================
104	*/
105
106	if ($('.page-content').length){
107		$('.page-content').flyout({
108            trigger: '[data-toggle="ts-flyout"]',
109            css: {
110	            'padding-top': '65px'
111            },
112            panels: [
113            	{
114	            	id: 'ts_pnl_0',
115	            	url: '/mycadmium2/modules/activity/ajaxcalls/getPanel.asp?filter=unread',
116	            	onload: function(panel){
117		            	// initialize mini toolspage
118	            	}
119            	}
120			]
121        });	
122    }	
123			
124
125	/*
126	=====================================================================
127	Simple ajax request and response
128	=====================================================================
129	*/
130
131	$('body').on('tap', '[data-ajax="true"]', function(e){
132		e.preventDefault();
133		var elem = $(this);
134		var loadFrom = elem.attr('href') || elem.attr('data-href');
135		loadFrom = loadFrom == '#' ? null : loadFrom;
136					
137		if (loadFrom) {
138			var requestData = $.parseParams(loadFrom.split('?')[1] || '');
139			loadFrom = loadFrom.split('?')[0]
140		
141			$.ajax({
142				url: loadFrom,
143				type: elem.attr('data-method') || 'GET',
144				data: requestData,
145				success: function(data) {
146					var response = data.split('|');
147					
148					if (data == 'session expired') {
149						popupAlert({
150							icon: 'icon-cancel-2',
151							duration: 4000, 
152							message: 'Your session has expired.  Please log in to the system again.'
153						});
154					}else if (data && response[0].toLowerCase() == 'success') {
155						popupAlert({
156							icon: 'icon-checkmark',
157							duration: 4000, 
158							message: response[1]
159						});
160					}else if (data  && response[0].toLowerCase() == 'error'){
161						popupAlert({
162							icon: 'icon-cancel-2',
163							duration: 4000, 
164							message: response[1]
165						});
166					}
167					
168					if (elem.is('[data-trigger]')){
169						$('body').trigger(elem.attr('data-trigger'));
170					}
171				},
172				error: function() {
173					popupAlert({
174						duration: 4500, 
175						message: 'Request failed.<br/>Please see a developer to correct the issue.'
176					});
177				}
178			});
179			
180		}else {
181			throw new Error('URL not specified.');
182		}
183		
184		return false;
185	});
186	
187	
188	/*
189	=====================================================================
190	Ajax content into a div
191	=====================================================================
192	*/
193
194	$('body').on('tap', '[data-trigger="ajaxContent"]', function(e){
195		e.preventDefault();
196		var elem = $(this);
197		var target = $(elem.attr('data-target'));
198		
199		if (target && target.length) {
200			var loadFrom = elem.attr('href') || elem.attr('data-href');
201			loadFrom = loadFrom == '#' ? null : loadFrom;
202						
203			if (loadFrom) {
204
205				ajaxContent(loadFrom, elem, function(data){
206					// Append the html to the target element
207					target.empty().append(data);					
208				});
209				
210			}else {
211				throw new Error('Target URL not found ([href|data-href]).');
212			}
213		}else {
214			throw new Error('Target selector not found ([data-target]).');
215		}		
216		
217		return target;
218		
219	});
220			
221	
222	/*
223	=====================================================================
224	NAVIGATION CODE
225	=====================================================================
226	*/
227
228	// Expand submenus
229	$('body').on('tap', '#sidenav .side-nav-tab li', function(e){
230		e.preventDefault();
231		e.stopPropagation();			
232		var elem = $(this);
233		
234		// Check for a url in case we are ajaxing content
235		var loadFrom = elem.attr('data-href');
236		loadFrom = loadFrom == '#' ? null : loadFrom;
237		
238		if (loadFrom) {
239			
240			ajaxContent(loadFrom, elem, function(data){
241				
242				// Append the html to the target element
243				$('ul', elem).remove();
244				elem.append(data);
245				
246				// Expand the ajaxed content
247				elem.children('ul').first().slideToggle(250, function(){
248					elem.attr('data-expanded', elem.attr('data-expanded') == 'true' ? 'false' : 'true');
249				});
250					
251			});
252		
253		}else {
254				
255			elem.children('ul').first().slideToggle(250, function(){
256				elem.attr('data-expanded', elem.attr('data-expanded') == 'true' ? 'false' : 'true');
257			});
258		
259		}
260		
261		return false;
262		
263	});
264	
265	// Prevent event bubbling to parent
266	$('body').on('tap', '#sidenav .side-nav-tab a', function(e){
267		e.stopPropagation(); 
268	});
269
270
271	/*
272	=====================================================================
273	Generic tabbed navigation
274	=====================================================================
275	*/
276	
277	// Make sure all tabbed view links have a target element
278	$('.tabbed-view > *').each(function(){
279		var target = $($(this).attr('data-target'));		
280		// Check for a target
281		if (!target || target.length == 0) {
282			
283			console.warn('Target selector not found ([data-target]).');
284		}
285	});
286	
287	// Links that ajax content will change the state of the tabs 
288	// once the content is loaded successfully
289	$('body').on('cd.ajaxContent.successEnd', '.tabbed-view > *[data-target][data-trigger="ajaxContent"]', function(e){
290		e.preventDefault();
291		var target = $($(this).attr('data-target'));
292		toggleTabbedViewState($(this), target);
293	});
294	
295	// Links that are just showing and hiding divs do not have to wait
296	$('body').on('tap', '.tabbed-view > *[data-target]:not([data-trigger])', function(e){
297		e.preventDefault();
298		var target = $($(this).attr('data-target'));
299		toggleTabbedViewState($(this), target);
300	});
301
302	
303	// Function to toggle the state of the tabbed links
304	function toggleTabbedViewState(elem, target) {
305		// Remove the active class from sibling and its targets
306		elem.siblings('.active').each(function(){
307			$(this).removeClass('active');
308			$($(this).attr('data-target')).removeClass('active').trigger('cd.tabbedview.hidden');
309		});
310
311		// Apply active state to the tab trigger and tab content
312		elem.addClass('active');
313		target.addClass('active').trigger('cd.tabbedview.shown');;
314	}
315		
316	
317	
318	/*
319	=====================================================================
320	Trigger custom event so we can run functions in the background
321	=====================================================================
322	*/
323	
324	$('body').on('click', '[data-trigger]', function(e){
325		// If it happens to be an ajax request we will run the update punch function on success
326		if (!$(this).is('[data-ajax="true"]')){
327			$('body').trigger($(this).attr('data-trigger'));
328		}
329	});
330	
331			
332	/*
333	=====================================================================
334	Punch clock
335	=====================================================================
336	*/
337	
338	// Custom event handler to trigger the update punch function
339	$('body').on('updatePunch', function(){
340		myCad.navigation.updatePunch(true);
341	});
342
343	// Custom punch clock project seach
344	$('body').on('keyup paste', '#side-nav-punches [name="punchSearch"]', function(e){	
345		var input = $(this);
346		var val = input.val();
347		var form = input.parents('form');
348		var container = $('#punchCategories');
349		
350		if (val && val != ''){
351			container.find('.staticResults').fadeOut(250, function(){
352				container.find('.searchResults').html('<p class="text-muted text-sm text-center">Type a client or project name and hit enter to search projects</p>');
353			});
354			
355			if (e.keyCode == 13) {
356				e.stopPropagation();
357				input.parent().append('<img src="/mycadmium2/includes/images/ajaxWheel.gif" alt="ajax wheel" />');
358				
359				$.ajax({
360					url: form.attr('action'),
361					type: form.attr('method'),
362					data: form.serializeArray(),
363					success: function(data){
364						if (data == 'session expired') {
365							popupAlert({
366								icon: 'icon-cancel-2',
367								duration: 4500, 
368								message: 'Your session has expired.  Please log in to the system again.'
369							});
370						}else {
371							container.find('.staticResults').fadeOut(250, function(){
372								container.find('.searchResults').html(data);
373								input.parent().find('img').remove();
374							});
375						}							
376					}
377				});
378			}
379			
380		}else {
381			container.find('.searchResults').empty();
382			container.find('.staticResults').fadeIn(250);
383		}
384		
385		return false;
386	});
387
388		
389				
390		
391	/*
392	=====================================================================
393	  MYCADMIUM 2.0 OMNISEARCH CODE
394	=====================================================================
395	*/
396			
397	$('#searchFilters a[data-search]').on('click', function(e){
398		e.stopPropagation();
399		$('#searchFilters .searchable').removeClass('searchable');
400		$(this).toggleClass('searchable');
401		
402	});		
403	
404	 
405	$('body').on('focus', '#SearchFilterAjax, .highlightVal', function(e){
406		$(this).select();
407	});
408	
409	
410	$('#SearchFilterAjax').on('keyup', function(e){
411		if (e.keyCode != 13) {return true;}
412		$("#detailsPopup").hide();
413		var elem = $(this);
414		var searchText = elem.val();			
415		var modal = elem.attr('data-modal') || 'mycadModal';
416		var href = elem.attr('href') || elem.attr('data-href');
417					
418		if (!$('#mycadModal').length) {
419			var template = _.template($("#mycadModalTemplate").html());
420			$('body').prepend(template);
421		}
422		
423		var popup = $('#'+modal); 
424		popup.empty().removeClass('no-data data-found');
425		
426		if (searchText && searchText != '') {
427			
428			if (searchText.substring(0, 3).toLowerCase() == 'es ') {
429				var searchArgs = searchText.split(' ');
430				if (isNaN(searchArgs[1]) || (searchArgs[1].length < 4 && searchArgs.length < 3)) {
431					var now = new Date();
432					var year = now.getFullYear();
433					year = now.getMonth() == 11 ? ++year : year;
434					searchArgs.splice(1, 0, year)
435				}
436
437				var win = window.open("https://www.eventscribe.net/"+ searchArgs[1] +'/'+ searchArgs[2] +'?planner_admin_mode=1');
438				win.focus();
439				
440			} else if (searchText.substring(0, 3).toLowerCase() == 'po ') {
441				var searchArgs = searchText.split(' ');
442				if (isNaN(searchArgs[1]) || (searchArgs[1].length < 4 && searchArgs.length < 3)) {
443					var now = new Date();
444					var year = now.getFullYear();
445					year = now.getMonth() == 11 ? ++year : year;
446					searchArgs.splice(1, 0, year)
447				}
448
449				var win = window.open("https://www.eventscribe.net/"+ searchArgs[1] +'/posters/'+ searchArgs[2] +'?poster_admin_mode=1');
450				win.focus();
451			
452			} else if (searchText.substring(0, 4).toLowerCase() == 'err ') {
453				var searchArgs = searchText.split(' ');
454				var win = window.open("/MyCadmium/modules/ErrorLog/ErrorLog.asp?ErrorID="+ searchArgs[1] );
455				win.focus();
456				
457			} else if (searchText.toLowerCase() == 'dev') {
458				var win = window.open("/MyCadmium/modules/development/requests.asp");
459				win.focus();
460				
461			} else if (searchText.toLowerCase() == 'clients') {
462				var win = window.open("/MyCadmium/Modules/Clients/Accounts.asp?Filter=c");
463				win.focus();
464				
465			} else if (searchText.toLowerCase() == 'users') {
466				var win = window.open("/MyCadmium/modules/clients/userlist.as
466p");
467				win.focus();
468				
469			} else if (searchText.toLowerCase() == 'events') {
470				var win = window.open("/MyCadmium/Modules/Events/EventTools.asp");
471				win.focus();
472				
473			} else if (searchText.toLowerCase() == 'punch') {
474				var win = window.open("/MyCadmium/Modules/PunchClock/PunchClockControlPanel.asp");
475				win.focus();
476				
477			} else if (searchText.toLowerCase() == 'projects') {
478				var win = window.open("/mycadmium/modules/Projects/ViewProjects_V2.asp");
479				win.focus();
480				
481			} else if (searchText.toLowerCase() == 'email') {
482				var win = window.open("/mycadmium/modules/aaEmails/emailindex.asp");
483				win.focus();
484				
485			} else if (searchText.toLowerCase() == 'sop') {
486				var win = window.open("/MyCadmium/Modules/assets/SOPs/sops.asp");
487				win.focus();
488				
489			} else if (searchText.toLowerCase() == 'app') {
490				var win = window.open("/MyCadmium/modules/products/apps/apps.asp?ClientID=0&startDate=&endDate=&datafilter=Custom");
491				win.focus();
492				
493			} else if (searchText.toLowerCase() == 'scorecard') {
494				var win = window.open("/MyCadmium/modules/products/scorecards/scorecards.asp?ClientID=0&startDate=&endDate=&datafilter=Custom");
495				win.focus();
496				
497			} else if (searchText.toLowerCase() == 'magnet') {
498				var win = window.open("/MyCadmium/modules/products/magnets/magnets.asp?ClientID=0&startDate=&endDate=&datafilter=Custom");
499				win.focus();
500				
501			} else if (searchText.toLowerCase() == 'expo') {
502				var win = window.open("/MyCadmium/modules/products/expo/expo.asp?ClientID=0&startDate=&endDate=&datafilter=Custom");
503				win.focus();
504				
505			} else if (searchText.toLowerCase() == 'website') {
506				var win = window.open("/MyCadmium/modules/products/websites/websites.asp?ClientID=0&startDate=&endDate=&datafilter=Custom");
507				win.focus();
508				
509			} else if (searchText.toLowerCase() == 'integrations') {
510				var win = window.open("/MyCadmium/modules/Integrations/Integrations.asp");
511				win.focus();
512			
513			} else if (searchText.toLowerCase() == 'timeline') {
514				var win = window.open("/MyCadmium/modules/Events/projecttimeline/projectTimeline.asp");
515				win.focus();
516
517			} else if (searchText.substring(0, 3).toLowerCase() == 'dr ') {
518				var searchArgs = searchText.split(' ');
519				var win = window.open("/MyCadmium/modules/development/requests.asp?target=details&drID="+ searchArgs[1] );
520				win.focus();
521
522			} else {
523				elem.parent().append('<img src="/mycadmium2/includes/images/ajaxWheel.gif" alt="ajax wheel" />');
524				var params = $('#searchFilters').find('a.searchable').attr('data-search');
525				
526				$.ajax({
527				    url: '/mycadmium2/ajaxcalls/omnisearch/search.asp',
528				    type: 'POST',
529				    data: {params: params, SearchText: searchText},
530				    success: function(data){
531					    if (data == 'session expired') {
532							popupAlert({
533								icon: 'icon-cancel-2',
534								duration: 4500, 
535								message: 'Your session has expired.  Please log in to the system again.'
536							});
537						}else {
538							elem.parent().find('img').remove();
539						    
540					     	if (data) {
541					 	    	popup.addClass('data-found');
542					 			popup.append(data);
543					    	}else {
544					 			popup.addClass('no-data');
545					    	}
546							popup.modal({keyboard: true});
547							$('.numeric').numeric();
548							//popup.find("[autofocus]:first").focus();
549						}
550					    
551				    }
552				});
553			}
554		}
555	});
556		
557		
558	/*
559	=====================================================================
560	  MYCADMIUM 2.0 MODAL JS
561	=====================================================================
562	*/
563	
564	
565	// MODAL POPUP CLASS
566	$('body').on('tap', '.modalPopup:not([data-size])', function(e){
567		e.preventDefault();
568		var elem = $(this);
569
570		modalPopup(elem, {
571			href: elem.attr('href') || elem.attr('data-href'),
572			method: elem.attr('data-method') || 'GET',
573			modal: elem.attr('data-modal') || 'mycadModal'
574		});
575	});
576	
577	
578	// SUBMIT MODAL -- FORM SUBMISSION
579	$('body').on('click tap', '.submitModal', function(e){
580		e.preventDefault();
581		var elem = $(this);
582		var form = elem.parents('.modal-content').find('form').first();
583		
584		elem.removeClass('submitModal').addClass('btn-faded');
585		
586		var errors = validateFormBeta(form);
587		
588		if (errors == 0) {
589			form.submit();
590		}else {
591			elem.removeClass('btn-faded').addClass('submitModal');
592		}
593		
594		return false;
595	});
596	
597	
598	// SUBMIT MODAL -- AJAX SUBMISSION
599	$('body').on('click tap', '.ajaxModal', function(e){
600		e.preventDefault();
601		$("#detailsPopup").hide();
602		var elem = $(this);
603		var popup = elem.parents('.modal');
604		var form = elem.parents('.modal-content').find('form').first();
605		var cb = elem.attr('data-callback');
606		var newPopupURL = elem.attr('data-href')
607		elem.removeClass('ajaxModal').addClass('btn-faded');
608		
609		var errors = validateFormBeta(form);
610		
611		if (errors == 0) {
612			$.ajax({
613				url: form.attr('action'),
614				type: form.attr('method'),
615				data: form.serializeArray(),
616				success: function(data){
617					if (data == 'session expired') {
618						popupAlert({
619							icon: 'icon-cancel-2',
620							duration: 4500, 
621							message: 'Your session has expired.  Please log in to the system again.'
622						});
623					}else {
624													
625						if (data && data != ''){
626							popupAlert({message: data, icon: 'icon-checkmark', duration: 4500});
627						}
628						
629						if (newPopupURL) {
630							
631							var requestData = $.parseParams(newPopupURL.split('?')[1] || '');
632							href = newPopupURL.split('?')[0];
633							
634							$.ajax({
635								url: href,
636								type: 'POST',
637								data: requestData,
638								success: function(data){
639									popup.removeClass('in');
640									setTimeout(function(){
641										popup.empty().append(data);
642										popup.addClass('in');
643										if (cb) callFnByString(cb, data);
644									}, 500);
645									
646								}
647							});
648						}else {
649							elem.removeClass('btn-faded').addClass('ajaxModal');
650							$('.modal').modal('hide');
651							if (cb) callFnByString(cb, data)
652						}
653					}
654				},
655				error: function() {
656					popupAlert({
657						duration: 4500, 
658						message: 'Request failed.<br/>Your request either failed or was only partially processed.'
659					});
660					elem.removeClass('btn-faded').addClass('ajaxModal');
661				}
662			});
663		}else {
664			popupAlert({message: 'Please fill all required fields', icon: 'icon-warning', duration: 2500});
665			elem.removeClass('btn-faded').addClass('ajaxModal');
666		}
667		
668		return false;
669	});
670	
671	
672	// SUBMIT MODAL -- CONTINUE TO OTHER POPUP
673	$('body').on('click tap', '.modal .nextModal', function(e){
674		e.preventDefault();
675		$("#detailsPopup").hide();
676		var elem = $(this);
677		var popup = $('.modal');
678		var form = elem.parents('.modal-content').find('form').first();
679		
680		elem.removeClass('nextModal').addClass('btn-faded');
681		
682		var errors = validateFormBeta(form);
683		
684		if (errors == 0) {
685		
686			$.ajax({
687				url: form.attr('action'),
688				type: form.attr('method'),
689				data: form.serializeArray(),
690				success: function(data){
691					if (data == 'session expired') {
692						popupAlert({
693							icon: 'icon-cancel-2',
694							duration: 4500, 
695							message: 'Your session has expired.  Please log in to the system again.'
696						});
697					}else {
698						popup.removeClass('in');
699						setTimeout(function(){
700							popup.empty().append(data);
701							popup.addClass('in');
702						}, 500);
703					}
704					
705				},
706				error: function() {
707					popupAlert({
708						duration: 4500, 
709						message: 'Request failed.<br/>The next popup failed to load because there was an error on the page.'
710					});
711					elem.removeClass('btn-faded').addClass('nextModal');
712				}
713			});
714		}else {
715			elem.removeClass('btn-faded').addClass('nextModal');
716		}
717		
718		return false;
719	});
720	
721	
722	// AJAX MODAL -- CONTINUE TO OTHER POPUP
723	$('body').on('click tap', '.nextModalBtn', function(e){
724		e.preventDefault();
725		$("#detailsPopup").hide();
726		var elem = $(this);
727		var popup = $('.modal');
728		var method = elem.attr('data-method') || "POST";
729		var targetURL = elem.attr('data-href');
730		
731		var requestData = $.parseParams(targetURL.split('?')[1] || '');
732		href = targetURL.split('?')[0];
733		
734		if (!href || href == '') {
735			console.log('data-href attibute is missing.')
736			return false;
737		}
738		
739		elem.removeClass('nextModalBtn').addClass('btn-faded');
740		
741		$.ajax({
742			url: href,
743			type: method,
744			data: requestData,
745			success: function(data){
746				if (data == 'session expired') {
747					popupAlert({
748						icon: 'icon-cancel-2',
749						duration: 4500, 
750						message: 'Your session has expired.  Please log in to the system again.'
751					});
752				}else {
753
754					popup.removeClass('in');
755					setTimeout(function(){
756						popup.empty().append(data);
757						popup.addClass('in');
758						$('.tipsy').hide();
759						$('.numeric').numeric();
760					}, 500);
761				}
762				
763			},
764			error: function() {
765				popupAlert({
766					duration: 4500, 
767					message: 'Request failed.<br/>The next popup failed to load because there was an error on the page.'
768				});
769				elem.removeClass('btn-faded').addClass('nextModalBtn');
770			}
771		});
772		
773		return false;
774	});
775	
776	
777	// TABBED MODAL SWITCH TABS
778	$('body').on('tap', '.modal-body .tabs [data-target]', function(e){
779		e.preventDefault();
780		var elem = $(this);
781		var panel = $('#'+ elem.attr('data-target'));
782		
783		$('[data-target].active').removeClass('active');
784		$('.pnl.active').trigger('cd.popuptab.hide').removeClass('active').trigger('cd.popuptab.hidden');
785		panel.trigger('cd.popuptab.show').addClass('active').trigger('cd.popuptab.shown');
786		elem.addClass('active');
787		
788	});
789	
790	
791	$(document).on('shown.bs.modal', '.modal', function() {
792		$(".tipsy, #detailsPopup").hide();
793    	$(this).find("[autofocus]").focus();
794    });
795
796		
797		
798    /*
799	=====================================================================
800	  MYCADMIUM 2.0 GLOBAL DETAILS POPUP
801	=====================================================================
802	*/
803    
804    var detailsTimer;
805    
806    $('body').on('click tap', '[data-details="true"]', function(e){
807		if (e.target.className != 'noPopup') {
808			e.preventDefault();
809			var elem = jQuery(this);
810			var detailsPopup, leftPos, topPos;
811			
812			if (!$('#detailsPopup').length){
813				$('body').prepend('<div id="detailsPopup"></div>');
814			}
815			
816			clearTimeout(detailsTimer);
817			
818			if (elem.is('[data-href]')) {
819				var id = elem.attr("data-id");
820				
821				$.ajax({
822					url: elem.attr('data-href'),
823					type: 'POST',
824					data: {ID: id},
825					success: function(data) {
826						if (data == 'session expired') {
827							popupAlert({
828								icon: 'icon-cancel-2',
829								duration: 4500, 
830								message: 'Your session has expired.  Please log in to the system again.'
831							});
832						}else if (data) {
833								
834							detailsPopup = jQuery('#detailsPopup');
835							detailsPopup.removeClass();
836							detailsPopup.empty().append(data);
837							
838							positionDetailsPopup(e);
839						}
840					},
841					error: function() {
842						popupAlert({
843							duration: 4500, 
844							message: 'Request failed.'
845						});
846					}
847				});
848				
849			}else {
850				htmlContent = elem.find('.details').html();
851				
852				detailsPopup = jQuery('#detailsPopup');
853				detailsPopup.removeClass();
854				detailsPopup.empty().append(htmlContent);
855				
856				positionDetailsPopup(e);
857									
858			}
859			}
860		});
861		
862	
863	// CLEAR THE POPUP TIMER WHEN WE HOVER OVER THE DETAILS POPUP
864	$("body").on('mouseenter', '#detailsPopup', function () {
865		clearTimeout(detailsTimer);
866	}).on('mouseleave', '#detailsPopup', function () {
867		detailsTimer = setTimeout(function(){$('#detailsPopup').stop(true, true).fadeOut(200);}, 500);
868	});
869	
870			
871	if (isMobile.any()) {
872		
873		// HIDE THE POPUP WHEN WE SWIPE LEFT OR RIGHT ON MOBILE
874		$('body').on('swipeleft swiperight', '#detailsPopup', function (){
875		    $('#detailsPopup').stop(true, true).fadeOut(200);
876		});
877	
878		// HIDE THE POPUP WHEN WE SWIPE LEFT OR RIGHT ON MOBILE
879		$('body').bind("scroll", function(e){
880			$('#detailsPopup').stop(true, true).hide();
881		});
882	}
883   
884			
885	/*
886	=====================================================================
887	  MYCADMIUM 2.0 DEFAULT POPUP ALERT JS
888	=====================================================================
889	*/
890	
891	
892	$('body').on('click', '#popupAlert .cancelBtn', function(e){
893		e.preventDefault();
894		closePopup();
895	});
896		
897		
898	/*
899	=====================================================================
900	  MYCADMIUM 2.0 SPEEDBUMP CLASS
901	=====================================================================
902	*/
903
904	// SPEED BUMP CLASS
905	$('body').on('click', '.speedBump', function(e){
906		e.preventDefault();
907		jQuery("#detailsPopup").hide();
908		
909		var elem = $(this);
910		var href = elem.attr('href') || elem.attr('data-href');
911		var yesText = elem.attr('data-yestext') || 'Continue';
912		var msg = elem.attr('data-text') || 'Are you sure you want to continue?';
913		var yesClass = elem.attr('data-yesClass') || 'yesClass'; 
914			
915		popupAlert({
916			icon: 'icon-warning',
917			message: msg,
918			duration: 999999999,
919			yesText: yesText,
920			yesLink: href,
921			yesClass : yesClass, 
922			cancelLink: '#'
923		});	
924		
925	});
926		
927		
928	/*
929	=====================================================================
930	  MYCADMIUM 2.0 FORMS
931	=====================================================================
932	*/
933	
934	
935	$('body').on('keypress', '.disable-input', function(e){
936		e.preventDefault();
937		return false;
938	});
939		
940		
941		
942	/*
943	=====================================================================
944	  MISC FUNCTIONS
945	=====================================================================
946	*/
947	
948	// SEND CADMIUM USER KEY
949	$('body').on('tap', '.sendkey', function(e) {
950		e.preventDefault();
951		var id = jQuery(this).attr('data-id') || jQuery(this).parents('.list-item').attr('data-id');
952
953		jQuery.ajax({
954			url: "/mycadmium2/modules/clients/users/ajaxcalls/sendKey.asp", 
955			type: 'POST',
956			data: {ID: id},
957			success: function(data) {
958				if (data == 'session expired') {
959					popupAlert({
960						icon: 'icon-cancel-2',
961						duration: 4500, 
962						message: 'Your session has expired.  Please log in to the system again.'
963					});
964				}else {
965					popupAlert({
966						duration: 4500, 
967						icon: 'icon-checkmark', 
968						message: 'Login details were sent to '+ data
969					});
970				}
971				
972			},
973			error: function(){
974				popupAlert({
975					duration: 4500, 
976					message: 'Request failed.<br/>Your request either failed or was only partially processed.'
977				});
978				
979			}
980		});
981	});
982	
983	
984	$('body').on('tap', '.postLink', function(e) {
985		e.preventDefault();
986		var hrefArr = this.href.split('?');
987		var href = hrefArr[0];
988		var params = $.parseParams(hrefArr[1] || '');
989		var newWin = $(this).attr('target') == '_blank' ? true : false;
990		post(href, params, newWin);
991	});
992	
993	
994	/* we do this here so users arent trying to interact with the UI while a new request is being processed */
995	$(window).on('beforeunload', function(){
996	    $('body').empty().addClass('loading');
997	    $('body').append('<div id="loadTxt" class="text-muted text-lg">Processing Request...</div>');
998	});
999	
1000}); //end ready
1001
1002
1003
1004
1005
1006
1007
1008		
1009		
1010/*
1011=====================================================================
1012POPUP FUNCTIONS
1013=====================================================================
1014*/
1015
1016function popupAlert(settings) {
1017	jQuery("#detailsPopup").hide();
1018				
1019	var defaults = {
1020		icon: 'icon-warning',
1021		duration: 3500,
1022		noText: 'No',
1023		noClass: 'noBtn',
1024		yesText: 'Yes',
1025		yesClass: 'yesBtn',
1026		cancelText: 'Cancel',
1027		cancelClass: 'cancelBtn',
1028		popup: false
1029	}
1030	
1031	settings = $.extend(defaults, settings);
1032	
1033	if (!$('#popupAlert').length) {
1034		var template = _.template($("#popupAlertTemplate").html());
1035		
1036		if (settings.popup) {
1037			if ($('.modal .modal-body').length) {
1038				$('.modal .modal-body').prepend(template);
1039			}else {
1040				throw new Error('No modal body element was found.');
1041				return false;
1042			}
1043			
1044		}else {
1045			$('body').prepend(template);
1046		}
1047		
1048		
1049	}
1050	
1051	var buttons = '';
1052	var popupAlert = $("#popupAlert");
1053	
1054	
1055	if (!settings.message) {
1056		throw new Error('No message provided.');
1057		return false;
1058	}
1059	
1060	if (settings.color) {
1061		popupAlert.addClass(settings.color);
1062	}else {
1063		settings.yesClass = settings.yesClass + ' btn-red';
1064		settings.cancelClass = settings.cancelClass + ' btn-blue';
1065	}
1066
1067	if(settings.cancelLink){
1068		buttons = buttons + "<a class='btn "+ settings.cancelClass +"' id='"+ settings.cancelID +"' href='"+ settings.cancelLink +"'>"+ settings.cancelText +"</a>"
1069	}
1070	
1071	if(settings.noLink){
1072		buttons = buttons + "<a class='btn "+ settings.noClass +"' id='"+ settings.noID +"' href='"+ settings.noLink +"'>"+ settings.noText +"</a>"
1073	}
1074	
1075	if(settings.yesLink){
1076		buttons = buttons + "<a class='btn "+ settings.yesClass +"' id='"+ settings.yesID +"' href='"+ settings.yesLink +"'>"+ settings.yesText +"</a>";
1077	}
1078	
1079	if(settings.customDataAttr){
1080		for (var attr in settings.customDataAttr) {
1081		  if (settings.customDataAttr.hasOwnProperty(attr)) {
1082			  popupAlert.attr('data-'+attr, settings.customDataAttr[attr]);
1083		  }
1084		}
1085	}
1086	
1087	popupAlert.find('.buttons').empty();
1088	popupAlert.find('span.icon').remove();
1089	popupAlert.find('h4 >
1089 span').empty().html(settings.message);
1090	
1091	if (settings.icon && settings.icon != '') {
1092		if (settings.popup) {
1093			$('h4', popupAlert).prepend('<span aria-hodden="true" class="icon '+ settings.icon +'"></span>');
1094		}else {
1095			popupAlert.prepend('<span aria-hodden="true" class="icon '+ settings.icon +'"></span>');
1096		}
1097	}
1098	
1099	if (buttons) {
1100		popupAlert.find('.buttons').html(buttons);
1101	}
1102	
1103	if (settings.onShow && typeof settings.onShow == 'function') {
1104		settings.onShow();
1105	}
1106		
1107	if (settings.popup) {
1108		popupAlert.slideDown(250, function(){
1109			
1110			if (settings.onShown && typeof settings.onShown == 'function') {
1111				settings.onShown();
1112			}
1113			
1114			setTimeout(function(){
1115				if (settings.onHide && typeof settings.onHide == 'function') {
1116					settings.onHide();
1117				}
1118				
1119				popupAlert.slideUp(250, function(){
1120					if (settings.onHidden && typeof settings.onHidden == 'function') {
1121						settings.onHidden();
1122					}
1123				});
1124			}, settings.duration);
1125		});
1126	}else {
1127		
1128		popupAlert.fadeIn(250, function(){
1129			
1130			if (settings.onShown && typeof settings.onShown == 'function') {
1131				settings.onShown();
1132			}
1133			
1134			setTimeout(function(){
1135				if (settings.onHide && typeof settings.onHide == 'function') {
1136					settings.onHide();
1137				}
1138					
1139				popupAlert.fadeOut(250, function() {
1140					if (settings.onHidden && typeof settings.onHidden == 'function') {
1141						settings.onHidden();
1142					}
1143				});
1144			}, settings.duration);
1145		});
1146	}
1147	
1148	
1149}
1150
1151function closePopup() {
1152	var popup = jQuery('#popupAlert');
1153	if (popup.parents('.modal').length) {
1154		popup.slideUp(250);
1155	}else {
1156		popup.fadeOut(250);
1157	}
1158}
1159		
1160
1161/*
1162=====================================================================
1163SEARCH FUNCTIONS
1164=====================================================================
1165*/	
1166
1167function myCadmiumSearch(input, elements, callback){
1168	// IF WE ARE USING IE...	
1169	if (navigator.appName == 'Microsoft Internet Explorer'){
1170
1171		input.bind('keypress change paste', function(e){
1172			//search when Enter/Return key was pressed
1173			jQuery(this).next().fadeIn(250);
1174
1175			if(jQuery(this).val() == '') {  
1176				jQuery(this).next().fadeOut(250); 
1177			} 
1178				
1179			if (e.keyCode == 13) {
1180		        keywordSearch(elements, jQuery(this).val());
1181		        if (typeof callback === "function") {
1182					callback();
1183				}
1184		    }
1185		});
1186
1187	//OTHER BROWSERS START HERE
1188	}else {
1189
1190		input.on('keyup change paste', function(e) {
1191			jQuery(this).next().fadeIn(250);
1192
1193			if(jQuery(this).val() == '') {  
1194				jQuery(this).next().fadeOut(250); 
1195			} 
1196
1197			keywordSearch(elements, jQuery(this).val());
1198				if (typeof callback === "function") {
1199				callback();
1200			}
1201		});
1202
1203	}// end IE if statement
1204	
1205	function keywordSearch(elements, search_text) {
1206		var rg = new RegExp('^(?=.*?'+jQuery.unique(search_text.split(" ")).join(")(?=.*?")+')', "i");
1207		elements.each(function(){
1208			var elem = jQuery(this);
1209			if(jQuery.trim(elem.text()).replace(/\s/g, "").search(rg) == -1) {
1210				elem.css('display', 'none');
1211			} else {
1212				elem.css('display', '');
1213			}
1214
1215		});
1216		
1217	}
1218	
1219	input.next().on('click', function(){
1220		input.val('');	
1221		$(this).fadeOut(250);
1222		elements.each(function(){
1223			jQuery(this).css('display','');
1224		});
1225		
1226		if (typeof callback === "function") {
1227			callback();
1228		}
1229	});
1230	
1231}
1232	
1233
1234	
1235/*
1236=====================================================================
1237  GENERAL PURPOSE FUNCTIONS
1238=====================================================================
1239*/
1240	
1241function positionDetailsPopup(event) {
1242	var panel = $('#content-container');
1243	var leftBound = panel.offset().left;
1244	var rightBound = leftBound + panel.outerWidth();
1245	rightBound = Math.min(rightBound, $(window).width());
1246	
1247	var popupWidth = $('#detailsPopup').outerWidth();
1248	var topPos = event.pageY - 10;
1249	
1250	if (rightBound - popupWidth < event.pageX) {
1251		if (($(window).height() - topPos) <= ($('#detailsPopup').outerHeight() + 50)) {
1252			$('#detailsPopup').addClass('bottom-right-arrow');
1253			topPos = topPos - $('#detailsPopup').outerHeight() - 20;
1254		}else {
1255			$('#detailsPopup').addClass('top-right-arrow');
1256		}
1257		leftPos = event.pageX - ($('#detailsPopup').outerWidth() - 25);
1258		
1259	}else if (event.pageX - popupWidth < leftBound) {
1260		if (($(window).height() - topPos) <= ($('#detailsPopup').outerHeight() + 50)) {
1261			$('#detailsPopup').addClass('bottom-left-arrow');
1262			topPos = topPos - $('#detailsPopup').outerHeight() - 20;
1263		}else {
1264			$('#detailsPopup').addClass('top-left-arrow');
1265		}
1266		leftPos = event.pageX - 25;
1267		
1268	}else {
1269		leftPos = event.pageX - (($('#detailsPopup').outerWidth() / 2) + 5);
1270		
1271		if (($(window).height() - topPos) <= $('#detailsPopup').outerHeight()) {
1272			$('#detailsPopup').addClass('bottom-arrow');
1273			topPos = topPos - $('#detailsPopup').outerHeight() - 20;
1274		}
1275	}
1276	$('#detailsPopup').css({'position':'absolute', 'top':topPos, 'left':leftPos}).stop(true, true).fadeIn(400);
1277}
1278
1279
1280// CALL A FUNCTION USING ITS STRING NAME
1281function callFnByString(string, params) {
1282	// find object
1283	var fn = window[string];
1284	// is object a function?
1285	if (typeof fn === "function") fn(params);
1286}
1287	
1288		
1289// POST TO THE PROVIDED URL WITH THE SPECIFIED PARAMETERS
1290function post(path, parameters, newWin) {
1291    var form = $('<form></form>');
1292    form.attr("method", "post");
1293    form.attr("action", path);
1294    if (newWin) form.attr('target', '_blank')
1295
1296    $.each(parameters, function(key, value) {
1297        var field = jQuery('<input></input>');
1298        field.attr("type", "hidden");
1299        field.attr("name", key);
1300        field.attr("value", value);
1301
1302        form.append(field);
1303    });
1304
1305    // The form needs to be a part of the document in
1306    // order for us to be able to submit it.
1307    $(document.body).append(form);
1308    form.submit();
1309}
1310
1311
1312function ajaxContent(loadFrom, elem, success, error) {
1313	// Check for a url in case we are ajaxing content
1314
1315	if (!loadFrom || loadFrom == '') {
1316		var loadFrom = elem.attr('href') || elem.attr('data-href');
1317		loadFrom = loadFrom == '#' ? null : loadFrom;
1318	}
1319	
1320	if (!elem || elem.length == 0) elem = $('body');
1321
1322	if (loadFrom) {
1323		// Trigger a custom event so we can piggyback off of this function
1324		elem.trigger('cd.ajaxContent.beforeSend');
1325		
1326		// Parse the url and the request data
1327		var requestData = $.parseParams(loadFrom.split('?')[1] || '');
1328		loadFrom = loadFrom.split('?')[0]
1329	
1330		// Send the request
1331		$.ajax({
1332			url: loadFrom,
1333			type: elem.attr('data-method') || 'GET',
1334			data: requestData,
1335			success: function(data){
1336				// Successful - before firing callback
1337				elem.trigger('cd.ajaxContent.successBegin');
1338				
1339				// Trigger callback if we were passed a function
1340				if (success && typeof success == 'function') success(data);
1341				
1342				// Successful - before firing callback
1343				elem.trigger('cd.ajaxContent.successEnd');
1344				myCad.setup();
1345			},
1346			error: function() {
1347				// Error - before firing callback
1348				elem.trigger('cd.ajaxContent.errorBegin');
1349				
1350				// Trigger callback if we were passed a function
1351				if (error && typeof error == 'function') error();
1352				
1353				// Error - before firing callback
1354				elem.trigger('cd.ajaxContent.errorEnd');
1355			}
1356		});
1357		
1358	}else {
1359		throw new Error('URL not specified.');
1360	}
1361	
1362	return elem;
1363}
1364
1365
1366//ADD OR UPDATE QUERYSTRING PARAMETERS
1367function updateQSParameter(uri, key, value) {
1368	var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
1369	var separator = uri.indexOf('?') !== -1 ? "&" : "?";
1370	if (uri.match(re)) {
1371		if (value && value != '') {
1372			return uri.replace(re, '$1' + key + "=" + value + '$2');
1373		}else {
1374			return uri.replace(re, '');
1375		}
1376	}else {
1377		if (value && value != '') {
1378			return uri + separator + key + "=" + value;
1379		}
1380	}
1381}
1382
1383function getQSParameter(name, url) {
1384    if (!url) url = window.location.href;
1385    name = name.replace(/[\[\]]/g, "\\$&");
1386    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
1387        results = regex.exec(url);
1388    if (!results) return null;
1389    if (!results[2]) return '';
1390    return decodeURIComponent(results[2].replace(/\+/g, " "));
1391}
1392
1393// PARSE QUERYSTRING ARGUMENTS INTO AN OBJECT
1394(function($) {
1395	
1396	var re = /([^&=]+)=?([^&]*)/g;
1397	var decodeRE = /\+/g;  // Regex for replacing addition symbol with a space
1398	var decode = function (str) {return decodeURIComponent( str.replace(decodeRE, " ") );};
1399	jQuery.parseParams = function(query) {
1400	    var params = {}, e;
1401	    while ( e = re.exec(query) ) { 
1402	        var k = decode( e[1] ), v = decode( e[2] );
1403	        if (k.substring(k.length - 2) === '[]') {
1404	            k = k.substring(0, k.length - 2);
1405	            (params[k] || (params[k] = [])).push(v);
1406	        }
1407	        else params[k] = v;
1408	    }
1409	    return params;
1410	};
1411})(jQuery);
1412
1413if (!Object.keys) {
1414    Object.keys = function (obj) {
1415        var keys = [], k;
1416        for (k in obj) {
1417            if (Object.prototype.hasOwnProperty.call(obj, k)) keys.push(k);
1418        }
1419        return keys;
1420    };
1421}
1422
1423function ColorLuminance(hex, lum) {
1424	// validate hex string
1425	hex = String(hex).replace(/[^0-9a-f]/gi, '');
1426	if (hex.length < 6) {
1427		hex = hex[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2];
1428	}
1429	lum = lum || 0;
1430
1431	// convert to decimal and change luminosity
1432	var rgb = "#", c, i;
1433	for (i = 0; i < 3; i++) {
1434		c = parseInt(hex.substr(i*2,2), 16);
1435		c = Math.round(Math.min(Math.max(0, c + (c * lum)), 255)).toString(16);
1436		rgb += ("00"+c).substr(c.length);
1437	}
1438
1439	return rgb;
1440}
1441
1442
1443function rgb2hex(rgb) {
1444    if (/^#[0-9A-F]{6}$/i.test(rgb)) return rgb;
1445
1446    rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
1447    function hex(x) {
1448        return ("0" + parseInt(x).toString(16)).slice(-2);
1449    }
1450    return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
1451}
1452
1453
1454function attachDatePicker(elem, config) {
1455	var value = elem.val();
1456	var date = new Date(value);
1457	var defaults = {
1458	    field: elem[0],
1459	    format: 'MMM DD, YYYY',
1460	    defaultDate: new Date(elem.val()),
1461	    setDefaultDate: new Date(elem.val()),
1462	    onOpen: onPikadayOpen
1463	}
1464
1465	if (!isMobile.any()) {
1466		
1467		elem.attr('type', 'text');
1468	    return new Pikaday($.extend(defaults, config));
1469		
1470	}else {
1471		elem.attr('type', 'date');
1472		elem.val(moment(date).format('YYYY-MM-DD'));
1473		return;
1474	}
1475		
1476}
1477
1478function onPikadayOpen() {
1479	$('.tipsy').hide();
1480}
1481				
1482	
1483function attachTimePicker(elem, config) {
1484	var value = parseTime(elem.val());
1485
1486
1487	if (!isMobile.any()) {
1488		
1489		elem.attr('type', 'text');
1490		
1491	    return elem.clockpick({
1492			minutedivisions: 12, // 5 minute intervals
1493			starthour: 0,
1494			endhour: 23
1495		});
1496		
1497	}else {
1498		elem.attr('type', 'time');
1499		if (value instanceof Date) elem.val(moment(value).format('HH:mm:ss'));
1500		return;
1501	}
1502		
1503}	
1504
1505function parseTime(time) {
1506	if (typeof time !== 'string') return null;
1507	time = time.trim().toLowerCase();
1508	
1509	var pm = false;
1510	if (time.indexOf('pm') > 0) pm = true;
1511	time = time.replace('am', '').replace('pm', '').trim();
1512	
1513	var parts = time.split(':');
1514	if (parts.length == 2) {
1515		return new Date(1970, 1, 1, parts[0], parts[1], 0, 0);
1516	}else if (parts.length == 3) {
1517		return new Date(1970, 1, 1, parts[0], parts[1], parts[2], 0);
1518	}else {
1519		return null;
1520	}
1521}
1522
1523function validateFormBeta(form) {
1524	var errors = 0;
1525	$('.required.form-control', form).each(function(){
1526		var val = $(this).val();
1527		var panel = $(this).parents('.pnl');
1528		$(this).parent().removeClass('has-error');
1529		
1530		if (val == '') {
1531			$(this).parent().addClass('has-error');
1532			if (panel.length && panel.attr('id')) {
1533				$('[data-target="'+panel.attr('id')+'"]').addClass('has-error');
1534			}
1535			errors++;
1536		}else {
1537			$(this).parent().removeClass('has-error');
1538			if (panel.length && panel.attr('id')) {
1539				$('[data-target="'+panel.attr('id')+'"]').removeClass('has-error');
1540			}
1541		}
1542		
1543	});
1544	return errors;
1545}
1546
1547
1548function formSetup() {
1549	if ($('form').length) {
1550		insertRequiredAsterisks();
1551	}
1552	
1553}
1554
1555function insertRequiredAsterisks() {
1556	$('.form-control[name][required]').not('[type="radio"], [type="checkbox"]').each(function(){
1557		var label = $('label[for="'+ $(this).attr('id') +'"]');
1558		if (!$('.reqMark', label).length && label.attr('data-asterisk') !== 'false') {
1559			label.append($('<span class="reqMark" role="presentation"></span>'));
1560		}
1561	});
1562}
1563
1564
1565function modalPopup(elem, options) {
1566	$("#detailsPopup").hide();
1567		
1568	if (!$('#mycadModal').length) {
1569		var template = _.template($("#mycadModalTemplate").html());
1570		$('body').prepend(template);
1571	}
1572	
1573	options.modal = options.modal || 'mycadModal'
1574		
1575	var popup = $('#'+ options.modal); 
1576	popup.empty().removeClass('no-data data-found');			
1577		
1578	var requestData = $.parseParams(options.href.split('?')[1] || '');
1579	options.href = options.href.split('?')[0]
1580		
1581	$.ajax({
1582	    url: options.href,
1583	    type: options.method || 'GET',
1584	    data: requestData,
1585	    success: function(data){
1586		    if (data == 'session expired') {
1587				popupAlert({
1588					icon: 'icon-cancel-2',
1589					duration: 4500, 
1590					message: 'Your session has expired.  Please log in to the system again.'
1591				});
1592			}else {
1593		     	if (data) {
1594		 	    	popup.addClass('data-found');
1595		 			popup.append(data);
1596		    	}else {
1597		 			popup.addClass('no-data');
1598		    	}
1599				popup.modal({keyboard: true});
1600				myCad.setup();
1601			}
1602	    }
1603	});
1604	
1605}
1606
1607function getMyCadmiumDirectory() {
1608	return window.location.pathname.split('/')[1]
1609}
1610	
1611	
1612/*
1613=====================================================================
1614Class for myCadmium application
1615=====================================================================
1616*/
1617
1618function myCadmium() {
1619	this.navigation = new navigation();
1620	
1621	this.eventListeners();
1622	this.setup();
1623	
1624	
1625}
1626
1627
1628// This needs to be run when new content is loaded via ajax
1629myCadmium.prototype.setup = function() {
1630	formSetup();								// Initialize forms if they exist
1631	$('.numeric').numeric();					// run the numeric class	
1632	
1633	// Initialize bootstrap tooltips
1634	$('[data-toggle="tooltip"]').tooltip({		
1635		html:true,
1636		container: 'body',
1637		trigger: 'click',
1638		viewport: '.page-content'
1639	});		
1640	
1641	// Initialize bootstrap popovers
1642	$('[data-toggle="popover"]').popover({		
1643		html:true,
1644		container: 'body',
1645		trigger: 'click',
1646		viewport: '.page-content'		
1647	});			
1648}
1649
1650myCadmium.prototype.eventListeners = function() {
1651	
1652	// Cancel inactive buttons
1653	$(document).on('tap', '.btn.inactive, .btn.spacer, .modalPopup.inactive', function(e){
1654		e.preventDefault();
1655		e.stopPropagation();
1656		return false;
1657	});
1658	
1659	$(document).on('show.bs.popover', function(e){
1660		$('[data-toggle="popover"]').not(e.target).popover('hide');
1661	});
1662}
1663		
1664/*
1665=====================================================================
1666Class to control the navigation
1667=====================================================================
1668*/
1669
1670// Constructor
1671function navigation() {
1672	this.sideNav = new sideNav();
1673	this.updatePunch(false);
1674}
1675
1676navigation.prototype.updatePunch = function(showMessage) {
1677	$.ajax({
1678		url: '/myCadmium2/ajaxcalls/nav/getLastPunch.asp',
1679		type: 'GET',
1680		success: function(data) {
1681			// console.log('data: ' + data);
1682			if (data === "session expired") return;
1683			var punch = JSON.parse(data);
1684			$('#navPunch').attr('data-tooltip', punch.tooltip);
1685			$('#navPunch').removeClass('punchIn punchOut btn-green btn-orange').addClass(punch.classes);
1686			$('#navPunch').attr('href', punch.link);
1687			$('#navPunch').text(punch.text);
1688			
1689			if (showMessage) {
1690				var msg = ''
1691				if (punch.text.toLowerCase() == 'punch in') {
1692					msg = 'Successfully punched out.'
1693				}else {
1694					msg = 'Successfully punched in.'
1695				}
1696				
1697				popupAlert({
1698					icon:'icon-checkmark',
1699					duration: 2500, 
1700					message: msg
1701				});
1702			}
1703		},
1704		error: function(){
1705			$('#navPunch').attr('data-tooltip', 'Failed to retrieve punch data.<br/>Please see the myCadmium developer to have this resolved.');
1706			$('#navPunch').removeClass('punchIn punchOut btn-green btn-orange').addClass('btn-red');
1707			$('#navPunch').attr('href', 'javascript:void(0);');
1708			$('#navPunch').text('No Punch Data');
1709			
1710			popupAlert({
1711				icon:'icon-warning',
1712				duration: 999999999, 
1713				message: 'Failed to retrieve punch data.<br/>Please see the myCadmium developer to have this resolved.',
1714				cancelText: 'OK',
1715				cancelLink:'#'
1716			});
1717		}
1718	});
1719	
1720}
1721
1722
1723/*
1724=====================================================================
1725Class to control the side nav
1726=====================================================================
1727*/
1728
1729// Constructor
1730function sideNav() {
1731	this.panels = [];
1732	this.expanded = false;	
1733	this.init();	
1734}
1735
1736// Initialize the side navigation with some events
1737sideNav.prototype.init = function(){
1738	
1739	var self = this;
1740
1741	// Collapse quick links section for mobile
1742	if ($(window).width() < 992 || getMyCadmiumDirectory().toLowerCase() == 'mycadmium') {
1743		if ($(window).width() < 768) $('#navbar-left').addClass('collapse');
1744		self.collapse();
1745	}else {
1746		self.expand();
1747	}
1748	
1749	// collapse the quick links if we are on mobile
1750	$(window).resize(function(){
1751		if ($(window).width() >= 768) {
1752			$('#navbar-left').removeClass('collapse in');
1753			$('#navbar-left').removeAttr('aria-expanded').removeAttr('style');
1754		}else {
1755			$('#navbar-left').addClass('collapse');
1756			self.collapse();
1757		}
1758	});
1759	
1760	// toggle the side navigation panel
1761	$('body').on('click', '#navbar .toggleNav', function(e){
1762		e.preventDefault();
1763		self.toggle();
1764	});
1765		
1766	// fire a custom resize event when the css transition ends on the side navigation
1767	$('#sidenav').on("webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend", function(){
1768		$('body').trigger("nav-resized");
1769	});
1770
1771	return this;
1772}
1773
1774// Expand the side navigation
1775sideNav.prototype.expand = function(){
1776	var container = $('#container');
1777	if (!this.expanded) {
1778		container.removeClass('nav-collapsed').addClass('nav-expanded');
1779		$('body').trigger("nav-resize");
1780		this.expanded = true;
1781	}
1782	return this;
1783}
1784
1785// Collapse the side navigation
1786sideNav.prototype.collapse = function(){
1787	var container = $('#container');
1788	if (this.expanded) {
1789		container.removeClass('nav-expanded').addClass('nav-collapsed');
1790		$('body').trigger("nav-resize");
1791		this.expanded = false;
1792	}
1793	return this;
1794}
1795
1796// Toggle the side navigation
1797sideNav.prototype.toggle = function(){
1798	return (this.expanded) ? this.collapse() : this.expand();
1799}
1800	
1801	

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.