Merge pull request #5488 from eileenmcnaughton/CRM-16184
[civicrm-core.git] / templates / CRM / common / l10n.js.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.6 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2015 |
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 *}// http://civicrm.org/licensing
26 // <script> Generated {$smarty.now|date_format:'%d %b %Y %H:%M:%S'}
27 {* This file should only contain strings and settings which rarely change *}
28 (function($) {ldelim}
29 // Config settings
30 CRM.config.userFramework = {$config->userFramework|@json_encode};
31 CRM.config.resourceBase = {$config->resourceBase|@json_encode};
32 CRM.config.lcMessages = {$config->lcMessages|@json_encode};
33 $.datepicker._defaults.dateFormat = CRM.config.dateInputFormat = {$config->dateInputFormat|@json_encode};
34 CRM.config.timeIs24Hr = {if $config->timeInputFormat eq 2}true{else}false{/if};
35 CRM.config.ajaxPopupsEnabled = {$ajaxPopupsEnabled|@json_encode};
36
37 // Merge entityRef settings
38 CRM.config.entityRef = $.extend({ldelim}{rdelim}, {$entityRef|@json_encode}, CRM.config.entityRef || {ldelim}{rdelim});
39
40 // Initialize CRM.url and CRM.formatMoney
41 CRM.url({ldelim}back: '{crmURL p="*path*" q="*query*" h=0 fb=1}', front: '{crmURL p="*path*" q="*query*" h=0 fe=1}'{rdelim});
42 CRM.formatMoney('init', {$moneyFormat});
43
44 // Localize select2
45 $.fn.select2.defaults.formatNoMatches = "{ts escape='js'}None found.{/ts}";
46 $.fn.select2.defaults.formatLoadMore = "{ts escape='js'}Loading...{/ts}";
47 $.fn.select2.defaults.formatSearching = "{ts escape='js'}Searching...{/ts}";
48 $.fn.select2.defaults.formatInputTooShort = function() {ldelim}
49 return ($(this).data('api-entity') === 'contact' || $(this).data('api-entity') === 'Contact') ? {$contactSearch} : {$otherSearch};
50 {rdelim};
51
52 // Localize jQuery UI
53 $.ui.dialog.prototype.options.closeText = "{ts escape='js'}Close{/ts}";
54
55 // Localize strings for jQuery.validate
56 var messages = {ldelim}
57 required: "{ts escape='js'}This field is required.{/ts}",
58 remote: "{ts escape='js'}Please fix this field.{/ts}",
59 email: "{ts escape='js'}Please enter a valid email address.{/ts}",
60 url: "{ts escape='js'}Please enter a valid URL.{/ts}",
61 date: "{ts escape='js'}Please enter a valid date.{/ts}",
62 dateISO: "{ts escape='js'}Please enter a valid date (YYYY-MM-DD).{/ts}",
63 number: "{ts escape='js'}Please enter a valid number.{/ts}",
64 digits: "{ts escape='js'}Please enter only digits.{/ts}",
65 creditcard: "{ts escape='js'}Please enter a valid credit card number.{/ts}",
66 equalTo: "{ts escape='js'}Please enter the same value again.{/ts}",
67 accept: "{ts escape='js'}Please enter a value with a valid extension.{/ts}",
68 maxlength: $.validator.format("{ts escape='js'}Please enter no more than {ldelim}0{rdelim} characters.{/ts}"),
69 minlength: $.validator.format("{ts escape='js'}Please enter at least {ldelim}0{rdelim} characters.{/ts}"),
70 rangelength: $.validator.format("{ts escape='js'}Please enter a value between {ldelim}0{rdelim} and {ldelim}1{rdelim} characters long.{/ts}"),
71 range: $.validator.format("{ts escape='js'}Please enter a value between {ldelim}0{rdelim} and {ldelim}1{rdelim}.{/ts}"),
72 max: $.validator.format("{ts escape='js'}Please enter a value less than or equal to {ldelim}0{rdelim}.{/ts}"),
73 min: $.validator.format("{ts escape='js'}Please enter a value greater than or equal to {ldelim}0{rdelim}.{/ts}")
74 };
75 $.extend($.validator.messages, messages);
76 {literal}
77
78 var params = {
79 errorClass: 'crm-inline-error',
80 messages: {},
81 // TODO: remove after resolution of https://github.com/jzaefferer/jquery-validation/pull/1261
82 ignore: ":hidden, [readonly]"
83 };
84
85 // use civicrm notifications when there are errors
86 params.invalidHandler = function(form, validator) {
87 if ($('#crm-notification-container').length) {
88 $.each(validator.errorList, function(k, error) {
89 $(error.element).crmError(error.message);
90 });
91 } else {
92 alert({/literal}"{ts escape='js'}Please review and correct the highlighted fields before continuing.{/ts}"{literal});
93 }
94 };
95
96 CRM.validate = {
97 _defaults: params,
98 params: {},
99 functions: []
100 };
101 })(jQuery);
102 {/literal}