Merge pull request #16697 from eileenmcnaughton/deprecate
[civicrm-core.git] / templates / CRM / common / dashboard.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | Copyright CiviCRM LLC. All rights reserved. |
4 | |
5 | This work is published under the GNU AGPLv3 license with some |
6 | permitted exceptions and without any warranty. For full license |
7 | and copyright information, see https://civicrm.org/licensing |
8 +--------------------------------------------------------------------+
9 *}
10 {literal}
11 <script type="text/javascript">
12
13 CRM.$(function($) {
14 // The set of options we can use to initialize jQuery.dashboard().
15 var options = {
16
17 widgetsByColumn: {/literal}{$contactDashlets|@json_encode}{literal},
18
19 // These define the urls and data objects used for all of the ajax requests to the server.
20 ajaxCallbacks: {
21
22 // jQuery.dashboard() POSTs the widget-to-column settings here.
23 // The 'columns' property of data is reserved for the widget-to-columns settings:
24 // An array (keyed by zero-indexed column ID), of arrays (keyed by widget ID)
25 // of ints; 1 if the widget is minimized. 0 if not.
26 saveColumns: {
27 url: {/literal}'{crmURL p='civicrm/ajax/dashboard' h=0 }'{literal},
28 data: {
29 // columns: array(0 => array(widgetId => isMinimized, ...), ...),
30 op: 'save_columns', key: {/literal}"{crmKey name='civicrm/ajax/dashboard'}"{literal}
31 }
32 },
33
34 // jQuery.dashboard() GETs a widget's settings object and POST's a users submitted
35 // settings back to the server. The return, in both cases, is an associative
36 // array with the new settings markup and other info:
37 //
38 // Required properties:
39 // * markup: HTML string. The inner HTML of the settings form. jQuery.dashboard()
40 // provides the Save and Cancel buttons and wrapping <form> element. Can include
41 // <input>s of any standard type and <select>s, nested in <div>s etc.
42 //
43 // Server-side executable script callbacks (See documentation for
44 // ajaxCallbacks.getWidgets):
45 // * initScript: Called when widget settings are initialising.
46 // * script: Called when switching into settings mode. Executed every time
47 // the widget goes into settings-edit mode.
48 //
49 // The 'id' property of data is reserved for the widget ID.
50 // The 'settings' property of data is reserved for the user-submitted settings.
51 // An array (keyed by the name="" attributes of <input>s), of <input> values.
52 widgetSettings: {
53 url: {/literal}'{crmURL p='civicrm/ajax/dashboard' h=0 }'{literal},
54 data: {
55 // id: widgetId,
56 // settings: array(name => value, ...),
57 op: 'widget_settings', key: {/literal}"{crmKey name='civicrm/ajax/dashboard'}"{literal}
58 }
59 }
60 }
61
62 };
63
64 var dashboard = $('#civicrm-dashboard')
65 .on('mouseover', '.widget-header', function() {
66 $(this).closest('.widget-wrapper').addClass('db-hover-handle');
67 })
68 .on('mouseout', '.widget-header', function() {
69 $(this).closest('.widget-wrapper').removeClass('db-hover-handle');
70 })
71 .dashboard(options);
72
73
74 $('.crm-hover-button.show-refresh').click(function(e) {
75 e.preventDefault();
76 $.each(dashboard.widgets, function(id, widget) {
77 widget.reloadContent();
78 });
79 });
80
81 });
82
83 </script>
84 {/literal}