Skip to content
This repository has been archived by the owner on Jul 16, 2022. It is now read-only.

Commit

Permalink
Allowing options.title_format to accept a callback
Browse files Browse the repository at this point in the history
  • Loading branch information
multiwebinc authored Dec 4, 2018
1 parent 133b5c5 commit ab1522a
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions js/pickmeup.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,12 @@
header = local_date.getFullYear();
} else if (dom_has_class(root_element, 'pmu-view-days')) {
date_add_months(local_date, i - current_cal);
header = format_date(local_date, options.title_format, options.locales[options.locale], true);
if (typeof options.title_format === "function") {
header = options.title_format(local_date, options.locales[options.locale]);
}
else {
header = format_date(local_date, options.title_format, options.locales[options.locale]);
}
}
if (!shown_date_to) {
if (max_date) {
Expand Down Expand Up @@ -632,7 +637,7 @@
return date;
}

function format_date (date, format, locale, html) {
function format_date (date, format, locale) {
var m = date.getMonth();
var d = date.getDate();
var y = date.getFullYear();
Expand Down Expand Up @@ -714,15 +719,8 @@
case 'Y':
part = y;
break;
default:
parts[i] = 'default';
}
if (html) {
parts[i] = '<span class="pmu-month-text-' + parts[i] + '">' + part + '</span>';
}
else {
parts[i] = part;
}
parts[i] = part;
}
return parts.join('');
}
Expand Down Expand Up @@ -884,6 +882,7 @@

function prepare_date (options) {
var result;
console.log("preparing date")
if (options.mode == 'single') {
result = new Date(options.date);
return {
Expand Down

0 comments on commit ab1522a

Please sign in to comment.