/*! * DW JS iAdmin LIBRARY 2.0 * * jQuery 1.4.2 * Colorbox 1.3.9 * jQuery Tools 1.2.5 * jQuery UI 1.8.5 * jScrollPane v2.0.0beta5 * scrollTo 1.4.2 */ function newWindow(path, w, h, scroll, name) { if (name == null) { name = "newWin"; } var height = h; var width = w; var wleft = (screen.width - width - 20) / 2; var wtop = (screen.height - height) / 2; window.open(path, name, 'fullscreen=0,scrollbars=' + scroll + ',height=' + height + ',width=' + width + ',top=' + wtop + ',left=' + wleft + ''); } $(document).ready(function() { initAdmin(); loadDashboardNetworkFind(); if($(".mrp_radioSelectWrap").length>0){ setMrpRadioSelect($("input[type=radio]:checked").parent()); } }); var lastChecked = null; var iHeight = 500; var iHeightOffset = 60; var iContentSrc = ""; var navTimers = []; var loader16x16 = "loading..."; function initAdmin() { initMaxLengths(); initModalBox(); $(".contentSubWrap").addClass("clearfix"); //this can probably be written in the backend now that we know we are set with contentsubwraps $('.popoverBtn').popover(); $('.popoverNext').popover({content:function(){return ajaxTipContent(this);}, html:true}); $(".tooltipMeNext").tooltip({title:function(){return getTipContent(this);}}); $(".tooltipMe").tooltip(); //wire the "saving" state for buttons $(".loadBtn").button(); //for auto showing the first tab/pane in a tab list $(".autoInitTab.tab-content .tab-pane:first-child").addClass("active"); $(".autoInitTab.nav li:first-child").addClass("active"); //init drowdown menu active tab $("#siteMenu .dropdown li.active").closest("li.dropdown").addClass("active"); $(".siteMenu .dropdown li.active").closest("li.dropdown").addClass("active"); var bodyRel=$("body").attr('rel'); if(bodyRel != null){ var menuIdentifier = bodyRel.split('-')[1]; $(".iconMenuWrap li.nav-" + menuIdentifier).addClass("active"); $(".iconMenuWrap .dropdown li.active").closest("li.dropdown").addClass("active"); $(".iconMenuWrap .iconMenuItem.active").append(""); } initCheckBoxShift() $('.timePicker').timepicker(); $('.scrollMe').perfectScrollbar({includePadding:true}); //initPreviewWindow(); } function validate(group){ var isValid = Page_ClientValidate(group); //parameter is the validation group - thanks @Jeff if (!isValid){ setTimeout(function(){ $(".loadBtn").button('reset');},3000); } } function getTipContent(el){ return $(el).nextAll(".tipContent").html(); } function ajaxTipContent(el){ var content = $(el).nextAll(".tipContent").html(); return content; } function initModalBox() { if ($("a.modalBox").length > 0) { $("a.modalBox").colorbox(); $("a.inlineModal").colorbox({ inline: true, href: $(this).attr("href") }); } if ($("a.modalFrame").length > 0) { $("a.modalFrame").each(function() { var modalDimensions = '350x350'; //&d= var modalWidth; var modalHeight; var modalCallBack = ''; //&f= var autoSize="false"; var modalArgs = $(this).attr("rel"); if (modalArgs) { modalDimensions = parseArgs('d', modalArgs); modalCallBack = parseArgs('f', modalArgs); autoSize = parseArgs('a', modalArgs); } if(modalDimensions=="full"){ modalHeight=$(window).height()-50; modalWidth=$(window).width()-50; }else{ modalWidth = parseInt(modalDimensions.split("x")[0]); modalHeight = parseInt(modalDimensions.split("x")[1]); if(autoSize=="true"){ if(modalHeight > ($(window).height()-50)){ modalHeight = $(window).height()-50; } if(modalWidth > ($(window).width()-50)){ modalWidth = $(window).width()-50; } } modalWidth=modalWidth+"px"; modalHeight=modalHeight+"px"; } $(this).colorbox({ iframe: true, width: modalWidth, height: modalHeight, rel: 'nofollow', onClosed: function() { eval(modalCallBack); } }); }); } } function genAjaxLoad(el, path, loaderLoc) { $("#pageLoader").show(); el.load(path, '', function() { $("#pageLoader").hide(); }); } function genPageAlert(alertMessage){ if($("#pageAlert").length >0){ $("#pageAlertInner").text(alertMessage); $("#pageAlert").fadeTo("slow", 1).animate({ opacity: 1.0 }, 1000).fadeTo("slow", 0, function(){$("#pageAlert").hide();}); } } function simpleAjax(el) { //assumes anchor element $("#pageLoader").show(); $.ajax({ url: el.href, async: true, cache:false, success: function updateStatus(newStatus) { $(el).replaceWith(newStatus); $("#pageLoader").hide(); } }); } function showPageLoader(){ $("#pageLoader").show(); } function childAjaxReload(parentEl, path) { var newHtml = ""; $.ajax({ url: path, success: function(data) { doReload(data); } }); function doReload(newHtml) { newHtml = newHtml.split("|"); $.each(newHtml, function(i, val) { var curClass = val.split(":")[0]; var curVal = val.split(":")[1]; $(parentEl + " ." + curClass).text(curVal); }); } } function initAdminResize() { $("#mrpPanel").resizable({ maxHeight: 1000, maxWidth: 980, minHeight: 300, minWidth: 980, handles: 's', grid: 1 }); } function initMaxLengths() { $(".txtMax").each(function() { var max = parseInt($(this).attr("class").split("chars")[1]); initMax(this, max); }); } function initMax(el, max) { if ($(el).next().is(".charsRemaining")) { $(el).next().remove(); } $(el).after("

"); $(el).parent().find('.charsRemaining').html('You have ' + (max - $(el).val().length) + ' characters remaining.'); $(el).keydown(function() { $(el).parent().find('.charsRemaining').html('You have ' + (max - $(el).val().length) + ' characters remaining.'); if ($(el).val().length > max) { $(el).val($(el).val().substr(0, max)); } $(el).parent().find('.charsRemaining').html('You have ' + (max - $(el).val().length) + ' characters remaining.'); }); } function initSmartHeight(el) { if (el) { setHeight(el, 0); } else { if (!($.browser.msie && $.browser.version < 8)) { ///do not do for ie7 and lower $(".smartHeight").each(function() { if ($(this).attr("id") == "mrpPanel") { setHeight(this, iHeightOffset); } else { setHeight(this, 0); } $(this).css("overflow", "auto"); }); $("body").css("overflow", "hidden").css("position", "relative"); } } $(window).resize(function() { initSmartHeight(); }); function setHeight(el, hOffset) { //use hOffset when needed (example: mrpPanel) var elOffset = $(el).offset(); var winHeight = $(window).height(); var newHeight = (winHeight - elOffset.top - hOffset); var elMinHeight = $(el).css("min-height"); $(el).css("height", newHeight + "px"); if ($(el).get(0).scrollHeight > $(el).height()) { $(".fauxThead th.scrollFiller").show(); } else { $(".fauxThead th.scrollFiller").hide(); } } } function initSmartWidth(el) { if (el) { setWidth(el); } else { $(".smartWidth").each(function() { setWidth(this); }); } function setWidth(el) { var usedSpace = $(el).siblings().outerWidth(true); var parentWidth = $(el).parent().outerWidth(true); var extraSpace = $(el).outerWidth(true) - $(el).width(); var newWidth = (parentWidth - usedSpace - extraSpace) + "px"; $(el).css("width", newWidth).css("visibility", "visible"); } } function initSessionTimer(sessionLength) { var t; function checkServer() { $.ajax({ cache:false, url: '/admin/cr/ui/checkLogin.aspx', success: function(data) { if (data == 1) { resetTimer(); } else { alert("We're sorry, your session has already expired. Please login again."); parent.location.href = "/myaccount/signin.aspx"; } } }); } function checkSession() { var r = confirm("Your session is about to expire. Press 'OK' to remain logged in."); if (r == true) { checkServer(); } else { checkServer(); } } function resetTimer() { //alert("init timer with a session length of: " + sessionLength / 60000 + " minutes."); clearTimeout(t); t = setTimeout(checkSession, sessionLength - 240000) //alert 4 minutes before session ends } resetTimer(); } ///END INIT FUNCTIONS/// function swapEl(toShow, navClicked) { if (navClicked) { $(navClicked).siblings().removeClass("genUrl"); $(navClicked).addClass("genUrl"); } $(toShow).show(); $(toShow).siblings().hide(); } function quickToggle(el) { //pass an element and it will toggle the children that have a class of "quickHide" $(el).find(".quickHide").toggle(); } function querySt(ji) { hu = window.location.search.substring(1); gy = hu.split("&"); for (i = 0; i < gy.length; i++) { ft = gy[i].split("="); if (ft[0] == ji) { return ft[1]; } } } function parseArgs(ji, toParse) { hu = toParse; gy = hu.split("|"); for (i = 0; i < gy.length; i++) { ft = gy[i].split(":"); if (ft[0] == ji) { return ft[1]; } } } function getHash(){ return document.location.hash.replace("#", ""); } function winScroll() { $('html, body').animate({ scrollTop: 0 }, 'slow'); return false; } function updateClone(type, clonerId, el) { if (type == "radio") { if ($(el).is(":checked")) { $(clonerId).text($(el).val()); } } if (type == "checkbox") { var curSelected = $(clonerId).text(); if ($(el).is(":checked")) { $(clonerId).text(curSelected + $(el).val() + ", "); } else { $(clonerId).text($(clonerId).text().replace($(el).val() + ', ', "")); } } if (type == "text") { $(clonerId).text($(el).val()); } } function initClones() { $(".clonee").each(function() { var clonerId = "#" + $(this).attr("rel"); var type = ""; var isPreChecked = $(this).attr("id").indexOf("cur-"); if (isPreChecked != -1) { $(this).attr("checked", "checked"); //check it (doesn't fire event) $(this).click(); //fire event (also unchecks it) $(this).attr("checked", "checked"); //check it (won't fire event) } else { if ($(this).attr("type") == "radio") { //check if it is a radio button type = "radio"; $(this).change(function() { updateClone(type, clonerId, this); }) .change(); } else if ($(this).attr("type") == "checkbox") { //check if it is a checkbox list type = "checkbox"; $(this).change(function() { updateClone(type, clonerId, this); }) .change(); } else if (($(this).attr("type") == "text") || ($(this).is("textarea"))) { //check if it is a textbox var type = "text"; $(this).change(function() { updateClone(type, clonerId, this); }).keyup(function() { updateClone(type, clonerId, this); }).change(); } } }); } function stickySide(id, gutter) { if (window.XMLHttpRequest) { if (document.documentElement.scrollTop > gutter || self.pageYOffset > gutter) { $('#' + id).css('position', 'fixed'); $('#' + id).css('top', '8px'); } else if (document.documentElement.scrollTop < gutter || self.pageYOffset < gutter) { $('#' + id).css('position', 'absolute'); $('#' + id).css('top', gutter + 'px'); } } } function cr_reloadSelf() { window.location.href = window.location.href.split('#')[0]; //self.location.reload(true); } function reloadUpdatePanel(panel) { __doPostBack(panel, ''); } function redirectParent(url) { if (window.location != window.parent.location) { window.parent.location = url; } else { window.location = url; } } function cr_openImageMerge(hidValuesBox){ if($("." + hidValuesBox).length > 0){ newWindow("/admin/cr/ui/media.aspx?actn=merge&type=image&m=" + $("." + hidValuesBox).val(), 600, 600, 1); } } function renderAutoItem(ul, item){ if(item.id==-1){ return $( "
  • " ).append("Add: "+ item.label + "").appendTo( ul ); }else{ if(item.desc !="") return $( "
  • " ).append(""+item.label + "
    " + item.desc +"
    ").appendTo( ul ); else return $( "
  • " ).append(""+ item.label + "").appendTo( ul ); } } function renderAutoItem_v2(ul, item) { // Start HTML and append driver's name var tag = "
  • "; tag += "
    " + item.MainText + ""; // Append previously used status if (item.PreviouslyUsed) { tag += ""; } // Append subtext if (item.SubText) { tag += "
    " + item.SubText; } // Append secondary subtext if (item.SubTextTwo) { tag += "
    " + item.SubTextTwo + ""; } tag += "
    " // Append driver's image if (item.Image) { tag += ""; } tag += "
  • "; // Return HTML return $(tag).appendTo(ul); } function loadCommonTags(el, link){ var path = $(link).attr("href"); if($(el).is(":visible")){ $(el).hide(); }else{ $(el+" ul").load(path, function(){ $(el).show(); }); } } function showPopup(el, button){ if($(el).is(":visible")){ $(el).offset({left:0, top: 0}).hide(); } else { var $this = $(button); var offset = $this.offset(); var width = $this.outerWidth(); var height = $this.outerHeight(); var centerX = offset.left + (width / 2); var centerY = offset.top + height; var elW = $(el).width(); centerX=centerX-(elW/2); $(el).offset({left:centerX, top: centerY + $(window).scrollTop()}).show(); } } function loadHelpPopout(el){ var path = $(el).attr("href"); if($("#helpPopOver").is(":visible")){ $("#helpPopOver").hide(); }else{ if($("#helpPopoverInner").hasClass("loaded")) { $("#helpPopOver").show(); }else { $("#helpPopOver").show(); $("#helpPopoverInner").html("
    loading...
    "); $("#helpPopoverInner").load("/admin/cr/help/?actn=pageTopics&path=" + path, function(){ $("#helpPopoverInner").addClass("loaded"); }); } } } function loadOtherAdminSites() { if ($("#adminSiteList").hasClass("loaded")) { } else { $("#adminSiteList").html("
  • loading...
  • "); $("#adminSiteList").load("/admin/cr/ui/getSites.aspx", function() { $("#adminSiteList").addClass("loaded"); }); } } function initCheckBoxShift() { var $chkboxes = $('.rowSelWrap input[type=checkbox]'); if($chkboxes != null) { $chkboxes.click(function(e) { if(!lastChecked) { lastChecked = this; return; } if(e.shiftKey) { var start = $chkboxes.index(this); var end = $chkboxes.index(lastChecked); $chkboxes.slice(Math.min(start,end), Math.max(start,end)+ 1).prop('checked', lastChecked.checked); } lastChecked = this; }); } } function closeParentPopover(el, disId){ $(el).hide(); if(disId != null){ $.ajax({ cache:false, type: "GET", url: "/admin/cr/ui/alert.aspx?actn=dismiss&i=" + disId }); } } function showHelpPopups(el, button) { var $this = $(button); var offset = $this.offset(); var width = $this.outerWidth(); var height = $this.outerHeight(); var centerX; var centerY; var elW = $(el).width(); centerX=centerX-(elW/2); if($(el).hasClass("left")){ centerY= (offset.top +(height/2)) -($(el).height()/2); centerX = offset.left - elW; }else if($(el).hasClass("right")){ centerY= (offset.top +(height/2)) -($(el).height()/2); centerX = offset.left + width + elW; } $(el).offset({left:centerX, top: centerY + $(window).scrollTop()}).fadeIn(); } function rotateImage(id, size) { var d = new Date(); var n = d.getTime(); $("#media" + id).attr("src", mrpAssetsUrl + "/adminicons/loader.gif").addClass("rotateLoader"); $("#media"+id).attr("src", "/admin/cr/ui/media.aspx?actn=rotate&i=" + id + "&s=" + size + "&tms=" + n).removeClass("rotateLoader"); } function togglePrintPageAll(state) { $(".printSelectButton").each(function () { var noneButton = document.getElementById("printNoneButton"); var allButton = document.getElementById("printAllButton"); if (state == 0) { if ($(this).hasClass("disabled")) { } else { $(this).addClass("disabled"); $(this).parent().addClass("disabled"); $(noneButton).addClass("hide"); $(noneButton).removeClass("btn"); $(allButton).removeClass("hide"); $(allButton).addClass("btn"); //---Added to modify FA icon--- $(".printSelectButton .fa").removeClass("fa-minus"); $(".printSelectButton .fa").addClass("fa-plus"); //----------------------------- } } else { $(this).removeClass("disabled"); $(this).parent().removeClass("disabled"); $(noneButton).removeClass("hide"); $(noneButton).addClass("btn"); $(allButton).addClass("hide"); $(allButton).removeClass("btn"); //---Added to modify FA icon--- $(".printSelectButton .fa").removeClass("fa-plus"); $(".printSelectButton .fa").addClass("fa-minus"); //----------------------------- } }); } function toggleFontSize(select) { if(select == 1) { //revert to default size $(".printPage").removeClass("toggleSmaller"); $(".printPage").removeClass("toggleSmall"); } else if(select == 2) { //add smaller size $(".printPage").addClass("toggleSmaller"); } } //function togglePrintPageNone() { // var checks = document.getElementsByClassName("printSelectButton"), // length = checks !== null ? checks.length : 0, // i = 0; // for (i; i < length; i++) { // var check = checks[i]; // var checkPage = $(check).parent(".printPage"); // if ($(check).hasClass("enabled")) { // $(checks).className = "printSelectButton tooltipMeNext disabled"; // $(checkPage).className = "printPage disabled"; // } // } //} function togglePrintPage(el){ var page = $(el).parent(".printPage"); var child = $(el).children(".fa"); if ($(el).hasClass("disabled")) { $(el).removeClass("disabled"); $(page).removeClass("disabled"); //---Added to modify FA icon--- $(child).removeClass("fa-plus"); $(child).addClass("fa-minus"); //----------------------------- } else { $(el).addClass("disabled"); $(page).addClass("disabled"); //---Added to modify FA icon--- $(child).removeClass("fa-minus"); $(child).addClass("fa-plus"); //----------------------------- } } function loadDashboardNetworkFind(){ $(".mrp_foundNews").load("/admin/cr/ui/networkFind.aspx?type=news"); $(".mrp_foundEvents").load("/admin/cr/ui/networkFind.aspx?type=sch"); } function setMrpRadioSelect(wrap) { $(".mrp_radioSelectWrap.active input[type=radio]").prop("checked", false); $(".mrp_radioSelectWrap").removeClass("active"); $(wrap).addClass("active"); $(wrap).find($("input[type=radio]")).prop("checked", true); } //CodeMirror var myCodeMirror = ""; var mirrorChanged=false; function initCodeMirror(fileType) { var useLint = false; if (fileType == "css" || fileType == "javascript") useLint = true; var width = 0; var height=0; if($(".codeMirrorWrapper").length>0){ height = $(window).height()-200; width = $(".codeMirrorWrapper").width() } if($(".colorSamples").length>0){ $(".colorSamples").height($(window).height()-250); } myCodeMirror = CodeMirror.fromTextArea(document.getElementById($(".txtHtmlFile").attr('id')), { mode: fileType, lineNumbers: true, indentWithTabs: true, indentUnit: 4, lineWrapping: false, matchTags: {bothTags:true}, gutters: ["CodeMirror-lint-markers"], lint: useLint, extraKeys: { "F11": function(cm) { cm.setOption("fullScreen", !cm.getOption("fullScreen")); }, "Esc": function(cm) { if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false); }, "Ctrl-J": "toMatchingTag" } }); myCodeMirror.on("change", function(){setCodeMirrorChange();}); if(height!=0 && width !=0) myCodeMirror.setSize(width, height); //this needs to be updated somehow, but it's a pain in the ass else if(width !=0) myCodeMirror.setSize(width); //this needs to be updated somehow, but it's a pain in the ass else myCodeMirror.setSize("1000px"); //this needs to be updated somehow, but it's a pain in the ass window.onbeforeunload = function() { if(mirrorChanged==true) return true; } } function saveEditor() { myCodeMirror.save(); mirrorChanged=false; $("#notSavedWrap").hide(); } function setCodeMirrorChange(){ mirrorChanged=true; $("#notSavedWrap").show(); } //End CodeMirror //function initPreviewWindow(){ // $("#previewWrapper iframe").height($(window).height()-41); // // $(".previewSwitch").bootstrapSwitch().on('switch-change', function (e, data) { // if($("#adminWrapper").is(":visible")){ // $("#adminWrapper").hide(); // $("#previewWrapper").show(); // // if(!$("#previewWrapper iframe").hasClass("loaded")){ // $("#previewWrapper iframe").attr('src',$(".txtLiveLink").val()).addClass("loaded"); // } // }else{ // $("#previewWrapper").hide(); // $("#adminWrapper").show(); // } // // // }); //} //function togglePreview(){ // if($("#adminWrapper").is(":visible")){ // $("#adminWrapper").hide(); // $("#previewWrapper").show(); // }else{ // $("#previewWrapper").hide(); // $("#adminWrapper").show(); // } //} /*TimePicker*/ !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery)}(function(a){function b(a){if(a.minTime&&(a.minTime=s(a.minTime)),a.maxTime&&(a.maxTime=s(a.maxTime)),a.durationTime&&"function"!=typeof a.durationTime&&(a.durationTime=s(a.durationTime)),a.disableTimeRanges.length>0){for(var b in a.disableTimeRanges)a.disableTimeRanges[b]=[s(a.disableTimeRanges[b][0]),s(a.disableTimeRanges[b][1])];a.disableTimeRanges=a.disableTimeRanges.sort(function(a,b){return a[0]-b[0]});for(var b=a.disableTimeRanges.length-1;b>0;b--)a.disableTimeRanges[b][0]<=a.disableTimeRanges[b-1][1]&&(a.disableTimeRanges[b-1]=[Math.min(a.disableTimeRanges[b][0],a.disableTimeRanges[b-1][0]),Math.max(a.disableTimeRanges[b][1],a.disableTimeRanges[b-1][1])],a.disableTimeRanges.splice(b,1))}return a}function c(b){var c=b.data("timepicker-settings"),f=b.data("timepicker-list");if(f&&f.length&&(f.remove(),b.data("timepicker-list",!1)),c.useSelect){f=a("