$(document).ready(function() { var selectedIndicatorsToGraph = []; //main tab scroll distance $distance = 100; $distance_counter = 0; $distance_counter_val = []; Dashboard.EditMode = false; var isMouseDown = false; $popularDashboardMode = false; var collapsed = false; var dashboard_collapsed = true; var oTable; // Datatable var lastMouseX = null; var lastMouseY = null; var row_obj = null; var toggleNumberFormatting = function(){ $('#toggle_number_formatting').click(function(e){ e.preventDefault(); if (DISABLE_NUMBER_FORMATTING == false){ DISABLE_NUMBER_FORMATTING = true; }else{ DISABLE_NUMBER_FORMATTING = false; } viewDashboard(); }); } toggleNumberFormatting(); var tabClick = function() { /* if (!dirtyTabConfirmation()) { return false; }*/ if (Dashboard.EditMode) { saveTabData(); } $("#main-tabs ul li").removeClass("active"); var $li = $(this).closest('li'); $li.addClass("active"); $isLast = $li.next().addClass("nextsibling"); //if last element was clicked, resize the tabs / container if($isLast.length == 0){ mainTabSizer(); } Dashboard.ResetIndicators(); Dashboard.trashDomIndicators(); Dashboard.trashDomRemoveSelectedIndicators(); Dashboard.trashDomSelectedIndicators(); $("#chart").slideUp(200, function(){ mainTabSizer(); }); viewDashboard(); if (Dashboard.EditMode) { editableTab(this) } } var dirtyTabConfirmation = function() { if (Dashboard.EditMode && Dashboard.DirtyTab) { if (!confirm('Changes to the tab have not be saved. Continue?')) { return false; } } return true; } var disableEditableTab = function() { if ($('#tab-name-inputdiv').length > 0) { // Restore the old tab. var $parent = $('#tab-name').parent(); $parent.find('img').show(); $("").attr("href", "javascript:void(0)").text($("#tab-name").data('value')).appendTo($parent); $('#tab-name').remove(); $('#tab-name-inputdiv').remove(); } } var editableTab = function(clicked) { disableEditableTab(); $(clicked).parent().find('img').hide(); var text = $(clicked).text(); $("").attr("id", "tab-name").attr("type","hidden").data("value",text).appendTo($(clicked).parent().append()); $("
").attr('data-value',text).attr("contenteditable","true").attr("id", "tab-name-inputdiv").html(text).appendTo($(clicked).parent().append()); $(clicked).remove(); } var closePopup = function(e) { $("#popup-detail").stop().animate({ opacity: 0.0 }, 200, function(){ $(this).offset( { left:-9999, top: -9999 }); }); } var closeExportPopup = function() { Dashboard.HideOverlay(); $('#popup-export').fadeOut(200, function() { $(this).offset({ left:-9999, top: -9999 }); }); } var closeExportdataPopup = function() { Dashboard.HideOverlay(); $('#popup-export-data').fadeOut(200, function() { $(this).offset({ left:-9999, top: -9999 }); }); } var closeReportdataPopup = function() { Dashboard.HideOverlay(); $('#popup-report-data').fadeOut(200, function() { $(this).offset({ left:-9999, top: -9999 }); }); } var timer; var showPopup = function(row, data) { clearTimeout(timer); timer = null; $('#facebox .column1 .row2').text($(row).children('.name').text()); $('#facebox .column2 .row2').text($(row).children('.location').text()); $('#facebox .column3 .row2').text($(row).children('.date').text()); //$('#popup-detail .aggregate').toggle(); var currentContainer = []; var c = 0; var type = { DataType: jQuery(row).attr('data-type'),decimals: jQuery(row).data('decimals'),display_units: jQuery(row).data('display_units') }; for (var date in data.simple) { var dateData = data.simple[date]; var theDate = new Date(date); dateData.dateLabel = Dashboard.DateFormat(date,jQuery(row).attr('data-period')); /* dateData.dateLabel = Dashboard.Months[theDate.getMonth()] + '-' + ('0' + (theDate.getYear() > 100 ? theDate.getYear() - 100 : theDate.getYear())).slice(-2);*/ dateData.type = type; currentContainer.push(dateData); if (c++ == 11) break; } $('#current-monthly tbody').empty(); $('#template-current-monthly').tmpl(currentContainer).appendTo('#current-monthly tbody'); $('#aggregate-monthly tbody').empty(); $('#tempate-aggregate-monthly').tmpl(currentContainer).appendTo('#aggregate-monthly tbody'); c = 0; currentContainer = []; for (var date in data.complex) { var dateParts = date.toString().match(/(\d+)/g); var dateData = data.complex[date]; var theDate = new Date(dateParts[0], dateParts[1]-1, dateParts[2]); if($(row).data('period') == 8 || $(row).data('period') == 1) { dateData.vf = data.complex[date] ? data.complex[date].vf : 'no data'; } else { dateData.vf = data.simple[date] ? data.simple[date].vf : 'no data'; } /*dateData.dateLabel = Dashboard.Months[theDate.getMonth()] + ' ' + ('0' + (theDate.getYear() > 100 ? theDate.getYear() - 100 : theDate.getYear())).slice(-2);*/ dateData.dateLabel = Dashboard.DateFormat(date,data.complex[date].period); dateData.type = type; currentContainer.push(dateData); if (c++ == 9) break; } $('#current-yearly tbody').empty(); $('#template-current-yearly').tmpl(currentContainer).appendTo('#current-yearly tbody'); $('#aggregate-yearly tbody').empty(); $('#template-aggregate-yearly').tmpl(currentContainer).appendTo('#aggregate-yearly tbody'); //movePopupDetail(); $("#popup-detail").stop().animate({ opacity: 1.0 }, 200, function(){}); }; var mouseVelocity = 0; function trackMouseSpeed() { var mrefreshinterval = 20; // update display every 500ms var lastmousex=-1; var lastmousey=-1; var lastmousetime; var mousetravel = 0; var mpoints = []; var mpoints_max = 30; $('#data-table .dataTables_scrollBody').mousemove(function(e) { var mousex = e.pageX; var mousey = e.pageY; if (lastmousex > -1) { mousetravel += Math.max( Math.abs(mousex-lastmousex), Math.abs(mousey-lastmousey) ); } lastmousex = mousex; lastmousey = mousey; }); var mdraw = function() { var md = new Date(); var timenow = md.getTime(); if (lastmousetime && lastmousetime!=timenow) { var pps = Math.round(mousetravel / (timenow - lastmousetime) * 1000); mpoints.push(pps); if (mpoints.length > mpoints_max) mpoints.splice(0,1); mousetravel = 0; mouseVelocity = pps; } lastmousetime = timenow; setTimeout(mdraw, mrefreshinterval); } // We could use setInterval instead, but I prefer to do it this way setTimeout(mdraw, mrefreshinterval); }; var movePopupDetail = function() { $popupHeight = $("#popup-detail").outerHeight(); $popupOffset = $("#popup-detail").offset(); $popupOffsetY = $popupOffset.top; $popupBottom = $popupOffsetY + $popupHeight; $arrowOffset = $("#popup-detail .hover-arrow").position(); $arrowOffsetY = $arrowOffset.top; $mousePopupOffsetY = 156; if($popupOffsetY != -9999){ if(($popupBottom >= $(window).height() + $(window).scrollTop()) && $arrowOffsetY >= 156){ $top = $(window).height() + $(window).scrollTop() - $popupHeight; } else{ $top = window.mouseY -$mousePopupOffsetY; } $("#popup-detail").offset({ left:window.mouseX +15, top: $top }); //if($arrowOffsetY + 30 <= $popupHeight - 10){ $("#popup-detail .hover-arrow").offset({ left:window.mouseX +15, top: window.mouseY }); //} } //else, initial move to visible range is happening else{ $("#popup-detail").offset({ left:window.mouseX +15, top: window.mouseY -$mousePopupOffsetY }); $("#popup-detail .hover-arrow").offset({ left:window.mouseX +15, top: window.mouseY }); } } var viewDashboard = function() { //var categoryClick = function(){} //Categories.Init(categoryClick, function() { //loadGrid(); //}); if (!Dashboard.EditMode) { Dashboard.PopulateDataContainer(function() { resizeTable(); }); } else { Dashboard.PopulateDataContainer(function() { $("#data-table tbody tr").addClass("edit-mode"); $("#data-table tbody tr").removeClass("active"); $("#main-tab-icons .icon-delete").show(); $("#main-tab-icons .icon-save").show(); $("#chart").slideUp(200, function(){}); $("#sub-tabs").slideDown(200, function(){ $("#sub-tabs ul li").fadeTo(200, 1.0, function() { //$('#sub-tabs ul li').removeClass('active').eq(1).addClass('active'); subTabSizer(); }); }); $("#filter-checkboxes").slideDown(200, function(){ }); $(".dataTables_scrollBody").animate({ height: '600px' }, 200, function() { mainTabSizer(); }); resizeTable(); }); } }; var viewDashboardFirst = function() { if (!Dashboard.EditMode) { Dashboard.PopulateDataContainer(function() { resizeTable(); }); } else { Dashboard.PopulateDataContainer(function() { $("#data-table tbody tr").addClass("edit-mode"); $("#data-table tbody tr").removeClass("active"); $("#main-tab-icons .icon-delete").show(); $("#main-tab-icons .icon-save").show(); $("#chart").slideUp(200, function(){}); $("#sub-tabs").slideDown(200, function(){ $("#sub-tabs ul li").fadeTo(200, 1.0, function() { //$('#sub-tabs ul li').removeClass('active').eq(1).addClass('active'); subTabSizer(); }); }); $(".dataTables_scrollBody").animate({ height: '600px' }, 200, function() { mainTabSizer(); }); resizeTable(); }); } }; var resizeTable = function() { var width = $(window).width(); $('table .fluid').hide(); if (width > 1050) { $('table .fluid-1050').show(); } if (width > 1750) { $('table .fluid-1750').show(); } if (oTable) { oTable.fnAdjustColumnSizing(false); } mainTabSizer(); }; // Checks to see if any of the advanced search dropdowns changed and reloads the dashboard if they have. /* (function() { var $state = $('#state'); var $city = $('#city'); var $county = $('#county'); var $metro = $('#metro'); $state.data('old-val', $state.val()); $city.data('old-val', $city.val()); $county.data('old-val', $county.val()); $metro.data('old-val', $metro.val()); setInterval(function() { if ($state.val() != $state.data('old-val') || $city.val() != $city.data('old-val') || $county.val() != $county.data('old-val') || $metro.val() != $metro.data('old-val')) { $state.data('old-val', $state.val()); $city.data('old-val', $city.val()); $county.data('old-val', $county.val()); $metro.data('old-val', $metro.val()); viewDashboard(); } }, 200); })(); */ // Checks to see if the advanced search keywords have been changed on blur // or if the key enter was pressed. Updates dashboard if so. (function() { var $keywords = $('#keywords'); $keywords.data('old-val', $keywords.val()); /* $keywords.blur(function(){ if($keywords.val() != $keywords.data('old-val')){ $keywords.data('old-val', $keywords.val()); viewDashboard(); } }); */ $keywords.keypress(function(e) { if(e.which == 13) { $keywords.data('old-val', $keywords.val()); viewDashboard(); } }); })(); var UpdateDataAreaPop = function() { //alert("main#UpdateDataAreaPop"); //$('#chart-bodyPop').show(); Dashboard.DrawChartPop(function() { mainTabSizer(); }); }; var UpdateDataAreaEmp = function() { //alert("main#UpdateDataAreaEmp"); //$('#chart-bodyPop').show(); Dashboard.DrawChartEmp(function() { mainTabSizer(); }); }; var UpdateDataAreaSpend = function() { //alert("main#UpdateDataAreaSpend"); //$('#chart-bodyPop').show(); Dashboard.DrawChartSpend(function() { mainTabSizer(); }); }; var UpdateDataArea = function() { //alert("hiii"); if ($('#chart .chart').hasClass('active')) { $('#thegrid-body').hide(); $('#chart-body').show(); $('#chart-legend').show(); Dashboard.DrawChart(function() { $("#chart").slideDown(400, function(){ mainTabSizer(); }); /* $('html, body').animate({ scrollTop: $("#chart").offset().top }, 2000);*/ }, function() { $("#chart").slideUp(400, function(){ mainTabSizer(); }); }); } else if ($('#chart .list').hasClass('active')) { $('#chart-body').hide(); $('#chart-legend').hide(); $('#chart').show(0, function () { $('#thegrid-body').show(0, function() { Dashboard.DrawGrid(function() { mainTabSizer(); }, function() { $("#chart").slideUp(200, function(){ mainTabSizer(); }); }); }); }); } else if ($('#chart .bar').hasClass('active')) { $('#thegrid-body').hide(); $('#chart-body').show(); $('#chart-legend').show(); Dashboard.DrawBarChart(function() { $("#chart").slideDown(200, function(){ mainTabSizer(); }); }, function() { $("#chart").slideUp(200, function(){ mainTabSizer(); }); }); } } $("#addTabButton").click(function(e) { // the callback function sent in Dashboard.Add will no longer be called. // ideally this would just be removed. saveTabData();/* if (!dirtyTabConfirmation()) { return false; }*/ Dashboard.AddTab(function() { mainTabSizer(); displayTabScroller(); $distance_counter = 0; $distance_counter_val = []; //$("#main-tab-scrollwrap").width($scrollWrapWidth); $count = $("#main-tabs ul li").length; $i = 0; while($i<($count-1)){ $("#main-tabs ul li").eq($distance_counter).hide(); $obj = $("#main-tabs ul li").eq($distance_counter); $distance_counter++; $distance_counter_val[$distance_counter] = $obj; $i++; } $('#main_save').removeClass('form_submit_button').addClass('button'); $('#main_cancel').removeClass('form_submit_button').addClass('button'); }); }); $(document).on('click', '#main-tabs ul li img', function() { if (Dashboard.EditMode) { var id = $(this).closest('li').data('tab-id'); Dashboard.DeleteTab(id, function(wasLast) { if (wasLast) { $('#main-tabs ul li:last').addClass("last"); } mainTabSizer(); displayTabScroller(); }); } }); if($("#data-table").length > 0){ oTable = $('#data-table table').dataTable( { "sScrollY": "305px", "bPaginate": false, "sDom": '<"top">rt<"bottom"lp><"clear">', "bAutoWidth": false, bSort: false } ); $(window).bind('resize', function () { resizeTable(); } ); resizeTable(); } if($(".date-input").length > 0){ $(".date-input").datepicker({ changeYear: true, changeMonth: true }); } $(window).bind('resize', function () { waitForFinalEvent(function(){ displayTabScroller(); }, 200, "displaytabscroller"); }); //$(".select-input").selectBox(); $(window).bind('resize', function(){ mainTabSizer(); subTabSizer(); }); // LIVE ON CLICKS $(document).on("click", "#main-tabs ul li.tab div a", tabClick); $(document).on("click", "#data-table .checkbox .box", function(e) { toggleSelectIndicatorCheckbox($(this)); if ($(this).hasClass("selected")){ Dashboard.addDomSelectedIndicator($(this).closest('tr').data('id')); Dashboard.removeDomRemoveSelectedIndicator($(this).closest('tr').data('id')); } else { Dashboard.removeDomSelectedIndicator($(this).closest('tr').data('id')); Dashboard.addDomRemoveSelectedIndicator($(this).closest('tr').data('id')); } }); $(document).on("click", "#data-table #checkboxheader .box", function(e) { var is_checked = false; if($(this).hasClass("selected")){ $(this).removeClass("selected") } else { $(this).addClass("selected"); is_checked = true; } $("#data-table .checkbox .box").each(function(key, value){ if(is_checked == true){ if(!$(value).hasClass("selected")) $(value).trigger('click'); } else { if($(value).hasClass("selected")) $(value).trigger('click'); } }); }); $(document).on("keyup", "#main-tabs ul li div", function() { Dashboard.DirtyTab = $(this).html() != $(this).data('value'); }); $(document).mousemove(function(e) { window.mouseX = e.pageX; window.mouseY = e.pageY; }); var lastPopup; var popupCancelled; /* $(document).on('mousemove', '#data-table table tbody tr', function(e){ //make sure this is really on mouse move (bug in chrome fix) if(lastMouseX == e.pageX && lastMouseY == e.pageY){ return; } else{ lastMouseX = e.pageX; lastMouseY = e.pageY; } popupCancelled = false; var row = this; if(Dashboard.EditMode == true){ return; } if (lastPopup == row) { movePopupDetail(); return; } if (timer != null){ return; } if ($(this).find('td').hasClass('dataTables_empty')){ return; } else { if(mouseVelocity > 1000){ $timerRate = 750; } else { $timerRate = (mouseVelocity / 1000) * 750; } timer = setTimeout(function() { lastPopup = row; var detail = $(row).attr('data-detail'); if (!detail || popupCancelled) return; showPopup(row, $.parseJSON(detail)); }, $timerRate); } }); $(document).on('mouseleave', '#data-table table tbody tr', function() { popupCancelled = true; clearTimeout(timer); timer = null; closePopup(); lastPopup = null; }); $(document).on('mousemove', '#popup-detail', function() { //$("#popup-detail").offset({ // left:window.mouseX + 15, // top: window.mouseY - 156 //}); $(this).stop().animate({ opacity: 1.0 }); movePopupDetail(); }); $(document).on('mouseleave', '#popup-detail', function() { popupCancelled = true; clearTimeout(timer); timer = null; closePopup(); lastPopup = null; }); */ $(document).on('click', '#data-table table.dataTable tbody tr', function(e){ if (Dashboard.EditMode) return false; $(this).toggleClass("active"); //e.stopPropagation(); var name = $(this).find('.name').text(); if($(this).hasClass('active')){ Dashboard.addDomIndicator($(this).data('id'), name, $(this).data('period')); }else{ Dashboard.removeDomIndicator($(this).data('id')); } UpdateDataArea(); //return false; }); $(document).on('click', '.image_one, span#time_one', function(e){ var id = $(".image_one").attr("data-id"); var period = $(".image_one").attr("data-period"); var name = $(".image_one").attr("data-name"); Dashboard.addDomIndicatorPop(id, name, period); $("#goedland").css("display","none"); $("#popup_emp").css("display","none"); $("#popup_spend").css("display","none"); $("#popup_population").css("display","block"); UpdateDataAreaPop(); }); $(document).on('click', '.image_one2, #time_one2', function(e){ var id = $(".image_one2").attr("data-id"); var period = $(".image_one2").attr("data-period"); var name = $(".image_one2").attr("data-name"); //alert(name); Dashboard.addDomIndicatorEmp(id, name, period); $("#goedland").css("display","none"); $("#popup_population").css("display","none"); $("#popup_spend").css("display","none"); $("#popup_emp").css("display","block"); UpdateDataAreaEmp(); }); $(document).on('click', '.image_one12, #time_one12', function(e){ var id = $(".image_one12").attr("data-id"); var period = $(".image_one12").attr("data-period"); var name = $(".image_one12").attr("data-name"); //alert(name); Dashboard.addDomIndicatorSpend(id, name, period); $("#goedland").css("display","none"); $("#popup_population").css("display","none"); $("#popup_emp").css("display","none"); $("#popup_spend").css("display","block"); UpdateDataAreaSpend(); }); $(document).on('click', '.close-pop', function(e){ $("#goedland").css("display","block"); $("#popup_population").css("display","none"); $("#popup_emp").css("display","none"); $("#popup_spend").css("display","none"); }); $(document).on('click', '#chkMultiaxis', function(e){ if (Dashboard.EditMode) return false; UpdateDataArea(); //return false; }); $(document).on('click', '#data-table div.ez-checkbox', function(event){ event.preventDefault(); event.stopPropagation(); row_obj = $(this).parents('tr'); var $indi_id = $(row_obj).data('id'); var $content = "Quick Chart"; if($('#_graph_holder #_indicator_graph_'+$indi_id).length > 0){ $content += "Remove From Full Chart"; $('div.full_chart').attr('title','Remove From Full Chart'); } else { $content += "Add to Full Chart"; $('div.full_chart').attr('title','Add to Full Chart'); } $content +="Create Reports"; //$content +="Indicator ExportTab ExportDashboard ExportIndicator Info"; $content +="Export Data"; /*if(Dashboard.checkbox_follow_indicators[$indi_id] == undefined || Dashboard.checkbox_follow_indicators[$indi_id] == false) { $content +="Set Email"; $('div.set_email').attr('title','Set Email Notification'); } else { $content +="Remove Email"; $('div.set_email').attr('title','Remove Email Notification'); }*/ if(Dashboard.checkbox_msg_indicators[$indi_id] == undefined || Dashboard.checkbox_msg_indicators[$indi_id] == false) { //$content +="Set Text"; //$('div.set_msg').attr('title','Set Text Notification'); } else { $content +="Remove Text"; $('div.set_msg').attr('title','Remove Text Notification'); } $('.popover').remove(); $(this).popover({ content: $content, stopChildrenPropagation:false }); $(this).popover('show'); }); $(document).on('click', 'span.full_chart', function(event){ if (Dashboard.EditMode) return false; if (row_obj == null ) return false; $(row_obj).toggleClass("active"); //e.stopPropagation(); var name = $(row_obj).find('.name').text(); if($(row_obj).hasClass('active')){ Dashboard.addDomIndicator($(row_obj).data('id'), name, $(row_obj).data('period')); }else{ Dashboard.removeDomIndicator($(row_obj).data('id')); } UpdateDataArea(); }); $(document).on('click', 'div.full_chart', function(event){ if (Dashboard.EditMode) return false; if (row_obj == null ) return false; $(row_obj).toggleClass("active"); //e.stopPropagation(); var name = $(row_obj).find('.name').text(); if($(row_obj).hasClass('active')){ Dashboard.addDomIndicator($(row_obj).data('id'), name, $(row_obj).data('period')); }else{ Dashboard.removeDomIndicator($(row_obj).data('id')); } UpdateDataArea(); $.facebox.close() }); $(document).on('click', 'span.quick_chart', function(event){ if (Dashboard.EditMode) return false; if (row_obj == null ) return false; mainloading(true); var id = $(row_obj).data('id'); var detail = ''; //var detail = $(row_obj).attr('data-detail'); var graph_datatype = $(row_obj).attr('data-type'); var graph_decimals = $(row_obj).attr('data-decimals'); //if (!detail) return; //showPopup(row_obj, $.parseJSON(detail)); $.ajax({ url: PageSettings.BaseUrl + "manage/indicators/get", data: { id: id, graph:1 }, type: 'GET', //dataType: 'json', success: function(data) { if (data.success) { if(data.indicator.Name!='') $('#indi-info-alias').html(data.indicator.Name); if(data.indicator.Source!='') $('#indi-info-source').html(data.indicator.Source); if(data.indicator.SourceURL!='') $('#indi-info-slocation').html(data.indicator.SourceURL); else $('#indi-info-slocation').html("Internal Data Set"); if(data.indicator.variable_description_definition!='') $('#indi-info-variable').html(data.indicator.variable_description_definition); else $('#indi-info-variable').html("Information is currently pending as Applied Analysis works to update its base data."); if(data.indicator.IsAdjustment == 0) $('#indi-info-seasonally').html("Not Seasonally Adjusted"); else $('#indi-info-seasonally').html("Seasonally Adjusted"); if(data.indicator.GeographicAlias!='') $('#indi-info-glocation').html(data.indicator.GeographicAlias); if(data.indicator.Period1 !='') { var period = ' '; switch (parseInt(data.indicator.Period1)) { case 1: // Quarterly period = 'Weekly'; break; case 2: // Quarterly period = 'Bi-weekly'; break; case 5: // Quarterly period = 'Quarterly'; break; case 7: // Yearly period = 'Yearly'; break; case 3: // Monthly period = 'Monthly'; break; case 4: // Bi Monthly period = 'Bi Monthly'; break; case 6 : // Semi Anually period = 'Semi Anually'; break; case 8 : // Semi Anually period = 'Daily'; break; default: period = ' '; } $('#indi-info-period').html(period); } var mydate = new Date(data.indicator.last_updated); var monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; var formattedDate = monthNames[mydate.getMonth()] +' '+ mydate.getDate() +', ' + mydate.getFullYear(); $('#indi-info-lupdate').html(formattedDate); var mydate = new Date(data.indicator.NextUpdate); var formattedDate = monthNames[mydate.getMonth()] +' '+ mydate.getDate() +', ' + mydate.getFullYear(); $('#indi-info-nupdate').html(formattedDate); $('#indi-info-category').html(data.indicator.Categories_list_name.join('
')); $('div.hide-info').hide(); $.facebox({ div:'#popup-detail', loadingImage : 'assets/img/loading.gif', closeImage : 'assets/img/closelabel.png' }); detail = data.detail; //alert(detail); //alert(data.getJSONObject(2).getString("detail")); showPopup(row_obj, $.parseJSON(detail)); var graph_html = ''; var detail_json = $.parseJSON(detail) $('#facebox div.top-graph').html(graph_html); var graph = new GraphSummary('popup-graph'); graph.DrawGraph(detail_json.simple,graph_datatype,graph_decimals); } else { jAlert(data.error); } mainloading(false); }, error: function() { jAlert('Indicator could not be loaded'); } }); }); var mainloading = function(show) { $("#data-table").css({ opacity: show ? .5 : 1 }); $("#loading").toggle(show); } $(document).on('click', 'span.indi-info', function(event){ var id = $(row_obj).data('id'); $.ajax({ url: PageSettings.BaseUrl + "manage/indicators/get", data: { id: id }, type: 'GET', dataType: 'json', success: function(data) { if (data.success) { if(data.indicator.Name!='') $('#indi-info-alias').html(data.indicator.Name); if(data.indicator.Source!='') $('#indi-info-source').html(data.indicator.Source); if(data.indicator.SourceURL!='') $('#indi-info-slocation').html(data.indicator.SourceURL); else $('#indi-info-slocation').html("Internal Data Set"); if(data.indicator.variable_description_definition!='') $('#indi-info-variable').html(data.indicator.variable_description_definition); else $('#indi-info-variable').html("Information is currently pending as Applied Analysis works to update its base data."); if(data.indicator.IsAdjustment == 0) $('#indi-info-seasonally').html("Not Seasonally Adjusted"); else $('#indi-info-seasonally').html("Seasonally Adjusted"); if(data.indicator.GeographicAlias!='') $('#indi-info-glocation').html(data.indicator.GeographicAlias); if(data.indicator.Period1 !='') { var period = ' '; switch (parseInt(data.indicator.Period1)) { case 1: // Quarterly period = 'Weekly'; break; case 2: // Quarterly period = 'Bi-weekly'; break; case 5: // Quarterly period = 'Quarterly'; break; case 7: // Yearly period = 'Yearly'; break; case 3: // Monthly period = 'Monthly'; break; case 4: // Bi Monthly period = 'Bi Monthly'; break; case 6 : // Semi Anually period = 'Semi Anually'; break; case 8 : // Semi Anually period = 'Daily'; break; default: period = ' '; } $('#indi-info-period').html(period); } var mydate = new Date(data.indicator.last_updated); var monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; var formattedDate = monthNames[mydate.getMonth()] +' '+ mydate.getDate() +' , ' + mydate.getFullYear(); $('#indi-info-lupdate').html(formattedDate); var mydate = new Date(data.indicator.NextUpdate); var formattedDate = monthNames[mydate.getMonth()] +' '+ mydate.getDate() +' , ' + mydate.getFullYear(); $('#indi-info-nupdate').html(formattedDate); $('#indi-info-category').html(data.indicator.Categories_list_name.join('
')); $('div.hide-info').show(); $.facebox({ div:'#hide-indi-info', loadingImage : 'assets/img/loading.gif', closeImage : 'assets/img/closelabel.png' }); } else { jAlert(data.error); } }, error: function() { jAlert('Indicator could not be loaded'); } }); }); $(document).on('click', '#data-export-selindicator', function(event){ $('#allindicatorIds').val(0); Dashboard.HideOverlay(); $('#popup-export-data').fadeOut(200, function() { $(this).offset({ left:-9999, top: -9999 }); }); $('div#popup_summary_export').css('display','none'); $('div#popup_quick_export').css('display','block'); $('div#popup_tab_export').css('display','none'); var popupWidth = $('#popup-export').width(); var popupHeight = $('#popup-export').height(); var wndWidth = $(window).width(); var wndHeight = $(window).height(); Dashboard.ShowOverlay(); $("#popup-export").css("position", "fixed"); $("#popup-export").css("top", "50%"); $("#popup-export").css("left", "50%"); $("#popup-export").css("margin-left", (-1)*(popupWidth / 4)); $("#popup-export").css("margin-top", (-1)*(popupHeight / 2)); $('#popup-export').fadeIn(200, function() { }); $(document).on('click', '#export-csv', exportCsvHandler); Dashboard.single_export = true; Dashboard.single_row_obj = row_obj; }); $(document).on('click', '#data-export-allindicator', function(event){ $('#allindicatorIds').val(0); Dashboard.HideOverlay(); $('#popup-export-data').fadeOut(200, function() { $(this).offset({ left:-9999, top: -9999 }); }); $('div#popup_summary_export').css('display','none'); $('div#popup_quick_export').css('display','none'); $('div#popup_tab_export').css('display','block'); var popupWidth = $('#popup-export').width(); var popupHeight = $('#popup-export').height(); var wndWidth = $(window).width(); var wndHeight = $(window).height(); Dashboard.ShowOverlay(); $("#popup-export").css("position", "fixed"); $("#popup-export").css("top", "50%"); $("#popup-export").css("left", "50%"); $("#popup-export").css("margin-left", (-1)*(popupWidth / 4)); $("#popup-export").css("margin-top", (-1)*(popupHeight / 2)); $('#popup-export').fadeIn(200, function() { }); var selectedIndicatorsType = $('#data-table tbody tr').map(function() { return $(this).data('period'); }).get(); var flag = false; outer_loop: for(var i=0;i<(selectedIndicatorsType.length);i++) { var val1 = selectedIndicatorsType[i]; for(var j=0;j<(selectedIndicatorsType.length);j++) { inner_loop: if(val1!=selectedIndicatorsType[j]) { flag = true; break outer_loop; break inner_loop; } } } if(flag == true){ $('#tab-export-csv').css('opacity', .5); $(document).off('click', '#tab-export-csv', exportCsvHandler1); $(document).on('click', '#tab-export-csv', blockExportCsvHandler); }else{ $('#tab-export-csv').css('opacity', 1); $(document).off('click', '#tab-export-csv', blockExportCsvHandler); $(document).on('click', '#tab-export-csv', exportCsvHandler1); Dashboard.all_indicators = true; Dashboard.single_row_obj = row_obj; } }); $(document).on('click', 'span.data_export', function(event){ $('div#popup_data_export').css('display','block'); var popupWidth = $('#popup-export-data').width(); var popupHeight = $('#popup-export-data').height(); var wndWidth = $(window).width(); var wndHeight = $(window).height(); Dashboard.ShowOverlay(); $("#popup-export-data").css("position", "fixed"); $("#popup-export-data").css("top", "50%"); $("#popup-export-data").css("left", "50%"); $("#popup-export-data").css("margin-left", (-1)*(popupWidth / 4)); $("#popup-export-data").css("margin-top", (-1)*(popupHeight / 2)); $('#popup-export-data').fadeIn(200, function() { }); }); $(document).on('click', 'span.data_report', function(event){ $('div#popup_data_report').css('display','block'); var popupWidth = $('#popup-report-data').width(); var popupHeight = $('#popup-report-data').height(); var wndWidth = $(window).width(); var wndHeight = $(window).height(); Dashboard.ShowOverlay(); $("#popup-report-data").css("position", "fixed"); $("#popup-report-data").css("top", "50%"); $("#popup-report-data").css("left", "50%"); $("#popup-report-data").css("margin-left", (-1)*(popupWidth / 2)); $("#popup-report-data").css("margin-top", (-1)*(popupHeight / 2)); $('#popup-report-data').fadeIn(200, function() { }); }); $(document).on('click', '#data-export-dashindicator', function(event){ Dashboard.HideOverlay(); $('#popup-export-data').fadeOut(200, function() { $(this).offset({ left:-9999, top: -9999 }); }); $('div#popup_summary_export').css('display','none'); $('div#popup_quick_export').css('display','none'); $('div#popup_tab_export').css('display','none'); $('div#popup_dashboard_export').css('display','block'); var popupWidth = $('#popup-export').width(); var popupHeight = $('#popup-export').height(); var wndWidth = $(window).width(); var wndHeight = $(window).height(); Dashboard.ShowOverlay(); $("#popup-export").css("position", "fixed"); $("#popup-export").css("top", "50%"); $("#popup-export").css("left", "50%"); $("#popup-export").css("margin-left", (-1)*(popupWidth / 3)); $("#popup-export").css("margin-top", (-1)*(popupHeight / 2)); $('#popup-export').fadeIn(200, function() { }); var selectedIndicatorsType = $('#indicatorperiod').val(); selectedIndicatorsType = selectedIndicatorsType.split(','); //alert(selectedIndicatorsType); var flag = false; outer_loop: for(var i=0;i<(selectedIndicatorsType.length);i++) { var val1 = selectedIndicatorsType[i]; for(var j=0;j<(selectedIndicatorsType.length);j++) { inner_loop: if(val1!=selectedIndicatorsType[j]) { flag = true; break outer_loop; break inner_loop; } } } if(flag == true){ $('#dashboard-export-csv').css('opacity', .5); $(document).off('click', '#dashboard-export-csv', exportCsvHandler1); $(document).on('click', '#dashboard-export-csv', blockExportCsvHandler); }else{ $('#dashboard-export-csv').css('opacity', 1); $(document).off('click', '#dashboard-export-csv', blockExportCsvHandler); $(document).on('click', '#dashboard-export-csv', exportCsvHandler1); Dashboard.dashboard_indicators = true; Dashboard.single_row_obj = row_obj; } }); $(document).on('click', 'div.quick_export', function(event){ $('div#popup_summary_export').css('display','none'); $('div#popup_quick_export').css('display','block'); $('div#popup_tab_export').css('display','none'); var popupWidth = $('#popup-export').width(); var popupHeight = $('#popup-export').height(); var wndWidth = $(window).width(); var wndHeight = $(window).height(); Dashboard.ShowOverlay(); $("#popup-export").css("position", "fixed"); $("#popup-export").css("top", "50%"); $("#popup-export").css("left", "50%"); $("#popup-export").css("margin-left", (-1)*(popupWidth / 3)); $("#popup-export").css("margin-top", (-1)*(popupHeight / 2)); $('#popup-export').fadeIn(200, function() { }); $(document).on('click', '#export-csv', exportCsvHandler); Dashboard.single_export = true; Dashboard.single_row_obj = row_obj; }); $(document).on('click', 'div.summary_export', function() { $('div#popup_quick_export').css('display','none'); $('div#popup_summary_export').css('display','block'); $('div#popup_tab_export').css('display','none'); var popupWidth = $('#popup-export').width(); var popupHeight = $('#popup-export').height(); var wndWidth = $(window).width(); var wndHeight = $(window).height(); Dashboard.ShowOverlay(); $("#popup-export").css("position", "fixed"); $("#popup-export").css("top", "50%"); $("#popup-export").css("left", "50%"); $("#popup-export").css("margin-left", (-1)*(popupWidth / 4)); $("#popup-export").css("margin-top", (-1)*(popupHeight / 2)); $('#popup-export').fadeIn(200, function() { }); $(document).on('click', '#summary-export-excel', exportCsvHandler); $(document).on('click', '#summary-export-pdf', exportCsvHandler); }); $(document).on('click', 'div.indi_info', function() { $('div.hide-info').slideToggle('slow'); }); $(document).on('click','span.set_email,div.set_email',function(e){ e.stopPropagation(); $iid = $(row_obj).data('id'); var $is_checked = false; if(Dashboard.checkbox_follow_indicators[$iid] == undefined || Dashboard.checkbox_follow_indicators[$iid] == false) { $is_checked = true; } $.ajax({ url: PageSettings.BaseUrl + "dashboard/follow_indicator/"+$iid, cache: false, data: { id: $iid, checked: $is_checked }, dataType: 'json', type: 'POST', success: function(data, xhr, textStatus) { if($is_checked == true) { $('div.set_email').attr('title','Remove Email Notification'); } else { $('div.set_email').attr('title','Set Email Notification'); } }, error: function(){ jAlert(data.error); } }); Dashboard.checkbox_follow_indicators[$iid] = $is_checked; }); $(document).on('click','span.set_msg,div.set_msg',function(e){ e.stopPropagation(); $iid = $(row_obj).data('id'); var $is_checked = false; if(Dashboard.checkbox_msg_indicators[$iid] == undefined || Dashboard.checkbox_msg_indicators[$iid] == false) { $is_checked = true; } $.ajax({ url: PageSettings.BaseUrl + "dashboard/msg_indicator/"+$iid, cache: false, data: { id: $iid, checked: $is_checked }, dataType: 'json', type: 'POST', success: function(data, xhr, textStatus) { if($is_checked == true) { //$('div.set_msg').attr('title','Remove Text Notification'); } else { //$('div.set_msg').attr('title','Set Text Notification'); } }, error: function(){ jAlert(data.error); } }); Dashboard.checkbox_msg_indicators[$iid] = $is_checked; }); $(document).on('click', '#chart .icon-delete', function() { $('#data-table table.dataTable tbody tr.active').each(function(){ $(this).toggleClass("active"); Dashboard.removeDomIndicator($(this).data('id')); }); UpdateDataArea(); }); $(document).on('click', '#chart .export', function() { Dashboard.single_export = false; Dashboard.single_row_obj = null; Dashboard.xls_format = false; $('div#popup_summary_export').css('display','none'); $('div#popup_quick_export').css('display','block'); $('div#popup_tab_export').css('display','none'); var popupWidth = $('#popup-export').width(); var popupHeight = $('#popup-export').height(); var wndWidth = $(window).width(); var wndHeight = $(window).height(); Dashboard.ShowOverlay(); $("#popup-export").css("background", "none repeat scroll 0 0 #444444"); $("#popup-export").css("border-radius", " 0 0 0 0"); $("#popup-export").css("height", "228px"); $("#popup-export").css("left", "0px"); $("#popup-export").css("margin-top", "0"); $("#popup-export").css("opacity", "0.73"); $("#popup-export").css("padding", "296px"); $("#popup-export").css("position", "fixed"); $("#popup-export").css("top", "0"); $("#popup-export").css("width", "376px"); $('#popup-export').fadeIn(200, function() { }); // If there is more than 1 indicator period type selected then disable the csv export var types = []; $('._hidden_graph_holder').each(function(i){ var val = 'period' + $(this).data('period').toString(); if (jQuery.inArray(val, types) == -1){ types.push(val); } }); if(types.length > 1){ $('#export-csv').css('opacity', .5); $(document).off('click', '#export-csv', exportCsvHandler); $(document).on('click', '#export-csv', blockExportCsvHandler); }else{ $('#export-csv').css('opacity', 1); $(document).off('click', '#export-csv', blockExportCsvHandler); $(document).on('click', '#export-csv', exportCsvHandler1); } }); var blockExportCsvHandler = function(e){ jAlert('You have selected data with multiple periodicities. CSV exports require that all of the data be consistent in terms of reporting periods. Please either select another export option or reselect variable with similar reporting intervals.'); e.preventDefault(); } var exportCsvHandler = function(){ Dashboard.Export('csv'); } var exportCsvHandler1 = function(){ Dashboard.all_indicators = true; Dashboard.single_row_obj = row_obj; Dashboard.Export('csv'); } $(document).on('click', '#export-excel', function() { Dashboard.Export('xls'); }); $(document).on('click', '#summary-export-excel', function() { Dashboard.single_export = true; Dashboard.single_row_obj = row_obj; Dashboard.xls_format = 1; Dashboard.Export('xls'); }); $(document).on('click', '#summary-export-pdf', function() { Dashboard.single_export = true; Dashboard.single_row_obj = row_obj; Dashboard.Export('pdf'); }); $(document).on('click', '#tab-export-excel', function() { Dashboard.all_indicators = true; Dashboard.single_row_obj = row_obj; Dashboard.Export('xls'); }); $(document).on('click', '#dashboard-export-excel', function() { Dashboard.dashboard_indicators = true; Dashboard.single_row_obj = row_obj; Dashboard.Export('xls'); }); /*$(document).on('click', '#dashboard-export-csv', function() { Dashboard.dashboard_indicators = true; Dashboard.single_row_obj = row_obj; Dashboard.Export('csv'); });*/ $(document).on('click', '#export-png', function() { Dashboard.Export('png'); }); $(document).on('click', '#popup-export .icon-close', function() { closeExportPopup(); }); $(document).on('click', '#popup-export-data .icon-close', function() { closeExportdataPopup(); }); $(document).on('click', '#popup-report-data .icon-close', function() { closeReportdataPopup(); }); $(document).on('click', '.icon-refresh', viewDashboard); $(document).on('click', '#chart .icon-left', function() { var isActive = $(this).hasClass('active'); if (isActive) return; $(this).siblings('.icon-left').removeClass('active'); $(this).addClass('active'); UpdateDataArea(); }); $('.notification').click(function() { var me = this; $(me).fadeOut(200); $.ajax({ url: PageSettings.BaseUrl + "dashboard/ReadUserMessage", data: { id: $(this).data('id') }, type: 'POST', dataType: 'json', success: function() { $(me).remove(); $('#notifications-widget .notification').each(function(index) { $(me).removeClass('even').removeClass('odd').addClass(index % 2 == 0 ? 'even' : 'odd'); }); $('#notifications-widget .count').text('(' + ($('#notifications-widget .notification').length) + ')'); }, error: function() { $(me).fadeIn(100); } }); }); $("#isia").click(function() { $.ajax({ url: PageSettings.BaseUrl + "account/changeia", data: { enabled: $(this).is(":checked") }, dataType: 'json', type: 'POST', success: function() { viewDashboard(); UpdateDataArea(); } }) }); $('#collapseUp').click(function() { dashboard_collapsed = !dashboard_collapsed; if (dashboard_collapsed) { $('#user-widgets').animate({ height: '40px' }, { queue: false, duration : 200 }); } else { $('#user-widgets').animate({ height: '141px' }, { queue: false, duration : 200 }); } $(this).toggleClass("up").toggleClass("down"); }); $('#tab-name-inputdiv').live('focus', function() { before = $(this).html(); }).live('blur keyup paste', function() { if (before != $(this).html()) { $(this).trigger('change'); } }); $('#tab-name-inputdiv').live('change', function() { //alert($('#tab-name-inputdiv').text().length) if($('#tab-name-inputdiv').text().length > 120) { jAlert('Dashboard tab labels are limited to 125 characters. Please revise the label and press save to continue.'); $('#tab-name-inputdiv').text($(this).text().substr(0, 120)); $('#tab-name-inputdiv').blur(); return; } $("#tab-name").data("value", $('#tab-name-inputdiv').text()); }); Categories.Init(function(){ //$("#sub-tabs ul li").removeClass("active"); //$(this).parent().addClass("active"); viewDashboard(); //var id = Categories.SelectedCategory(); //$('#checkboxes .checkbox .box').removeClass('selected'); //$('#checkboxes .checkbox').slideUp(200); //$("#checkboxes .checkbox[data-parent='" + id + "']").slideDown(200); }, function() { //viewDashboard(); }); Categories.SetThat(Dashboard); $("#main-tab-left-arrow").bind("mousedown", tabScrollLeft); $("#main-tab-left-arrow").bind("mouseup", function() { clearInterval(isMouseDown); isMouseDown = false; }); $("#main-tab-left-arrow").bind("mouseleave", function() { clearInterval(isMouseDown); isMouseDown = false; }); function tabScrollLeft(){ if($distance_counter_val[$distance_counter] != undefined ) { $($distance_counter_val[$distance_counter]).show(); $distance_counter--; //$newScrollLeft = parseInt($("#main-tab-scrollwrap ul").css('left')) + $distance_counter_val[$distance_counter]; //$("#main-tab-scrollwrap ul").css('left',$newScrollLeft); } else { return false; } /* if (!isMouseDown) { isMouseDown = setInterval(tabScrollLeft, 200); } */ } $("#main-tab-right-arrow").bind("mousedown", tabScrollRight); $("#main-tab-right-arrow").bind("mouseup", function() { clearInterval(isMouseDown); isMouseDown = false; }); $("#main-tab-right-arrow").bind("mouseleave", function() { clearInterval(isMouseDown); isMouseDown = false; }); function tabScrollRight(){ if($("#main-tabs ul li").eq($distance_counter).length > 0 && $distance_counter!=($("#main-tabs ul li").length-1)) { //$distance = $("#main-tabs ul li").eq($distance_counter).width(); $("#main-tabs ul li").eq($distance_counter).hide(); $obj = $("#main-tabs ul li").eq($distance_counter); $distance_counter++; $distance_counter_val[$distance_counter] = $obj; } else { return false; } //$newScrollLeft = parseInt($("#main-tab-scrollwrap ul").css('left')) - $distance; //$distance_counter_val[$distance_counter] = $distance; //$("#main-tab-scrollwrap ul").css('left',$newScrollLeft); /* if (!isMouseDown) { isMouseDown = setInterval(tabScrollRight, 200); }*/ } $('.checkbox').live('click',function(){ $('#main_save').removeClass('button').addClass('form_submit_button'); $('#main_cancel').removeClass('button').addClass('form_submit_button'); }); $('#main-tab-icons .icon-save,#main_save').click(function() { if (Dashboard.EditMode) { Dashboard.resetSearchParams(); Dashboard.SaveTab(function() { //jAlert('Tab Saved'); $('#main-tab-icons .icon-setting').hide(); name = $('#main-tabs ul li.active div#tab-name-inputdiv').html(); name = name.replace(/(\r\n|\n|\r)/gm, ''); name = name.replace(/<(?:.|\n)*?>/gm, ''); $('#main-tabs ul li.active input').data('value', name); Dashboard.DirtyTab = false; cancelEditMode(); }, function() { jAlert('Unable to save tab!'); }); } else { Dashboard.CopyTabs(function() { jAlert('Tabs have been copied to your dashboard.'); $("#main-tab-icons .icon-back").trigger('click'); //window.location.reload() }); } }); $('div#facebox #edit-adjust-order1').live('click',function() { if (Dashboard.EditMode) { $("#indicator_sort #indicator_list").empty(); $("#indicator_sort #sorted_indicator_list").empty(); $("div#facebox #indicator_list option").appendTo("#indicator_sort #indicator_list"); $("div#facebox #sorted_indicator_list option").appendTo("#indicator_sort #sorted_indicator_list"); $.facebox.close(); Dashboard.resetSearchParams(); Dashboard.ReorderIndicator(function() { //jAlert('Tab Saved'); $('#main-tab-icons .icon-setting').hide(); name = $('#main-tabs ul li.active div#tab-name-inputdiv').html(); name = name.replace(/(\r\n|\n|\r)/gm, ''); name = name.replace(/<(?:.|\n)*?>/gm, ''); $('#main-tabs ul li.active input').data('value', name); Dashboard.DirtyTab = false; cancelEditMode(); }, function() { jAlert('Unable to save tab!'); }); } }); $('div#facebox #edit-adjust-order').live('click',function() { if (Dashboard.EditMode) { $("#indicator_sort #indicator_list").empty(); $("#indicator_sort #sorted_indicator_list").empty(); $("div#facebox #indicator_list option").appendTo("#indicator_sort #indicator_list"); $("div#facebox #sorted_indicator_list option").appendTo("#indicator_sort #sorted_indicator_list"); $.facebox.close(); Dashboard.ReorderIndicatorManager(function() { $.facebox({ div: '#search_select_option' }); }, function() { jAlert('Unable to save tab!'); }); } }); $('div#facebox #edit-tab-order1').live('click',function() { if (Dashboard.EditMode) { $('#tab_sort #tab_list').empty(); $("div#facebox #tab_list option").appendTo("#tab_sort #tab_list"); $.facebox.close(); Dashboard.resetSearchParams(); Dashboard.ReorderTab(function() { //jAlert('Tab Saved'); $('#main-tab-icons .icon-setting').hide(); name = $('#main-tabs ul li.active div#tab-name-inputdiv').html(); name = name.replace(/(\r\n|\n|\r)/gm, ''); name = name.replace(/<(?:.|\n)*?>/gm, ''); $('#main-tabs ul li.active input').data('value', name); Dashboard.DirtyTab = false; cancelEditMode(); }, function() { jAlert('Unable to save tab!'); }); } }); $('div#facebox #edit-tab-order').live('click',function() { if (Dashboard.EditMode) { $('#tab_sort #tab_list').empty(); $("div#facebox #tab_list option").appendTo("#tab_sort #tab_list"); $.facebox.close(); Dashboard.ReorderTabManager(function() { $.facebox({ div: '#search_select_option' }); }, function() { jAlert('Unable to save tab!'); }); } }); $('div#facebox #addremove_indicator').live('click',function(){ $("#filter-checkboxes").slideDown(200, function(){ }); $(".dataTables_scrollBody").animate({ height: '600px' }, 200, function() { mainTabSizer(); }); resizeTable(); $.facebox.close(); $('#main_save').removeClass('form_submit_button').addClass('button'); $('#main_cancel').removeClass('form_submit_button').addClass('button'); }); $('.icon-refresh_new').click(function(event){ viewDashboardFirst(); }); $('#filter-checkbox1').click(function(){ $('#filter-checkbox2').toggle('slow'); $('#filter-checkbox3').toggle('slow'); $('#filter-checkbox4').toggle('slow'); $('#search_date_wrapper').hide(); $('#search_geography_wrapper').hide(); $('#search_category_wrapper').hide(); $('#apply_search1').hide(); $('#apply_search2').hide(); $('#apply_search3').hide(); if($(this).children('h2').hasClass('h2_apply_search')) { $(this).children('h2').removeClass('h2_apply_search').addClass('h2_apply_search_open'); $(this).children('h2').children('span').html('-'); } else { $(this).children('h2').removeClass('h2_apply_search_open').addClass('h2_apply_search'); $(this).children('h2').children('span').html('+'); } }); $('#filter-checkbox2').click(function(){ $('#search_date_wrapper').hide(); $('#search_geography_wrapper').hide(); $('#apply_search2').hide(); $('#apply_search3').hide(); if($(this).children('h2').hasClass('h2_apply_search')) { $(this).children('h2').removeClass('h2_apply_search').addClass('h2_apply_search_open'); $(this).children('h2').children('span').html('-'); } else { $(this).children('h2').removeClass('h2_apply_search_open').addClass('h2_apply_search'); $(this).children('h2').children('span').html('+'); } $('#filter-checkbox3').children('h2').removeClass('h2_apply_search_open').addClass('h2_apply_search'); $('#filter-checkbox3').children('h2').children('span').html('+'); $('#filter-checkbox4').children('h2').removeClass('h2_apply_search_open').addClass('h2_apply_search'); $('#filter-checkbox4').children('h2').children('span').html('+'); $('#search_category_wrapper').toggle(); $('#apply_search1').toggle(); if(Dashboard.cl == null){ Dashboard.cl = jQuery.fn.jColumnListView({ id: 'cl1', width: 800, columnWidth: 200, columnHeight: 200, columnMargin: 10, paramName: 'columnview', columnNum: 10, appendToId: 't1', elementId: 'categories-list', columnMinWidth: 200, columnMaxWidth: 500, childIndicator: true, leafMode: false, onItemChecked: function (ci) { //Categories.onCategoryClick(); }, onItemUnchecked: function (ci) { //Categories.onCategoryClick(); } }); } }); $('#filter-checkbox3').click(function(){ $('#search_date_wrapper').hide(); $('#search_category_wrapper').hide(); $('#apply_search1').hide(); $('#apply_search3').hide(); $('#apply_search2').toggle(); if($(this).children('h2').hasClass('h2_apply_search')) { $(this).children('h2').removeClass('h2_apply_search').addClass('h2_apply_search_open'); $(this).children('h2').children('span').html('-'); } else { $(this).children('h2').removeClass('h2_apply_search_open').addClass('h2_apply_search'); $(this).children('h2').children('span').html('+'); } $('#filter-checkbox2').children('h2').removeClass('h2_apply_search_open').addClass('h2_apply_search'); $('#filter-checkbox2').children('h2').children('span').html('+'); $('#filter-checkbox4').children('h2').removeClass('h2_apply_search_open').addClass('h2_apply_search'); $('#filter-checkbox4').children('h2').children('span').html('+'); $('#search_geography_wrapper').toggle('slow'); if(Dashboard.c2 == null){ Dashboard.c2 = jQuery.fn.jColumnListView({ id: 'gl1', width: 800, columnWidth: 200, columnHeight: 200, columnMargin: 10, paramName: 'columnview', columnNum: 10, appendToId: 't2', elementId: 'geography-list', columnMinWidth: 200, columnMaxWidth: 500, childIndicator: true, leafMode: false, singleCheck: true, onItemChecked: function (ci) { //Categories.onCategoryClick(); }, onItemUnchecked: function (ci) { //Categories.onCategoryClick(); } }); } }); $('#filter-checkbox4').click(function(){ $('#search_geography_wrapper').hide(); $('#search_category_wrapper').hide(); if($(this).children('h2').hasClass('h2_apply_search')) { $(this).children('h2').removeClass('h2_apply_search').addClass('h2_apply_search_open'); $(this).children('h2').children('span').html('-'); } else { $(this).children('h2').removeClass('h2_apply_search_open').addClass('h2_apply_search'); $(this).children('h2').children('span').html('+'); } $('#filter-checkbox2').children('h2').removeClass('h2_apply_search_open').addClass('h2_apply_search'); $('#filter-checkbox2').children('h2').children('span').html('+'); $('#filter-checkbox3').children('h2').removeClass('h2_apply_search_open').addClass('h2_apply_search'); $('#filter-checkbox3').children('h2').children('span').html('+'); $('#search_date_wrapper').toggle(); $('#apply_search1').hide(); $('#apply_search2').hide(); $('#apply_search3').toggle(); }); $('div#facebox #reorder_indicator').live('click',function(){ $.facebox({ div: '#indicator_sort' }); $("div#facebox #indicator_list option").each(function(index, value){ if($(value).attr('is_adjustment') == 1) { var ext_html = $(value).html(); ext_html = ''+$(value).text(); $(value).html(ext_html); } }); $("div#facebox #sorted_indicator_list option").each(function(index, value){ if($(value).attr('is_adjustment') == 1) { var ext_html = $(value).html(); ext_html = ''+$(value).text(); $(value).html(ext_html); } }); }); $('div#facebox #reorder_tab').live('click',function(){ $.facebox({ div: '#tab_sort' }); }); $('div#facebox #create_tab').live('click',function(){ if(readCookie('reorder_tab') == null) { $.facebox({ div: '#create_remove_tab' }); } else { $.facebox.close(); $('#addTabButton').trigger('click'); $('#main_save').removeClass('form_submit_button').addClass('button'); $('#main_cancel').removeClass('form_submit_button').addClass('button'); } }); $('div#facebox #donot').live('click',function(){ if($(this).is(':checked')) { createCookie('reorder_tab','1','365'); } else { eraseCookie('reorder_tab') } }); //Categories.Load(function() {}); /*$.ajax({ url: PageSettings.BaseUrl + "dashboard/geographytree", cache: false, type: 'GET', datatype: 'html', success: function(data) { $("#geography").html(data); $("#geography").children("ul").attr("id","geography-list"); } });*/ $(".widget-down").bind("mousedown", widgetDown); $(".widget-up").bind("mousedown", widgetUp); $(".widget-down").bind("mouseup", function (){ clearInterval(isMouseDown); isMouseDown = false; }); $(".widget-up").bind("mouseup", function (){ clearInterval(isMouseDown); isMouseDown = false; }); $(".widget-down").bind("mouseleave", function (){ clearInterval(isMouseDown); isMouseDown = false; }); $(".widget-up").bind("mouseleave", function (){ clearInterval(isMouseDown); isMouseDown = false; }); function widgetUp($e, $that) { if(typeof $that == 'undefined'){ $that = $(this); } $step = 20; $currentMarginTop = parseInt($that.siblings(".scroll-block").css("marginTop")); $newMarginTop = $currentMarginTop + $step; $elemHeight = parseInt($that.siblings(".scroll-block").height()); if($currentMarginTop < 0){ $that.siblings(".scroll-block").stop().animate({ 'marginTop': $newMarginTop+"px" }, 200); } if (!isMouseDown) { isMouseDown = setInterval(function(){ widgetUp($e, $that) }, 200); } } function widgetDown($e, $that){ if(typeof $that == 'undefined'){ $that = $(this); } $step = 20; $currentMarginTop = parseInt($that.siblings(".scroll-block").css("marginTop")); $newMarginTop = $currentMarginTop - $step; $elemHeight = parseInt($that.siblings(".scroll-block").height()); if(Math.abs($newMarginTop) < $elemHeight - 50){ $that.siblings(".scroll-block").stop().animate({ 'marginTop': $newMarginTop+"px" }, 200); } if (!isMouseDown) { isMouseDown = setInterval(function(){ widgetDown($e, $that) }, 200); } } $('#main-tab-icons .icon-delete').bind('click', function() { // Cancel edit mode. cancelEditMode(); }); $('#main_cancel').bind('click', function() { // Cancel edit mode. cancelEditMode(); }); function cancelEditMode() { disableEditableTab() Dashboard.EditMode = false; $("#advanced-search").slideToggle(); Dashboard.resetSearchParams(); $("#main-tab-icons .icon-add").hide(); $("#main-tab-icons .icon-delete").hide(); $("#main-tab-icons .icon-save").hide(); $("#main-tab-icons .icon-setting").hide(); $("#main-tab-icons .icon-edit").show(); $('#ia').show(); $('#main-tabs ul li img').hide(); //$("#sub-tabs ul li").fadeTo(200, 0.0, function() { viewDashboard(); //$("#sub-tabs").slideUp(200, function(){ //}); $("#filter-checkboxes").slideUp(200, function(){}); $("#advanced-search").slideUp(200, function(){}); $(".dataTables_scrollBody").animate({ height: '305px' }, 200, function() { mainTabSizer(); }); //}); } $("#main-tab-icons .icon-setting").bind("click", function(){ $.facebox({ div: '#search_select_option' }); }); $("#main-tab-icons .icon-edit").bind("click", function(){ $(this).toggleClass("active"); $("#advanced-search").slideToggle(); Dashboard.EditMode = true; $("#main-tab-icons .icon-add").show(); $("#main-tab-icons .icon-delete").show(); $("#main-tab-icons .icon-setting").show(); $("#main-tab-icons .icon-edit").hide(); $('#main-tabs ul li img').fadeIn(200); //$('#main-tabs ul li img:first').hide(); $('#ia').hide(); editableTab($('#main-tabs ul li.active a')[0]) viewDashboardFirst(); mainTabSizer(); $.facebox({ div: '#search_select_option' }); }); $("#dashboard-widget .dashboard").bind("click", function(){ if (Dashboard.EditMode) { return; } if($popularDashboardMode == true){ //return; } if($(this).hasClass("active")){ return; } $popularDashboardMode = true; //$("#dashboard-widget").addClass("hover-disable"); $("#dashboard-widget .dashboard").removeClass("active"); $(this).addClass("active"); $("#notifications-widget").fadeTo(200, 0.2, function(){}); $("#messages-widget").fadeTo(200, 0.2, function(){}); $("#chart").slideUp(200, function(){}); $("#legend").hide(); mainTabSizer(); Dashboard.DashboardUserID = $(this).data('id'); Dashboard.LoadPopularDashboard(function() { $("#main-tab-icons .icon-back").show(); $("#main-tab-icons .icon-save").show(); $("#main-tab-icons .icon-edit").hide(); $("#data-table table tbody tr td.up").addClass("grey"); $("#data-table table tbody tr td.down").addClass("grey"); $("#data-table tbody tr").addClass("edit-mode").addClass("no-checkbox"); $("#data-table tbody tr").removeClass("active"); mainTabSizer(); $distance_counter = 0; $distance_counter_val = []; $("#main-tabs ul").css('left','0'); displayTabScroller(); Dashboard.PopulateDataContainer(function() { resizeTable(); }); }); }); $("#main-tab-icons .icon-back").bind("click", function(){ $popularDashboardMode = false; $("#dashboard-widget").removeClass("hover-disable"); $("#dashboard-widget .dashboard").removeClass("active"); $("#notifications-widget").fadeTo(200, 1.0, function(){}); $("#messages-widget").fadeTo(200, 1.0, function(){}); $("#legend").show(); Dashboard.DashboardUserID = null; Dashboard.LoadPopularDashboard(function() { $("#main-tab-icons .icon-back").hide(); $("#main-tab-icons .icon-save").hide(); $("#main-tab-icons .icon-edit").show(); $('#ia').show(); $("#data-table table tbody tr td.up").removeClass("grey"); $("#data-table table tbody tr td.down").removeClass("grey"); $("#data-table tbody tr").removeClass("edit-mode").removeClass("no-checkbox"); mainTabSizer(); displayTabScroller(); Dashboard.PopulateDataContainer(function() { resizeTable(); }); }); }); mainTabSizer(); subTabSizer(); displayTabScroller(); trackMouseSpeed(); function getData($id){ return null; for (var key in data) { if (data.hasOwnProperty(key) && data[key].id == $id) { return data[key]; } } return null; } function clickFirstTab(){ if( $("#main-tabs ul li.tab:first div a").length > 0){ $("#main-tabs ul li.tab:first div a").trigger("click"); } } //adjusts the size of the main tab UL and container function mainTabSizer(){ $count = $("#main-tabs ul li").length; $i = 0; $totalWidth = 0; while($i<$count){ $totalWidth = $totalWidth + 780+1; // HACK to get it to look right in the demo. $i++; } $("#main-tabs ul").width($totalWidth); $scrollWrapWidth = $("#main-tabs").width() - $("#main-tab-icons").outerWidth(); if($("#main-tabs ul li").length > 1){ $scrollWrapWidth = $scrollWrapWidth - $("#main-tab-left-arrow").outerWidth(); } //$scrollWrapWidth = '83%'; $scrollWrapWidth = $scrollWrapWidth - 5; $("#main-tab-scrollwrap").width($scrollWrapWidth); } function subTabSizer(){ //$count = $("#sub-tabs ul li").length; //$i = 0; //$totalWidth = 0; //while($i<$count){ // $totalWidth = $totalWidth + $("#sub-tabs ul li").eq($i).width(); // $i++; //} //$("#sub-tabs ul").width($totalWidth); //$("#sub-tabs-scrollwrap").width($("#sub-tabs .sub-tabs-middle").width()); } //handles the show/hide of the main tab scroller function displayTabScroller(){ if($("#main-tabs ul li").length > 1){ $("#main-tab-right-arrow").show(); $("#main-tab-left-arrow").show(); } else{ $("#main-tab-right-arrow").hide(); $("#main-tab-left-arrow").hide(); } } //click the first tab clickFirstTab(); $("#ecoExtBtn").bind("click", function(){ if($("#eco_header").css('display')=='block') { var id = $(".eco_goed").attr('rel'); var url= 'ecoDevPdf'; var key= 'economy'; }else if($("#labor_header").css('display')=='block') { var id = $(".labor_goed").attr('rel'); var url= 'laborDevPdf'; var key= 'labor'; }else if($("#real_header").css('display')=='block') { var id = $(".real_goed").attr('rel'); var url= 'realDevPdf'; var key= 'real'; }else if($("#utilities_header").css('display')=='block') { var id = $(".utility_goed").attr('rel'); var url= 'utilityDevPdf'; var key= 'utility'; }else if($("#taxes_header").css('display')=='block') { var id = $(".tex_goed").attr('rel'); var url= 'taxesDevPdf'; var key= 'taxes'; } $.ajax({ url: PageSettings.BaseUrl + "goed/"+url, data: { id: id }, type: 'POST', //dataType: 'json', success: function(data) { window.location = PageSettings.BaseUrl + "goed/actionPdf/"+key; }, error: function() { alert('Sorry, there is some issue in printing.'); } }); }); $(".ecoprintBtnExp").bind("click", function(){ if($("#eco_header").css('display')=='block') { var id = $(".eco_goed").attr('rel'); var url= 'ecoDevXls'; var key= 'economy'; }else if($("#labor_header").css('display')=='block') { var id = $(".labor_goed").attr('rel'); var url= 'laborDevXls'; var key= 'labor'; }else if($("#real_header").css('display')=='block') { var id = $(".real_goed").attr('rel'); var url= 'realDevXls'; var key= 'real'; }else if($("#utilities_header").css('display')=='block') { var id = $(".utility_goed").attr('rel'); var url= 'utilityDevXls'; var key= 'utility'; }else if($("#taxes_header").css('display')=='block') { var id = $(".tex_goed").attr('rel'); var url= 'taxesDevXls'; var key= 'taxes'; } $.ajax({ url: PageSettings.BaseUrl + "goed/"+url, data: { id: id }, type: 'POST', //dataType: 'json', success: function(data) { window.location = PageSettings.BaseUrl + "goed/actionXls/"+key; }, error: function() { alert('Sorry, there is some issue in export.'); } }); }); $(document).on('click', '#data-report-selindicator', function() { closeReportdataPopup(); Dashboard.report_indicatorid = $(row_obj).data('id'); Dashboard.Report('indicator'); }); $(document).on('click', '#data-report-allindicator', function() { closeReportdataPopup(); //Dashboard.Report('tab'); $('div#tab_report_option').css('display','block'); var popupWidth = $('#tab_report_option').width(); var popupHeight = $('#tab_report_option').height(); var wndWidth = $(window).width(); var wndHeight = $(window).height(); Dashboard.ShowOverlay(); $("#tab_report_option").css("position", "fixed"); $("#tab_report_option").css("top", "50%"); $("#tab_report_option").css("left", "50%"); $("#tab_report_option").css("margin-left", (-1)*(popupWidth / 2)); $("#tab_report_option").css("margin-top", (-1)*(popupHeight / 2)); $('#tab_report_option').fadeIn(200, function() { }); }); $(document).on('click', '#tab_report_option a#tab_option_current', function() { $('#show_trailing').val('false'); Dashboard.Report('tab'); }); $(document).on('click', '#tab_report_option a#tab_option_all', function() { $('#show_trailing').val('true'); Dashboard.Report('tab'); }); $(document).on('click', '#tab_report_option .icon-close', function() { Dashboard.HideOverlay(); $('#tab_report_option').fadeOut(200, function() { $(this).offset({ left:-9999, top: -9999 }); }); }); }); var waitForFinalEvent = (function () { var timers = {}; return function (callback, ms, uniqueId) { if (!uniqueId) { uniqueId = "Don't call this twice without a uniqueId"; } if (timers[uniqueId]) { clearTimeout (timers[uniqueId]); } timers[uniqueId] = setTimeout(callback, ms); }; })(); function toggleSelectIndicatorCheckbox(obj){ $newValue = Math.round((parseInt($(".checkbox").attr("data-value")) + 1) % 2); obj.parent().attr("data-value", $newValue); obj.toggleClass("selected"); if (obj.hasClass("selected") && obj.data('was-selected') == '0') { // If it IS selected and it was NOT selected before. Then it has to be added. var id = obj.closest('tr').data('id'); Dashboard.AddIndicator(id); } else if (!obj.hasClass("selected")) { // If it is NOT selected and WAS selected before. Then we have to remove it. var id = obj.closest('tr').data('id'); Dashboard.RemoveIndicator(id); } Dashboard.DirtyTab = true; // Could be cleaner } function saveTabData() { name = $('#main-tabs li.active input').data('value'); name = name.replace(/(\r\n|\n|\r)/gm, ''); name = name.replace(/<(?:.|\n)*?>/gm, ''); addIndicators = []; removeIndicators = []; // take hidden selected indicators and populate the addIndicators array $('._hidden_select_holder').each(function(){ addIndicators.push($(this).data('value')); }); $('._hidden_r_select_holder').each(function(){ removeIndicators.push($(this).data('value')); }); $('#sorted_indicator_list option').attr('selected', 'selected'); var sortIndicators = $('#sorted_indicator_list').val(); var data ={ tabID: $('#main-tabs li.active').data('tab-id'), name: name, addIndicators: addIndicators.join(','), removeIndicators: removeIndicators.join(','), sortIndicators: sortIndicators }; $.ajax({ url: PageSettings.BaseUrl + 'dashboard/TabSave', data: data, dataType: 'json', type: 'POST', success: function(data, xhr, textStatus) { if (data.success) { $("#data-table .checkbox .selected").attr('data-was-selected', 1); // Update the was selected so any further updates are picked up properly. Chaging the attr instead of using .data() because of selectors that are used to get the added adn removed indicators. $("#data-table .checkbox .box:not(.selected)").attr('data-was-selected', 0); //Dashboard.DirtyTab = false; } else { jAlert(data.error); } }, error: function() { jAlert('Unable to save tab!'); } }); } function createCookie(name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = "; expires=" + date.toGMTString(); } else var expires = ""; document.cookie = escape(name) + "=" + escape(value) + expires + "; path=/"; } function readCookie(name) { var nameEQ = escape(name) + "="; 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, c.length); if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length, c.length)); } return null; } function eraseCookie(name) { createCookie(name, "", -1); }