$.fn.modal = function (option) { return this.each(function () { var $this = $(this) , data = $this.data('modal') , options = $.extend( {}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option ) if (!data) $this.data( 'modal', (data = new Modal(this, options)) ) if (typeof option == 'string') data[option]() else if (options.show) data.show() }) }