Skip to content

Commit

Permalink
Enable/disable prashantchaudhary#55
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasz Przybysz committed Aug 27, 2017
1 parent 9158eb2 commit 6982088
Showing 1 changed file with 39 additions and 21 deletions.
60 changes: 39 additions & 21 deletions jquery.ddslick.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,24 @@
});
}

//Public method to disable dropdown
methods.disable = function () {
return this.each(function () {
var $this = $(this);

$this.addClass('dd-disabled');
});
};

//Public method to enable a disabled dropdown
methods.enable = function () {
return this.each(function () {
var $this = $(this);
if ($this.hasClass('dd-disabled'))
$this.removeClass('dd-disabled');
});
};

//Private: Select id
function selectId(obj, id) {

Expand Down Expand Up @@ -299,30 +317,30 @@

//Private: Close the drop down options
function open(obj) {
if (!obj.hasClass('dd-disabled')) {
var $this = obj.find('.dd-select'),
ddOptions = $this.siblings('.dd-options'),
ddPointer = $this.find('.dd-pointer'),
wasOpen = ddOptions.is(':visible');

//Close all open options (multiple plugins) on the page
$('.dd-click-off-close').not(ddOptions).slideUp(50);
$('.dd-pointer').removeClass('dd-pointer-up');
$this.removeClass('dd-open');

var $this = obj.find('.dd-select'),
ddOptions = $this.siblings('.dd-options'),
ddPointer = $this.find('.dd-pointer'),
wasOpen = ddOptions.is(':visible');

//Close all open options (multiple plugins) on the page
$('.dd-click-off-close').not(ddOptions).slideUp(50);
$('.dd-pointer').removeClass('dd-pointer-up');
$this.removeClass('dd-open');
if (wasOpen) {
ddOptions.slideUp('fast');
ddPointer.removeClass('dd-pointer-up');
$this.removeClass('dd-open');
} else {
$this.addClass('dd-open');
ddOptions.slideDown('fast');
ddPointer.addClass('dd-pointer-up');
}

if (wasOpen) {
ddOptions.slideUp('fast');
ddPointer.removeClass('dd-pointer-up');
$this.removeClass('dd-open');
//Fix text height (i.e. display title in center), if there is no description
adjustOptionsHeight(obj);
}
else {
$this.addClass('dd-open');
ddOptions.slideDown('fast');
ddPointer.addClass('dd-pointer-up');
}

//Fix text height (i.e. display title in center), if there is no description
adjustOptionsHeight(obj);
}

//Private: Close the drop down options
Expand Down

0 comments on commit 6982088

Please sign in to comment.