Last active
August 16, 2016 18:28
-
-
Save alexpts/fa28f3cbb56ff034b105c0688bc03935 to your computer and use it in GitHub Desktop.
Example js module 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($, $popover) { | |
/** | |
* @param {{}|undefined}options | |
* @returns {{on: Function, off: Function}} | |
* @constructor | |
*/ | |
var Popover = function (options) { | |
options = $.extend({ | |
delegateElement: document, | |
}, options || {}); | |
/** | |
* @param {Event} event | |
*/ | |
var _close = function (event) { | |
$('.popover').popover('hide'); | |
}; | |
// public | |
return { | |
on: function () { | |
$(options.delegateElement) | |
.on('click', '.popover .close', _close) | |
.on('show.bs.popover', _close); | |
}, | |
off: function () { | |
$(options.delegateElement) | |
.off('click', '.popover .close', _close) | |
.off('show.bs.popover', _close); | |
} | |
}; | |
}; | |
// pass module to app, one of way | |
$(document).trigger('js.load', ['popover', Popover]); | |
})(jQuery, jQuery.fn.popover); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment