Commit | Line | Data |
---|---|---|
b7ceb253 | 1 | {* |
3d527838 | 2 | +--------------------------------------------------------------------+ |
1188c7a8 | 3 | | Copyright CiviCRM LLC. All rights reserved. | |
3d527838 | 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 | | |
3d527838 CW |
8 | +--------------------------------------------------------------------+ |
9 | *}// http://civicrm.org/licensing | |
51b81901 | 10 | // <script> Generated {$smarty.now|date_format:'%d %b %Y %H:%M:%S'} |
4e56e743 | 11 | {* This file should only contain strings and settings which rarely change *} |
3d527838 | 12 | (function($) {ldelim} |
4e56e743 CW |
13 | // Config settings |
14 | CRM.config.userFramework = {$config->userFramework|@json_encode}; | |
dc662c39 | 15 | CRM.config.resourceBase = {$config->userFrameworkResourceURL|@json_encode}; |
3130950c | 16 | CRM.config.packagesBase = {capture assign=packagesBase}{crmResURL expr='[civicrm.packages]/.'}{/capture}{$packagesBase|@json_encode}; |
4e56e743 | 17 | CRM.config.lcMessages = {$config->lcMessages|@json_encode}; |
b30809e4 CW |
18 | CRM.config.locale = {$locale|@json_encode}; |
19 | CRM.config.cid = {$cid|@json_encode}; | |
af3775b3 CW |
20 | $.datepicker._defaults.dateFormat = CRM.config.dateInputFormat = {$config->dateInputFormat|@json_encode}; |
21 | CRM.config.timeIs24Hr = {if $config->timeInputFormat eq 2}true{else}false{/if}; | |
7b83e312 | 22 | CRM.config.ajaxPopupsEnabled = {$ajaxPopupsEnabled|@json_encode}; |
a9fb6123 | 23 | CRM.config.allowAlertAutodismissal = {$allowAlertAutodismissal|@json_encode}; |
c7e39a79 | 24 | CRM.config.resourceCacheCode = {$resourceCacheCode|@json_encode}; |
4e56e743 | 25 | |
b7ceb253 CW |
26 | // Merge entityRef settings |
27 | CRM.config.entityRef = $.extend({ldelim}{rdelim}, {$entityRef|@json_encode}, CRM.config.entityRef || {ldelim}{rdelim}); | |
6ef865c6 | 28 | |
3d527838 | 29 | // Initialize CRM.url and CRM.formatMoney |
cdef34e0 | 30 | CRM.url({ldelim}back: '{crmURL p="civicrm-placeholder-url-path" q="civicrm-placeholder-url-query=1" h=0 fb=1}', front: '{crmURL p="civicrm-placeholder-url-path" q="civicrm-placeholder-url-query=1" h=0 fe=1}'{rdelim}); |
7f92cfa9 | 31 | CRM.formatMoney('init', false, {$moneyFormat}); |
3d527838 CW |
32 | |
33 | // Localize select2 | |
34 | $.fn.select2.defaults.formatNoMatches = "{ts escape='js'}None found.{/ts}"; | |
35 | $.fn.select2.defaults.formatLoadMore = "{ts escape='js'}Loading...{/ts}"; | |
36 | $.fn.select2.defaults.formatSearching = "{ts escape='js'}Searching...{/ts}"; | |
37 | $.fn.select2.defaults.formatInputTooShort = function() {ldelim} | |
b3d31cda | 38 | return ($(this).data('api-entity') === 'contact' || $(this).data('api-entity') === 'Contact') ? {$contactSearch} : {$otherSearch}; |
3d527838 CW |
39 | {rdelim}; |
40 | ||
6ef865c6 CW |
41 | // Localize jQuery UI |
42 | $.ui.dialog.prototype.options.closeText = "{ts escape='js'}Close{/ts}"; | |
43 | ||
7d12de7f JL |
44 | // Localize jQuery DataTables |
45 | // Note the first two defaults set here aren't localization related, | |
46 | // but need to be set globally for all DataTables. | |
47 | $.extend( $.fn.dataTable.defaults, {ldelim} | |
48 | "searching": false, | |
49 | "jQueryUI": true, | |
50 | "language": {ldelim} | |
51 | "emptyTable": "{ts escape='js'}None found.{/ts}", | |
3fff685f | 52 | "info": "{ts escape='js' 1=_START_ 2=_END_ 3=_TOTAL_}Showing %1 to %2 of %3 entries{/ts}", |
7d12de7f JL |
53 | "infoEmpty": "{ts escape='js'}Showing 0 to 0 of 0 entries{/ts}", |
54 | "infoFiltered": "{ts escape='js' 1=_MAX_}(filtered from %1 total entries){/ts}", | |
55 | "infoPostFix": "", | |
56 | "thousands": {$config->monetaryThousandSeparator|json_encode}, | |
57 | "lengthMenu": "{ts escape='js' 1=_MENU_}Show %1 entries{/ts}", | |
58 | "loadingRecords": " ", | |
59 | "processing": " ", | |
60 | "zeroRecords": "{ts escape='js'}None found.{/ts}", | |
61 | "paginate": {ldelim} | |
62 | "first": "{ts escape='js'}First{/ts}", | |
63 | "last": "{ts escape='js'}Last{/ts}", | |
64 | "next": "{ts escape='js'}Next{/ts}", | |
65 | "previous": "{ts escape='js'}Previous{/ts}" | |
66 | {rdelim} | |
67 | {rdelim} | |
68 | {rdelim}); | |
69 | ||
3d527838 CW |
70 | // Localize strings for jQuery.validate |
71 | var messages = {ldelim} | |
72 | required: "{ts escape='js'}This field is required.{/ts}", | |
73 | remote: "{ts escape='js'}Please fix this field.{/ts}", | |
74 | email: "{ts escape='js'}Please enter a valid email address.{/ts}", | |
75 | url: "{ts escape='js'}Please enter a valid URL.{/ts}", | |
76 | date: "{ts escape='js'}Please enter a valid date.{/ts}", | |
77 | dateISO: "{ts escape='js'}Please enter a valid date (YYYY-MM-DD).{/ts}", | |
78 | number: "{ts escape='js'}Please enter a valid number.{/ts}", | |
79 | digits: "{ts escape='js'}Please enter only digits.{/ts}", | |
80 | creditcard: "{ts escape='js'}Please enter a valid credit card number.{/ts}", | |
81 | equalTo: "{ts escape='js'}Please enter the same value again.{/ts}", | |
82 | accept: "{ts escape='js'}Please enter a value with a valid extension.{/ts}", | |
83 | maxlength: $.validator.format("{ts escape='js'}Please enter no more than {ldelim}0{rdelim} characters.{/ts}"), | |
84 | minlength: $.validator.format("{ts escape='js'}Please enter at least {ldelim}0{rdelim} characters.{/ts}"), | |
85 | rangelength: $.validator.format("{ts escape='js'}Please enter a value between {ldelim}0{rdelim} and {ldelim}1{rdelim} characters long.{/ts}"), | |
86 | range: $.validator.format("{ts escape='js'}Please enter a value between {ldelim}0{rdelim} and {ldelim}1{rdelim}.{/ts}"), | |
87 | max: $.validator.format("{ts escape='js'}Please enter a value less than or equal to {ldelim}0{rdelim}.{/ts}"), | |
88 | min: $.validator.format("{ts escape='js'}Please enter a value greater than or equal to {ldelim}0{rdelim}.{/ts}") | |
89 | }; | |
90 | $.extend($.validator.messages, messages); | |
91 | {literal} | |
92 | ||
93 | var params = { | |
94 | errorClass: 'crm-inline-error', | |
8947862b CW |
95 | messages: {}, |
96 | // TODO: remove after resolution of https://github.com/jzaefferer/jquery-validation/pull/1261 | |
97 | ignore: ":hidden, [readonly]" | |
3d527838 CW |
98 | }; |
99 | ||
100 | // use civicrm notifications when there are errors | |
101 | params.invalidHandler = function(form, validator) { | |
cd73f9c5 | 102 | // If there is no container for display then red text will still show next to the invalid fields |
103 | // but there will be no overall message. Currently the container is only available on backoffice pages. | |
3d527838 CW |
104 | if ($('#crm-notification-container').length) { |
105 | $.each(validator.errorList, function(k, error) { | |
106 | $(error.element).crmError(error.message); | |
107 | }); | |
3d527838 CW |
108 | } |
109 | }; | |
110 | ||
111 | CRM.validate = { | |
112 | _defaults: params, | |
113 | params: {}, | |
114 | functions: [] | |
115 | }; | |
ff566396 CW |
116 | |
117 | // Load polyfill | |
118 | if (!('Promise' in window)) { | |
119 | CRM.loadScript(CRM.config.resourceBase + 'bower_components/es6-promise/es6-promise.auto.min.js'); | |
120 | } | |
121 | ||
3d527838 CW |
122 | })(jQuery); |
123 | {/literal} |