/*! * 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 = ""; 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 $( "