From ef46499ab8b3cdb8f432e3be701056f2a74e7c33 Mon Sep 17 00:00:00 2001 From: "Chakib.B (Spike)" Date: Tue, 3 Apr 2012 12:23:12 +0200 Subject: [PATCH] Add fadeIn and fadeOut methods --- js/bootstrap-magic-button.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/js/bootstrap-magic-button.js b/js/bootstrap-magic-button.js index 6ed8620..9afee1c 100644 --- a/js/bootstrap-magic-button.js +++ b/js/bootstrap-magic-button.js @@ -130,9 +130,24 @@ function ($) { 'background-image': (this.$isToggled) ? this.$toggleImgUrl : this.$imgUrl }).show() this.$shown = true - } + }, - , + fadeIn: function () { + this.calculatePosition() + var $o = this.options + this.$element.fadeIn('fast').css({ + top: this.$top, + left: this.$left, + 'background-image': (this.$isToggled) ? this.$toggleImgUrl : this.$imgUrl + }) + this.$shown = true + }, + + fadeOut: function () { + this.$element.fadeOut(10) + this.$shown = false + }, + hide: function () { this.$element.hide() this.$shown = false @@ -184,6 +199,8 @@ function ($) { data.calculatePosition('right') if (option == 'toggle') data.toggle() if (option == 'show') data.show() + if (option == 'fadeIn') data.fadeIn() + if (option == 'fadeOut') data.fadeOut() if (option == 'hide') data.hide() else if (option) data.setState(option)