allow follow links in disabled state

This commit is contained in:
vitalets 2013-05-20 00:14:22 +04:00
parent a12a01b07f
commit 9c77ecaa32
2 changed files with 7 additions and 4 deletions

@ -3,6 +3,7 @@ X-editable changelog
Version 1.4.5 wip Version 1.4.5 wip
---------------------------- ----------------------------
[enh] allow follow links in disabled state (vitalets)
[enh] update combodate to 1.0.4, fix #222 (vitalets) [enh] update combodate to 1.0.4, fix #222 (vitalets)

@ -60,20 +60,22 @@ Makes editable any HTML element on the page. Applied as jQuery method.
if(this.options.toggle !== 'manual') { if(this.options.toggle !== 'manual') {
this.$element.addClass('editable-click'); this.$element.addClass('editable-click');
this.$element.on(this.options.toggle + '.editable', $.proxy(function(e){ this.$element.on(this.options.toggle + '.editable', $.proxy(function(e){
//prevent following link //prevent following link if editable enabled
e.preventDefault(); if(!this.options.disabled) {
e.preventDefault();
}
//stop propagation not required because in document click handler it checks event target //stop propagation not required because in document click handler it checks event target
//e.stopPropagation(); //e.stopPropagation();
if(this.options.toggle === 'mouseenter') { if(this.options.toggle === 'mouseenter') {
//for hover only show container //for hover only show container
this.show(); this.show();
} else { } else {
//when toggle='click' we should not close all other containers as they will be closed automatically in document click listener //when toggle='click' we should not close all other containers as they will be closed automatically in document click listener
var closeAll = (this.options.toggle !== 'click'); var closeAll = (this.options.toggle !== 'click');
this.toggle(closeAll); this.toggle(closeAll);
} }
}, this)); }, this));
} else { } else {
this.$element.attr('tabindex', -1); //do not stop focus on element when toggled manually this.$element.attr('tabindex', -1); //do not stop focus on element when toggled manually