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