| 1 | {* |
| 2 | +--------------------------------------------------------------------+ |
| 3 | | CiviCRM version 4.7 | |
| 4 | +--------------------------------------------------------------------+ |
| 5 | | Copyright CiviCRM LLC (c) 2004-2017 | |
| 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"> |
| 28 | |
| 29 | CRM.$(function($) { |
| 30 | // The set of options we can use to initialize jQuery.dashboard(). |
| 31 | var options = { |
| 32 | |
| 33 | widgetsByColumn: {/literal}{$contactDashlets|@json_encode}{literal}, |
| 34 | |
| 35 | // These define the urls and data objects used for all of the ajax requests to the server. |
| 36 | ajaxCallbacks: { |
| 37 | |
| 38 | // jQuery.dashboard() POSTs the widget-to-column settings here. |
| 39 | // The 'columns' property of data is reserved for the widget-to-columns settings: |
| 40 | // An array (keyed by zero-indexed column ID), of arrays (keyed by widget ID) |
| 41 | // of ints; 1 if the widget is minimized. 0 if not. |
| 42 | saveColumns: { |
| 43 | url: {/literal}'{crmURL p='civicrm/ajax/dashboard' h=0 }'{literal}, |
| 44 | data: { |
| 45 | // columns: array(0 => array(widgetId => isMinimized, ...), ...), |
| 46 | op: 'save_columns', key: {/literal}"{crmKey name='civicrm/ajax/dashboard'}"{literal} |
| 47 | } |
| 48 | }, |
| 49 | |
| 50 | // jQuery.dashboard() GETs a widget's settings object and POST's a users submitted |
| 51 | // settings back to the server. The return, in both cases, is an associative |
| 52 | // array with the new settings markup and other info: |
| 53 | // |
| 54 | // Required properties: |
| 55 | // * markup: HTML string. The inner HTML of the settings form. jQuery.dashboard() |
| 56 | // provides the Save and Cancel buttons and wrapping <form> element. Can include |
| 57 | // <input>s of any standard type and <select>s, nested in <div>s etc. |
| 58 | // |
| 59 | // Server-side executable script callbacks (See documentation for |
| 60 | // ajaxCallbacks.getWidgets): |
| 61 | // * initScript: Called when widget settings are initialising. |
| 62 | // * script: Called when switching into settings mode. Executed every time |
| 63 | // the widget goes into settings-edit mode. |
| 64 | // |
| 65 | // The 'id' property of data is reserved for the widget ID. |
| 66 | // The 'settings' property of data is reserved for the user-submitted settings. |
| 67 | // An array (keyed by the name="" attributes of <input>s), of <input> values. |
| 68 | widgetSettings: { |
| 69 | url: {/literal}'{crmURL p='civicrm/ajax/dashboard' h=0 }'{literal}, |
| 70 | data: { |
| 71 | // id: widgetId, |
| 72 | // settings: array(name => value, ...), |
| 73 | op: 'widget_settings', key: {/literal}"{crmKey name='civicrm/ajax/dashboard'}"{literal} |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | }; |
| 79 | |
| 80 | var dashboard = $('#civicrm-dashboard') |
| 81 | .on('mouseover', '.widget-header', function() { |
| 82 | $(this).closest('.widget-wrapper').addClass('db-hover-handle'); |
| 83 | }) |
| 84 | .on('mouseout', '.widget-header', function() { |
| 85 | $(this).closest('.widget-wrapper').removeClass('db-hover-handle'); |
| 86 | }) |
| 87 | .dashboard(options); |
| 88 | |
| 89 | |
| 90 | $('.crm-hover-button.show-refresh').click(function(e) { |
| 91 | e.preventDefault(); |
| 92 | $.each(dashboard.widgets, function(id, widget) { |
| 93 | widget.reloadContent(); |
| 94 | }); |
| 95 | }); |
| 96 | |
| 97 | }); |
| 98 | |
| 99 | </script> |
| 100 | {/literal} |