Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
2c4c49ca | 3 | | CiviCRM version 4.7 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
fa938177 | 5 | | Copyright CiviCRM LLC (c) 2004-2016 | |
6a488035 TO |
6 | +--------------------------------------------------------------------+ |
7 | | This file is a part of CiviCRM. | | |
8 | | | | |
9 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
10 | | under the terms of the GNU Affero General Public License | | |
11 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
12 | | | | |
13 | | CiviCRM is distributed in the hope that it will be useful, but | | |
14 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
15 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
16 | | See the GNU Affero General Public License for more details. | | |
17 | | | | |
18 | | You should have received a copy of the GNU Affero General Public | | |
19 | | License and the CiviCRM Licensing Exception along | | |
20 | | with this program; if not, contact CiviCRM LLC | | |
21 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
22 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
23 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
24 | +--------------------------------------------------------------------+ | |
25 | *} | |
26 | {literal} | |
27 | <script type="text/javascript"> | |
f813f78e | 28 | |
3cc60a06 | 29 | CRM.$(function($) { |
6a488035 TO |
30 | // The set of options we can use to initialize jQuery.dashboard(). |
31 | var options = { | |
32 | // Optional. Defaults to 3. You'll need to change the width of columns in CSS too. | |
33 | columns: 2, | |
34 | ||
35 | // Set this to a link to your server-side script that adds widgets to the dashboard. | |
36 | // The server will need to choose a column to add it to, and change the user's settings | |
37 | // stored server-side. | |
38 | // Required. | |
39 | emptyPlaceholderInner: '', | |
40 | ||
55be4d47 CW |
41 | widgetsByColumn: {/literal}{$contactDashlets|@json_encode}{literal}, |
42 | ||
6a488035 | 43 | // These define the urls and data objects used for all of the ajax requests to the server. |
6a488035 TO |
44 | ajaxCallbacks: { |
45 | ||
f813f78e | 46 | // jQuery.dashboard() POSTs the widget-to-column settings here. The server's |
6a488035 TO |
47 | // response is sent to console.log() (if it exists), but is not used. No checks |
48 | // for errors have been implemented yet. | |
49 | // The 'columns' property of data is reserved for the widget-to-columns settings: | |
50 | // An array (keyed by zero-indexed column ID), of arrays (keyed by widget ID) | |
51 | // of ints; 1 if the widget is minimized. 0 if not. | |
52 | saveColumns: { | |
53 | url: {/literal}'{crmURL p='civicrm/ajax/dashboard' h=0 }'{literal}, | |
54 | data: { | |
55 | // columns: array(0 => array(widgetId => isMinimized, ...), ...), | |
56 | op: 'save_columns', key: {/literal}"{crmKey name='civicrm/ajax/dashboard'}"{literal} | |
57 | } | |
58 | }, | |
f813f78e | 59 | |
6a488035 TO |
60 | // jQuery.dashboard() GETs a widget's settings object and POST's a users submitted |
61 | // settings back to the server. The return, in both cases, is an associative | |
62 | // array with the new settings markup and other info: | |
63 | // | |
64 | // Required properties: | |
65 | // * markup: HTML string. The inner HTML of the settings form. jQuery.dashboard() | |
66 | // provides the Save and Cancel buttons and wrapping <form> element. Can include | |
67 | // <input>s of any standard type and <select>s, nested in <div>s etc. | |
68 | // | |
69 | // Server-side executable script callbacks (See documentation for | |
70 | // ajaxCallbacks.getWidgets): | |
71 | // * initScript: Called when widget settings are initialising. | |
72 | // * script: Called when switching into settings mode. Executed every time | |
73 | // the widget goes into settings-edit mode. | |
74 | // | |
75 | // The 'id' property of data is reserved for the widget ID. | |
76 | // The 'settings' property of data is reserved for the user-submitted settings. | |
77 | // An array (keyed by the name="" attributes of <input>s), of <input> values. | |
78 | widgetSettings: { | |
79 | url: {/literal}'{crmURL p='civicrm/ajax/dashboard' h=0 }'{literal}, | |
80 | data: { | |
81 | // id: widgetId, | |
82 | // settings: array(name => value, ...), | |
83 | op: 'widget_settings', key: {/literal}"{crmKey name='civicrm/ajax/dashboard'}"{literal} | |
84 | } | |
85 | } | |
6a488035 | 86 | } |
6a488035 | 87 | |
dd3770bc | 88 | }; |
6a488035 | 89 | |
b9104ebf CW |
90 | $('#civicrm-dashboard') |
91 | .on('mouseover', '.widget-header', function() { | |
92 | $(this).closest('.widget-wrapper').addClass('db-hover-handle'); | |
93 | }) | |
94 | .on('mouseout', '.widget-header', function() { | |
95 | $(this).closest('.widget-wrapper').removeClass('db-hover-handle'); | |
dd3770bc CW |
96 | }) |
97 | .dashboard(options); | |
b9104ebf | 98 | |
201ddbaf | 99 | }); |
6a488035 TO |
100 | |
101 | </script> | |
102 | {/literal} |