fix lint errors
This commit is contained in:
parent
46d77f50bb
commit
89cccbb860
src
containers
editable-form
element
inputs
@ -141,13 +141,13 @@ Applied as jQuery method.
|
||||
nochange: $.proxy(function(){ this.hide('nochange'); }, this), //click on submit button (value NOT changed)
|
||||
cancel: $.proxy(function(){ this.hide('cancel'); }, this), //click on calcel button
|
||||
show: $.proxy(function() {
|
||||
if(this.delayedHide) {
|
||||
this.hide(this.delayedHide.reason);
|
||||
this.delayedHide = false;
|
||||
} else {
|
||||
this.setPosition();
|
||||
}
|
||||
}, this), //re-position container every time form is shown (occurs each time after loading state)
|
||||
if(this.delayedHide) {
|
||||
this.hide(this.delayedHide.reason);
|
||||
this.delayedHide = false;
|
||||
} else {
|
||||
this.setPosition();
|
||||
}
|
||||
}, this), //re-position container every time form is shown (occurs each time after loading state)
|
||||
rendering: $.proxy(this.setPosition, this), //this allows to place container correctly when loading shown
|
||||
resize: $.proxy(this.setPosition, this), //this allows to re-position container when form size is changed
|
||||
rendered: $.proxy(function(){
|
||||
@ -230,11 +230,11 @@ Applied as jQuery method.
|
||||
|
||||
//if form is saving value, schedule hide
|
||||
if(this.$form.data('editableform').isSaving) {
|
||||
this.delayedHide = {reason: reason};
|
||||
return;
|
||||
} else {
|
||||
this.delayedHide = false;
|
||||
}
|
||||
this.delayedHide = {reason: reason};
|
||||
return;
|
||||
} else {
|
||||
this.delayedHide = false;
|
||||
}
|
||||
|
||||
this.$element.removeClass('editable-open');
|
||||
this.innerHide();
|
||||
|
@ -222,16 +222,21 @@
|
||||
|
||||
//see http://stackoverflow.com/questions/7264899/detect-css-transitions-using-javascript-and-without-modernizr
|
||||
supportsTransitions: function () {
|
||||
var b = document.body || document.documentElement;
|
||||
var s = b.style;
|
||||
var p = 'transition';
|
||||
if(typeof s[p] == 'string') {return true; }
|
||||
var b = document.body || document.documentElement,
|
||||
s = b.style,
|
||||
p = 'transition',
|
||||
v = ['Moz', 'Webkit', 'Khtml', 'O', 'ms'];
|
||||
|
||||
if(typeof s[p] === 'string') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Tests for vendor specific prop
|
||||
v = ['Moz', 'Webkit', 'Khtml', 'O', 'ms'],
|
||||
p = p.charAt(0).toUpperCase() + p.substr(1);
|
||||
for(var i=0; i<v.length; i++) {
|
||||
if(typeof s[v[i] + p] == 'string') { return true; }
|
||||
if(typeof s[v[i] + p] === 'string') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
|
||||
//sending data to server
|
||||
$.when(this.save(submitValue))
|
||||
.done($.proxy(function(response) {
|
||||
this.isSaving = false;
|
||||
this.isSaving = false;
|
||||
|
||||
//run success callback
|
||||
var res = typeof this.options.success === 'function' ? this.options.success.call(this.options.scope, response, newValue) : null;
|
||||
@ -269,7 +269,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
|
||||
this.$div.triggerHandler('save', {newValue: newValue, submitValue: submitValue, response: response});
|
||||
}, this))
|
||||
.fail($.proxy(function(xhr) {
|
||||
this.isSaving = false;
|
||||
this.isSaving = false;
|
||||
|
||||
var msg;
|
||||
if(typeof this.options.error === 'function') {
|
||||
|
@ -89,7 +89,7 @@ Makes editable any HTML element on the page. Applied as jQuery method.
|
||||
//if display is function it's far more convinient to have autotext = always to render correctly on init
|
||||
//see https://github.com/vitalets/x-editable-yii/issues/34
|
||||
if(typeof this.options.display === 'function') {
|
||||
this.options.autotext = 'always'
|
||||
this.options.autotext = 'always';
|
||||
}
|
||||
|
||||
//check conditions for autotext:
|
||||
@ -277,17 +277,17 @@ Makes editable any HTML element on the page. Applied as jQuery method.
|
||||
*/
|
||||
if(isEmpty !== undefined) {
|
||||
this.isEmpty = isEmpty;
|
||||
} else {
|
||||
//detect empty
|
||||
if($.trim(this.$element.html()) === '') {
|
||||
this.isEmpty = true;
|
||||
} else if($.trim(this.$element.text()) !== '') {
|
||||
this.isEmpty = false;
|
||||
} else {
|
||||
//e.g. '<img>'
|
||||
this.isEmpty = !this.$element.height() || !this.$element.width();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//detect empty
|
||||
if($.trim(this.$element.html()) === '') {
|
||||
this.isEmpty = true;
|
||||
} else if($.trim(this.$element.text()) !== '') {
|
||||
this.isEmpty = false;
|
||||
} else {
|
||||
//e.g. '<img>'
|
||||
this.isEmpty = !this.$element.height() || !this.$element.width();
|
||||
}
|
||||
}
|
||||
|
||||
//emptytext shown only for enabled
|
||||
if(!this.options.disabled) {
|
||||
@ -546,15 +546,15 @@ Makes editable any HTML element on the page. Applied as jQuery method.
|
||||
**/
|
||||
case 'getValue':
|
||||
if(arguments.length === 2 && arguments[1] === true) { //isSingle = true
|
||||
result = this.eq(0).data(datakey).value;
|
||||
} else {
|
||||
this.each(function () {
|
||||
var $this = $(this), data = $this.data(datakey);
|
||||
if (data && data.value !== undefined && data.value !== null) {
|
||||
result[data.options.name] = data.input.value2submit(data.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
result = this.eq(0).data(datakey).value;
|
||||
} else {
|
||||
this.each(function () {
|
||||
var $this = $(this), data = $this.data(datakey);
|
||||
if (data && data.value !== undefined && data.value !== null) {
|
||||
result[data.options.name] = data.input.value2submit(data.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
|
||||
/**
|
||||
|
@ -155,8 +155,8 @@ To create your own input you can inherit from this class.
|
||||
/**
|
||||
Additional actions when destroying element
|
||||
**/
|
||||
destroy: function() {
|
||||
},
|
||||
destroy: function() {
|
||||
},
|
||||
|
||||
// -------- helper functions --------
|
||||
setClass: function() {
|
||||
|
@ -82,51 +82,51 @@ $(function(){
|
||||
Date.superclass.value2html(text, element);
|
||||
},
|
||||
|
||||
html2value: function(html) {
|
||||
return this.parseDate(html, this.parsedViewFormat);
|
||||
},
|
||||
html2value: function(html) {
|
||||
return this.parseDate(html, this.parsedViewFormat);
|
||||
},
|
||||
|
||||
value2str: function(value) {
|
||||
return value ? this.dpg.formatDate(value, this.parsedFormat, this.options.datepicker.language) : '';
|
||||
},
|
||||
value2str: function(value) {
|
||||
return value ? this.dpg.formatDate(value, this.parsedFormat, this.options.datepicker.language) : '';
|
||||
},
|
||||
|
||||
str2value: function(str) {
|
||||
return this.parseDate(str, this.parsedFormat);
|
||||
},
|
||||
str2value: function(str) {
|
||||
return this.parseDate(str, this.parsedFormat);
|
||||
},
|
||||
|
||||
value2submit: function(value) {
|
||||
return this.value2str(value);
|
||||
},
|
||||
value2submit: function(value) {
|
||||
return this.value2str(value);
|
||||
},
|
||||
|
||||
value2input: function(value) {
|
||||
this.$input.bdatepicker('update', value);
|
||||
},
|
||||
value2input: function(value) {
|
||||
this.$input.bdatepicker('update', value);
|
||||
},
|
||||
|
||||
input2value: function() {
|
||||
return this.$input.data('datepicker').date;
|
||||
},
|
||||
input2value: function() {
|
||||
return this.$input.data('datepicker').date;
|
||||
},
|
||||
|
||||
activate: function() {
|
||||
},
|
||||
activate: function() {
|
||||
},
|
||||
|
||||
clear: function() {
|
||||
this.$input.data('datepicker').date = null;
|
||||
this.$input.find('.active').removeClass('active');
|
||||
if(!this.options.showbuttons) {
|
||||
this.$input.closest('form').submit();
|
||||
}
|
||||
},
|
||||
clear: function() {
|
||||
this.$input.data('datepicker').date = null;
|
||||
this.$input.find('.active').removeClass('active');
|
||||
if(!this.options.showbuttons) {
|
||||
this.$input.closest('form').submit();
|
||||
}
|
||||
},
|
||||
|
||||
autosubmit: function() {
|
||||
this.$input.on('mouseup', '.day', function(e){
|
||||
if($(e.currentTarget).is('.old') || $(e.currentTarget).is('.new')) {
|
||||
return;
|
||||
}
|
||||
var $form = $(this).closest('form');
|
||||
setTimeout(function() {
|
||||
$form.submit();
|
||||
}, 200);
|
||||
});
|
||||
autosubmit: function() {
|
||||
this.$input.on('mouseup', '.day', function(e){
|
||||
if($(e.currentTarget).is('.old') || $(e.currentTarget).is('.new')) {
|
||||
return;
|
||||
}
|
||||
var $form = $(this).closest('form');
|
||||
setTimeout(function() {
|
||||
$form.submit();
|
||||
}, 200);
|
||||
});
|
||||
//changedate is not suitable as it triggered when showing datepicker. see #149
|
||||
/*
|
||||
this.$input.on('changeDate', function(e){
|
||||
@ -144,18 +144,18 @@ $(function(){
|
||||
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.datepicker.language);
|
||||
if(typeof str === 'string') {
|
||||
formattedBack = this.dpg.formatDate(date, format, this.options.datepicker.language);
|
||||
if(str !== formattedBack) {
|
||||
date = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return date;
|
||||
}
|
||||
var date = null, formattedBack;
|
||||
if(str) {
|
||||
date = this.dpg.parseDate(str, format, this.options.datepicker.language);
|
||||
if(typeof str === 'string') {
|
||||
formattedBack = this.dpg.formatDate(date, format, this.options.datepicker.language);
|
||||
if(str !== formattedBack) {
|
||||
date = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
@ -168,18 +168,18 @@ $(function(){
|
||||
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;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user