/** Bootstrap-datetimepicker. Based on [smalot bootstrap-datetimepicker plugin](https://github.com/smalot/bootstrap-datetimepicker). Before usage you should manually include dependent js and css: For **i18n** you should include js file from here: https://github.com/smalot/bootstrap-datetimepicker/tree/master/js/locales and set `language` option. @class datetime @extends abstractinput @final @since 1.4.4 @example 15/03/2013 12:45 **/ (function ($) { "use strict"; var DateTime = function (options) { this.init('datetime', options, DateTime.defaults); this.initPicker(options, DateTime.defaults); }; $.fn.editableutils.inherit(DateTime, $.fn.editabletypes.abstractinput); $.extend(DateTime.prototype, { 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 datetimepicker config defined as json string in data-datetimepicker options.datetimepicker = $.fn.editableutils.tryParseJson(options.datetimepicker, true); //overriding datetimepicker config (as by default jQuery extend() is not recursive) //since 1.4 datetimepicker internally uses viewformat instead of format. Format is for submit only this.options.datetimepicker = $.extend({}, defaults.datetimepicker, options.datetimepicker, { format: this.options.viewformat }); //language this.options.datetimepicker.language = this.options.datetimepicker.language || 'en'; //store DPglobal this.dpg = $.fn.datetimepicker.DPGlobal; //store parsed formats this.parsedFormat = this.dpg.parseFormat(this.options.format, this.options.formatType); this.parsedViewFormat = this.dpg.parseFormat(this.options.viewformat, this.options.formatType); }, render: function () { this.$input.datetimepicker(this.options.datetimepicker); //adjust container position when viewMode changes //see https://github.com/smalot/bootstrap-datetimepicker/pull/80 this.$input.on('changeMode', function (e) { var f = $(this).closest('form').parent(); //timeout here, otherwise container changes position before form has new size setTimeout(function () { f.triggerHandler('resize'); }, 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, h, i
@property format
@type string
@default yyyy-mm-dd hh:ii
**/
format: 'yyyy-mm-dd hh:ii',
formatType: 'standard',
/**
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 datetimepicker.
Full list of options: https://github.com/smalot/bootstrap-datetimepicker
@property datetimepicker
@type object
@default { }
**/
datetimepicker: {
todayHighlight: false,
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.datetime = DateTime;
}(window.jQuery));
/**
Bootstrap datetimefield input - datetime input for inline mode.
Shows normal and binds popup datetimepicker.
Automatically shown in inline mode.
@class datetimefield
@extends datetime
**/
(function ($) {
"use strict";
var DateTimeField = function (options) {
this.init('datetimefield', options, DateTimeField.defaults);
this.initPicker(options, DateTimeField.defaults);
};
$.fn.editableutils.inherit(DateTimeField, $.fn.editabletypes.datetime);
$.extend(DateTimeField.prototype, {
render: function () {
this.$input = this.$tpl.find('input');
this.setClass();
this.setAttr('placeholder');
this.$tpl.datetimepicker(this.options.datetimepicker);
//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.datetimepicker('update');
}, this));
},
value2input: function (value) {
this.$input.val(this.value2html(value));
this.$tpl.datetimepicker('update');
},
input2value: function () {
return this.html2value(this.$input.val());
},
activate: function () {
$.fn.editabletypes.text.prototype.activate.call(this);
},
autosubmit: function () {
//reset autosubmit to empty
}
});
DateTimeField.defaults = $.extend({}, $.fn.editabletypes.datetime.defaults, {
/**
@property tpl
**/
tpl: '