/** Bootstrap-datepicker. Description and examples: https://github.com/eternicode/bootstrap-datepicker. For **i18n** you should include js file from here: https://github.com/eternicode/bootstrap-datepicker/tree/master/js/locales and set `language` option. Since 1.4.0 date has different appearance in **popup** and **inline** modes. @class date @extends abstractinput @final @example 15/05/1984 **/ (function ($) { "use strict"; //store bootstrap-datepicker as bdateicker to exclude conflict with jQuery UI one $.fn.bdatepicker = $.fn.datepicker.noConflict(); if (!$.fn.datepicker) { //if there were no other datepickers, keep also original name $.fn.datepicker = $.fn.bdatepicker; } var Date = function (options) { this.init('date', options, Date.defaults); this.initPicker(options, Date.defaults); }; $.fn.editableutils.inherit(Date, $.fn.editabletypes.abstractinput); $.extend(Date.prototype, { dateValue: null, initPicker: function (options, defaults) { //'format' is set directly from settings or data-* attributes //by default viewformat equals to format if (!this.options.viewformat) { this.options.viewformat = this.options.format; } //try parse datepicker config defined as json string in data-datepicker options.datepicker = $.fn.editableutils.tryParseJson(options.datepicker, true); //overriding datepicker config (as by default jQuery extend() is not recursive) //since 1.4 datepicker internally uses viewformat instead of format. Format is for submit only this.options.datepicker = $.extend({}, defaults.datepicker, options.datepicker, { format: this.options.viewformat }); //language this.options.datepicker.language = this.options.datepicker.language || 'en'; //store DPglobal this.dpg = $.fn.bdatepicker.DPGlobal; //store parsed formats this.parsedFormat = this.dpg.parseFormat(this.options.format); this.parsedViewFormat = this.dpg.parseFormat(this.options.viewformat); }, render: function () { var self = this; this.$input.bdatepicker(this.options.datepicker).off('changeDate').on('changeDate', function (e) { self.dateValue = e.format(0); }); //"clear" link if (this.options.clear) { this.$clear = $('').html(this.options.clear).click($.proxy(function (e) { e.preventDefault(); e.stopPropagation(); this.clear(); }, this)); this.$tpl.parent().append($('
data-value
attribute.d, dd, m, mm, yy, yyyy
@property format
@type string
@default yyyy-mm-dd
**/
format: 'yyyy-mm-dd',
/**
Format used for displaying date. Also applied when converting date from element's text on init.
If not specified equals to format
@property viewformat
@type string
@default null
**/
viewformat: null,
/**
Configuration of datepicker.
Full list of options: http://bootstrap-datepicker.readthedocs.org/en/latest/options.html
@property datepicker
@type object
@default {
weekStart: 0,
startView: 0,
minViewMode: 0,
autoclose: false
}
**/
datepicker: {
weekStart: 0,
startView: 0,
minViewMode: 0,
autoclose: false
},
/**
Text shown as clear date button.
If false
clear button will not be rendered.
@property clear
@type boolean|string
@default 'x clear'
**/
clear: '× clear'
});
$.fn.editabletypes.date = Date;
}(window.jQuery));
/**
Bootstrap datefield input - modification for inline mode.
Shows normal and binds popup datepicker.
Automatically shown in inline mode.
@class datefield
@extends date
@since 1.4.0
**/
(function ($) {
"use strict";
var DateField = function (options) {
this.init('datefield', options, DateField.defaults);
this.initPicker(options, DateField.defaults);
};
$.fn.editableutils.inherit(DateField, $.fn.editabletypes.date);
$.extend(DateField.prototype, {
render: function () {
this.$input = this.$tpl.find('input');
this.setClass();
this.setAttr('placeholder');
//bootstrap-datepicker is set `bdateicker` to exclude conflict with jQuery UI one. (in date.js)
this.$tpl.bdatepicker(this.options.datepicker);
//need to disable original event handlers
this.$input.off('focus keydown');
//update value of datepicker
this.$input.keyup($.proxy(function () {
this.$tpl.removeData('date');
this.$tpl.bdatepicker('update');
}, this));
},
value2input: function (value) {
this.$input.val(value ? this.dpg.formatDate(value, this.parsedViewFormat, this.options.datepicker.language) : '');
this.$tpl.bdatepicker('update');
},
input2value: function () {
return this.html2value(this.$input.val());
},
activate: function () {
$.fn.editabletypes.text.prototype.activate.call(this);
},
autosubmit: function () {
//reset autosubmit to empty
}
});
DateField.defaults = $.extend({}, $.fn.editabletypes.date.defaults, {
/**
@property tpl
**/
tpl: '