; (function ($){ $.fn.show_popdown = function (uri, options){ if (_AN_Read_length('length', $('#popdown-opacity')) > 0) { $('#popdown-opacity').remove(); } opacity = $('
').attr('id', 'popdown-opacity').css({ position: 'absolute', top: 0, left: 0, width: $(document).outerWidth(true ), height: $(document).outerHeight(true ), zIndex: 99998, display: 'none'} ); container = $('').attr('id', 'popdown-dialog').css({ maxWidth: options.width, height: options.height, zIndex: 99999, margin: '0 auto', position: 'relative', display: 'none'} ); $('body').append(opacity); $('#popdown-opacity').fadeIn(100).append(container); $('#popdown-opacity').append(container).stop().animate({ opacity: 1} , 100, function (){ $('#popdown-dialog').fadeIn(50, function (){ $.get(uri, function (resp){ $('#popdown-dialog').html(resp).addClass('popdown-done').removeClass('popdown-loading'); $("html, body").animate({ scrollTop: 0} , "fast"); } ); } ); } ); } ; $.fn.close_popdown = function (){ if (_AN_Read_length("length", $('#popdown-opacity')) > 0) { $('#popdown-dialog').stop().animate({ opacity: 0, height: 0} , 200, function (){ $('#popdown-opacity').remove(); } ); } } ; $.fn.popdown = function (options){ var defaults = { width: 610, height: 'auto'} ; var options = $.extend(defaults, options); $(window).resize(function (){ if (_AN_Read_length('length', $('#popdown-opacity')) > 0) { $('#popdown-opacity').css({ width: $(document).outerWidth(), height: $(document).outerHeight()} ); } } ); $(document).keyup(function (e){ if (e.keyCode === 27) { $.fn.close_popdown(); } } ); $(document).on('click', '.close-popdown', function (e){ if (!$(this).is('.close-popdown')) { e.preventDefault(); } $.fn.close_popdown(); } ); $(document).click(function (event){ if (!_AN_Read_length('length', $(_AN_Read_target('target', event)).closest('#popdown-dialog'))) { if ($('#popdown-dialog').is(":visible")) { $.fn.close_popdown(); } } } ); return this.each(function (){ var self = $(this); self.bind('click', function (e){ if (self.is('a')) { e.preventDefault(); } if ($('#popdown-opacity').is(':visible')) { $.fn.close_popdown(); } else { if (self.data('uri')) { $.fn.show_popdown(self.data('uri'), options); } else if (self.attr('href')) { $.fn.show_popdown(self.attr('href'), options); } else { alert("No popdown dialog set for this action."); } } } ); } ); } ; } )(jQuery);