preventDefault only if toggle=click
This commit is contained in:
@@ -74,8 +74,13 @@ Makes editable any HTML element on the page. Applied as jQuery method.
|
||||
//add 'editable' class
|
||||
this.$element.addClass('editable');
|
||||
|
||||
//always attach click handler, but in disabled mode it just prevent default action (useful for links)
|
||||
this.$element.on('click.editable', $.proxy(this.click, this));
|
||||
//attach click handler. In disabled mode it just prevent default action (useful for links)
|
||||
if(this.options.toggle === 'click') {
|
||||
this.$element.addClass('editable-click');
|
||||
this.$element.on('click.editable', $.proxy(this.click, this));
|
||||
} else {
|
||||
this.$element.attr('tabindex', -1); //do not stop focus on element when toggled manually
|
||||
}
|
||||
|
||||
//check conditions for autotext:
|
||||
//if value was generated by text or value is empty, no sense to run autotext
|
||||
@@ -114,8 +119,7 @@ Makes editable any HTML element on the page. Applied as jQuery method.
|
||||
this.$element.removeClass('editable-disabled');
|
||||
this.handleEmpty();
|
||||
if(this.options.toggle === 'click') {
|
||||
this.$element.addClass('editable-click');
|
||||
if(this.$element.attr('tabindex') === -1) {
|
||||
if(this.$element.attr('tabindex') === '-1') {
|
||||
this.$element.removeAttr('tabindex');
|
||||
}
|
||||
}
|
||||
@@ -128,12 +132,10 @@ Makes editable any HTML element on the page. Applied as jQuery method.
|
||||
disable: function() {
|
||||
this.options.disabled = true;
|
||||
this.hide();
|
||||
this.$element.addClass('editable-disabled');
|
||||
this.$element.addClass('editable-disabled')
|
||||
this.handleEmpty();
|
||||
if(this.options.toggle === 'click') {
|
||||
this.$element.removeClass('editable-click');
|
||||
this.$element.attr('tabindex', -1);
|
||||
}
|
||||
//do not stop focus on this element
|
||||
this.$element.attr('tabindex', -1);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -196,10 +198,10 @@ Makes editable any HTML element on the page. Applied as jQuery method.
|
||||
|
||||
click: function (e) {
|
||||
e.preventDefault();
|
||||
if(this.options.disabled || this.options.toggle !== 'click') {
|
||||
if(this.options.disabled) {
|
||||
return;
|
||||
}
|
||||
//stop propagation bacause document listen any click to hide all containers
|
||||
//stop propagation bacause document listen any click to hide all editableContainers
|
||||
e.stopPropagation();
|
||||
this.toggle();
|
||||
},
|
||||
|
Reference in New Issue
Block a user