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