@@ -720,7 +720,7 @@ nb.define('popup-toggler', {
720720 if ( evt ) {
721721 evt . preventDefault ( ) ;
722722 }
723- if ( ! this . $node . hasClass ( '_nb-is-disabled' ) && this . popup && ! this . popup . isOpen ( ) ) {
723+ if ( this . isEnabled ( ) && this . popup && ! this . popup . isOpen ( ) ) {
724724 this . popup . open ( this . options ) ;
725725 this . trigger ( 'nb-opened' , this ) ;
726726 }
@@ -733,7 +733,7 @@ nb.define('popup-toggler', {
733733 * @returns {Object } nb.block
734734 */
735735 close : function ( ) {
736- if ( ! this . $node . hasClass ( '_nb-is-disabled' ) && this . popup && this . popup . isOpen ( ) ) {
736+ if ( this . isEnabled ( ) && this . popup && this . popup . isOpen ( ) ) {
737737 this . popup . close ( ) ;
738738 this . trigger ( 'nb-closed' , this ) ;
739739 }
@@ -814,6 +814,51 @@ nb.define('popup-toggler', {
814814 return this ;
815815 } ,
816816
817+ /**
818+ * Disable the toggler
819+ *
820+ * ```
821+ * popupToggler.disable();
822+ * ```
823+ *
824+ * @fires 'nb-disabled'
825+ * @return {Object } blocks for chaining
826+ */
827+ disable : function ( ) {
828+ this . _tabindex = this . $node . attr ( 'tabindex' ) ;
829+ this . $node . attr ( 'tabindex' , '-1' ) ;
830+ this . $node . addClass ( '_nb-is-disabled' ) ;
831+ this . trigger ( 'nb-disabled' , this ) ;
832+ return this ;
833+ } ,
834+
835+ /**
836+ * Enables the toggler
837+ *
838+ * ```
839+ * popupToggler.enable();
840+ * ```
841+ *
842+ * @fires 'nb-enabled'
843+ * @return {Object } blocks for chaining
844+ */
845+ enable : function ( ) {
846+ this . $node . attr ( 'tabindex' , this . _tabindex || '0' ) ;
847+ this . $node . removeClass ( '_nb-is-disabled' ) ;
848+ this . trigger ( 'nb-enabled' , this ) ;
849+ return this ;
850+ } ,
851+
852+ /**
853+ * Return state of the toggler
854+ *
855+ *
856+ * @return {Boolean }
857+ */
858+ isEnabled : function ( ) {
859+ return ! this . $node . hasClass ( '_nb-is-disabled' ) ;
860+ } ,
861+
817862 /**
818863 * Destroy the popup toggler
819864 * @fires 'nb-destroyed'
0 commit comments