commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / templates / CRM / Contribute / Page / DashBoard.js
1 // http://civicrm.org/licensing
2 /*jslint indent: 2 */
3 /*global CRM, cj */
4 (function($) {
5 'use strict';
6
7 var load = {
8 chart_view: function() {
9 var chartUrl = CRM.url("civicrm/ajax/chart", {
10 'snippet': 4,
11 'year': $('#select_year').val() || new Date().getFullYear(),
12 'type': $('#chart_type').val() || 'bvg'
13 });
14 $("#chartData").load(chartUrl, function() {
15 $("select", "#chartData").change(load.chart_view);
16 });
17 },
18 table_view: function() {
19 var tableUrl = CRM.url("civicrm/contribute/ajax/tableview", {showtable: 1, snippet: 4});
20 $("#chartData").load(tableUrl);
21 }
22 };
23
24 function refresh() {
25 $('#chart_view, #table_view').click(function () {
26 if ($(this).hasClass('ui-state-default')) {
27 $('.ui-tabs-selected', '#mainTabContainer').removeClass('ui-state-active ui-tabs-selected').addClass('ui-state-default');
28 $(this).removeClass('ui-state-default').addClass('ui-state-active ui-tabs-selected');
29 load[this.id]();
30 }
31 });
32
33 // Initialize chart or table based on url hash
34 if (window.location.hash === '#table_layout') {
35 $('#table_view').click();
36 }
37 else {
38 load.chart_view();
39 }
40 }
41
42 $(function () {
43 $('#crm-main-content-wrapper').on('crmLoad', function (e) {
44 if ($(e.target).is(this)) {
45 refresh();
46 }
47 });
48 refresh();
49 });
50 })(CRM.$);
51