/* The following errors were found when attempting to minify this file: - Line 1699: Parse error. syntax error - Line 1704: Parse error. syntax error - Line 1705: Parse error. syntax error - Line 1706: Parse error. 'try' without 'catch' or 'finally' - Line 1708: Parse error. syntax error - Line 1710: Parse error. syntax error - Line 1712: Parse error. syntax error - Line 1713: Parse error. missing ; before statement - Line 1716: Parse error. syntax error - Line 1718: Parse error. syntax error - Line 1719: Parse error. syntax error - Line 1720: Parse error. invalid return - Line 1721: Parse error. syntax error */ /// /// /// /// //Callback global variables for Slideshow. var callbackfnDocumentCenter = null; var callbackfnSlideshowSave = null; var $popUp_Slideshow = null; var parentID_Slideshow = null; var slideshowFolderDefault = ''; var numbersOnly = new RegExp('^[0-9]*$'); //Global variable for ThemeProperties modal var $popup_ThemeProperties = null; //Callback variables for Slideshow. var SetCursorPosition = null; // Prevents errors for Internet Explorer (modes prior to 9). // They will occur unless the developer tools are open. if (!window.console) { var noop = function () { }; // Note: MSIE will override this once the dev. tools are open. window.console = { log: noop, clear: noop, warn: noop, error: noop, assert: noop, dir: noop, count: noop, profile: noop, profileEnd: noop, trace: noop, info: noop, memoryProfile: noop, memoryProfileEnd: noop, exception: noop, debug: noop, dirxml: noop, group: noop, groupEnd: noop, markTimeline: noop, time: noop, timeEnd: noop, groupCollapsed: noop }; } // User-agent sniffing for functions that rely on the user-agent // to determine version of Safari. Avoid using this variable and // check for the presence of features instead (best-practice). var isWebKit = (navigator.userAgent.toLowerCase().indexOf('webkit') > -1); // Determines if an array contains an object. // Uses == equality, case-sensitive. a containsExact() could do === equality. if (!Array.prototype.contains) { Array.prototype.contains = function (item) { for (var i = 0; i < this.length; i++) { if (this[i] == item) return true; } return false; } } // Gets index of an item if it is present in the array, else returns -1. if (!Array.prototype.indexOf) { Array.prototype.indexOf = function (item) { for (var i = 0; i < this.length; i++) { if (this[i] == item) return i; } return -1; } } // Implement ECMAScript 5 String.trim() and friends for browsers that // don't have it (e.g. Firefox prior to 3.5, Internet Explorer 6, 7, 8). if (!String.prototype.trim) { String.prototype.trim = function () { return this.replace(/^\s+/g, "").replace(/\s+$/g, ""); } String.prototype.trimLeft = function () { return this.replace(/^\s+/g, ""); } String.prototype.trimRight = function () { return this.replace(/\s+$/g, ""); } } // Implement .NET-style left-padding method. String.prototype.padLeft = function (desiredLength, paddingChar) { paddingChar += ''; desiredLength = parseInt(desiredLength); if (paddingChar.length > 1) paddingChar = paddingChar.charAt(0); else if (paddingChar.length < 1) return this; if (this.length >= desiredLength) return this; else { var arr = new Array(); var padNum = desiredLength - this.length; for (var i = 0; i < padNum; i++) arr.push(paddingChar); return arr.join('') + this; } } // Implement .NET-style right-padding method. String.prototype.padRight = function (desiredLength, paddingChar) { paddingChar += ''; desiredLength = parseInt(desiredLength); if (paddingChar.length > 1) paddingChar = paddingChar.charAt(0); else if (paddingChar.length < 1) return this; if (this.length >= desiredLength) return this; else { var arr = new Array(); var padNum = desiredLength - this.length; for (var i = 0; i < padNum; i++) arr.push(paddingChar); return this + arr.join(''); } } String.isNullOrEmpty = function (text) { return (text == null || text == ''); } // Adds static method to regular expressions that escapes meta-characters. if (!RegExp.metaEscape) { RegExp.metaEscape = function (text) { if (text == null) return null; else if (typeof (text) != "string") text += ''; return text.replace(/(\\|\/|\<|\>|\:|\.|\*|\+|\?|\$|\[|\]|\(|\)|\{|\}|\||\&)/g, '\\$1'); }; } // Copies text data to clipboard in WebKit browsers (Chrome/Safari). function toWebkitClipboard(text) { // Create element in DOM with text to copy. var tmp = document.createElement('div'); tmp.textContent = text; document.body.appendChild(tmp); // Get current user selection, and remove selection current ranges. var curSelection = window.getSelection(); curSelection.removeAllRanges(); // Create new selection range with DOM element containing text to copy. var textRange = document.createRange(); textRange.selectNode(tmp); curSelection.addRange(textRange); // Execute COPY DHTML command. document.execCommand("Copy"); // Clean-up. document.body.removeChild(tmp); } // Copies value in stringVal to the clipboard, displaying the successMessage if hideAlert is false. // NOTE: Replace this with something like toWebkitClipboard() at some point. function toClipboardEx(stringVal, hideAlert, successMessage) { if (window.clipboardData) { // Internet Explorer if (!window.clipboardData.setData("Text", stringVal) && !hideAlert) hideAlert = true; } else if ((window.WebKitPoint || !window.netscape) && !window.opera) { toWebkitClipboard(stringVal); } else if (window.netscape) { // Mozilla Firefox and derivitives (Netscape, Seamonkey)... try { // Request full access to the XPCOM (Cross-Platform COM) API. netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); } catch (e) { // Unable to obtain access, user rejected or setting in about:config not set right. alert('Please type "about:config" in your browser and press enter. Type "signed.applets.codebase_principal_support" in Filter. Double click to change the value to "true". Then come back and click on the link again.\n\nIf you have already performed this action, make sure when you are asked whether to allow or deny the browser permission, that you are allowing it.'); return; } // Create an instance of the clipboard class. var clipBoard = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard); // Create an instance of the Transferable class (used to talk to the clipboard). var clipTrans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable); // Set clipboard format for text only. clipTrans.addDataFlavor('text/unicode'); // Create XPCOM string, set data to copy of stringVal. var clipString = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString); var copyText = stringVal; clipString.data = copyText; // Note: This code may be bugged in some scenarios! 1 char does not always equal 2 bytes in UTF-16! // Set data to transfer to the clipboard (length * 2, since 1 char is usually 2 bytes in UTF-16). clipTrans.setTransferData("text/unicode", clipString, copyText.length * 2); // Transfer data to the global clipboard. clipBoard.setData(clipTrans, null, clipBoard.kGlobalClipboard); } if (!hideAlert) alert(successMessage); return true; } function toClipboard(stringVal, hideAlert) { return toClipboardEx(stringVal, hideAlert, "The link has been copied to your clipboard."); } function getClipboard() { if (window.clipboardData) { return window.clipboardData.getData('Text'); } else if (window.netscape) { try { netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); } catch (e) { alert('Please type "about:config" in your browser and press enter. Type "signed.applets.codebase_principal_support" in Filter. Double click to change the value to "true". Then come back and click on the link again.\n\nIf you have already performed this action, make sure when you are asked whether to allow or deny the browser permission, that you are allowing it.'); return; } // Create instances of the Clipboard and Transferable objects. var clipBoard = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard); var clipTrans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable); // Get data from global clipboard, place in clipTrans object. clipTrans.addDataFlavor('text/unicode'); clipBoard.getData(clipTrans, clipBoard.kGlobalClipboard); // Create objects to pass to getTransferData, which uses XPCOM String // and Integer classes instead of those normally used by JavaScript. var objStr = new Object(); var objNumBytes = new Object(); try { clipTrans.getTransferData('text/unicode', objStr, objNumBytes); } catch (error) { return ''; } // Query whichever interface is available, opting to use nsISupportsWString. if (objStr) { if (Components.interfaces.nsISupportsWString) objStr = objStr.value.QueryInterface(Components.interfaces.nsISupportsWString); else if (Components.interfaces.nsISupportsString) objStr = objStr.value.QueryInterface(Components.interfaces.nsISupportsString); else objStr = null; } // Note: This code may be bugged in some scenarios! 1 char does not always equal 2 bytes in UTF-16! // Get data out of the XPCOM string and into a normal JS string. if (objStr) return (objStr.data.substring(0, objNumBytes.value / 2)); } return; } // Gets the computed style of an element (browser-independent). var getCurrentStyle = (document.defaultView ? function (elem) { return document.defaultView.getComputedStyle(elem, ''); } : function (elem) { return elem.currentStyle; } ); // Gets children nodes of an HTML DOM element matching the tag name specified. function getChildNodesByTag(domElement, tagName) { var cn = domElement.childNodes; var nodesPresent = 0, retVal = new Array(); retVal.length = cn.length; tagName = tagName.toUpperCase(); for (var cv = 0; cv < cn.length; cv++) { if (cn[cv].nodeType == 1 && cn[cv].nodeName == tagName) retVal[nodesPresent++] = cn[cv]; } return retVal.slice(0, nodesPresent); } // Returns true on Safari browsers 1.3.4 and older (bad date object behavior in old Safari). // Check does not work properly if user-agent has been modified by user. var isSafariVersion13OrOlder = (isWebKit ? function () { var navAppVersion = navigator.appVersion; var phraseToFind = 'AppleWebKit/'; var foundStartAt = navAppVersion.indexOf(phraseToFind) + phraseToFind.length; var foundEndAt = navAppVersion.indexOf(' ', foundStartAt + 1); return (parseInt(navAppVersion.substring(foundStartAt, foundEndAt)) < 320); } : function () { return false; } ); // Returns true on Safari browsers 2.0.4 and older (textbox/button not stylable before 3.x). // Check does not work properly if user-agent has been modified by user. var isSafariVersion20OrOlder = (isWebKit ? function () { var navAppVersion = navigator.appVersion; var phraseToFind = 'AppleWebKit/'; var foundStartAt = navAppVersion.indexOf(phraseToFind) + phraseToFind.length; var foundEndAt = navAppVersion.indexOf(' ', foundStartAt + 1); return (parseInt(navAppVersion.substring(foundStartAt, foundEndAt)) < 525); } : function () { return false; } ); // Returns true if an event fired too soon after another event. // Mechanism used on older Safari browsers to prevent // double-fire problems (especially with key presses). function safariEventRateLimitBlock() { if (isWebKit && isSafariVersion13OrOlder()) { if (safariRateLimited != 0) return true; else { safariRateLimited = setTimeout('safariRateLimited = 0;', 10); return false; } } } // Get coordinates relative to document (works out container issues). // Wrote this so it works in quirks or standards mode. function getDocumentCoordinates(element) { var htmlElem = document.body.parentNode; var bodyElem = document.body; var pos = { "x": 0, "y": 0 }; pos.toString = function () { return this.x + ', ' + this.y; } while (element != null) { pos.x += element.offsetLeft; pos.y += element.offsetTop; switch (element.offsetParent) { case htmlElem: case bodyElem: case null: return pos; } element = element.offsetParent; } } // Attach an event handler to an object (browser-independent). // First clause is W3C DOM method, second is DHTML (IE). var addEvent = (window.addEventListener ? function (obj, evType, fn, useCapture) { try { obj.addEventListener(evType, fn, useCapture); } catch (e) { } return true; } : function (obj, evType, fn, useCapture) { try { return obj.attachEvent('on' + evType, fn); } catch (e) { } } ); // Release an event handler from an object (browser-independent). // First clause is W3C DOM method, second is DHTML (IE). var removeEvent = (window.removeEventListener ? function (obj, evType, fn, useCapture) { try { obj.removeEventListener(evType, fn, useCapture); } catch (e) { } return true; } : function (obj, evType, fn, useCapture) { try { obj.detachEvent('on' + evType, fn); } catch (e) { } return true; } ); // Stops a DOM event from propagating further than the current handler. // Note: Returning false from event handlers in IE 6/7/8 does the same thing. function stopEventPropagation(evObj) { if (evObj.preventDefault) evObj.preventDefault(); // Calling cancelButton after stopPropagation // may negate the stopPropagation so do not do it. -KB if (evObj.stopPropagation) evObj.stopPropagation(); else if (evObj.cancelBubble) evObj.cancelBubble(); } // These functions assists in obscuring email addresses: function mailTo(obj) { //alert('mailto:'+eval(obj.getAttribute('id'))); obj.setAttribute('href', 'mailto:' + eval(obj.getAttribute('id'))); } function js_mail(obj, Emails) { var mail_link = Emails[0]; for (var email = 1; email < Emails.length; email++) if (Emails[email] != null && Emails[email] != '' && Emails[email].substr(1, 4) != 'href') mail_link = mail_link + Emails[email]; obj.setAttribute('href', 'mailto:' + mail_link); } // Used to prevent right-click menu from appearing for some clients that wanted this ability. function antiContextMenuHook() { // Note: Opera is not hookable. var showAlert = function () { alert('All images are protected by Copyright. Do not use without permission.'); } var mdClick = function (e) { if (!document.all) { if (e.button == 2 || e.button == 3) showAlert(); } else if (event && event.button == 2) showAlert(); } var cmClick = function (e) { if (navigator.userAgent.toLowerCase().indexOf('khtml') > -1) { // Safari, Konquerer if (e.preventDefault) e.preventDefault(); showAlert(); } if (e.stopPropagation) e.stopPropagation(); // Mozilla Firefox 2.0 return false; // IE 6.0 and 7.0 } document.onmousedown = mdClick; document.oncontextmenu = cmClick; } // Form validation functions: function RegExValidate(expression, value, param) { var re = new RegExp(expression, param); if (value != '' && value != undefined) { if (value.match(re)) return true; else return false; } else return true; } // Used for validating emailaddress for special scenarios like continuous periods. - VB function checkSpecialScenarios(s) { var bugchars = '!#$^&*()|}{[]?><~%:;/,=`"'; var i; var lchar = ""; // Search through string's characters one by one. // If character is not in bag. for (i = 0; i < s.length; i++) { // Check that current character isn't whitespace. var c = s.charAt(i); if (i > 0) lchar = s.charAt(i - 1) if (bugchars.indexOf(c) != -1 || (lchar == "." && c == ".")) return false; } return true; } // JavaScript version of CivicPlus.CMS.Site.Validation.IsValidEmailAddress(); function emailValidate(emailAddress) { var emailAddressTrimmed = TrimString(emailAddress + ""); if (emailAddressTrimmed != "") { if (checkSpecialScenarios(emailAddressTrimmed) == false) return false; if (emailAddressTrimmed.replace(/[^@]/g, '').length > 1) return false; var parts = emailAddressTrimmed.splitRemoveEmpties('@'); if (emailAddressTrimmed.substr(emailAddressTrimmed.length - 1) == '@') return false; if (parts.length == 2) { for (var i = 0; i < parts.length; i++) { if (((!RegExValidate('^[A-Z0-9]$', parts[i].substr(0, 1), 'i') || !RegExValidate('^[A-Z0-9]$', parts[i].substr(parts[i].length - 1), 'i')) && i == 1) || (!RegExValidate('^[A-Z0-9_%-\\.]+$', parts[i].substr(0, parts[i].length - 1), 'i'))) return false; } var lastDotPos = parts[1].lastIndexOf('.'); if (lastDotPos < 0 || parts[1].substr(lastDotPos).length < 3 || (!RegExValidate('^[A-Z]+$', parts[1].substr(lastDotPos + 1), 'i'))) return false; else return true; } else return false; } else return false; } // Returns: 0 - success, 1 - illegal value, 2 - too large, 3 - too small, 4 - blank. function intValidateWithRange(value, min, max) { if (value == '' || value == null) return 4; if (RegExValidate('^(-|)[0-9]*$', value, 'i')) { try { var pint = parseInt(value); } catch (ex) { return 1; } if (pint < min) return 3; else if (pint > max) return 2; return 0; } else return 1; } // Split function that remotes empty entries. String.prototype.splitRemoveEmpties = function (separator, howmany) { var splitArr; var returnArr = new Array(); if (arguments.length == 2) splitArr = this.split(separator, howmany); else splitArr = this.split(separator); for (var i = 0; i < splitArr.length; i++) { if (splitArr[i] != '') returnArr.push(splitArr[i]); } return returnArr; } // JavaScript equivalent of a function in GlobalFunctionsDetail.aspx. // Do not use this function unless you have a good reason (e.g. textarea length on client must match size on server). // KNOWN: Does not do entities properly, matches server behavior (where's the semi-colon?). function SQLSafe(strInput) { return strInput.replace(/\'/g, "'").replace(/\"/g, """); } // Returns true if the string is empty. Will blow up on NULLs. function FieldIsEmpty(strInput) { if (strInput == undefined) return true; return TrimString(strInput).length == 0; } // Removes leading and trailing white space from a string. Will blow up on NULLs. function TrimString(strInput) { return strInput.replace(/^\s+/g, "").replace(/\s+$/g, ""); } // Returns true if the value is an integer value. function isInteger(strInput) { var leadingZeros = calculateLeadingZeroStrings(strInput); return leadingZeros == strInput || (strInput == leadingZeros + parseInt(strInput).toString()); } // Returns true if the value is a real number. function isRealNumber(strInput) { var leadingZeros = calculateLeadingZeroStrings(strInput); return leadingZeros == strInput || (strInput == leadingZeros + parseFloat(strInput)); } function calculateLeadingZeroStrings(strInput) { var leadingZeros = ""; if (strInput != null) { for (var i = 0; i < strInput.length; i++) { if (strInput[i] == "0") { leadingZeros += "0"; } else { break; } } } return leadingZeros; } // Date validator class. function dateValidator() { this.firstValidDate = new Date('01/01/1753'); this.lastValidDate = new Date('01/01/3000'); this.strStartDateID = 'Start/Begin Date'; this.strEndDateID = 'End/Stop/Expiration Date'; this.strStartTimeID = 'Start Time'; this.strEndTimeID = 'End Time'; this.ysnRequireStartDateIfEndSpecified = false; this.ysnStartDateRequired = false; this.ysnEndDateRequired = false; this.ysnStartTimeRequired = false; this.ysnEndTimeRequired = false; this.ysnAllowEqualDates = false; this.ysnAllowTimeOnly = false; this.ysnCent = false; //Allow only four digit years var dtiEndDate; var dtiStartDate; var dtiStartTime; var dtiEndTime; this.timesAlreadyValidated = false; this.datesAlreadyValidated = false; this.setStartDate = function (date) { dtiStartDate = this.cleanDate(date); } this.setEndDate = function (date) { dtiEndDate = this.cleanDate(date); } this.setStartDateRequired = function (required) { this.ysnStartDateRequired = required; } this.setEndDateRequired = function (required) { this.ysnEndDateRequired = required; } this.setRequireStartDateIfEndSpecified = function (required) { this.ysnRequireStartDateIfEndSpecified = required; } this.cleanDate = function (date) { if (date) { if (typeof isMobileView != 'undefined' && isMobileView) { date = this.ChangeDateFormatForMobileView(date); } else if (RegExValidate('^([0-9\-\\\/]*?)([0-9]{2,4})$', date, 'i')) { var year = RegExp.$2; if (year.length == 2) { if (year >= 50) date = RegExp.$1 + "19" + year; else date = RegExp.$1 + "20" + year; } date = date.replace('\-', '/', 'g'); } } return date; } this.ChangeDateFormatForMobileView = function (date) { var rxDatePattern = /^\d{4}\-\d{1,2}\-\d{1,2}$/; //Regex for yyyy-mm-dd format var match = date.match(rxDatePattern); if (match != null) { var dateArray = date.split('-'); var dateFormat = getDateFormat().toLowerCase(); if (dateFormat == "mm/dd/yyyy") date = dateArray[1] + '/' + dateArray[2] + '/' + dateArray[0]; else if (dateFormat == "dd/mm/yyyy") date = dateArray[2] + '/' + dateArray[1] + '/' + dateArray[0]; } return date; } this.dateValidate = function (dtiDate, ysnRequired, strID) { if (!ysnRequired && (dtiDate == null || dtiDate == '')) return true; else if (ysnRequired && (dtiDate == null || dtiDate == '')) { if (strID) this.error = strID + ' cannot be blank.'; else this.error = ' cannot be blank'; this.errorNumber = 1; return false; } else if (RegExValidate('^(1[0-2]|0?[1-9])(\/|\-)(0?[1-9]|[1-2][0-9]|3[0-1])\\2([0-9]{4}|[0-9]{2})$', dtiDate, 'i')) { var month = RegExp.$1; var day = RegExp.$3; var year = RegExp.$4; if (year.length == 2 && this.ysnCent == true) { if (strID) this.error = strID + ' requires a four digit year'; else this.error = 'Please use a four digit year'; return false; } if (year.length == 4 && (year > 3000 || year < 1753)) { this.error = dtiDate + '\nis outside of the date range.'; this.errorNumber = 2; return false; } if (day == 31 && (month == 4 || month == 6 || month == 9 || month == 11)) { this.error = 'This month doesn\'t have 31 days'; this.errorNumber = 3; return false; } if (day >= 30 && month == 2) { this.error = 'February doesn\'t have ' + day + ' days'; this.errorNumber = 4; return false; } if (month == 2 && day == 29 && !(year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))) { this.error = 'This is not a leap year\nFebruary doesn\'t have 29 days.'; this.errorNumber = 5; return false; } return true; } else { if (strID) this.error = strID + ' is not a valid date format.\nPlease use ' + getDateFormat().toUpperCase() + '.'; else this.error = dtiDate + '\n is an invalid date format.\nPlease use ' + getDateFormat().toUpperCase() + '.'; this.errorNumber = 6; return false; } return false; } this.dateOrderValidate = function () { if (this.dateValidate(dtiStartDate, this.ysnStartDateRequired, this.strStartDateID) && this.dateValidate(dtiEndDate, this.ysnEndDateRequired, this.strEndDateID)) { if (this.ysnRequireStartDateIfEndSpecified && !dtiStartDate && dtiEndDate) { this.error = 'A Start Date must be specified if an End Date was entered.'; this.errorNumber = 9; return false; } if (!dtiStartDate || !dtiEndDate) return true; else { var StartDate = new Date(dtiStartDate); var EndDate = new Date(dtiEndDate); } if (StartDate.getTime() < EndDate.getTime()) return true; else if (StartDate.getTime() == EndDate.getTime() && this.ysnAllowEqualDates == true) { this.ysnDatesAreEqual = true; return true; } else { this.error = 'The End Date must be after the Start Date.'; this.errorNumber = 7; return false; } } else return false; } this.dateValidateNew = function (dtiDate, ysnRequired, strID) { var month; var day; var year; if (dtiDate === undefined) dtiDate = ''; if (!ysnRequired && (dtiDate == '' || !dtiDate)) return true; if (ysnRequired && dtiDate == '') { if (strID) this.error = strID + ' is required'; else this.error = ' is required'; this.errorNumber = 1; return false; } var dateFormat = getDateFormat().toLowerCase(); if (typeof isMobileView != 'undefined' && isMobileView) { dtiDate = this.ChangeDateFormatForMobileView(dtiDate); } if ((dateFormat == "mm/dd/yyyy") && (RegExValidate('^(1[0-2]|0?[1-9])(\/|\-)(0?[1-9]|[1-2][0-9]|3[0-1])\\2([0-9]{4}|[0-9]{2})$', dtiDate, 'i'))) { month = RegExp.$1; day = RegExp.$3; year = RegExp.$4; return this.validDateParts(month, day, year); } if ((dateFormat == "dd/mm/yyyy") && (RegExValidate('^(0?[1-9]|[1-2][0-9]|3[0-1])(\/|\-)(1[0-2]|0?[1-9])\\2([0-9]{4}|[0-9]{2})$', dtiDate, 'i'))) { month = RegExp.$3; day = RegExp.$1; year = RegExp.$4; return this.validDateParts(month, day, year); } if (strID) this.error = strID + ' is not a valid date format.\nPlease use ' + dateFormat.toUpperCase() + '.'; else this.error = dtiDate + '\n is an invalid date format.\nPlease use ' + dateFormat.toUpperCase() + '.'; this.errorNumber = 6; return false; } this.validDateParts = function (month, day, year) { if (year.length == 2 && this.ysnCent == true) { if (strID) this.error = strID + ' requires a four digit year'; else this.error = 'Please use a four digit year'; return false; } if (year.length == 4 && (year > 3000 || year < 1753)) { this.error = dtiDate + '\nis outside of the date range.'; this.errorNumber = 2; return false; } if (day == 31 && (month == 4 || month == 6 || month == 9 || month == 11)) { this.error = 'This month doesn\'t have 31 days'; this.errorNumber = 3; return false; } if (day >= 30 && month == 2) { this.error = 'February doesn\'t have ' + day + ' days'; this.errorNumber = 4; return false; } if (month == 2 && day == 29 && !(year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))) { this.error = 'This is not a leap year\nFebruary doesn\'t have 29 days.'; this.errorNumber = 5; return false; } return true; } this.dateOrderValidateNew = function () { //If sending in US format run dateValidateNew first becuase it expects dates in daybeforemonth format if (this.datesAlreadyValidated || (this.dateValidateNew(dtiStartDate, this.ysnStartDateRequired, this.strStartDateID) && this.dateValidateNew(dtiEndDate, this.ysnEndDateRequired, this.strEndDateID))) { if (this.ysnRequireStartDateIfEndSpecified && !dtiStartDate && dtiEndDate) { this.error = 'A Start Date must be specified if an End Date was entered.' this.errorNumber = 9; return false; } if (!dtiStartDate || !dtiEndDate || dtiEndDate == "NaN/NaN/NaN" || dtiStartDate == "NaN/NaN/NaN") return true; else { //Expects dates in US format var StartDate = new Date(dtiStartDate); var EndDate = new Date(dtiEndDate); } if (StartDate.getTime() < EndDate.getTime()) return true; else if (StartDate.getTime() == EndDate.getTime() && this.ysnAllowEqualDates == true) { this.ysnDatesAreEqual = true; return true; } else { this.error = 'The End Date must be after the Start Date.'; this.errorNumber = 7; return false; } } else return false; } this.getStandardDate = function (dateText) { $.ajax({ url: '/Utility/GetDate?dateText=' + dateText, async: false, type: 'GET', dataType: 'json', success: function (data) { dateText = data.date; }, error: function (jqXHR, textStatus, errorThrown) { } }); return dateText; } this.smallDateTimeMaxValueValidate = function () { var StartDate = new Date(dtiStartDate); var EndDate = new Date(dtiEndDate); var MaxDate = new Date('05/06/2079 23:59:59'); var result = true; if (StartDate <= MaxDate && EndDate <= MaxDate) { result = true; } else if (StartDate > MaxDate) { this.error = "The Start Date must be less than '5/6/2079'."; this.errorNumber = 2; result = false; } else if (EndDate > MaxDate) { this.error = "The End Date must be less than '5/6/2079'."; this.errorNumber = 3; result = false; } return result; } this.format = function (format, date) { if (!date) date = new Date(); var day = date.getDate(); var month = date.getMonth() + 1; var year = date.getFullYear(); return format.toLowerCase().replace(/dd/g, day).replace(/mm/g, month).replace(/y{1,4}/g, year) } this.timeValidate = function (ditTime, ysnRequired, strID) { if (!ysnRequired && ditTime == '') return true; else if (ysnRequired && ditTime == '') { if (strID) this.error = strID + ' is required'; else this.error = 'Time is required'; this.errorNumber = 1; return false; } else if (RegExValidate('^(1[0-2]|0?[1-9]):([0-5]?[0-9])(:([0-5][0-9]))?$', ditTime, 'i')) return true; else { if (strID) this.error = strID + ' is not a valid time format. Please use HH:MM.'; else this.error = ' is not a valid time format. Please use HH:MM.'; this.errorNumber = 8; return false; } } this.timeValidate24Hour = function (ditTime, ysnRequired, strID) { if (!ysnRequired && ditTime == '') return true; else if (ysnRequired && ditTime == '') { if (strID) this.error = strID + ' is required'; else this.error = 'Time is required'; this.errorNumber = 1; return false; } else if (RegExValidate('^([01]?[0-9]|2[0-3]):([0-5]?[0-9])(:([0-5][0-9]))?$', ditTime, 'i')) return true; else { if (strID) this.error = strID + ' is not valid.'; else this.error = ' is not valid.'; this.errorNumber = 8; return false; } } this.timeOrderValidate = function () { if (!this.ysnAllowTimeOnly && ((!dtiStartDate && this.dtiStartTime) || (!dtiEndDate && this.dtiEndTime))) { this.error = 'You only submited a time.\nPlease provide a day as well.'; this.errorNumber = 10; this.startDateBlank = (!dtiStartDate && this.dtiStartTime); this.endDateBlank = (!dtiEndDate && this.dtiEndTime); return false; } if (this.timesAlreadyValidated || (this.timeValidate(this.dtiStartTime, this.ysnStartTimeRequired, this.strStartTimeID) && this.timeValidate(this.dtiEndTime, this.ysnEndTimeRequired, this.strEndTimeID))) { if (!this.ysnDatesAreEqual) return true; if (!this.dtiStartTime && !this.ysnStartTimeRequired) return true; if (!this.dtiEndTime && !this.ysnEndTimeRequired) return true; var dtiStartTime = this.convertTo24Hour(this.dtiStartTime, this.strStartAMPM, dtiStartDate); var dtiEndTime = this.convertTo24Hour(this.dtiEndTime, this.strEndAMPM, dtiEndDate); if (dtiStartTime.getTime() < dtiEndTime.getTime()) return true; else if (dtiStartTime.getTime() == dtiEndTime.getTime() && this.ysnAllowEqualTimes == true) { this.ysnTimesAreEqual = true; return true; } else { this.error = 'The End Time must be after the Start Time if the Start and End Dates are the same.' this.errorNumber = 9; return false; } } return false; } this.convertTo24Hour = function (time, AMPM, date) { if (!date) date = "1/1/70"; var dtTime = time.indexOf(AMPM) == -1 ? new Date(date + " " + time + " " + AMPM) : new Date(date + " " + time); if (dtTime == 'Invalid Date') { var dayBeforeMonthOn = getDateFormat().toLocaleLowerCase() == "dd/mm/yyyy" ? true : false; if (dayBeforeMonthOn) { var dateArray = date.split('/'); date = dateArray[1] + '/' + dateArray[0] + '/' + dateArray[2]; dtTime = time.indexOf(AMPM) == -1 ? new Date(date + " " + time + " " + AMPM) : new Date(date + " " + time); } } return dtTime; } } // Helper function for inputAlert(). function inputEmailValidate(obj, required) { if (required == null || required == false) return (obj.value == '' || emailValidate(obj.value) == true) else return (obj.value != '' && emailValidate(obj.value) == true) } // Note: This function does not match standard validation behavior! Users are supposed to see // a summary of problems with their inputs and not be alerted multiple times! // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // Calls another validation routine, and determines success/failure on result of call (true/false). // Displays error message on validation failure. Returns result of call. function inputAlert(call, obj, required, errorMessage) { call = eval('input' + call + 'Validate'); if (call(obj, required) == false) { if (errorMessage == null) errorMessage = 'Please enter a single valid email address without any extra body, subject, etc. information (ie user@domain.com).'; obj.setAttribute('autocomplete', 'off'); obj.focus(); obj.setAttribute('autocomplete', 'on'); alert(errorMessage); return false; } else return true; } // Takes array of required fields and checks whether they have a value or not // If empty fields found, formats a javascript alert to inform the user and returns true function checkRequiredFieldsEmpty(requiredFieldList) { var badList = new Array(); for (var i = 0, len = requiredFieldList.length; i < len; i++) { var $this = requiredFieldList[i]; var $fieldId = $('#' + $this); if (($fieldId.length > 0) && (FieldIsEmpty($fieldId.val()))) { var $label = $('label[for=' + $this + ']'); if ($label.length > 0) badList.push($label.text().trim()); else badList.push($this); } } if (badList.length > 0) { var msg = badList.join(" cannot be blank.\r\n"); msg += " cannot be blank."; msg = msg.replace(/\*/g, ''); alert(msg); return true; } return false; } // End Form Validation functions. // Begin AJAX functions: // See http://blogs.msdn.com/xmlteam/archive/2006/10/23/using-the-right-version-of-msxml-in-internet-explorer.aspx // If you are curious why the XMLHTTP versions specified are and why others are not. function makeErrorRequest(url, status) { var http_error_request = false; var origin = location.pathname; if (window.XMLHttpRequest) { // Mozilla, Safari, IE7 http_error_request = new XMLHttpRequest(); if (http_error_request.overrideMimeType) http_error_request.overrideMimeType("text/html"); } else if (window.ActiveXObject) { // IE6 try { http_error_request = new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e) { try { http_error_request = new ActiveXObject("Msxml2.XMLHTTP"); // Version 3.0 } catch (e) { } } } http_error_request.onreadystatechange = function () { } http_error_request.open("GET", "/AJAX-error.ashx?url=" + escape(url) + "&status=" + status + "&origin=" + escape(origin), true); http_error_request.send(null); //if(status == 403) //window.location = '/admin/AccessDenied.aspx?fromURL=' + window.location.pathname.substr(7); } // Makes AJAX request, additionally supporting POST data (makeHttpRequest doesn't). // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // Note: It's YOUR responsibility as a developer to make sure data // placed in formData is formatted as it should be. Form data should be // in Query String format with the value portions escape()'d. -KB function makeHttpRequestEx(URL, formData, callbackFunc, ysnReturnXML) { URL = window.location.origin + URL; if (formData != null) { $.ajax({ type: 'POST', url: URL, data: formData, success: callbackFunc }); } else { $.ajax({ type: 'GET', url: URL, success: callbackFunc }); } } // NOTE: Do not use this in new code, use $.ajax() instead. // Makes AJAX request. Used in n-menu code. function makeHttpRequest(url, callback_function, return_xml) { var http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari, IE7 http_request = new XMLHttpRequest(); if (http_request.overrideMimeType && !return_xml) http_request.overrideMimeType("text/html"); } else if (window.ActiveXObject) { // IE6 try { http_request = new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e) { try { http_request = new ActiveXObject("MSxml2.XMLHTTP"); // Version 3 } catch (e) { } } } if (!http_request) { alert("Unfortunately, your browser doesn't support this feature."); return false; } http_request.onreadystatechange = function () { if (http_request.readyState == 4) { --ajax_call_counter; //try { if (http_request.status == 200) { if (return_xml) eval(callback_function + ', http_request.responseXML)'); else { if (http_request.responseText.search(/
/i) < 0) eval(callback_function + ', http_request.responseText)'); else makeErrorRequest(url, http_request.status); } } else if (http_request.status) makeErrorRequest(url, http_request.status); //} catch (e) { // If this happens, there is no way to notify anyone // of the previous error. It might be their connection died, // or failed in some other way. //alert('An error occured while reporting the previous error.'); //var USER_EXPLAIN_ERR_EN = '\n\nTechnical Details:\n' + e.name + ' - '; // IE 6 & 7: No Line Number, No Filename //if (document.all && !window.opera) { // alert(USER_EXPLAIN_ERR_EN + e.description + ' (line unavailable, code: ' + e.number + ')' + '\n\nJavaScript Callback:\n' + callback_function + ', );'); //} // Opera and Firefox 1.5+: Line Number + Filename //else { // alert(USER_EXPLAIN_ERR_EN + e.message + '\n' + e.fileName + ', line ' + e.lineNumber + '\n\nJavaScript Callback:\n' + callback_function + ', );'); //} //} http_request = null; } } http_request.open("GET", url, true); http_request.send(null); } // Invoked on window.onunload for pages using synchronous AHAH. // Catches switches to different pages and window closes. // -=-=-=-=- // Note: It is synchronous instead of asynchronous to ensure // the operation completes before a close. This is SHAH. // function destroyAHAH(e) { var http_request; if (window.XMLHttpRequest) { // Mozilla, Safari, IE7 http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType("text/html"); } } else if (window.ActiveXObject) { // IE6 try { http_request = new ActiveXObject("MSXML2.XMLHTTP.6.0"); } catch (e) { try { http_request = new ActiveXObject("MSXML2.XMLHTTP"); // Version 3 } catch (e) { } } } if (!http_request) return; http_request.open("GET", 'http://' + window.location.host + '/AJAX-NMenuLoader.ashx?clearCache=1', false); http_request.send(null); //alert(http_request.status + ': if 200, the session cache object was term\'d where needed be.'); } // End AJAX functions. // // slideShow class // vars: // slideShowId constructor param for the id of the image that will have the Slide Show // slideShowLink constructor param for the id of the link that will be around the image that has Slide Show, use '' for no link // slideShowSpeed optional constructor param for the speed of the slide show, default = 5000 // filterName optional constructor param for the IE filter, default = blendTrans // filterAttr1 optional constructor param for the IE filter, default = duration=3 // filterAttr2 optional constructor param for the IE filter // filterAttr3 optional constructor param for the IE filter // j counter for the object // picArr array of pictures // altArr array of alt text // linkArr array of links // methods: // addImage(n, img, alt, caption, lngCaption, link) add an image with alt text and a link, n specifies which postion in the arrays // runSlideShow() continually calls nextSlide to run the Slide Show // nextSlide() applies the transition and advances the Slide Show image 1 spot in the arrays // mouseOver() detects and loads that image to the Main Image Display & draws border around the slected image & removed border from the Other small image icons function slideShow(slideShowId, slideShowLink, slideShowSpeed, filterName, filterAttr1, filterAttr2, filterAttr3, slideShowLinkTarget, layout, externalLink) { if (!slideShowLinkTarget || slideShowLinkTarget == null || slideShowLinkTarget == "undefined" || slideShowLinkTarget == "") slideShowLinkTarget = "_self"; if (!layout || layout == null || layout == "undefined") layout = 1; this.slideShowId = document.getElementById(slideShowId); this.picArr = new Array(); this.altArr = new Array(); this.captionArr = new Array(); this.lngCaptionArr = new Array(); this.linkArr = new Array(); this.linkTargetArr = new Array(); this.showExternalLinkPrompts = new Array(); var useStyle = false; var captionFilter = ""; var cssRule = false; var pos = 0; //Get The filter for IE.// for (i = 0; i < document.styleSheets.length; i++) { var styles = document.styleSheets[i]; do { if (styles.href && styles.href.indexOf("style.css") > -1) { if (styles.cssRules) { cssRule = styles.cssRules[pos]; } else if (styles.rules) { cssRule = styles.rules[pos]; } } if (cssRule && cssRule.selectorText != undefined && cssRule.selectorText.indexOf('slideCaption') != -1) { useStyle = true; captionFilter = cssRule.style.filter; break; } pos++; } while (cssRule && !useStyle) if (useStyle) break; } var useStyle = $('.slideCaption').attr('class') == 'slideCaption'; // If junk data causes one slideshow to fail the others should not. if (this.slideShowId == null) { this.addImage = function (n, img, alt, link, linkTarget, caption, lngCaption, externalLink) { } this.runSlideShow = function () { } this.nextSlide = function () { } this.mouseOver = function (elem, imgPath, altText) { } return; } var tmpElem = document.createElement('a'); if (slideShowLink && slideShowLink != '') { do { slideShowLink = (slideShowLink).replace("%38", "&"); } while ((slideShowLink).indexOf("%38") != -1) tmpElem.href = slideShowLink; if (slideShowLinkTarget && slideShowLinkTarget != '') tmpElem.target = slideShowLinkTarget; var ssID = this.slideShowId.id.replace("cvpSlideShowImage", ""); var capt = document.getElementById('slideCaption' + ssID); if (externalLink == "True" && $('#ShowLeavingPageForExternalLinks') == "True") { tmpElem.setAttribute("onclick", "return showExternalSiteDialog(this);"); tmpElem.onclick = function () { return showExternalSiteDialog(this); }; if (capt) { capt.children[0].setAttribute("onclick", "return showExternalSiteDialog(this);"); } } else { tmpElem.onclick = ""; if (capt) capt.children[0].removeAttribute("onclick"); } } else tmpElem.removeAttribute('href'); this.j = 1; if (slideShowSpeed == null || slideShowSpeed == '') this.slideShowSpeed = 4000; else this.slideShowSpeed = slideShowSpeed * 1000; if (filterAttr1 == null || filterAttr1 == '') filterAttr1 = 2; if (filterName == null || filterName == '' || filterName.toLowerCase() == 'blendtrans') this.filterName = 'BlendTrans(duration=' + filterAttr1; else if (filterName.toLowerCase() != 'none') this.filterName = 'progid:DXImageTransform.Microsoft.' + filterName + ', duration=' + filterAttr1; if (filterAttr2 != null && filterAttr2 != '' && filterAttr2 != 'null') this.filterName = this.filterName + ',' + filterAttr2; if (filterAttr3 != null && filterAttr3 != '' && filterAttr3 != 'null') this.filterName = this.filterName + ',' + filterAttr3; if (filterName.toLowerCase() == 'none') this.filterName = filterName; else this.filterName = this.filterName + ')'; switch (layout) { case 1: // Standard tmpElem.style.border = 'none'; tmpElem.style.background = 'transparent'; //tmpElem.style.border = 'medium none'; //tmpElem.style.background = 'transparent none repeat scroll 0% 0%'; tmpElem.id = slideShowId + '_link'; this.slideShowLink = tmpElem; this.slideShowId.parentNode.insertBefore(tmpElem, this.slideShowId); this.slideShowId.parentNode.removeChild(this.slideShowId); this.slideShowLink.appendChild(this.slideShowId); break; case 5: // StandardFiveBottom //DO NOT COPY for this case - follow 12 for a better code. //tmpElem.style.border = 'none'; //tmpElem.style.background = 'transparent'; tmpElem.style.border = 'medium none'; tmpElem.style.background = 'transparent none repeat scroll 0% 0%'; tmpElem.id = slideShowId + '_link'; this.slideShowLink = tmpElem; this.slideShowId.parentNode.insertBefore(tmpElem, this.slideShowId); //this.slideShowId.parentNode.removeChild(this.slideShowId); this.slideShowLink.appendChild(this.slideShowId); var tmpElemHTML = this.slideShowLink.innerHTML; var td = this.slideShowId.parentNode.parentNode; this.slideShowId.parentNode.parentNode.removeChild(this.slideShowId.parentNode); var newSection = document.createElement("div"); newSection.setAttribute("id", "SubSection1"); var cpSlideShowWrapper1 = document.createElement("div"); cpSlideShowWrapper1.setAttribute("id", "cpSlideShowWrapper1"); cpSlideShowWrapper1.style.padding = "5px"; cpSlideShowWrapper1.style.background = "rgb(70, 43, 16) none repeat scroll 0% 0%"; cpSlideShowWrapper1.style.position = "relative"; cpSlideShowWrapper1.style.width = "416px"; //cpSlideShowWrapper1.style.-moz-background-clip = "border"; //cpSlideShowWrapper1.style.-moz-background-origin = "padding"; //cpSlideShowWrapper1.style.-moz-background-inline-policy = "continuous"; cpSlideShowWrapper1.style.height = "254px"; var imageHead = document.createElement("div"); imageHead.style.padding = "4px"; imageHead.style.background = "rgb(241, 239, 234) none repeat scroll 0% 0%"; imageHead.style.align = "left"; imageHead.style.width = "406px"; //-moz-background-clip: border; //-moz-background-origin: padding; //-moz-background-inline-policy: continuous; imageHead.style.float = "left"; imageHead.style.height = "198px"; imageHead.style.align = "left"; imageHead.innerHTML = tmpElemHTML; cpSlideShowWrapper1.appendChild(imageHead); var imageRows = document.createElement("div"); imageRows.setAttribute("id", "imageRows"); imageRows.style.position = "relative"; imageRows.style.align = "left"; imageRows.style.margin = "5px 0px 0px 0px"; imageRows.style.width = "416px"; imageRows.style.float = "left"; imageRows.style.height = "42px"; imageRows.style.clear = "both"; cpSlideShowWrapper1.appendChild(imageRows); newSection.appendChild(cpSlideShowWrapper1); td.appendChild(newSection); this.slideShowId = document.getElementById(slideShowId); if (isie) { this.slideShowId.style.height = "100%"; this.slideShowId.style.width = "100%"; } else { this.slideShowId.setAttribute("height", "100%"); this.slideShowId.setAttribute("width", "100%"); } break; case 12: //This case would handle the new 12 image slideshow without Rotation. & with mouseover tmpElem.id = slideShowId + '_link'; this.slideShowLink = tmpElem; this.slideShowId.parentNode.insertBefore(tmpElem, this.slideShowId); this.slideShowLink.appendChild(this.slideShowId); var tmpElemHTML = this.slideShowLink.innerHTML; var td = this.slideShowId.parentNode.parentNode; // If the slideshow is in the middle of the page's content, we // have to keep track of its next sibling, so we put the 12-thumbnail // content in the new location. var nextSibling = this.slideShowLink.nextSibling; this.slideShowId.parentNode.parentNode.removeChild(this.slideShowId.parentNode); var newSection = document.createElement("div"); newSection.setAttribute("id", "SubSectionFor" + slideShowId); var cpSlideShowWrapper1 = document.createElement("div"); cpSlideShowWrapper1.setAttribute("id", "cpSlideShowWrapper" + slideShowId); //Remove these in-line style Height and Width after CSS changes cpSlideShowWrapper1.style.width = "441px"; cpSlideShowWrapper1.style.height = "190px"; cpSlideShowWrapper1.style.padding = "5px"; cpSlideShowWrapper1.style.position = "relative"; cpSlideShowWrapper1.style.clear = "both"; var imageHead = document.createElement("div"); imageHead.setAttribute("id", "imageHead"); //Remove these in-line style Height and Width after CSS changes imageHead.style.width = "201px"; //185 px imageHead.style.height = "168px"; imageHead.style.padding = "8px"; imageHead.style.align = "left"; imageHead.style.styleFloat = "left"; imageHead.style.cssFloat = "left"; imageHead.innerHTML = tmpElemHTML; cpSlideShowWrapper1.appendChild(imageHead); var imageRowsHeader = document.createElement("div"); imageRowsHeader.setAttribute("id", "imageRowsHeader"); imageRowsHeader.style.position = "relative"; imageRowsHeader.style.align = "right"; imageRowsHeader.style.styleFloat = "right"; imageRowsHeader.style.cssFloat = "right"; imageRowsHeader.style.width = "216px"; //247px imageRowsHeader.style.height = "18px"; //Image Link var slideImageHeaderLink = document.createElement("a"); slideImageHeaderLink.setAttribute("href", "/gallery.aspx"); //Image Header var slideImageHeader = document.createElement("img"); slideImageHeader.setAttribute("id", slideShowId + "Header"); slideImageHeader.setAttribute("src", "/images/pages/ImageHeader.jpg"); slideImageHeader.setAttribute("target", "_blank"); slideImageHeader.style.width = "198px"; //247px slideImageHeader.style.height = "18px"; slideImageHeader.setAttribute("border", "0"); slideImageHeaderLink.appendChild(slideImageHeader); imageRowsHeader.appendChild(slideImageHeaderLink); cpSlideShowWrapper1.appendChild(imageRowsHeader); var imageRows = document.createElement("div"); imageRows.setAttribute("id", "imageRows"); imageRows.style.position = "relative"; imageRows.style.align = "right"; //imageRows.style.margin = "28px 0px 0px 0px"; imageRows.style.styleFloat = "right"; imageRows.style.cssFloat = "right"; imageRows.style.width = "216px"; //247px imageRows.style.height = "145px"; imageRows.style.padding = "4px"; cpSlideShowWrapper1.appendChild(imageRows); newSection.appendChild(cpSlideShowWrapper1); var scriptTag = td.firstChild; while (scriptTag) { if (scriptTag.nodeType == 1 && scriptTag.tagName == 'SCRIPT') break; scriptTag = scriptTag.nextSibling; } if (nextSibling != null) td.insertBefore(newSection, nextSibling); else td.insertBefore(newSection, scriptTag); this.slideShowId = document.getElementById(slideShowId); //Remove these in-line style Height and Width after CSS changes if (isie) { this.slideShowId.style.height = "100%"; this.slideShowId.style.width = "100%"; } else { this.slideShowId.setAttribute("height", "100%"); this.slideShowId.setAttribute("width", "100%"); } break; default: break; } this.addImage = function (n, img, alt, link, linkTarget, caption, lngCaption, isExternal) { if (layout == 12 && n > 11) return; // Allow only upto 12 thumbnail images for Standard 12 Bottom layout if (!linkTarget || linkTarget == null || linkTarget == "undefined" || linkTarget == "") linkTarget = "_self"; this.picArr[n] = new Image(); this.picArr[n].src = img; this.showExternalLinkPrompts[n] = (isExternal == "True" && $('#ShowLeavingPageForExternalLinks').val() == "True"); do { alt = (alt).replace("%39", "'"); } while ((alt).indexOf("%39") != -1) this.altArr[n] = alt; this.captionArr[n] = caption; this.lngCaptionArr[n] = lngCaption; do { link = (link).replace("%38", "&"); } while ((link).indexOf("%38") != -1) this.linkArr[n] = link; this.linkTargetArr[n] = linkTarget; switch (layout) { case 5: var slideImage = document.createElement("img"); slideImage.setAttribute("id", slideShowId + n); if (isie) { slideImage.style.height = "40"; slideImage.style.width = "40"; } else { slideImage.setAttribute("height", "40"); slideImage.setAttribute("width", "40"); } if (n == 0) slideImage.setAttribute("border", "1"); else slideImage.setAttribute("border", "0"); slideImage.style.borderStyle = "solid"; slideImage.style.borderColor = "#FFFF00"; slideImage.setAttribute("src", img); slideImage.setAttribute("alt", alt); slideImage.setAttribute("link", link); slideImage.setAttribute("target", linkTarget); slideImage.setAttribute("class", "photoGalleryImgArray"); if (n == 0) slideImage.style.margin = "0px 0px 0px 0px"; else slideImage.style.margin = "0px 0px 0px 6px"; this.imageRows = document.getElementById("imageRows"); this.imageRows.appendChild(slideImage); break; case 12: //This case would handle the new 12 image slideshow without Rotation. & with mouseover var slideImage = document.createElement("img"); slideImage.setAttribute("id", slideShowId + n); //Remove these in-line style 'Padding' after CSS changes if (n == 0) { if (isie) slideImage.style.cssText = "margin:6px 6px; border: 2px solid transparent; background-color: lightblue; padding: 3px; height:30px; width:30px;"; else slideImage.setAttribute('style', 'margin:6px 6px; border: 2px solid transparent; background-color: lightblue; padding: 3px; height:30px; width:30px;'); } else { if (isie) slideImage.style.cssText = "margin:6px 6px; border: 2px solid transparent ; background-color: white; padding: 3px; height:30px; width:30px;"; else slideImage.setAttribute('style', 'margin:6px 6px; border: 2px solid transparent ; background-color: white; padding: 3px;height:30px; width:30px;'); } slideImage.setAttribute("src", img); slideImage.setAttribute("alt", alt); slideImage.setAttribute("link", link); slideImage.setAttribute("target", linkTarget); slideImage.setAttribute("class", "photoGalleryImgArray"); var siObj = eval(slideShowId.replace("Image", "")); slideImage.onmouseover = function () { siObj.mouseOver(slideShowId + n, img, alt); }; this.imageRows = document.getElementById("imageRows"); this.imageRows.appendChild(slideImage); break; default: break; } } this.mouseOver = function (elem, imgPath, altText) { //Set the Main Display image to mouseOver Image this.slideShowId.setAttribute("src", imgPath); this.slideShowId.alt = altText; //Loop through all other images and set the border to 1 this.ImageRows = document.getElementById("imageRows"); this.ImageRows.Images = this.ImageRows.getElementsByTagName("img"); var j = 0; while (j < this.ImageRows.Images.length) { if (this.ImageRows.Images[j] == document.getElementById(elem)) { if (isie) this.ImageRows.Images[j].style.cssText = "margin:6px 6px; border: 2px solid transparent; background-color: lightblue; padding: 3px; height:30px; width:30px;"; else this.ImageRows.Images[j].setAttribute('style', 'margin:6px 6px; border: 2px solid transparent; background-color: lightblue; padding: 3px;height:30px; width:30px;'); } else { if (isie) this.ImageRows.Images[j].style.cssText = "margin:6px 6px; border: 2px solid transparent; background-color:white; padding: 3px;height:30px; width:30px;"; else this.ImageRows.Images[j].setAttribute('style', 'margin:6px 6px; border: 2px solid transparent; background-color:white; padding: 3px;height:30px; width:30px;'); } j++; } } this.runSlideShow = function () { switch (layout) { case 12: case 5: //Do nothing, do not run a slideshow break; default: if (this.picArr.length > 1) { var self = this; // reference to get around context loss of this during setTimeout() this.timeoutId = setTimeout(function () { self.nextSlide(); self.runSlideShow(); }, this.slideShowSpeed); } break; } } this.nextSlide = function () { var ssID = this.slideShowId.id.replace("cvpSlideShowImage", ""); var capt = document.getElementById('slideCaption' + ssID); var lngCapt = document.getElementById('slideCaptionLng' + ssID); if (document.all && this.slideShowId.filters && this.slideShowId.filters.length > 0 && this.filterName.toLowerCase() != 'none') { this.slideShowId.style.filter = this.filterName; this.slideShowId.filters.item(0).apply(); if (capt) { capt.style.filter = captionFilter + " " + this.filterName; capt.filters.item(capt.filters.length - 1).apply(); if (lngCapt) { lngCapt.style.filter = captionFilter + " " + this.filterName; lngCapt.filters.item(lngCapt.filters.length - 1).apply(); } } } this.slideShowId.setAttribute('src', this.picArr[this.j].src); this.slideShowId.setAttribute('alt', this.altArr[this.j]); this.slideShowId.setAttribute('title', this.altArr[this.j]); var height = ''; var marginTop = useStyle ? "-61px" : "0px"; var paddingTop = "3px"; if (this.captionArr[this.j] == "") { height = "0px"; } else if (this.lngCaptionArr[this.j] == "") { height = "31px"; marginTop = useStyle ? "-35px" : "0px"; paddingTop = useStyle ? "-4px" : "0px"; } else height = useStyle ? "55px" : ""; if (capt) { capt.innerHTML = useStyle ? this.captionArr[this.j] : "" + this.captionArr[this.j] + ""; capt.style.marginTop = marginTop; capt.style.height = height; capt.style.paddingLeft = useStyle ? "15px" : "5px"; capt.style.paddingRight = useStyle ? "10px" : "5px"; capt.style.paddingTop = paddingTop; if (height != "0px" && lngCapt != null) { lngCapt.innerHTML = this.lngCaptionArr[this.j]; lngCapt.style.marginTop = useStyle ? "-38px" : "0px"; lngCapt.style.paddingLeft = useStyle ? "15px" : "5px"; lngCapt.style.paddingRight = useStyle ? "10px" : "5px"; lngCapt.style.paddingTop = paddingTop; lngCapt.style.overflow = 'hidden'; } else if (lngCapt != null) { lngCapt.style.marginTop = "0px"; lngCapt.innerHTML = ""; lngCapt.height = "0px"; } } var slideLink = this.linkArr[this.j] var slideLinkTarget = this.linkTargetArr[this.j] if (slideLink && slideLink != '') { tmpElem.href = slideLink; if (this.showExternalLinkPrompts[this.j] == true) { this.slideShowLink.setAttribute("onclick", "return showExternalSiteDialog(this);"); tmpElem.onclick = function () { return showExternalSiteDialog(this); }; } else { this.slideShowLink.removeAttribute("onclick"); tmpElem.onclick = ""; } if (capt) if (this.showExternalLinkPrompts[this.j] == true) { capt.innerHTML = useStyle ? "" + this.captionArr[this.j] + "" : "" + this.captionArr[this.j] + ""; } else { capt.innerHTML = useStyle ? "" + this.captionArr[this.j] + "" : "" + this.captionArr[this.j] + ""; } if (slideLinkTarget && slideLinkTarget != '') tmpElem.target = slideLinkTarget; } else { tmpElem.removeAttribute('href'); if (capt) capt.removeAttribute('href'); } if (document.all && this.slideShowId.filters && this.slideShowId.filters.length > 0 && filterName.toLowerCase() != 'none') { this.slideShowId.filters.item(0).play(); if (capt) { capt.filters.item(capt.filters.length - 1).play(); lngCapt.filters.item(lngCapt.filters.length - 1).play(); } } var slideImageId, slideImage; if (layout == 5) { // Set the selected image's border if (this.j == 0) slideImageId = slideShowId + (this.picArr.length - 1); else slideImageId = slideShowId + (this.j - 1); slideImage = document.getElementById(slideImageId); slideImage.setAttribute("border", "0"); slideImageId = slideShowId + this.j; slideImage = document.getElementById(slideImageId); slideImage.setAttribute("border", "1"); } this.j++; if (this.j >= this.picArr.length) this.j = 0; } } function validateMultiFileUpload(el, useWhiteList) { try { const fileNames = [...el.files].map(file => file.name); const xhr = new XMLHttpRequest(); xhr.open('POST', '/Utility/AreValidFileNames', false); xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); const data = new FormData(); fileNames.forEach(fileName => { data.append("paths[]", fileName); }) xhr.send(data); const response = JSON.parse(xhr.responseText); const isValid = response.every(x => x === true); for (const fileName of fileNames) { if (!isAllowedFileExtension(fileName, useWhiteList) || !isValid) { return false; } } return true; } catch (e) { console.error(e); return false; } } //el is the pointer to the input type="file" //example usage: function validateFileUpload(el, useWhiteList) { var val = el.value; var cbox = document.getElementById(el.name + "_pdf"); if (cbox) { cbox.disabled = true; cbox.checked = false; } if (val.length > 0) { var isValid = false; if (val.indexOf(':\\fakepath\\') > -1) val = val.substring(12); $.ajax({ async: false, type: "POST", url: '/Utility/IsValidFileName', data: { path: val }, dataType: "json", success: function (response) { if (typeof (response.d) != "undefined") { response = response.d; } if (response.result == "True") isValid = true; } }); if (!isAllowedFileExtension(val, useWhiteList) || !isValid) { alert("The file you are trying to upload is not an allowed file type or has an invalid file name. These are the accepted characters: A-z 0-9 ~ ! ( ) - + = [ ] { } , . _"); var tempElem = el.cloneNode(false); tempElem.value = ""; el.parentNode.replaceChild(tempElem, el); el.focus(); return false; } if (cbox) { cbox.disabled = !isAllowedFileExtensionPDF(val); if (cbox.disabled) cbox.checked = false; } } return true; } // Recommended you use isAllowedFileExtensionWhiteList() instead. Do not use this method // where useWhiteList is false or null, that is not secure (uses blacklist rather than whitelist). function isAllowedFileExtension(filename, useWhiteList) { if (filename + '' == '') return true; // Cut out the path portion (why not use lastIndexOf()?). while (filename.indexOf("/", 0) > 0) filename = filename.substr(filename.indexOf("/", 0) + 1, filename.length - filename.indexOf("/", 0)) while (filename.indexOf("\\", 0) > 0) filename = filename.substr(filename.indexOf("\\", 0) + 1, filename.length - filename.indexOf("\\", 0)) var lastPeriod = filename.indexOf(".", 0); var i = lastPeriod; while (lastPeriod > 0) { i = lastPeriod; lastPeriod = filename.indexOf(".", i + 1); } var fileExtension = (i > 0 ? filename.substr(i + 1, filename.length - i) : ""); if (useWhiteList) return isAllowedFileExtensionWhiteList('.' + fileExtension) else { switch (fileExtension.toUpperCase()) { case "ASA": case "ASAX": case "ASBX": case "ASCX": case "ASP": case "ASPX": case "BAT": case "CAB": case "CF": case "CFM": case "CGI": case "COM": case "CONFIG": case "DLL": case "EXE": case "HTA": case "LHA": case "LHZ": case "MIM": case "PIF": case "PL": case "SYS": case "UUE": case "VBS": case "VXD": case "WEBINFO": case "WIZ": case "WSH": { return false; break; } default: { return true; break; } } } } // Makes sure a file being uploaded for PDF conversion is supported. // Note: Server logic should additionally chop out paths and other evil things (e.g. Windows Device Names like 'CON', 'AUX', etc). function isAllowedFileExtensionPDF(filename) { //cut out the path portion while (filename.indexOf("/", 0) > 0) filename = filename.substr(filename.indexOf("/", 0) + 1, filename.length - filename.indexOf("/", 0)) while (filename.indexOf("\\", 0) > 0) filename = filename.substr(filename.indexOf("\\", 0) + 1, filename.length - filename.indexOf("\\", 0)) var lastPeriod, i, fileExtension; lastPeriod = filename.indexOf(".", 0); i = lastPeriod; while (lastPeriod > 0) { i = lastPeriod; lastPeriod = filename.indexOf(".", i + 1); } if (i > 0) fileExtension = filename.substr(i + 1, filename.length - i).toUpperCase(); else fileExtension = ""; switch (fileExtension) { case "HTM": case "HTML": case "DOC": case "DOCX": case "XLS": case "XLSX": case "TXT": { return true; break; } default: { return false; break; } } } // returns true if it is a valid US or Canadian zip code. // supports ZIP, ZIP+4 and Canadian zip code format // * intCountryCode is a ISO 3166-1 numeric value. function isZipCode(strInput, intCountryCode) { var countryCodeRe = { 840: /^\d{5}([\-]\d{4})?$/, // USA 124: /^[ABCEGHJ-NPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][ -]?\d[ABCEGHJ-NPRSTV-Z]\d$/i, //Canada 36: /^(?:(?:[2-8]\d|9[0-7]|0?[28]|0?9(?=09))(?:\d{2}))$/ //Australia }; if (intCountryCode in countryCodeRe) { return countryCodeRe[intCountryCode].test(strInput); } return strInput.length > 0; } // returns name to assign postal/zip code. function getZipCodeName(intCountryCode) { if (intCountryCode == 840) // USA return 'Zip'; else// if (intCountryCode == 124) // Canada return 'Postal'; } function updateAddressPlaceholdersForCanadinaClients(zipElementId, stateElementId) { document.getElementById(stateElementId).setAttribute('placeholder', 'Province'); document.getElementById(stateElementId).style.width = '5em'; document.getElementById(zipElementId).setAttribute('placeholder', 'Postal Code'); } function getLowerCaseStateString() { if (intCountryCode == 124) return "province"; else// if (intCountryCode == 840) <- neutral setting (en-US). return "state"; } // Gets card type. Will return one of the following values (or an empty string for unknown/invalid cards): // * Master = M // * Visa = V // * Discover = D // * American Express = A function getCreditCardType(cardNumber) { switch (cardNumber.substr(0, 2)) { case "50": case "51": case "52": case "53": case "54": case "55": return "M"; case "65": return "D"; } switch (cardNumber.substr(0, 1)) { case "4": return "V"; } switch (cardNumber.substr(0, 4)) { case "6011": return "D"; } switch (cardNumber.substr(0, 2)) { case "34": case "37": return "A"; } // Card unknown/invalid. return ''; } // Validates credit card numbers. cardType is an optional argument. function isValidCreditCardNumber(cardNumber, cardType) { var isValid = false; var ccCheckRegExp = /[^\d ]/; isValid = !ccCheckRegExp.test(cardNumber); if (isValid) { // Get card type if not explicitly specified. if (cardType == null) cardType = getCreditCardType(cardNumber); // If unknown/unsupported/invalid card type, abort/fail. if (cardType == '') return false; var cardNumbersOnly = cardNumber.replace(/ /g, ""); var cardNumberLength = cardNumbersOnly.length; var lengthIsValid = false; var patternIsValid = false; var patternRegExp; switch (cardType) { case "V": { // visa lengthIsValid = (cardNumberLength == 13 || cardNumberLength == 16); patternRegExp = /^4/; break; } case "M": { // mastercard lengthIsValid = (cardNumberLength == 16); patternRegExp = /^5[0-5]/; break; } case "A": { // amercian express lengthIsValid = (cardNumberLength == 15); patternRegExp = /^3[4,7]/; break; } case "D": { // discover lengthIsValid = (cardNumberLength == 16); patternRegExp = /^6011/; break; } /*case "J": { // jcb lengthIsValid = (cardNumberLength == 15) || (cardNumberLength == 16); patternRegExp = /^[3,1800,2131]/; break; } case "C": { // diner's club lengthIsValid = (cardNumberLength == 14); patternRegExp = /^3[0,6,8]/; break; }*/ default: patternRegExp = /^$/; } patternIsValid = patternRegExp.test(cardNumbersOnly); isValid = patternIsValid && lengthIsValid; } if (isValid) { var numberProduct; var numberProductDigitIndex; var checkSumTotal = 0; for (digitCounter = cardNumberLength - 1; digitCounter >= 0; digitCounter--) { checkSumTotal += parseInt(cardNumbersOnly.charAt(digitCounter)); digitCounter--; numberProduct = String((cardNumbersOnly.charAt(digitCounter) * 2)); for (var productDigitCounter = 0; productDigitCounter < numberProduct.length; productDigitCounter++) checkSumTotal += parseInt(numberProduct.charAt(productDigitCounter)); } isValid = (checkSumTotal % 10 == 0); } return isValid; } // Confirms data given is legal. function isDate(varDateToCheck) { var objDate = new dateValidator(); return objDate.dateValidate(varDateToCheck, true, 'Date'); } // Confirms data given is legal. function isDateNew(varDateToCheck) { var objDate = new dateValidator(); return objDate.dateValidateNew(varDateToCheck, true, 'Date'); } // TODO: JavaScript - Remove this function. Better ways to handle this. // Date comparison function. function dateDiff(dtiDateEntered, dtiDateToday) { var date1 = new Date(); var date2 = new Date(); var diff = new Date(); // Initialize the first date var date1temp = new Date(dtiDateEntered); date1.setTime(date1temp.getTime()); // Initialize the second date var date2temp = new Date(dtiDateToday); date2.setTime(date2temp.getTime()); // sets difference date to difference of first date and second date diff.setTime(date1.getTime() - date2.getTime()); timediff = diff.getTime(); days = Math.floor(timediff / (86400000)); // 1000 * 60 * 60 * 24 timediff -= days * (86400000); return days; } // .NET JavaScript debugging function. // TO-DO: Add sections for 'add_' and 'remove_' event prefixes. function debugDisplayMembers(obj) { var getters = new Array(); var setters = new Array(); var others = new Array(); var sKey; for (var key in obj) { sKey = key + ""; if (!((sKey.length > 0) && (sKey[0] == '_'))) { switch (sKey.substr(0, 4)) { case 'get_': getters.push(key); break; case 'set_': setters.push(key); break; default: others.push(key); } } } getters.sort(); setters.sort(); others.sort(); alert(others.join(", ") + "\r\n\r\n" + getters.join(", ") + "\r\n\r\n" + setters.join(", ")); } // BEGIN PSEUDO-FORMS CODE // Do not call any of these methods directly in your application code. // Pseudo-forms are transparent, you shouldn't need to use these methods. addEvent(window, 'load', initializePseudoForms, false); // Allows IE to recognize tag "subform". You cannot legally nest // FORM tags inside FORM tags and at least Firefox pretends they're not // in the DOM period. This is problematic, so the tag was renamed. // Done for FORMS inside of FORMs trick to get around ASP.NET form limitations // for content we cannot control (User Pages, Info Advanced HTML, etc). document.createElement('subform'); // Initialize pseudo-forms. Called on window load. function initializePseudoForms() { // Make sure we're in an HTML document (not XUL). if (document.body) { var subForms = document.body.getElementsByTagName('subform'); for (var i = 0; i < subForms.length; i++) setupPseudoForm(subForms[i]); } } // Sets up pseudo-form. function setupPseudoForm(pseudoFormElement) { // Re-routes form submission elements (no javascript used/necessary). // (those being input.type=submit, button.type=submit, and input.type=image) var rerouteElement = function (input, pseudoFormElement, newTagName, newType, copyInnerHTML) { var replacement = document.createElement(newTagName); replacement.setAttribute('type', newType); var onClickDest, onClickSrc = replacement.getAttribute('onclick'); if (onClickSrc != null) replacement.removeAttribute('onclick'); cloneAttributes(input, replacement); if (onClickSrc != null) { eval("window.tmp = function(event) { " + onClick + " }"); onClickSrc = window.tmp; window.tmp = null; onClickDest = function (ev) { ev = (window.event ? window.event : ev); if (onClickSrc(ev) == false) return; pseudoFormElement._submitter = replacement; pseudoFormElement._submevent = ev; pseudoFormElement.submit(); } } else { onClickDest = function (ev) { ev = (window.event ? window.event : ev); pseudoFormElement._submitter = replacement; pseudoFormElement._submevent = ev; pseudoFormElement.submit(); } } // Return replacement routine. var fn = function () { var inputParent = input.parentNode; var inputRightAfter = input.nextSibling; var inputDisabled = input.disabled; // For Internet Explorer (it forgets). var inputHTML = (copyInnerHTML ? input.innerHTML : null); inputParent.removeChild(input); input = null; if (copyInnerHTML) replacement.innerHTML = inputHTML; inputParent.insertBefore(replacement, inputRightAfter); replacement.disabled = inputDisabled; addEvent(replacement, 'click', onClickDest, false); } return fn; } // Re-route submits (needs to be done early on). var inputs, input, inc, repls; repls = new Array(); inputs = pseudoFormElement.getElementsByTagName('input'); for (var i = 0; i < inputs.length; i++) { input = inputs[i]; switch (input.type.toLowerCase()) { case 'submit': repls.push(rerouteElement(input, pseudoFormElement, 'input', 'button', false)); break; case 'image': repls.push(rerouteElement(input, pseudoFormElement, 'img', 'image', false)); break; } } inputs = pseudoFormElement.getElementsByTagName('button'); for (var i = 0; i < inputs.length; i++) { input = inputs[i]; switch (input.type.toLowerCase()) { case 'submit': repls.push(rerouteElement(input, pseudoFormElement, 'button', 'button', true)); break; } } for (var i = 0; i < repls.length; i++) repls[i](); // Implement properties for pseudo-form. var name = pseudoFormElement.getAttribute('name'); if (name && name != '') { document[name] = pseudoFormElement; document.forms[name] = pseudoFormElement; } pseudoFormElement.method = pseudoFormElement.getAttribute('method'); if (pseudoFormElement.method == null || pseudoFormElement.method == '') pseudoFormElement.method = 'get'; pseudoFormElement.enctype = pseudoFormElement.getAttribute('enctype'); if (pseudoFormElement.enctype == null || pseudoFormElement.enctype == '') pseudoFormElement.enctype = 'application/x-www-form-urlencoded'; pseudoFormElement.target = pseudoFormElement.getAttribute('target'); pseudoFormElement.action = pseudoFormElement.getAttribute('action'); pseudoFormElement.acceptCharset = pseudoFormElement.getAttribute('accept-charset'); // Initialize. var elements = new Array(); // elements in pseudo-form (for form.elements). var simpleInputs = new Array(); // simple value inputs and textareas, no additional logic. var stateInputs = new Array(); // checkboxes and radiobuttons. var dropdowns = new Array(); // drop-downs and lists. pseudoFormElement.elements = elements; pseudoFormElement._simple = simpleInputs; pseudoFormElement._state = stateInputs; pseudoFormElement._dropdown = dropdowns; // Registers element for the pseudo-form. var registerElement = function (input) { // Add to elements array. elements.push(input); // Add as property. if (input.name != '' && input.name != null) { obj = pseudoFormElement[input.name]; if (obj == null) pseudoFormElement[input.name] = input; else if (obj instanceof Array) obj.push(input); else { var arr = new Array(); arr.push(obj); arr.push(input); pseudoFormElement[input.name] = arr; } } } // Add methods (can be overridden by form elements /w same names, just like real forms). pseudoFormElement.submit = function () { submitPseudoForm(this, false); } pseudoFormElement.reset = document.aspnetForm.reset; // HACK (we'll fix it if someone complains) // Register elements, and categorize them for form submission. inputs = pseudoFormElement.getElementsByTagName('input'); for (var i = 0; i < inputs.length; i++) { input = inputs[i]; switch (input.type.toLowerCase()) { case 'checkbox': case 'radio': stateInputs.push(input); registerElement(input); break; case 'text': case 'hidden': case 'password': simpleInputs.push(input); registerElement(input); break; default: registerElement(input); } } inputs = pseudoFormElement.getElementsByTagName('textarea'); for (var i = 0; i < inputs.length; i++) { input = inputs[i]; simpleInputs.push(input); registerElement(input); } inputs = pseudoFormElement.getElementsByTagName('select'); for (var i = 0; i < inputs.length; i++) { input = inputs[i]; dropdowns.push(input); registerElement(input); } inputs = pseudoFormElement.getElementsByTagName('button'); for (var i = 0; i < inputs.length; i++) registerElement(inputs[i]); } // Copies attributes from one element to another. Copy should occur // before destElement is added to the DOM, as some things become read-only. // ID and CLASS need to be handled specially for compatiblity reasons. // Warning: TYPE is not supported (blame IE)! function cloneAttributes(srcElement, destElement) { var attr; for (var i = 0; i < srcElement.attributes.length; i++) { attr = srcElement.attributes[i]; switch (attr.name.toLowerCase()) { case 'name': if ((attr.value + '').toLowerCase() == 'submit') destElement.setAttribute('name', 'submit_button'); else destElement.setAttribute('name', attr.value); break; case 'class': destElement.className = attr.value; break; case 'id': destElement.id = attr.value; break; case 'type': case 'form': break; default: try { destElement.setAttribute(attr.name, attr.value); } catch (e) { } } } } // Called by pseudo-form when submit() is invoked. function submitPseudoForm(pseudoFormElement, debugMode) { var inputs, input; var spawner = pseudoFormElement._submitter; var spawnerEvent = pseudoFormElement._submevent; pseudoFormElement._submitter = null; pseudoFormElement._submevent = null; // Destroy form if it already exists (possible if target not implicit/explicit "_self"). if (pseudoFormElement._form != null) document.body.removeChild(pseudoFormElement._form); pseudoFormElement._form = null; // Fire pseudo-onsubmit event (remember that just like in real forms, only fires on non-J/S submits). var onsubmit = pseudoFormElement.getAttribute('onsubmit'); if (onsubmit != null && onsubmit != '' && spawnerEvent) { eval("window.tmp = function(event) { " + onsubmit + " }"); onsubmit = window.tmp; window.tmp = null; if (onsubmit(spawnerEvent) == false) return false; } // Create actual form to forward submission to. var newForm = document.createElement('form'); pseudoFormElement._form = newForm; // Transfer some standard HTML/XHTML attributes. newForm.dir = pseudoFormElement.dir; newForm.lang = pseudoFormElement.lang; newForm.title = pseudoFormElement.title; // Setup actual form action, accept, accept-charset, encoding, method, and target. var action = pseudoFormElement.getAttribute('action'); var method = pseudoFormElement.getAttribute('method'); var target = pseudoFormElement.getAttribute('target'); var enctype = pseudoFormElement.getAttribute('enctype'); var accept = pseudoFormElement.getAttribute('accept'); var acceptCharset = pseudoFormElement.getAttribute('accept-charset'); if (action) newForm.action = action; if (method) newForm.method = method; if (target) newForm.target = target; if (enctype) newForm.enctype = enctype; if (accept) newForm.accept = accept; if (acceptCharset) newForm.acceptCharset = acceptCharset; // Method used to create hidden input copies. var newHiddenInput = function (name, value) { var ret = document.createElement('input'); ret.type = 'hidden'; ret.value = value; ret.name = name; newForm.appendChild(ret); } // Create element for spawner if one exists (submitted w/o JS, e.g. input.type=submit). if (spawner && spawner.name != null && spawner.name != '') newHiddenInput(spawner.name, spawner.value); // Forward text, textarea, hidden, and password input values. inputs = pseudoFormElement._simple; for (var i = 0; i < inputs.length; i++) { input = inputs[i]; if ((!input.disabled) && (input.style.display != 'none')) newHiddenInput(input.name, input.value); } // Forward checkbox and radio-button values. inputs = pseudoFormElement._state; for (var i = 0; i < inputs.length; i++) { input = inputs[i]; if ((!input.disabled) && (input.style.display != 'none')) { if (input.checked) newHiddenInput(input.name, input.value); } } // Forward drop-down/list selections. // Blame for text/value condition and necessity of options loop lies with IE. // 1) Specifically, IE 7 and IE 7 mode don't give the implicit value if it's left off. // 2) IE 8 should support retrieval of all values from the select.value prop, but doesn't. inputs = pseudoFormElement._dropdown; for (var i = 0; i < inputs.length; i++) { input = inputs[i]; if ((!input.disabled) && (input.style.display != 'none')) { for (var j = 0; j < input.options.length; j++) { if (input.options[j].selected) { if (input.options[j].value == '') newHiddenInput(input.name, input.options[j].text); else newHiddenInput(input.name, input.options[j].value); } } } } document.body.appendChild(newForm); if (debugMode) alert(newForm.innerHTML); newForm.submit(); } // END PSEUDO-FORMS CODE function phoneStripFormatting(value) { /// Strips formatting characters (for display purposes only) from the NANP phone number given. /// Phone number. /// Phone number with formatting cahracter removed. return (value + '').replace(/\(/g, '').replace(/\)/g, '').replace(/\s/g, '').replace(/\-/g, ''); } function phoneReformat(value, delim) { /// Reformats a number for display purposes using delimiter specified. /// The phone number. /// The delimiter used. If argument is not passed, a hyphen is used. /// Reformatted phone number. value = phoneStripFormatting(value); if (delim == null) delim = '-'; return value.substr(0, 3) + delim + value.substr(3, 3) + delim + value.substr(6) } function phoneObfuscate(value, secret, delim) { /// Reformats a number for display purposes, obfuscating the first 6 digits. /// The phone number. /// The obfuscation character or string to use in place of a digit in the number. If argument is not pased, a asterisk is used. /// The delimiter used. If argument is not passed, a hyphen is used. /// Reformatted, obfuscated phone number. value = phoneStripFormatting(value); if (secret == null) secret = '*'; if (delim == null) delim = '-'; secret = secret + secret + secret + delim; return secret + secret + value.substr(6); } function phoneValidate(value, intCountryCode) { /// Validates that phone numbers appear to adhere to the NANP format (North American Numbering Plan). /// /// Expects area code to be present, and no country code (e.g. 555-555-0123 is valid, 1-555-555-0123 is not). /// Does not validate that numbers are legal (e.g. area code 123 is invalid, area codes cannot begin with 1). /// /// Phone number. /// Whether or not number passed a basic format validation. value = phoneStripFormatting(value); if (value.length == 10) return numbersOnly.test(value); else if (value.length == 8 && intCountryCode == 36) //For Australia return numbersOnly.test(value); else return false; } //gets the cookie, if it exists function getCookieValue(cookiename) { var ck = document.cookie; var cn = cookiename + "="; var pos = ck.indexOf(cn); if (pos != -1) { var start = pos + cn.length; var end = ck.indexOf(";", start); if (end == -1) end = ck.length; var cookieValue = ck.substring(start, end); return (cookieValue); } return (null); } window['getCookieValue'] = getCookieValue; function setCookieValue(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); var expires = "expires=" + d.toUTCString(); document.cookie = cname + "=" + cvalue + "; " + expires + "; path=/"; } //Gets no of days between 2 dates provided in a string format('mm/dd/yyyy') function dayDifference(first, second) { return Math.floor((Date.parse(first) - Date.parse(second)) / 86400000); } // Returns whether or not file extension given is acceptable. // Client-side version of FileSystemSafety.IsAllowedFileExtension(). function isAllowedFileExtensionWhiteList(ext) { // Check if the URL contains the string "Admin" const allowed = window.location.pathname.toLowerCase().startsWith("/admin") ? 1 : 0; if (!window.acceptedFileExtensions) { window.acceptedFileExtensions = { '.123': 1, '.3g2': 1, '.3gp': 1, '.3gp2': 1, '.7z': allowed, '.aac': 1, '.abw': 1, '.abx': 1, '.accdb': 1, '.accde': 1, '.accdr': 1, '.accdt': 1, '.accfl': 1, '.ace': allowed, '.ade': 1, '.adp': 1, '.aeh': 1, '.ai': 1, '.aif': 1, '.aiff': 1, '.amr': 1, '.apng': 1, '.arc': allowed, '.art': 1, '.asc': 1, '.asf': 1, '.asx': 1, '.atom': 1, '.au': 1, '.avi': 1, '.awt': 1, '.azw': 1, '.azw1': 1, '.b64': 1, '.backup': 1, '.bin': 1, '.bmp': 1, '.bz': 1, '.bz2': 1, '.bzip': 1, '.bzip2': allowed, '.cab': allowed, '.cad': 1, '.caf': 1, '.cal': 1, '.cgm': 1, '.crtx': 1, '.css': 1, '.csv': 1, '.cwk': 1, '.dap': 1, '.db': 1, '.dbf': 1, '.dcr': 1, '.dds': 1, '.dex': 1, '.dib': 1, '.dif': 1, '.diz': 1, '.dmg': 1, '.doc': 1, '.docm': 1, '.docx': 1, '.dot': 1, '.dotm': 1, '.dotx': 1, '.drw': 1, '.ds_store': 1, '.dv': 1, '.dvr-ms': 1, '.dwf': 1, '.dwg': 1, '.dxf': 1, '.emf': 1, '.eml': 1, '.emlx': 1, '.emz': 1, '.eot': 1, '.eps': 1, '.fbp': 1, '.fdp': 1, '.fhtml': 1, '.file': 1, '.flac': 1, '.flc': 1, '.fli': 1, '.flp': 1, '.flv': 1, '.fm': 1, '.fm2': 1, '.fm3': 1, '.fm5': 1, '.fmp': 1, '.fnt': 1, '.fon': 1, '.fp': 1, '.fp3': 1, '.fp5': 1, '.fp7': 1, '.fphtml': 1, '.fpt': 1, '.fpweb': 1, '.fpx': 1, '.gg': 1, '.gif': 1, '.gnumeric': 1, '.gra': 1, '.gsm': 1, '.gz': allowed, '.hdmov': 1, '.hdp': 1, '.hqx': 1, '.htm': 1, '.html': 1, '.ical': 1, '.icns': 1, '.ico': 1, '.ics': 1, '.ifo': 1, '.indd': 1, '.isf': 1, '.isu': 1, '.ivs': 1, '.jbf': 1, '.jfif': 1, '.jpe': 1, '.jpeg': 1, '.jpf': 1, '.jpg': 1, '.jxr': 1, '.key': 1, '.kml': 1, '.kmz': 1, '.knt': 1, '.kth': 1, '.lhz': 1, '.lit': 1, '.log': 1, '.lrc': 1, '.lrf': 1, '.lrx': 1, '.lst': 1, '.lyr': 1, '.m4a': 1, '.m4b': 1, '.m4p': 1, '.m4r': 1, '.mdb': 1, '.mde': 1, '.mht': 1, '.mhtml': 1, '.mid': 1, '.midi': 1, '.mim': 1, '.mix': 1, '.mng': 1, '.mobi': 1, '.mod': 1, '.moi': 1, '.mov': 1, '.movie': 1, '.mp3': 1, '.mp4': 1, '.mpa': 1, '.mpc': 1, '.mpe': 1, '.mpeg': 1, '.mpg': 1, '.mpv2': 1, '.msg': 1, '.mswmm': 1, '.mxd': 1, '.numbers': 1, '.odb': 1, '.odf': 1, '.odg': 1, '.ods': 1, '.odx': 1, '.ofm': 1, '.oft': 1, '.ogg': 1, '.ogm': 1, '.ogv': 1, '.one': 1, '.onepkg': 1, '.opx': 1, '.osis': 1, '.ost': 1, '.otf': 1, '.oth': 1, '.p65': 1, '.p7b': 1, '.pages': 1, '.pbm': 1, '.pcast': 1, '.pcf': 1, '.pcm': 1, '.pct': 1, '.pcx': 1, '.pdc': 1, '.pdd': 1, '.pdf': 1, '.pdp': 1, '.pfx': 1, '.pgf': 1, '.pic': 1, '.pict': 1, '.pkg': 1, '.pmd': 1, '.pmf': 1, '.png': 1, '.pot': 1, '.pothtml': 1, '.potm': 1, '.potx': 1, '.ppam': 1, '.pps': 1, '.ppsm': 1, '.ppsx': 1, '.ppt': 1, '.ppthtml': 1, '.pptm': 1, '.pptx': 1, '.prc': 1, '.ps': 1, '.psd': 1, '.psp': 1, '.pspimage': 1, '.pst': 1, '.pub': 1, '.pubhtml': 1, '.pubmhtml': 1, '.qbb': 1, '.qcp': 1, '.qt': 1, '.qxd': 1, '.qxp': 1, '.ra': 1, '.ram': 1, '.ramm': 1, '.rar': allowed, '.raw': 1, '.rax': 1, '.rm': 1, '.rmh': 1, '.rmi': 1, '.rmm': 1, '.rmvb': 1, '.rmx': 1, '.rp': 1, '.rss': 1, '.rt': 1, '.rtf': 1, '.rts': 1, '.rv': 1, '.sbx': 1, '.sdf': 1, '.sea': 1, '.shs': 1, '.sit': 1, '.sitx': 1, '.smil': 1, '.snapfireshow': 1, '.snp': 1, '.stc': 1, '.svg': 1, '.svgz': 1, '.swf': 1, '.sxc': 1, '.sxi': 1, '.tab': 1, '.tar': allowed, '.tex': 1, '.tga': 1, '.thmx': 1, '.tif': 1, '.tiff': 1, '.tpz': 1, '.tr': 1, '.trm': 1, '.tsv': 1, '.ttf': 1, '.txt': 1, '.uue': 1, '.vcf': 1, '.vob': 1, '.vrml': 1, '.vsc': 1, '.vsd': 1, '.wab': 1, '.wav': 1, '.wax': 1, '.wbk': 1, '.wbmp': 1, '.wdp': 1, '.webarchive': 1, '.webloc': 1, '.wk1': 1, '.wk3': 1, '.wm': 1, '.wma': 1, '.wmf': 1, '.wmmp': 1, '.wmv': 1, '.wmx': 1, '.wpd': 1, '.wps': 1, '.wri': 1, '.wvx': 1, '.xbm': 1, '.xcf': 1, '.xg0': 1, '.xg1': 1, '.xg2': 1, '.xg3': 1, '.xg4': 1, '.xht': 1, '.xhtm': 1, '.xhtml': 1, '.xif': 1, '.xlam': 1, '.xlb': 1, '.xlc': 1, '.xld': 1, '.xlk': 1, '.xlm': 1, '.xls': 1, '.xlsb': 1, '.xlshtml': 1, '.xlsm': 1, '.xlsmhtml': 1, '.xlsx': 1, '.xlt': 1, '.xlthtml': 1, '.xltm': 1, '.xltx': 1, '.xlv': 1, '.xlw': 1, '.xml': 1, '.xpi': 1, '.xps': 1, '.xsf': 1, '.xsn': 1, '.xtp': 1, '.zabw': 1, '.zip': allowed, '.zipx': allowed }; } return (window.acceptedFileExtensions[(ext + '').toLowerCase()] === 1); } function handleServiceMethodError(error) { throw new Error('A server-side error occurred during the execution of an AJAX request (' + error.get_exceptionType() + ')!\r\n\r\nAdditional Information:\r\n' + error.get_message() + '\r\n\r\nStack Trace:\r\n' + error.get_stackTrace().trim()); } function toggleDisplay(elem) { elem.style.display = (elem.style.display == 'none' ? '' : 'none'); } // BEGIN Old Character Counter var APENDED_TEXT_LEN = typeof intCountryCode !== 'undefined' && intCountryCode === 840 && typeof FeatureToggles !== 'undefined' && FeatureToggles.isActive("CivicPlus.SendNotificationSmsViaCPNotify") ? 9 : 0; var MAX_MESSAGE_SIZE_SMS = 160 - APENDED_TEXT_LEN; var trackLengths = new Array(); function registerCharCounter(input, outputElemID, maxMessageSize) { var outputElem = document.getElementById(outputElemID); var id = input.id; var tracker; tracker = new Object(); tracker.oldLength = -1; tracker.outputElem = outputElem; tracker.input = input; trackLengths[id] = tracker; setInterval( 'var tracker = trackLengths[\'' + id + '\'];\r\n' + 'var newLength = (tracker.input.value + \'\').length;\r\n' + 'if (newLength != tracker.oldLength) {\r\n' + ' if (newLength > ' + maxMessageSize + ')' + ' tracker.outputElem.innerHTML = (newLength - ' + maxMessageSize + ') + " Characters Over";\r\n' + ' else\r\n' + ' tracker.outputElem.innerHTML = (' + maxMessageSize + ' - newLength) + " Characters Remaining";\r\n' + ' \r\n' + ' tracker.oldLength = newLength;\r\n' + '}\r\n', 100); } // END Old Character Counter function elemInsideOrEq(elemFirst, elemSecond) { /// Gets whether or not second element specified is inside or is equal to first element. /// First element. /// Second element. if (elemFirst == elemSecond) return true; if (elemFirst && elemSecond) { elemSecond = elemSecond.parentNode; while (elemSecond != null) { if (elemSecond == elemFirst) return true; elemSecond = elemSecond.parentNode; } } return false; } // Do not use in new code. Use jQuery with event.preventDefault(). function hookAnchorClick(anchor, fn) { /// Hooks an anchor onclick and prevents default HREF behavior. /// The DOM element to attach the event handler for. /// Function to be called when anchor is clicked. Should have sender and event argument, in that order. var clickHandler = function (event) { var sender; if (window.event) { event = window.event; sender = event.srcElement; } else sender = event.target; fn(sender, event); if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true; return false; } // HACK: MSIE/Opera onclick fails to operate correctly. if (isie || isie8 || isie7 || isie6 || (document.documentMode < 8) || window.opera) anchor.onmousedown = clickHandler; else anchor.onclick = clickHandler; } // For ClientCharacterCounter control. var registeredCounters = null; function registerCounter(assocElem, counterElem, fmtStandard, fmtOver, maxChars) { if (assocElem == null || counterElem == null || maxChars == null || fmtStandard == null || fmtOver == null) return; if (registeredCounters == null) { registeredCounters = []; setInterval(function () { for (var i = 0, l = registeredCounters.length; i < l; i++) { if (registeredCounters[i].counter && registeredCounters[i].input) { var len; if (typeof registeredCounters[i].input.value === 'undefined') len = registeredCounters[i].input.val().length; else len = registeredCounters[i].input.value.length; var prevLen = registeredCounters[i].prevLen; if (len == prevLen) continue; else { registeredCounters[i].prevLen = len; var max = registeredCounters[i].maxChars; var numToDisplay = max - len; var fmtToUse = (numToDisplay >= 0 ? registeredCounters[i].fmtStandard : registeredCounters[i].fmtOver); if (numToDisplay >= 0) registeredCounters[i].counter.className = 'counterUnderLimit'; else registeredCounters[i].counter.className = 'counterOverLimit'; numToDisplay = Math.abs(numToDisplay); registeredCounters[i].counter.innerHTML = fmtToUse .replace(/\{0\}/g, numToDisplay) .replace(/\{1\}/g, (numToDisplay == 1 ? '' : 's')); } } } }, 100); } registeredCounters.push({ "fmtStandard": fmtStandard, "fmtOver": fmtOver, "counter": counterElem, "input": assocElem, "prevLen": -1, "maxChars": maxChars }); } // Detects if nextElementSibling/previousElementSibling are present. function detectElementSiblingSupport() { var p = document.createElement('div'); var c1 = document.createElement('div'); var c2 = document.createElement('div'); p.appendChild(c1); p.appendChild(c2); return (c1.nextElementSibling != null); } // Gets next sibling element. Version for browsers missing nextElementSibling DOM property. function nextElementSibling(elem) { elem = elem.nextSibling; while (elem != null) { if (elem.nodeType == 1) return elem; elem = elem.nextSibling; } return null; } // Gets previous sibling element. Version for browsers missing previousElementSibling DOM property. function previousElementSibling(elem) { elem = elem.previousSibling; while (elem != null) { if (elem.nodeType == 1) return elem; elem = elem.previousSibling; } return null; } // Gets first child element. Version for browsers missing firstElementChild DOM property. function firstElementChild(elem) { elem = elem.firstChild; while (elem != null) { if (elem.nodeType == 1) return elem; elem = elem.nextSibling; } return null; } if (detectElementSiblingSupport()) { // If browsers support built-in DOM properties, just use those. nextElementSibling = function (elem) { return elem.nextElementSibling; } previousElementSibling = function (elem) { return elem.previousElementSibling; } firstElementChild = function (elem) { return elem.firstElementChild; } } function haltEvent(event, windowEvent) { if (windowEvent & !window.opera) windowEvent.cancelBubble(); else { if (event.stopPropagation) event.stopPropagation(); if (event.preventDefault) event.preventDefault(); } } // Gets absolute left offset. function absoluteOffsetLeft(oElem) { var oLeft = 0; while (oElem != null) { oLeft += oElem.offsetLeft; oElem = oElem.offsetParent; } return oLeft; } function imposeMaxLength(e, Object, MaxLen) { //Truncate to maximum length if (Object.value.length > MaxLen) Object.value = Object.value.substring(0, MaxLen); //ALLOW: BACKSPACE DELETE LEFT ARROW UP ARROW RIGHT ARROW DOWN ARROW if ((e.keyCode == '8') || (e.keyCode == '46') || (e.keyCode == '37') || (e.keyCode == '38') || (e.keyCode == '39') || (e.keyCode == '40')) return true; return (Object.value.length <= MaxLen); } function checkURL(val, showAlert) { val = TrimString(val); if (val != '' && (val.substr(0, 7) != 'http://' && val.substr(0, 8) != 'https://' && val.substr(0, 6) != 'ftp://' && val.substr(0, 1) != '/')) { if (arguments.length == 1 || showAlert) alert('All URLs must begin with http:// or https:// or ftp://.\nAll internal links must start with a /.'); return false; } return true; } function toSQLSafe(formvar) { var s = String(formvar); s = (s.replace(/'/gi, "'")).replace(/"/gi, """); return s; } function cancelFE(needsConfirm) { if (needsConfirm) { if (!confirm("You will discard any unsaved changes. Do you want to proceed?")) return; } window.parent.closeModalDialog('editItemBehavior'); return false; } function getThumbNailPath(path, width, height) { var lastSlashPos = path.lastIndexOf('/'); var filename = path.substr(lastSlashPos + 1); var directory = path.substr(0, lastSlashPos); var lastDotPos = filename.lastIndexOf('.'); var filenameWithOutExtension = filename.substr(0, lastDotPos) var fileExtension = filename.substr(lastDotPos) return directory + "/ThumbNails/" + filenameWithOutExtension + "_" + width + "x" + height + "_thumb" + fileExtension; } function measureHtml(html, fontStyle) { var tmp = document.createElement('span'); tmp.style.display = 'inline'; tmp.style.position = 'absolute'; tmp.style.top = '-1000px'; tmp.style.left = '-1000px'; tmp.style.font = fontStyle; tmp.innerHTML = html; document.body.appendChild(tmp); var retVal = { width: tmp.clientWidth, height: tmp.clientHeight }; document.body.removeChild(tmp); return retVal; } function fileValidateError(errorType) { if (errorType == 1) alert("A file you tried to upload was not of a permitted type. Only *.jpeg, *.jpg, *.gif, *.png, *.bmp are allowed"); else alert("You have an invalid character in your filename. These are the accepted characters: a-z 0-9 ~ !( ) - + = [ ] { } , . $"); } function getNumericThousandsSeparator() { var dummy = new Number(11111111); var thousandSep = dummy.toLocaleString().replace(/1/g, ''); return (thousandSep.length > 0 ? thousandSep.charAt(0) : ','); } function getNumericDecimalSeparator() { var dummy = new Number(1.1); var thousandSep = dummy.toLocaleString().replace(/1/g, ''); return (thousandSep.length > 0 ? thousandSep.charAt(0) : '.'); } function JSSafe(txtString) { var myRegExp = new RegExp("'", "g"); return (txtString).replace(myRegExp, "\\'"); } function openReportInAppropriateWindow(url, popupWindowID, modalTitleID) { //Please use ajaxContainer.FindControl to determine the identifiers of the modal (popupWindowID, modalTitleID) //please check jobs2 jobsContent.ascx for reference document.getElementById(modalTitleID).innerHTML = 'Report This Listing as Inappropriate'; behavior = $find('editItemBehavior'); if (behavior) { var ifr = document.getElementById('liveEditDialog'); var liveEditPopupWindow = document.getElementById(popupWindowID); liveEditPopupWindow.className = "modalContainer reportInappropriate"; var url = "/common/modules/ReportInappropriate/ReportInappropriate.aspx?popupWindowID=" + popupWindowID + "&url=" + url; ifr.src = url; ifr.style.display = 'block'; behavior.show(); } } function ChangeDateFormat(elem) { if (elem.value != "") { var Error = false; var dateSplit = (elem.value).split("/"); if (dateSplit.length == 3) { if (dateSplit[0] <= 12 && dateSplit[1] <= 31) { var d = new Date(elem.value); var currentDate = new Date(); var selectedDate = d.getDate(); var selectedMonth = d.getMonth(); var SelectedYear = d.getFullYear(); if (isNaN(selectedDate)) Error = true; else if (isNaN(selectedDate)) Error = true; else if (isNaN(selectedDate)) Error = true; if (Error == false) { if (selectedDate.toString().length == 1) selectedDate = '0' + selectedDate; selectedMonth++; if (selectedMonth.toString().length == 1) selectedMonth = '0' + selectedMonth; currentYear = currentDate.getFullYear(); if (SelectedYear.toString().substr(0, 2) < 20) SelectedYear = currentYear; elem.value = selectedMonth + '/' + selectedDate + '/' + SelectedYear; } } else Error = true; } else Error = true; if (Error == true) { alert('Date should be in the format MM/DD/YYY'); elem.value = ""; } } } function ChangeDateFormatNew(elem) { return isDateNew(elem.value); } function isSilverlightInstalled() { var isSilverlightInstalled = false; try { //check on IE try { var slControl = new ActiveXObject('AgControl.AgControl'); isSilverlightInstalled = true; isSilverlightInstalled = true; } catch (e) { //either not installed or not IE. Check Firefox. if (navigator.plugins["Silverlight Plug-In"]) { isSilverlightInstalled = true; } } } catch (e) { //we don't want to leak exceptions. However, you may want //to add exception tracking code here. } return isSilverlightInstalled; } function setModalClass(cssClass, behaviorID) { var modalContainer = document.getElementById(behaviorID._PopupControlID); if (modalContainer) modalContainer.className = 'modalContainer modalContainerCP ' + cssClass; } function setModalClassFE(cssClass, behaviorID) { var modalContainer = document.getElementById(behaviorID._PopupControlID); if (modalContainer) modalContainer.className = 'modalContainer ' + cssClass; } //------------------- Copy Link ---------------------// function showCopyLinkWindow(relatedLink, absoluteAddress, behavior, ifrID) { if (behavior) { setModalClass('modalCopyLink', behavior); var iFrame = document.getElementById(ifrID); iFrame.src = '/common/admin/CopyLink.aspx?relatedLink=' + encodeURIComponent(relatedLink) + '&absoluteAddress=' + encodeURIComponent(absoluteAddress); iFrame.style.display = 'block'; behavior.show(); } else { openCpModal({ title: 'Copy Link', className: 'modalCopyLink', isFrontEnd: false, useIframe: true, url: '/common/admin/CopyLink.aspx?relatedLink=' + encodeURIComponent(relatedLink) + '&absoluteAddress=' + encodeURIComponent(absoluteAddress) }); } } function showCopyLinkWindowUsingAddress(absoluteAddress) { var relatedUrl = absoluteAddress.replace(window.location.host, ''); relatedUrl = relatedUrl.replace(window.location.protocol + '//', ''); var behavior = $find('copyLinkBehavior'); if (behavior) showCopyLinkWindow(relatedUrl, absoluteAddress, behavior, 'copyLinkDialog'); else showCopyLinkWindow(relatedUrl, absoluteAddress, $find('editItemBehavior'), 'liveEditDialog'); } function showCopyLinkWindowUsingRelatedLink(relatedUrl) { var absoluteUrl = window.location.protocol + '//' + window.location.host + relatedUrl; var behavior = $find('copyLinkBehavior'); if (behavior) showCopyLinkWindow(relatedUrl, absoluteUrl, behavior, 'copyLinkDialog'); else showCopyLinkWindow(relatedUrl, absoluteUrl, $find('editItemBehavior'), 'liveEditDialog'); } function closeCopyModal() { var behavior = $find('copyLinkBehavior'); if (behavior) behavior.hide(); else { behavior = $find('editItemBehavior'); if (behavior) behavior.hide(); else closeCpModal(); } } //------------------- Copy Link End---------------------// //Parses the query string for the specified paramter and returns the value //Returns "" if the parameter is not found function GetQueryStringParameter(name) { name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regexS = "[\\?&]" + name + "=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(window.location.href); if (results == null) return ""; else return results[1]; } function setModalTitle(title, behaviorID) { if (behaviorID) { $('#' + behaviorID._PopupControlID).find('.modalTitle').text(title); } else { //if behaviorID is not provided, do the same as setModalTitle on FrontEnd.js var titleElem = document.getElementById('ctl00_LiveEditModalTitle'); if (titleElem == null) titleElem = document.getElementById('ctl00_ct100_LiveEditModalTitle'); if (titleElem == null) titleElem = document.getElementById('ctl00_ctl00_NotifyMeModalTitle'); if (titleElem) titleElem.innerHTML = title; } } //------------------- Copy Link End---------------------// function isNull(object, replacement) { return object == null ? replacement : object; } // Validates domain of email with service (ensures MX record present, DNS name valid, acceptable format). // The callbacks object should contain the following methods: // * badFormat - Email format invalid. Will also be thrown for null/empty email addresses. // * mxMissing - MX record missing for the domain. // * dnsError - A DNS error occurred (domain invalid, invalid characters in domain, etc). // * success - The email appears to be valid. function validateEmailDomain(emailAddress, callbacks) { $.ajax({ type: "POST", url: "/Services/ValidateEmail.ashx", data: { email: emailAddress }, success: function (data, textStatus, jqXHR) { switch (data.d) { case 1: callbacks.badFormat(emailAddress); break; case 2: callbacks.mxMissing(emailAddress); break; case 3: callbacks.dnsError(emailAddress); break; case 0: default: callbacks.success(emailAddress); break; } } }); } //Called when opening action menu. function openPopUp(id, event) { var $popUp = $(document.getElementById(id)); if ($popUp.hasClass('popped')) { //do not do anything if popup is already open. return false; } //Hide all popups already open if nesessary. $('.popUp').fadeOut(200).removeClass('popped'); $('.popUpParent').removeClass('popped'); //Open popup $popUp.fadeIn(200); $popUp.addClass('popped'); $popUp.parents('.popUpParent').addClass('popped'); //prevent triggering any other event. if (window.event) window.event.cancelBubble = true; else event.stopPropagation(); } function SignIn() { window.location.href = '/MyAccount?from=url&url=' + window.location.pathname + window.location.search; } function SignOut() { window.location.href = '/publiclogin.aspx?out=true&txtRedirect=' + window.location.pathname.substring(1) + window.location.search; } function removeIEParagraphs(editor) { editor.attachEventHandler("onkeyup", function (e) { if (e.keyCode == 8 || e.keyCode == 46 || e.keyCode == 13) { var result = ''; var re = new RegExp("<[P]> <\\/[P]>", "gi"); var m = re.exec(editor.get_html(true)); if (m == null) { return; } else { result = editor.get_html(true).replace(re, '
'); editor.set_html(result); } } }); } //To toggle the slide show and image manger menu items based on if the img is a from a slide show or not. function setMenuItems(editor) { var contextMenu = editor.getContextMenuByTagName("IMG"); if (!contextMenu) return; //Attach to the context menu show event, obtain editor selection and determine which tools to show contextMenu.add_show(function () { //Must be an image, the context menu would not fire var sel = editor.getSelectedElement(); //An array of menu item objects var menuItems = contextMenu.get_items(); var menuItem = null; //reset to show all and then disable the menu item based on currently selection for (i = 0; i < menuItems.length; i++) { menuItems[i].get_element().style.display = ""; menuItems[i].get_element().parentNode.style.display = ""; } //end for if (sel.getAttribute("slideshowimage")) { menuItem = menuItems[menuItems.length - 3]; menuItem.get_element().style.display = "none"; menuItem.get_element().parentNode.style.display = "none"; menuItem = menuItems[menuItems.length - 2]; menuItem.get_element().style.display = "none"; menuItem.get_element().parentNode.style.display = "none"; } else { menuItem = menuItems[menuItems.length - 1]; menuItem.get_element().style.display = "none"; menuItem.get_element().parentNode.style.display = "none"; } }); } function integersOnly(e, input) { var charCode = (e.which) ? e.which : e.keyCode; var keyChar = String.fromCharCode(charCode); var currentValue = $(input).val(); var allowNegativeSign = !$(input).hasClass("positive") && currentValue.indexOf('-') == -1 && (currentValue.length == 0 || currentValue == window.getSelection().toString()); if (keyChar == '-' && allowNegativeSign) return true; if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; return true; } function decimalOnly(e, input, skipSelected) { skipSelected = (skipSelected == undefined || skipSelected == null) ? false : skipSelected; var charCode = (e.which) ? e.which : e.keyCode; var keyChar = String.fromCharCode(charCode); var currentValue = $(input).val(); var hasDecimalPoint = currentValue.indexOf('.') != -1; if ((keyChar == '.' && !hasDecimalPoint)) return true; if (!skipSelected && isTextSelected(input)) return true; return integersOnly(e, input); } function isTextSelected(input) { if (typeof input.selectionStart == "number") { return input.selectionStart == 0 && input.selectionEnd == input.value.length; } else if (typeof document.selection != "undefined") { input.focus(); return document.selection.createRange().text == input.value; } } function validFileName(e) { var charCode = (e.which) ? e.which : e.keyCode; var keyChar = String.fromCharCode(charCode); var invalidCharacters = "\\/:*?\"<>|',"; return invalidCharacters.indexOf(keyChar) < 0; } function isValidURL(value) { return /^(https?:\/\/|ftp:\/\/|\/).+/i.test(value); } function isValidAbsoluteURL(value) { return /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value); } function validateLink(link) { if (link != '') { if ((link.indexOf('http://') == -1) && (link.indexOf('https://') == -1) && (link.substr(0, 1) != '/')) { return false; } } return true; } // Check if string is a whole number(digits only). function isWholeNumber(val) { return String(val).search(/^(([1-9]{1}\d{0,2},(\d{3},)*\d{3})|([1-9]{1}\d{0,}))$/) != -1; } // Checks that an input string is a decimal number function isDecimalOrZero(val) { isDecimal_re = /^\d{1,5}(\.\d{1,2})?$/; return String(val).search(isDecimal_re) != -1; } //Allows login to CPC function RebuildCSS(menu) { if (confirm('This will take some time\nand the site may look funny during the process.\nAre you sure?')) { var frmARC = document.forms.frmAdminRebuldCSS; frmARC.ysnNeedInclude.value = '1'; frmARC.intMenu.value = menu; frmARC.submit(); } } //Allows login to CPC function adminGetHelp(helpUrl, newWindow) { var cpcDomain = $('#cpcDomain').val(); if (cpcDomain.indexOf('https://') == -1) cpcDomain = 'https://' + cpcDomain document.cpconnect.action = cpcDomain + '/MyAccount?from=url&url=' + helpUrl; cpconnecttLogin(); } function connectCPC() { var cpcDomain = $('#cpcDomain').val(); if (cpcDomain.indexOf('https://') == -1) cpcDomain = 'https://' + cpcDomain document.cpconnect.action = cpcDomain + '/MyAccount'; var ifr = document.createElement('iframe'); ifr.name = "submitCPCFrame"; ifr.id = "submitCPCFrame"; ifr.style.display = 'none'; var frm = $(document.cpconnect).clone().get(0); frm.name = "iframeCPCConnect" frm.target = 'submitCPCFrame'; ifr.appendChild(frm); document.body.appendChild(ifr); frm.submit(); } function showFeatureNotAvailablePopup(hypothesisID) { var data = { id: hypothesisID }; $('.emailPage').removeClass('emailPage'); $.ajax({ url: '/FeatureNotAvailable/Popup', type: 'GET', data: { hypothesisID: hypothesisID }, cache: false, success: function (response) { if (response.action == 'modal') { openCpModal({ title: 'Feature Not Yet Available', className: 'featureNotAvailableModal moduleContentNew modalContainer', htmlContent: response.html, autoAdjust: true, isFrontEnd: true, elementID: 'featureNotAvailableModal' }); } else { window.location = '/FeatureNotAvailable?hypothesisID=' + hypothesisID + '&referrerUrl=' + window.location; } }, beforeSend: function () { ajaxPostBackStart('Loading'); }, complete: function () { ajaxPostBackEnd(); } }); } function getDateFormat() { if (!gDateFormat) { $.ajax({ url: "/GetDateFormat", type: "GET", success: function (response) { if (response.DateFormat) gDateFormat = response.DateFormat; }, error: function (xhr, textStatus, exception) { gDateFormat = "MM/dd/yyyy"; }, async: false }); } return gDateFormat == null ? "MM/dd/yyyy" : gDateFormat; } function getdDateFormat() { var dateFormat; $.ajax({ url: '/Utility/GetdDateFormat', async: false, type: 'GET', dataType: 'json', success: function (data) { dateFormat = data.dateFormat; }, error: function (jqXHR, textStatus, errorThrown) { dateFormat = "mm/dd/yyyy"; } }); return dateFormat; } function getDateFromInput(datePickerID, keepDayBeforeMonth) { var datePicker = $(datePickerID); var date; var dateFormat = keepDayBeforeMonth ? getDateFormat() : "mm/dd/yyyy"; //See if datepicker if so becuase of UK format we cannot just grab the value if (!isNaN(datePicker.data('tDatePicker')) && datePicker.data('tDatePicker') && datePicker.data('tDatePicker').value()) { var dateValTmp = new dateValidator(); date = dateValTmp.format(dateFormat,new Date(datePicker.data('tDatePicker').value())); } else { if (datePicker.val()) { var dayBeforeMonthOn = getDateFormat().toLocaleLowerCase() == "dd/mm/yyyy" ? true : false; //Check if valid date before trying to format var dateString = checkDateFormatReturnUSString(datePicker.val(), dayBeforeMonthOn); var dateVal = new dateValidator(); if (dateVal.dateValidateNew(dateString, false)) { date = dateVal.format(dateFormat,new Date(checkDateFormatReturnUSString(dateString, false))); } else { //Send the date string formatted eventhough invalid date. Allow date validation to return approiate error if (keepDayBeforeMonth) { date = dateString; } else { date = checkDateFormatReturnUSString(dateString, true); } } } } return date; } function formatUkDateReturnUSString(dateStr, isForce) { var retVal; if (isForce || getDateFormat().toLocaleLowerCase() == "dd/mm/yyyy") { dateStr = dateStr.replace(/\-/g, '/'); dateStr = dateStr.split("/"); retVal = dateStr[1] + "/" + dateStr[0] + "/" + dateStr[2]; } else { retVal = dateStr; } return retVal; } function formatRFC3339DateReturnString(dateStr, keepDayBeforeMonth) { var retVal; var dateStrMod = dateStr.replace(/\-/g, '/'); dateStrMod = dateStr.split("/"); if (dateStrMod.length == 3 && dateStrMod[0].length == 4) { if (keepDayBeforeMonth && getDateFormat().toLowerCase() == "dd/mm/yyyy") { retVal = dateStrMod[2] + "/" + dateStrMod[1] + "/" + dateStrMod[0]; } else { retVal = dateStrMod[1] + "/" + dateStrMod[2] + "/" + dateStrMod[0]; } } else { retVal = dateStr; } return retVal; } function checkDateFormatReturnUSString(dateStr, keepDayBeforeMonth) { var retVal; if (dateStr) { var splitDate = dateStr; dateStr = dateStr.replace(/\-/g, '/'); splitDate = dateStr.split("/"); if (splitDate.length == 3) { if (splitDate[0].length == 4) { retVal = formatRFC3339DateReturnString(dateStr, keepDayBeforeMonth); } else if (keepDayBeforeMonth) { retVal = dateStr; } else { var dateVal = new dateValidator(); retVal = formatUkDateReturnUSString(dateVal.cleanDate(dateStr)); } } else { retVal = dateStr; } } return retVal; } //IE no longer displays as IE by design code to determin if it is IE11 function isIE11() { var trident = !!navigator.userAgent.match(/Trident\/7.0/); var net = !!navigator.userAgent.match(/.NET4.0E/); return trident && net; } function isValidUrl(url) { return url.match(/^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s<>\#%"\,\{\}\\|\\\^\[\]`]+)?$/); } function isValidAbsoluteUrl(value) { return /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value); } //Replaces the given tag with the tag to replace inside the element for all occurences of the tag within the element. //$element - The element to perform the replace to //tagToReplace - Tag to be replaced replace provided as string, ex: "i", "b", "strong" etc //tagToReplaceWith - Tag to replace with, provided as string, ex: "i", "b", "strong" etc function replaceTag($element, tagToReplace, tagToReplaceWith) { var $tagElemsToReplace = $element.find(tagToReplace); $tagElemsToReplace.each(function () { var $tagElem = $(this); var tagElemeHtml = $tagElem.html(); $tagElem.replaceWith('<' + tagToReplaceWith + '>' + tagElemeHtml + ''); }); } window.addEventListener("load", function () { if (MutationObserver != null) { if ($('.contentContainerOld').length > 0 && ($('.spellchecker').length > 0 || $('[id^="DialogOpener"]').length > 0)) { var observer = new MutationObserver(function moveTelerikModalOverlay(mutations) { mutations.forEach(function (mutation) { if (!mutation.addedNodes) return; for (var i = 0; i < mutation.addedNodes.length; i++) { // do things to your newly added nodes here var node = mutation.addedNodes[i]; if (node.classList != null && node.classList.contains("TelerikModalOverlay")) { $('.contentContainerOld').after(node); } } }); }); observer.observe(document.getElementsByClassName('contentContainerOld')[0], { childList: true, subtree: true, attributes: false, characterData: false }); } } }); if (!Array.prototype.includes) { Array.prototype.includes = function (searchElement) { 'use strict'; if (this == null) { throw new TypeError('Array.prototype.includes called on null or undefined'); } var O = Object(this); var len = parseInt(O.length, 10) || 0; if (len === 0) { return false; } var n = parseInt(arguments[1], 10) || 0; var k; if (n >= 0) { k = n; } else { k = len + n; if (k < 0) { k = 0; } } var currentElement; while (k < len) { currentElement = O[k]; if (searchElement === currentElement || (searchElement !== searchElement && currentElement !== currentElement)) { // NaN !== NaN return true; } k++; } return false; }; } function isMsie() { ua = navigator.userAgent; /* MSIE used to detect old browsers and Trident used to newer ones*/ var is_ie = ua.indexOf("MSIE ") > -1 || ua.indexOf("Trident/") > -1; return is_ie; } function isMozilla() { return navigator.userAgent.toLowerCase().indexOf('firefox') > -1; } function browserVersion() { ua = navigator.userAgent; var browserVersion = null; var verOffset = null; if (isMsie()) { verOffset = ua.indexOf("rv:"); browserVersion = ua.slice(verOffset + 3).slice(0, 4); } else if (isMozilla()) { verOffset = ua.indexOf("Firefox") browserVersion= ua.substring(verOffset + 8) } return browserVersion; } function setDatepickerHighlightedDate(date, datePickerId) { var dateFormat = getdDateFormat(); var momentDate = moment(date, dateFormat.toUpperCase()).format('MM/DD/YYYY'); if (momentDate.toLowerCase() !== "invalid date") { $('#' + datePickerId).pickadate('picker').set('highlight', date, { format: dateFormat }); } } ; /// if (!window.Core) { window.Core = new CoreNamespace(); } function AJAX(url, type, json, callBack, showLoadingMessage, contentType, forceCallBack, suppressErrorMessage) { contentType = contentType || 'application/x-www-form-urlencoded; charset=UTF-8'; showLoadingMessage = showLoadingMessage == null ? true : showLoadingMessage; forceCallBack = forceCallBack == null ? false : forceCallBack; if (typeof (suppressErrorMessage) === 'undefined') suppressErrorMessage = false; $.ajax({ url: url, type: type, contentType: contentType, data: json, success: function (response) { if (response.ErrorMessage && !forceCallBack) { if (response.ErrorMessage.indexOf('You do not have permission to perform this action.') != -1 && !isUserLoggedIn()) { // 079B4F43 alert('You are not logged in. Please login to continue.'); location.href = '/myaccount?from=url&url=' + window.location.pathname; } else { alert(response.ErrorMessage); } } else if (response.RedirectURL && !forceCallBack) window.location.href = response.RedirectURL; else if (callBack) callBack(response); }, beforeSend: function () { if (showLoadingMessage) { ajaxPostBackStart('Loading'); } }, complete: function () { if (showLoadingMessage) { ajaxPostBackEnd(); } }, error: function (xhr, textStatus, exception) { if (!suppressErrorMessage) { alert('Error: ' + xhr.statusText + '\nStatus: ' + xhr.status); } } }); } function isUserLoggedIn() { var result = true; // if there is an error lets not show the login message. $.ajaxSetup({ async: false, ignoreEditor: true }); $.post('/Utility/IsUserLoggedIn', function (data) { result = data; }); $.ajaxSetup({ async: true, ignoreEditor: false }); return result; } ///Method to pause a javascript execution for x seconds, works like sleep(). VB function sleep(seconds) { var max_sec = new Date().getTime(); while (new Date() < max_sec + seconds * 1000) { } return true; } if (!String.prototype.format) { String.prototype.format = function () { var args = arguments; return this.replace(/{(\d+)}/g, function (match, number) { return typeof args[number] != 'undefined' ? args[number] : match ; }); }; } if (!String.prototype.isNullOrWhiteSpace) { String.prototype.isNullOrWhiteSpace = function () { return this == null || this.trim() == ''; }; } function isValidMoney(value) { var isValid = false; if (value && value != '') isValid = /^\$?\s*\d+(,\d{3})*(\.\d{1,2})?$/.test(value); return isValid; }; if (typeof String.prototype.startsWith != 'function') { String.prototype.startsWith = function (str) { return this.slice(0, str.length) == str; }; } String.prototype.format = String.prototype.f = function () { var s = this, i = arguments.length; while (i--) { s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), arguments[i]); } return s; }; //Creates a javascript namespace, if one already exists, just returns that namespace. function createNamespace(namespaceString) { var parts = namespaceString.split('.'), parent = window, currentPart = '', nsLength = parts.length; for (var i = 0, length = nsLength; i < length; i++) { currentPart = parts[i]; parent[currentPart] = parent[currentPart] || {}; parent = parent[currentPart]; } return parent; } $(function () { // Ensures a dependency exists. If it doesn't acquire it. function ensure(dependencyExists, dependencyUrl, onceItExistsCallback) { if (dependencyExists) { onceItExistsCallback(); return; } $.getScript(dependencyUrl, onceItExistsCallback); } var ajaxControlToolkit = window.AjaxControlToolkit; // This is hack override in order to fix problems with Ajax Toolkit Drag and Drop in newer browsers. It substitutes in jQuery Draggable if it is available. // A more proper fix is ideal, but extremely expensive as it would require replacing over a hundred instances of invocations of the old modal. // There isn't a clean way to integrate in the new modal system. JE // https://system.netsuite.com/app/crm/support/issuedb/issue.nl?id=3809568&l=T if (ajaxControlToolkit && ajaxControlToolkit.ModalPopupBehavior) { ajaxControlToolkit.ModalPopupBehavior.prototype._attachPopup = function () { /// /// Attach the event handlers for the popup /// if (this._DropShadow && !this._dropShadowBehavior) { this._dropShadowBehavior = $create(ajaxControlToolkit.DropShadowBehavior, {}, null, null, this._popupElement); } var _this = this; // Drag and Drop Replacement. Acquire any dependencies on the fly. ensure($.ui, "/Common/Controls/jquery-ui/js/jquery.ui.core.min.js", function () { // I ensure($.widget, "/Common/Controls/jquery-ui/js/jquery.ui.widget.min.js", function () { // callbacks ensure($.ui.mouse, "/Common/Controls/jquery-ui/js/jquery.ui.mouse.min.js", function () { // love ensure($.fn.draggable, '/Common/Controls/jquery-ui/js/jquery.ui.draggable.min.js', function () { $("#" + _this._PopupControlID).draggable({ handle: '#' + _this._PopupDragHandleControlID }); // Subsitution over original Ajax Toolkit Drag and Drop code. $("#" + _this._PopupDragHandleControlID).css('cursor', 'move'); // Let's go ahead and fix the move handle while we are at it. }); }); }); }); $addHandler(window, 'resize', this._resizeHandler); $addHandler(window, 'scroll', this._scrollHandler); this._windowHandlersAttached = true; } } }); String.prototype.replaceAll = function (search, replacement) { var target = this; return target.replace(new RegExp(search, 'g'), replacement); }; function executeViewMapPostClickActions($element) { //Hide the view map element post click(to avoid clicking repeatedly) $element.hide('fast'); //Collect analytics around map clicks var url = '/Admin/Analytics/CollectGoogleMapClicks/Execute'; var moduleId = $element.data('moduleid'); $.ajax({ url: url, type: 'POST', data: { url: window.location.href, moduleId: moduleId }, success: function (json) { //send data to telemetry appInsights.trackEvent("googlemapclicked", json); }, error: function (xhr, textStatus, exception) { alert("Error: " + xhr.statusText + "\nStatus: " + xhr.status); } }); } function importModal(options) { if (window.ImportModalInstance === undefined) { var script = document.createElement("script"); script.onload = function () { window.ImportModalInstance.init(options); }; script.src = "/Assets/Scripts/ImportModal.js"; document.head.appendChild(script); } else window.ImportModalInstance.init(options); } function exportModal(options) { if (window.ExportModalInstance === undefined) { var script = document.createElement("script"); script.onload = function () { window.ExportModalInstance.init(options); }; script.src = "/Assets/Scripts/ExportModal.js"; document.head.appendChild(script); } else window.ExportModalInstance.init(options); } document.addEventListener("DOMContentLoaded", function () { var modal = document.querySelector(".importModal"); if (modal !== null) { try { if (!modal.classList.contains("processed")) { var options = modal.dataset.importconfig; if (options) { modal.addEventListener("click", function (e) { e.preventDefault(); importModal(JSON.parse(options)); }); //Avoid further processing if the event gets triggered multiple times during page load modal.classList.add("processed"); } } } catch (err) { console.error("Unable to initialize import modal"); } } var modalExport = document.querySelector(".exportModal"); if (modalExport !== null) { try { if (!modalExport.classList.contains("processed")) { var options = modalExport.dataset.exportconfig; if (options) { modalExport.addEventListener("click", function (e) { e.preventDefault(); exportModal(JSON.parse(options)); }); //Avoid further processing if the event gets triggered multiple times during page load modalExport.classList.add("processed"); } } } catch (err) { console.error("Unable to initialize export modal"); } } }); ; $(document).ready(function () { if (window.isResponsiveEnabled && !window.pageHandleResponsive) { function executeRWDResizeEvents(event) { var listener = function (e) { if ($('#hdnPageID').length == 0) { var breakpointWidth = 600, viewportWidth = $(window).width(), currentCookieValue = getCookieValue('viewportWidth'); currentCookieValue = currentCookieValue == null || currentCookieValue == '' ? 0 : Number(currentCookieValue); document.cookie = 'viewportWidth=' + viewportWidth + '; path=/'; if ((viewportWidth < breakpointWidth && currentCookieValue >= breakpointWidth) || (viewportWidth >= breakpointWidth && currentCookieValue < breakpointWidth)) { window.location.reload(); } } }; if (window.addEventListener) { window.addEventListener(event, listener, false); } else if (window.attachEvent) { window.attachEvent("on" + event, listener); } } executeRWDResizeEvents('resize'); } // Always reset the viewport width now that the document is fully loaded and we can make it more accurate. // (Sometimes on load it comes back much wider than it should) document.cookie = 'viewportWidth=' + $(window).width() + '; path=/'; }); ; function Animations() { if ($('.activeWidgetSkinComponentsOnPageJson').html() != '') this.components = $.parseJSON($('.activeWidgetSkinComponentsOnPageJson').html()); this.selectors = [ '', '.widgetHeader', '.widgetBody', '.widgetItem', '.widgetTitle', '.widgetMeta', '.widgetBody .bullets', 'a:link', '.readOn:link', '.widgetViewAll:link', '.widgetRSS:link', '.widgetFooter', '.cpTabs', '.cpTabs > li > a:link', '.cpTabPanel', '.separated .half:after, .separated .third:after, .separated .fourth:after, .separated .fifth:after, .separated.cpGrid .col:after ', '.miniCalendarHeader', '.miniCalendar > table', '.miniCalendar th', '.miniCalendar td > span', '.miniCalendar td > a', '.miniCalendar .today > span', '.miniCalendar .not > span', '.miniCalendar' ]; $('.activeWidgetSkinComponentsOnPageJson').remove(); } Animations.prototype.Apply = function () { var self = this; self.addClassToContainers(); self.bindContainerTriggers(); self.addClassAndTriggerToSkinComponents(); }; /// Gets the css class to be applied from the hidden element already present on the page and applies the css class to the Container(Structural/Content) Animations.prototype.addClassToContainers = function () { var $hiddenAnimationElements = $('.hiddenAnimations'); if ($hiddenAnimationElements != null) { $hiddenAnimationElements.each(function () { //Get hidden element var $hiddenAnimationElement = $(this); //Get css class from it var cssClass = $hiddenAnimationElement.data('animationclass'); var startCssClass = cssClass + '_Start'; var triggerData = $hiddenAnimationElement.data('trigger'); //Apply that class to parent container, depending on container type //For Strctural container if ($hiddenAnimationElement.parent('[data-cprole=structuralContainer]') != null) { $hiddenAnimationElement.parent('[data-cprole=structuralContainer]').addClass(startCssClass); $hiddenAnimationElement.parent('[data-cprole=structuralContainer]').addClass(triggerData); setTimeout(function () { $hiddenAnimationElement.parent('[data-cprole=structuralContainer]').addClass(cssClass); $hiddenAnimationElement.parent('[data-cprole=structuralContainer]').removeClass(startCssClass); }, 10); } //For Content Container if ($hiddenAnimationElement.parent('[data-cprole=contentContainer]') != null) { $hiddenAnimationElement.parent('[data-cprole=contentContainer]').addClass(startCssClass); $hiddenAnimationElement.parent('[data-cprole=contentContainer]').addClass(triggerData); setTimeout(function () { $hiddenAnimationElement.parent('[data-cprole=contentContainer]').addClass(cssClass); $hiddenAnimationElement.parent('[data-cprole=contentContainer]').removeClass(startCssClass); }, 10); } }); } }; //Apply animation class to widget skin components on page Animations.prototype.addClassAndTriggerToSkinComponents = function () { var self = this; var $widgetsHavingSkinsApplied = $("[class*='skin']"); if ($widgetsHavingSkinsApplied != null) { //array of unique skin ids var $uniqueSkinIds = []; $widgetsHavingSkinsApplied.each(function () { //Get skin class var skinClass = $(this).attr('class').match(/.skin\d+/g)[0]; //Parse skinId off of skin class var skinId = parseInt(skinClass.match(/\d+/)[0]); //Insert if not there in array if ($.inArray(skinId, $uniqueSkinIds) === -1) $uniqueSkinIds.push(skinId); }); $.each($uniqueSkinIds, function (index, value) { var skinId = value; for (var i = 0; i < self.selectors.length; i++) { //Find all widget skincomponents on the page using this skin. var $skinComponentsOnPageUsingThisSkin = $('.skin' + skinId + ' ' + self.selectors[i] + ''); var animationClass = self.classAndTrigger(skinId, i).className; var animationTrigger = self.classAndTrigger(skinId, i).triggerName; var scrollOffset = self.classAndTrigger(skinId, i).scrollOffset; if (animationClass !== undefined) { //Apply animation class $skinComponentsOnPageUsingThisSkin.addClass(animationClass + '_Start').addClass(animationClass).removeClass(animationClass + '_Start'); } if (animationTrigger !== undefined && animationTrigger !== 'hover') { //Apply animation trigger $skinComponentsOnPageUsingThisSkin.addClass(animationTrigger + 'AnimationTrigger'); $skinComponentsOnPageUsingThisSkin.data("scrolloffset", scrollOffset); } } }); } }; ///Get animation class given the component and skin Id Animations.prototype.classAndTrigger = function (skinId, componentTypeId) { var self = this; var components = self.components; var classAndTrigger = {}; if (components.length > 0) { for (var i = 0; i < components.length; i++) { if (components[i].WidgetSkinID === skinId && components[i].ComponentType === componentTypeId) { classAndTrigger.className = components[i].AnimationClass; classAndTrigger.triggerName = components[i].TriggerNameLowerCase; classAndTrigger.scrollOffset = components[i].ScrollOffset; return classAndTrigger; } } } return classAndTrigger; }; /// Gets the css class to be applied from the hidden element already present on the page and applies the css class to the Nav container(Main/Side) Animations.prototype.applyAnimationClassToNavContainers = function ($olSubMenu, menuType) { var mainMenu = 2; var sideMenu = 1; var cssClass; var triggerData; var $mainNavHiddenElement = $('#mainNav').children('[class*="hiddenAnimations"]'); var $secondaryNavHiddenElement = $('#secondaryNav').children('[class*="hiddenAnimations"]'); if ($('#mainNav').length > 0 && menuType === mainMenu) { cssClass = $mainNavHiddenElement.data('animationclass'); triggerData = $mainNavHiddenElement.data('trigger'); $olSubMenu.addClass(cssClass); setTimeout(function () { $olSubMenu.addClass(cssClass); $olSubMenu.addClass('animation-triggered'); $olSubMenu.removeClass(cssClass + '_Start'); }, 10); }; if ($('#secondaryNav').length > 0 && menuType === sideMenu) { cssClass = $secondaryNavHiddenElement.data('animationclass'); triggerData = $secondaryNavHiddenElement.data('trigger'); $olSubMenu.addClass(cssClass); setTimeout(function () { $olSubMenu.addClass(cssClass); $olSubMenu.addClass('animation-triggered'); $olSubMenu.removeClass(cssClass + '_Start'); }, 10); }; }; Animations.prototype.applyAnimationClassToMegaMenuContainer = function ($megaMenuContainer, timeOut) { var cssClass; var $megaMenuHiddenElement = $('.megaMenuContainer').children('[class*="hiddenAnimations"]'); $megaMenuContainer.mouseleave(function () { if (!$('.megaMenuContainer').children('.pinned').length > 0) { $(this).removeClass('animation-triggered'); } }); if ($('.megaMenuContainer').length > 0) { cssClass = $megaMenuHiddenElement.data('animationclass'); setTimeout(function () { $megaMenuContainer.addClass('animation-triggered'); $megaMenuContainer.removeClass(cssClass + '_Start'); }, timeOut); }; }; /// Gets the css class to be applied from the hidden element already present on the page and applies the css class to the Nav container(Main/Side) Animations.prototype.applyInitial = function ($olSubMenu, menuType) { var mainMenu = 2; var sideMenu = 1; var cssClass; var triggerData; var $mainNavHiddenElement = $('#mainNav').children('[class*="hiddenAnimations"]'); var $secondaryNavHiddenElement = $('#secondaryNav').children('[class*="hiddenAnimations"]'); if ($('#mainNav').length > 0 && menuType === mainMenu) { cssClass = $mainNavHiddenElement.data('animationclass'); triggerData = $mainNavHiddenElement.data('trigger'); $olSubMenu.addClass(cssClass + '_Start').addClass(triggerData); }; if ($('#secondaryNav').length > 0 && menuType === sideMenu) { cssClass = $secondaryNavHiddenElement.data('animationclass'); triggerData = $secondaryNavHiddenElement.data('trigger'); $olSubMenu.addClass(cssClass + '_Start').addClass(triggerData); }; }; Animations.prototype.bindContainerTriggers = function () { $(document) .delegate('[class*="clickAnimationTrigger"]', 'click', function () { $(this).addClass('animation-triggered'); }); $(window).scroll(function () { $('.scrollAnimationTrigger').not('.cpCarousel .widgetItem.scrollAnimationTrigger').each(function () { var scrollOffsetPercentage = $(this).data('scrolloffset') / 100; if (isNaN(scrollOffsetPercentage)) scrollOffsetPercentage = $(this).children().first().data('scrolloffset') / 100; if (scrollOffsetPercentage != 0 && ($(window).scrollTop() + ($(window).height() * (1 - scrollOffsetPercentage))) > $(this).offset().top && ($(this).offset().top + $(this).height()) > $(window).scrollTop()) $(this).addClass('animation-triggered'); }); $('.cpCarousel .widgetItem.scrollAnimationTrigger').each( function () { $(this).addClass('animation-triggered'); } ); }); }; function StickyStructuralContainers() { //Add sticky class to structuralStructuralContainer var stickyContainers = $('div.stickyInnerDiv.sticky'); if (stickyContainers.length > 0) { stickyContainers.each(function () { $(this).parent().addClass('stickyStructuralContainer stickySticky'); }); if ($("#divToolbars")[0]) { $(".stickyStructuralContainer.stickySticky").css('top', ($("#divToolbars")[0].getBoundingClientRect().height + parseInt($('#divToolbars').css('margin-top'))) + "px"); } } //Add sticky class to structural container inside of stickyStructualContainer var structuralContainersUnderSticky = $('div.structuralUnderStickyInnerDiv'); if (structuralContainersUnderSticky.length > 0) { structuralContainersUnderSticky.each(function () { $(this).parent().addClass($(this).attr('class')); }); } } StickyStructuralContainers.prototype.init = function () { var self = this; var stickyContainers = $('div.stickyInnerDiv.sticky'); var paddingCalc = $("#divToolbars").outerHeight() - parseInt($("#divToolbars").css('padding-top')); if (stickyContainers.length > 0) { var bottomOfSticky = $('.stickyStructuralContainer.stickySticky').outerHeight(); $('#bodyWrapper').addClass('noTransition'); $('.stickyStructuralContainer.stickySticky').next().css('padding-top', bottomOfSticky + 'px'); } //Adjusted / re - calculate the padding for sibling of sticky structural container. window.Pages.onResizeHandlers = window.Pages.onResizeHandlers || []; window.Pages.onResizeHandlers.push(function () { $('.stickySticky').each(function () { var padding = $(this).outerHeight() - 1 + 'px'; var self = this; if ($('.stickySticky').next().attr('data-cprole') == "banner") { $('.stickySticky').next().find('[id^="structuralContainer"]').first().css('padding-top', padding); } else { window.setTimeout(function () { $(self).next().css('padding-top', padding); }, 500); } }); }); //set up scroll events var stickyCollapsedContainers = $('div.stickyInnerDiv.stickyCollapsedWhenScrolled'); if (stickyCollapsedContainers.length > 0 && !window.isMobileBrowserIncludingTablets) { stickyCollapsedContainers.each(function () { $(this).parent().addClass('stickyStructuralContainer stickyStickyCollapsedWhenScrolled'); if ($(this).hasClass('stickyFadeAnimation')) { $(this).parent().addClass('stickyStickyFadeAnimation'); } else if ($(this).hasClass('stickySlideDownAnimation')) { $(this).parent().addClass('stickyStickySlideDownAnimation'); } }); var bottomOfStickyCollapsed = $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled').offset().top + $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled').outerHeight() - $("#divToolbars").height(); var hideWhenExpandedHeights = self.getAllHeights($('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .structuralUnderStickyInnerDiv.hideWhenExpanded')); var hideWhenCollapsedHeights = self.getAllHeights($('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .structuralUnderStickyInnerDiv.hideWhenCollapsed')); var scrollDownTrigger = self.getStickyScrollBreakpoint(bottomOfStickyCollapsed, hideWhenExpandedHeights, hideWhenCollapsedHeights); self.showHideStickyContainers(true, scrollDownTrigger, paddingCalc); self.bindScrollForSticky(bottomOfStickyCollapsed, hideWhenExpandedHeights, hideWhenCollapsedHeights); } else { stickyContainers = $('div.stickyInnerDiv'); if (stickyContainers.length > 0 && stickyContainers.find('.structuralUnderStickyInnerDiv.showInMobile').length > 0) { stickyContainers.find('.structuralUnderStickyInnerDiv').not('.showInMobile') .each(function () { $(this).hide(); }); } } } StickyStructuralContainers.prototype.bindScrollForSticky = function (bottomOfStickyCollapsed, hideWhenExpandedHeights, hideWhenCollapsedHeights) { var self = this; var scrollDownTrigger = self.getStickyScrollBreakpoint(bottomOfStickyCollapsed, hideWhenExpandedHeights, hideWhenCollapsedHeights); var paddingCalc = $("#divToolbars").outerHeight() - parseInt($("#divToolbars").css('padding-top')); $(window) .scroll(function () { self.showHideStickyContainers(false, scrollDownTrigger, paddingCalc); }); } StickyStructuralContainers.prototype.showHideStickyContainers = function (initialLoad, scrollDownTrigger, paddingCalc) { var $stickyStructuralContainer = $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled'); var wS = $(window).scrollTop(); if (wS >= scrollDownTrigger + paddingCalc) { $stickyStructuralContainer.addClass('stickyCollapsed'); $(".stickyStructuralContainer.stickyStickyCollapsedWhenScrolled") .css('top', $("#divToolbars").outerHeight() + "px"); //Structrual overrides content container so show/hide if content container doesn't have a structural container around it $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .hideWhenExpanded') .each(function () { if ($(this).parents('.structuralUnderStickyInnerDiv') === 0) { $(this).show(); } }); $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .hideWhenCollapsed') .each(function () { if ($(this).parents('.structuralUnderStickyInnerDiv') === 0) { $(this).hide(); } }); //Structrual overrides content container so show/hide structural containers and any content containers under it that would be opposite behavior $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .structuralUnderStickyInnerDiv.hideWhenCollapsed').hide(); $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .structuralUnderStickyInnerDiv.hideWhenExpanded').show(); $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .hideWhenExpanded').find('.hideWhenCollapsed').show(); $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .hideWhenCollapsed').find('.hideWhenExpanded').hide(); //Animate the slide down $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled.stickyStickyFadeAnimation.stickyCollapsed') .addClass('stickyAnimFade'); $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled.stickyStickySlideDownAnimation.stickyCollapsed') .addClass('stickyAnimSlideDown'); if ($('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled.stickyCollapsed').length > 0 && !$('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled.stickyCollapsed').hasClass('stickyAnimComplete') ) { setTimeout(function () { $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled.stickyCollapsed') .addClass('stickyAnimComplete'); }, 0); $('#stickyPlaceholder').css('height', scrollDownTrigger + paddingCalc + 'px'); if (!window.isRemoveSetHeights) SetHeights(); } } else { if (($('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled.stickyCollapsed').length > 0 && $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled.stickyCollapsed').hasClass('stickyAnimComplete')) || initialLoad) { $(".stickyStructuralContainer.stickyStickyCollapsedWhenScrolled").css('top', 'auto'); //Structrual overrides content container so show/hide if content container doesn't have a structural container around it $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .hideWhenExpanded') .each(function () { if ($(this).parents('.structuralUnderStickyInnerDiv') === 0) { $(this).hide(); } }); $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .hideWhenCollapsed') .each(function () { if ($(this).parents('.structuralUnderStickyInnerDiv') === 0) { $(this).show(); } }); //Structrual overrides content container so show/hide structural containers and any content containers under it that would be opposite behavior $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .structuralUnderStickyInnerDiv.hideWhenExpanded').hide(); $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .structuralUnderStickyInnerDiv.hideWhenCollapsed').show(); $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .hideWhenExpanded').find('.hideWhenCollapsed').hide(); $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .hideWhenCollapsed').find('.hideWhenExpanded').show(); $('#stickyPlaceholder').css('height', '0'); $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled.stickyStickyFadeAnimation.stickyCollapsed') .removeClass('stickyAnimFade'); $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled.stickyStickySlideDownAnimation.stickyCollapsed') .removeClass('stickyAnimSlideDown'); $stickyStructuralContainer.removeClass('stickyCollapsed stickyAnimComplete'); if (!window.isRemoveSetHeights) SetHeights(); } } } StickyStructuralContainers.prototype.getAllHeights = function (elements) { var heights = 0; if (elements && elements.length > 0) { elements.each(function () { if ($(this).parents('.structuralUnderStickyInnerDiv.hideWhenExpanded').length === 0 && $(this).parents('.structuralUnderStickyInnerDiv.hideWhenCollapsed').length === 0) heights += $(this).height(); }); } return heights; } StickyStructuralContainers.prototype.getStickyScrollBreakpoint = function (bottomOfStickyCollapsed, hideWhenExpandedHeights, hideWhenCollapsedHeights) { var scrollDownTrigger; var $stickyStructuralContainer = $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled'); var toolBarAndStickyHeight = $stickyStructuralContainer.outerHeight() - $("#divToolbars").height(); //Logic for when there are structural containers if ($('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .structuralUnderStickyInnerDiv.hideWhenCollapsed').length > 0 || $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .structuralUnderStickyInnerDiv.hideWhenExpanded').length > 0) { //If page loaded and already collapsed and has both show and hide containers if ($('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled.stickyCollapsed .structuralUnderStickyInnerDiv.hideWhenCollapsed').length > 0 && $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled.stickyCollapsed .structuralUnderStickyInnerDiv.hideWhenExpanded').length > 0) { scrollDownTrigger = hideWhenCollapsedHeights + toolBarAndStickyHeight - hideWhenExpandedHeights; //If page loaded and NOT collapsed and has both show and hide containers } else if ($('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .structuralUnderStickyInnerDiv.hideWhenCollapsed').length > 0 && $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .structuralUnderStickyInnerDiv.hideWhenExpanded').length > 0) { scrollDownTrigger = toolBarAndStickyHeight; //If page loaded and collapsed and has only visible containers when collapsed } else if ( $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled.stickyCollapsed .structuralUnderStickyInnerDiv.hideWhenExpanded').length > 0) { scrollDownTrigger = toolBarAndStickyHeight - hideWhenExpandedHeights; //If page loaded and collapsed and has only visible containers when expanded } else if ( $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled.stickyCollapsed .structuralUnderStickyInnerDiv.hideWhenCollapsed').length > 0) { scrollDownTrigger = hideWhenCollapsedHeights + toolBarAndStickyHeight; //If page loaded and NOT collapsed and has only one style of visible container (collapsed or non) } else if ($('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .structuralUnderStickyInnerDiv.hideWhenCollapsed').length > 0 || $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .structuralUnderStickyInnerDiv.hideWhenExpanded').length > 0) { scrollDownTrigger = toolBarAndStickyHeight; } else { scrollDownTrigger = toolBarAndStickyHeight; } //Logic for when there are only content containers. Same scenarios as strucrual } else { if ($('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled.stickyCollapsed .hideWhenCollapsed').length > 0 && $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled.stickyCollapsed .hideWhenExpanded').length > 0) { scrollDownTrigger = hideWhenCollapsedHeights + toolBarAndStickyHeight - hideWhenExpandedHeights; } else if ($('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .hideWhenCollapsed').length > 0 && $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .hideWhenExpanded').length > 0) { scrollDownTrigger = toolBarAndStickyHeight; } else if ( $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled.stickyCollapsed .hideWhenExpanded').length > 0) { scrollDownTrigger = toolBarAndStickyHeight - hideWhenExpandedHeights; } else if ( $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled.stickyCollapsed .hideWhenCollapsed').length > 0) { scrollDownTrigger = hideWhenCollapsedHeights + toolBarAndStickyHeight; } else if ($('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .hideWhenCollapsed').length > 0 || $('.stickyStructuralContainer.stickyStickyCollapsedWhenScrolled .hideWhenExpanded').length > 0) { scrollDownTrigger = toolBarAndStickyHeight; } else { scrollDownTrigger = toolBarAndStickyHeight; } } return scrollDownTrigger; }; var commonLocalization = null; var userAgent = window.navigator.userAgent; var iOSSafari = userAgent.match(/iP(ad|hone)/i) && userAgent.match(/WebKit/i) && !userAgent.match(/CriOS/i); var hashRegex = /^(#cc[A-z0-9]{8}-[A-z0-9]{4}-[A-z0-9]{4}-[A-z0-9]{4}-[A-z0-9]{12})$/; var stickyStructuralContainers = null; if (window.location.hash && hashRegex.test(window.location.hash)) { var targetHash = window.location.hash; window.location.hash = ''; scroll(0, 0); setTimeout(function () { scroll(0, 0); }, 1); } if (window.isResponsiveEnabled) { loadMediaFramework(); } function loadMediaFramework() { Modernizr.load([ //test old browsers to use polyfills { test: window.addEventListener, nope: "/Assets/Scripts/RWD/eventListener.js" }, { test: window.matchMedia, nope: "/Assets/Scripts/RWD/media.match.js" }, { test: Modernizr.touch, yep: "/Assets/Scripts/RWD/quo.debug.js" }, //Load Media Framework after polyfills if needed getAbsoluteUrl("/Assets/Scripts/RWD/MediaFramework.js") ]); } (function () { var timer = 4000; var incrementTimer = function () { timer = timer * 1.25; }; var timeOutFunction = function () { setTimeout(timeOutFunction, timer); setBannerHeights(); incrementTimer(); }; timeOutFunction(); }()); $(document).ready(function () { if (!window.isResponsiveEnabled) { //Setup execution of events when resizing var timeout = 250; //time out to debounce event window.Pages = window.Pages || {}; window.Pages.onResizeHandlers = window.Pages.onResizeHandlers || []; if (typeof updateMegaMenusOnBrowserResize === 'function') window.Pages.onResizeHandlers.push(updateMegaMenusOnBrowserResize); if ($('#hdnWidgetManager').length == 0 && typeof rearrangeFlyoutsOnResizeEvents === 'function') window.Pages.onResizeHandlers.push(rearrangeFlyoutsOnResizeEvents); function executeResizeEvents(event) { var timer; var listener = function (e) { //Execute the handlers for resize events. timer && clearTimeout(timer); timer = setTimeout(function () { for (var i = 0; i < window.Pages.onResizeHandlers.length; i++) { if (typeof (window.Pages.onResizeHandlers[i]) === 'function') { window.Pages.onResizeHandlers[i](); } } }, timeout); }; if (window.addEventListener) { window.addEventListener(event, listener, false); } else if (window.attachEvent) { window.attachEvent("on" + event, listener); } } executeResizeEvents('resize'); executeResizeEvents('orientationChange'); } if (window.isResponsiveEnabled) { //Inserts data-label on each table cell in froala editor. Needed for responsive view $.each($.find('.fr-view table'), function (tableIndex, tableValue) { $(tableValue).parent().addClass('responsiveEditor'); $.each($(tableValue).find('thead th'), function (headerIndex, headerValue) { $.each($(tableValue).find('tbody tr'), function (rowIndex, rowValue) { $($(rowValue).find('td')[headerIndex]).attr('data-label', headerValue.textContent); }); }); }); } $('#divToolbars').css('overflow-x', 'visible'); $('#divToolbars').css('overflow-y', 'visible'); browserFailOvers(); var GetCookie = function (cname) { var name = cname + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1); if (c.indexOf(name) == 0) return c.substring(name.length, c.length); } return ""; } var IsLiveEditOn = function () { return GetCookie("enableLiveEdit") === "true"; }; if (IsLiveEditOn() && isUserLoggedIn()) { $('body').addClass('liveEditOn'); } setTimeout(function () { $('.mobile.header .mobileMenu').css('top', $('#divToolbars .mobileAlertBar').outerHeight(true)); }, 10); $('div.mobile.header > a.mobileMenu').unbind().click(function (e) { e.preventDefault(); $('#menuPanel').css('top', $('#divToolbars').outerHeight(true)); $('#menuPanel').toggle('slide'); window.scrollTo(0, 0); }); // Set Heights really fast at first then after 4 seconds slow it down. if (typeof SetHeights === 'function') { var stretchContainers = (typeof window.dynamicStretchContainers === 'function'); var setHeightInterval = setInterval(function () { if (!window.isRemoveSetHeights) SetHeights(); if (stretchContainers) window.dynamicStretchContainers(); }, 50); setTimeout(function () { clearInterval(setHeightInterval); if (IsLiveEditOn()) { setInterval(function () { if (!window.isRemoveSetHeights) SetHeights(); if (stretchContainers) window.dynamicStretchContainers(); }, 2000); } }, 4000); } //Do not execute for WidgetManager, it has a slightly different logic thats handled in WidgetManager code itself. if ($('#hdnWidgetManager').length == 0) { if (typeof rearrangeFlyouts === 'function') { setTimeout(function () { setInterval(function () { rearrangeFlyouts(false); }, 2000); }, 2000); } } window.setTimeout(function () { moveMegaMenusInDOM({ direction: $('#megaMenuPopupDirection').val() }); }, 50); frontEnd_removeAttributesFromGraphicLinks(); if ($('.viewArchiveLink').length > 0) { $('body').addClass('cpViewArchiveOn'); } //workaround to make legacy LE modal to be centered correctly $("body").append($("#ctl00_ctl00_MainContent_ctl00_liveEditPopupWindow")).append($("#editItemBehavior_backgroundElement")); //Workaround to adjust the toolbar dropdowns dynamically based on the .cpToolbar height + some other initialization stuff for Layout. Core.Layout.toggleFeatureColumn(); Core.Layout.attachTabbedWidgetTabHandlers(); //when clicking on error details links onOrLive($("a.errorDetails"), function (e) { e.preventDefault(); $(this).next("div").slideToggle('fast'); }, "click.errorDetails"); onOrLive(onOrLive($("img.imageHover"), function () { $(this).attr('src', $(this).data("hover")); }, "mouseenter.imageHover"), function () { $(this).attr('src', $(this).data("image")); }, "mouseleave.imageHover"); //$("img.imageHover").live("mouseenter.imageHover", function () { // $(this).attr('src', $(this).data("hover")); //}).live("mouseleave.imageHover", function () { // $(this).attr('src', $(this).data("image")); //}); // Setup handlers for My Account toolbar var $Favorites = $('#favoritesList'); var $UserMenu = $('.cpToolbar .userMenu .popOut'); $Favorites.hide(); $UserMenu.hide(); $('a[href="#favoritesList"]').click(function (e) { e.preventDefault(); if ($Favorites.hasClass('open')) { $Favorites.slideUp(200); } else { slideToggle($Favorites, true, 200); } $Favorites.toggleClass('open'); }); $('.cpToolbar .popOutContainer > a').click(function (e) { if ($UserMenu.hasClass('open')) { $UserMenu.slideUp(200); } else { $UserMenu.slideDown(200); } $UserMenu.toggleClass('open'); }); //Authentication onOrLive($('.requireSignIn'), function () { $(this).click(); }, "keypress"); onOrLive($('.requireSignIn'), function (event) { event.preventDefault(); $(this).click(function (event) { event.preventDefault(); }); var $self = $(this); $.ajax({ url: '/Saml/IsSamlLoginEnabled?loginPage=LoginPageMyAccount', type: 'GET', success: function (response) { RequireSignInSuccess(response, $self) }, async: false }); }, "mouseup"); function RequireSignInSuccess(response, $elem) { if (response.IsSamlLoginEnabled) { window.location = '/Admin/Saml/LogonRequest?RelayState=' + window.location.pathname.substring(1); } else { var popupBasedAuthenticationJs = new PopupBasedAuthentication(); popupBasedAuthenticationJs.requireLoggedIn($elem.attr('href'), ''); } } flipHandlesIfNecessary(); $(window).scroll(function () { $('.flipHandles').removeClass('flipHandles'); }); if (location.search.toLowerCase().indexOf('preview=yes') > -1 || location.search.toLowerCase().indexOf('print=yes') > -1) { $('body').addClass('printPreview'); } else { $('body').removeClass('printPreview'); } $('#viewFullWebsiteOnMobile').unbind('click').click(function () { var curDate = new Date(); curDate.setHours(curDate.getHours() + 2); var curDateInUTCStringFormat = curDate.toUTCString(); document.cookie = "forceMobileOff=true; expires=" + curDateInUTCStringFormat + "; path=/"; }); $('#backToMobileView').unbind('click').click(function () { //expire the cookie document.cookie = "forceMobileOff=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/"; }); if ($("iframe").length > 0) { $.getScript('/Assets/Scripts/attrchange.js', function () { $.getScript('/Assets/Scripts/attrchange_ext.js', function () { $("iframe").attrchange({ callback: function (event) { if (!window.isRemoveSetHeights) SetHeights(); } }); }); }); } //Apply classes to parent containers and initialize the stickyStructuralContainers class if (typeof (StickyStructuralContainers) === 'function') { stickyStructuralContainers = new StickyStructuralContainers(); } var liveEditEnabled = getCookieValue("enableLiveEdit") === "true"; if (typeof (Animations) === 'function') { var animations = new Animations(); //If live edit enabled, give it a delay for animation classes to apply properly. if (liveEditEnabled) { setTimeout(function () { animations.Apply(); }, 100); } else { //Apply animation classes and triggers animations.Apply(); } } //Fixes image cache problem on iOS safari if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) { $(".graphicButtonLink").removeAttr("onmouseover"); } onOrLive($('.cp-modificationProhibited'), function () { if ($(this).hasClass('cp-modificationProhibited')) { showWidgetDisabledPopUp(); } }, "click"); onOrLive($('.pageCopyEditWidgetModal'), function () { savePageCopy(); }, "click"); onOrLive($('.closeEditWidgetModal'), function () { closeModal(); }, "click"); onOrLive($('.viewMap, .viewMapAsLink'), function () { executeViewMapPostClickActions($(this)); }, "click"); }); onOrLive($(window), function () { if (stickyStructuralContainers) { stickyStructuralContainers.init(); // Fire resize handlers to recalculate any height adjustments required after sticky container setup. var resizeHandlers = window.Pages && window.Pages.onResizeHandlers || []; resizeHandlers.forEach(function (handler) { handler(); }); } $('[class*="pageloadAnimationTrigger"]').each( function () { $(this).addClass('animation-triggered'); }); setTimeout(function () { //Fix for blank target elements with rel attributes to avoid phishing attack. var blankTargetElements = $("[target='_blank']"); $.each(blankTargetElements, function (index, element) { $(element).attr("rel", "noopener"); }); }, 175); $('body').find('table').removeAttr('border'); $('body').find('table').removeAttr('cellspacing'); $('body').find('table').removeAttr('cellpadding'); }, "load"); function flipHandlesIfNecessary() { $('.widget').unbind('mouseover').mouseover(function (e) { var $this = $(this); var $innerCol = $this.parents('div.inner.col'); if ($innerCol != null && !$innerCol.hasClass('flipHandles') && $('#ysnEnableLiveEdit').is(':checked')) { var $removeHandle = $innerCol.find('.handle.remove'); var $toolbarHeight = $('.cpToolbars').outerHeight(true); var $removeHandleHeight = $removeHandle.outerHeight(); if ($removeHandle.length > 0) { var $removeHandleTop = $removeHandle.offset().top - $(document).scrollTop(); if (parseFloat($toolbarHeight - $removeHandleTop) >= parseFloat($removeHandleHeight / 3)) $innerCol.addClass('flipHandles'); else $innerCol.removeClass('flipHandles'); } } }); } function reinitCarousels() { if (window.carouselsToInit && window.carouselsToInit != undefined) { for (var i = 0; i < window.carouselsToInit.length; i++) { carouselsToInit[i](); } } } function SetHeights() { if ($('body').hasClass('mobile') || $('.pageContent.dragging').length > 1 || !window.Core.performSetHeights) { return; } var originalScrollPosition = $('body').scrollTop(); if (!originalScrollPosition) { originalScrollPosition = $('html').scrollTop(); } // Grow the heights and set them in place. $('.inner.col, .outer.col, .resize, .indicator.vertical, div.widgetSpacer').css('height', 'auto'); var adjustColumnHeights = function () { if (typeof CustomAdjustHeights === 'function') { CustomAdjustHeights(); return; } $('.row.nest.wide').each(function () { var height = $(this).outerHeight(); if (height < 15) { height = 15; } if (!window.FeatureToggles.isActive("CMS.JqueryUpgrade.UpgradeTo224")) { $(this).children('.inner.col, .resize, .indicator.vertical').height(height); } else { $(this).children('.inner.col, .resize, .indicator.vertical').css('height', height + "px"); } }); $('.row.outer.wide:not(.autoWidths)').each(function () { var height = $(this).outerHeight(); if (height < 15) { height = 15; } if (!window.FeatureToggles.isActive("CMS.JqueryUpgrade.UpgradeTo224")) { $(this).children('.outer.col, .resize, .indicator.vertical, .row.nest.first.last > .inner.col') .height(height); $(this).find('.outer.col > .row.nest.first.last > .inner.col').height(height); } else { $(this).children('.outer.col, .resize, .indicator.vertical, .row.nest.first.last > .inner.col') .css('height', height + "px"); $(this).find('.outer.col > .row.nest.first.last > .inner.col').css('height', height + "px"); } }); }; adjustColumnHeights(); var autoWidthRowsHandler = function ($this) { var height = 15; $this.children('.col').each(function () { var columnHeight = $(this).outerHeight(); if (columnHeight > height) { height = columnHeight; } }); $this.find('.indicator.vertical').height(height); }; $('.outer.row.autoWidths.wide').each(function () { autoWidthRowsHandler($(this)); $(this).find('.row').each(function () { autoWidthRowsHandler($(this)); }); }); if (!window.isResponsiveEnabled || getCookieValue("enableLiveEdit") === "true") { $('div.widgetSpacer').each(function () { var $spacer = $(this); var $innerCol = $spacer.parent(), $innerRow = $innerCol.parent(); if ($innerRow.hasClass("first") && $innerRow.hasClass("last")) { var outerRowHeight = $innerRow.parent().parent().height(), innerColPadding = $innerCol.css("padding-top").replace("px", ""), spacerHeight = outerRowHeight - (2 * parseInt(innerColPadding, 10)); $spacer.height(spacerHeight); $innerCol.height(spacerHeight); } else { var innerColHeight = $innerCol.innerHeight(); if (innerColHeight > 30) $spacer.height(innerColHeight); else $spacer.height(30); //default spacer height } }); } adjustColumnHeights(); $('.outer.col').height('auto'); if (!iOSSafari) { $('html,body').scrollTop(originalScrollPosition); } setBannerHeights(); reinitCarousels(); } function frontEnd_removeAttributesFromGraphicLinks() { $('.widgetGraphicLinks li.GraphicLinks > a > img').removeAttr('height').removeAttr('width'); } function closeModalDialog(behaviourID) { var behavior = $find(behaviourID); if (behavior) behavior.hide(); else closeCpModal(); } function SetMegaMenuToOpenAbove() { moveMegaMenusInDOM({ direction: '1' }); } function SetMegaMenuToOpenBelow() { moveMegaMenusInDOM({ direction: '0' }); } function changeModalDialogHeight(height, showDetails) { var ifr = document.getElementById('liveEditDialog'); if (ifr) ifr.style.height = height + 'px'; if (showDetails != '') document.cookie = "showAddDetails=" + showDetails + ";"; } function setModalClassForEditItemBehavior(cssClass, showDetails) { var behaviorID = $find('editItemBehavior'); var modalContainer = document.getElementById(behaviorID._PopupControlID); if (modalContainer) modalContainer.className = 'modalContainer modalContainerCP ' + cssClass; if (showDetails != '') document.cookie = "showAddDetails=" + showDetails + ";"; } function loadStyleSheet(href, id) { var styleSheet = document.createElement('link'); styleSheet.type = 'text/css'; styleSheet.rel = 'stylesheet'; styleSheet.setAttribute('href', href); if (id) { styleSheet.setAttribute('id', id); } var head = document.getElementsByTagName('head')[0]; head.appendChild(styleSheet); } function enableLiveEdit(checked) { var $liveEditTabs = $('#liveEditTabs'); if (checked) { document.cookie = "enableLiveEdit=true; expires=12/31/2999; path=/"; $('.handle').show(); $('#bodyWrapper').removeClass('noTransition'); $('#LiveEditCSS').prop('disabled', false); var versionTitle = $('#versionHeadLine').text(); $('#versionHeadLine').html('Version Options'); $('#versionHeadLine').append('' + versionTitle + ''); $('#versionHeadLineOptionsHandle').unbind().click(function () { versionActions(ContentCollectionInstance.VersionID, 'edit', { "pageID": ContentCollectionInstance.PageID, "versionID": ContentCollectionInstance.VersionID }); }); if ($('#404Content').length > 0 || $('#pagePageID').val() === '') { location.reload(); } else if ($liveEditTabs.length > 0) { redrawContextualInnerToolbar(window.ContentCollectionInstance.PageID, window.ContentCollectionInstance.VersionID); window.ContentCollectionInstance.reloadContent(); InitializeContainers(); setTimeout(window.ContentCollectionInstance.refreshNavContainers, 10); refreshMegaMenusForLiveEdit(); showLiveEditElement($liveEditTabs); if (liveEditTabs.currentState !== 'closed') { liveEditTabs.setBodyPadding(); } } else { $.ajax({ url: '/LiveEditMarkup', type: 'GET', cache: false, async: false, success: function (response) { var $body = $('body'); $body.append(response).addClass('liveEditOn'); loadStyleSheet('/Areas/Pages/Assets/Styles/Home.css'); loadStyleSheet('/Assets/AdminRefresh/LiveEdit/Styles/LiveEdit.css', 'LiveEditCSS'); if (!window.ContentCollectionInstance) { window.ContentCollectionInstance = new ContentCollectionClass(); window.ContentCollectionInstance.init(); } if (!window.ResizeData) { window.ResizeData = new ResizeClass(); } redrawContextualInnerToolbar(window.ContentCollectionInstance.PageID, window.ContentCollectionInstance.VersionID); var moduleID = $('#pageModuleID').val(); if (moduleID == '') { moduleID = 76; } else { moduleID = Number(moduleID); } renderLiveEditTabs(moduleID); window.ContentCollectionInstance.reloadContent(); InitializeContainers(); setTimeout(window.ContentCollectionInstance.refreshNavContainers, 10); refreshMegaMenusForLiveEdit(); }, error: function (xhr, textStatus, exception) { alert("Error: " + xhr.statusText + "\nStatus: " + xhr.status); } }); } triggerStickyStructuralInitLogic(); //no responsive when live edit enabled, so default to wide view $('.widget.narrow').each(function () { var $this = $(this); $this.removeClass('narrow').addClass('wide'); }); $('.tabbedWidgetNarrow.cpTabs:not(.accordion)').hide(); $('.tabbedWidget.cpTabs').show(); Core.Layout.attachTabbedWidgetTabHandlers(); if ($('script:contains("audioeye.com")').length >= 1) { $('script:contains("audioeye.com")').remove(); } } else { document.cookie = "enableLiveEdit=false; expires=12/31/2999; path=/"; $('#liveEditMenu').hide(); setTimeout(window.ContentCollectionInstance.refreshNavContainers, 10); refreshMegaMenusForLiveEdit(); var publishedVersion = $liveEditTabs.length > 0 && $('#hdnVersionStatus').val() === '40'; var isPublishedVersionAndContainsTabbedWidget = publishedVersion && $('.widgetTabbed').length > 0; if (!publishedVersion || isPublishedVersionAndContainsTabbedWidget) location.reload(); $('body.liveEditOn').removeClass('liveEditOn').addClass('liveEditOff'); window.ContentCollectionInstance.reloadContent(null, null, true); loadMediaFramework(); $('#bodyWrapper').attr('style', ''); $('#versionHeadLineOptionsHandle').remove(); $('#versionHeadLine').html($('#versionHeadLine').text()); $('a.editCustomHtml').hide(); hideLiveEditElement($liveEditTabs); hideLiveEditElement($('#innerToolbar')); triggerStickyStructuralInitLogic(); setTimeout(function () { $('#LiveEditCSS').prop('disabled', true); }, 666); //For some reason, loadMediaFramework doesnt load MediaFramework.js on disabling live edit, this forces it to download it again hence fixing a responsive issue. if (window.cpMedia) { window.cpMedia = undefined; var scriptSrc = ''; var script = document.createElement('script'); script.async = false; script.type = 'text/javascript'; scriptSrc = '/Assets/Scripts/RWD/MediaFramework.js'; script.src = scriptSrc; document.body.appendChild(script); } Core.Layout.attachTabbedWidgetTabHandlers(); $.ajax({ url: '/IncludeScript/AudioEyeScript/', type: 'GET', cache: false, async: false, success: function (response) { if (response) { var scriptText = $(response)[2].innerText; var s = document.createElement("script"); s.type = "text/javascript"; s.text = scriptText; document.body.appendChild(s); } }, error: function (xhr, textStatus, exception) { alert("Error: " + xhr.statusText + "\nStatus: " + xhr.status); } }); } //If IE, simply perform location.reload in order to execute _rootfrontend file again to render the IE meta tag according to settings. This tag cannot be //added dynamically, so a reload is required for (https://civicplus.tpondemand.com/entity/29964). if (window.isie) { location.reload(); return; } } function refreshMegaMenusForLiveEdit() { setTimeout(function () { var megaMenuContentContainers = $('[data-displaymegamenu="True"]') .map(function () { $('#mainNavMegaMenu' + $(this).data('pageid') + ' div.pageContent').html('Loading...'); return $('#mainNavMegaMenu' + $(this).data('pageid') + ' div.pageContent').data('containerid'); }).toArray(); window.Pages.megaMenuLoaded.resolve(); reloadSharedContentContainers(megaMenuContentContainers); }, 200); } function showHideUnpublishedItems(checked) { if (checked) { document.cookie = "showAll=true; expires=12/31/2999 23:59:59; path=/"; document.getElementById('ysnLiveEditShowMyActionItems').checked = true; document.getElementById('ysnLiveEditShowMyActionItems').disabled = true; } } function showHideUnpublishedItems(checked) { if (checked) { document.cookie = "showAll=true; expires=12/31/2999 23:59:59; path=/"; document.getElementById('ysnLiveEditShowMyActionItems').checked = true; document.getElementById('ysnLiveEditShowMyActionItems').disabled = true; } else { document.cookie = "showAll=false; expires=12/31/2999 23:59:59; path=/"; document.getElementById('ysnLiveEditShowMyActionItems').checked = false; document.getElementById('ysnLiveEditShowMyActionItems').disabled = false; } showHideActionItems(document.getElementById('ysnLiveEditShowMyActionItems').checked); } function showHideActionItems(checked) { if (checked) document.cookie = "showActionItems=true; expires=12/31/2999 23:59:59; path=/"; else document.cookie = "showActionItems=false; expires=12/31/2999 23:59:59; path=/"; if (typeof redrawContent == 'function') redrawContent(); else location.reload(true); } function showHideLiveEditControl(checked) { if (checked) document.cookie = "showLiveEditControls=true; expires=12/31/2999 23:59:59;"; else document.cookie = "showLiveEditControls=false; expires=12/31/2999 23:59:59;"; //if (typeof redrawContent == 'function' && !$.browser.msie) // redrawContent(); //else location.reload(true); } function disableCustomHtmlRendering(checked) { if (checked) document.cookie = "disableCustomHtmlRendering=true; expires=12/31/2999 23:59:59; path=/"; else document.cookie = "disableCustomHtmlRendering=false; expires=12/31/2999 23:59:59; path=/"; location.reload(true); } // Print preview. function pPreview(mode) { var printStr = 'PREVIEW=YES'; if (mode == 1) printStr = 'PRINT=YES'; var url = document.URL.split("#")[0]; window.open(url + (url.indexOf("?") == -1 ? '?' : '&') + printStr, '_blank'); } function Navigate(txtAction) { if (txtAction.lastIndexOf("&") == txtAction.length - 1) txtAction = txtAction.slice(0, -1); document.frmNavigate.action = txtAction; location.href = txtAction; } function showExternalSiteDialog(anchor) { if ($(anchor).closest('[contenteditable=true]').length) { // Don't do anything for content editables return false; } window.externalUrl = anchor.href; window.externalTarget = anchor.target; openCpModal({ title: 'Leaving Site', className: 'externalLinkDialog', url: '/Common/Modules/LeavingSite/Dialog.aspx', useIframe: true, iframeHeight: '370px', scrolling: true }); return false; } // todo: rename to openModalDialog, to match closeModalDialog function openGenericModalDialog(height, className, title, src) { document.getElementById('ctl00_LiveEditModalTitle').innerHTML = title; behavior = $find('editItemBehavior'); if (behavior) { var ifr = document.getElementById('liveEditDialog'); var target = document.getElementById('ctl00_ctl00_MainContent_ctl00_liveEditPopupWindow'); ifr.src = src; if (className) target.className = 'modalContainer ' + className; if (height) ifr.style.height = height; ifr.style.display = 'block'; behavior.show(); } } function expandCollapseCategory(catID) { if (commonLocalization == null) { commonLocalization = GetJson('/Localization/Index'); } if (document.getElementById(catID).style.display == 'none') { $('#cat' + catID + ' > a').attr('title', commonLocalization.CollapseThisCategory); document.getElementById(catID).style.display = 'block'; document.getElementById('a_' + catID).innerHTML = '▼'; } else { $('#cat' + catID + ' > a').attr('title', commonLocalization.ExpandThisCategory); document.getElementById(catID).style.display = 'none'; document.getElementById('a_' + catID).innerHTML = '►'; } } function slideToggle(element, bShow, duration) { var $el = $(element) , visible = $el.is(":visible"); // if the bShow isn't present, get the current visibility and reverse it if (arguments.length == 1) bShow = !visible; // if the current visiblilty is the same as the requested state, cancel if (bShow == visible) return false; $.each($el, function (i, e) { var $e = $(e); var visible = $e.is(":visible"); var height = $e.show().height(); if (!$e.data("originalHeight")) { $e.data("originalHeight", height); }; if (!visible) $e.hide().css({ height: 0 }); }); // expand the knowledge (instead of slideDown/Up, use custom animation which applies fix) if (bShow) { $.each($el, function (i, e) { $e = $(e); $e.show().animate({ height: $e.data("originalHeight") }, { duration: duration }); }); } else { $el.animate({ height: 0 }, { duration: duration, complete: function () { $el.hide(); } }); } $el.queue(function () { $el.height('auto'); $(this).dequeue(); }); } onOrLive($(window), function () { removeEmptyFeaturedAreas(); //Run these once here since window.load invokes after images are loaded as well in the DOM. This fixes one of the issues where the landscape version of the page on ipad etc has images all messed up //since SetHeights run before the images are loaded in the DOM if (window.isResponsiveEnabled) { if (typeof SetHeights === 'function' && !window.isRemoveSetHeights) SetHeights(); if (typeof dynamicStretchContainers === 'function') dynamicStretchContainers(); } }, "load"); function GetSignIn() { $.get('Services/ForgotPassword.ashx?Username=' + encodeURIComponent(userName), function (data) { if (data == -1) alert($("#Localization_AccountDoesNotExist").val()); else alert($("#Localization_PasswordReminder").val()); }); } function PerformSignIn() { var userName = $('#UserName').val(); var password = $('#Password').val(); var rememberMe = $('#RememberMe').val(); var emailAddress = $('#UserName').val(); var url; $.post('/MyAccount/SignInJson?' + 'UserName=' + userName + '&Password=' + password + '&RememberMe=' + rememberMe + '&EmailAddress=' + emailAddress , function (data) { if (data.status != 1) alert(data.msg); else { if (data.HasAcceptedTerms == true) { url = getParameterByName('url'); url = url == '' ? window.location.href : url; window.location.href = url; } else { window.location.href = '/MyAccount/Terms'; } } }); } function SignIn() { window.location.href = '/MyAccount?from=url&url=' + window.location.pathname + window.location.search; } function SignOut() { (function ($) { $.QueryString = (function (a) { if (a == "") return {}; var b = {}; for (var i = 0; i < a.length; ++i) { var p = a[i].split('='); if (p.length != 2) continue; b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " ")); } return b; })(window.location.search.substr(1).split('&')) })(jQuery); var url = '/publiclogin.aspx?out=true&txtRedirect=' + window.location.pathname.substring(1) + window.location.search; var dn = $.QueryString['dn']; if (dn != undefined) { if (!dn.toLowerCase().startsWith('http')) dn = 'http://' + dn; url = dn + url; } window.location.href = url; } function getParameterByName(name) { var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search); return match && decodeURIComponent(match[1].replace(/\+/g, ' ')); } //Share current page url using common mvc modal (only for mvc modules) function openShareEmailPageModal(subject) { var emailSubject = (subject && subject != '') ? subject : document.title; openCpModal({ type: 'POST', data: { subject: emailSubject }, title: 'Email This Page', className: 'emailPage', url: '/EmailPage/Home/EmailPageModal' }); } function openShareEmailPageModalWithReferrel(subject, urlReferrer) { var emailSubject = (subject && subject != '') ? subject : document.title; openCpModal({ type: 'POST', data: { subject: emailSubject, specificUrlReferrer: urlReferrer }, title: 'Email This Page', className: 'emailPage', url: '/EmailPage/Home/EmailPageModalWithSpecificUrl', elementID: 'mvcModal' }); } //Share current page url redirecting to email page (for legacy pages do not support new mvc modal) function openShareEmailPage(subject) { var emailSubject = (subject && subject != '') ? subject : document.title; window.location.href = '/EmailPage/?subject=' + escape(emailSubject); } //Layout Banners function renderBanner(bannerPlaceHolderID, bannerSlotID, bannerOption, bannerImage, imageFolder, imageTag) { var $bannerSlot = $('#' + bannerSlotID); var $bannerPlaceHolder = $('#' + bannerPlaceHolderID); //render external banner $bannerPlaceHolder.replaceWith(createBannerExternalMarkup($bannerSlot, bannerOption, bannerImage, imageFolder, imageTag)); var stickyContainers = $('div.stickyInnerDiv.sticky'); if (stickyContainers.length > 0) { $('#bodyWrapper .bannerObject.external').css('top', '0'); } setTimeout(function () { if (!window.isRemoveSetHeights) SetHeights(); }, 5500); } function centerImage(parentWidth, parentHeight, imageWidth, imageHeight) { var left = 0; //Adjust width to view port proportionally var proportionRatio = 1; if (imageWidth > parentWidth) { proportionRatio = (imageWidth - parentWidth) / imageWidth; imageHeight -= imageHeight * proportionRatio; } else if (imageWidth < parentWidth) { proportionRatio = (parentWidth - imageWidth) / imageWidth; imageHeight += imageHeight * proportionRatio; } imageWidth = parentWidth; if (imageHeight < parentHeight) { //Readjust Height to view port proportionally proportionRatio = (parentHeight - imageHeight) / imageHeight; imageWidth += imageWidth * proportionRatio; imageHeight = parentHeight; left = -1 * (imageWidth - parentWidth) / 2; //move left to center image } return { imageWidth: imageWidth, imageHeight: imageHeight, left: left }; } function createBannerExternalMarkup($bannerSlot, bannerOption, bannerImage, imageFolder, imageTag) { if (!window.isRemoveSetHeights) SetHeights(); if (typeof window.dynamicStretchContainers === 'function') window.dynamicStretchContainers(); var parentHeight = $bannerSlot.parent().outerHeight(true); var windowHeight = $(window).height(); var imageHeight = bannerImage.Height; var isBackgroundBanner = $bannerSlot.parent().attr("id") == "bodyWrapper" || $bannerSlot.parent().parent().attr("id") == "bodyWrapper"; var left = 0; if (isBackgroundBanner && windowHeight > parentHeight) { parentHeight = windowHeight; } var imageWidth = bannerImage.Width; if (bannerOption.ImageScale) { var parentWidth = $bannerSlot.outerWidth(true); if (isBackgroundBanner) { parentHeight = windowHeight; } var centerValues = centerImage(parentWidth, parentHeight, imageWidth, imageHeight); imageWidth = centerValues.imageWidth; parentHeight = centerValues.imageHeight; left = centerValues.left; } if (bannerImage.FileName.startsWith('/')) { imageFolder = ''; } var $img = (!imageTag) ? $('') : $(imageTag); $img.attr("width", imageWidth + "px"); $img.css("position", "absolute"); switch (bannerOption.ImageAlignment) { case 1: case "Left": $img.css("left", "0"); $img.css("margin", "0"); break; case 2: case "Center": $img.css("left", "50%"); $img.css("margin", "0 0 0 -" + Math.round(bannerImage.Width / 2) + "px"); break; case 3: case "Right": $img.css("right", "0px"); $img.css("margin", "0"); break; } var position = 'position: ' + (bannerOption.ImageScroll ? 'absolute;' : 'fixed;'); var $bodyWrapper = $("#bodyWrapper"); if (!bannerOption.ImageScroll) { left += parseInt($bodyWrapper.css("padding-left"), 10); //workaround for fixed position } var html = '
'; var $html = $(html).append($img); $html.attr('data-image-scale', bannerOption.ImageScale); var oldScreenHeight = screen.height; var oldScreenWidth = screen.width; //bind windows resize event if needed $(window).unbind('resize.banner' + bannerOption.SlotName); if (bannerOption.ImageScale) { $(window).bind('resize.banner' + bannerOption.SlotName, function () { if (screen.height !== oldScreenHeight && screen.width !== oldScreenWidth) { oldScreenHeight = screen.height; oldScreenWidth = screen.width; resize($bannerSlot); } }); } ///private function that takes care of resizing when image scale var resize = function ($bannerSlotContainer) { var parentHeight = $bannerSlotContainer.parent().outerHeight(true); var windowHeight = $(window).height(); var left = 0; if (isBackgroundBanner && windowHeight > parentHeight) { parentHeight = windowHeight; } var imageWidth = bannerImage.Width; if (bannerOption.ImageScale) { var parentWidth = $bannerSlotContainer.outerWidth(true); if (isBackgroundBanner) { parentHeight = windowHeight; } var centerValues = centerImage(parentWidth, parentHeight, imageWidth, imageHeight); imageWidth = centerValues.imageWidth; parentHeight = centerValues.imageHeight; left = centerValues.left; } if (!bannerOption.ImageScroll) { left += parseInt($bodyWrapper.css("padding-left"), 10); //workaround for fixed position } $html.css("left", left); $html.find('img.bannerObject').width(imageWidth); $html.css("min-height", parentHeight + "px"); }; window.Pages = window.Pages || {}; window.Pages.Banners = window.Pages.Banners || {}; $(window.Pages.Banners).bind('ExternalBannersResize', function () { resize($bannerSlot); }); // resize external banners if (jQuery.resize) { $bannerSlot.children(":not(.bannerObject, script)").unbind("resize").bind("resize", function () { $(window.Pages.Banners).trigger('ExternalBannersResize'); }); } if (bannerOption.ImageScale) { window.Pages.onResizeHandlers = window.Pages.onResizeHandlers || []; window.Pages.onResizeHandlers.push(function () { $(window.Pages.Banners).trigger('ExternalBannersResize'); }); } setTimeout(function () { if (!window.isRemoveSetHeights) SetHeights(); }, 8000); return $html; }; function setBannerHeights() { $('div.bannerObject.external').each(function () { var $this = $(this); var isBackgroundBanner = $this.parent().attr("id") == "bodyWrapper" || $this.parent().parent().attr("id") == "bodyWrapper"; var parentHeight = parentHeight = $this.parent().outerHeight(true); var windowHeight = $(window).height(); if (isBackgroundBanner && windowHeight > parentHeight) { parentHeight = windowHeight; } if ($this.attr('data-image-scale') === "true") { $this.css('min-height', $this.find('img').height()); } else { $this.css('min-height', parentHeight); } }); } //Creates slideshow markup for external banners. function createBannerExternalMarkupForSlideshow($bannerSlot, bannerOption, imageFolder, bannerImagesJSON, bannerMode, rotatingSequence) { if (!window.isRemoveSetHeights) SetHeights(); if (typeof window.dynamicStretchContainers === 'function') window.dynamicStretchContainers(); var parentHeight = $bannerSlot.parent().outerHeight(true); var parentWidth = $bannerSlot.outerWidth(true); var windowHeight = $(window).height(); var isBackgroundBanner = $bannerSlot.parent().attr("id") == "bodyWrapper" || $bannerSlot.parent().parent().attr("id") == "bodyWrapper"; var greaterImageWidth = 0, greaterImageHeight = 0; var left = 0; if (isBackgroundBanner && windowHeight > parentHeight) { parentHeight = windowHeight; } var img = ''; for (var i = 0; i < bannerImagesJSON.length; i++) { var bannerImage = bannerImagesJSON[i]; var imageWidth = bannerImagesJSON[i].Width; if (imageWidth > greaterImageWidth) greaterImageWidth = imageWidth; if (bannerImagesJSON[i].Height > greaterImageHeight) greaterImageHeight = bannerImagesJSON[i].Height; var alignmentCss = ""; switch (bannerOption.ImageAlignment) { case 1: case "Left": alignmentCss += 'left: 0; margin: 0;'; break; case 2: case "Center": alignmentCss += ' left: 50%; margin: 0 0 0 -' + Math.round(bannerImage.Width / 2) + 'px;'; break; case 3: case "Right": alignmentCss += ' right: 0px; margin: 0;'; break; } if (bannerOption.ImageScale) { imageWidth = parentWidth; } var tempImageFolder = imageFolder; if (bannerImagesJSON[i].FileName.startsWith('/')) { tempImageFolder = ''; } if (bannerMode === 'Slideshow') { if (i > 0) { img += ''; } else { img += ''; } } else if (bannerMode === 'Rotating') { if (rotatingSequence < 0) { rotatingSequence = 0; } var rotSeqLessOne = rotatingSequence === 0 ? bannerImagesJSON.length - 1 : rotatingSequence - 1; var rotSeqPlusOne = rotatingSequence === bannerImagesJSON.length - 1 ? 0 : rotatingSequence + 1; if (bannerOption.SlideshowControlsPosition === 0 || bannerOption.SlideshowControlsPosition === 'None') { if (i === rotatingSequence) { img += ''; } } else { if (i === rotSeqLessOne || i === rotatingSequence || i === rotSeqPlusOne) { img += ''; } else { img += ''; } } } } var position = 'position: ' + (bannerOption.ImageScroll ? 'absolute;' : 'fixed;'); var $bodyWrapper = $("#bodyWrapper"); if (!bannerOption.ImageScroll) { left += parseInt($bodyWrapper.css("padding-left"), 10); //workaround for fixed position } var html = '
' + img + '
'; var $html = $(html); $html.attr('data-image-scale', bannerOption.ImageScale); ///private function that takes care of resizing when image scale var resize = function ($bannerSlotContainer) { var parentHeight = $bannerSlotContainer.parent().outerHeight(true); var windowHeight = $(window).height(); var left = 0; if (isBackgroundBanner && windowHeight > parentHeight) { parentHeight = windowHeight; } var imageWidth = greaterImageWidth; if (bannerOption.ImageScale) { var parentWidth = $bannerSlotContainer.outerWidth(true); if (isBackgroundBanner) { parentHeight = windowHeight; } var centerValues = centerImage(parentWidth, parentHeight, imageWidth, greaterImageHeight); imageWidth = centerValues.imageWidth; parentHeight = centerValues.imageHeight; left = centerValues.left; } if (!bannerOption.ImageScroll) { left += parseInt($bodyWrapper.css("padding-left"), 10); //workaround for fixed position } $html.css("left", left); $html.find('img.bannerObject').width(imageWidth); $html.css("min-height", parentHeight + "px"); }; var displayArrows = function ($bannerSlotContainer) { var $bannerSlideshowControls = $('#bannerSlideshowControls_' + $bannerSlotContainer[0].id); var windowWidth = $(window).width(); if ($bannerSlideshowControls.length > 0 && windowWidth < 416) { $bannerSlideshowControls.hide(); $html.removeClass('fixedBanner'); } else if ($bannerSlideshowControls.length > 0 && windowWidth >= 416 && !$bannerSlideshowControls.hasClass("none")) { $bannerSlideshowControls.show(); $html.addClass('fixedBanner'); } } //bind windows resize event if needed $(window).unbind('resize.banner' + bannerOption.SlotName); if (bannerOption.ImageScale) { window.Pages.onResizeHandlers = window.Pages.onResizeHandlers || []; window.Pages.onResizeHandlers.push(function () { resize($bannerSlot); }); resize($bannerSlot); } window.Pages.onResizeHandlers = window.Pages.onResizeHandlers || []; window.Pages.onResizeHandlers.push(function () { displayArrows($bannerSlot); }); var $bannerSlideshowControls = $('#bannerSlideshowControls_' + $bannerSlot[0].id); if ($bannerSlideshowControls.length > 0) { $html.addClass('fixedBanner'); } return $html; }; //Render Slideshow for External banners. function renderExternalBannerSlideshow(bannerSlotID, bannerOption, imageFolder, bannerMode, rotatingSequence) { var bannerImagesJSON = bannerOption.BannerImages; if (!bannerOption.SlideShowSlideTiming) { bannerOption.SlideShowSlideTiming = 1; } if (!bannerOption.SlideShowTransitionTiming) { bannerOption.SlideShowTransitionTiming = 1; } var slideTransitionTiming = parseFloat(bannerOption.SlideShowSlideTiming) * 1000; var transitionTiming = parseFloat(bannerOption.SlideShowTransitionTiming) * 1000; var $bannerSlot = $('#' + bannerSlotID); var imagesHtml = createBannerExternalMarkupForSlideshow($bannerSlot, bannerOption, imageFolder, bannerImagesJSON, bannerMode, parseInt(rotatingSequence)); var $imagesHtml = $(imagesHtml); $imagesHtml.insertAfter($('#bannerImagesJSON' + bannerOption.BannerOptionID)); var images = null; if (window.FeatureToggles.isActive("CMS.JqueryUpgrade.UpgradeTo224") && $('#hdnModuleEligibleForJquery224Upgrade').val() == "true") images = $('div#bannerDiv' + bannerSlotID).find('img.bannerObject'); else { images = $('div.#bannerDiv' + bannerSlotID).find('img.bannerObject'); } if (bannerOption.SlideshowTransition == '1') // 1 corresponds to "none" { transitionTiming = 0; // A 0 transition time is the same as no transition. } //Moves banner controls to the body level of the DOM to avoid layout issues with z-index if ($('.bannerSlideshowControlsNew.centered.container').length > 0) { var $banner = $('#' + bannerSlotID); $banner.prepend($('#bannerSlideshowControls_' + bannerSlotID)); } else { $(document.body).append($('#bannerSlideshowControls_' + bannerSlotID)); } var ss = new SimpleSlideshow(images, transitionTiming, slideTransitionTiming, bannerMode, parseInt(rotatingSequence)); } function SimpleSlideshow($images, transitionTime, slideTime, bannerMode, rotatingSequence) { "use strict"; var slideshowRef = this; var $imageToBeShown = null; var $currentImage = null; var $nextImage = null; var $previousImage = null; //Setting the imageToShowIndex = -1 make sure that the 1st image showing in the slideshow is the 1st image in the slideshow. var imageToShowIndex = -1; var nextImageIndex = -1; var previousImageIndex = 0; var paused = false; var numberOfImages = $images.length; var onLoad = false; //Setting imageToShowIndex as the next rotating sequence if slideshow enhancements are enabled and option is refreshing if (bannerMode === 'Rotating' && numberOfImages > 1) { imageToShowIndex = rotatingSequence - 1; onLoad = true; } var DEBUG = false; var diag = function (msg) { if (DEBUG) { console.log('[Simple Slideshow] ' + msg); } }; slideshowRef.autoFadeNext = function () { if (!paused && bannerMode == 'Slideshow') { slideshowRef.goToNext(); } }; slideshowRef.goToNext = function () { imageToShowIndex = imageToShowIndex >= (numberOfImages - 1) ? 0 : imageToShowIndex + 1; previousImageIndex = imageToShowIndex == 0 ? numberOfImages - 1 : imageToShowIndex - 1; nextImageIndex = imageToShowIndex < numberOfImages - 1 ? imageToShowIndex + 1 : 0; $imageToBeShown = $($images[imageToShowIndex]); $nextImage = $($images[nextImageIndex]); if ($nextImage.data('is-delayed') == true) { $nextImage.attr('src', $nextImage.data('delayed-image')); (new Image()).src = $nextImage.data('delayed-image'); $nextImage.data('is-delayed', 'false'); $nextImage.data('delayed-image', ''); } $currentImage = $($images[previousImageIndex]); diag('Automatic transition next. Image To Show Index: ' + imageToShowIndex + ', Previous Image Index: ' + previousImageIndex); slideshowRef.sendBehindFront($imageToBeShown).show(); if (!onLoad) { if (numberOfImages == 1) { slideshowRef.sendToFront($currentImage).show(); } else if (numberOfImages > 1) { slideshowRef.sendToFront($currentImage) .show() .fadeOut(transitionTime, function () { diag('Fade out.'); setTimeout(slideshowRef.autoFadeNext, slideTime); }); } } }; slideshowRef.goToPrevious = function () { imageToShowIndex = imageToShowIndex == 0 ? numberOfImages - 1 : imageToShowIndex - 1; previousImageIndex = imageToShowIndex == 0 ? numberOfImages - 1 : imageToShowIndex - 1; nextImageIndex = imageToShowIndex < numberOfImages - 1 ? imageToShowIndex + 1 : 0; $imageToBeShown = $($images[imageToShowIndex]); $previousImage = $($images[previousImageIndex]); if ($previousImage.data('is-delayed') == true) { $previousImage.attr('src', $previousImage.data('delayed-image')); (new Image()).src = $previousImage.data('delayed-image'); $previousImage.data('is-delayed', 'false'); $previousImage.data('delayed-image', ''); } $currentImage = $($images[nextImageIndex]); diag('Automatic transition next. Image To Show Index: ' + imageToShowIndex + ', Previous Image Index: ' + nextImageIndex); slideshowRef.sendBehindFront($imageToBeShown).show(); slideshowRef.sendToFront($currentImage) .show() .fadeOut(transitionTime, function () { diag('Fade out.'); setTimeout(slideshowRef.autoFadeNext, slideTime); }); }; this.pause = function () { paused = true; } this.sendToFront = function ($image) { $image.css('z-index', '3'); return $image; }; this.sendBehindFront = function ($image) { $image.css('z-index', '2'); return $image; }; window.setTimeout(function () { slideshowRef.autoFadeNext(); }, 500); if (bannerMode == 'Rotating' && numberOfImages > 1) { this.goToNext(); } var disabledNext = false; var disabledPrevious = false; $('a[id*="arrowNext_"],button[id*="arrowNext_"]').click(function (e) { if (disabledNext) { e.preventDefault(); return false; } slideshowRef.pause(); slideshowRef.goToNext(); disabledNext = true; setTimeout(function () { disabledNext = false; }, 1000); e.preventDefault(); }); $('a[id*="arrowPrev_"],button[id*="arrowPrev_"]').click(function (e) { if (disabledPrevious) { e.preventDefault(); return false; } slideshowRef.pause(); slideshowRef.goToPrevious(); disabledPrevious = true; setTimeout(function () { disabledPrevious = false; }, 1000); e.preventDefault(); }); onLoad = false; } //External banner for videos function renderBannerVideo(bannerPlaceHolderID, bannerSlotID, bannerVideo, videoTag) { if (bannerVideo == null) return; var $bannerSlot = $('#' + bannerSlotID); var $bannerPlaceHolder = $('#' + bannerPlaceHolderID); var isBackgroundBanner = $bannerSlot.parent().attr("id") == "bodyWrapper" || $bannerSlot.parent().parent().attr("id") == "bodyWrapper"; var html = '
'; var $html = $(html); // Inserting html elements before resizing because they need to be on DOM beforehand. $bannerPlaceHolder.after($html); // Workaround. videotag needs to be added with jquery html() function in order to prevent issues with cache JQuery version has $bannerPlaceHolder.next().html(videoTag); ///private function that takes care of resizing for video var resize = function ($bannerSlotContainer) { var parentHeight = $bannerSlotContainer.parent().outerHeight(true); var windowHeight = $(window).height(); var left = 0; if (isBackgroundBanner && windowHeight > parentHeight) { parentHeight = windowHeight; } var videoHeight = bannerVideo.VideoHeight; var videoWidth = bannerVideo.VideoWidth; //by default video will always scale var parentWidth = $bannerSlotContainer.outerWidth(true); if (isBackgroundBanner) { parentHeight = windowHeight; } var centerValues = centerImage(parentWidth, parentHeight, videoWidth, videoHeight); videoWidth = centerValues.imageWidth; parentHeight = centerValues.imageHeight; left = centerValues.left; var $html = $bannerPlaceHolder.next(); $html.css("left", left); $html.find('video').css("width", videoWidth + "px"); $html.find('img').css("width", videoWidth + "px"); $html.css("min-height", parentHeight + "px"); }; //bind windows resize event if needed $(window).unbind('resize.banner' + bannerSlotID); window.Pages.onResizeHandlers = window.Pages.onResizeHandlers || []; window.Pages.onResizeHandlers.push(function () { resize($bannerSlot); }); //adjust resize first time resize($bannerSlot); } //removes empty feature areas function removeEmptyFeaturedAreas() { $('div[id^="featureArea"]').each(function () { if ($(this).html().trim() == "") { $(this).parent().css("display", "none"); } }); $('div[id^="featureContent"]').each(function () { if ($(this).html().trim() == "") { $(this).css("display", "none"); } }); } function setWidgetServiceHovering($widgetHeader, bindKeyPress, additionalLogic) { if (window.isMobileBrowserIncludingTablets) { setWidgetServiceClicking($widgetHeader, bindKeyPress, additionalLogic); return; } var $widgetBody = $widgetHeader.next(); var $parent = $widgetHeader.parent(); var timeOutID = null; var hideDelay = 400; var showDelay = 300; $widgetHeader.bind("mouseenter.services", function () { clearTimeout(timeOutID); timeOutID = setTimeout(function () { if (!$widgetBody.is(':visible')) adjustFlyoutPosition($parent, $widgetBody); $widgetBody.show(); additionalLogic(); }, showDelay); }); $widgetHeader.bind("mouseleave.services", function () { clearTimeout(timeOutID); timeOutID = setTimeout(function () { $widgetBody.hide(); additionalLogic(); }, hideDelay); }); $widgetBody.children().bind("mouseenter.services", function () { clearTimeout(timeOutID); timeOutID = setTimeout(function () { if (!$widgetBody.is(':visible')) adjustFlyoutPosition($parent, $widgetBody); $widgetBody.show(); additionalLogic(); }, showDelay); }); $widgetBody.children().bind("mouseleave.services", function () { clearTimeout(timeOutID); timeOutID = setTimeout(function () { $widgetBody.hide(); additionalLogic(); }, hideDelay); }); if (bindKeyPress) { $widgetHeader.unbind("keypress").bind("keypress", function (e) { if (e.which === 13) { $widgetHeader.trigger("mouseenter.services"); } }); } } function setWidgetServiceClicking($widgetHeader, bindKeyPress, additionalLogic) { var $widgetBody = $widgetHeader.next(); var $parent = $widgetHeader.parent(); var click = function (e) { e.stopPropagation(); e.preventDefault(); //If the Flyout is for a megamenu, add a class of forMegaMenu. if ($widgetHeader.parents('.megaMenu').length > 0) $widgetBody.addClass('forMegaMenu'); if (!$widgetBody.is(':visible')) adjustFlyoutPosition($parent, $widgetBody); $widgetBody.toggle(); if (!window.isRemoveSetHeights) SetHeights(); additionalLogic(); }; $widgetHeader.unbind("click").bind("click", click); if (bindKeyPress) { $widgetHeader.unbind("keypress").bind("keypress", function (e) { if (e.which === 13) { click(e); } }); } } function setWidgetSearchClicking($widgetHeader) { var $widgetBody = $widgetHeader.next(); $widgetHeader.unbind("click").bind("click", function (e) { e.stopPropagation(); e.preventDefault(); $widgetBody.toggle(); if (!window.isRemoveSetHeights) SetHeights() }); } //removes empty feature content areas for IE7 function removeEmptyFeaturedAreas() { $('div[class^="html5aside"]').each(function () { if ($(this).html().trim() === "") { $(this).remove(); } }); } //Usage: Core.Layout.attachTabbedWidgetTabHandlers(); LayoutClass.prototype.attachTabbedWidgetTabHandlers = function () { window.Pages.tabChangeHandlers = window.Pages.tabChangeHandlers || []; // Hiding all panels, then showing the first one $('.tabbedWidget.cpTabPanel').hide(); $('.tabbedWidget.cpTabPanel.showing').show(); $('.tabbedWidget.cpTabs, .tabbedWidgetNarrow.cpTabs').each(function (e) { var $tabs = $(this); // When a tab is clicked $tabs.find('li:not(.newTab) > a').unbind('click').click(function (e) { e.preventDefault(); var $selectedTab = $(this); var selectedTabHref = attrOrProps($selectedTab, 'href'); var hashTabOffset = selectedTabHref.indexOf('#'); var target = selectedTabHref.slice(hashTabOffset); var anchor = this; var $target = $('div' + target); var $targetli = $selectedTab.parent(); var isNarrow = $selectedTab.parent().parent().hasClass('tabbedWidgetNarrow'); var isAccordion = $selectedTab.parent().parent().hasClass('accordion'); var $parentTab = $selectedTab.parent().parent().parent(); var tabAriaAttribute = isAccordion ? "aria-expanded" : "aria-selected"; var showTab = function () { $target.addClass('showing').slideDown(function () { doAfterSwitchingTabs($target); if (document.body.classList.contains("narrow")) { anchor.scrollIntoView({behavior: "smooth", block: "start", inline: "nearest"}); } }).css({'overflow': ''}); } // Checking to see if it's showing already if (!$target.hasClass('showing') || isAccordion === true) { // Making the current tab inactive, and the new one active var $widget = $selectedTab.parents('.widget.widgetTabbed'); if(isAccordion === false) { if ($widget.hasClass('narrow')) { $selectedTab.parent().parent().siblings('ol').find('li.active').removeClass('active'); $selectedTab.parent().parent().siblings('ol').find('a[' + tabAriaAttribute + '="true"]').attr(tabAriaAttribute, "false") } else { $parentTab.children().first().find('li.active').removeClass('active'); $parentTab.children().first().find('a[' + tabAriaAttribute + '="true"]').attr(tabAriaAttribute, "false") } } var tabButton = $widget.find('a[href="' + target + '"]'); if (isNarrow && isAccordion === false) { tabButton.attr(tabAriaAttribute, "true"); tabButton.parent().addClass('active'); } // Hiding the current panel, showing the new one if (!isNarrow) { tabButton.attr(tabAriaAttribute, "true"); tabButton.parent().addClass('active'); $target.siblings('.showing').removeClass('showing').hide(); $target.addClass('showing').show(); doAfterSwitchingTabs($target); } else { if(isAccordion === false) { $target.siblings('.showing').removeClass('showing').slideUp(); showTab(); } else { if ($targetli.hasClass('active')) { $targetli.removeClass('active'); $targetli.find("a").attr(tabAriaAttribute, "false"); } else { $targetli.addClass('active'); $targetli.find("a").attr(tabAriaAttribute, "true"); } $target.hasClass('showing') ? $target.removeClass('showing').slideUp() : showTab(); } } var $arr = ($target).contents().find('.videoPlayer'); if ($arr.length > 0) { ($target).contents().find('.videoPlayer').children('iframe').trigger('onload'); } } //Checking any on tab change handlers were added if (window.Pages.tabChangeHandlers.length > 0) { window.Pages.tabChangeHandlers.forEach(function (car) { car(); }); } }); }); $('.nextAction.tabName').unbind('click').click(function (e) { e.preventDefault(); }); $.fn.hasData = function (prop) { return this.filter( function () { return $(this).data(prop) != null; } ); }; var doAfterSwitchingTabs = function ($target) { fireMediaQueriesIfNeeded($target); if (!window.isRemoveSetHeights) SetHeights(); }; }; LayoutClass.prototype.debouncedStyleSheetUpdate = (function () { var writeStylesTimeouts = {}; var DEBUG = false; var diag = DEBUG && console && console.log ? function (msg) { console.log('[Debounced Stylesheet Update] ' + msg); } : function () { }; // Original Function We are Debouncing to update stylesheet. var updateStylesheet = function (styleSheetID, styles, isEditor) { diag('Debounced Call'); var styleSheet = document.getElementById(styleSheetID); isEditor = isEditor === undefined ? false : isEditor; if (!isEditor) { //Include misc styles from Theme properties. if ($('#hdnThemePropertiesMiscStyles').length > 0 && $('#hdnThemePropertiesMiscStyles').html() != '') styles += $('#hdnThemePropertiesMiscStyles').html(); } if (styleSheet == null) { styleSheet = document.createElement('style'); styleSheet.id = styleSheetID; styleSheet.setAttribute('type', 'text/css'); var head = document.getElementsByTagName('head')[0]; head.appendChild(styleSheet); } if (styleSheet.styleSheet) { styleSheet.styleSheet.cssText = styles; //IE only } else { styleSheet.innerHTML = styles; } }; return function (styleSheetID, styles) { diag('Bounce Call'); if (writeStylesTimeouts[styleSheetID]) { clearTimeout(writeStylesTimeouts[styleSheetID]); } writeStylesTimeouts[styleSheetID] = setTimeout(function () { updateStylesheet(styleSheetID, styles); }, 100); }; }()); LayoutClass.prototype.updateStylesheet = function (styleSheetID, styles) { this.debouncedStyleSheetUpdate(styleSheetID, styles); }; //Usage: Core.Layout.toggleFeatureColumn(); LayoutClass.prototype.toggleFeatureColumn = function () { if ($('#pageShowFeatureColumn').val() == 'True') { $('body').addClass('withFeatureColumn'); $('#featureColumn').show(); } else { $('body').removeClass('withFeatureColumn'); $('#featureColumn').hide(); } if (typeof SetHeights == 'function' && !window.isRemoveSetHeights) { SetHeights(); } }; //Usage: Core.Layout.stretchContainers(containerSelectors); LayoutClass.prototype.stretchContainers = function (containerSelectors) { this.unstretchContainers(containerSelectors); $(containerSelectors).each(function () { var $container = $(this); var height = $container.outerHeight(); $container.siblings().each(function () { var $sibling = $(this); if ($sibling.css('float') != 'none') { var siblingHeight = $sibling.outerHeight(); height = siblingHeight > height ? siblingHeight : height; } }); if (height >= ($container.outerHeight())) { var desiredContainerHeight = height; var $innermostWrapper = $container; //The paddings of the container itself needs to be considered as well since we allow for paddings on the structural containers too. //This fixes the height issues we have been having with several sites(neighboring containers dont match height) Vishal var $wrappers = $innermostWrapper; while ($innermostWrapper.children('.inner').length) { $wrappers = $wrappers.add($innermostWrapper.children('.inner')); $innermostWrapper = $innermostWrapper.children('.inner'); } var paddingHeight = 0; $wrappers.each(function () { $this = $(this); paddingHeight += parseFloat($this.css('paddingTop')) + parseFloat($this.css('paddingBottom')) + parseFloat($this.css('borderBottomWidth')) + parseFloat($this.css('borderTopWidth')); }); var calculatedHeight = desiredContainerHeight - paddingHeight; var heightString = calculatedHeight.toString() + 'px'; $innermostWrapper.css('min-height', heightString); } }); setTimeout(function () { if (!window.isRemoveSetHeights) SetHeights(); }, 8000); }; //Usage: Core.Layout.unstretchContainers(containerSelectors); LayoutClass.prototype.unstretchContainers = function (containerSelectors) { $(containerSelectors).each(function () { var $container = $(this); $container.css('min-height', '0'); $('.inner', $container).css('min-height', '0'); }); }; //Usage: Core.Layout.dynamicJavascript(javaScriptCode); LayoutClass.prototype.dynamicJavascript = function (javaScriptCode) { var code = javaScriptCode.replace(/\\'/g, "'").replace(/\\\"/g, "\"").replace(/\\\t/g, "\t").replace(/\\\r/g, "\r").replace(/\\\n/g, "\n").replace(/\\\f/g, "\f").replace(/\\\\/g, "\\"); var myFucn = new Function(code); myFucn(); }; //Usage: Core.Layout.setColumnWidth($widget); LayoutClass.prototype.setColumnWidth = function ($widget) { var width = $('input.auto.update.widgetOption.common[name=WidgetWidth]').val(); $widget.closest('div.outer.col').css('width', width ? width + '%' : ""); }; function LayoutClass() { this.filter = null; } if (!window.Core.Layout) { window.Core.Layout = new LayoutClass(); } // Handles polling login status after ajax requests lazily, and notifying the user if they should be notified. // The whole intention of this block of code is to alert the user they aren't logged in after executing an AJAX request // without colliding with other AJAX requests or affecting user experience. This is only done if the user is initially logged in. $(function () { var DEBUG = false; var diag = function (msg) { if (DEBUG) { console.log("[Send User Home If Logged Out] " + msg); } }; // We want to be able to start/load this at a specific time (after all of the initial ajax calls complete) so I wrapped it in a function. var isLoggedInModule = function () { "use strict"; diag('Initializing Send User Home If Logged Out module.'); var ns = this; var notLoggedInMessage = 'You are no longer logged in. Please login to continue.'; var loginCheckPending = false; if (window.FeatureToggles.isActive("CMS.JqueryUpgrade.UpgradeTo224") && $('#hdnModuleEligibleForJquery224Upgrade').val() == "true") { ns.initiallyLoggedInWithLiveEdit = $('[href="#liveEditMenu"]').hasClass('on'); } else { ns.initiallyLoggedInWithLiveEdit = $('[href=#liveEditMenu]').hasClass('on'); } if (!ns.initiallyLoggedInWithLiveEdit) { diag('Initialization Stopped - Not initially logged in with Live Edit On.'); return; // We don't need to notify them they aren't logged in, if they aren't logged in initially. } $.ajaxSetup({ beforeSend: function () { ns.isAjaxOccuring = true; }, complete: function () { diag('Ajax Call Completed (hook) - ' + (loginCheckPending ? 'Login Check is Pending.' : 'Login Check is not already Pending.')); ns.isAjaxOccuring = false; // If an ajax call is already occuring wait until it is finished. We don't want to affect the user experience with normal AJAX calls. if (!loginCheckPending) { lazyExecute( alertIfUserNotLoggedIn, function () { return !ns.isAjaxOccuring; }, 2000 ); } } }); // Executes a function based on a condition lazily, checking a given predicate at a set interval. var lazyExecute = function (fn, executeWhenPredicate, pollingTime) { diag('Lazy Execution Triggered.'); loginCheckPending = true; var intervalExecuter = null; var internalHandler = function () { diag('Attempting to execute login check.'); if (executeWhenPredicate()) { fn(); clearInterval(intervalExecuter); diag('Login check is no longer pending. Login check invoked.'); loginCheckPending = false; } else { diag('AJAX request in progress. Trying again in a short bit.'); } }; intervalExecuter = setInterval(internalHandler, pollingTime); } var alertIfUserNotLoggedIn = function () { if (!isUserLoggedIn()) { alert('You are no longer logged in. Please login to continue.'); location.href = '/myaccount?from=url&url=' + window.location.pathname; } } } // We don't need to start checking if the user is logged in until after everything is probably loaded. I went with 10 seconds setTimeout(isLoggedInModule, 6000); }); //Begin Authentication if (!window.location.origin) { window.location.origin = window.location.protocol + "//" + window.location.host; } function popupSignIn(redirectUrl, parameterSet, jsCallback) { var popupBasedAuthenticationJs = new PopupBasedAuthentication(); popupBasedAuthenticationJs.setupJsCallback(jsCallback); popupBasedAuthenticationJs.requireLoggedIn(redirectUrl, parameterSet); }; function internetExplorerMessagingHandlerForPopup(data) { var popupBasedAuthenticationJs = new PopupBasedAuthentication(); popupBasedAuthenticationJs.internetExplorerMessageHandling(data); }; ///Matches the rest of the tab's height with the highest tab in a tabbed widget. function setTabbedWidgetsTabHeight(tabWrapperID) { if (tabWrapperID == null || typeof tabWrapperID == 'undefined') { $('.tabbedWidget.cpTabs').not('.left,.right').each(function (e) { var $this = $(this); $this.find('li').each(function () { var $thisLi = $(this); if ($thisLi.css('height') != '0px') $thisLi.find('a').css('height', $thisLi.css('height')); }) }); } else { var $wrapper = $('#' + tabWrapperID); $wrapper.find('ol.tabbedWidget.cpTabs').not('.left,.right').find('li').each(function () { var $thisLi = $(this); if (!$thisLi.is(':hidden')) { if ($thisLi.css('height') != '0px') $thisLi.find('a').css('height', $thisLi.css('height')); } }); } } var internetExplorerVersion = (function () { var undef; var agent = navigator.userAgent; var reg = /MSIE\s?(\d+)(?:\.(\d+))?/i; var matches = agent.match(reg); if (matches != null) { return matches[1]; } return undef; }()); //End authentication /******************************************************************************** Logic for moving mega menus in DOM and updating their attributes. /*******************************************************************************/ function moveMegaMenusInDOM(data) { //Grab all the flyouts that are not moved yet and are not tooltips and not in WidgetManager var $megaMenus = $('.megaMenuContainer').not('.moved'); var $megaMenusAlreadyMoved = $('.megaMenuContainer.moved'); var parentID; var marginLeft, marginTop; $megaMenus.each(function (e) { $(this).appendTo('body'); $(this).addClass('moved').addClass('megaMenu'); $(this).css('position', 'absolute'); $(this).css('z-index', '100'); updateMegaMenuAttributes($(this), data); }); $megaMenusAlreadyMoved.each(function (e) { updateMegaMenuAttributes($(this), data); }); } function updateMegaMenusOnBrowserResize() { var $megaMenus = $('.megaMenuContainer'); $megaMenus.each(function () { updateMegaMenuAttributes($(this)); }); } function updateMegaMenuAttributes($this, data) { //Enums var MegaMenuWidthReferenceEnum = { MainNavigation: 0, SitesContent: 1 }; var MegaMenuPopupDirectionEnum = { Below: 0, Above: 1 }; var widthReference = $('#megaMenuWidthReference').val(); var direction = $('#megaMenuPopupDirection').val(); //If data has been provded, use it!. if (data != null) { if (data.widthReference != null) widthReference = data.widthReference; if (data.direction != null) direction = data.direction; } //Get the main nav. var $mainNav = $('.siteNav.mainNav'); //Get the closest parent having a siteWrap class. var $siteWrap = $mainNav.closest('.siteWrap'); var $referenceElem = null; if (widthReference == MegaMenuWidthReferenceEnum.MainNavigation) $referenceElem = $mainNav; else $referenceElem = $siteWrap; if ($referenceElem != null && $referenceElem.length > 0) { //Set left position of megamenu $this.css('left', $referenceElem.offset().left + parseFloat($referenceElem.css('padding-left'))); //Set width of megamenu $this.css('width', $referenceElem.width()); } if (direction == null || direction == MegaMenuPopupDirectionEnum.Below) { //Set top position of megamenu. //NOTE: Even if the widthReference is set to SitesContent, the top position is calculated always using siteNav.mainNav since thats where the megamenu needs to be displayed. //The siteWrap is some scenarios contains all the content pushing the megamnus to show even below the footer. Vishal $this.css('top', $mainNav.offset().top + $mainNav.height()); } else { //Set top position of megamenu $this.css('top', '-' + ($this.height() - $('#divToolbars').height()) + 'px'); } } function adjustMegaMenuDisplay(widthReference, direction) { var $megaMenu = $('#sampleMegaMenu'); updateMegaMenuAttributes($megaMenu, { widthReference: widthReference, direction: direction }); } /******************************************************************************** Logic for moving mega menus in DOM and updating their attributes. /*******************************************************************************/ /*********************************************************************************************************** Common editor rendering functions used in multiple widgets(editor and InfoAdvanced so far) /**********************************************************************************************************/ function renderSlideshowIfApplicable($element) { var $slideshow = $element.find('.cpSlideshowImages'); $slideshow.each(function (e) { var $this = $(this); var imgWidth = $this.attr('data-width'); var className = $this.attr('class'); var id = $this.attr('id'); var html = getSlideshowContent(id); $this.replaceWith(html); // Froala specific data //Add froala related classes and image attributes only after html is replaced. if (className.indexOf('fr-') > -1) { var inlineStyles = $this.attr("style"); var $images = $('.cpSlideshowJS' + id + ' img[data-delayed-image]'); $images.each(function (index) { var $image = $(this); $image.attr("style", inlineStyles); }); // In-line and block classes if (this.classList.contains('fr-dib')) $('.cpSlideshowJS' + id).addClass('fr-dib'); else if (this.classList.contains('fr-dii')) $('.cpSlideshowJS' + id).addClass('fr-dii'); // Alignment classes if (this.classList.contains('fr-fil')) $('.cpSlideshowJS' + id).addClass('fr-fil'); else if (this.classList.contains('fr-fir')) $('.cpSlideshowJS' + id).addClass('fr-fir'); // Image resize needs to apply to entire slideshow var style = 'width: ' + imgWidth + 'px; height: auto;'; $('.cpSlideshowJS' + id).attr('style', style); } //If the slideshow has an alignment set in the editor, that alignment needs to be applied to the ol surrounding the images in slideshow. if (className.indexOf('float') > 0) { var applyClass = ''; switch (className) { case 'cpSlideshowImages floatRight': applyClass = 'floatRight'; break; case 'cpSlideshowImages floatLeft': applyClass = 'floatLeft'; break; case 'cpSlideshowImages floatCenter': applyClass = 'floatCenter'; break; case 'cpSlideshowImages floatJustify': applyClass = 'floatJustify'; break; } $('.cpSlideshowJS' + id).addClass(applyClass); } }); } function getSlideshowContent(slideshowID) { var slideshowHtml = ''; $.ajax({ url: location.protocol + '//' + window.location.hostname + '/Slideshow/Render/' + slideshowID, type: 'POST', cache: false, async: false, success: function (response) { slideshowHtml = response; }, error: function (xhr, textStatus, exception) { alert("Error: " + xhr.statusText + "\nStatus: " + xhr.status); } }); return slideshowHtml; } /***************************************************************************************************************** Common editor rendering functions used in multiple widgets(editor and InfoAdvanced so far) Ends /****************************************************************************************************************/ ///Gets absolute Url when given a relative Url. Useful for certain scenarios where http call is made under https hood and it fails. function getAbsoluteUrl(relativeUrl) { var myAccount = $('#MyAccountLoginPage').val(); if (myAccount != null && myAccount.toLowerCase() == "true") { var basePath = location.protocol + '//' + location.hostname + (typeof (location.port) !== 'undefined' && location.port != '' && location.port != '80' ? ':' + location.port : ''); return basePath + relativeUrl; } return relativeUrl; } function fireMediaQueriesIfNeeded($parent) { if (window.cpMedia) { fireMediaElementQueriesOfChildren($parent); } } function loadMaps() { downloadGoogleMapsCustomScript(); } function googleMapsCustomScriptDownloaded() { $('.googleMap').each(function (index, item) { new CivicPlus.Maps().LoadMap(item); }); } function downloadGoogleMapsCustomScript() { if (typeof (CivicPlus) !== 'undefined') CivicPlus.Maps = {}; var script = document.createElement('script'); script.type = 'text/javascript'; if (script.readyState) { //IE script.onreadystatechange = function () { if (script.readyState === "loaded" || script.readyState === "complete") { script.onreadystatechange = null; if (window.googleMapsMode !== 2)//dynamic but lazy loaded googleMapsCustomScriptDownloaded(); } }; } else { //Others script.onload = function () { if (window.googleMapsMode !== 2)//dynamic but lazy loaded googleMapsCustomScriptDownloaded(); }; } script.src = '/Assets/Scripts/GoogleMaps.js'; document.getElementsByTagName("head")[0].appendChild(script); } function loadGoogleMapsScript(mode, callback) { var script; window.googleMapsMode = mode; if ($('div.widgetStaffDirectory').length > 0 || $('.DirectoryNormalText .mapWrap .googleMap').length > 0) { if ($('#GoogleMapsJS').length == 0) { script = document.createElement('script'); var key = document.getElementById('GoogleMapsKey').value; script.id = 'GoogleMapsJS'; script.type = 'text/javascript'; if (key != null) { script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&key=' + key + '&callback='; } else { script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&callback='; } script.src += mode !== 2 ? callback : 'downloadGoogleMapsCustomScript'; document.body.appendChild(script); } else { if (window.google && window.google.maps) { loadMaps(); } } } } onOrLive($(window), function () { if (typeof targetHash !== "undefined" && targetHash) { smoothScroll(targetHash); } $("a[href*='#']:not(a[href^='/#'], [href='#'])").click(function () { var $this = $(this)[0]; if (hashRegex.test($this.hash)) { if ($this.target !== '_blank') { if (location.pathname .replace(/^\//, '') === this.pathname.replace(/^\//, '') && location.hostname === this.hostname) { return smoothScroll(this.hash); } } } }); if (window.location && window.location.hash && $(window.location.hash.replace('/', '\\/')).offset()) { setTimeout(function () { $('html, body').animate({ scrollTop: $(window.location.hash).offset().top - calculateTotalFixedHeight() }, 300); }, 2000); } }, "load"); //Calculates the total fixed length function calculateTotalFixedHeight() { var totalHeight = 0; if ($('.fixedTop_ts').height()) { totalHeight += $('.fixedTop_ts').height(); } if ($('#divToolbars').height()) { totalHeight += $('#divToolbars').height(); } if ($('div.cp-Toolbars').height()) { totalHeight += $('div.cp-Toolbars').height(); } if ($('.stickyStructuralContainer').height()) { totalHeight += $('.stickyStructuralContainer').height(); } return totalHeight; } function smoothScroll(hash) { var target = $(hash); target = target.length ? target : $('[name=' + hash.slice(1) + ']'); if (!target.length) { return false; } var speed = target[0].getAttribute('data-smoothscrolling') ? 1333 : 1; $('html, body').animate({ scrollTop: target.offset().top - ($('#divToolbars').height() + $('div.cp-Toolbars').height()) }, speed); window.location.hash = ''; // Fixes chrome focus bug window.location.hash = hash; return false; } function hideLiveEditElement(target) { target.addClass('hide'); setTimeout(function () { target.hide(); }, 666); } function showLiveEditElement(target) { target.show(); setTimeout(function () { target.removeClass('hide'); }, 1); } function redrawContextualInnerToolbar(pageID, versionID) { if (versionID > 0) { var url = '/Pages/Toolbar/Contextual?pageID=' + pageID + '&versionID=' + versionID; $.ajax({ url: url, type: 'GET', cache: false, success: function (response) { $('#informativeToolBar').remove(); var $toolbar = $('#innerToolbar'); if ($toolbar.length > 0) { $toolbar.replaceWith(response); } else { $('#divToolbars').append(response); } var toolbarHeight = $('#divToolbars').height() + 'px'; $('#bodyWrapper').css('padding-top', toolbarHeight); if (window.liveEditTabs != null && typeof (window.liveEditTabs.updateMaxHeightTabs) == "function") window.liveEditTabs.updateMaxHeightTabs(); InitializeToolbar(); if (window.Toolbars && window.Toolbars.ContextualToolbar) { $(window.Toolbars.ContextualToolbar).trigger('Loaded'); } $('.widgetSpacer').each(function () { var $this = $(this); if (!$this.hasClass('adminWrap')) { $this.addClass('adminWrap'); } }); }, error: function (xhr, textStatus, exception) { if (xhr.status !== 0 && xhr.readyState !== 0) alert('Error: ' + xhr.statusText + '\nStatus: ' + xhr.status); } }); } } function InitializeToolbar() { $('#lnkVersionSaveAsCopy', '#ulVersionToolBar').unbind('click').click(function (e) { e.preventDefault(); if (!$(this).hasClass('inactive')) { SaveAsCopy(); } }); $('#lnkVersionCancel', '#ulVersionToolBar').unbind('click').click(function (e) { e.preventDefault(); if (!$(this).hasClass('inactive')) { AbandonWorkingCopy(); } }); $('#layoutPageSelector', "#LayoutToolBar").unbind('change').change(function () { window.location.href = "/" + $(this).val(); }); } function triggerStickyStructuralInitLogic() { setTimeout(function () { new StickyStructuralContainers().init(); }, 666); } //Function to toggle for widget link. function toggleWidgetsLink(isEnabled) { var widgetLink = $('#innerLnkwidgets'); if (widgetLink) { if (isEnabled) { widgetLink.removeAttr('disabled').removeClass('cp-modificationProhibited'); widgetLink[0].href = '#liveEditTab_widgets'; addClassToWidgets(true); } else { widgetLink.attr('disabled', 'disabled').addClass('cp-modificationProhibited'); widgetLink[0].href = '#'; addClassToWidgets(false); } } } //Function to show/hide widget disabled popup. function showWidgetDisabledPopUp() { var options = { title: 'Widget Edit', elementID: 'widgetDisabledPopup', autoAdjust: false, className: 'adminWrap accountActivation widgetPopUp popup-position', isFrontEnd: false, htmlContent: '

To modify this content, you\'ll have to create a copy of the page first.

', draggable: true } openCpModal(options); } //Function to save page copy. function savePageCopy() { SaveAsCopy(); closeModal(); } //Function to close the modal function closeModal() { hideModal('.modalContainer.modalContainerCP'); } //Function to add class to widgets function addClassToWidgets(isEnabled) { var pageContent = $('.pageContent div'); $.each(pageContent, function (index, item) { if (isEnabled) { $(item).removeClass('cp-modificationProhibited'); } else { $(item).addClass('cp-modificationProhibited'); } }); }; /**** Functions to handle Main/Left Menu on Front-end. *****/ //Global variables var MAIN_MENU = 2; var SIDE_MENU = 1; var menuManager = new MenuManager(); //setup RWD menu window.Pages = window.Pages || {}; $.when(window.Pages.rwdReady, menuManager.mainMenuReady).done(function () { menuManager.initRWD(); var isLoggedBackendUser = $('#helpMenu').length == 1; var mql = matchMedia(window.mainMenuMediaQuery); var isFirstTimeRun = true; var executeOnce = function () { fireAllMediaElementQueries(); if (typeof rearrangeFlyouts === 'function') rearrangeFlyouts(false); window.Pages.onResizeHandlersExecute(); window.Pages.toolBarDeferred.resolve(); }; if (!mql.matches) { executeOnce(); isFirstTimeRun = false; } cpMedia.register(window.mainMenuMediaQuery, { setup: function () { if (isLoggedBackendUser) $('div.cpToolbar.user').removeClass('public').addClass('admin adminWrap'); }, match: function () { $('body').addClass('narrow').removeClass('wide'); if (isLoggedBackendUser) $('div.cpToolbar.user').removeClass('admin adminWrap').addClass('public'); menuManager.moveToMobile(); resetBodyPadding && resetBodyPadding(); if (isFirstTimeRun) { executeOnce(); } isFirstTimeRun = false; }, unmatch: function () { $('body').addClass('wide').removeClass('narrow'); if (isLoggedBackendUser) $('div.cpToolbar.user').removeClass('public').addClass('admin adminWrap'); menuManager.moveToDesktop(); } }); }); //Defines menu class to handle Main/Left Menu on Front-end. function MenuManager() { //object variables this.$divListSubMenus = null; //hide div where submenus are be placed. //this.$containerSubMenus = $('#containerSubMenus'); ; //no hidden div to hold the submenus of main menu being displayed. Workaround to solve z-index issues. could be removed along with its related code after redo layout project! this.menuTimeoutID = null; this.mainMenuMaxSubMenuLevels = 0; this.sideMenuMaxSubMenuLevels = 0; this.popdownDelaySideMenu = 500; this.popdownDelayTopMenu = 500; this.popupDelaySideMenu = 300; this.popupDelayTopMenu = 300; this.isMainMenuEditable = false; this.isMainMenuBeingDragged = false; this.isSideMenuEditable = false; this.isSideMenuBeingDragged = false; this.sideMenuHasCustomLinks = false; this.bouncing = true; this.initialized = false; this.setupDraggable = false; this.mobileMainNav = false; this.mainMenuInit = false; this.mainMenuReady = $.Deferred(); this.$mainNavHolderMobile = null; this.$mainNav = null; this.$mainNavMenu = null; this.rwdInitNavOpenButton = false; this.mainMenuTextResizer = false; this.mainMenuTextResizerRatio = 0.5; this.isAdjustingMainMenuItemsWidth = false; //Initialize menu manger after document was load this.init = function () { var self = this; // Reference to current object if (!self.initialized) { self.initialized = true; this.resetSubMenus(); //hide all submenus after clicking any menu item onOrLive($('li.subMenuItem > a.navMenuItem, li.topMenuItem > a.navMainItem'), function () { menuManager.hideAllSubMenus(MAIN_MENU); menuManager.hideAllSubMenus(SIDE_MENU); }, 'click'); // Hide all submenus when the Escape key is pressed document.addEventListener('keydown', function(event) { if (event.key === "Escape") { menuManager.hideAllSubMenus(MAIN_MENU); menuManager.hideAllSubMenus(SIDE_MENU); } }); } if (self.setupDraggable) self.attachDragAndDropHandlers(); }; this.initRWD = function () { var self = this; // Reference to current object self.$mainNavHolderMobile = $("#mainNavHolderMobile"); self.$mainNav = $("#mainNav"); self.$mainNavMenu = $("#mainNavMenu"); if (self.isAdjustingMainMenuItemsWidth) { self.resetMainItemsWidth("#mainNavMenu"); self.adjustMainItemsWidth("#mainNavMenu"); } if (self.mainMenuTextResizer) self.$mainNavMenu.responsiveMenuText({ ratio: self.mainMenuTextResizerRatio }); }; this.resetSubMenus = function () { var self = this; // Reference to current object if (self.$divListSubMenus != null) self.$divListSubMenus.remove(); var $divListSubMenus = $(''); //Trick to get width from hidden elements needed to calculate bouncing. If above styles creates problems use hack from http://stackoverflow.com/questions/1472303/jquery-get-width-of-element-when-not-visible-display-none var docFrag = $(document.createDocumentFragment()); docFrag[0].appendChild($divListSubMenus[0].cloneNode(true)); self.$divListSubMenus = docFrag.children(); $divListSubMenus.remove(); }; /*var $body = $("body"); this.isNarrowSite = function () { //return $body.hasClass("narrow"); return true; };*/ } MenuManager.prototype.moveToMobile = function () { var menusToClose = document.getElementsByClassName("megaMenuContainer"); for (i = 0; i < menusToClose.length; i++) { menusToClose[i].style.display = "none"; } var self = this; // Reference to current object if (!self.mobileMainNav) { self.mobileMainNav = true; if (self.mainMenuTextResizer && self.$mainNavMenu.data('responsiveMenuText')) self.$mainNavMenu.responsiveMenuText('dispose'); if ($("#nav-open-btn").length === 0) { $('#divToolbars').append($('Menu')); self.applyResponsiveMenuSettings(); self.initNavOpenButton(); } self.$mainNav.before($('')); self.$mainNavHolderMobile.append(self.$mainNav); self.$mainNavMenu.wrap('
'); self.$mainNavMenu.attr('aria-hidden', 'true'); var $menu = $('#rwd-menu'); $menu.rwdmenu(); $menu.onclick = function () { }; if (self.isAdjustingMainMenuItemsWidth) self.resetMainItemsWidth("#mainNavMenu"); } }; MenuManager.prototype.applyResponsiveMenuSettings = function () { var signInBar = $('.cpToolbar.user.public'); var alertBar = $('.alertToolbar'); var navButton = $("#nav-open-btn"); var fullWidth = window.fullWidthResponsiveMenu; var fixedMenu = window.fixedResponsiveMenu; var responsiveMenuButtonHeight = window.responsiveMenuHeight !== '' ? window.responsiveMenuHeight : "34"; var responsiveMenuButtonHeightWithPx = ""; if (responsiveMenuButtonHeight.indexOf('px') === -1) responsiveMenuButtonHeightWithPx = responsiveMenuButtonHeight + 'px'; if (responsiveMenuButtonHeight > 34) //dont assign any inline styles if height < 34 { responsiveMenuButtonHeight -= (signInBar.length && 8); var responsiveMenuButtonHeightNavbtnWithpx = ""; if (responsiveMenuButtonHeight.toString().indexOf('px') === -1) responsiveMenuButtonHeightNavbtnWithpx = responsiveMenuButtonHeight + 'px'; // Set the button height if (responsiveMenuButtonHeight !== "px") navButton.css("height", responsiveMenuButtonHeightNavbtnWithpx).css("line-height", responsiveMenuButtonHeightNavbtnWithpx); } var responsiveMenuFontSize = window.responsiveMenuFontSize; if (responsiveMenuFontSize.indexOf('px') === -1) responsiveMenuFontSize += 'px'; // Set the button font-size if (responsiveMenuFontSize !== 'px') navButton.css('font-size', responsiveMenuFontSize); if ((fullWidth || alertBar.length) && !signInBar.length) { // Apply styles for the full-width button navButton.css("right", "0"); navButton.css("bottom", "auto"); } // Special case: Forces full-width in order to avoid empty gap on right side of hamburger menu - see bug https://civicplus.tpondemand.com/entity/77390-an-extra-spacing-appears-below-the if (!fixedMenu && !fullWidth && !alertBar.length && !signInBar.length) { // Apply styles for the full-width button navButton.css("right", "0"); navButton.css("bottom", "auto"); } if (signInBar.length) { // Fix sign in bar height signInBar.css("height", responsiveMenuButtonHeightWithPx); // Fix sign in button height signInBar.find(".button").css("height", responsiveMenuButtonHeightWithPx).css("line-height", responsiveMenuButtonHeightWithPx); if (window.fixedResponsiveMenu && $('#nav-open-btn').length) { $('.cpToolbar.user.public').css("z-index" , "101"); } } if (fixedMenu) { // Move the menu button and menu to #outer-wrap (outside of transform) $("#nav-open-btn, #mainNavHolderMobile").appendTo("#outer-wrap"); // Make fixed navButton.css("position", "fixed"); // Prevent overlapping in the menu $("#mainNavHolderMobile").css("position", "fixed").css("top", responsiveMenuButtonHeightWithPx).css("left", "0").css("right", "0").css("bottom", "0"); // Remove main nav transform, fix z-index issues $("").appendTo("body"); // Prevent overflow of the menu $("#mainNav").css("overflow-y", "auto"); if (signInBar.length) { // Move the sign in bar to #outer-wrap (outside of transform) signInBar.appendTo("#outer-wrap"); signInBar.css("top", "0").css("left", "0").css("right", "0").css("position", "fixed"); } if (fullWidth || signInBar.length || alertBar.length) { // Add padding-top to #outer-wrap (prevent the button/sign in bar from overlapping stuff) $("#outer-wrap").css("padding-top", responsiveMenuButtonHeightWithPx); } } }; MenuManager.prototype.moveToDesktop = function () { var self = this; // Reference to current object if (self.mobileMainNav) { self.mobileMainNav = false; $("#mainNavOriginalPosition").replaceWith(self.$mainNav); self.$mainNavMenu.unwrap().rwdmenu('destroy'); if (self.isAdjustingMainMenuItemsWidth) self.adjustMainItemsWidth("#mainNavMenu"); if (self.mainMenuTextResizer) self.$mainNavMenu.responsiveMenuText({ ratio: self.mainMenuTextResizerRatio }); self.$mainNavMenu.attr('aria-hidden', 'false'); self.$mainNav.css("overflow-y", ""); } }; MenuManager.prototype.initNavOpenButton = function () { var self = this; // Reference to current object if (self.rwdInitNavOpenButton) return; self.rwdInitNavOpenButton = true; var trim = function (str) { return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, ''); }; var hasClass = function (el, cn) { return (' ' + el.className + ' ').indexOf(' ' + cn + ' ') !== -1; }; var addClass = function (el, cn) { if (!hasClass(el, cn)) { el.className = (el.className === '') ? cn : el.className + ' ' + cn; } }; var removeClass = function (el, cn) { el.className = trim((' ' + el.className + ' ').replace(' ' + cn + ' ', ' ')); }; var hasParent = function (el, id) { if (el) { do { if (el.id === id) { return true; } if (el.nodeType === 9) { break; } } while ((el = el.parentNode)); } return false; }; var doc = document.documentElement; var transform_prop = window.Modernizr.prefixed('transform'), transition_prop = window.Modernizr.prefixed('transition'), transition_end = (function () { var props = { 'WebkitTransition': 'webkitTransitionEnd', 'MozTransition': 'transitionend', 'OTransition': 'oTransitionEnd otransitionend', 'msTransition': 'MSTransitionEnd', 'transition': 'transitionend' }; return props.hasOwnProperty(transition_prop) ? props[transition_prop] : false; })(); var inner = $("#inner-wrap")[0]; var nav_open = false; var nav_class = 'js-navopen'; var closeNavEnd = function (e) { if (e && e.target === inner) { document.removeEventListener(transition_end, closeNavEnd, false); } nav_open = false; }; var closeNav = function () { if (nav_open) { // close navigation after transition or immediately var duration = (transition_end && transition_prop) ? parseFloat(window.getComputedStyle(inner, '')[transition_prop + 'Duration']) : 0; if (duration > 0) { document.addEventListener(transition_end, closeNavEnd, false); } else { closeNavEnd(null); } } removeClass(doc, nav_class); $('ol#mainNavMenu').find('li.rwd-close').remove(); $('ol#mainNavMenu').attr('aria-hidden', 'true'); }; var openNav = function () { if (nav_open) { return; } addClass(doc, nav_class); $('ol#mainNavMenu').attr('aria-hidden', 'false'); var $firstItem = $('ol#mainNavMenu').find('li > a').first(); if (!$firstItem.hasClass('backMenuLink') && !$firstItem.hasClass('closeMenuLink')) { var $close = $('
  • Close Menu
  • '); $('#mainNavMenu').prepend($close); $firstItem = $('ol#mainNavMenu').find('li > a').first(); $firstItem.bind('click', function (e) { e.preventDefault(); closeNav(); }); } $firstItem.focus(); nav_open = true; }; var toggleNav = function (e) { if (nav_open && hasClass(doc, nav_class)) { closeNav(); } else { openNav(); } if (e) { e.preventDefault(); } }; // open nav with main "nav" button document.getElementById('nav-open-btn').addEventListener('click', toggleNav, false); /* close nav with main "close" button document.getElementById('nav-close-btn').addEventListener('click', toggleNav, false); */ // close nav by touching the partial off-screen content document.addEventListener('click', function (e) { if (nav_open && !hasParent(e.target, 'mainNav') && !hasClass(e.target, 'nav-btn')) { e.preventDefault(); closeNav(); } }, true); }; //Configure a menu. This function should be call only inside $(document).ready MenuManager.prototype.setupMenu = function (menuID, menuContainerID, menuType, setupDraggable, urlToGetHiddenMenus) { var self = this; // Reference to current object self.setupDraggable = setupDraggable; //Initialize menu manger after DOM elements are loaded self.init(); $('#' + menuID).data('menu', { type: menuType, level: 1, parentID: null }); //mouse over on menu items from first level $("li.topMenuItem", '#' + menuID).mouseover(function (e) { e.stopPropagation(); }); //mouse enter on menu items from first level $("li.topMenuItem", '#' + menuID).mouseenter(function () { var $li = $(this); self.menuMouseOver($li); //return false; //do not bubble mouse over events on other nested li tags }); //mouse out on menu items from first level $("li.topMenuItem", '#' + menuID).mouseleave(function () { var $li = $(this); self.menuMouseOut($li); }); $.ajax({ url: urlToGetHiddenMenus, type: 'get', async: true, //let the page continue loading/processing meanwhile submenus are loaded cache: false, dataType: 'html', success: function (response) { if (response.ErrorMessage) alert(response.ErrorMessage); else { //Append submenus into divListSubMenus and bind menuMouseOut function on mouseleave event for all
  • . //create temporary container. var tempContainerID = 'dummyDivTemp' + menuID; var $tempContainer = $('
    ').append(response); //set up hasChildren class on top level items $('#' + menuID + ' li').each(function () { var $this = $(this); var id = $this.attr('id'); //.replace(/item|leftItem/i, ''); if (id != null) { var $olSubMenu = $tempContainer.find('#Parent' + id).find('li').not(".addPage"); if ($olSubMenu.length > 0) { $this.addClass('hasChildren'); $this.attr('aria-haspopup', 'true'); //for secondary menus, set up withChildren class on top level items if (menuType === SIDE_MENU && $this.data("displayMainItemSubMenuIndicators") == "True") { $this.children('a.secondaryNavItem').addClass('withChildren'); } } } }); //This needs to be executed once to bind draggable to main and side menu's root elements. if (setupDraggable) { //init drag and drop for menu items $('#' + menuID).find("li").each(function () { //set as droppable all submenu items on main menu self.setupDroppableElement($(this), menuType); }); $('#' + menuID).find(".grippy").each(function () { //setup grip icons as draggable elements for main menu sub items. self.setupDraggableElement($(this), menuType, '#' + menuContainerID); }); } //move submenus to main submenus container. self.$divListSubMenus.append($tempContainer.children()/*$('#' + tempContainerID + ' ol')*/); $tempContainer.remove(); } }, error: function (xhr, textStatus, exception) { if (xhr.status != 0) alert("Error retrieving sub-menus for menuID '" + menuID + "' : " + xhr.statusText + "\ntextStatus: " + xhr.status); } }); }; //Handles mouse over event on menu items MenuManager.prototype.menuMouseOver = function ($li) { var self = this; // Reference to current object if (self.mobileMainNav || ($('.pageContent.cpGrid.dragging').length > 0) || ($('.pageContent.cpGrid.pinned').length > 0)) { return; } this.resetMouseOvers(); $li.addClass('mouseover'); $li.parentsUntil('#mainNavMenu').children('a').addClass('mouseover'); clearTimeout(self.menuTimeoutID); var $parent = $li.parent(); var menuData = $parent.data('menu'); //bail when is currently dragging an item to a different type of menu only if there is not custom links on side menu if (!self.sideMenuHasCustomLinks && self.isMainMenuBeingDragged && menuData.type === SIDE_MENU) return; if (!self.sideMenuHasCustomLinks && self.isSideMenuBeingDragged && menuData.type === MAIN_MENU) return; if ((menuData.type === MAIN_MENU && self.isMainMenuEditable && (self.isMainMenuBeingDragged || self.isSideMenuBeingDragged) && $li.hasClass('liDropabble') && !$li.hasClass('beingDragged')) || (menuData.type === SIDE_MENU && self.isSideMenuEditable && (self.isMainMenuBeingDragged || self.isSideMenuBeingDragged) && $li.hasClass('liDropabble') && !$li.hasClass('beingDragged'))) { //set elements settings when element is over $li.addClass('hover'); } $('#mainNav').css('z-index', '10'); //hide if needed submenus from siblings if ($li.hasClass('topMenuItem')) { //for top level menu items hide all the submenus before displaying another level self.hideAllSubMenus(menuData.type, $li); } else { //for all other submenus which are naturally inside DOM elements $parent.children().each(function () { if ($(this) != $li) self.hideSubMenu($(this)); }); } //When opening different type of menu, hide submenus from the other types menu if (menuData.type === MAIN_MENU) { self.hideAllSubMenus(SIDE_MENU); } else if (menuData.type === SIDE_MENU) { self.hideAllSubMenus(MAIN_MENU); } if (!$li.hasClass('beingDragged')) { var id = $li.attr('id'); //.replace(/item|leftItem/i, ''); var pageID = $li.data('pageid'); var displayMegaMenu = $li.data('displaymegamenu'); var delay = $li.hasClass('topMenuItem') ? self.popupDelayTopMenu : self.popupDelaySideMenu; //This is to pick the list with with the most sub menus and remove the rest. Prevents issue with not displaying all submenus when there is more than one of the same //submenu being rendered, since the first rendered sub menu will be used for all submenu duplicates even though it may not have all the submenus included. //https://civicplus.tpondemand.com/entity/22126 var maxSubMenus = 0; var maxResult; if (self.$divListSubMenus.find('#Parent' + id).length > 1) { $(self.$divListSubMenus.find('#Parent' + id)).each(function () { if ($(this).children().length > maxSubMenus) { maxSubMenus = $(this).children().length; maxResult = this; } $(this).addClass('removal'); }); } $(maxResult).removeClass('removal'); self.$divListSubMenus.remove(".removal"); self.$divListSubMenus.children().append(maxResult); var $olSubMenu = self.$divListSubMenus.find('#Parent' + id); $('.megaMenuContainer.hover').hide().removeClass('hover'); if (displayMegaMenu == 'True') { if (menuData.type === MAIN_MENU) { //Hack to get the heights of the megaMenu elements correctly, in state of display none, incorrect height is being returned. Vishal var $megaMenuContainer = $('.mainNavMegaMenu.megaMenuContainer.pageID_' + pageID); $megaMenuContainer.css('visibility', 'hidden'); $megaMenuContainer.css("overflow", "hidden"); $megaMenuContainer.css("height", "0"); $megaMenuContainer.css("padding", "0"); $megaMenuContainer.show(); //Apply menu animation's start state var applyAnimation = function ($megaMenuContainer, timeout) { if (typeof (Animations) === 'function') { var animations = new Animations(); animations.applyAnimationClassToMegaMenuContainer($megaMenuContainer, timeout); } } var timeout = delay ? delay : 0; self.menuTimeoutID = window.setTimeout(function () { updateMegaMenuAttributes($megaMenuContainer); fireMediaQueriesIfNeeded($megaMenuContainer); $megaMenuContainer.show(); $megaMenuContainer.css("visibility", ""); $megaMenuContainer.css("overflow", ""); $megaMenuContainer.css("height", ""); $megaMenuContainer.css("padding", ""); applyAnimation($megaMenuContainer, timeout); if (!window.isRemoveSetHeights) SetHeights(); }, timeout); } else { delay ? self.menuTimeoutID = setTimeout(function () { $('.secondaryNavMegaMenu.megaMenuContainer.pageID_' + pageID).show(); if (!window.isRemoveSetHeights) SetHeights(); }, delay) : $('.secondaryNavMegaMenu.megaMenuContainer.pageID_' + pageID).show(); } } //For side menu, there isnt a mega menu, so render regular sub menu irrespective of displayMegaMenu setting. if (displayMegaMenu != 'True' || menuData.type === SIDE_MENU) { if ($olSubMenu.length > 1) { //remove duplicates. they might have been added by different menu (main/side) $olSubMenu.slice(1).remove(); $olSubMenu = self.$divListSubMenus.find('#Parent' + id); $olSubMenu.removeClass('takenIntoAccount'); } if ($olSubMenu.length == 1) { $olSubMenu.removeClass('takenIntoAccount'); $olSubMenu.data('menu', { type: menuData.type, level: menuData.level + 1, parentID: $parent.attr('id') }); var allowedToShow = ($olSubMenu.data('menu').type === MAIN_MENU) ? $olSubMenu.data('menu').level <= self.mainMenuMaxSubMenuLevels : $olSubMenu.data('menu').level <= self.sideMenuMaxSubMenuLevels; if (allowedToShow) { delay ? self.menuTimeoutID = setTimeout(function () { self.showSubMenu($li, $olSubMenu); }, delay) : self.showSubMenu($li, $olSubMenu); } } } if (displayMegaMenu == 'True' && !window.isRemoveSetHeights) { SetHeights(); } } }; //Display submenu items MenuManager.prototype.showSubMenu = function ($li, $olSubMenu) { var self = this; // Reference to current object var menuType = $olSubMenu.data('menu').type; var animations = null; //Apply menu animation's start state if (typeof (Animations) === 'function') { animations = new Animations(); animations.applyInitial($olSubMenu, menuType); } //Bind mouseenter for second level submenus //Also set the tab index for each
  • $olSubMenu.children().each(function () { if (self.type != "hidden") { var $input = $(this); } //mouse over on menu items from second and subsequent levels. $(this).bind("mouseenter.menu", function () { var $li = $(this); self.menuMouseOver($li); return false; //do not bubble mouse over events on other nested li tags }); }); //Bind mouseleave for second level submenus $olSubMenu.children().each(function () { //mouse over on menu items from second and subsequent levels. $(this).bind("mouseleave.menu", function () { var $li = $(this); self.menuMouseOut($li); //self.hideAllSubMenus(menuType, $li); }); }); var bouncing = self.bouncing && ((menuType === MAIN_MENU && $olSubMenu.data('menu').level > 2) || (menuType === SIDE_MENU)); var $parentOl = $li.parent(); var parentLeftLi = $li.offset().left; self.moveSubMenuInDOM($olSubMenu, menuType); if (bouncing) { //logic to bounce submenu to be opened if needed. var subMenuWidth = $olSubMenu.outerWidth(); //get width from submenu which is hidden (required to add extra styles on divListSubMenus) var isOpeningToRight = !$parentOl.hasClass('flipLeft'); if (isOpeningToRight) { var winWidth = $(window).width(); var parentWidthLi = $parentOl.outerWidth(); if ((winWidth - parentLeftLi - parentWidthLi) <= (subMenuWidth + 3)) { $olSubMenu.addClass('flipLeft'); } } else { if ((parentLeftLi) <= (subMenuWidth + 3)) { $olSubMenu.addClass('flipRight'); } else { $olSubMenu.addClass('flipLeft'); } } } self.positionSubMenuInDOM($olSubMenu, $li, menuType); if (self.setupDraggable) { //init drag and drop for menu items $olSubMenu.find("li").each(function () { //set as droppable all submenu items on main menu self.setupDroppableElement($(this), menuType); }); $olSubMenu.find(".grippy").each(function () { //setup grip icons as draggable elements for main menu sub items. self.setupDraggableElement($(this), menuType, menuType == MAIN_MENU ? '#mainNav' : '#secondaryNav'); }); } //If Animation manager toggled on, implement the menu animations if (animations != null) { animations.applyAnimationClassToNavContainers($olSubMenu, menuType); } }; //Handles mouse out event on menu items MenuManager.prototype.menuMouseOut = function ($li) { var self = this; // Reference to current object var menuType = $li.attr('id') != null ? ($li.attr('id').match(/MainItem/) != null ? MAIN_MENU : SIDE_MENU) : (($li.hasClass('secondaryNavItem') || $li.parents('ol').attr('id').match(/SideItem/) != null) ? SIDE_MENU : MAIN_MENU); if (self.mobileMainNav) return; //log("popdownDelaySideMenu" + popdownDelaySideMenu); var delay = $li.hasClass('topMenuItem') ? self.popdownDelayTopMenu : self.popdownDelaySideMenu; if (self.isMainMenuBeingDragged || self.isSideMenuBeingDragged) { //reset elements settings $li.removeClass('hover'); } $('#mainNav').css('z-index', ''); clearTimeout(self.menuTimeoutID); self.menuTimeoutID = setTimeout(function () { /*if ($li.parent().data('menu').type == MAIN_MENU) self.hideAllSubMenus(MAIN_MENU); //workaround related with containerSubMenus else*/ $('#bodyWrapper').animate({ 'padding-bottom': 0 }, 'fast'); $('#bodyWrapper').data('maxPaddingBottom', '0'); $('.takenIntoAccount').removeClass('takenIntoAccount'); if (!$li.hasClass('topMenuItem')) self.hideAllSubMenus(menuType, $li); else self.hideSubMenu($li); }, delay); }; MenuManager.prototype.hideAllSubMenus = function (menuType, $currentLi) { var self = this; // Reference to current object switch (menuType) { case SIDE_MENU: //hide sub menus for left menu $("li.topMenuItem", ".secondaryNav ol.rootNavMenu").each(function () { if ($currentLi && $(this).attr('id') === $currentLi.attr('id')) return true; //continue. don't hide current top menu item opened if provided self.hideSubMenu($(this)); }); break; case MAIN_MENU: //hide sub menus for main menu /*var openMenuID = self.$containerSubMenus.find('ol:first').attr('id'); if ($currentLi && openMenuID === ('Parent' + $currentLi.attr('id'))) return true; //continue. don't hide current top menu item opened if provided self.hideSubMenu(self.$containerSubMenus);*/ $("li.topMenuItem", "#mainNavMenu").each(function () { if ($currentLi && $(this).attr('id') === $currentLi.attr('id')) return true; //continue. don't hide current top menu item opened if provided self.hideSubMenu($(this)); }); break; default: //hide submenus for all type of menus //self.hideSubMenu(self.$containerSubMenus); $("li.topMenuItem", "#mainNavMenu").each(function () { self.hideSubMenu($(this)); }); $("li.topMenuItem", "#sideNavMenu").each(function () { self.hideSubMenu($(this)); }); break; } }; MenuManager.prototype.hideSubMenu = function ($li) { var self = this; // Reference to current object var displayMegaMenu = $li.data('displaymegamenu'); var mainMenu = $li.parents('nav').hasClass('mainNav') | $li.parents('ol').hasClass('mainSubMenu'); //When a menu item is set to display as mega menu, we still display regular sub menu for secondary nav, since it doesnt have a megamenu. So while hiding, hide the regular submenu for side navigation. if (displayMegaMenu != 'True' || !mainMenu) { if ($('#mainNavMenu').find('.navMenu').length == 0) { $('#mainNavMenu li a.mouseover').removeClass('mouseover'); } var id = $li.attr('id'); var $olSubMenu = $('#Parent' + id); if ($olSubMenu.length == 1) { //moves sub menu to hidden div $olSubMenu.appendTo(self.$divListSubMenus); //reset data of the menu $olSubMenu.removeData('menu'); if (self.bouncing) { //remove bouncing classes $olSubMenu.removeClass('flipLeft flipRight'); } $olSubMenu.css({ position: '', top: '', left: '', zIndex: '' }); //moves recursively its children if needed $olSubMenu.children().each(function () { self.hideSubMenu($(this)); $(this).unbind("mouseenter.menu"); }); //Remove animation trigger class $olSubMenu.removeClass('animation-triggered'); } } else { var pageID = $li.data('pageid'); var megaMenuContainer = $('.mainNavMegaMenu.megaMenuContainer.pageID_' + pageID); if (!megaMenuContainer.hasClass('hover') && $('.megaMenuContainer .handle.pin.pinned').length === 0) { //$('#megaMenu').hide(); megaMenuContainer.hide(); $('#mainNav').css('z-index', ''); $('.megaMenuContainer').css("display", "none"); $('.megaMenuContainer').removeClass('animation-triggered'); } if (!$('.secondaryNavMegaMenu.megaMenuContainer.pageID_' + pageID).hasClass('hover')) { $('.secondaryNavMegaMenu.megaMenuContainer.pageID_' + pageID).hide(); } } }; //Supports legacy code to set delays when opening/close submenus MenuManager.prototype.setMOMMode = function (mommode, menuType) { //support legacy code if (menuType === MAIN_MENU) { switch (mommode) { case 0: self.popdownDelayTopMenu = 3; self.popupDelayTopMenu = false; self.mainMenuMaxSubMenuLevels = 0; break; case 2: self.popdownDelayTopMenu = 500; self.popupDelayTopMenu = 500; break; case 3: self.popdownDelayTopMenu = 500; self.popupDelayTopMenu = false; break; } } else if (menuType === SIDE_MENU) { switch (mommode) { case 0: self.popdownDelaySideMenu = 3; self.popupDelaySideMenu = false; self.sideMenuMaxSubMenuLevels = 0; break; case 2: self.popdownDelaySideMenu = 500; self.popupDelaySideMenu = 500; break; case 3: self.popdownDelaySideMenu = 500; self.popupDelaySideMenu = false; break; } } }; MenuManager.prototype.adjustMainItemsWidth = function (menuSelector) { this.isAdjustingMainMenuItemsWidth = true; return adjustMainItemsWidth(menuSelector); }; function adjustMainItemsWidth(menuSelector) { var widths = []; var $items = []; $(menuSelector).data('autowidth', true).find(".topMenuItem").each(function () { widths.push($(this).outerWidth()); $items.push($(this)); }); if (widths.length > 0) { var totalWidth = 0; var i; for (i = 0; i < widths.length; i++) { totalWidth += widths[i]; } var menuWidth = window.FeatureToggles.isActive("CMS.JqueryUpgrade.UpgradeTo224") ? $(menuSelector).outerWidth() : $(menuSelector).width(); var availableWidth = menuWidth - totalWidth; var paddingPerItem = availableWidth / $items.length; for (i = 0; i < $items.length; i++) { var width = (100 * (widths[i] + paddingPerItem) / menuWidth); //This is to account for the anomoly of the last menu item wrapping for one client (Anoka County) only in Mac Safari //A site-specific solution was sought but none found that was acceptable if (navigator.userAgent.indexOf("Safari") > -1 && navigator.userAgent.indexOf('Chrome') == -1 && i == $items.length - 1) { width = width - 1; } window.FeatureToggles.isActive("CMS.JqueryUpgrade.UpgradeTo224") ? $items[i].outerWidth(width + "%") : $items[i].width(width + "%"); } } } MenuManager.prototype.resetMainItemsWidth = function (menuSelector) { $(menuSelector).find(".topMenuItem").each(function () { $(this).css("width", "auto"); }); }; function log(text) { console.log(text); } /**** End-Functions to handle Main/Left Menu on Front-end. *****/ /***** Drag and Drop functions to handle main/side menus ********/ //Handles when an element was dropped MenuManager.prototype.dragHandler = function ($element, dragInfo) { var self = this; // Reference to current object //var miLeave = 0; var menuItemLeave = function ($menuItemOver) { $menuItemOver.removeClass('hover'); //miLeave++; //log("Leave event " + (miLeave) + ", liID=" + $menuItemOver.attr('id') + ", class=" + $menuItemOver.attr('class')); //$('#log3').val("Leave event " + (miLeave) + ", liID=" + $menuItemOver.attr('id') + ", class=" + $menuItemOver.attr('class')); }; if ($element.length != 0 && !$element.hasClass('thingToDrag')) { //workaround to avoid executing drag handler when mouse pointer is over drag helper //resetElementOver(); //dragInfo.currentElementOver = { $element: null, $li: null, isAddPage: null, $ol: null }; dragInfo.resetCurrentElementOver(); // This element will hold info to keep track of the current element that the mouse pointer is over. dragInfo.currentElementOver.$element = $element; //$('#log1').val('element ID:' + $element.attr('id') + ', class=' + $element.attr('class') + ", tag=" + $element.get(0).nodeName + "html=" + $element.html()); if ($element.hasClass('inside')) { //when mouse is over any DOM element inside an LI MenuItem var $li = $element.closest('li'); dragInfo.currentElementOver.$li = $li; } else if ($element.hasClass('liDropabble')) { //when mouse is over LI form field element dragInfo.currentElementOver.$li = $element; } if (dragInfo.currentElementOver.$li != null && dragInfo.currentElementOver.$li.hasClass('liDropabble')) { //Over a valid droppable li dragInfo.currentElementOver.$ol = dragInfo.currentElementOver.$li.parent(); //$('#log2').val("inside.. . currentLI=" + dragInfo.currentElementOver.$li.attr('id')); } // Logic to determines if mouse pointer is out of a menu item. if (dragInfo.$prevMenuItemOver != null && (dragInfo.currentElementOver.$li == null || dragInfo.currentElementOver.$li[0] != dragInfo.$prevMenuItemOver[0])) { //fire menu item leave event menuItemLeave(dragInfo.$prevMenuItemOver); } dragInfo.$prevMenuItemOver = dragInfo.currentElementOver.$li; //mouse is over a valid form field to resize.?? } }; ///Handles when an element was dropped MenuManager.prototype.dropHandler = function (dragInfo) { var self = this; // Reference to current object var validPosition = false; if (dragInfo.currentElementOver != null && dragInfo.currentElementOver.$li != null && dragInfo.currentElementOver.$li.hasClass('liDropabble') && !dragInfo.currentElementOver.$li.hasClass('beingDragged')) { var $liTarget = dragInfo.currentElementOver.$li; $liTarget.removeClass('hover'); if (self.sideMenuHasCustomLinks || dragInfo.$draggedElement.data('drag').menuType === $liTarget.data('drag').menuType) { validPosition = true; //var msgSource = "ID=" + dragInfo.$draggedElement.data('drag').itemID + ",parentID=" + dragInfo.$draggedElement.data('drag').parentID + ",prevItemID=" + dragInfo.$draggedElement.data('drag').prevItemID + ",isAddPage=" + dragInfo.$draggedElement.data('drag').isAddPage; //var msgTarget = "ID=" + $liTarget.data('drag').itemID + ",parentID=" + $liTarget.data('drag').parentID + ",prevItemID=" + $liTarget.data('drag').prevItemID + ",isAddPage=" + $liTarget.data('drag').isAddPage; //alert("dropped source=" + msgSource + "\nOn target=" + msgTarget); var url = ''; var addingPage = false; if (dragInfo.$draggedElement.data('drag').isAddPage) { //Creating a new page in a specific menu position addingPage = true; url = "/Pages/Page/Add"; } else { //Moving an existing menu item on different position url = "/Pages/PageStatus/Move/" + dragInfo.$draggedElement.data('drag').itemID; } //logic to build position where menu item was dropped url += "?parentID=" + $liTarget.data('drag').parentID; if ($liTarget.data('drag').isAddPage) { if ($liTarget.data('drag').prevItemID != null) url += "&refPageID={1}&position=Next".replace("{1}", $liTarget.data('drag').prevItemID); else url += "&position=Child"; } else { url += "&refPageID={1}&position=Previous".replace("{1}", $liTarget.data('drag').itemID); if ($liTarget.hasClass('topMenuItem') && $liTarget.data('drag').menuType == MAIN_MENU) { //Check whether or not is possible to copy layout from top sibling page var message = ''; $.ajax({ url: '/Layout/CopyAssociation/CheckTopPages?copyLayoutFrom={0}' .replace('{0}', $liTarget.data('drag').itemID), type: 'POST', async: false, //Needs to be a sync request success: function (response) { if (response.ErrorMessage) { alert(response.ErrorMessage); } else if (response.Message) { message = response.Message; } }, error: function (xhr, textStatus, exception) { alert("Error: " + xhr.statusText + "\nStatus: " + xhr.status); } }); if (message.length > 0 && confirm(message)) { url += "©LayoutFrom=" + $liTarget.data('drag').itemID; } } } if (addingPage) { window.location.href = url; } else { $.ajax({ url: url, type: 'POST', success: function (response) { if (response.ErrorMessage) { alert(response.ErrorMessage); ajaxPostBackEnd(); } else if (response.RedirectURL && response.RedirectURL !== location.href) { location.href = response.RedirectURL; } else { location.reload(true); } }, beforeSend: function () { ajaxPostBackStart('Loading'); }, error: function (xhr, textStatus, exception) { alert("Error: " + xhr.statusText + "\nStatus: " + xhr.status); ajaxPostBackEnd(); } }); } } } }; MenuManager.prototype.setupDraggableElement = function ($element, menuType, containerSelectorToAppend) { var self = this; // Reference to current object //Unbind the event before binding it again. Both solutions below work. $element.unbind('draginit dragstart drag dragend'); //$element.drag('destroy'); // Prevents IE from selecting text while starting a drag. $element.bind('selectstart', function (event) { event.preventDefault(); return false; }); var dragInfo = null; var relativeContainerOffSet = { top: 0, left: 0 }; var draggedRelativeElementOffset = { top: 0, left: 0 }; var isAddPageElem = $element.hasClass('addPage'); //jquery event drag 2.0 plugin. $element.drag("start", function () { if (self.mobileMainNav) return false; self.isMainMenuBeingDragged = (menuType == MAIN_MENU); self.isSideMenuBeingDragged = (menuType == SIDE_MENU); var $draggedElement = null; if ($(this).hasClass('grippy')) $draggedElement = $(this).parent('li'); //page menu items else if ($(this).hasClass('addPage')) $draggedElement = $(this); //Add Page menu items $draggedElement.addClass('beingDragged'); /*if ($draggedElement.hasClass('topMenuItem') && (menuType == MAIN_MENU)) { //workaround to hide top level menu items on main menu. (hideMenu don't work since submenus are not naturally on DOM) self.hideAllSubMenus(MAIN_MENU); } else*/ self.hideSubMenu($draggedElement); dragInfo = { $draggedElement: $draggedElement, currentElementOver: { $element: null, $li: null, isAddPage: null, $ol: null }, $prevMenuItemOver: null, resetCurrentElementOver: function () { this.currentElementOver.$element = null; this.currentElementOver.$li = null; this.currentElementOver.$ol = null; this.currentElementOver.isAddPage = null; } }; //If container for thing to drag has relative position, gets its offset to subtract coordinates while dragging. relativeContainerOffSet = ($(containerSelectorToAppend).css("position") == "relative") ? $(containerSelectorToAppend).offset() : { top: 0, left: 0 }; var hasChildren = $draggedElement.hasClass('hasChildren'); var menuText = $draggedElement.children('a.navMenuItem, a.navMainItem').text(); if (menuText == '') { menuText = $draggedElement.children('div.accordionNavItem').children('a.navMenuItem').text(); } var html = '' + menuText + ''; var $dragHelper = $(html); return $dragHelper.appendTo(containerSelectorToAppend); }).drag(function (e, dd) { //if draggable element has relative position, gets the offset where the mouse was clicked to add coordinates while dragging. draggedRelativeElementOffset = (isAddPageElem) ? { top: dd.startY - dd.originalY, left: dd.startX - dd.originalX } : { top: 0, left: 0 }; $(dd.proxy).css({ top: (dd.offsetY + draggedRelativeElementOffset.top - relativeContainerOffSet.top) + 15, left: (dd.offsetX + draggedRelativeElementOffset.left - relativeContainerOffSet.left) - 10 }); //$('#log4').val('dd.offsetX=' + dd.offsetX + ',dd.offsetY=' + dd.offsetY + ',e.clientX=' + e.clientX + ',e.clientY=' + e.clientY + ',e.pageX=' + e.pageX + ',e.pageY=' + e.pageY); var $elementOver = $(document.elementFromPoint(e.clientX, e.clientY)); // Execute drag handler if (dragInfo != null) self.dragHandler($elementOver, dragInfo); }, { relative: false }) .drag("end", function (ev, dd) { if (self.mobileMainNav) return false; $(dd.proxy).remove(); if (dragInfo != null) { self.dropHandler(dragInfo); dragInfo.$draggedElement.removeClass('beingDragged'); dragInfo.$draggedElement = null; dragInfo.$prevMenuItemOver = null; dragInfo = null; } self.isMainMenuBeingDragged = false; self.isSideMenuBeingDragged = false; }); }; MenuManager.prototype.setupDroppableElement = function ($element, menuType) { var self = this; // Reference to current object if (!self.mobileMainNav && $element.find('div.indicator').length == 1 && !$element.hasClass('liDropabble')) { $element.addClass('liDropabble'); //initialize drag jquery data for droppable elements var isAddPage = $element.hasClass('addPage'); var itemID = !isAddPage ? $element.attr('id').replace(/MainItem|SideItem/i, '') : ''; var prevItemID = ($element.prev().length == 1) ? $element.prev().attr('id').replace(/MainItem|SideItem/i, '') : null; var parentID = $element.parent().attr('id').replace(/ParentMainItem|ParentSideItem/i, ''); if (isNaN(parentID)) //for top level menu items parentID = $element.parent().data('parent'); $element.data('drag', { itemID: itemID, parentID: parentID, prevItemID: prevItemID, isAddPage: isAddPage, menuType: menuType }); /// Setups recursively all children DOM elements with class needed by drag algorithm to recognize which element mouse pointer is var setUpChildren = function ($children) { if ($children.length > 0) { $children.each(function () { $children.addClass('inside'); setUpChildren($(this).children()); }); } }; setUpChildren($element.children()); } }; MenuManager.prototype.setupDroppableAccordionElement = function ($element) { var self = this; if (!self.mobileMainNav && $element.find('div.indicator').length > 0 && !$element.hasClass('liDropabble')) { $element.addClass('liDropabble'); //initialize drag jquery data for droppable elements var isAddPage = $element.hasClass('addPage'); var itemID = !isAddPage ? $element.attr('id').replace(/MainItem|SideItem/i, '') : ''; var prevItemID = ($element.prev().length == 1) ? $element.prev().attr('id').replace(/MainItem|SideItem/i, '') : null; var $parent = $element.parents('li:first'); if ($parent.length == 0) { $parent = $element.parents('ol:first'); } var parentID = $parent.attr('id').replace(/ParentMainItem|ParentSideItem/i, ''); if (isNaN(parentID)) //for top level menu items parentID = $element.parent().data('parent'); $element.data('drag', { itemID: itemID, parentID: parentID, prevItemID: prevItemID, isAddPage: isAddPage, menuType: SIDE_MENU }); /// Setups recursively all children DOM elements with class needed by drag algorithm to recognize which element mouse pointer is var setUpChildren = function ($children) { $children.each(function () { $children.addClass('inside'); setUpChildren($(this).children()); }); }; setUpChildren($element.children()); } $element.unbind('mouseenter').mouseenter(function (e) { e.stopPropagation(); if (self.isSideMenuBeingDragged) { $element.addClass('hover'); } }); $element.unbind('mouseleave').mouseleave(function (e) { $element.removeClass('hover'); }); }; ///Moves the submenu to be displayed at the bottom of the DOM. MenuManager.prototype.moveSubMenuInDOM = function ($submenu, menuType) { //Remove any old .pop elements from the DOM to reload the new one. if ($('body').find($submenu).length > 0) $('body').find($submenu).remove(); //$submenu is the ol, $parent is the li. $submenu.addClass('subMenuMoved').appendTo('body'); var className = menuType == MAIN_MENU ? 'mainSubMenu' : 'secondarySubMenu'; $submenu.addClass(className); $submenu.addClass('moved'); $submenu.css('position', 'absolute'); $submenu.css('z-index', '100'); } ///Updates the position of submenus in the DOM. MenuManager.prototype.positionSubMenuInDOM = function ($submenu, $li, menuType) { var topMainNavigationLink = menuType == MAIN_MENU && $li.hasClass('topMenuItem'); var self = this; self.updateSubMenuPositionAttributes($submenu, topMainNavigationLink, menuType); //If after the submenu is positioned, it has a class of flipLeft, remove it since that causes some display issues on the front-end. Vishal if ($submenu.hasClass('flipLeft')) $submenu.removeClass('flipLeft').addClass('flippedLeft'); }; MenuManager.prototype.updateSubMenuPositionAttributes = function ($submenu, topMainNavigationLink, menuType) { //Get the main nav. var parentID = $submenu.attr('id').replace(/Parent/, ''); var $parent = $('#' + parentID); $submenu.removeClass('flippedLeft'); if ($('#bodyWrapper').data('maxPaddingBottom') == undefined) $('#bodyWrapper').data('maxPaddingBottom', 0); //Reset bottom-padding on body wrapper to allow accurate calculation $('#bodyWrapper').css('padding-bottom', $('#bodyWrapper').data('maxPaddingBottom')); var docHeight = $(document).height(); var menuVisibleSpaceAvailable = docHeight - $parent.offset().top; var submenuHeight = $submenu.height(); //If the parent submenu opened in towards left, let all the subsequent submenus open in the same flow. if ($parent.length > 0 && $parent.parents('ol.subMenuMoved').hasClass('flippedLeft')) $submenu.addClass('flipLeft'); if (menuVisibleSpaceAvailable < submenuHeight && !$submenu.hasClass('takenIntoAccount')) { //20 is just a default safe padding apart from the calculations. $('#bodyWrapper').css('padding-bottom', (submenuHeight - menuVisibleSpaceAvailable + parseFloat($('#bodyWrapper').data('maxPaddingBottom')) + 20)); $('#bodyWrapper').data('maxPaddingBottom', $('#bodyWrapper').css('padding-bottom')); $submenu.addClass('takenIntoAccount'); if (!$submenu.hasClass('safePaddingApplied')) { //Add a padding-bottom of 10px to the submenu to be more presentable $submenu.css('padding-bottom', '10px'); $submenu.addClass('safePaddingApplied'); } } if (menuType == MAIN_MENU) { //Set top position of main submenu $submenu.css('top', $parent.offset().top + (topMainNavigationLink ? $parent.height() : 0)); if ($submenu.hasClass('flipLeft')) { var width = $submenu.find('li:first').width(); //Set left position of side submenu $submenu.css('left', $parent.offset().left - width); } else { //Set left position of main submenu $submenu.css('left', $parent.offset().left + (topMainNavigationLink ? 0 : $parent.width())); } } else { //Set top position of side submenu $submenu.css('top', $parent.offset().top); if ($submenu.hasClass('flipLeft')) { var width = $submenu.find('li:first').width(); //Set left position of side submenu $submenu.css('left', $parent.offset().left - width); } else { //Set left position of side submenu $submenu.css('left', $parent.offset().left + $parent.width()); } } }; /***** End - Drag and Drop functions to handle main/side menus ********/ /***** Start - Mega Menu methods ********/ MenuManager.prototype.pinMegaMenuOpen = function ($this) { var $megaMenuGrid = $this.parents('.megaMenuContainer').children('.pageContent.cpGrid'); if ($megaMenuGrid.is(':visible')) { $('#mainNav').css('z-index', '10'); $megaMenuGrid.addClass('pinned'); $megaMenuGrid.find('.handle.pin').addClass('pinned'); if (typeof PageEditLocalization != 'undefined') { $megaMenuGrid.find('.handle.pin').attr('title', pageEditLocalization.UnpinMegaMenu); } } }; MenuManager.prototype.resetMouseOvers = function () { $('#mainNav').css('z-index', '').find('*').removeClass('mouseover'); $('#secondaryNav').find('*').removeClass('mouseover'); }; /// Setup MenuManager.prototype.initializeMegaMenus = function () { var self = this; if (typeof window.DesignCenter === 'undefined' || typeof window.DesignCenter.themeJSON === 'undefined') { // If we aren't in design center.... $('#megaMenu,.megaMenuContainer').unbind('mouseenter').mouseenter(function (e) { e.stopPropagation(); var $megaMenuContainer = $(this).attr('id') == 'megaMenu' ? $('.megaMenuContainer:visible') : $(this); var pageID = $megaMenuContainer.attr('id').match(/\d+$/)[0]; $('#mainNav [data-pageid=' + pageID + '] a').addClass('mouseover'); $megaMenuContainer.addClass('hover'); }); $('.megaMenuContainer').unbind('mouseleave').mouseleave(function (e) { var $megaMenuContainer = $(this); var visible = $(this).is(':visible'); if (visible) { if ($megaMenuContainer.hasClass('optionOpen') && !$('.cpPopOver.common').is(':visible')) { $megaMenuContainer.removeClass('optionOpen'); } if (!$megaMenuContainer.hasClass('handleHover') && !$megaMenuContainer.hasClass('optionOpen') && !$megaMenuContainer.find('.pageContent.cpGrid').hasClass('dragging') && !$megaMenuContainer.find('.pageContent.cpGrid').hasClass('pinned')) { $megaMenuContainer.hide().removeClass('hover'); //$('#megaMenu').hide(); $('.megaMenu').hide(); //While mousing out of mega menu, if it contains any flyout widgets, hide them. $('.flyOut.moved.forMegaMenu').hide(); self.resetMouseOvers(); } } }); $('.megaMenuContainer .handle.remove, .megaMenuContainer .handle.move, .megaMenuContainer .handle.inheritance').unbind('mouseenter').mouseenter(function (e) { e.stopPropagation(); $(this).parents('.megaMenuContainer').addClass('handleHover'); }); $('.megaMenuContainer .handle.remove, .megaMenuContainer .handle.move, .megaMenuContainer .handle.inheritance').unbind('mouseleave').mouseleave(function (e) { $(this).parents('.megaMenuContainer').removeClass('handleHover'); }); $('.megaMenuContainer .handle.pin').unbind('click').click(function (e) { $(this).toggleClass('pinned'); $(this).parent().toggleClass('pinned'); if (typeof PageEditLocalization != 'undefined') { $(this).attr('title', $(this).hasClass('pinned') ? pageEditLocalization.UnpinMegaMenu : pageEditLocalization.PinMegaMenu); } }); } }; MenuManager.prototype.attachDragAndDropHandlers = function () { //Make mega menu items draggable var $currentDraggables = $('.megaMenuContainer').find('li.level1.ui-draggable, li.level2.ui-draggable'); if ($currentDraggables.length) { $currentDraggables.draggable('destroy'); } $('.megaMenuContainer').find('li.level1, li.level2').draggable({ helper: function (event) { var html = '
      '; html += $('
      ').append($(this).clone()).html() + '
    '; return $(html); }, start: function (event, ui) { $('.megaMenuContainer .pageContent').addClass('megaMenudragging'); }, stop: function (event, ui) { $('.megaMenuContainer .pageContent').removeClass('megaMenudragging'); }, cursorAt: { top: 5, right: 5 }, cursor: 'move', handle: '.grippy' }); //Attach drop target handlers var $currentDroppables = $('.megaMenuTarget.ui-droppable', '.megaMenuContainer.ui-droppable'); if ($currentDroppables.length) { $currentDroppables.droppable('destroy'); } $('.megaMenuTarget', '.megaMenuContainer').droppable({ over: function (event, ui) { $(this).parent().addClass('hover'); }, out: function (event, ui) { $(this).parent().removeClass('hover'); }, drop: function (event, ui) { var $target = $(this), targetPageID = $target.data('pageid'), targetPosition = $target.data('position'), parentID = $target.data('parentid'), pageID = $(ui.helper).children('li').data('pageid'); $target.parent().removeClass('hover'); var url = "/Pages/PageStatus/Move/" + pageID; url += "?parentID=" + parentID; url += "&refPageID={0}&position={1}".replace("{0}", targetPageID).replace("{1}", targetPosition); $.ajax({ url: url, type: 'POST', success: function (response) { if (response.ErrorMessage) { alert(response.ErrorMessage); ajaxPostBackEnd(); } else { location.href = response.RedirectURL; } }, beforeSend: function () { ajaxPostBackStart('Loading'); }, error: function (xhr, textStatus, exception) { alert("Error: " + xhr.statusText + "\nStatus: " + xhr.status); ajaxPostBackEnd(); } }); }, tolerance: 'pointer' }); }; /***** End - Mega Menu methods ********/ /***** Start - Class/functions to handle custom links ********/ function MenuCustomLinksManager(confirmCustomLinksDeletion, pageID, moduleID) { this.pageID = pageID; this.moduleID = moduleID; this.checkOrphanFeatureLinks = function () { if (confirmCustomLinksDeletion && confirmCustomLinksDeletion.length > 0) { return confirm(confirmCustomLinksDeletion); } return true; }; this.updateSideMenu = function (actionUrl) { $.ajax({ url: actionUrl, type: 'post', cache: false, success: function (response) { if (response.ErrorMessage) { alert(response.ErrorMessage); ajaxPostBackEnd(); } else if (response.RedirectURL) window.location.href = response.RedirectURL; else { //update side menu UI. window.location.reload(true); } }, beforeSend: function () { ajaxPostBackStart('Loading'); }, error: function (xhr, textStatus, exception) { ajaxPostBackEnd(); alert("Error choosing default side menu: " + xhr.statusText + "\nStatus: " + xhr.status); } }); }; } /// open modal to chose page to associate with current page/module as custom link MenuCustomLinksManager.prototype.chosePage = function () { var self = this; // Reference to current object if (self.checkOrphanFeatureLinks()) { openCpModal({ title: 'Choose Page', className: 'notContent choosePageForLinks', isFrontEnd: false, url: '/Pages/CustomLinks/ChoosePage/?pageID=' + self.pageID + '&moduleID=' + self.moduleID }); } }; /// Call back to execute after choosing a page on modal. MenuCustomLinksManager.prototype.chosePageExecute = function (chosenPageID) { var self = this; // Reference to current object closeCpModal(); //Update side nav. self.updateSideMenu('/Pages/CustomLinks/ChangeSideMenu/?pageID=' + self.pageID + '&moduleID=' + self.moduleID + '&chosenPageID=' + chosenPageID); }; /// Creates a new empty root feature link for specific page/module MenuCustomLinksManager.prototype.createNewCustomLink = function () { var self = this; // Reference to current object if (self.checkOrphanFeatureLinks()) { self.updateSideMenu('/Pages/CustomLinks/CreateCustomFeatureLinks/?pageID=' + self.pageID + '&moduleID=' + self.moduleID); } }; /// Make default side menu for current page/module (remove custom link previously assigned). MenuCustomLinksManager.prototype.choseDefaultSideMenu = function () { var self = this; // Reference to current object if (self.checkOrphanFeatureLinks()) { self.updateSideMenu('/Pages/CustomLinks/ChoseDefaultSideMenu/?pageID=' + self.pageID + '&moduleID=' + self.moduleID); } }; /***** End - Class/functions to handle feature links on Secondary menus ********/ /***** Start - Class/functions to handle Main Menu Options ********/ function MainMenuOptions(pageID, mainMenuRootID) { var wasCheckBoxChanged = function ($checkbox) { if ($checkbox.is(":checked")) return $checkbox.data('original') != 'True'; else return $checkbox.data('original') == 'True'; }; var closeMainMenuPopover = function ($handler, doNotResetCheckboxes) { $handler.data("cpPopover").hide(); if (doNotResetCheckboxes) return; //reset checkbox selections $('div.menuOptions input[type=checkbox]').each(function () { if ($(this).data("original") == "True") $(this).attr("checked", "checked"); else $(this).removeAttr("checked"); }); }; var initializeMainMenuPopup = function ($handler) { $('#cancelMainNavOptions', "#modalMainNavOptions") .unbind('click.mainMenuOptions').bind("click.mainMenuOptions", function (e) { e.preventDefault(); closeMainMenuPopover($handler, false); }); $('#saveMainNavOptions', "#modalMainNavOptions") .unbind('click.mainMenuOptions').bind("click.mainMenuOptions", function (e) { e.preventDefault(); var useThisPageAsMainMenu = null; var displayMegaMenu = []; $('div.menuOptions input.DisplayMegaMenu').each(function () { if (wasCheckBoxChanged($(this))) displayMegaMenu.push({ PageID: $(this).data('pageid'), DisplayMegaMenu: $(this).is(':checked') }); }); if ($('#ysnUseThisPagesSubpages', 'div.menuOptions').length == 1 && wasCheckBoxChanged($('#ysnUseThisPagesSubpages'), 'div.menuOptions')) useThisPageAsMainMenu = $('#ysnUseThisPagesSubpages', 'div.menuOptions').is(':checked'); var data = JSON.stringify({ pageID: pageID, versionID: $('#hdnVersionID').val(), useThisPageAsMainMenu: useThisPageAsMainMenu, displayMegaMenu: displayMegaMenu, structureID: $('#hdnStructureID').val() }); AJAX("/Pages/Menu/MainMenuOptionsSave", 'POST', data, function (response) { window.location.reload(true); }, true, 'application/json'); closeMainMenuPopover($handler, true); }); }; var $handlerMainMenu = $('#mainNavMenuHandleOptions'); if ($('#hdnIsLayoutPage').val() === "True" || $('#hdnVersionID').length === 0 || $('#hdnVersionID').val() == "0") { $handlerMainMenu.remove(); } else { $handlerMainMenu.cpPopover({ url: '/Pages/Menu/MainMenuOptions', type: 'POST', contentType: 'application/json', data: JSON.stringify({ pageID: pageID, mainMenuRootID: mainMenuRootID }), className: 'options adminWrap admin menuOptions', onInit: function () { initializeMainMenuPopup($handlerMainMenu); }, onClose: function (e) { e.preventDefault(); closeMainMenuPopover($handlerMainMenu, false); } }); } } /***** End - Class/functions to handle Main Menu Options ********/ function showHideAccordionMenuForSecondaryNav($elem) { var secondaryMenu = 1; var hasAccordionSubmenu = $elem.next('a.openAccordionNav').length > 0; if (hasAccordionSubmenu) $elem = $elem.next('a.openAccordionNav'); var $container = $elem.parent().siblings('.accordionNavContainer'); var $secondaryNavHiddenElement = $('#secondaryNav').children('[class*="hiddenAnimations"]'); var animations = null; //Apply initial animation state before the sliding happens to open the accordion submenu if (!$elem.hasClass('accordionNavOpened')) { if (typeof (Animations) === 'function') { animations = new Animations(); animations.applyInitial($container, secondaryMenu); } } else {//reset the container by removing animation classes. if ($secondaryNavHiddenElement.length > 0 && $secondaryNavHiddenElement.data('animationClass') != undefined) $container.removeClass($secondaryNavHiddenElement.data('animationclass')); $container.removeClass('animation-triggered'); } $elem.toggleClass('accordionNavOpened'); $container.css('overflow', 'hidden'); $container.slideToggle("333ms"); if ($container.attr('aria-hidden') == 'true') { $container.attr('aria-hidden', 'false'); } else { $container.attr('aria-hidden', 'true'); } setTimeout(function () { $container.css('overflow', ''); if ($elem.hasClass('accordionNavOpened')) { //If Animation manager toggled on, implement the menu animations if (animations != null) animations.applyAnimationClassToNavContainers($container, 1); } }, 400); if (typeof dynamicStretchContainers === 'function') { setTimeout(dynamicStretchContainers, 400); } } $(document).ready(function () { //Mega menus handlers $('.megaMenuContainer') .hide() .removeClass('hidden') .find('.handle.inheritance').remove(); menuManager.initializeMegaMenus(); }); ; /*Strategy pattern AccessibleMenu: Abstract class with default implementation for bindHandlers, initialize MainAccessibleMenu: Concrete implementation of Accessible menu SecondaryAccessibleMenu: Concrete implementation of Accessible menu AccordionAccessibleMenu: Concrete implementation of Accessible menu accordionMenuStack: A stack to maintain hierarchy of accordion menu items so that traversing them back(Up arrow) becomes super easy*/ var stack = []; var AccessibleMenu = function () { this.menuItem = ""; }; //Static field AccessibleMenu.accordionMenuStack = []; AccessibleMenu.prototype = { initialize: function (mainMenuItem, accordionMenu) { if (mainMenuItem) this.setStrategy(new MainAccessibleMenu()); else { if (accordionMenu) this.setStrategy(new AccordionAccessibleMenu()); else this.setStrategy(new SecondaryAccessibleMenu()); } }, setStrategy: function (menuItem) { this.menuItem = menuItem; }, bindHandlers: function ($elem) { var self = this; $elem.unbind('keydown').keydown(function (e) { if (e.which == 37) {//left self.left($elem); e.preventDefault(); } if (e.which == 38) {//up self.up($elem); e.preventDefault(); } if (e.which == 39) {//right self.right($elem); e.preventDefault(); } if (e.which == 40) {//down self.down($elem); e.preventDefault(); } }); }, left: function ($elem) { this.menuItem.left($elem); }, up: function ($elem) { this.menuItem.up($elem); }, right: function ($elem) { this.menuItem.right($elem); }, down: function ($elem) { this.menuItem.down($elem); } }; //MainAccessibleMenu concrete class var MainAccessibleMenu = function () { this.left = function ($elem) { var topLevelMenuItem = $elem.hasClass('navMainItem'); if (topLevelMenuItem) { //move to the next main menu item $elem.parent('li').prev('li').find('a:first').focus(); } else { var parentOlId = $elem.parents('ol').attr('id'); var parentMenuItemId = parentOlId.slice('Parent'.length); $('#' + parentMenuItemId).find('a:first').focus(); } }; this.up = function ($elem) { var $firstSubmenuItemOfMainMenuItem = $elem.parents('.mainSubMenu').find('a:first'); var currentElemIsfirstSubmenuItemOfMainMenuItem = $firstSubmenuItemOfMainMenuItem[0] == $elem[0]; if (currentElemIsfirstSubmenuItemOfMainMenuItem) { //find the top level menu item var $olParent = $elem.parents('.mainSubMenu'); var parentMenuItemId = $olParent.attr('id').slice('Parent'.length); $('#' + parentMenuItemId).find('a:first').focus(); } else { //find prev sibling var $prev = $elem.parent('li').prev('li').find('a:first'); if ($prev != null) $prev.focus(); } }; this.right = function ($elem) { var topLevelMenuItem = $elem.hasClass('navMainItem'); if (topLevelMenuItem) { //move to the next main menu item $elem.parent('li').next('li').find('a:first').focus(); } else { var $parentLi = $elem.parent('li'); var $parentId = "Parent" + $parentLi.attr('id'); var $firstAnchorOfSubmenu = $('ol[id=' + $parentId + '] a:first'); $firstAnchorOfSubmenu.focus(); } }; this.down = function ($elem) { var topLevelMenuItem = $elem.hasClass('navMainItem'); if (topLevelMenuItem) { //find on basis of submenu var $parentLi = $elem.parent('li'); var $parentId = "Parent" + $parentLi.attr('id'); var $firstAnchorOfSubmenu = $('ol[id=' + $parentId + '] a:first'); $firstAnchorOfSubmenu.focus(); } else { //find on basis of sibling var $next = $elem.parent('li').next('li').find('a:first'); if ($next != null) $next.focus(); } }; }; //SecondaryAccessibleMenu concrete class var SecondaryAccessibleMenu = function () { this.left = function ($elem) { var parentOlId = $elem.parents('ol').attr('id'); var parentMenuItemId = parentOlId.slice('Parent'.length); $('#' + parentMenuItemId).find('a:first').focus(); }; this.up = function ($elem) { var $prev = $elem.parent('li').prev('li').find('a:first'); if ($prev != null) $prev.focus(); }; this.right = function ($elem) { var $parentLi = $elem.parent('li'); var $parentId = "Parent" + $parentLi.attr('id'); var $firstAnchorOfSubmenu = $('ol[id=' + $parentId + '] a:first'); $firstAnchorOfSubmenu.focus(); }; this.down = function ($elem) { var $next = $elem.parent('li').next('li').find('a:first'); if ($next != null) $next.focus(); }; }; //AccordionMenu concrete class var AccordionAccessibleMenu = function () { this.left = function ($elem) { //do nothing }; this.up = function ($elem) { var $popped = AccessibleMenu.accordionMenuStack.pop(); if($popped != null) $popped.focus(); }; this.right = function ($elem) { //do nothing }; this.down = function ($elem) { AccessibleMenu.accordionMenuStack.push($elem); var hasAccordionSubmenu = $elem.next('a.openAccordionNav').length > 0; var accordionSubmenuAlreadyOpen = $elem.next('a.openAccordionNav').hasClass('accordionNavOpened'); var $nextElementToFocus = ''; if (hasAccordionSubmenu && !accordionSubmenuAlreadyOpen) { $nextElementToFocus = $elem.parents('.topMenuItem').next('li').find('a:first'); $nextElementToFocus.focus(); return; } if (hasAccordionSubmenu) { $nextElementToFocus = $elem.parents('[role=menuitem]:first').children('ol.accordionNavContainer').find('a:first'); $nextElementToFocus.focus(); } else { var $nextSiblingLi = $elem.parents('[role=menuitem]').next('li:first'); if ($nextSiblingLi != null && $nextSiblingLi.length > 0) { $nextElementToFocus = $nextSiblingLi.find('a:first'); $nextElementToFocus.focus(); } else { $nextElementToFocus = $elem.parents('.topMenuItem').next('li').find('a:first'); $nextElementToFocus.focus(); } } }; }; //Self invloked function (function () { var isClick = false; onOrLive($("a.navMainItem, a.navMenuItem"), function () { //Set isClick true if clicked on secondary nav menu item. isClick = true; }, "mousedown"); function menuHandler(e) { var $this = $(this); var accessibleMenu = new AccessibleMenu(); var mainMenuItem = $this.parents('nav').hasClass('mainNav') | $this.parents('ol').hasClass('mainSubMenu'); var accordionMenu = false; var $topmostAccordionMenuItem = $this.parents('nav').find('a:first'); if ($this[0] === $topmostAccordionMenuItem[0]) { //Reset the stack AccessibleMenu.accordionMenuStack = []; } if (!mainMenuItem) accordionMenu = $this.parent('div').hasClass('accordionNavItem'); accessibleMenu.initialize(mainMenuItem, accordionMenu); if (!accordionMenu) { //show sub menu menuManager.menuMouseOver($this.parent('li')); window.lastMegaMenuOpen = $this.parent('li'); } accessibleMenu.bindHandlers($this); } if (!window.FeatureToggles.isActive("CMS.JqueryUpgrade.UpgradeTo224")) { $("a.navMainItem, a.navMenuItem").live("focusin", menuHandler); } else { $(document).on("focusin", "a.navMainItem, a.navMenuItem", menuHandler); } //hide last main menu item on tabbing through the menu item. onOrLive($(".siteWrap"), function (e) { menuManager.hideAllSubMenus(MAIN_MENU); }, "focusin"); }()); ; /*Strategy pattern AccessibleMegaMenu: Abstract class with default implementation for bindHandlers, initialize FormattedMegaMenu: Concrete implementation of Accessible mega menu*/ var AccessibleMegaMenu = function () { this.megaMenuItem = ""; this.depth = 1; this.cols = 1; }; AccessibleMegaMenu.prototype = { initialize: function (format) { this.setStrategy(new FormatedMegaMenu()); }, setStrategy: function (megaMenuItem) { this.megaMenuItem = megaMenuItem; }, bindHandlers: function ($elem) { var self = this; var LEFT = 37; var UP = 38; var RIGHT = 39; var DOWN = 40; $elem.unbind('keydown').keydown(function (e) { if (e.which == LEFT) { self.left($elem); e.preventDefault(); } if (e.which == UP) { self.up($elem); e.preventDefault(); } if (e.which == RIGHT) { self.right($elem); e.preventDefault(); } if (e.which == DOWN) { self.down($elem); e.preventDefault(); } }); }, exitMegaMenu: function ($elem) { this.megaMenuItem.exitMegaMenu($elem); }, left: function ($elem) { this.megaMenuItem.left($elem); }, up: function ($elem) { this.megaMenuItem.up($elem); }, right: function ($elem) { this.megaMenuItem.right($elem); }, down: function ($elem) { this.megaMenuItem.down($elem); } }; //Format 1,2,3,4 concrete implementation var FormatedMegaMenu = function () { var self = this; this.left = function ($elem) { var rootTopLevelItem = $elem.closest('li').hasClass('topMenuItem'); if (rootTopLevelItem) { $elem.closest('li.topMenuItem').prev().find('a:first').focus(); return; } var $prev = $elem.closest('div.col').prev().find('li.widgetItem:first').find('a:first'); if ($prev.length === 0) this.exitMegaMenu($elem); else $prev.focus(); }; this.up = function ($elem) { var isWidgetItemElement = $elem.closest('li').hasClass('widgetItem'); var rootTopLevelItem = $elem.closest('li').hasClass('topMenuItem'); if (isWidgetItemElement) var topLevelMenuItem = $elem[0] == $elem.closest('li').parent('ol').children('li:first').find('a:first')[0]; if (rootTopLevelItem) { var id = $elem.closest('li').attr('id'); $('#mainNavMegaMenu' + id).removeClass('hover'); menuManager.menuMouseOut($elem.closest('li')); return; } if (topLevelMenuItem) { var MainItemId = '#MainItem' + $elem.closest('aside').attr('id').slice('mainNavMegaMenu'.length); $(MainItemId).find('a:first').focus(); } else { var isLiHasParentOl = $elem.closest('li').parent('ol'); if (isLiHasParentOl.length > 0 && isLiHasParentOl.children('li:first').children('a')[0] == $elem[0]) { isLiHasParentOl.parent('li').find('a:first').focus(); } else { var prevLi = $elem.closest('li').prev('li'); var $next = null; if (prevLi.hasClass('widgetItem')) { if (prevLi.children('ol').length > 0) { $next = $elem.closest('li').prev('li').children('ol').children('li:last').find('a:first'); } else { $next = $elem.closest('li').prev('li').find('a:first'); } } else $next = $elem.closest('li').prev('li').find('a:first'); $next.focus(); } } }; this.right = function ($elem) { var rootTopLevelItem = $elem.closest('li').hasClass('topMenuItem'); if (rootTopLevelItem) { $elem.closest('li.topMenuItem').next().find('a:first').focus(); return; } var $next = $elem.closest('div.col').next().find('li.widgetItem:first').find('a:first'); if ($next.length === 0) this.exitMegaMenu($elem); else $next.focus(); }; this.down = function ($elem) { var topLevelMenuItem = $elem.hasClass('navMainItem'); if (topLevelMenuItem) { //find on basis of submenu var $parentLi = $elem.parent('li'); var $parentId = "mainNavMegaMenu" + $parentLi.attr('data-pageid'); var $firstAnchorOfSubmenu = $('aside[id=' + $parentId + '] div.col:first ol:first a:first'); $firstAnchorOfSubmenu.focus(); } else { //find on basis of sibling var isWidgetItemElement = $elem.closest('li').hasClass('widgetItem'); var $next = null; if (isWidgetItemElement) { var isLiHasChildren = $elem.closest('li').children('ol'); if (isLiHasChildren.length > 0) $next = isLiHasChildren.children('li:first').children('a'); else $next = $elem.closest('li').next('li').find('a:first'); } else { $next = $elem.closest('li').next('li').find('a:first');//.children('li:first').children('a'); if ($next.length <= 0) { $next = $elem.parents('li.widgetItem').next('li').find('a:first'); } } if ($next != null && $next.length > 0) $next.focus(); else this.exitMegaMenu($elem); } }; this.exitMegaMenu = function ($elem) { var asideContainerId = $elem.parents('.megaMenuContainer.megaMenu').attr('id').slice('mainNavMegaMenu'.length); var $li = $('#MainItem' + asideContainerId); $elem.parents('.megaMenuContainer.megaMenu').removeClass('hover'); menuManager.menuMouseOut($li); $elem.focus(); }; }; //Self invloked function (function () { onOrLive($(".megaMenuContainer h4.widgetTitle ,#mainNav a.navMainItem , li.megaMenuItem a"), function (e) { var $this = $(this); var execute = true; var topMenuItem = $this.hasClass('navMainItem'); if (topMenuItem) { var $parent = $this.parent('li'); if ($parent != null) { //Logic for flyout menu is in AccessibleMenu.js, so do not execute the logic below for the same if ($parent.data('displaymegamenu') == 'False') execute = false; } } if (execute) { var depth = $this.parents('.widgetPages').find('.depth').html(); var cols = $this.parents('.widgetPages').find('.cols').html(); var accessibleMegaMenu = new AccessibleMegaMenu(); var mainMenuItem = true; //If top menu item(and has megamenu which is already checked above), replicate the logic for "mouse near" to load the mega menus if (topMenuItem) { var megaMenuContentContainers = $('[data-displaymegamenu="True"]') .map(function () { $('#mainNavMegaMenu' + $(this).data('pageid') + ' div.pageContent').html('Loading...'); return $('#mainNavMegaMenu' + $(this).data('pageid') + ' div.pageContent').data('containerid'); }).toArray(); reloadSharedContentContainers(megaMenuContentContainers); } accessibleMegaMenu.initialize(depth, cols); accessibleMegaMenu.bindHandlers($this); } }, "focusin"); }()); var AccessibleAnchors = function () { }; AccessibleAnchors.prototype = { configure: function (config) { var self = this; self.OPEN_IN_NEW_WINDOW_TEXT = ' Opens in new window'; if (config.type === 'popup') { this.bindPopupHandlers(self); } if (config.type === 'extend') { this.bindExtendHandlers(self); } if (config.type === 'both') { this.bindPopupHandlers(self); this.bindExtendHandlers(self); } $(document).ready(function () { var anchors_TargetBlank = $('a[target=_blank]'); $.each(anchors_TargetBlank, function () { var $this = $(this); self.setAriaLabelAndAlt($this); }); }); }, bindExtendHandlers: function (self) { onOrLive($('a[target=_blank]'), function (e) { var $this = $(this); self.setAriaLabelAndAlt($this); }, "focusin mouseenter"); }, setAriaLabelAndAlt: function ($this) { //If anchor has an image inside it if (this.hasImage($this)) { var $img = $this.children('img'); if ($img.length == 0) $img = $this.children('span').children('img'); var alt = $img.attr('alt'); if (alt) { if (alt.indexOf(this.OPEN_IN_NEW_WINDOW_TEXT) === -1) $img.attr('alt', alt + this.OPEN_IN_NEW_WINDOW_TEXT); } else { $img.attr('alt', $img.attr('title') + this.OPEN_IN_NEW_WINDOW_TEXT); } this.setAriaLabel($this, $img.attr('alt')); } else { this.setAriaLabel($this, $this.text() + this.OPEN_IN_NEW_WINDOW_TEXT); } }, bindPopupHandlers: function (self) { onOrLive($('a[target=_blank]'), function (e) { var $this = $(this); $this.trigger('focusout'); $this.append($('')); }, "focusin mouseenter"); onOrLive($('a[target=_blank]'), function (e) { $('.newWindowIndicator').remove(); }, "focusout mouseleave"); }, setAriaLabel: function($anchor, ariaLabelText){ var ariaLabel = $anchor.attr('aria-label'); if (ariaLabel) { if (ariaLabel.indexOf(this.OPEN_IN_NEW_WINDOW_TEXT) == -1) $anchor.attr('aria-label', ariaLabelText); } else { $anchor.attr('aria-label', ariaLabelText); } }, hasImage: function ($anchor) { var hasImage = false; if ($anchor.children('img') != null && $anchor.children('img').length > 0) return true; else if ($anchor.children('span') != null && $anchor.children('span').length > 0) { return $anchor.children('span').children('img') != null && $anchor.children('span').children('img').length > 0; } } }; //Self invloked function (function () { //Add a warning span to body for anchors that open in new window $( new AccessibleAnchors().configure({ type: 'extend' }) ); }()); ; /* File Created: February 11, 2013 by Vishal Bhatia*/ function rearrangeFlyouts(clearDOM) { if (clearDOM) { //Remove any old .pop elements from the DOM to reload the new one. $('.flyOut.moved').remove(); } //Grab all the flyouts that are not moved yet and are not tooltips and not in WidgetManager var $flyOutDivs = $('.flyOut').not('.moved').not('.helpTip').not('.widgetManager'); var parentID; var marginLeft, marginTop; $flyOutDivs.each(function (e) { parentID = $(this).parent('.flyOutParent').attr('id'); //If the element does not have a flyOutParent, display it on the center of the screen. if (parentID == undefined) { marginLeft = '-' + $(this).outerWidth() / 2 + 'px'; marginTop = '-' + $(this).outerHeight() / 2 + 'px'; $(this).css('left', '50%'); $(this).css('margin-left', marginLeft); $(this).css('top', '50%'); $(this).css('margin-top', marginTop); $(this).appendTo('body'); $(this).addClass('moved'); //TODO: Confirm from Kyle and remove 2 lines below since they are being done through css. $(this).css('position', 'absolute'); $(this).css('z-index', '100'); } else { //Remove any pre existing copies of this element from the DOM. $('[data-parentID=' + parentID + ']').remove(); //Remove margin styles if the element has a flyOutParent. $(this).css({ 'margin-left': '', 'margin-top': '' }); $(this).appendTo('body'); $(this).addClass('moved'); //TODO: Confirm from Kyle and remove 2 lines below since they are being done through css. $(this).css('position', 'absolute'); $(this).css('z-index', '100'); $(this).attr('data-parentID', parentID); adjustFlyoutPosition($('#' + parentID), $(this)); } }); } ///Executes when the browser is being resized or the screen orientation changes(portrait/landscape). function rearrangeFlyoutsOnResizeEvents() { //Grab all the flyouts that are not moved yet and are not tooltips and not in WidgetManager var $flyOutDivs = $('.flyOut').not('.helpTip').not('.widgetManager').not('.mainNavMegaMenu.megaMenuContainer');; var parentID; var marginLeft, marginTop; $flyOutDivs.each(function (e) { parentID = $(this).data('parentid'); //If the element does not have a flyOutParent, display it on the center of the screen. if (parentID == undefined) { marginLeft = '-' + $(this).outerWidth() / 2 + 'px'; marginTop = '-' + $(this).outerHeight() / 2 + 'px'; $(this).css('margin-left', marginLeft); $(this).css('margin-top', marginTop); } else { adjustFlyoutPosition($('#' + parentID), $(this)); } }); } ///Checks if any ancestor of a flyout element is fixed positioned. function anyAncestorFixedPositioned($parent) { var anyAncestorFixedPosition = false; if ($parent.css('position') === 'fixed') anyAncestorFixedPosition = true; if (!anyAncestorFixedPosition) { $parent.parents().each(function () { if (!anyAncestorFixedPosition) { if ($(this).css('position') === 'fixed') anyAncestorFixedPosition = true; } }); } return anyAncestorFixedPosition; } function adjustFlyoutPosition($parent, $this) { var $parentElem = $parent; if ($parentElem != null) { var parentWidth = $parent.outerWidth(false); var parentHeight = $parent.outerHeight(false); var offset = $parent.offset(); if (offset != null) { var offsetLeft = offset.left; //Take into account scroll height if the document has been scrolled, to compute the top distance from viewport. VB var offsetTop = $this.css('position') === 'fixed' ? offset.top - $(document).scrollTop() : offset.top; // Take into account if the item is fixed or absolutely positioned. if (anyAncestorFixedPositioned($parent)) $this.css('position', 'fixed'); var offsetRight; var offsetBottom; if ($this.hasClass('left') || $this.hasClass('leftCorner')) { offsetLeft = offsetLeft - $this.outerWidth(false); $this.css('left', offsetLeft); } if ($this.hasClass('right') || $this.hasClass('rightCorner')) { offsetLeft = offsetLeft + parentWidth; $this.css('left', offsetLeft); } if ($this.hasClass('top') || $this.hasClass('topCorner')) { offsetBottom = offsetTop - $this.outerHeight(false); $this.css('top', offsetBottom); } if ($this.hasClass('bottom') || $this.hasClass('bottomCorner')) { offsetTop = offsetTop + parentHeight; $this.css('top', offsetTop); } if ($this.hasClass('leftEdge')) { $this.css('left', offsetLeft); if ($this.hasClass('rightEdge')) { $this.css('width', parentWidth); } } if ($this.hasClass('rightEdge')) { offsetLeft = offsetLeft + parentWidth - $this.outerWidth(false); $this.css('left', offsetLeft); } if ($this.hasClass('topEdge')) { $this.css('top', offsetTop); if ($this.hasClass('bottomEdge')) { $this.css('height', parentHeight); } } if ($this.hasClass('bottomEdge')) { offsetTop = offsetTop + parentHeight - $this.outerHeight(false); $this.css('top', offsetTop); } if ($this.hasClass('center') && ($this.hasClass('top') || $this.hasClass('bottom'))) { offsetLeft = offsetLeft + (parentWidth / 2) - ($this.outerWidth(false) / 2); $this.css('left', offsetLeft); } if ($this.hasClass('center') && ($this.hasClass('left') || $this.hasClass('right'))) { offsetTop = offsetTop + (parentHeight / 2) - ($this.outerHeight(false) / 2); $this.css('top', offsetTop); } } } }; // Note some of this functionality is in Menu.js as well // Deferred Loading for mega menus $(function () { "use strict"; var thisRef = {}; thisRef.initialized = false; var LOAD_TRIGGER_DISTANCE = 200; // in px var $megaMenus = $('[data-displaymegamenu="True"]'); function isNear(element, distance, event) { var left = element.offset().left - distance, top = element.offset().top - distance, right = left + element.width() + 2 * distance, bottom = top + element.height() + 2 * distance, x = event.pageX, y = event.pageY; return (x > left && x < right && y > top && y < bottom); }; $('body:not(.mobile)').bind('mousemove.megaMenuLazyLoad', function (e) { $megaMenus.each(function (index) { var mouseIsNear = isNear($(this), LOAD_TRIGGER_DISTANCE, e); if (mouseIsNear) { if (!thisRef.initialized) { $('body').unbind('.megaMenuLazyLoad'); thisRef.initialized = true; var megaMenuContentContainers = $('[data-displaymegamenu="True"]') .map(function () { $('#mainNavMegaMenu' + $(this).data('pageid') + ' div.pageContent').html('Loading...'); return $('#mainNavMegaMenu' + $(this).data('pageid') + ' div.pageContent').data('containerid'); }).toArray(); window.Pages.megaMenuLoaded.resolve(); reloadSharedContentContainers(megaMenuContentContainers); } } }); }); }); var reloadSharedContentContainers = function (containerIDs) { if (containerIDs.length > 0) { // Reload all mega menus? var url = getAbsoluteUrl('/Content/Load?contentCollectionID=' + $('#hdnContentCollectionID').val() + "&StructureID=" + $('#hdnStructureID').val() + "&themeID=" + $('#hdnThemeID').val()); if ($('body').hasClass('preview')) url += "&preview=true"; $.ajax({ url: url, type: 'POST', data: JSON.stringify({ "contentContainerIDs": containerIDs }), contentType: 'application/json', cache: false, async: true, ignoreEditor: true, //prevent for executing global editor event error: function (xhr, textStatus, exception) { if (xhr.status != 0) { alert("Error: " + xhr.statusText + "\nStatus: " + xhr.status); } }, success: function (response) { if (response.PageModified !== undefined && response.PageModified === true && response.PageModifiedMessage) { if (confirm(response.PageModifiedMessage)) { document.cookie = "refresh=true; max-age=5"; location.reload(); } } else if (response.ErrorMessage) alert(response.ErrorMessage); else { //Replace content containers HTML var root = document.createElement("div"); root.innerHTML = response; $(root).find('#fb-root').remove(); $('head').append($(root).find('.bundledStyles')); var allChilds = root.childNodes; for (var i = 0; i < containerIDs.length; i++) { var contentContainerID = containerIDs[i]; //Grab Content Container HTML from response var contentContainerHtml = null; for (var j = 0; j < allChilds.length; j++) { if (allChilds[j].id && allChilds[j].id == 'cc' + contentContainerID) { contentContainerHtml = allChilds[j].outerHTML; break; } } if (contentContainerHtml != null) { var $contentContainer = $('#cc' + contentContainerID); $contentContainer.empty().replaceWith(contentContainerHtml); } else { //ContentContainer Html was not found. This might happen when we have a html version and switch (Refresh containers) to a linked version on the same page. } } if (window.cpMedia) { $('.mainNavMegaMenu.megaMenuContainer').each(function () { applyElementQueryToChildren($(this)); }); } //TODO: unbind/destroy events/drag/drop on elements before initialize containers if (typeof InitializeContainers == 'function' && getCookieValue("enableLiveEdit") === "true") { InitializeContainers({ hidePopover: false }); $('.mainNavMegaMenu.megaMenuContainer').find('.pinned').removeClass('pinned'); setTimeout(function () { // It is unfortunate to use timeout here, but there is a very difficult to reproduce race condition in FF where it is still getting unpinned by something $('.mainNavMegaMenu.megaMenuContainer').find('.pinned').removeClass('pinned'); },300); } if (menuManager && typeof menuManager.attachDragAndDropHandlers == 'function') { menuManager.attachDragAndDropHandlers(); } //Execute this function or else the click event wont be registered for tabbed widgets inside megamenus. Core.Layout.attachTabbedWidgetTabHandlers(); } } }); } }; // Handle touchstart event for touch devices. First click will load the megamenus if they haven't been loaded and show the mega menu. Second click will navigate to the menu link itself. $('[data-displaymegamenu="True"]').bind('touchstart', function (e) { e.stopPropagation(); // prevent this event from bubbling up and triggering the handler on document below! if (($(this).closest('.mainNavHolderMobile')[0] !== undefined) || ($('body:not(.mobile)').length === 0)) { // Return if mobile menu is being shown return; } if (window.lastMegaMenuOpen === this) { // Used to do the second click navigation if the same menu is clicked twice. return; } e.preventDefault(); if (!window.megaMenuInitializedForTouch) { $('body').unbind('.megaMenuLazyLoad'); window.megaMenuInitializedForTouch = true; var megaMenuContentContainers = $('[data-displaymegamenu="True"]') .map(function () { $('#mainNavMegaMenu' + $(this).data('pageid') + ' div.pageContent').html('Loading...'); return $('#mainNavMegaMenu' + $(this).data('pageid') + ' div.pageContent').data('containerid'); }).toArray(); window.Pages.megaMenuLoaded.resolve(); reloadSharedContentContainers(megaMenuContentContainers); } menuManager.menuMouseOver($(this)); window.lastMegaMenuOpen = this; }); $(document).bind('touchstart click', function (e) { if (window.lastMegaMenuOpen === undefined || window.lastMegaMenuOpen === this || !isResolvedOrState(window.Pages.megaMenuLoaded)) { return; } //Skip menumouseout method if user slide up the expanded mega menu to scroll if (!e.target.id.startsWith("mainNavMegaMenu")) { if (!$(e.target).parents("aside[id^='mainNavMegaMenu']").length) { menuManager.menuMouseOut($(window.lastMegaMenuOpen)); } } }); /* Responsive Menu Font Sizing * Joshua Enfield * ------------- * This resizes menus responsively. It takes into account the original font size. * If auto widths are on font sizes are adjusted based on the size left in menu items. * If auto widths are off font sizes are adjusted based on the size left in the main nav. * --------------- * Common Usage: $('menuOLSelector').responsiveMenuText(); * jQuery Usage expects markup in the form of ol > li > a */ (function ($, window, undefined) { 'use strict'; var DEBUG = false; var diag = function (msg) { if (DEBUG) { window.console.log('[ Responsive Menus ] ' + msg); } }; $.MenuTextResizer = function (options, element) { this.$mainNavMenu = $(element); this.$topLevelMenuItems = this.$mainNavMenu.find('a'); this._init(options); }; // the options $.MenuTextResizer.defaults = { ratio: 0.5, timeout: 120, numberOfFontSizes: 20, tolerance: 0.00 }; $.MenuTextResizer.prototype = { _init: function (options) { // options this.options = $.extend(true, {}, $.MenuTextResizer.defaults, options); // local variables var self = this; this.timer = null; this.autoCreatedWrapper = false; createInnerWrappersIfWrappersDoNotExist(); var desktopFontSize = parseFloat(this.$topLevelMenuItems.css('font-size')); // Initial Font Size. When at maximum size font-size should be this. var numberOfFontSizes = this.options.numberOfFontSizes; var fontSizes = getFontSizes(); var currentFontIndex = fontSizes.length - 1; var tolerance = this.options.tolerance; var autoWidths = this.$mainNavMenu.data('autowidth') == true; var ratioToTriggerResize = autoWidths ? { menuRatio: 1.00, itemRatio: self.options.ratio } : { menuRatio: self.options.ratio, itemRatio: 1.00 }; //var ratioToTriggerResize = { menuRatio: 0.68, itemRatio: 1.00 }; //var ratioToTriggerResize = { menuRatio: 1.00, itemRatio: 0.70 }; if (autoWidths) diag('Auto Widths Detected.'); else { diag('Auto Widths Turned Off.'); } diag('Font Sizes: ' + fontSizes); // Gets list of font sizes to resize amongst function getFontSizes () { var fontSizes = []; // Linear Scale for (var i = 0; i < numberOfFontSizes; i++) { fontSizes[i] = Math.floor(desktopFontSize / numberOfFontSizes * (i + 1)); } // Exponential Decay /* fontSizes[numberOfFontSizes - 1] = desktopFontSize; for (var i = (numberOfFontSizes-2); i > 0; i--) { fontSizes[i] = Math.floor(0.95 * fontSizes[i+1]); }*/ return fontSizes; } // Increases font size. var increaseFontSize = function () { var wasFontSizeIncreased = false; if (currentFontIndex < (fontSizes.length - 1)) { currentFontIndex++; wasFontSizeIncreased = true; // ratioToTriggerResize.itemRatio -= 0.1; } self.$topLevelMenuItems.css('font-size', fontSizes[currentFontIndex]); diag('INCREASE IN SIZE TRIGGERED (sizeIndex: ' + currentFontIndex + (currentFontIndex == (numberOfFontSizes - 1) ? '(MAX)' : '') + ' ,' + fontSizes[currentFontIndex] + ')'); return wasFontSizeIncreased; }; // Decreases font size. var decreaseFontSize = function () { var wasFontSizeDecreased = false; if (currentFontIndex > 0) { currentFontIndex--; wasFontSizeDecreased = true; // ratioToTriggerResize.itemRatio += 0.1; } self.$topLevelMenuItems.css('font-size', fontSizes[currentFontIndex]); diag('DECREASE IN SIZE TRIGGERED (sizeIndex: ' + currentFontIndex + ',' + fontSizes[currentFontIndex] + ')'); return wasFontSizeDecreased; }; // Wraps menu Items with a span if spans are not already wrapping them. function createInnerWrappersIfWrappersDoNotExist () { if (self.$topLevelMenuItems.find('span').length === 0) { self.$topLevelMenuItems.removeAttr('style').wrapInner('').find('span').css('display', 'inline'); self.autoCreatedWrapper = true; } } // Get the ratios of space taken to space available for menu items and the menu itself function getRatio () { var getItemRatio = function ($item) { return $item.find('span').width() / $item.width(); }; var itemRatio = getItemRatio(self.$topLevelMenuItems.first()); var widthConsumedByMenuItems = 0; self.$topLevelMenuItems.each(function () { widthConsumedByMenuItems += $(this).outerWidth(true); var currentItemRatio = getItemRatio($(this)); if (currentItemRatio > itemRatio) { itemRatio = currentItemRatio; } }); var menuRatio = widthConsumedByMenuItems / self.$mainNavMenu.width(); var result = { menuRatio: menuRatio.toFixed(2), itemRatio: itemRatio.toFixed(2) }; return result; } // Conditions var predicates = (function () { // Should return true when an increase in size should occur. var shouldIncreaseInSize = function () { var currentRatio = getRatio(); diag(JSON.stringify(currentRatio)); if (autoWidths) { return currentRatio.itemRatio < (ratioToTriggerResize.itemRatio - tolerance); } else { return currentRatio.menuRatio < (ratioToTriggerResize.menuRatio - tolerance); } }; // Should return true when a decrease in size should occur. var shouldDescreaseInSize = function () { var currentRatio = getRatio(); diag(JSON.stringify(currentRatio)); if (autoWidths) { return currentRatio.itemRatio > (ratioToTriggerResize.itemRatio - tolerance); } else { return currentRatio.menuRatio > (ratioToTriggerResize.menuRatio - tolerance); } }; return { shouldIncreaseInSize: shouldIncreaseInSize, shouldDescreaseInSize: shouldDescreaseInSize }; }()); // Function that actually adjusts menu font sizes. this.adjustMenuFontSize = function () { while (predicates.shouldIncreaseInSize() && increaseFontSize()) ; while (predicates.shouldDescreaseInSize() && decreaseFontSize()) ; }; this._initDefault(); }, _initDefault : function () { // Setup and bind menu resizing logic var self = this; var timeout = self.options.timeout || 100; //debouncing $(window).bind('resize.responsiveMenuText', function () { self.timer && clearTimeout(self.timer); self.timer = setTimeout(function () { self.adjustMenuFontSize(); }, timeout); }); self.adjustMenuFontSize(); }, dispose: function () { var self = this; clearTimeout(self.timer); $(window).unbind('.responsiveMenuText'); if (self.autoCreatedWrapper) { self.$topLevelMenuItems.find('span').contents().unwrap(); setTimeout(function () { self.$topLevelMenuItems.removeAttr('style'); }, 200); } } }; /* jQuery Plugin Support Expected Markup structure: ol > li > a Menu Text is dynamically wrapped by a span if it isn't already. */ $.fn.responsiveMenuText = function (options) { if (typeof options === 'string') { var args = Array.prototype.slice.call(arguments, 1); this.each(function () { var instance = $.data(this, 'responsiveMenuText'); if (!instance) { diag("cannot call methods on responsiveMenuText prior to initialization; " + "attempted to call method '" + options + "'"); return; } if (!$.isFunction(instance[options]) || options.charAt(0) === "_") { diag("no such method '" + options + "' for responsiveMenuText instance"); return; } instance[options].apply(instance, args); }); } else { this.each(function () { var instance = $.data(this, 'responsiveMenuText'); if (instance) { instance._init(options); } else { instance = $.data(this, 'responsiveMenuText', new $.MenuTextResizer(options, this)); } }); } return this; }; })(jQuery, window); /** * Based on jquery.rwdmenu.js v1.0.1 * http://www.codrops.com * */ ; (function ($, window, undefined) { 'use strict'; // global var Modernizr = window.Modernizr, $body = $('body'); $.RWDMenu = function (options, element) { this.$el = $(element); this._init(options); }; // the options $.RWDMenu.defaults = { // classes for the animation effects animationClasses: { classin: 'rwd-animate-in', classout: 'rwd-animate-out' }, // callback: click a link that has a sub menu // el is the link element (li); name is the level name onLevelClick: function (el, name) { return false; }, // callback: click a link that does not have a sub menu // el is the link element (li); ev is the event obj onLinkClick: function (el, ev) { return false; } }; $.RWDMenu.prototype = { _init: function (options) { // options this.options = $.extend(true, {}, $.RWDMenu.defaults, options); // cache some elements and initialize some variables this._config(); var animEndEventNames = { 'WebkitAnimation': 'webkitAnimationEnd', 'OAnimation': 'oAnimationEnd', 'msAnimation': 'MSAnimationEnd', 'animation': 'animationend' }, transEndEventNames = { 'WebkitTransition': 'webkitTransitionEnd', 'MozTransition': 'transitionend', 'OTransition': 'oTransitionEnd', 'msTransition': 'MSTransitionEnd', 'transition': 'transitionend' }; // animation end event name this.animEndEventName = animEndEventNames[Modernizr.prefixed('animation')] + '.rwdmenu'; // transition end event name this.transEndEventName = transEndEventNames[Modernizr.prefixed('transition')] + '.rwdmenu', // support for css animations and css transitions this.supportAnimations = Modernizr.cssanimations, this.supportTransitions = Modernizr.csstransitions; var self = this; this.clickMenuItem = function (event) { //if (!menuManager.mobileMainNav) return true; event.stopPropagation(); var $li = $(this), $submenu = $li.children('ol.rwd-submenu'); if ($submenu.length == 0) { var id = $li.attr('id'); //.replace(/item|leftItem/i, ''); var $olSubMenu = menuManager.$divListSubMenus.find('#Parent' + id); if ($olSubMenu.length > 1) { //remove duplicates. they might have been added by different menu (main/side) $olSubMenu.slice(1).remove(); $olSubMenu = menuManager.$divListSubMenus.find('#Parent' + id); } if ($olSubMenu.length == 1) { var $parentAnchor = $li.children('a:first').clone(); $parentAnchor.removeAttr('class').addClass('navMenuItem openThePageLink').html('Open the ' + $parentAnchor.text() + ' page').css('z-index', '2').attr('role', 'menuitem'); var $liToParent = $('
  • ').append($parentAnchor); $olSubMenu.prepend($liToParent); var $back = $('
  • Back
  • '); $back.bind('click.rwdmenu', self.clickBack); $olSubMenu.prepend($back); $olSubMenu.addClass('rwd-submenu'); $olSubMenu.find('li:not(.rwd-back)').bind('click.rwdmenu', self.clickMenuItem); $li.append($olSubMenu); $submenu = $olSubMenu; } } if ($submenu.length > 0) { var $flyin = $submenu.clone().css('opacity', 0).insertAfter(self.$menu), onAnimationEndFn = function () { self.$menu.unbind(self.animEndEventName).removeClass(self.options.animationClasses.classout).addClass('rwd-subview'); $('.rwd-subviewopen').children('ol').attr('aria-hidden', 'true'); $li.addClass('rwd-subviewopen').parents('.rwd-subviewopen:first').removeClass('rwd-subviewopen').addClass('rwd-subview'); $li.children('ol').attr('aria-hidden', 'false'); $flyin.remove(); $li.find('.openThePageLink').focus(); }; setTimeout(function () { $flyin.addClass(self.options.animationClasses.classin); self.$menu.addClass(self.options.animationClasses.classout); if (self.supportAnimations) { self.$menu.bind(self.animEndEventName, onAnimationEndFn); } else { onAnimationEndFn.call(); } self.options.onLevelClick($li, $li.children('a:first').text()); }); return false; } else { self.options.onLinkClick($li, event); } }; this.clickBack = function (event) { var $this = $(this), $submenu = $this.parents('ol.rwd-submenu:first'), $item = $submenu.parent(), $flyin = $submenu.clone().insertAfter(self.$menu); var onAnimationEndFn = function () { self.$menu.unbind(self.animEndEventName).removeClass(self.options.animationClasses.classin); $flyin.remove(); }; setTimeout(function () { $flyin.addClass(self.options.animationClasses.classout); self.$menu.addClass(self.options.animationClasses.classin); if (self.supportAnimations) { self.$menu.bind(self.animEndEventName, onAnimationEndFn); } else { onAnimationEndFn.call(); } $item.removeClass('rwd-subviewopen').children('ol').attr('aria-hidden', 'true'); var $subview = $this.parents('.rwd-subview:first'); if ($subview.is('li')) { $subview.addClass('rwd-subviewopen').children('ol').attr('aria-hidden', 'false'); } $subview.removeClass('rwd-subview'); $('ol#mainNavMenu').find('li > a').first().focus(); }); return false; }; this._initEvents(); }, _config: function () { this.$menu = this.$el;// this.$el.children('ol.rwd-menu'); this.$menuitems = this.$menu.find('li.topMenuItem'); this.$menu.addClass('rwd-menu'); }, _initEvents: function () { var self = this; this.$menuitems.bind('click.rwdmenu', self.clickMenuItem); }, destroy: function () { //Remove classes, other events, not needed lis (back, to parent) and place back into hidden div. this.$menu.removeClass('rwd-menu rwd-subview'); this.$menu.find('li').removeClass('rwd-subviewopen rwd-subview').unbind('.rwdmenu'); this.$menu.find('li.rwd-back').remove(); this.$menu.find('li.toParent').remove(); this.$menu.find('ol').removeClass('rwd-submenu').each(function () { menuManager.$divListSubMenus.append($(this)); }); } }; var logError = function (message) { if (window.console) { window.console.error(message); } }; $.fn.rwdmenu = function (options) { if (typeof options === 'string') { var args = Array.prototype.slice.call(arguments, 1); this.each(function () { var instance = $.data(this, 'rwdmenu'); if (!instance) { logError("cannot call methods on rwdmenu prior to initialization; " + "attempted to call method '" + options + "'"); return; } if (!$.isFunction(instance[options]) || options.charAt(0) === "_") { logError("no such method '" + options + "' for rwdmenu instance"); return; } instance[options].apply(instance, args); }); } else { this.each(function () { var instance = $.data(this, 'rwdmenu'); if (instance) { instance._init(); } else { instance = $.data(this, 'rwdmenu', new $.RWDMenu(options, this)); } }); } return this; }; })(jQuery, window); /*! jQuery UI - v1.10.4 - 2014-01-17 * http://jqueryui.com * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.ui.effect.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.effect-blind.js, jquery.ui.effect-bounce.js, jquery.ui.effect-clip.js, jquery.ui.effect-drop.js, jquery.ui.effect-explode.js, jquery.ui.effect-fade.js, jquery.ui.effect-fold.js, jquery.ui.effect-highlight.js, jquery.ui.effect-pulsate.js, jquery.ui.effect-scale.js, jquery.ui.effect-shake.js, jquery.ui.effect-slide.js, jquery.ui.effect-transfer.js, jquery.ui.menu.js, jquery.ui.position.js, jquery.ui.progressbar.js, jquery.ui.slider.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */ (function(t,e){function i(e,i){var n,o,a,r=e.nodeName.toLowerCase();return"area"===r?(n=e.parentNode,o=n.name,e.href&&o&&"map"===n.nodeName.toLowerCase()?(a=t("img[usemap=#"+o+"]")[0],!!a&&s(a)):!1):(/input|select|textarea|button|object/.test(r)?!e.disabled:"a"===r?e.href||i:i)&&s(e)}function s(e){return t.expr.filters.visible(e)&&!t(e).parents().addBack().filter(function(){return"hidden"===t.css(this,"visibility")}).length}var n=0,o=/^ui-id-\d+$/;t.ui=t.ui||{},t.extend(t.ui,{version:"1.10.4",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),t.fn.extend({focus:function(e){return function(i,s){return"number"==typeof i?this.each(function(){var e=this;setTimeout(function(){t(e).focus(),s&&s.call(e)},i)}):e.apply(this,arguments)}}(t.fn.focus),scrollParent:function(){var e;return e=t.ui.ie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(t.css(this,"position"))&&/(auto|scroll)/.test(t.css(this,"overflow")+t.css(this,"overflow-y")+t.css(this,"overflow-x"))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(t.css(this,"overflow")+t.css(this,"overflow-y")+t.css(this,"overflow-x"))}).eq(0),/fixed/.test(this.css("position"))||!e.length?t(document):e},zIndex:function(i){if(i!==e)return this.css("zIndex",i);if(this.length)for(var s,n,o=t(this[0]);o.length&&o[0]!==document;){if(s=o.css("position"),("absolute"===s||"relative"===s||"fixed"===s)&&(n=parseInt(o.css("zIndex"),10),!isNaN(n)&&0!==n))return n;o=o.parent()}return 0},uniqueId:function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++n)})},removeUniqueId:function(){return this.each(function(){o.test(this.id)&&t(this).removeAttr("id")})}}),t.extend(t.expr[":"],{data:t.expr.createPseudo?t.expr.createPseudo(function(e){return function(i){return!!t.data(i,e)}}):function(e,i,s){return!!t.data(e,s[3])},focusable:function(e){return i(e,!isNaN(t.attr(e,"tabindex")))},tabbable:function(e){var s=t.attr(e,"tabindex"),n=isNaN(s);return(n||s>=0)&&i(e,!n)}}),t("").outerWidth(1).jquery||t.each(["Width","Height"],function(i,s){function n(e,i,s,n){return t.each(o,function(){i-=parseFloat(t.css(e,"padding"+this))||0,s&&(i-=parseFloat(t.css(e,"border"+this+"Width"))||0),n&&(i-=parseFloat(t.css(e,"margin"+this))||0)}),i}var o="Width"===s?["Left","Right"]:["Top","Bottom"],a=s.toLowerCase(),r={innerWidth:t.fn.innerWidth,innerHeight:t.fn.innerHeight,outerWidth:t.fn.outerWidth,outerHeight:t.fn.outerHeight};t.fn["inner"+s]=function(i){return i===e?r["inner"+s].call(this):this.each(function(){t(this).css(a,n(this,i)+"px")})},t.fn["outer"+s]=function(e,i){return"number"!=typeof e?r["outer"+s].call(this,e):this.each(function(){t(this).css(a,n(this,e,!0,i)+"px")})}}),t.fn.addBack||(t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t("").data("a-b","a").removeData("a-b").data("a-b")&&(t.fn.removeData=function(e){return function(i){return arguments.length?e.call(this,t.camelCase(i)):e.call(this)}}(t.fn.removeData)),t.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),t.support.selectstart="onselectstart"in document.createElement("div"),t.fn.extend({disableSelection:function(){return this.bind((t.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(t){t.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),t.extend(t.ui,{plugin:{add:function(e,i,s){var n,o=t.ui[e].prototype;for(n in s)o.plugins[n]=o.plugins[n]||[],o.plugins[n].push([i,s[n]])},call:function(t,e,i){var s,n=t.plugins[e];if(n&&t.element[0].parentNode&&11!==t.element[0].parentNode.nodeType)for(s=0;n.length>s;s++)t.options[n[s][0]]&&n[s][1].apply(t.element,i)}},hasScroll:function(e,i){if("hidden"===t(e).css("overflow"))return!1;var s=i&&"left"===i?"scrollLeft":"scrollTop",n=!1;return e[s]>0?!0:(e[s]=1,n=e[s]>0,e[s]=0,n)}})})(jQuery),function(t,e){var i=0,s=Array.prototype.slice,n=t.cleanData;t.cleanData=function(e){for(var i,s=0;null!=(i=e[s]);s++)try{t(i).triggerHandler("remove")}catch(o){}n(e)},t.widget=function(i,s,n){var o,a,r,h,l={},c=i.split(".")[0];i=i.split(".")[1],o=c+"-"+i,n||(n=s,s=t.Widget),t.expr[":"][o.toLowerCase()]=function(e){return!!t.data(e,o)},t[c]=t[c]||{},a=t[c][i],r=t[c][i]=function(t,i){return this._createWidget?(arguments.length&&this._createWidget(t,i),e):new r(t,i)},t.extend(r,a,{version:n.version,_proto:t.extend({},n),_childConstructors:[]}),h=new s,h.options=t.widget.extend({},h.options),t.each(n,function(i,n){return t.isFunction(n)?(l[i]=function(){var t=function(){return s.prototype[i].apply(this,arguments)},e=function(t){return s.prototype[i].apply(this,t)};return function(){var i,s=this._super,o=this._superApply;return this._super=t,this._superApply=e,i=n.apply(this,arguments),this._super=s,this._superApply=o,i}}(),e):(l[i]=n,e)}),r.prototype=t.widget.extend(h,{widgetEventPrefix:a?h.widgetEventPrefix||i:i},l,{constructor:r,namespace:c,widgetName:i,widgetFullName:o}),a?(t.each(a._childConstructors,function(e,i){var s=i.prototype;t.widget(s.namespace+"."+s.widgetName,r,i._proto)}),delete a._childConstructors):s._childConstructors.push(r),t.widget.bridge(i,r)},t.widget.extend=function(i){for(var n,o,a=s.call(arguments,1),r=0,h=a.length;h>r;r++)for(n in a[r])o=a[r][n],a[r].hasOwnProperty(n)&&o!==e&&(i[n]=t.isPlainObject(o)?t.isPlainObject(i[n])?t.widget.extend({},i[n],o):t.widget.extend({},o):o);return i},t.widget.bridge=function(i,n){var o=n.prototype.widgetFullName||i;t.fn[i]=function(a){var r="string"==typeof a,h=s.call(arguments,1),l=this;return a=!r&&h.length?t.widget.extend.apply(null,[a].concat(h)):a,r?this.each(function(){var s,n=t.data(this,o);return n?t.isFunction(n[a])&&"_"!==a.charAt(0)?(s=n[a].apply(n,h),s!==n&&s!==e?(l=s&&s.jquery?l.pushStack(s.get()):s,!1):e):t.error("no such method '"+a+"' for "+i+" widget instance"):t.error("cannot call methods on "+i+" prior to initialization; "+"attempted to call method '"+a+"'")}):this.each(function(){var e=t.data(this,o);e?e.option(a||{})._init():t.data(this,o,new n(a,this))}),l}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
    ",options:{disabled:!1,create:null},_createWidget:function(e,s){s=t(s||this.defaultElement||this)[0],this.element=t(s),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=t.widget.extend({},this.options,this._getCreateOptions(),e),this.bindings=t(),this.hoverable=t(),this.focusable=t(),s!==this&&(t.data(s,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===s&&this.destroy()}}),this.document=t(s.style?s.ownerDocument:s.document||s),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:t.noop,_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(t.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:t.noop,widget:function(){return this.element},option:function(i,s){var n,o,a,r=i;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof i)if(r={},n=i.split("."),i=n.shift(),n.length){for(o=r[i]=t.widget.extend({},this.options[i]),a=0;n.length-1>a;a++)o[n[a]]=o[n[a]]||{},o=o[n[a]];if(i=n.pop(),1===arguments.length)return o[i]===e?null:o[i];o[i]=s}else{if(1===arguments.length)return this.options[i]===e?null:this.options[i];r[i]=s}return this._setOptions(r),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return this.options[t]=e,"disabled"===t&&(this.widget().toggleClass(this.widgetFullName+"-disabled ui-state-disabled",!!e).attr("aria-disabled",e),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")),this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_on:function(i,s,n){var o,a=this;"boolean"!=typeof i&&(n=s,s=i,i=!1),n?(s=o=t(s),this.bindings=this.bindings.add(s)):(n=s,s=this.element,o=this.widget()),t.each(n,function(n,r){function h(){return i||a.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof r?a[r]:r).apply(a,arguments):e}"string"!=typeof r&&(h.guid=r.guid=r.guid||h.guid||t.guid++);var l=n.match(/^(\w+)\s*(.*)$/),c=l[1]+a.eventNamespace,u=l[2];u?o.delegate(u,c,h):s.bind(c,h)})},_off:function(t,e){e=(e||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,t.unbind(e).undelegate(e)},_delay:function(t,e){function i(){return("string"==typeof t?s[t]:t).apply(s,arguments)}var s=this;return setTimeout(i,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){t(e.currentTarget).addClass("ui-state-hover")},mouseleave:function(e){t(e.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){t(e.currentTarget).addClass("ui-state-focus")},focusout:function(e){t(e.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(e,i,s){var n,o,a=this.options[e];if(s=s||{},i=t.Event(i),i.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),i.target=this.element[0],o=i.originalEvent)for(n in o)n in i||(i[n]=o[n]);return this.element.trigger(i,s),!(t.isFunction(a)&&a.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,i){t.Widget.prototype["_"+e]=function(s,n,o){"string"==typeof n&&(n={effect:n});var a,r=n?n===!0||"number"==typeof n?i:n.effect||i:e;n=n||{},"number"==typeof n&&(n={duration:n}),a=!t.isEmptyObject(n),n.complete=o,n.delay&&s.delay(n.delay),a&&t.effects&&t.effects.effect[r]?s[e](n):r!==e&&s[r]?s[r](n.duration,n.easing,o):s.queue(function(i){t(this)[e](),o&&o.call(s[0]),i()})}})}(jQuery),function(t){var e=!1;t(document).mouseup(function(){e=!1}),t.widget("ui.mouse",{version:"1.10.4",options:{cancel:"input,textarea,button,select,option",distance:1,delay:0},_mouseInit:function(){var e=this;this.element.bind("mousedown."+this.widgetName,function(t){return e._mouseDown(t)}).bind("click."+this.widgetName,function(i){return!0===t.data(i.target,e.widgetName+".preventClickEvent")?(t.removeData(i.target,e.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):undefined}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&t(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(i){if(!e){this._mouseStarted&&this._mouseUp(i),this._mouseDownEvent=i;var s=this,n=1===i.which,o="string"==typeof this.options.cancel&&i.target.nodeName?t(i.target).closest(this.options.cancel).length:!1;return n&&!o&&this._mouseCapture(i)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){s.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(i)&&this._mouseDelayMet(i)&&(this._mouseStarted=this._mouseStart(i)!==!1,!this._mouseStarted)?(i.preventDefault(),!0):(!0===t.data(i.target,this.widgetName+".preventClickEvent")&&t.removeData(i.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(t){return s._mouseMove(t)},this._mouseUpDelegate=function(t){return s._mouseUp(t)},t(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),i.preventDefault(),e=!0,!0)):!0}},_mouseMove:function(e){return t.ui.ie&&(!document.documentMode||9>document.documentMode)&&!e.button?this._mouseUp(e):this._mouseStarted?(this._mouseDrag(e),e.preventDefault()):(this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,e)!==!1,this._mouseStarted?this._mouseDrag(e):this._mouseUp(e)),!this._mouseStarted)},_mouseUp:function(e){return t(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,e.target===this._mouseDownEvent.target&&t.data(e.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(e)),!1},_mouseDistanceMet:function(t){return Math.max(Math.abs(this._mouseDownEvent.pageX-t.pageX),Math.abs(this._mouseDownEvent.pageY-t.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}})}(jQuery),function(t){t.widget("ui.draggable",t.ui.mouse,{version:"1.10.4",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1,drag:null,start:null,stop:null},_create:function(){"original"!==this.options.helper||/^(?:r|a|f)/.test(this.element.css("position"))||(this.element[0].style.position="relative"),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._mouseInit()},_destroy:function(){this.element.removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled"),this._mouseDestroy()},_mouseCapture:function(e){var i=this.options;return this.helper||i.disabled||t(e.target).closest(".ui-resizable-handle").length>0?!1:(this.handle=this._getHandle(e),this.handle?(t(i.iframeFix===!0?"iframe":i.iframeFix).each(function(){t("
    ").css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1e3}).css(t(this).offset()).appendTo("body")}),!0):!1)},_mouseStart:function(e){var i=this.options;return this.helper=this._createHelper(e),this.helper.addClass("ui-draggable-dragging"),this._cacheHelperProportions(),t.ui.ddmanager&&(t.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(),this.offsetParent=this.helper.offsetParent(),this.offsetParentCssPosition=this.offsetParent.css("position"),this.offset=this.positionAbs=this.element.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},this.offset.scroll=!1,t.extend(this.offset,{click:{left:e.pageX-this.offset.left,top:e.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this.position=this._generatePosition(e),this.originalPageX=e.pageX,this.originalPageY=e.pageY,i.cursorAt&&this._adjustOffsetFromHelper(i.cursorAt),this._setContainment(),this._trigger("start",e)===!1?(this._clear(),!1):(this._cacheHelperProportions(),t.ui.ddmanager&&!i.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e),this._mouseDrag(e,!0),t.ui.ddmanager&&t.ui.ddmanager.dragStart(this,e),!0)},_mouseDrag:function(e,i){if("fixed"===this.offsetParentCssPosition&&(this.offset.parent=this._getParentOffset()),this.position=this._generatePosition(e),this.positionAbs=this._convertPositionTo("absolute"),!i){var s=this._uiHash();if(this._trigger("drag",e,s)===!1)return this._mouseUp({}),!1;this.position=s.position}return this.options.axis&&"y"===this.options.axis||(this.helper[0].style.left=this.position.left+"px"),this.options.axis&&"x"===this.options.axis||(this.helper[0].style.top=this.position.top+"px"),t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),!1},_mouseStop:function(e){var i=this,s=!1;return t.ui.ddmanager&&!this.options.dropBehaviour&&(s=t.ui.ddmanager.drop(this,e)),this.dropped&&(s=this.dropped,this.dropped=!1),"original"!==this.options.helper||t.contains(this.element[0].ownerDocument,this.element[0])?("invalid"===this.options.revert&&!s||"valid"===this.options.revert&&s||this.options.revert===!0||t.isFunction(this.options.revert)&&this.options.revert.call(this.element,s)?t(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){i._trigger("stop",e)!==!1&&i._clear()}):this._trigger("stop",e)!==!1&&this._clear(),!1):!1},_mouseUp:function(e){return t("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)}),t.ui.ddmanager&&t.ui.ddmanager.dragStop(this,e),t.ui.mouse.prototype._mouseUp.call(this,e)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(e){return this.options.handle?!!t(e.target).closest(this.element.find(this.options.handle)).length:!0},_createHelper:function(e){var i=this.options,s=t.isFunction(i.helper)?t(i.helper.apply(this.element[0],[e])):"clone"===i.helper?this.element.clone().removeAttr("id"):this.element;return s.parents("body").length||s.appendTo("parent"===i.appendTo?this.element[0].parentNode:i.appendTo),s[0]===this.element[0]||/(fixed|absolute)/.test(s.css("position"))||s.css("position","absolute"),s},_adjustOffsetFromHelper:function(e){"string"==typeof e&&(e=e.split(" ")),t.isArray(e)&&(e={left:+e[0],top:+e[1]||0}),"left"in e&&(this.offset.click.left=e.left+this.margins.left),"right"in e&&(this.offset.click.left=this.helperProportions.width-e.right+this.margins.left),"top"in e&&(this.offset.click.top=e.top+this.margins.top),"bottom"in e&&(this.offset.click.top=this.helperProportions.height-e.bottom+this.margins.top)},_getParentOffset:function(){var e=this.offsetParent.offset();return"absolute"===this.cssPosition&&this.scrollParent[0]!==document&&t.contains(this.scrollParent[0],this.offsetParent[0])&&(e.left+=this.scrollParent.scrollLeft(),e.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]===document.body||this.offsetParent[0].tagName&&"html"===this.offsetParent[0].tagName.toLowerCase()&&t.ui.ie)&&(e={top:0,left:0}),{top:e.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:e.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"===this.cssPosition){var t=this.element.position();return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:t.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e,i,s,n=this.options;return n.containment?"window"===n.containment?(this.containment=[t(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,t(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,t(window).scrollLeft()+t(window).width()-this.helperProportions.width-this.margins.left,t(window).scrollTop()+(t(window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],undefined):"document"===n.containment?(this.containment=[0,0,t(document).width()-this.helperProportions.width-this.margins.left,(t(document).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],undefined):n.containment.constructor===Array?(this.containment=n.containment,undefined):("parent"===n.containment&&(n.containment=this.helper[0].parentNode),i=t(n.containment),s=i[0],s&&(e="hidden"!==i.css("overflow"),this.containment=[(parseInt(i.css("borderLeftWidth"),10)||0)+(parseInt(i.css("paddingLeft"),10)||0),(parseInt(i.css("borderTopWidth"),10)||0)+(parseInt(i.css("paddingTop"),10)||0),(e?Math.max(s.scrollWidth,s.offsetWidth):s.offsetWidth)-(parseInt(i.css("borderRightWidth"),10)||0)-(parseInt(i.css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(e?Math.max(s.scrollHeight,s.offsetHeight):s.offsetHeight)-(parseInt(i.css("borderBottomWidth"),10)||0)-(parseInt(i.css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relative_container=i),undefined):(this.containment=null,undefined)},_convertPositionTo:function(e,i){i||(i=this.position);var s="absolute"===e?1:-1,n="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent;return this.offset.scroll||(this.offset.scroll={top:n.scrollTop(),left:n.scrollLeft()}),{top:i.top+this.offset.relative.top*s+this.offset.parent.top*s-("fixed"===this.cssPosition?-this.scrollParent.scrollTop():this.offset.scroll.top)*s,left:i.left+this.offset.relative.left*s+this.offset.parent.left*s-("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():this.offset.scroll.left)*s}},_generatePosition:function(e){var i,s,n,o,a=this.options,r="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,h=e.pageX,l=e.pageY;return this.offset.scroll||(this.offset.scroll={top:r.scrollTop(),left:r.scrollLeft()}),this.originalPosition&&(this.containment&&(this.relative_container?(s=this.relative_container.offset(),i=[this.containment[0]+s.left,this.containment[1]+s.top,this.containment[2]+s.left,this.containment[3]+s.top]):i=this.containment,e.pageX-this.offset.click.lefti[2]&&(h=i[2]+this.offset.click.left),e.pageY-this.offset.click.top>i[3]&&(l=i[3]+this.offset.click.top)),a.grid&&(n=a.grid[1]?this.originalPageY+Math.round((l-this.originalPageY)/a.grid[1])*a.grid[1]:this.originalPageY,l=i?n-this.offset.click.top>=i[1]||n-this.offset.click.top>i[3]?n:n-this.offset.click.top>=i[1]?n-a.grid[1]:n+a.grid[1]:n,o=a.grid[0]?this.originalPageX+Math.round((h-this.originalPageX)/a.grid[0])*a.grid[0]:this.originalPageX,h=i?o-this.offset.click.left>=i[0]||o-this.offset.click.left>i[2]?o:o-this.offset.click.left>=i[0]?o-a.grid[0]:o+a.grid[0]:o)),{top:l-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():this.offset.scroll.top),left:h-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():this.offset.scroll.left)}},_clear:function(){this.helper.removeClass("ui-draggable-dragging"),this.helper[0]===this.element[0]||this.cancelHelperRemoval||this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1},_trigger:function(e,i,s){return s=s||this._uiHash(),t.ui.plugin.call(this,e,[i,s]),"drag"===e&&(this.positionAbs=this._convertPositionTo("absolute")),t.Widget.prototype._trigger.call(this,e,i,s)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),t.ui.plugin.add("draggable","connectToSortable",{start:function(e,i){var s=t(this).data("ui-draggable"),n=s.options,o=t.extend({},i,{item:s.element});s.sortables=[],t(n.connectToSortable).each(function(){var i=t.data(this,"ui-sortable");i&&!i.options.disabled&&(s.sortables.push({instance:i,shouldRevert:i.options.revert}),i.refreshPositions(),i._trigger("activate",e,o))})},stop:function(e,i){var s=t(this).data("ui-draggable"),n=t.extend({},i,{item:s.element});t.each(s.sortables,function(){this.instance.isOver?(this.instance.isOver=0,s.cancelHelperRemoval=!0,this.instance.cancelHelperRemoval=!1,this.shouldRevert&&(this.instance.options.revert=this.shouldRevert),this.instance._mouseStop(e),this.instance.options.helper=this.instance.options._helper,"original"===s.options.helper&&this.instance.currentItem.css({top:"auto",left:"auto"})):(this.instance.cancelHelperRemoval=!1,this.instance._trigger("deactivate",e,n))})},drag:function(e,i){var s=t(this).data("ui-draggable"),n=this;t.each(s.sortables,function(){var o=!1,a=this;this.instance.positionAbs=s.positionAbs,this.instance.helperProportions=s.helperProportions,this.instance.offset.click=s.offset.click,this.instance._intersectsWith(this.instance.containerCache)&&(o=!0,t.each(s.sortables,function(){return this.instance.positionAbs=s.positionAbs,this.instance.helperProportions=s.helperProportions,this.instance.offset.click=s.offset.click,this!==a&&this.instance._intersectsWith(this.instance.containerCache)&&t.contains(a.instance.element[0],this.instance.element[0])&&(o=!1),o})),o?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=t(n).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item",!0),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return i.helper[0]},e.target=this.instance.currentItem[0],this.instance._mouseCapture(e,!0),this.instance._mouseStart(e,!0,!0),this.instance.offset.click.top=s.offset.click.top,this.instance.offset.click.left=s.offset.click.left,this.instance.offset.parent.left-=s.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=s.offset.parent.top-this.instance.offset.parent.top,s._trigger("toSortable",e),s.dropped=this.instance.element,s.currentItem=s.element,this.instance.fromOutside=s),this.instance.currentItem&&this.instance._mouseDrag(e)):this.instance.isOver&&(this.instance.isOver=0,this.instance.cancelHelperRemoval=!0,this.instance.options.revert=!1,this.instance._trigger("out",e,this.instance._uiHash(this.instance)),this.instance._mouseStop(e,!0),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&this.instance.placeholder.remove(),s._trigger("fromSortable",e),s.dropped=!1)})}}),t.ui.plugin.add("draggable","cursor",{start:function(){var e=t("body"),i=t(this).data("ui-draggable").options;e.css("cursor")&&(i._cursor=e.css("cursor")),e.css("cursor",i.cursor)},stop:function(){var e=t(this).data("ui-draggable").options;e._cursor&&t("body").css("cursor",e._cursor)}}),t.ui.plugin.add("draggable","opacity",{start:function(e,i){var s=t(i.helper),n=t(this).data("ui-draggable").options;s.css("opacity")&&(n._opacity=s.css("opacity")),s.css("opacity",n.opacity)},stop:function(e,i){var s=t(this).data("ui-draggable").options;s._opacity&&t(i.helper).css("opacity",s._opacity)}}),t.ui.plugin.add("draggable","scroll",{start:function(){var e=t(this).data("ui-draggable");e.scrollParent[0]!==document&&"HTML"!==e.scrollParent[0].tagName&&(e.overflowOffset=e.scrollParent.offset())},drag:function(e){var i=t(this).data("ui-draggable"),s=i.options,n=!1;i.scrollParent[0]!==document&&"HTML"!==i.scrollParent[0].tagName?(s.axis&&"x"===s.axis||(i.overflowOffset.top+i.scrollParent[0].offsetHeight-e.pageY=0;u--)r=p.snapElements[u].left,h=r+p.snapElements[u].width,l=p.snapElements[u].top,c=l+p.snapElements[u].height,r-g>v||m>h+g||l-g>b||_>c+g||!t.contains(p.snapElements[u].item.ownerDocument,p.snapElements[u].item)?(p.snapElements[u].snapping&&p.options.snap.release&&p.options.snap.release.call(p.element,e,t.extend(p._uiHash(),{snapItem:p.snapElements[u].item})),p.snapElements[u].snapping=!1):("inner"!==f.snapMode&&(s=g>=Math.abs(l-b),n=g>=Math.abs(c-_),o=g>=Math.abs(r-v),a=g>=Math.abs(h-m),s&&(i.position.top=p._convertPositionTo("relative",{top:l-p.helperProportions.height,left:0}).top-p.margins.top),n&&(i.position.top=p._convertPositionTo("relative",{top:c,left:0}).top-p.margins.top),o&&(i.position.left=p._convertPositionTo("relative",{top:0,left:r-p.helperProportions.width}).left-p.margins.left),a&&(i.position.left=p._convertPositionTo("relative",{top:0,left:h}).left-p.margins.left)),d=s||n||o||a,"outer"!==f.snapMode&&(s=g>=Math.abs(l-_),n=g>=Math.abs(c-b),o=g>=Math.abs(r-m),a=g>=Math.abs(h-v),s&&(i.position.top=p._convertPositionTo("relative",{top:l,left:0}).top-p.margins.top),n&&(i.position.top=p._convertPositionTo("relative",{top:c-p.helperProportions.height,left:0}).top-p.margins.top),o&&(i.position.left=p._convertPositionTo("relative",{top:0,left:r}).left-p.margins.left),a&&(i.position.left=p._convertPositionTo("relative",{top:0,left:h-p.helperProportions.width}).left-p.margins.left)),!p.snapElements[u].snapping&&(s||n||o||a||d)&&p.options.snap.snap&&p.options.snap.snap.call(p.element,e,t.extend(p._uiHash(),{snapItem:p.snapElements[u].item})),p.snapElements[u].snapping=s||n||o||a||d)}}),t.ui.plugin.add("draggable","stack",{start:function(){var e,i=this.data("ui-draggable").options,s=t.makeArray(t(i.stack)).sort(function(e,i){return(parseInt(t(e).css("zIndex"),10)||0)-(parseInt(t(i).css("zIndex"),10)||0)});s.length&&(e=parseInt(t(s[0]).css("zIndex"),10)||0,t(s).each(function(i){t(this).css("zIndex",e+i)}),this.css("zIndex",e+s.length))}}),t.ui.plugin.add("draggable","zIndex",{start:function(e,i){var s=t(i.helper),n=t(this).data("ui-draggable").options;s.css("zIndex")&&(n._zIndex=s.css("zIndex")),s.css("zIndex",n.zIndex)},stop:function(e,i){var s=t(this).data("ui-draggable").options;s._zIndex&&t(i.helper).css("zIndex",s._zIndex)}})}(jQuery),function(t){function e(t,e,i){return t>e&&e+i>t}t.widget("ui.droppable",{version:"1.10.4",widgetEventPrefix:"drop",options:{accept:"*",activeClass:!1,addClasses:!0,greedy:!1,hoverClass:!1,scope:"default",tolerance:"intersect",activate:null,deactivate:null,drop:null,out:null,over:null},_create:function(){var e,i=this.options,s=i.accept; this.isover=!1,this.isout=!0,this.accept=t.isFunction(s)?s:function(t){return t.is(s)},this.proportions=function(){return arguments.length?(e=arguments[0],undefined):e?e:e={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight}},t.ui.ddmanager.droppables[i.scope]=t.ui.ddmanager.droppables[i.scope]||[],t.ui.ddmanager.droppables[i.scope].push(this),i.addClasses&&this.element.addClass("ui-droppable")},_destroy:function(){for(var e=0,i=t.ui.ddmanager.droppables[this.options.scope];i.length>e;e++)i[e]===this&&i.splice(e,1);this.element.removeClass("ui-droppable ui-droppable-disabled")},_setOption:function(e,i){"accept"===e&&(this.accept=t.isFunction(i)?i:function(t){return t.is(i)}),t.Widget.prototype._setOption.apply(this,arguments)},_activate:function(e){var i=t.ui.ddmanager.current;this.options.activeClass&&this.element.addClass(this.options.activeClass),i&&this._trigger("activate",e,this.ui(i))},_deactivate:function(e){var i=t.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass),i&&this._trigger("deactivate",e,this.ui(i))},_over:function(e){var i=t.ui.ddmanager.current;i&&(i.currentItem||i.element)[0]!==this.element[0]&&this.accept.call(this.element[0],i.currentItem||i.element)&&(this.options.hoverClass&&this.element.addClass(this.options.hoverClass),this._trigger("over",e,this.ui(i)))},_out:function(e){var i=t.ui.ddmanager.current;i&&(i.currentItem||i.element)[0]!==this.element[0]&&this.accept.call(this.element[0],i.currentItem||i.element)&&(this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("out",e,this.ui(i)))},_drop:function(e,i){var s=i||t.ui.ddmanager.current,n=!1;return s&&(s.currentItem||s.element)[0]!==this.element[0]?(this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function(){var e=t.data(this,"ui-droppable");return e.options.greedy&&!e.options.disabled&&e.options.scope===s.options.scope&&e.accept.call(e.element[0],s.currentItem||s.element)&&t.ui.intersect(s,t.extend(e,{offset:e.element.offset()}),e.options.tolerance)?(n=!0,!1):undefined}),n?!1:this.accept.call(this.element[0],s.currentItem||s.element)?(this.options.activeClass&&this.element.removeClass(this.options.activeClass),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("drop",e,this.ui(s)),this.element):!1):!1},ui:function(t){return{draggable:t.currentItem||t.element,helper:t.helper,position:t.position,offset:t.positionAbs}}}),t.ui.intersect=function(t,i,s){if(!i.offset)return!1;var n,o,a=(t.positionAbs||t.position.absolute).left,r=(t.positionAbs||t.position.absolute).top,h=a+t.helperProportions.width,l=r+t.helperProportions.height,c=i.offset.left,u=i.offset.top,d=c+i.proportions().width,p=u+i.proportions().height;switch(s){case"fit":return a>=c&&d>=h&&r>=u&&p>=l;case"intersect":return a+t.helperProportions.width/2>c&&d>h-t.helperProportions.width/2&&r+t.helperProportions.height/2>u&&p>l-t.helperProportions.height/2;case"pointer":return n=(t.positionAbs||t.position.absolute).left+(t.clickOffset||t.offset.click).left,o=(t.positionAbs||t.position.absolute).top+(t.clickOffset||t.offset.click).top,e(o,u,i.proportions().height)&&e(n,c,i.proportions().width);case"touch":return(r>=u&&p>=r||l>=u&&p>=l||u>r&&l>p)&&(a>=c&&d>=a||h>=c&&d>=h||c>a&&h>d);default:return!1}},t.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(e,i){var s,n,o=t.ui.ddmanager.droppables[e.options.scope]||[],a=i?i.type:null,r=(e.currentItem||e.element).find(":data(ui-droppable)").addBack();t:for(s=0;o.length>s;s++)if(!(o[s].options.disabled||e&&!o[s].accept.call(o[s].element[0],e.currentItem||e.element))){for(n=0;r.length>n;n++)if(r[n]===o[s].element[0]){o[s].proportions().height=0;continue t}o[s].visible="none"!==o[s].element.css("display"),o[s].visible&&("mousedown"===a&&o[s]._activate.call(o[s],i),o[s].offset=o[s].element.offset(),o[s].proportions({width:o[s].element[0].offsetWidth,height:o[s].element[0].offsetHeight}))}},drop:function(e,i){var s=!1;return t.each((t.ui.ddmanager.droppables[e.options.scope]||[]).slice(),function(){this.options&&(!this.options.disabled&&this.visible&&t.ui.intersect(e,this,this.options.tolerance)&&(s=this._drop.call(this,i)||s),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],e.currentItem||e.element)&&(this.isout=!0,this.isover=!1,this._deactivate.call(this,i)))}),s},dragStart:function(e,i){e.element.parentsUntil("body").bind("scroll.droppable",function(){e.options.refreshPositions||t.ui.ddmanager.prepareOffsets(e,i)})},drag:function(e,i){e.options.refreshPositions&&t.ui.ddmanager.prepareOffsets(e,i),t.each(t.ui.ddmanager.droppables[e.options.scope]||[],function(){if(!this.options.disabled&&!this.greedyChild&&this.visible){var s,n,o,a=t.ui.intersect(e,this,this.options.tolerance),r=!a&&this.isover?"isout":a&&!this.isover?"isover":null;r&&(this.options.greedy&&(n=this.options.scope,o=this.element.parents(":data(ui-droppable)").filter(function(){return t.data(this,"ui-droppable").options.scope===n}),o.length&&(s=t.data(o[0],"ui-droppable"),s.greedyChild="isover"===r)),s&&"isover"===r&&(s.isover=!1,s.isout=!0,s._out.call(s,i)),this[r]=!0,this["isout"===r?"isover":"isout"]=!1,this["isover"===r?"_over":"_out"].call(this,i),s&&"isout"===r&&(s.isout=!1,s.isover=!0,s._over.call(s,i)))}})},dragStop:function(e,i){e.element.parentsUntil("body").unbind("scroll.droppable"),e.options.refreshPositions||t.ui.ddmanager.prepareOffsets(e,i)}}}(jQuery),function(t){function e(t){return parseInt(t,10)||0}function i(t){return!isNaN(parseInt(t,10))}t.widget("ui.resizable",t.ui.mouse,{version:"1.10.4",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:90,resize:null,start:null,stop:null},_create:function(){var e,i,s,n,o,a=this,r=this.options;if(this.element.addClass("ui-resizable"),t.extend(this,{_aspectRatio:!!r.aspectRatio,aspectRatio:r.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:r.helper||r.ghost||r.animate?r.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)&&(this.element.wrap(t("
    ").css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.data("ui-resizable")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize()),this.handles=r.handles||(t(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),e=this.handles.split(","),this.handles={},i=0;e.length>i;i++)s=t.trim(e[i]),o="ui-resizable-"+s,n=t("
    "),n.css({zIndex:r.zIndex}),"se"===s&&n.addClass("ui-icon ui-icon-gripsmall-diagonal-se"),this.handles[s]=".ui-resizable-"+s,this.element.append(n);this._renderAxis=function(e){var i,s,n,o;e=e||this.element;for(i in this.handles)this.handles[i].constructor===String&&(this.handles[i]=t(this.handles[i],this.element).show()),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)&&(s=t(this.handles[i],this.element),o=/sw|ne|nw|se|n|s/.test(i)?s.outerHeight():s.outerWidth(),n=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join(""),e.css(n,o),this._proportionallyResize()),t(this.handles[i]).length},this._renderAxis(this.element),this._handles=t(".ui-resizable-handle",this.element).disableSelection(),this._handles.mouseover(function(){a.resizing||(this.className&&(n=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),a.axis=n&&n[1]?n[1]:"se")}),r.autoHide&&(this._handles.hide(),t(this.element).addClass("ui-resizable-autohide").mouseenter(function(){r.disabled||(t(this).removeClass("ui-resizable-autohide"),a._handles.show())}).mouseleave(function(){r.disabled||a.resizing||(t(this).addClass("ui-resizable-autohide"),a._handles.hide())})),this._mouseInit()},_destroy:function(){this._mouseDestroy();var e,i=function(e){t(e).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};return this.elementIsWrapper&&(i(this.element),e=this.element,this.originalElement.css({position:e.css("position"),width:e.outerWidth(),height:e.outerHeight(),top:e.css("top"),left:e.css("left")}).insertAfter(e),e.remove()),this.originalElement.css("resize",this.originalResizeStyle),i(this.originalElement),this},_mouseCapture:function(e){var i,s,n=!1;for(i in this.handles)s=t(this.handles[i])[0],(s===e.target||t.contains(s,e.target))&&(n=!0);return!this.options.disabled&&n},_mouseStart:function(i){var s,n,o,a=this.options,r=this.element.position(),h=this.element;return this.resizing=!0,/absolute/.test(h.css("position"))?h.css({position:"absolute",top:h.css("top"),left:h.css("left")}):h.is(".ui-draggable")&&h.css({position:"absolute",top:r.top,left:r.left}),this._renderProxy(),s=e(this.helper.css("left")),n=e(this.helper.css("top")),a.containment&&(s+=t(a.containment).scrollLeft()||0,n+=t(a.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:s,top:n},this.size=this._helper?{width:this.helper.width(),height:this.helper.height()}:{width:h.width(),height:h.height()},this.originalSize=this._helper?{width:h.outerWidth(),height:h.outerHeight()}:{width:h.width(),height:h.height()},this.originalPosition={left:s,top:n},this.sizeDiff={width:h.outerWidth()-h.width(),height:h.outerHeight()-h.height()},this.originalMousePosition={left:i.pageX,top:i.pageY},this.aspectRatio="number"==typeof a.aspectRatio?a.aspectRatio:this.originalSize.width/this.originalSize.height||1,o=t(".ui-resizable-"+this.axis).css("cursor"),t("body").css("cursor","auto"===o?this.axis+"-resize":o),h.addClass("ui-resizable-resizing"),this._propagate("start",i),!0},_mouseDrag:function(e){var i,s=this.helper,n={},o=this.originalMousePosition,a=this.axis,r=this.position.top,h=this.position.left,l=this.size.width,c=this.size.height,u=e.pageX-o.left||0,d=e.pageY-o.top||0,p=this._change[a];return p?(i=p.apply(this,[e,u,d]),this._updateVirtualBoundaries(e.shiftKey),(this._aspectRatio||e.shiftKey)&&(i=this._updateRatio(i,e)),i=this._respectSize(i,e),this._updateCache(i),this._propagate("resize",e),this.position.top!==r&&(n.top=this.position.top+"px"),this.position.left!==h&&(n.left=this.position.left+"px"),this.size.width!==l&&(n.width=this.size.width+"px"),this.size.height!==c&&(n.height=this.size.height+"px"),s.css(n),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),t.isEmptyObject(n)||this._trigger("resize",e,this.ui()),!1):!1},_mouseStop:function(e){this.resizing=!1;var i,s,n,o,a,r,h,l=this.options,c=this;return this._helper&&(i=this._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),n=s&&t.ui.hasScroll(i[0],"left")?0:c.sizeDiff.height,o=s?0:c.sizeDiff.width,a={width:c.helper.width()-o,height:c.helper.height()-n},r=parseInt(c.element.css("left"),10)+(c.position.left-c.originalPosition.left)||null,h=parseInt(c.element.css("top"),10)+(c.position.top-c.originalPosition.top)||null,l.animate||this.element.css(t.extend(a,{top:h,left:r})),c.helper.height(c.size.height),c.helper.width(c.size.width),this._helper&&!l.animate&&this._proportionallyResize()),t("body").css("cursor","auto"),this.element.removeClass("ui-resizable-resizing"),this._propagate("stop",e),this._helper&&this.helper.remove(),!1},_updateVirtualBoundaries:function(t){var e,s,n,o,a,r=this.options;a={minWidth:i(r.minWidth)?r.minWidth:0,maxWidth:i(r.maxWidth)?r.maxWidth:1/0,minHeight:i(r.minHeight)?r.minHeight:0,maxHeight:i(r.maxHeight)?r.maxHeight:1/0},(this._aspectRatio||t)&&(e=a.minHeight*this.aspectRatio,n=a.minWidth/this.aspectRatio,s=a.maxHeight*this.aspectRatio,o=a.maxWidth/this.aspectRatio,e>a.minWidth&&(a.minWidth=e),n>a.minHeight&&(a.minHeight=n),a.maxWidth>s&&(a.maxWidth=s),a.maxHeight>o&&(a.maxHeight=o)),this._vBoundaries=a},_updateCache:function(t){this.offset=this.helper.offset(),i(t.left)&&(this.position.left=t.left),i(t.top)&&(this.position.top=t.top),i(t.height)&&(this.size.height=t.height),i(t.width)&&(this.size.width=t.width)},_updateRatio:function(t){var e=this.position,s=this.size,n=this.axis;return i(t.height)?t.width=t.height*this.aspectRatio:i(t.width)&&(t.height=t.width/this.aspectRatio),"sw"===n&&(t.left=e.left+(s.width-t.width),t.top=null),"nw"===n&&(t.top=e.top+(s.height-t.height),t.left=e.left+(s.width-t.width)),t},_respectSize:function(t){var e=this._vBoundaries,s=this.axis,n=i(t.width)&&e.maxWidth&&e.maxWidtht.width,r=i(t.height)&&e.minHeight&&e.minHeight>t.height,h=this.originalPosition.left+this.originalSize.width,l=this.position.top+this.size.height,c=/sw|nw|w/.test(s),u=/nw|ne|n/.test(s);return a&&(t.width=e.minWidth),r&&(t.height=e.minHeight),n&&(t.width=e.maxWidth),o&&(t.height=e.maxHeight),a&&c&&(t.left=h-e.minWidth),n&&c&&(t.left=h-e.maxWidth),r&&u&&(t.top=l-e.minHeight),o&&u&&(t.top=l-e.maxHeight),t.width||t.height||t.left||!t.top?t.width||t.height||t.top||!t.left||(t.left=null):t.top=null,t},_proportionallyResize:function(){if(this._proportionallyResizeElements.length){var t,e,i,s,n,o=this.helper||this.element;for(t=0;this._proportionallyResizeElements.length>t;t++){if(n=this._proportionallyResizeElements[t],!this.borderDif)for(this.borderDif=[],i=[n.css("borderTopWidth"),n.css("borderRightWidth"),n.css("borderBottomWidth"),n.css("borderLeftWidth")],s=[n.css("paddingTop"),n.css("paddingRight"),n.css("paddingBottom"),n.css("paddingLeft")],e=0;i.length>e;e++)this.borderDif[e]=(parseInt(i[e],10)||0)+(parseInt(s[e],10)||0);n.css({height:o.height()-this.borderDif[0]-this.borderDif[2]||0,width:o.width()-this.borderDif[1]-this.borderDif[3]||0})}}},_renderProxy:function(){var e=this.element,i=this.options;this.elementOffset=e.offset(),this._helper?(this.helper=this.helper||t("
    "),this.helper.addClass(this._helper).css({width:this.element.outerWidth()-1,height:this.element.outerHeight()-1,position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++i.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element},_change:{e:function(t,e){return{width:this.originalSize.width+e}},w:function(t,e){var i=this.originalSize,s=this.originalPosition;return{left:s.left+e,width:i.width-e}},n:function(t,e,i){var s=this.originalSize,n=this.originalPosition;return{top:n.top+i,height:s.height-i}},s:function(t,e,i){return{height:this.originalSize.height+i}},se:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},sw:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[e,i,s]))},ne:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},nw:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[e,i,s]))}},_propagate:function(e,i){t.ui.plugin.call(this,e,[i,this.ui()]),"resize"!==e&&this._trigger(e,i,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),t.ui.plugin.add("resizable","animate",{stop:function(e){var i=t(this).data("ui-resizable"),s=i.options,n=i._proportionallyResizeElements,o=n.length&&/textarea/i.test(n[0].nodeName),a=o&&t.ui.hasScroll(n[0],"left")?0:i.sizeDiff.height,r=o?0:i.sizeDiff.width,h={width:i.size.width-r,height:i.size.height-a},l=parseInt(i.element.css("left"),10)+(i.position.left-i.originalPosition.left)||null,c=parseInt(i.element.css("top"),10)+(i.position.top-i.originalPosition.top)||null;i.element.animate(t.extend(h,c&&l?{top:c,left:l}:{}),{duration:s.animateDuration,easing:s.animateEasing,step:function(){var s={width:parseInt(i.element.css("width"),10),height:parseInt(i.element.css("height"),10),top:parseInt(i.element.css("top"),10),left:parseInt(i.element.css("left"),10)};n&&n.length&&t(n[0]).css({width:s.width,height:s.height}),i._updateCache(s),i._propagate("resize",e)}})}}),t.ui.plugin.add("resizable","containment",{start:function(){var i,s,n,o,a,r,h,l=t(this).data("ui-resizable"),c=l.options,u=l.element,d=c.containment,p=d instanceof t?d.get(0):/parent/.test(d)?u.parent().get(0):d;p&&(l.containerElement=t(p),/document/.test(d)||d===document?(l.containerOffset={left:0,top:0},l.containerPosition={left:0,top:0},l.parentData={element:t(document),left:0,top:0,width:t(document).width(),height:t(document).height()||document.body.parentNode.scrollHeight}):(i=t(p),s=[],t(["Top","Right","Left","Bottom"]).each(function(t,n){s[t]=e(i.css("padding"+n))}),l.containerOffset=i.offset(),l.containerPosition=i.position(),l.containerSize={height:i.innerHeight()-s[3],width:i.innerWidth()-s[1]},n=l.containerOffset,o=l.containerSize.height,a=l.containerSize.width,r=t.ui.hasScroll(p,"left")?p.scrollWidth:a,h=t.ui.hasScroll(p)?p.scrollHeight:o,l.parentData={element:p,left:n.left,top:n.top,width:r,height:h}))},resize:function(e){var i,s,n,o,a=t(this).data("ui-resizable"),r=a.options,h=a.containerOffset,l=a.position,c=a._aspectRatio||e.shiftKey,u={top:0,left:0},d=a.containerElement;d[0]!==document&&/static/.test(d.css("position"))&&(u=h),l.left<(a._helper?h.left:0)&&(a.size.width=a.size.width+(a._helper?a.position.left-h.left:a.position.left-u.left),c&&(a.size.height=a.size.width/a.aspectRatio),a.position.left=r.helper?h.left:0),l.top<(a._helper?h.top:0)&&(a.size.height=a.size.height+(a._helper?a.position.top-h.top:a.position.top),c&&(a.size.width=a.size.height*a.aspectRatio),a.position.top=a._helper?h.top:0),a.offset.left=a.parentData.left+a.position.left,a.offset.top=a.parentData.top+a.position.top,i=Math.abs((a._helper?a.offset.left-u.left:a.offset.left-u.left)+a.sizeDiff.width),s=Math.abs((a._helper?a.offset.top-u.top:a.offset.top-h.top)+a.sizeDiff.height),n=a.containerElement.get(0)===a.element.parent().get(0),o=/relative|absolute/.test(a.containerElement.css("position")),n&&o&&(i-=Math.abs(a.parentData.left)),i+a.size.width>=a.parentData.width&&(a.size.width=a.parentData.width-i,c&&(a.size.height=a.size.width/a.aspectRatio)),s+a.size.height>=a.parentData.height&&(a.size.height=a.parentData.height-s,c&&(a.size.width=a.size.height*a.aspectRatio))},stop:function(){var e=t(this).data("ui-resizable"),i=e.options,s=e.containerOffset,n=e.containerPosition,o=e.containerElement,a=t(e.helper),r=a.offset(),h=a.outerWidth()-e.sizeDiff.width,l=a.outerHeight()-e.sizeDiff.height;e._helper&&!i.animate&&/relative/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:h,height:l}),e._helper&&!i.animate&&/static/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:h,height:l})}}),t.ui.plugin.add("resizable","alsoResize",{start:function(){var e=t(this).data("ui-resizable"),i=e.options,s=function(e){t(e).each(function(){var e=t(this);e.data("ui-resizable-alsoresize",{width:parseInt(e.width(),10),height:parseInt(e.height(),10),left:parseInt(e.css("left"),10),top:parseInt(e.css("top"),10)})})};"object"!=typeof i.alsoResize||i.alsoResize.parentNode?s(i.alsoResize):i.alsoResize.length?(i.alsoResize=i.alsoResize[0],s(i.alsoResize)):t.each(i.alsoResize,function(t){s(t)})},resize:function(e,i){var s=t(this).data("ui-resizable"),n=s.options,o=s.originalSize,a=s.originalPosition,r={height:s.size.height-o.height||0,width:s.size.width-o.width||0,top:s.position.top-a.top||0,left:s.position.left-a.left||0},h=function(e,s){t(e).each(function(){var e=t(this),n=t(this).data("ui-resizable-alsoresize"),o={},a=s&&s.length?s:e.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];t.each(a,function(t,e){var i=(n[e]||0)+(r[e]||0);i&&i>=0&&(o[e]=i||null)}),e.css(o)})};"object"!=typeof n.alsoResize||n.alsoResize.nodeType?h(n.alsoResize):t.each(n.alsoResize,function(t,e){h(t,e)})},stop:function(){t(this).removeData("resizable-alsoresize")}}),t.ui.plugin.add("resizable","ghost",{start:function(){var e=t(this).data("ui-resizable"),i=e.options,s=e.size;e.ghost=e.originalElement.clone(),e.ghost.css({opacity:.25,display:"block",position:"relative",height:s.height,width:s.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass("string"==typeof i.ghost?i.ghost:""),e.ghost.appendTo(e.helper)},resize:function(){var e=t(this).data("ui-resizable");e.ghost&&e.ghost.css({position:"relative",height:e.size.height,width:e.size.width})},stop:function(){var e=t(this).data("ui-resizable");e.ghost&&e.helper&&e.helper.get(0).removeChild(e.ghost.get(0))}}),t.ui.plugin.add("resizable","grid",{resize:function(){var e=t(this).data("ui-resizable"),i=e.options,s=e.size,n=e.originalSize,o=e.originalPosition,a=e.axis,r="number"==typeof i.grid?[i.grid,i.grid]:i.grid,h=r[0]||1,l=r[1]||1,c=Math.round((s.width-n.width)/h)*h,u=Math.round((s.height-n.height)/l)*l,d=n.width+c,p=n.height+u,f=i.maxWidth&&d>i.maxWidth,g=i.maxHeight&&p>i.maxHeight,m=i.minWidth&&i.minWidth>d,v=i.minHeight&&i.minHeight>p;i.grid=r,m&&(d+=h),v&&(p+=l),f&&(d-=h),g&&(p-=l),/^(se|s|e)$/.test(a)?(e.size.width=d,e.size.height=p):/^(ne)$/.test(a)?(e.size.width=d,e.size.height=p,e.position.top=o.top-u):/^(sw)$/.test(a)?(e.size.width=d,e.size.height=p,e.position.left=o.left-c):(p-l>0?(e.size.height=p,e.position.top=o.top-u):(e.size.height=l,e.position.top=o.top+n.height-l),d-h>0?(e.size.width=d,e.position.left=o.left-c):(e.size.width=h,e.position.left=o.left+n.width-h))}})}(jQuery),function(t){t.widget("ui.selectable",t.ui.mouse,{version:"1.10.4",options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch",selected:null,selecting:null,start:null,stop:null,unselected:null,unselecting:null},_create:function(){var e,i=this;this.element.addClass("ui-selectable"),this.dragged=!1,this.refresh=function(){e=t(i.options.filter,i.element[0]),e.addClass("ui-selectee"),e.each(function(){var e=t(this),i=e.offset();t.data(this,"selectable-item",{element:this,$element:e,left:i.left,top:i.top,right:i.left+e.outerWidth(),bottom:i.top+e.outerHeight(),startselected:!1,selected:e.hasClass("ui-selected"),selecting:e.hasClass("ui-selecting"),unselecting:e.hasClass("ui-unselecting")})})},this.refresh(),this.selectees=e.addClass("ui-selectee"),this._mouseInit(),this.helper=t("
    ")},_destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item"),this.element.removeClass("ui-selectable ui-selectable-disabled"),this._mouseDestroy()},_mouseStart:function(e){var i=this,s=this.options;this.opos=[e.pageX,e.pageY],this.options.disabled||(this.selectees=t(s.filter,this.element[0]),this._trigger("start",e),t(s.appendTo).append(this.helper),this.helper.css({left:e.pageX,top:e.pageY,width:0,height:0}),s.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var s=t.data(this,"selectable-item");s.startselected=!0,e.metaKey||e.ctrlKey||(s.$element.removeClass("ui-selected"),s.selected=!1,s.$element.addClass("ui-unselecting"),s.unselecting=!0,i._trigger("unselecting",e,{unselecting:s.element}))}),t(e.target).parents().addBack().each(function(){var s,n=t.data(this,"selectable-item");return n?(s=!e.metaKey&&!e.ctrlKey||!n.$element.hasClass("ui-selected"),n.$element.removeClass(s?"ui-unselecting":"ui-selected").addClass(s?"ui-selecting":"ui-unselecting"),n.unselecting=!s,n.selecting=s,n.selected=s,s?i._trigger("selecting",e,{selecting:n.element}):i._trigger("unselecting",e,{unselecting:n.element}),!1):undefined}))},_mouseDrag:function(e){if(this.dragged=!0,!this.options.disabled){var i,s=this,n=this.options,o=this.opos[0],a=this.opos[1],r=e.pageX,h=e.pageY;return o>r&&(i=r,r=o,o=i),a>h&&(i=h,h=a,a=i),this.helper.css({left:o,top:a,width:r-o,height:h-a}),this.selectees.each(function(){var i=t.data(this,"selectable-item"),l=!1;i&&i.element!==s.element[0]&&("touch"===n.tolerance?l=!(i.left>r||o>i.right||i.top>h||a>i.bottom):"fit"===n.tolerance&&(l=i.left>o&&r>i.right&&i.top>a&&h>i.bottom),l?(i.selected&&(i.$element.removeClass("ui-selected"),i.selected=!1),i.unselecting&&(i.$element.removeClass("ui-unselecting"),i.unselecting=!1),i.selecting||(i.$element.addClass("ui-selecting"),i.selecting=!0,s._trigger("selecting",e,{selecting:i.element}))):(i.selecting&&((e.metaKey||e.ctrlKey)&&i.startselected?(i.$element.removeClass("ui-selecting"),i.selecting=!1,i.$element.addClass("ui-selected"),i.selected=!0):(i.$element.removeClass("ui-selecting"),i.selecting=!1,i.startselected&&(i.$element.addClass("ui-unselecting"),i.unselecting=!0),s._trigger("unselecting",e,{unselecting:i.element}))),i.selected&&(e.metaKey||e.ctrlKey||i.startselected||(i.$element.removeClass("ui-selected"),i.selected=!1,i.$element.addClass("ui-unselecting"),i.unselecting=!0,s._trigger("unselecting",e,{unselecting:i.element})))))}),!1}},_mouseStop:function(e){var i=this;return this.dragged=!1,t(".ui-unselecting",this.element[0]).each(function(){var s=t.data(this,"selectable-item");s.$element.removeClass("ui-unselecting"),s.unselecting=!1,s.startselected=!1,i._trigger("unselected",e,{unselected:s.element})}),t(".ui-selecting",this.element[0]).each(function(){var s=t.data(this,"selectable-item");s.$element.removeClass("ui-selecting").addClass("ui-selected"),s.selecting=!1,s.selected=!0,s.startselected=!0,i._trigger("selected",e,{selected:s.element})}),this._trigger("stop",e),this.helper.remove(),!1}})}(jQuery),function(t){function e(t,e,i){return t>e&&e+i>t}function i(t){return/left|right/.test(t.css("float"))||/inline|table-cell/.test(t.css("display"))}t.widget("ui.sortable",t.ui.mouse,{version:"1.10.4",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_create:function(){var t=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?"x"===t.axis||i(this.items[0].item):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var t=this.items.length-1;t>=0;t--)this.items[t].item.removeData(this.widgetName+"-item");return this},_setOption:function(e,i){"disabled"===e?(this.options[e]=i,this.widget().toggleClass("ui-sortable-disabled",!!i)):t.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(e,i){var s=null,n=!1,o=this;return this.reverting?!1:this.options.disabled||"static"===this.options.type?!1:(this._refreshItems(e),t(e.target).parents().each(function(){return t.data(this,o.widgetName+"-item")===o?(s=t(this),!1):undefined}),t.data(e.target,o.widgetName+"-item")===o&&(s=t(e.target)),s?!this.options.handle||i||(t(this.options.handle,s).find("*").addBack().each(function(){this===e.target&&(n=!0)}),n)?(this.currentItem=s,this._removeCurrentsFromItems(),!0):!1:!1)},_mouseStart:function(e,i,s){var n,o,a=this.options;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(e),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},t.extend(this.offset,{click:{left:e.pageX-this.offset.left,top:e.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(e),this.originalPageX=e.pageX,this.originalPageY=e.pageY,a.cursorAt&&this._adjustOffsetFromHelper(a.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!==this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),a.containment&&this._setContainment(),a.cursor&&"auto"!==a.cursor&&(o=this.document.find("body"),this.storedCursor=o.css("cursor"),o.css("cursor",a.cursor),this.storedStylesheet=t("").appendTo(o)),a.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",a.opacity)),a.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",a.zIndex)),this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",e,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!s)for(n=this.containers.length-1;n>=0;n--)this.containers[n]._trigger("activate",e,this._uiHash(this));return t.ui.ddmanager&&(t.ui.ddmanager.current=this),t.ui.ddmanager&&!a.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(e),!0},_mouseDrag:function(e){var i,s,n,o,a=this.options,r=!1;for(this.position=this._generatePosition(e),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll&&(this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-e.pageY=0;i--)if(s=this.items[i],n=s.item[0],o=this._intersectsWithPointer(s),o&&s.instance===this.currentContainer&&n!==this.currentItem[0]&&this.placeholder[1===o?"next":"prev"]()[0]!==n&&!t.contains(this.placeholder[0],n)&&("semi-dynamic"===this.options.type?!t.contains(this.element[0],n):!0)){if(this.direction=1===o?"down":"up","pointer"!==this.options.tolerance&&!this._intersectsWithSides(s))break; this._rearrange(e,s),this._trigger("change",e,this._uiHash());break}return this._contactContainers(e),t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),this._trigger("sort",e,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(e,i){if(e){if(t.ui.ddmanager&&!this.options.dropBehaviour&&t.ui.ddmanager.drop(this,e),this.options.revert){var s=this,n=this.placeholder.offset(),o=this.options.axis,a={};o&&"x"!==o||(a.left=n.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollLeft)),o&&"y"!==o||(a.top=n.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollTop)),this.reverting=!0,t(this.helper).animate(a,parseInt(this.options.revert,10)||500,function(){s._clear(e)})}else this._clear(e,i);return!1}},cancel:function(){if(this.dragging){this._mouseUp({target:null}),"original"===this.options.helper?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var e=this.containers.length-1;e>=0;e--)this.containers[e]._trigger("deactivate",null,this._uiHash(this)),this.containers[e].containerCache.over&&(this.containers[e]._trigger("out",null,this._uiHash(this)),this.containers[e].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!==this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),t.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?t(this.domPosition.prev).after(this.currentItem):t(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(e){var i=this._getItemsAsjQuery(e&&e.connected),s=[];return e=e||{},t(i).each(function(){var i=(t(e.item||this).attr(e.attribute||"id")||"").match(e.expression||/(.+)[\-=_](.+)/);i&&s.push((e.key||i[1]+"[]")+"="+(e.key&&e.expression?i[1]:i[2]))}),!s.length&&e.key&&s.push(e.key+"="),s.join("&")},toArray:function(e){var i=this._getItemsAsjQuery(e&&e.connected),s=[];return e=e||{},i.each(function(){s.push(t(e.item||this).attr(e.attribute||"id")||"")}),s},_intersectsWith:function(t){var e=this.positionAbs.left,i=e+this.helperProportions.width,s=this.positionAbs.top,n=s+this.helperProportions.height,o=t.left,a=o+t.width,r=t.top,h=r+t.height,l=this.offset.click.top,c=this.offset.click.left,u="x"===this.options.axis||s+l>r&&h>s+l,d="y"===this.options.axis||e+c>o&&a>e+c,p=u&&d;return"pointer"===this.options.tolerance||this.options.forcePointerForContainers||"pointer"!==this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>t[this.floating?"width":"height"]?p:e+this.helperProportions.width/2>o&&a>i-this.helperProportions.width/2&&s+this.helperProportions.height/2>r&&h>n-this.helperProportions.height/2},_intersectsWithPointer:function(t){var i="x"===this.options.axis||e(this.positionAbs.top+this.offset.click.top,t.top,t.height),s="y"===this.options.axis||e(this.positionAbs.left+this.offset.click.left,t.left,t.width),n=i&&s,o=this._getDragVerticalDirection(),a=this._getDragHorizontalDirection();return n?this.floating?a&&"right"===a||"down"===o?2:1:o&&("down"===o?2:1):!1},_intersectsWithSides:function(t){var i=e(this.positionAbs.top+this.offset.click.top,t.top+t.height/2,t.height),s=e(this.positionAbs.left+this.offset.click.left,t.left+t.width/2,t.width),n=this._getDragVerticalDirection(),o=this._getDragHorizontalDirection();return this.floating&&o?"right"===o&&s||"left"===o&&!s:n&&("down"===n&&i||"up"===n&&!i)},_getDragVerticalDirection:function(){var t=this.positionAbs.top-this.lastPositionAbs.top;return 0!==t&&(t>0?"down":"up")},_getDragHorizontalDirection:function(){var t=this.positionAbs.left-this.lastPositionAbs.left;return 0!==t&&(t>0?"right":"left")},refresh:function(t){return this._refreshItems(t),this.refreshPositions(),this},_connectWith:function(){var t=this.options;return t.connectWith.constructor===String?[t.connectWith]:t.connectWith},_getItemsAsjQuery:function(e){function i(){r.push(this)}var s,n,o,a,r=[],h=[],l=this._connectWith();if(l&&e)for(s=l.length-1;s>=0;s--)for(o=t(l[s]),n=o.length-1;n>=0;n--)a=t.data(o[n],this.widgetFullName),a&&a!==this&&!a.options.disabled&&h.push([t.isFunction(a.options.items)?a.options.items.call(a.element):t(a.options.items,a.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),a]);for(h.push([t.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):t(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]),s=h.length-1;s>=0;s--)h[s][0].each(i);return t(r)},_removeCurrentsFromItems:function(){var e=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=t.grep(this.items,function(t){for(var i=0;e.length>i;i++)if(e[i]===t.item[0])return!1;return!0})},_refreshItems:function(e){this.items=[],this.containers=[this];var i,s,n,o,a,r,h,l,c=this.items,u=[[t.isFunction(this.options.items)?this.options.items.call(this.element[0],e,{item:this.currentItem}):t(this.options.items,this.element),this]],d=this._connectWith();if(d&&this.ready)for(i=d.length-1;i>=0;i--)for(n=t(d[i]),s=n.length-1;s>=0;s--)o=t.data(n[s],this.widgetFullName),o&&o!==this&&!o.options.disabled&&(u.push([t.isFunction(o.options.items)?o.options.items.call(o.element[0],e,{item:this.currentItem}):t(o.options.items,o.element),o]),this.containers.push(o));for(i=u.length-1;i>=0;i--)for(a=u[i][1],r=u[i][0],s=0,l=r.length;l>s;s++)h=t(r[s]),h.data(this.widgetName+"-item",a),c.push({item:h,instance:a,width:0,height:0,left:0,top:0})},refreshPositions:function(e){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());var i,s,n,o;for(i=this.items.length-1;i>=0;i--)s=this.items[i],s.instance!==this.currentContainer&&this.currentContainer&&s.item[0]!==this.currentItem[0]||(n=this.options.toleranceElement?t(this.options.toleranceElement,s.item):s.item,e||(s.width=n.outerWidth(),s.height=n.outerHeight()),o=n.offset(),s.left=o.left,s.top=o.top);if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(i=this.containers.length-1;i>=0;i--)o=this.containers[i].element.offset(),this.containers[i].containerCache.left=o.left,this.containers[i].containerCache.top=o.top,this.containers[i].containerCache.width=this.containers[i].element.outerWidth(),this.containers[i].containerCache.height=this.containers[i].element.outerHeight();return this},_createPlaceholder:function(e){e=e||this;var i,s=e.options;s.placeholder&&s.placeholder.constructor!==String||(i=s.placeholder,s.placeholder={element:function(){var s=e.currentItem[0].nodeName.toLowerCase(),n=t("<"+s+">",e.document[0]).addClass(i||e.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper");return"tr"===s?e.currentItem.children().each(function(){t(" ",e.document[0]).attr("colspan",t(this).attr("colspan")||1).appendTo(n)}):"img"===s&&n.attr("src",e.currentItem.attr("src")),i||n.css("visibility","hidden"),n},update:function(t,n){(!i||s.forcePlaceholderSize)&&(n.height()||n.height(e.currentItem.innerHeight()-parseInt(e.currentItem.css("paddingTop")||0,10)-parseInt(e.currentItem.css("paddingBottom")||0,10)),n.width()||n.width(e.currentItem.innerWidth()-parseInt(e.currentItem.css("paddingLeft")||0,10)-parseInt(e.currentItem.css("paddingRight")||0,10)))}}),e.placeholder=t(s.placeholder.element.call(e.element,e.currentItem)),e.currentItem.after(e.placeholder),s.placeholder.update(e,e.placeholder)},_contactContainers:function(s){var n,o,a,r,h,l,c,u,d,p,f=null,g=null;for(n=this.containers.length-1;n>=0;n--)if(!t.contains(this.currentItem[0],this.containers[n].element[0]))if(this._intersectsWith(this.containers[n].containerCache)){if(f&&t.contains(this.containers[n].element[0],f.element[0]))continue;f=this.containers[n],g=n}else this.containers[n].containerCache.over&&(this.containers[n]._trigger("out",s,this._uiHash(this)),this.containers[n].containerCache.over=0);if(f)if(1===this.containers.length)this.containers[g].containerCache.over||(this.containers[g]._trigger("over",s,this._uiHash(this)),this.containers[g].containerCache.over=1);else{for(a=1e4,r=null,p=f.floating||i(this.currentItem),h=p?"left":"top",l=p?"width":"height",c=this.positionAbs[h]+this.offset.click[h],o=this.items.length-1;o>=0;o--)t.contains(this.containers[g].element[0],this.items[o].item[0])&&this.items[o].item[0]!==this.currentItem[0]&&(!p||e(this.positionAbs.top+this.offset.click.top,this.items[o].top,this.items[o].height))&&(u=this.items[o].item.offset()[h],d=!1,Math.abs(u-c)>Math.abs(u+this.items[o][l]-c)&&(d=!0,u+=this.items[o][l]),a>Math.abs(u-c)&&(a=Math.abs(u-c),r=this.items[o],this.direction=d?"up":"down"));if(!r&&!this.options.dropOnEmpty)return;if(this.currentContainer===this.containers[g])return;r?this._rearrange(s,r,null,!0):this._rearrange(s,null,this.containers[g].element,!0),this._trigger("change",s,this._uiHash()),this.containers[g]._trigger("change",s,this._uiHash(this)),this.currentContainer=this.containers[g],this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[g]._trigger("over",s,this._uiHash(this)),this.containers[g].containerCache.over=1}},_createHelper:function(e){var i=this.options,s=t.isFunction(i.helper)?t(i.helper.apply(this.element[0],[e,this.currentItem])):"clone"===i.helper?this.currentItem.clone():this.currentItem;return s.parents("body").length||t("parent"!==i.appendTo?i.appendTo:this.currentItem[0].parentNode)[0].appendChild(s[0]),s[0]===this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(!s[0].style.width||i.forceHelperSize)&&s.width(this.currentItem.width()),(!s[0].style.height||i.forceHelperSize)&&s.height(this.currentItem.height()),s},_adjustOffsetFromHelper:function(e){"string"==typeof e&&(e=e.split(" ")),t.isArray(e)&&(e={left:+e[0],top:+e[1]||0}),"left"in e&&(this.offset.click.left=e.left+this.margins.left),"right"in e&&(this.offset.click.left=this.helperProportions.width-e.right+this.margins.left),"top"in e&&(this.offset.click.top=e.top+this.margins.top),"bottom"in e&&(this.offset.click.top=this.helperProportions.height-e.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var e=this.offsetParent.offset();return"absolute"===this.cssPosition&&this.scrollParent[0]!==document&&t.contains(this.scrollParent[0],this.offsetParent[0])&&(e.left+=this.scrollParent.scrollLeft(),e.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]===document.body||this.offsetParent[0].tagName&&"html"===this.offsetParent[0].tagName.toLowerCase()&&t.ui.ie)&&(e={top:0,left:0}),{top:e.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:e.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"===this.cssPosition){var t=this.currentItem.position();return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:t.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e,i,s,n=this.options;"parent"===n.containment&&(n.containment=this.helper[0].parentNode),("document"===n.containment||"window"===n.containment)&&(this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,t("document"===n.containment?document:window).width()-this.helperProportions.width-this.margins.left,(t("document"===n.containment?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]),/^(document|window|parent)$/.test(n.containment)||(e=t(n.containment)[0],i=t(n.containment).offset(),s="hidden"!==t(e).css("overflow"),this.containment=[i.left+(parseInt(t(e).css("borderLeftWidth"),10)||0)+(parseInt(t(e).css("paddingLeft"),10)||0)-this.margins.left,i.top+(parseInt(t(e).css("borderTopWidth"),10)||0)+(parseInt(t(e).css("paddingTop"),10)||0)-this.margins.top,i.left+(s?Math.max(e.scrollWidth,e.offsetWidth):e.offsetWidth)-(parseInt(t(e).css("borderLeftWidth"),10)||0)-(parseInt(t(e).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,i.top+(s?Math.max(e.scrollHeight,e.offsetHeight):e.offsetHeight)-(parseInt(t(e).css("borderTopWidth"),10)||0)-(parseInt(t(e).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top])},_convertPositionTo:function(e,i){i||(i=this.position);var s="absolute"===e?1:-1,n="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,o=/(html|body)/i.test(n[0].tagName);return{top:i.top+this.offset.relative.top*s+this.offset.parent.top*s-("fixed"===this.cssPosition?-this.scrollParent.scrollTop():o?0:n.scrollTop())*s,left:i.left+this.offset.relative.left*s+this.offset.parent.left*s-("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():o?0:n.scrollLeft())*s}},_generatePosition:function(e){var i,s,n=this.options,o=e.pageX,a=e.pageY,r="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,h=/(html|body)/i.test(r[0].tagName);return"relative"!==this.cssPosition||this.scrollParent[0]!==document&&this.scrollParent[0]!==this.offsetParent[0]||(this.offset.relative=this._getRelativeOffset()),this.originalPosition&&(this.containment&&(e.pageX-this.offset.click.leftthis.containment[2]&&(o=this.containment[2]+this.offset.click.left),e.pageY-this.offset.click.top>this.containment[3]&&(a=this.containment[3]+this.offset.click.top)),n.grid&&(i=this.originalPageY+Math.round((a-this.originalPageY)/n.grid[1])*n.grid[1],a=this.containment?i-this.offset.click.top>=this.containment[1]&&i-this.offset.click.top<=this.containment[3]?i:i-this.offset.click.top>=this.containment[1]?i-n.grid[1]:i+n.grid[1]:i,s=this.originalPageX+Math.round((o-this.originalPageX)/n.grid[0])*n.grid[0],o=this.containment?s-this.offset.click.left>=this.containment[0]&&s-this.offset.click.left<=this.containment[2]?s:s-this.offset.click.left>=this.containment[0]?s-n.grid[0]:s+n.grid[0]:s)),{top:a-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():h?0:r.scrollTop()),left:o-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():h?0:r.scrollLeft())}},_rearrange:function(t,e,i,s){i?i[0].appendChild(this.placeholder[0]):e.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?e.item[0]:e.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var n=this.counter;this._delay(function(){n===this.counter&&this.refreshPositions(!s)})},_clear:function(t,e){function i(t,e,i){return function(s){i._trigger(t,s,e._uiHash(e))}}this.reverting=!1;var s,n=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(s in this._storedCSS)("auto"===this._storedCSS[s]||"static"===this._storedCSS[s])&&(this._storedCSS[s]="");this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();for(this.fromOutside&&!e&&n.push(function(t){this._trigger("receive",t,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||e||n.push(function(t){this._trigger("update",t,this._uiHash())}),this!==this.currentContainer&&(e||(n.push(function(t){this._trigger("remove",t,this._uiHash())}),n.push(function(t){return function(e){t._trigger("receive",e,this._uiHash(this))}}.call(this,this.currentContainer)),n.push(function(t){return function(e){t._trigger("update",e,this._uiHash(this))}}.call(this,this.currentContainer)))),s=this.containers.length-1;s>=0;s--)e||n.push(i("deactivate",this,this.containers[s])),this.containers[s].containerCache.over&&(n.push(i("out",this,this.containers[s])),this.containers[s].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,this.cancelHelperRemoval){if(!e){for(this._trigger("beforeStop",t,this._uiHash()),s=0;n.length>s;s++)n[s].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!1}if(e||this._trigger("beforeStop",t,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null,!e){for(s=0;n.length>s;s++)n[s].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!0},_trigger:function(){t.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(e){var i=e||this;return{helper:i.helper,placeholder:i.placeholder||t([]),position:i.position,originalPosition:i.originalPosition,offset:i.positionAbs,item:i.currentItem,sender:e?e.element:null}}})}(jQuery),function(t,e){var i="ui-effects-";t.effects={effect:{}},function(t,e){function i(t,e,i){var s=u[e.type]||{};return null==t?i||!e.def?null:e.def:(t=s.floor?~~t:parseFloat(t),isNaN(t)?e.def:s.mod?(t+s.mod)%s.mod:0>t?0:t>s.max?s.max:t)}function s(i){var s=l(),n=s._rgba=[];return i=i.toLowerCase(),f(h,function(t,o){var a,r=o.re.exec(i),h=r&&o.parse(r),l=o.space||"rgba";return h?(a=s[l](h),s[c[l].cache]=a[c[l].cache],n=s._rgba=a._rgba,!1):e}),n.length?("0,0,0,0"===n.join()&&t.extend(n,o.transparent),s):o[i]}function n(t,e,i){return i=(i+1)%1,1>6*i?t+6*(e-t)*i:1>2*i?e:2>3*i?t+6*(e-t)*(2/3-i):t}var o,a="backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",r=/^([\-+])=\s*(\d+\.?\d*)/,h=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(t){return[t[1],t[2],t[3],t[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(t){return[2.55*t[1],2.55*t[2],2.55*t[3],t[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,parse:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])/,parse:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(t){return[t[1],t[2]/100,t[3]/100,t[4]]}}],l=t.Color=function(e,i,s,n){return new t.Color.fn.parse(e,i,s,n)},c={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},u={"byte":{floor:!0,max:255},percent:{max:1},degrees:{mod:360,floor:!0}},d=l.support={},p=t("

    ")[0],f=t.each;p.style.cssText="background-color:rgba(1,1,1,.5)",d.rgba=p.style.backgroundColor.indexOf("rgba")>-1,f(c,function(t,e){e.cache="_"+t,e.props.alpha={idx:3,type:"percent",def:1}}),l.fn=t.extend(l.prototype,{parse:function(n,a,r,h){if(n===e)return this._rgba=[null,null,null,null],this;(n.jquery||n.nodeType)&&(n=t(n).css(a),a=e);var u=this,d=t.type(n),p=this._rgba=[];return a!==e&&(n=[n,a,r,h],d="array"),"string"===d?this.parse(s(n)||o._default):"array"===d?(f(c.rgba.props,function(t,e){p[e.idx]=i(n[e.idx],e)}),this):"object"===d?(n instanceof l?f(c,function(t,e){n[e.cache]&&(u[e.cache]=n[e.cache].slice())}):f(c,function(e,s){var o=s.cache;f(s.props,function(t,e){if(!u[o]&&s.to){if("alpha"===t||null==n[t])return;u[o]=s.to(u._rgba)}u[o][e.idx]=i(n[t],e,!0)}),u[o]&&0>t.inArray(null,u[o].slice(0,3))&&(u[o][3]=1,s.from&&(u._rgba=s.from(u[o])))}),this):e},is:function(t){var i=l(t),s=!0,n=this;return f(c,function(t,o){var a,r=i[o.cache];return r&&(a=n[o.cache]||o.to&&o.to(n._rgba)||[],f(o.props,function(t,i){return null!=r[i.idx]?s=r[i.idx]===a[i.idx]:e})),s}),s},_space:function(){var t=[],e=this;return f(c,function(i,s){e[s.cache]&&t.push(i)}),t.pop()},transition:function(t,e){var s=l(t),n=s._space(),o=c[n],a=0===this.alpha()?l("transparent"):this,r=a[o.cache]||o.to(a._rgba),h=r.slice();return s=s[o.cache],f(o.props,function(t,n){var o=n.idx,a=r[o],l=s[o],c=u[n.type]||{};null!==l&&(null===a?h[o]=l:(c.mod&&(l-a>c.mod/2?a+=c.mod:a-l>c.mod/2&&(a-=c.mod)),h[o]=i((l-a)*e+a,n)))}),this[n](h)},blend:function(e){if(1===this._rgba[3])return this;var i=this._rgba.slice(),s=i.pop(),n=l(e)._rgba;return l(t.map(i,function(t,e){return(1-s)*n[e]+s*t}))},toRgbaString:function(){var e="rgba(",i=t.map(this._rgba,function(t,e){return null==t?e>2?1:0:t});return 1===i[3]&&(i.pop(),e="rgb("),e+i.join()+")"},toHslaString:function(){var e="hsla(",i=t.map(this.hsla(),function(t,e){return null==t&&(t=e>2?1:0),e&&3>e&&(t=Math.round(100*t)+"%"),t});return 1===i[3]&&(i.pop(),e="hsl("),e+i.join()+")"},toHexString:function(e){var i=this._rgba.slice(),s=i.pop();return e&&i.push(~~(255*s)),"#"+t.map(i,function(t){return t=(t||0).toString(16),1===t.length?"0"+t:t}).join("")},toString:function(){return 0===this._rgba[3]?"transparent":this.toRgbaString()}}),l.fn.parse.prototype=l.fn,c.hsla.to=function(t){if(null==t[0]||null==t[1]||null==t[2])return[null,null,null,t[3]];var e,i,s=t[0]/255,n=t[1]/255,o=t[2]/255,a=t[3],r=Math.max(s,n,o),h=Math.min(s,n,o),l=r-h,c=r+h,u=.5*c;return e=h===r?0:s===r?60*(n-o)/l+360:n===r?60*(o-s)/l+120:60*(s-n)/l+240,i=0===l?0:.5>=u?l/c:l/(2-c),[Math.round(e)%360,i,u,null==a?1:a]},c.hsla.from=function(t){if(null==t[0]||null==t[1]||null==t[2])return[null,null,null,t[3]];var e=t[0]/360,i=t[1],s=t[2],o=t[3],a=.5>=s?s*(1+i):s+i-s*i,r=2*s-a;return[Math.round(255*n(r,a,e+1/3)),Math.round(255*n(r,a,e)),Math.round(255*n(r,a,e-1/3)),o]},f(c,function(s,n){var o=n.props,a=n.cache,h=n.to,c=n.from;l.fn[s]=function(s){if(h&&!this[a]&&(this[a]=h(this._rgba)),s===e)return this[a].slice();var n,r=t.type(s),u="array"===r||"object"===r?s:arguments,d=this[a].slice();return f(o,function(t,e){var s=u["object"===r?t:e.idx];null==s&&(s=d[e.idx]),d[e.idx]=i(s,e)}),c?(n=l(c(d)),n[a]=d,n):l(d)},f(o,function(e,i){l.fn[e]||(l.fn[e]=function(n){var o,a=t.type(n),h="alpha"===e?this._hsla?"hsla":"rgba":s,l=this[h](),c=l[i.idx];return"undefined"===a?c:("function"===a&&(n=n.call(this,c),a=t.type(n)),null==n&&i.empty?this:("string"===a&&(o=r.exec(n),o&&(n=c+parseFloat(o[2])*("+"===o[1]?1:-1))),l[i.idx]=n,this[h](l)))})})}),l.hook=function(e){var i=e.split(" ");f(i,function(e,i){t.cssHooks[i]={set:function(e,n){var o,a,r="";if("transparent"!==n&&("string"!==t.type(n)||(o=s(n)))){if(n=l(o||n),!d.rgba&&1!==n._rgba[3]){for(a="backgroundColor"===i?e.parentNode:e;(""===r||"transparent"===r)&&a&&a.style;)try{r=t.css(a,"backgroundColor"),a=a.parentNode}catch(h){}n=n.blend(r&&"transparent"!==r?r:"_default")}n=n.toRgbaString()}try{e.style[i]=n}catch(h){}}},t.fx.step[i]=function(e){e.colorInit||(e.start=l(e.elem,i),e.end=l(e.end),e.colorInit=!0),t.cssHooks[i].set(e.elem,e.start.transition(e.end,e.pos))}})},l.hook(a),t.cssHooks.borderColor={expand:function(t){var e={};return f(["Top","Right","Bottom","Left"],function(i,s){e["border"+s+"Color"]=t}),e}},o=t.Color.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"}}(jQuery),function(){function i(e){var i,s,n=e.ownerDocument.defaultView?e.ownerDocument.defaultView.getComputedStyle(e,null):e.currentStyle,o={};if(n&&n.length&&n[0]&&n[n[0]])for(s=n.length;s--;)i=n[s],"string"==typeof n[i]&&(o[t.camelCase(i)]=n[i]);else for(i in n)"string"==typeof n[i]&&(o[i]=n[i]);return o}function s(e,i){var s,n,a={};for(s in i)n=i[s],e[s]!==n&&(o[s]||(t.fx.step[s]||!isNaN(parseFloat(n)))&&(a[s]=n));return a}var n=["add","remove","toggle"],o={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};t.each(["borderLeftStyle","borderRightStyle","borderBottomStyle","borderTopStyle"],function(e,i){t.fx.step[i]=function(t){("none"!==t.end&&!t.setAttr||1===t.pos&&!t.setAttr)&&(jQuery.style(t.elem,i,t.end),t.setAttr=!0)}}),t.fn.addBack||(t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t.effects.animateClass=function(e,o,a,r){var h=t.speed(o,a,r);return this.queue(function(){var o,a=t(this),r=a.attr("class")||"",l=h.children?a.find("*").addBack():a;l=l.map(function(){var e=t(this);return{el:e,start:i(this)}}),o=function(){t.each(n,function(t,i){e[i]&&a[i+"Class"](e[i])})},o(),l=l.map(function(){return this.end=i(this.el[0]),this.diff=s(this.start,this.end),this}),a.attr("class",r),l=l.map(function(){var e=this,i=t.Deferred(),s=t.extend({},h,{queue:!1,complete:function(){i.resolve(e)}});return this.el.animate(this.diff,s),i.promise()}),t.when.apply(t,l.get()).done(function(){o(),t.each(arguments,function(){var e=this.el;t.each(this.diff,function(t){e.css(t,"")})}),h.complete.call(a[0])})})},t.fn.extend({addClass:function(e){return function(i,s,n,o){return s?t.effects.animateClass.call(this,{add:i},s,n,o):e.apply(this,arguments)}}(t.fn.addClass),removeClass:function(e){return function(i,s,n,o){return arguments.length>1?t.effects.animateClass.call(this,{remove:i},s,n,o):e.apply(this,arguments)}}(t.fn.removeClass),toggleClass:function(i){return function(s,n,o,a,r){return"boolean"==typeof n||n===e?o?t.effects.animateClass.call(this,n?{add:s}:{remove:s},o,a,r):i.apply(this,arguments):t.effects.animateClass.call(this,{toggle:s},n,o,a)}}(t.fn.toggleClass),switchClass:function(e,i,s,n,o){return t.effects.animateClass.call(this,{add:i,remove:e},s,n,o)}})}(),function(){function s(e,i,s,n){return t.isPlainObject(e)&&(i=e,e=e.effect),e={effect:e},null==i&&(i={}),t.isFunction(i)&&(n=i,s=null,i={}),("number"==typeof i||t.fx.speeds[i])&&(n=s,s=i,i={}),t.isFunction(s)&&(n=s,s=null),i&&t.extend(e,i),s=s||i.duration,e.duration=t.fx.off?0:"number"==typeof s?s:s in t.fx.speeds?t.fx.speeds[s]:t.fx.speeds._default,e.complete=n||i.complete,e}function n(e){return!e||"number"==typeof e||t.fx.speeds[e]?!0:"string"!=typeof e||t.effects.effect[e]?t.isFunction(e)?!0:"object"!=typeof e||e.effect?!1:!0:!0}t.extend(t.effects,{version:"1.10.4",save:function(t,e){for(var s=0;e.length>s;s++)null!==e[s]&&t.data(i+e[s],t[0].style[e[s]])},restore:function(t,s){var n,o;for(o=0;s.length>o;o++)null!==s[o]&&(n=t.data(i+s[o]),n===e&&(n=""),t.css(s[o],n))},setMode:function(t,e){return"toggle"===e&&(e=t.is(":hidden")?"show":"hide"),e},getBaseline:function(t,e){var i,s;switch(t[0]){case"top":i=0;break;case"middle":i=.5;break;case"bottom":i=1;break;default:i=t[0]/e.height}switch(t[1]){case"left":s=0;break;case"center":s=.5;break;case"right":s=1;break;default:s=t[1]/e.width}return{x:s,y:i}},createWrapper:function(e){if(e.parent().is(".ui-effects-wrapper"))return e.parent();var i={width:e.outerWidth(!0),height:e.outerHeight(!0),"float":e.css("float")},s=t("

    ").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),n={width:e.width(),height:e.height()},o=document.activeElement;try{o.id}catch(a){o=document.body}return e.wrap(s),(e[0]===o||t.contains(e[0],o))&&t(o).focus(),s=e.parent(),"static"===e.css("position")?(s.css({position:"relative"}),e.css({position:"relative"})):(t.extend(i,{position:e.css("position"),zIndex:e.css("z-index")}),t.each(["top","left","bottom","right"],function(t,s){i[s]=e.css(s),isNaN(parseInt(i[s],10))&&(i[s]="auto")}),e.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})),e.css(n),s.css(i).show()},removeWrapper:function(e){var i=document.activeElement;return e.parent().is(".ui-effects-wrapper")&&(e.parent().replaceWith(e),(e[0]===i||t.contains(e[0],i))&&t(i).focus()),e},setTransition:function(e,i,s,n){return n=n||{},t.each(i,function(t,i){var o=e.cssUnit(i);o[0]>0&&(n[i]=o[0]*s+o[1])}),n}}),t.fn.extend({effect:function(){function e(e){function s(){t.isFunction(o)&&o.call(n[0]),t.isFunction(e)&&e()}var n=t(this),o=i.complete,r=i.mode;(n.is(":hidden")?"hide"===r:"show"===r)?(n[r](),s()):a.call(n[0],i,s)}var i=s.apply(this,arguments),n=i.mode,o=i.queue,a=t.effects.effect[i.effect];return t.fx.off||!a?n?this[n](i.duration,i.complete):this.each(function(){i.complete&&i.complete.call(this)}):o===!1?this.each(e):this.queue(o||"fx",e)},show:function(t){return function(e){if(n(e))return t.apply(this,arguments);var i=s.apply(this,arguments);return i.mode="show",this.effect.call(this,i)}}(t.fn.show),hide:function(t){return function(e){if(n(e))return t.apply(this,arguments);var i=s.apply(this,arguments);return i.mode="hide",this.effect.call(this,i)}}(t.fn.hide),toggle:function(t){return function(e){if(n(e)||"boolean"==typeof e)return t.apply(this,arguments);var i=s.apply(this,arguments);return i.mode="toggle",this.effect.call(this,i)}}(t.fn.toggle),cssUnit:function(e){var i=this.css(e),s=[];return t.each(["em","px","%","pt"],function(t,e){i.indexOf(e)>0&&(s=[parseFloat(i),e])}),s}})}(),function(){var e={};t.each(["Quad","Cubic","Quart","Quint","Expo"],function(t,i){e[i]=function(e){return Math.pow(e,t+2)}}),t.extend(e,{Sine:function(t){return 1-Math.cos(t*Math.PI/2)},Circ:function(t){return 1-Math.sqrt(1-t*t)},Elastic:function(t){return 0===t||1===t?t:-Math.pow(2,8*(t-1))*Math.sin((80*(t-1)-7.5)*Math.PI/15)},Back:function(t){return t*t*(3*t-2)},Bounce:function(t){for(var e,i=4;((e=Math.pow(2,--i))-1)/11>t;);return 1/Math.pow(4,3-i)-7.5625*Math.pow((3*e-2)/22-t,2)}}),t.each(e,function(e,i){t.easing["easeIn"+e]=i,t.easing["easeOut"+e]=function(t){return 1-i(1-t)},t.easing["easeInOut"+e]=function(t){return.5>t?i(2*t)/2:1-i(-2*t+2)/2}})}()}(jQuery),function(t){var e=0,i={},s={};i.height=i.paddingTop=i.paddingBottom=i.borderTopWidth=i.borderBottomWidth="hide",s.height=s.paddingTop=s.paddingBottom=s.borderTopWidth=s.borderBottomWidth="show",t.widget("ui.accordion",{version:"1.10.4",options:{active:0,animate:{},collapsible:!1,event:"click",header:"> li > :first-child,> :not(li):even",heightStyle:"auto",icons:{activeHeader:"ui-icon-triangle-1-s",header:"ui-icon-triangle-1-e"},activate:null,beforeActivate:null},_create:function(){var e=this.options;this.prevShow=this.prevHide=t(),this.element.addClass("ui-accordion ui-widget ui-helper-reset").attr("role","tablist"),e.collapsible||e.active!==!1&&null!=e.active||(e.active=0),this._processPanels(),0>e.active&&(e.active+=this.headers.length),this._refresh()},_getCreateEventData:function(){return{header:this.active,panel:this.active.length?this.active.next():t(),content:this.active.length?this.active.next():t()}},_createIcons:function(){var e=this.options.icons;e&&(t("").addClass("ui-accordion-header-icon ui-icon "+e.header).prependTo(this.headers),this.active.children(".ui-accordion-header-icon").removeClass(e.header).addClass(e.activeHeader),this.headers.addClass("ui-accordion-icons")) },_destroyIcons:function(){this.headers.removeClass("ui-accordion-icons").children(".ui-accordion-header-icon").remove()},_destroy:function(){var t;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role"),this.headers.removeClass("ui-accordion-header ui-accordion-header-active ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-selected").removeAttr("aria-controls").removeAttr("tabIndex").each(function(){/^ui-accordion/.test(this.id)&&this.removeAttribute("id")}),this._destroyIcons(),t=this.headers.next().css("display","").removeAttr("role").removeAttr("aria-hidden").removeAttr("aria-labelledby").removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled").each(function(){/^ui-accordion/.test(this.id)&&this.removeAttribute("id")}),"content"!==this.options.heightStyle&&t.css("height","")},_setOption:function(t,e){return"active"===t?(this._activate(e),undefined):("event"===t&&(this.options.event&&this._off(this.headers,this.options.event),this._setupEvents(e)),this._super(t,e),"collapsible"!==t||e||this.options.active!==!1||this._activate(0),"icons"===t&&(this._destroyIcons(),e&&this._createIcons()),"disabled"===t&&this.headers.add(this.headers.next()).toggleClass("ui-state-disabled",!!e),undefined)},_keydown:function(e){if(!e.altKey&&!e.ctrlKey){var i=t.ui.keyCode,s=this.headers.length,n=this.headers.index(e.target),o=!1;switch(e.keyCode){case i.RIGHT:case i.DOWN:o=this.headers[(n+1)%s];break;case i.LEFT:case i.UP:o=this.headers[(n-1+s)%s];break;case i.SPACE:case i.ENTER:this._eventHandler(e);break;case i.HOME:o=this.headers[0];break;case i.END:o=this.headers[s-1]}o&&(t(e.target).attr("tabIndex",-1),t(o).attr("tabIndex",0),o.focus(),e.preventDefault())}},_panelKeyDown:function(e){e.keyCode===t.ui.keyCode.UP&&e.ctrlKey&&t(e.currentTarget).prev().focus()},refresh:function(){var e=this.options;this._processPanels(),e.active===!1&&e.collapsible===!0||!this.headers.length?(e.active=!1,this.active=t()):e.active===!1?this._activate(0):this.active.length&&!t.contains(this.element[0],this.active[0])?this.headers.length===this.headers.find(".ui-state-disabled").length?(e.active=!1,this.active=t()):this._activate(Math.max(0,e.active-1)):e.active=this.headers.index(this.active),this._destroyIcons(),this._refresh()},_processPanels:function(){this.headers=this.element.find(this.options.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all"),this.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom").filter(":not(.ui-accordion-content-active)").hide()},_refresh:function(){var i,s=this.options,n=s.heightStyle,o=this.element.parent(),a=this.accordionId="ui-accordion-"+(this.element.attr("id")||++e);this.active=this._findActive(s.active).addClass("ui-accordion-header-active ui-state-active ui-corner-top").removeClass("ui-corner-all"),this.active.next().addClass("ui-accordion-content-active").show(),this.headers.attr("role","tab").each(function(e){var i=t(this),s=i.attr("id"),n=i.next(),o=n.attr("id");s||(s=a+"-header-"+e,i.attr("id",s)),o||(o=a+"-panel-"+e,n.attr("id",o)),i.attr("aria-controls",o),n.attr("aria-labelledby",s)}).next().attr("role","tabpanel"),this.headers.not(this.active).attr({"aria-selected":"false","aria-expanded":"false",tabIndex:-1}).next().attr({"aria-hidden":"true"}).hide(),this.active.length?this.active.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0}).next().attr({"aria-hidden":"false"}):this.headers.eq(0).attr("tabIndex",0),this._createIcons(),this._setupEvents(s.event),"fill"===n?(i=o.height(),this.element.siblings(":visible").each(function(){var e=t(this),s=e.css("position");"absolute"!==s&&"fixed"!==s&&(i-=e.outerHeight(!0))}),this.headers.each(function(){i-=t(this).outerHeight(!0)}),this.headers.next().each(function(){t(this).height(Math.max(0,i-t(this).innerHeight()+t(this).height()))}).css("overflow","auto")):"auto"===n&&(i=0,this.headers.next().each(function(){i=Math.max(i,t(this).css("height","").height())}).height(i))},_activate:function(e){var i=this._findActive(e)[0];i!==this.active[0]&&(i=i||this.active[0],this._eventHandler({target:i,currentTarget:i,preventDefault:t.noop}))},_findActive:function(e){return"number"==typeof e?this.headers.eq(e):t()},_setupEvents:function(e){var i={keydown:"_keydown"};e&&t.each(e.split(" "),function(t,e){i[e]="_eventHandler"}),this._off(this.headers.add(this.headers.next())),this._on(this.headers,i),this._on(this.headers.next(),{keydown:"_panelKeyDown"}),this._hoverable(this.headers),this._focusable(this.headers)},_eventHandler:function(e){var i=this.options,s=this.active,n=t(e.currentTarget),o=n[0]===s[0],a=o&&i.collapsible,r=a?t():n.next(),h=s.next(),l={oldHeader:s,oldPanel:h,newHeader:a?t():n,newPanel:r};e.preventDefault(),o&&!i.collapsible||this._trigger("beforeActivate",e,l)===!1||(i.active=a?!1:this.headers.index(n),this.active=o?t():n,this._toggle(l),s.removeClass("ui-accordion-header-active ui-state-active"),i.icons&&s.children(".ui-accordion-header-icon").removeClass(i.icons.activeHeader).addClass(i.icons.header),o||(n.removeClass("ui-corner-all").addClass("ui-accordion-header-active ui-state-active ui-corner-top"),i.icons&&n.children(".ui-accordion-header-icon").removeClass(i.icons.header).addClass(i.icons.activeHeader),n.next().addClass("ui-accordion-content-active")))},_toggle:function(e){var i=e.newPanel,s=this.prevShow.length?this.prevShow:e.oldPanel;this.prevShow.add(this.prevHide).stop(!0,!0),this.prevShow=i,this.prevHide=s,this.options.animate?this._animate(i,s,e):(s.hide(),i.show(),this._toggleComplete(e)),s.attr({"aria-hidden":"true"}),s.prev().attr("aria-selected","false"),i.length&&s.length?s.prev().attr({tabIndex:-1,"aria-expanded":"false"}):i.length&&this.headers.filter(function(){return 0===t(this).attr("tabIndex")}).attr("tabIndex",-1),i.attr("aria-hidden","false").prev().attr({"aria-selected":"true",tabIndex:0,"aria-expanded":"true"})},_animate:function(t,e,n){var o,a,r,h=this,l=0,c=t.length&&(!e.length||t.index()",options:{appendTo:null,autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null,change:null,close:null,focus:null,open:null,response:null,search:null,select:null},requestIndex:0,pending:0,_create:function(){var e,i,s,n=this.element[0].nodeName.toLowerCase(),o="textarea"===n,a="input"===n;this.isMultiLine=o?!0:a?!1:this.element.prop("isContentEditable"),this.valueMethod=this.element[o||a?"val":"text"],this.isNewMenu=!0,this.element.addClass("ui-autocomplete-input").attr("autocomplete","off"),this._on(this.element,{keydown:function(n){if(this.element.prop("readOnly"))return e=!0,s=!0,i=!0,undefined;e=!1,s=!1,i=!1;var o=t.ui.keyCode;switch(n.keyCode){case o.PAGE_UP:e=!0,this._move("previousPage",n);break;case o.PAGE_DOWN:e=!0,this._move("nextPage",n);break;case o.UP:e=!0,this._keyEvent("previous",n);break;case o.DOWN:e=!0,this._keyEvent("next",n);break;case o.ENTER:case o.NUMPAD_ENTER:this.menu.active&&(e=!0,n.preventDefault(),this.menu.select(n));break;case o.TAB:this.menu.active&&this.menu.select(n);break;case o.ESCAPE:this.menu.element.is(":visible")&&(this._value(this.term),this.close(n),n.preventDefault());break;default:i=!0,this._searchTimeout(n)}},keypress:function(s){if(e)return e=!1,(!this.isMultiLine||this.menu.element.is(":visible"))&&s.preventDefault(),undefined;if(!i){var n=t.ui.keyCode;switch(s.keyCode){case n.PAGE_UP:this._move("previousPage",s);break;case n.PAGE_DOWN:this._move("nextPage",s);break;case n.UP:this._keyEvent("previous",s);break;case n.DOWN:this._keyEvent("next",s)}}},input:function(t){return s?(s=!1,t.preventDefault(),undefined):(this._searchTimeout(t),undefined)},focus:function(){this.selectedItem=null,this.previous=this._value()},blur:function(t){return this.cancelBlur?(delete this.cancelBlur,undefined):(clearTimeout(this.searching),this.close(t),this._change(t),undefined)}}),this._initSource(),this.menu=t("