add datetime input
This commit is contained in:
80
src/inputs/datetime/datetimefield.js
Normal file
80
src/inputs/datetime/datetimefield.js
Normal file
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
Bootstrap datetimefield input - modification for inline mode.
|
||||
Shows normal <input type="text"> and binds popup datetimepicker.
|
||||
Automatically shown in inline mode.
|
||||
|
||||
@class datetimefield
|
||||
@extends datetime
|
||||
|
||||
**/
|
||||
(function ($) {
|
||||
|
||||
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(value ? this.dpg.formatDate(value, this.parsedViewFormat, this.options.datepicker.language) : '');
|
||||
this.$tpl.datepicker('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:'<div class="input-append date"><input type="text"/><span class="add-on"><i class="icon-th"></i></span></div>',
|
||||
/**
|
||||
@property inputclass
|
||||
@default 'input-small'
|
||||
**/
|
||||
inputclass: 'input-small',
|
||||
|
||||
/* datetimepicker config */
|
||||
datetimepicker:{
|
||||
weekStart: 0,
|
||||
startView: 2, // month
|
||||
maxView: 4, // decade
|
||||
minView: 0,
|
||||
todayHighlight: false,
|
||||
autoclose: true
|
||||
}
|
||||
});
|
||||
|
||||
$.fn.editabletypes.datetimefield = DateTimeField;
|
||||
|
||||
}(window.jQuery));
|
Reference in New Issue
Block a user