Sha256: 9f55f604336440084f4d83d1428f76f5406bb6d7d9e3eec3ece9db58247cabb6
Contents?: true
Size: 1.63 KB
Versions: 80
Compression:
Stored size: 1.63 KB
Contents
/** * Module dependencies. */ var Emitter = require('emitter'); var tmpl = require('./template'); var o = require('dom'); /** * Expose `overlay()`. */ exports = module.exports = overlay; /** * Expose `Overlay`. */ exports.Overlay = Overlay; /** * Return a new `Overlay` with the given `options`. * * @param {Object|Element} options * @return {Overlay} * @api public */ function overlay(options){ options = options || {}; // element if (options.nodeName) { options = { target: options }; } return new Overlay(options); }; /** * Initialize a new `Overlay`. * * @param {Object} options * @api public */ function Overlay(options) { Emitter.call(this); options = options || {}; this.target = options.target || 'body'; this.closable = options.closable; this.el = o(tmpl); this.el.appendTo(this.target); if (this.closable) this.el.on('click', this.hide.bind(this)); } /** * Mixin emitter. */ Emitter(Overlay.prototype); /** * Show the overlay. * * Emits "show" event. * * @return {Overlay} * @api public */ Overlay.prototype.show = function(){ this.emit('show'); this.el.removeClass('hide'); return this; }; /** * Hide the overlay. * * Emits "hide" event. * * @return {Overlay} * @api public */ Overlay.prototype.hide = function(){ this.emit('hide'); return this.remove(); }; /** * Hide the overlay without emitting "hide". * * Emits "close" event. * * @return {Overlay} * @api public */ Overlay.prototype.remove = function(){ var self = this; this.emit('close'); this.el.addClass('hide'); setTimeout(function(){ self.el.remove(); }, 2000); return this; };
Version data entries
80 entries across 80 versions & 1 rubygems