2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.3 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2013 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
27 <script type="text/javascript">
29 // Create closure, so that we don't accidentally spoil the global/window namespace.
31 // The set of options we can use to initialize jQuery.dashboard().
33 // Optional. Defaults to 3. You'll need to change the width of columns in CSS too.
36 // Set this to a link to your server-side script that adds widgets to the dashboard.
37 // The server will need to choose a column to add it to, and change the user's settings
38 // stored server-side.
40 emptyPlaceholderInner: '',
42 // These define the urls and data objects used for all of the ajax requests to the server.
43 // data objects are extended with more properties, as defined below.
44 // All are required. All should return JSON.
47 // Server returns the configuration of widgets for this user;
48 // An array (keyed by zero-indexed column ID), of arrays (keyed by widget ID) of
49 // booleans; true if the widget is minimized. False if not.
50 // E.g. [{ widgetID: isMinimized, ...}, ...]
52 url: {/literal}'{crmURL p='civicrm/ajax/dashboard' h=0 }'{literal},
54 op: 'get_widgets_by_column', key: {/literal}"{crmKey name='civicrm/ajax/dashboard'}"{literal}
58 // Given the widget ID, the server returns the widget object as an associative array.
59 // E.g. {content: '<p>Widget content</p>', title: 'Widget Title', }
61 // Required properties:
62 // * title: Text string. Widget title
63 // * content: HTML string. Widget content
65 // Optional properties:
66 // * classes: String CSS classes that will be added to the widget's <li>
67 // * fullscreen: HTML string for the content of the widget's full screen display.
68 // * settings: Boolean. True if widget has settings pane/display and server-side
71 // Server-side executable script callbacks are called and executed on certain
72 // events. They can use the widgets property of the dashboard object returned
73 // from jQuery.dashboard(). E.g. dashboard.widgets[widgetID]. They should be
74 // javascript files on the server. Set the property to the path of the js file:
75 // * initScript: Called when dashboard is initialising (but not finished).
76 // * fullscreenInitScript: Called when the full screen element is initialising
77 // (being created for the first time).
78 // * fullscreenScript: Called when switching into full screen mode. Executed
79 // every time the widget goes into full-screen mode.
80 // * reloadContentScript: Called when the widget's reloadContent() method is
81 // called. (The widget.reloadContent() method is not used internally so must
82 // have either the callback function or this server-side executable javascript
83 // file implemented for the method to do anything.)
85 // The 'id' property of data is reserved for the widget ID – a string.
87 url: {/literal}'{crmURL p='civicrm/ajax/dashboard' h=0 }'{literal},
90 op: 'get_widget', key: {/literal}"{crmKey name='civicrm/ajax/dashboard'}"{literal}
94 // jQuery.dashboard() POSTs the widget-to-column settings here. The server's
95 // response is sent to console.log() (if it exists), but is not used. No checks
96 // for errors have been implemented yet.
97 // The 'columns' property of data is reserved for the widget-to-columns settings:
98 // An array (keyed by zero-indexed column ID), of arrays (keyed by widget ID)
99 // of ints; 1 if the widget is minimized. 0 if not.
101 url: {/literal}'{crmURL p='civicrm/ajax/dashboard' h=0 }'{literal},
103 // columns: array(0 => array(widgetId => isMinimized, ...), ...),
104 op: 'save_columns', key: {/literal}"{crmKey name='civicrm/ajax/dashboard'}"{literal}
108 // jQuery.dashboard() GETs a widget's settings object and POST's a users submitted
109 // settings back to the server. The return, in both cases, is an associative
110 // array with the new settings markup and other info:
112 // Required properties:
113 // * markup: HTML string. The inner HTML of the settings form. jQuery.dashboard()
114 // provides the Save and Cancel buttons and wrapping <form> element. Can include
115 // <input>s of any standard type and <select>s, nested in <div>s etc.
117 // Server-side executable script callbacks (See documentation for
118 // ajaxCallbacks.getWidgets):
119 // * initScript: Called when widget settings are initialising.
120 // * script: Called when switching into settings mode. Executed every time
121 // the widget goes into settings-edit mode.
123 // The 'id' property of data is reserved for the widget ID.
124 // The 'settings' property of data is reserved for the user-submitted settings.
125 // An array (keyed by the name="" attributes of <input>s), of <input> values.
127 url: {/literal}'{crmURL p='civicrm/ajax/dashboard' h=0 }'{literal},
130 // settings: array(name => value, ...),
131 op: 'widget_settings', key: {/literal}"{crmKey name='civicrm/ajax/dashboard'}"{literal}
136 // Optional javascript callbacks for dashboard events.
137 // All callbacks have the dashboard object available as the 'this' variable.
138 // This property and all of it's members are optional.
140 // Called when dashboard is initializing.
142 var dashboard = this;
145 // Called when dashboard has finished initializing.
147 var dashboard = this;
150 // Called when dashboard has saved columns to the server.
151 saveColumns: function() {
152 var dashboard = this;
155 // Called when a widget has gone into fullscreen mode.
156 // Takes one argument for the widget.
157 enterFullscreen: function(widget) {
158 var dashboard = this;
161 // Called when a widget has come out of fullscreen mode.
162 // Takes one argument for the widget.
163 exitFullscreen: function(widget) {
164 var dashboard = this;
168 // Optional javascript callbacks for widget events.
169 // All callbacks have the respective widget object available as the 'this' variable.
170 // This property and all of it's members are optional.
172 // Called when a widget has been gotten from the server.
177 // Called when an external script has invoked the widget.reloadContent() method.
178 // (The widget.reloadContent() method is not used internally so must have either
179 // this callback function or a server-side executable javascript file implemented
180 // for the method to do anything.)
181 reloadContent: function() {
185 // Called when the widget has gone into settings-edit mode.
186 showSettings: function() {
190 // Called when the widget's settings have been saved to the server.
191 saveSettings: function() {
195 // Called when the widget has gone out of settings-edit mode.
196 hideSettings: function() {
200 // Called when the widget has been removed from the dashboard.
207 // Initialize the dashboard using these options, and save to the global/window
208 // namesapace so that server-side executable js file callbacks can access
209 // window.dashboardDemo.widgets by ID.
210 window.dashboardDemo = cj('#civicrm-dashboard').dashboard(options);