Owen Leonard
9ea7fbcb30
This patch adds HTML comments to Template::Toolkit include files which contain <script> tags so that it is clear where the embedded scripts can be found in the code. To test, apply the patch and view source on the following pages to verify the presence of the comments: Acquisitions home page: - acquisitions-toolbar.inc - validtor-strings.inc - js_includes.inc - format-price.inc Acquisitions -> Add order from new record, Acquisitions -> Receive order: - additem.js.inc Cataloging -> Add/Edit item: - columns_settings.inc - strings.inc - select2.inc - calendar.inc - str/cataloging_additem.inc Authorities home page: - authorities_js.inc Bibliographic detail page: - catalog-strings.inc Cataloging -> Advanced editor: - cateditor-ui.inc - cateditor-widgets-marc21.inc Administration -> Item types: - greybox.inc ILL requests: - ill-list-table-strings.inc Web installer - installer-intranet-bottom.inc Web installer -> Onboarding - installer-strings.inc Lists -> List contents -> Merge records - merge-record-strings.inc Patrons -> Patron -> Change password - password_check.inc - str/members-menu.inc Patrons -> Patron -> Print summary - slip-print.inc Circulation -> Check out - timepicker.inc Administration -> System preferences: - str/tinymce_i18n.inc - wysiwyg-systempreferences.inc Cataloging -> Z39.50 Search: - z3950_search.inc Signed-off-by: Frédéric Demians <f.demians@tamil.fr> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
70 lines
2.7 KiB
PHP
70 lines
2.7 KiB
PHP
[% USE Koha %]
|
|
[% USE raw %]
|
|
[% USE Asset %]
|
|
[% USE KohaDates %]
|
|
[% Asset.js("lib/moment/moment.min.js") | $raw %]
|
|
[% Asset.js("lib/moment/moment-timezone-with-data-10-year-range.min.js") | $raw %]
|
|
<!-- js-date-format.inc -->
|
|
<script>
|
|
(function() {
|
|
var def_date_format = '[% Koha.Preference('dateformat') | html %]';
|
|
var def_time_format = '[% Koha.Preference('TimeFormat') | html %]';
|
|
var def_tz = '[% KohaDates.tz | html %]';
|
|
|
|
var get_date_pattern = function(format) {
|
|
var date_pattern = 'YYYY-MM-DD';
|
|
if(format == 'us') date_pattern = 'MM/DD/YYYY';
|
|
if(format == 'metric') date_pattern = 'DD/MM/YYYY';
|
|
if(format == 'dmydot') date_pattern = 'DD.MM.YYYY';
|
|
return date_pattern;
|
|
};
|
|
|
|
var get_time_pattern = function(format) {
|
|
var time_pattern = 'HH:mm';
|
|
if(format == '12hr') time_pattern = 'hh:mm a';
|
|
return time_pattern;
|
|
};
|
|
|
|
/*
|
|
* A JS equivilent of the KohaDates TT Plugin. Passed an rfc3339 formatted date string,
|
|
* or JS Date, the function will return a date string formatted as per the koha instance config.
|
|
* Optionally accepts a dateformat parameter to allow override of the configured output format
|
|
* as well as a 'withtime' boolean denoting whether to include time or not in the output string.
|
|
*/
|
|
window.$date = function(value, options) {
|
|
var tz = (options&&options.tz)||def_tz;
|
|
var m = moment(value);
|
|
if(tz) m.tz(tz);
|
|
|
|
var dateformat = (options&&options.dateformat)||def_date_format;
|
|
var withtime = (options&&options.withtime)||false;
|
|
|
|
if(dateformat=='rfc3339' && withtime) return m.format();
|
|
|
|
var timeformat = (options&&options.timeformat)||def_time_format;
|
|
var date_pattern = get_date_pattern(dateformat);
|
|
var time_pattern = !withtime?'':' '+get_time_pattern(timeformat);
|
|
|
|
return m.format(date_pattern+time_pattern);
|
|
}
|
|
|
|
window.$datetime = function(value, options) {
|
|
options = options||{};
|
|
options.withtime = true;
|
|
return $date(value, options);
|
|
};
|
|
|
|
window.$time = function(value, options) {
|
|
var tz = (opitons&&options.tz)||def_tz;
|
|
var m = moment(value);
|
|
if(tz) m.tz(tz);
|
|
|
|
var dateformat = (options&&options.dateformat);
|
|
var timeformat = (dateformat=='rfc3339'&&'24hr')||(options&&options.timeformat)||def_time_format;
|
|
|
|
return m.format(get_time_pattern(timeformat)+(dateformat=='rfc3339'?':ss'+(!m.isUTC()?'Z':''):''))+(dateformat=='rfc3339' && m.isUTC()?'Z':'');
|
|
}
|
|
|
|
})();
|
|
</script>
|
|
<!-- / js-date-format.inc -->
|