CRM-12887 intial restructure into js file
authoreileen <eileen@fuzion.co.nz>
Sun, 23 Jun 2013 23:33:24 +0000 (11:33 +1200)
committereileen <eileen@fuzion.co.nz>
Sun, 23 Jun 2013 23:33:24 +0000 (11:33 +1200)
CRM/Contribute/Page/DashBoard.php
templates/CRM/Contribute/Page/DashBoard.js [new file with mode: 0644]
templates/CRM/Contribute/Page/DashBoard.tpl

index ce1c640d6c2fee829dca30dd10084aea04a5b876..1b5fcc02562cc2b1e2846ccec4369f83951cbb93 100644 (file)
@@ -121,6 +121,7 @@ class CRM_Contribute_Page_DashBoard extends CRM_Core_Page {
     $chartForm->setEmbedded(TRUE);
     $chartForm->process();
     $chartForm->run();
+    CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Contribute/Page/DashBoard.js');
 
     return parent::run();
   }
diff --git a/templates/CRM/Contribute/Page/DashBoard.js b/templates/CRM/Contribute/Page/DashBoard.js
new file mode 100644 (file)
index 0000000..af9a7ee
--- /dev/null
@@ -0,0 +1,49 @@
+// http://civicrm.org/licensing
+cj(document).ready( function( ) {
+    getChart( );
+    cj('#chart_view').click(function( ) {
+        if ( cj('#chart_view').hasClass('ui-state-default') ) {
+            cj('#chart_view').removeClass('ui-state-default').addClass('ui-state-active ui-tabs-selected');
+            cj('#table_view').removeClass('ui-state-active ui-tabs-selected').addClass('ui-state-default');
+            getChart( );
+            cj('#tableData').children().html('');
+        }
+    });
+    cj('#table_view').click(function( ) {
+        if ( cj('#table_view').hasClass('ui-state-default') ) {
+            cj('#table_view').removeClass('ui-state-default').addClass('ui-state-active ui-tabs-selected');
+            cj('#chart_view').removeClass('ui-state-active ui-tabs-selected').addClass('ui-state-default');
+            buildTabularView();
+            cj('#chartData').children().html('');
+        }
+    });
+});
+
+function getChart( ) {
+   var year        = cj('#select_year').val( );
+   var charttype   = cj('#chart_type').val( );
+   var date        = new Date()
+   var currentYear = date.getFullYear( );
+   if ( !charttype ) charttype = 'bvg';
+   if ( !year ) year           = currentYear;
+
+   var chartUrl = CRM.url("civicrm/ajax/chart", {snippet : 4});
+   chartUrl    += "&year=" + year + "&type=" + charttype;
+   cj.ajax({
+       url     : chartUrl,
+       success  : function(html){
+           cj( "#chartData" ).html( html );
+       }
+   });
+
+}
+
+function buildTabularView( ) {
+    var tableUrl = CRM.url("civicrm/contribute/ajax/tableview", {showtable:1, snippet:4});
+    cj.ajax({
+        url      : tableUrl,
+        success  : function(html){
+            cj( "#tableData" ).html( html );
+        }
+    });
+}
\ No newline at end of file
index bdc202cbcb561f2870594c4bedc17916f35ab83d..93f46d754a64c3d7b5b139b295c4925142a302de 100644 (file)
     <div>
         {include file="CRM/Contribute/Form/Selector.tpl" context="dashboard"}
     </div>
-{/if}{literal}
-<script type="text/javascript">
-
-cj(document).ready( function( ) {
-    getChart( );
-    cj('#chart_view').click(function( ) {
-        if ( cj('#chart_view').hasClass('ui-state-default') ) {
-            cj('#chart_view').removeClass('ui-state-default').addClass('ui-state-active ui-tabs-selected');
-            cj('#table_view').removeClass('ui-state-active ui-tabs-selected').addClass('ui-state-default');
-            getChart( );
-            cj('#tableData').children().html('');
-        }
-    });
-    cj('#table_view').click(function( ) {
-        if ( cj('#table_view').hasClass('ui-state-default') ) {
-            cj('#table_view').removeClass('ui-state-default').addClass('ui-state-active ui-tabs-selected');
-            cj('#chart_view').removeClass('ui-state-active ui-tabs-selected').addClass('ui-state-default');
-            buildTabularView();
-            cj('#chartData').children().html('');
-        }
-    });
-});
-
-function getChart( ) {
-   var year        = cj('#select_year').val( );
-   var charttype   = cj('#chart_type').val( );
-   var date        = new Date()
-   var currentYear = date.getFullYear( );
-   if ( !charttype ) charttype = 'bvg';
-   if ( !year ) year           = currentYear;
-
-   var chartUrl = {/literal}"{crmURL p='civicrm/ajax/chart' q='snippet=4' h=0}"{literal};
-   chartUrl    += "&year=" + year + "&type=" + charttype;
-   cj.ajax({
-       url     : chartUrl,
-       async    : false,
-       success  : function(html){
-           cj( "#chartData" ).html( html );
-       }
-   });
-
-}
-
-function buildTabularView( ) {
-    var tableUrl = {/literal}"{crmURL p='civicrm/contribute/ajax/tableview' q='showtable=1&snippet=4' h=0}"{literal};
-    cj.ajax({
-        url      : tableUrl,
-        async    : false,
-        success  : function(html){
-            cj( "#tableData" ).html( html );
-        }
-    });
-}
-
-</script>
-{/literal}
-
+{/if}
 {/if}
\ No newline at end of file