fix lint errors
This commit is contained in:
src
containers
editable-form
element
inputs
@ -5,7 +5,7 @@ Before usage you should manually include dependent js and css:
|
||||
|
||||
<link href="css/datetimepicker.css" rel="stylesheet" type="text/css"></link>
|
||||
<script src="js/bootstrap-datetimepicker.js"></script>
|
||||
|
||||
|
||||
For **i18n** you should include js file from here: https://github.com/smalot/bootstrap-datetimepicker/tree/master/js/locales
|
||||
and set `language` option.
|
||||
|
||||
@ -30,14 +30,14 @@ $(function(){
|
||||
**/
|
||||
(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
|
||||
@ -46,13 +46,13 @@ $(function(){
|
||||
if(!this.options.viewformat) {
|
||||
this.options.viewformat = this.options.format;
|
||||
}
|
||||
|
||||
|
||||
//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';
|
||||
|
||||
@ -63,10 +63,10 @@ $(function(){
|
||||
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) {
|
||||
@ -75,8 +75,8 @@ $(function(){
|
||||
setTimeout(function(){
|
||||
f.triggerHandler('resize');
|
||||
}, 0);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
//"clear" link
|
||||
if(this.options.clear) {
|
||||
this.$clear = $('<a href="#"></a>').html(this.options.clear).click($.proxy(function(e){
|
||||
@ -84,11 +84,11 @@ $(function(){
|
||||
e.stopPropagation();
|
||||
this.clear();
|
||||
}, this));
|
||||
|
||||
|
||||
this.$tpl.parent().append($('<div class="editable-clear">').append(this.$clear));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
value2html: function(value, element) {
|
||||
//formatDate works with UTCDate!
|
||||
var text = value ? this.dpg.formatDate(this.toUTC(value), this.parsedViewFormat, this.options.datetimepicker.language, this.options.formatType) : '';
|
||||
@ -96,45 +96,45 @@ $(function(){
|
||||
DateTime.superclass.value2html(text, element);
|
||||
} else {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
html2value: function(html) {
|
||||
//parseDate return utc date!
|
||||
var value = this.parseDate(html, this.parsedViewFormat);
|
||||
return value ? this.fromUTC(value) : null;
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
value2str: function(value) {
|
||||
//formatDate works with UTCDate!
|
||||
return value ? this.dpg.formatDate(this.toUTC(value), this.parsedFormat, this.options.datetimepicker.language, this.options.formatType) : '';
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
str2value: function(str) {
|
||||
//parseDate return utc date!
|
||||
var value = this.parseDate(str, this.parsedFormat);
|
||||
return value ? this.fromUTC(value) : null;
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
value2submit: function(value) {
|
||||
return this.value2str(value);
|
||||
},
|
||||
},
|
||||
|
||||
value2input: function(value) {
|
||||
if(value) {
|
||||
this.$input.data('datetimepicker').setDate(value);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
input2value: function() {
|
||||
//date may be cleared, in that case getDate() triggers error
|
||||
var dt = this.$input.data('datetimepicker');
|
||||
return dt.date ? dt.getDate() : null;
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
activate: function() {
|
||||
},
|
||||
|
||||
|
||||
clear: function() {
|
||||
this.$input.data('datetimepicker').date = null;
|
||||
this.$input.find('.active').removeClass('active');
|
||||
@ -142,7 +142,7 @@ $(function(){
|
||||
this.$input.closest('form').submit();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
autosubmit: function() {
|
||||
this.$input.on('mouseup', '.minute', function(e){
|
||||
var $form = $(this).closest('form');
|
||||
@ -151,38 +151,38 @@ $(function(){
|
||||
}, 200);
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
//convert date from local to utc
|
||||
toUTC: function(value) {
|
||||
return value ? new Date(value.valueOf() - value.getTimezoneOffset() * 60000) : value;
|
||||
},
|
||||
|
||||
|
||||
//convert date from utc to local
|
||||
fromUTC: function(value) {
|
||||
return value ? new Date(value.valueOf() + value.getTimezoneOffset() * 60000) : value;
|
||||
},
|
||||
|
||||
|
||||
/*
|
||||
For incorrect date bootstrap-datetimepicker returns current date that is not suitable
|
||||
for datetimefield.
|
||||
This function returns null for incorrect date.
|
||||
*/
|
||||
parseDate: function(str, format) {
|
||||
var date = null, formattedBack;
|
||||
if(str) {
|
||||
date = this.dpg.parseDate(str, format, this.options.datetimepicker.language, this.options.formatType);
|
||||
if(typeof str === 'string') {
|
||||
formattedBack = this.dpg.formatDate(date, format, this.options.datetimepicker.language, this.options.formatType);
|
||||
if(str !== formattedBack) {
|
||||
date = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return date;
|
||||
}
|
||||
var date = null, formattedBack;
|
||||
if(str) {
|
||||
date = this.dpg.parseDate(str, format, this.options.datetimepicker.language, this.options.formatType);
|
||||
if(typeof str === 'string') {
|
||||
formattedBack = this.dpg.formatDate(date, format, this.options.datetimepicker.language, this.options.formatType);
|
||||
if(str !== formattedBack) {
|
||||
date = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
DateTime.defaults = $.extend({}, $.fn.editabletypes.abstractinput.defaults, {
|
||||
/**
|
||||
@property tpl
|
||||
@ -192,7 +192,7 @@ $(function(){
|
||||
/**
|
||||
@property inputclass
|
||||
@default null
|
||||
**/
|
||||
**/
|
||||
inputclass: null,
|
||||
/**
|
||||
Format used for sending value to server. Also applied when converting date from <code>data-value</code> attribute.<br>
|
||||
@ -211,12 +211,12 @@ $(function(){
|
||||
@property viewformat
|
||||
@type string
|
||||
@default null
|
||||
**/
|
||||
viewformat: null,
|
||||
**/
|
||||
viewformat: null,
|
||||
/**
|
||||
Configuration of datetimepicker.
|
||||
Full list of options: https://github.com/smalot/bootstrap-datetimepicker
|
||||
|
||||
|
||||
@property datetimepicker
|
||||
@type object
|
||||
@default { }
|
||||
@ -228,13 +228,13 @@ $(function(){
|
||||
/**
|
||||
Text shown as clear date button.
|
||||
If <code>false</code> clear button will not be rendered.
|
||||
|
||||
|
||||
@property clear
|
||||
@type boolean|string
|
||||
@default 'x clear'
|
||||
@default 'x clear'
|
||||
**/
|
||||
clear: '× clear'
|
||||
});
|
||||
});
|
||||
|
||||
$.fn.editabletypes.datetime = DateTime;
|
||||
|
||||
|
Reference in New Issue
Block a user