/** * Class: $.Drawer * Box wysuwające menu. */ (function ($, win, doc) { 'use strict'; if ($.isFunction($.fn.Drawer)) { return; } $.widget('pr.Drawer', { _version: '1.0.0 Beta', _create: function () { var _this = this; this.handle = 'drawer-' + (this.options.handle || 'left'); this.body = $('body'); this.intervalAutoHide = 0; this.delayAutoHide = this.options.delayAutoHide || (5 * 60000); this.element.on('click', function () { _this[_this.element.is('.active') ? 'hide' : 'show'](); return false; }); $('#' + this.options.handle).on('mouseenter', $.proxy(this._stopAutoHide, this)).on('mouseleave', $.proxy(this._startAutoHide, this)); $(doc).on('click', '.drawer-uuid-' + this.uuid + ', #' + this.options.handle + ' .closed-drawer', function () { _this.hide(); return false; }); this._trigger('onCreate'); }, show: function () { this.body.addClass(this.handle); this.element.addClass('active'); this._trigger('onShow'); $('
', { 'class': 'drawer-close drawer-uuid-' + this.uuid }).appendTo(this.body); }, hide: function () { this.body.removeClass(this.handle); this.element.removeClass('active'); this._trigger('onHide'); this._stopAutoHide(); $('.drawer-uuid-' + this.uuid).remove(); }, _startAutoHide: function () { this.intervalAutoHide = win.setTimeout($.proxy(this.hide, this), this.delayAutoHide); }, _stopAutoHide: function () { win.clearTimeout(this.intervalAutoHide); }, destroy: function () { this.hide(); $.Widget.prototype.destroy.call(this); } }); })(jQuery, window, document);