Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
1188c7a8 | 3 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 4 | | | |
1188c7a8 TO |
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 | | |
6a488035 TO |
8 | +--------------------------------------------------------------------+ |
9 | *} | |
10 | {literal} | |
11 | <script type="text/javascript"> | |
f813f78e | 12 | |
3cc60a06 | 13 | CRM.$(function($) { |
6a488035 TO |
14 | // The set of options we can use to initialize jQuery.dashboard(). |
15 | var options = { | |
6a488035 | 16 | |
55be4d47 CW |
17 | widgetsByColumn: {/literal}{$contactDashlets|@json_encode}{literal}, |
18 | ||
6a488035 | 19 | // These define the urls and data objects used for all of the ajax requests to the server. |
6a488035 TO |
20 | ajaxCallbacks: { |
21 | ||
242055d3 | 22 | // jQuery.dashboard() POSTs the widget-to-column settings here. |
6a488035 TO |
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 | }, | |
f813f78e | 33 | |
6a488035 TO |
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 | } | |
6a488035 | 60 | } |
6a488035 | 61 | |
dd3770bc | 62 | }; |
6a488035 | 63 | |
4e1046df | 64 | var dashboard = $('#civicrm-dashboard') |
b9104ebf CW |
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'); | |
dd3770bc CW |
70 | }) |
71 | .dashboard(options); | |
b9104ebf | 72 | |
4e1046df CW |
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 | ||
201ddbaf | 81 | }); |
6a488035 TO |
82 | |
83 | </script> | |
84 | {/literal} |