Fancybox vs Jquery UI Dialog

Benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
Fancybox
/*
 * FancyBox - jQuery Plugin
 * Simple and fancy lightbox alternative
 *
 * Examples and documentation at: http://fancybox.net
 *
 * Copyright (c) 2008 - 2010 Janis Skarnelis
 * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
 *
 * Version: 1.3.4 (11/11/2010)
 * Requires: jQuery v1.3+
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

;(function($) {
        var tmp, loading, overlay, wrap, outer, content, close, title, nav_left, nav_right,

                selectedIndex = 0, selectedOpts = {}, selectedArray = [], currentIndex = 0, currentOpts = {}, currentArray = [],

                ajaxLoader = null, imgPreloader = new Image(), imgRegExp = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i, swfRegExp = /[^\.]\.(swf)\s*$/i,

                loadingTimer, loadingFrame = 1,

                titleHeight = 0, titleStr = '', start_pos, final_pos, busy = false, fx = $.extend($('<div/>')[0], { prop: 0 }),

                isIE6 = $.browser.msie && $.browser.version < 7 && !window.XMLHttpRequest,

                /*
                 * Private methods 
                 */

                _abort = function() {
                        loading.hide();

                        imgPreloader.onerror = imgPreloader.onload = null;

                        if (ajaxLoader) {
                                ajaxLoader.abort();
                        }

                        tmp.empty();
                },

                _error = function() {
                        if (false === selectedOpts.onError(selectedArray, selectedIndex, selectedOpts)) {
                                loading.hide();
                                busy = false;
                                return;
                        }

                        selectedOpts.titleShow = false;

                        selectedOpts.width = 'auto';
                        selectedOpts.height = 'auto';

                        tmp.html( '<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>' );

                        _process_inline();
                },

                _start = function() {
                        var obj = selectedArray[ selectedIndex ],
                                href, 
                                type, 
                                title,
                                str,
                                emb,
                                ret;

                        _abort();

                        selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox')));

                        ret = selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts);

                        if (ret === false) {
                                busy = false;
                                return;
                        } else if (typeof ret == 'object') {
                                selectedOpts = $.extend(selectedOpts, ret);
                        }

                        title = selectedOpts.title || (obj.nodeName ? $(obj).attr('title') : obj.title) || '';

                        if (obj.nodeName && !selectedOpts.orig) {
                                selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj);
                        }

                        if (title === '' && selectedOpts.orig && selectedOpts.titleFromAlt) {
                                title = selectedOpts.orig.attr('alt');
                        }

                        href = selectedOpts.href || (obj.nodeName ? $(obj).attr('href') : obj.href) || null;

                        if ((/^(?:javascript)/i).test(href) || href == '#') {
                                href = null;
                        }

                        if (selectedOpts.type) {
                                type = selectedOpts.type;

                                if (!href) {
                                        href = selectedOpts.content;
                                }

                        } else if (selectedOpts.content) {
                                type = 'html';

                        } else if (href) {
                                if (href.match(imgRegExp)) {
                                        type = 'image';

                                } else if (href.match(swfRegExp)) {
                                        type = 'swf';

                                } else if ($(obj).hasClass("iframe")) {
                                        type = 'iframe';

                                } else if (href.indexOf("#") === 0) {
                                        type = 'inline';

                                } else {
                                        type = 'ajax';
                                }
                        }

                        if (!type) {
                                _error();
                                return;
                        }

                        if (type == 'inline') {
                                obj     = href.substr(href.indexOf("#"));
                                type = $(obj).length > 0 ? 'inline' : 'ajax';
                        }

                        selectedOpts.type = type;
                        selectedOpts.href = href;
                        selectedOpts.title = title;

                        if (selectedOpts.autoDimensions) {
                                if (selectedOpts.type == 'html' || selectedOpts.type == 'inline' || selectedOpts.type == 'ajax') {
                                        selectedOpts.width = 'auto';
                                        selectedOpts.height = 'auto';
                                } else {
                                        selectedOpts.autoDimensions = false;    
                                }
                        }

                        if (selectedOpts.modal) {
                                selectedOpts.overlayShow = true;
                                selectedOpts.hideOnOverlayClick = false;
                                selectedOpts.hideOnContentClick = false;
                                selectedOpts.enableEscapeButton = false;
                                selectedOpts.showCloseButton = false;
                        }

                        selectedOpts.padding = parseInt(selectedOpts.padding, 10);
                        selectedOpts.margin = parseInt(selectedOpts.margin, 10);

                        tmp.css('padding', (selectedOpts.padding + selectedOpts.margin));

                        $('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() {
                                $(this).replaceWith(content.children());                                
                        });

                        switch (type) {
                                case 'html' :
                                        tmp.html( selectedOpts.content );
                                        _process_inline();
                                break;

                                case 'inline' :
                                        if ( $(obj).parent().is('#fancybox-content') === true) {
                                                busy = false;
                                                return;
                                        }

                                        $('<div class="fancybox-inline-tmp" />')
                                                .hide()
                                                .insertBefore( $(obj) )
                                                .bind('fancybox-cleanup', function() {
                                                        $(this).replaceWith(content.children());
                                                }).bind('fancybox-cancel', function() {
                                                        $(this).replaceWith(tmp.children());
                                                });

                                        $(obj).appendTo(tmp);

                                        _process_inline();
                                break;

                                case 'image':
                                        busy = false;

                                        $.fancybox.showActivity();

                                        imgPreloader = new Image();

                                        imgPreloader.onerror = function() {
                                                _error();
                                        };

                                        imgPreloader.onload = function() {
                                                busy = true;

                                                imgPreloader.onerror = imgPreloader.onload = null;

                                                _process_image();
                                        };

                                        imgPreloader.src = href;
                                break;

                                case 'swf':
                                        selectedOpts.scrolling = 'no';

                                        str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"><param name="movie" value="' + href + '"></param>';
                                        emb = '';

                                        $.each(selectedOpts.swf, function(name, val) {
                                                str += '<param name="' + name + '" value="' + val + '"></param>';
                                                emb += ' ' + name + '="' + val + '"';
                                        });

                                        str += '<embed src="' + href + '" type="application/x-shockwave-flash" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"' + emb + '></embed></object>';

                                        tmp.html(str);

                                        _process_inline();
                                break;

                                case 'ajax':
                                        busy = false;

                                        $.fancybox.showActivity();

                                        selectedOpts.ajax.win = selectedOpts.ajax.success;

                                        ajaxLoader = $.ajax($.extend({}, selectedOpts.ajax, {
                                                url     : href,
                                                data : selectedOpts.ajax.data || {},
                                                error : function(XMLHttpRequest, textStatus, errorThrown) {
                                                        if ( XMLHttpRequest.status > 0 ) {
                                                                _error();
                                                        }
                                                },
                                                success : function(data, textStatus, XMLHttpRequest) {
                                                        var o = typeof XMLHttpRequest == 'object' ? XMLHttpRequest : ajaxLoader;
                                                        if (o.status == 200) {
                                                                if ( typeof selectedOpts.ajax.win == 'function' ) {
                                                                        ret = selectedOpts.ajax.win(href, data, textStatus, XMLHttpRequest);

                                                                        if (ret === false) {
                                                                                loading.hide();
                                                                                return;
                                                                        } else if (typeof ret == 'string' || typeof ret == 'object') {
                                                                                data = ret;
                                                                        }
                                                                }

                                                                tmp.html( data );
                                                                _process_inline();
                                                        }
                                                }
                                        }));

                                break;

                                case 'iframe':
                                        _show();
                                break;
                        }
                },

                _process_inline = function() {
                        var
                                w = selectedOpts.width,
                                h = selectedOpts.height;

                        if (w.toString().indexOf('%') > -1) {
                                w = parseInt( ($(window).width() - (selectedOpts.margin * 2)) * parseFloat(w) / 100, 10) + 'px';

                        } else {
                                w = w == 'auto' ? 'auto' : w + 'px';    
                        }

                        if (h.toString().indexOf('%') > -1) {
                                h = parseInt( ($(window).height() - (selectedOpts.margin * 2)) * parseFloat(h) / 100, 10) + 'px';

                        } else {
                                h = h == 'auto' ? 'auto' : h + 'px';    
                        }

                        tmp.wrapInner('<div style="width:' + w + ';height:' + h + ';overflow: ' + (selectedOpts.scrolling == 'auto' ? 'auto' : (selectedOpts.scrolling == 'yes' ? 'scroll' : 'hidden')) + ';position:relative;"></div>');

                        selectedOpts.width = tmp.width();
                        selectedOpts.height = tmp.height();

                        _show();
                },

                _process_image = function() {
                        selectedOpts.width = imgPreloader.width;
                        selectedOpts.height = imgPreloader.height;

                        $("<img />").attr({
                                'id' : 'fancybox-img',
                                'src' : imgPreloader.src,
                                'alt' : selectedOpts.title
                        }).appendTo( tmp );

                        _show();
                },

                _show = function() {
                        var pos, equal;

                        loading.hide();

                        if (wrap.is(":visible") && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
                                $.event.trigger('fancybox-cancel');

                                busy = false;
                                return;
                        }

                        busy = true;

                        $(content.add( overlay )).unbind();

                        $(window).unbind("resize.fb scroll.fb");
                        $(document).unbind('keydown.fb');

                        if (wrap.is(":visible") && currentOpts.titlePosition !== 'outside') {
                                wrap.css('height', wrap.height());
                        }

                        currentArray = selectedArray;
                        currentIndex = selectedIndex;
                        currentOpts = selectedOpts;

                        if (currentOpts.overlayShow) {
                                overlay.css({
                                        'background-color' : currentOpts.overlayColor,
                                        'opacity' : currentOpts.overlayOpacity,
                                        'cursor' : currentOpts.hideOnOverlayClick ? 'pointer' : 'auto',
                                        'height' : $(document).height()
                                });

                                if (!overlay.is(':visible')) {
                                        if (isIE6) {
                                                $('select:not(#fancybox-tmp select)').filter(function() {
                                                        return this.style.visibility !== 'hidden';
                                                }).css({'visibility' : 'hidden'}).one('fancybox-cleanup', function() {
                                                        this.style.visibility = 'inherit';
                                                });
                                        }

                                        overlay.show();
                                }
                        } else {
                                overlay.hide();
                        }

                        final_pos = _get_zoom_to();

                        _process_title();

                        if (wrap.is(":visible")) {
                                $( close.add( nav_left ).add( nav_right ) ).hide();

                                pos = wrap.position(),

                                start_pos = {
                                        top      : pos.top,
                                        left : pos.left,
                                        width : wrap.width(),
                                        height : wrap.height()
                                };

                                equal = (start_pos.width == final_pos.width && start_pos.height == final_pos.height);

                                content.fadeTo(currentOpts.changeFade, 0.3, function() {
                                        var finish_resizing = function() {
                                                content.html( tmp.contents() ).fadeTo(currentOpts.changeFade, 1, _finish);
                                        };

                                        $.event.trigger('fancybox-change');

                                        content
                                                .empty()
                                                .removeAttr('filter')
                                                .css({
                                                        'border-width' : currentOpts.padding,
                                                        'width' : final_pos.width - currentOpts.padding * 2,
                                                        'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2
                                                });

                                        if (equal) {
                                                finish_resizing();

                                        } else {
                                                fx.prop = 0;

                                                $(fx).animate({prop: 1}, {
                                                         duration : currentOpts.changeSpeed,
                                                         easing : currentOpts.easingChange,
                                                         step : _draw,
                                                         complete : finish_resizing
                                                });
                                        }
                                });

                                return;
                        }

                        wrap.removeAttr("style");

                        content.css('border-width', currentOpts.padding);

                        if (currentOpts.transitionIn == 'elastic') {
                                start_pos = _get_zoom_from();

                                content.html( tmp.contents() );

                                wrap.show();

                                if (currentOpts.opacity) {
                                        final_pos.opacity = 0;
                                }

                                fx.prop = 0;

                                $(fx).animate({prop: 1}, {
                                         duration : currentOpts.speedIn,
                                         easing : currentOpts.easingIn,
                                         step : _draw,
                                         complete : _finish
                                });

                                return;
                        }

                        if (currentOpts.titlePosition == 'inside' && titleHeight > 0) { 
                                title.show();   
                        }

                        content
                                .css({
                                        'width' : final_pos.width - currentOpts.padding * 2,
                                        'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2
                                })
                                .html( tmp.contents() );

                        wrap
                                .css(final_pos)
                                .fadeIn( currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish );
                },

                _format_title = function(title) {
                        if (title && title.length) {
                                if (currentOpts.titlePosition == 'float') {
                                        return '<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">' + title + '</td><td id="fancybox-title-float-right"></td></tr></table>';
                                }

                                return '<div id="fancybox-title-' + currentOpts.titlePosition + '">' + title + '</div>';
                        }

                        return false;
                },

                _process_title = function() {
                        titleStr = currentOpts.title || '';
                        titleHeight = 0;

                        title
                                .empty()
                                .removeAttr('style')
                                .removeClass();

                        if (currentOpts.titleShow === false) {
                                title.hide();
                                return;
                        }

                        titleStr = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(titleStr, currentArray, currentIndex, currentOpts) : _format_title(titleStr);

                        if (!titleStr || titleStr === '') {
                                title.hide();
                                return;
                        }

                        title
                                .addClass('fancybox-title-' + currentOpts.titlePosition)
                                .html( titleStr )
                                .appendTo( 'body' )
                                .show();

                        switch (currentOpts.titlePosition) {
                                case 'inside':
                                        title
                                                .css({
                                                        'width' : final_pos.width - (currentOpts.padding * 2),
                                                        'marginLeft' : currentOpts.padding,
                                                        'marginRight' : currentOpts.padding
                                                });

                                        titleHeight = title.outerHeight(true);

                                        title.appendTo( outer );

                                        final_pos.height += titleHeight;
                                break;

                                case 'over':
                                        title
                                                .css({
                                                        'marginLeft' : currentOpts.padding,
                                                        'width' : final_pos.width - (currentOpts.padding * 2),
                                                        'bottom' : currentOpts.padding
                                                })
                                                .appendTo( outer );
                                break;

                                case 'float':
                                        title
                                                .css('left', parseInt((title.width() - final_pos.width - 40)/ 2, 10) * -1)
                                                .appendTo( wrap );
                                break;

                                default:
                                        title
                                                .css({
                                                        'width' : final_pos.width - (currentOpts.padding * 2),
                                                        'paddingLeft' : currentOpts.padding,
                                                        'paddingRight' : currentOpts.padding
                                                })
                                                .appendTo( wrap );
                                break;
                        }

                        title.hide();
                },

                _set_navigation = function() {
                        if (currentOpts.enableEscapeButton || currentOpts.enableKeyboardNav) {
                                $(document).bind('keydown.fb', function(e) {
                                        if (e.keyCode == 27 && currentOpts.enableEscapeButton) {
                                                e.preventDefault();
                                                $.fancybox.close();

                                        } else if ((e.keyCode == 37 || e.keyCode == 39) && currentOpts.enableKeyboardNav && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') {
                                                e.preventDefault();
                                                $.fancybox[ e.keyCode == 37 ? 'prev' : 'next']();
                                        }
                                });
                        }

                        if (!currentOpts.showNavArrows) { 
                                nav_left.hide();
                                nav_right.hide();
                                return;
                        }

                        if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) {
                                nav_left.show();
                        }

                        if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length -1)) {
                                nav_right.show();
                        }
                },

                _finish = function () {
                        if (!$.support.opacity) {
                                content.get(0).style.removeAttribute('filter');
                                wrap.get(0).style.removeAttribute('filter');
                        }

                        if (selectedOpts.autoDimensions) {
                                content.css('height', 'auto');
                        }

                        wrap.css('height', 'auto');

                        if (titleStr && titleStr.length) {
                                title.show();
                        }

                        if (currentOpts.showCloseButton) {
                                close.show();
                        }

                        _set_navigation();
        
                        if (currentOpts.hideOnContentClick)     {
                                content.bind('click', $.fancybox.close);
                        }

                        if (currentOpts.hideOnOverlayClick)     {
                                overlay.bind('click', $.fancybox.close);
                        }

                        $(window).bind("resize.fb", $.fancybox.resize);

                        if (currentOpts.centerOnScroll) {
                                $(window).bind("scroll.fb", $.fancybox.center);
                        }

                        if (currentOpts.type == 'iframe') {
                                $('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" ' + ($.browser.msie ? 'allowtransparency="true""' : '') + ' scrolling="' + selectedOpts.scrolling + '" src="' + currentOpts.href + '"></iframe>').appendTo(content);
                        }

                        wrap.show();

                        busy = false;

                        $.fancybox.center();

                        currentOpts.onComplete(currentArray, currentIndex, currentOpts);

                        _preload_images();
                },

                _preload_images = function() {
                        var href, 
                                objNext;

                        if ((currentArray.length -1) > currentIndex) {
                                href = currentArray[ currentIndex + 1 ].href;

                                if (typeof href !== 'undefined' && href.match(imgRegExp)) {
                                        objNext = new Image();
                                        objNext.src = href;
                                }
                        }

                        if (currentIndex > 0) {
                                href = currentArray[ currentIndex - 1 ].href;

                                if (typeof href !== 'undefined' && href.match(imgRegExp)) {
                                        objNext = new Image();
                                        objNext.src = href;
                                }
                        }
                },

                _draw = function(pos) {
                        var dim = {
                                width : parseInt(start_pos.width + (final_pos.width - start_pos.width) * pos, 10),
                                height : parseInt(start_pos.height + (final_pos.height - start_pos.height) * pos, 10),

                                top : parseInt(start_pos.top + (final_pos.top - start_pos.top) * pos, 10),
                                left : parseInt(start_pos.left + (final_pos.left - start_pos.left) * pos, 10)
                        };

                        if (typeof final_pos.opacity !== 'undefined') {
                                dim.opacity = pos < 0.5 ? 0.5 : pos;
                        }

                        wrap.css(dim);

                        content.css({
                                'width' : dim.width - currentOpts.padding * 2,
                                'height' : dim.height - (titleHeight * pos) - currentOpts.padding * 2
                        });
                },

                _get_viewport = function() {
                        return [
                                $(window).width() - (currentOpts.margin * 2),
                                $(window).height() - (currentOpts.margin * 2),
                                $(document).scrollLeft() + currentOpts.margin,
                                $(document).scrollTop() + currentOpts.margin
                        ];
                },

                _get_zoom_to = function () {
                        var view = _get_viewport(),
                                to = {},
                                resize = currentOpts.autoScale,
                                double_padding = currentOpts.padding * 2,
                                ratio;

                        if (currentOpts.width.toString().indexOf('%') > -1) {
                                to.width = parseInt((view[0] * parseFloat(currentOpts.width)) / 100, 10);
                        } else {
                                to.width = currentOpts.width + double_padding;
                        }

                        if (currentOpts.height.toString().indexOf('%') > -1) {
                                to.height = parseInt((view[1] * parseFloat(currentOpts.height)) / 100, 10);
                        } else {
                                to.height = currentOpts.height + double_padding;
                        }

                        if (resize && (to.width > view[0] || to.height > view[1])) {
                                if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') {
                                        ratio = (currentOpts.width ) / (currentOpts.height );

                                        if ((to.width ) > view[0]) {
                                                to.width = view[0];
                                                to.height = parseInt(((to.width - double_padding) / ratio) + double_padding, 10);
                                        }

                                        if ((to.height) > view[1]) {
                                                to.height = view[1];
                                                to.width = parseInt(((to.height - double_padding) * ratio) + double_padding, 10);
                                        }

                                } else {
                                        to.width = Math.min(to.width, view[0]);
                                        to.height = Math.min(to.height, view[1]);
                                }
                        }

                        to.top = parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - to.height - 40) * 0.5)), 10);
                        to.left = parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - to.width - 40) * 0.5)), 10);

                        return to;
                },

                _get_obj_pos = function(obj) {
                        var pos = obj.offset();

                        pos.top += parseInt( obj.css('paddingTop'), 10 ) || 0;
                        pos.left += parseInt( obj.css('paddingLeft'), 10 ) || 0;

                        pos.top += parseInt( obj.css('border-top-width'), 10 ) || 0;
                        pos.left += parseInt( obj.css('border-left-width'), 10 ) || 0;

                        pos.width = obj.width();
                        pos.height = obj.height();

                        return pos;
                },

                _get_zoom_from = function() {
                        var orig = selectedOpts.orig ? $(selectedOpts.orig) : false,
                                from = {},
                                pos,
                                view;

                        if (orig && orig.length) {
                                pos = _get_obj_pos(orig);

                                from = {
                                        width : pos.width + (currentOpts.padding * 2),
                                        height : pos.height + (currentOpts.padding * 2),
                                        top     : pos.top - currentOpts.padding - 20,
                                        left : pos.left - currentOpts.padding - 20
                                };

                        } else {
                                view = _get_viewport();

                                from = {
                                        width : currentOpts.padding * 2,
                                        height : currentOpts.padding * 2,
                                        top     : parseInt(view[3] + view[1] * 0.5, 10),
                                        left : parseInt(view[2] + view[0] * 0.5, 10)
                                };
                        }

                        return from;
                },

                _animate_loading = function() {
                        if (!loading.is(':visible')){
                                clearInterval(loadingTimer);
                                return;
                        }

                        $('div', loading).css('top', (loadingFrame * -40) + 'px');

                        loadingFrame = (loadingFrame + 1) % 12;
                };

        /*
         * Public methods 
         */

        $.fn.fancybox = function(options) {
                if (!$(this).length) {
                        return this;
                }

                $(this)
                        .data('fancybox', $.extend({}, options, ($.metadata ? $(this).metadata() : {})))
                        .unbind('click.fb')
                        .bind('click.fb', function(e) {
                                e.preventDefault();

                                if (busy) {
                                        return;
                                }

                                busy = true;

                                $(this).blur();

                                selectedArray = [];
                                selectedIndex = 0;

                                var rel = $(this).attr('rel') || '';

                                if (!rel || rel == '' || rel === 'nofollow') {
                                        selectedArray.push(this);

                                } else {
                                        selectedArray = $("a[rel=" + rel + "], area[rel=" + rel + "]");
                                        selectedIndex = selectedArray.index( this );
                                }

                                _start();

                                return;
                        });

                return this;
        };

        $.fancybox = function(obj) {
                var opts;

                if (busy) {
                        return;
                }

                busy = true;
                opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {};

                selectedArray = [];
                selectedIndex = parseInt(opts.index, 10) || 0;

                if ($.isArray(obj)) {
                        for (var i = 0, j = obj.length; i < j; i++) {
                                if (typeof obj[i] == 'object') {
                                        $(obj[i]).data('fancybox', $.extend({}, opts, obj[i]));
                                } else {
                                        obj[i] = $({}).data('fancybox', $.extend({content : obj[i]}, opts));
                                }
                        }

                        selectedArray = jQuery.merge(selectedArray, obj);

                } else {
                        if (typeof obj == 'object') {
                                $(obj).data('fancybox', $.extend({}, opts, obj));
                        } else {
                                obj = $({}).data('fancybox', $.extend({content : obj}, opts));
                        }

                        selectedArray.push(obj);
                }

                if (selectedIndex > selectedArray.length || selectedIndex < 0) {
                        selectedIndex = 0;
                }

                _start();
        };

        $.fancybox.showActivity = function() {
                clearInterval(loadingTimer);

                loading.show();
                loadingTimer = setInterval(_animate_loading, 66);
        };

        $.fancybox.hideActivity = function() {
                loading.hide();
        };

        $.fancybox.next = function() {
                return $.fancybox.pos( currentIndex + 1);
        };

        $.fancybox.prev = function() {
                return $.fancybox.pos( currentIndex - 1);
        };

        $.fancybox.pos = function(pos) {
                if (busy) {
                        return;
                }

                pos = parseInt(pos);

                selectedArray = currentArray;

                if (pos > -1 && pos < currentArray.length) {
                        selectedIndex = pos;
                        _start();

                } else if (currentOpts.cyclic && currentArray.length > 1) {
                        selectedIndex = pos >= currentArray.length ? 0 : currentArray.length - 1;
                        _start();
                }

                return;
        };

        $.fancybox.cancel = function() {
                if (busy) {
                        return;
                }

                busy = true;

                $.event.trigger('fancybox-cancel');

                _abort();

                selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts);

                busy = false;
        };

        // Note: within an iframe use - parent.$.fancybox.close();
        $.fancybox.close = function() {
                if (busy || wrap.is(':hidden')) {
                        return;
                }

                busy = true;

                if (currentOpts && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
                        busy = false;
                        return;
                }

                _abort();

                $(close.add( nav_left ).add( nav_right )).hide();

                $(content.add( overlay )).unbind();

                $(window).unbind("resize.fb scroll.fb");
                $(document).unbind('keydown.fb');

                content.find('iframe').attr('src', isIE6 && /^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank');

                if (currentOpts.titlePosition !== 'inside') {
                        title.empty();
                }

                wrap.stop();

                function _cleanup() {
                        overlay.fadeOut('fast');

                        title.empty().hide();
                        wrap.hide();

                        $.event.trigger('fancybox-cleanup');

                        content.empty();

                        currentOpts.onClosed(currentArray, currentIndex, currentOpts);

                        currentArray = selectedOpts     = [];
                        currentIndex = selectedIndex = 0;
                        currentOpts = selectedOpts      = {};

                        busy = false;
                }

                if (currentOpts.transitionOut == 'elastic') {
                        start_pos = _get_zoom_from();

                        var pos = wrap.position();

                        final_pos = {
                                top      : pos.top ,
                                left : pos.left,
                                width : wrap.width(),
                                height : wrap.height()
                        };

                        if (currentOpts.opacity) {
                                final_pos.opacity = 1;
                        }

                        title.empty().hide();

                        fx.prop = 1;

                        $(fx).animate({ prop: 0 }, {
                                 duration : currentOpts.speedOut,
                                 easing : currentOpts.easingOut,
                                 step : _draw,
                                 complete : _cleanup
                        });

                } else {
                        wrap.fadeOut( currentOpts.transitionOut == 'none' ? 0 : currentOpts.speedOut, _cleanup);
                }
        };

        $.fancybox.resize = function() {
                if (overlay.is(':visible')) {
                        overlay.css('height', $(document).height());
                }

                $.fancybox.center(true);
        };

        $.fancybox.center = function() {
                var view, align;

                if (busy) {
                        return; 
                }

                align = arguments[0] === true ? 1 : 0;
                view = _get_viewport();

                if (!align && (wrap.width() > view[0] || wrap.height() > view[1])) {
                        return; 
                }

                wrap
                        .stop()
                        .animate({
                                'top' : parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - content.height() - 40) * 0.5) - currentOpts.padding)),
                                'left' : parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - content.width() - 40) * 0.5) - currentOpts.padding))
                        }, typeof arguments[0] == 'number' ? arguments[0] : 200);
        };

        $.fancybox.init = function() {
                if ($("#fancybox-wrap").length) {
                        return;
                }

                $('body').append(
                        tmp     = $('<div id="fancybox-tmp"></div>'),
                        loading = $('<div id="fancybox-loading"><div></div></div>'),
                        overlay = $('<div id="fancybox-overlay"></div>'),
                        wrap = $('<div id="fancybox-wrap"></div>')
                );

                outer = $('<div id="fancybox-outer"></div>')
                        .append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>')
                        .appendTo( wrap );

                outer.append(
                        content = $('<div id="fancybox-content"></div>'),
                        close = $('<a id="fancybox-close"></a>'),
                        title = $('<div id="fancybox-title"></div>'),

                        nav_left = $('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),
                        nav_right = $('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>')
                );

                close.click($.fancybox.close);
                loading.click($.fancybox.cancel);

                nav_left.click(function(e) {
                        e.preventDefault();
                        $.fancybox.prev();
                });

                nav_right.click(function(e) {
                        e.preventDefault();
                        $.fancybox.next();
                });

                if ($.fn.mousewheel) {
                        wrap.bind('mousewheel.fb', function(e, delta) {
                                if (busy) {
                                        e.preventDefault();

                                } else if ($(e.target).get(0).clientHeight == 0 || $(e.target).get(0).scrollHeight === $(e.target).get(0).clientHeight) {
                                        e.preventDefault();
                                        $.fancybox[ delta > 0 ? 'prev' : 'next']();
                                }
                        });
                }

                if (!$.support.opacity) {
                        wrap.addClass('fancybox-ie');
                }

                if (isIE6) {
                        loading.addClass('fancybox-ie6');
                        wrap.addClass('fancybox-ie6');

                        $('<iframe id="fancybox-hide-sel-frame" src="' + (/^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank' ) + '" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(outer);
                }
        };

        $.fn.fancybox.defaults = {
                padding : 10,
                margin : 40,
                opacity : false,
                modal : false,
                cyclic : false,
                scrolling : 'auto',     // 'auto', 'yes' or 'no'

                width : 560,
                height : 340,

                autoScale : true,
                autoDimensions : true,
                centerOnScroll : false,

                ajax : {},
                swf : { wmode: 'transparent' },

                hideOnOverlayClick : true,
                hideOnContentClick : false,

                overlayShow : true,
                overlayOpacity : 0.7,
                overlayColor : '#777',

                titleShow : true,
                titlePosition : 'float', // 'float', 'outside', 'inside' or 'over'
                titleFormat : null,
                titleFromAlt : false,

                transitionIn : 'fade', // 'elastic', 'fade' or 'none'
                transitionOut : 'fade', // 'elastic', 'fade' or 'none'

                speedIn : 300,
                speedOut : 300,

                changeSpeed : 300,
                changeFade : 'fast',

                easingIn : 'swing',
                easingOut : 'swing',

                showCloseButton  : true,
                showNavArrows : true,
                enableEscapeButton : true,
                enableKeyboardNav : true,

                onStart : function(){},
                onCancel : function(){},
                onComplete : function(){},
                onCleanup : function(){},
                onClosed : function(){},
                onError : function(){}
        };

        $(document).ready(function() {
                $.fancybox.init();
        });

})(jQuery);
ready
Jquery UI
/*!
 * jQuery UI 1.8.16
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI
 */
(function(c,j){function k(a,b){var d=a.nodeName.toLowerCase();if("area"===d){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&l(a)}return(/input|select|textarea|button|object/.test(d)?!a.disabled:"a"==d?a.href||b:b)&&l(a)}function l(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.16",
keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({propAttr:c.fn.prop||c.fn.attr,_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=
this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this,"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,
"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position");if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":
"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,m,n){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(m)g-=parseFloat(c.curCSS(f,"border"+this+"Width",true))||0;if(n)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,
outerWidth:c.fn.outerWidth,outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h,d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){return k(a,!isNaN(c.attr(a,"tabindex")))},tabbable:function(a){var b=c.attr(a,
"tabindex"),d=isNaN(b);return(d||b>=0)&&k(a,!d)}});c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&
a.element[0].parentNode)for(var e=0;e<b.length;e++)a.options[b[e][0]]&&b[e][1].apply(a.element,d)}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(a,b){if(c(a).css("overflow")==="hidden")return false;b=b&&b==="left"?"scrollLeft":"scrollTop";var d=false;if(a[b]>0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a<b+d},isOver:function(a,b,d,e,h,i){return c.ui.isOverAxis(a,d,h)&&
c.ui.isOverAxis(b,e,i)}})}})(jQuery);
;/*!
 * jQuery UI Widget 1.8.16
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Widget
 */
(function(b,j){if(b.cleanData){var k=b.cleanData;b.cleanData=function(a){for(var c=0,d;(d=a[c])!=null;c++)try{b(d).triggerHandler("remove")}catch(e){}k(a)}}else{var l=b.fn.remove;b.fn.remove=function(a,c){return this.each(function(){if(!c)if(!a||b.filter(a,[this]).length)b("*",this).add([this]).each(function(){try{b(this).triggerHandler("remove")}catch(d){}});return l.call(b(this),a,c)})}}b.widget=function(a,c,d){var e=a.split(".")[0],f;a=a.split(".")[1];f=e+"-"+a;if(!d){d=c;c=b.Widget}b.expr[":"][f]=
function(h){return!!b.data(h,a)};b[e]=b[e]||{};b[e][a]=function(h,g){arguments.length&&this._createWidget(h,g)};c=new c;c.options=b.extend(true,{},c.options);b[e][a].prototype=b.extend(true,c,{namespace:e,widgetName:a,widgetEventPrefix:b[e][a].prototype.widgetEventPrefix||a,widgetBaseClass:f},d);b.widget.bridge(a,b[e][a])};b.widget.bridge=function(a,c){b.fn[a]=function(d){var e=typeof d==="string",f=Array.prototype.slice.call(arguments,1),h=this;d=!e&&f.length?b.extend.apply(null,[true,d].concat(f)):
d;if(e&&d.charAt(0)==="_")return h;e?this.each(function(){var g=b.data(this,a),i=g&&b.isFunction(g[d])?g[d].apply(g,f):g;if(i!==g&&i!==j){h=i;return false}}):this.each(function(){var g=b.data(this,a);g?g.option(d||{})._init():b.data(this,a,new c(d,this))});return h}};b.Widget=function(a,c){arguments.length&&this._createWidget(a,c)};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(a,c){b.data(c,this.widgetName,this);this.element=b(c);this.options=
b.extend(true,{},this.options,this._getCreateOptions(),a);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return b.metadata&&b.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+
"-disabled ui-state-disabled")},widget:function(){return this.element},option:function(a,c){var d=a;if(arguments.length===0)return b.extend({},this.options);if(typeof a==="string"){if(c===j)return this.options[a];d={};d[a]=c}this._setOptions(d);return this},_setOptions:function(a){var c=this;b.each(a,function(d,e){c._setOption(d,e)});return this},_setOption:function(a,c){this.options[a]=c;if(a==="disabled")this.widget()[c?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",
c);return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(a,c,d){var e=this.options[a];c=b.Event(c);c.type=(a===this.widgetEventPrefix?a:this.widgetEventPrefix+a).toLowerCase();d=d||{};if(c.originalEvent){a=b.event.props.length;for(var f;a;){f=b.event.props[--a];c[f]=c.originalEvent[f]}}this.element.trigger(c,d);return!(b.isFunction(e)&&e.call(this.element[0],c,d)===false||c.isDefaultPrevented())}}})(jQuery);
;/*
 * jQuery UI Position 1.8.16
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Position
 */
(function(c){c.ui=c.ui||{};var n=/left|center|right/,o=/top|center|bottom/,t=c.fn.position,u=c.fn.offset;c.fn.position=function(b){if(!b||!b.of)return t.apply(this,arguments);b=c.extend({},b);var a=c(b.of),d=a[0],g=(b.collision||"flip").split(" "),e=b.offset?b.offset.split(" "):[0,0],h,k,j;if(d.nodeType===9){h=a.width();k=a.height();j={top:0,left:0}}else if(d.setTimeout){h=a.width();k=a.height();j={top:a.scrollTop(),left:a.scrollLeft()}}else if(d.preventDefault){b.at="left top";h=k=0;j={top:b.of.pageY,
left:b.of.pageX}}else{h=a.outerWidth();k=a.outerHeight();j=a.offset()}c.each(["my","at"],function(){var f=(b[this]||"").split(" ");if(f.length===1)f=n.test(f[0])?f.concat(["center"]):o.test(f[0])?["center"].concat(f):["center","center"];f[0]=n.test(f[0])?f[0]:"center";f[1]=o.test(f[1])?f[1]:"center";b[this]=f});if(g.length===1)g[1]=g[0];e[0]=parseInt(e[0],10)||0;if(e.length===1)e[1]=e[0];e[1]=parseInt(e[1],10)||0;if(b.at[0]==="right")j.left+=h;else if(b.at[0]==="center")j.left+=h/2;if(b.at[1]==="bottom")j.top+=
k;else if(b.at[1]==="center")j.top+=k/2;j.left+=e[0];j.top+=e[1];return this.each(function(){var f=c(this),l=f.outerWidth(),m=f.outerHeight(),p=parseInt(c.curCSS(this,"marginLeft",true))||0,q=parseInt(c.curCSS(this,"marginTop",true))||0,v=l+p+(parseInt(c.curCSS(this,"marginRight",true))||0),w=m+q+(parseInt(c.curCSS(this,"marginBottom",true))||0),i=c.extend({},j),r;if(b.my[0]==="right")i.left-=l;else if(b.my[0]==="center")i.left-=l/2;if(b.my[1]==="bottom")i.top-=m;else if(b.my[1]==="center")i.top-=
m/2;i.left=Math.round(i.left);i.top=Math.round(i.top);r={left:i.left-p,top:i.top-q};c.each(["left","top"],function(s,x){c.ui.position[g[s]]&&c.ui.position[g[s]][x](i,{targetWidth:h,targetHeight:k,elemWidth:l,elemHeight:m,collisionPosition:r,collisionWidth:v,collisionHeight:w,offset:e,my:b.my,at:b.at})});c.fn.bgiframe&&f.bgiframe();f.offset(c.extend(i,{using:b.using}))})};c.ui.position={fit:{left:function(b,a){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();b.left=
d>0?b.left-d:Math.max(b.left-a.collisionPosition.left,b.left)},top:function(b,a){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();b.top=d>0?b.top-d:Math.max(b.top-a.collisionPosition.top,b.top)}},flip:{left:function(b,a){if(a.at[0]!=="center"){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();var g=a.my[0]==="left"?-a.elemWidth:a.my[0]==="right"?a.elemWidth:0,e=a.at[0]==="left"?a.targetWidth:-a.targetWidth,h=-2*a.offset[0];b.left+=
a.collisionPosition.left<0?g+e+h:d>0?g+e+h:0}},top:function(b,a){if(a.at[1]!=="center"){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();var g=a.my[1]==="top"?-a.elemHeight:a.my[1]==="bottom"?a.elemHeight:0,e=a.at[1]==="top"?a.targetHeight:-a.targetHeight,h=-2*a.offset[1];b.top+=a.collisionPosition.top<0?g+e+h:d>0?g+e+h:0}}}};if(!c.offset.setOffset){c.offset.setOffset=function(b,a){if(/static/.test(c.curCSS(b,"position")))b.style.position="relative";var d=c(b),
g=d.offset(),e=parseInt(c.curCSS(b,"top",true),10)||0,h=parseInt(c.curCSS(b,"left",true),10)||0;g={top:a.top-g.top+e,left:a.left-g.left+h};"using"in a?a.using.call(b,g):d.css(g)};c.fn.offset=function(b){var a=this[0];if(!a||!a.ownerDocument)return null;if(b)return this.each(function(){c.offset.setOffset(this,b)});return u.call(this)}}})(jQuery);
;/*
 * jQuery UI Dialog 1.8.16
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Dialog
 *
 * Depends:
 *      jquery.ui.core.js
 *      jquery.ui.widget.js
 *  jquery.ui.button.js
 *      jquery.ui.draggable.js
 *      jquery.ui.mouse.js
 *      jquery.ui.position.js
 *      jquery.ui.resizable.js
 */
(function(c,l){var m={buttons:true,height:true,maxHeight:true,maxWidth:true,minHeight:true,minWidth:true,width:true},n={maxHeight:true,maxWidth:true,minHeight:true,minWidth:true},o=c.attrFn||{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true,click:true};c.widget("ui.dialog",{options:{autoOpen:true,buttons:{},closeOnEscape:true,closeText:"close",dialogClass:"",draggable:true,hide:null,height:"auto",maxHeight:false,maxWidth:false,minHeight:150,minWidth:150,modal:false,
position:{my:"center",at:"center",collision:"fit",using:function(a){var b=c(this).css(a).offset().top;b<0&&c(this).css("top",a.top-b)}},resizable:true,show:null,stack:true,title:"",width:300,zIndex:1E3},_create:function(){this.originalTitle=this.element.attr("title");if(typeof this.originalTitle!=="string")this.originalTitle="";this.options.title=this.options.title||this.originalTitle;var a=this,b=a.options,d=b.title||"&#160;",e=c.ui.dialog.getTitleId(a.element),g=(a.uiDialog=c("<div></div>")).appendTo(document.body).hide().addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+
b.dialogClass).css({zIndex:b.zIndex}).attr("tabIndex",-1).css("outline",0).keydown(function(i){if(b.closeOnEscape&&!i.isDefaultPrevented()&&i.keyCode&&i.keyCode===c.ui.keyCode.ESCAPE){a.close(i);i.preventDefault()}}).attr({role:"dialog","aria-labelledby":e}).mousedown(function(i){a.moveToTop(false,i)});a.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(g);var f=(a.uiDialogTitlebar=c("<div></div>")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(g),
h=c('<a href="#"></a>').addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").hover(function(){h.addClass("ui-state-hover")},function(){h.removeClass("ui-state-hover")}).focus(function(){h.addClass("ui-state-focus")}).blur(function(){h.removeClass("ui-state-focus")}).click(function(i){a.close(i);return false}).appendTo(f);(a.uiDialogTitlebarCloseText=c("<span></span>")).addClass("ui-icon ui-icon-closethick").text(b.closeText).appendTo(h);c("<span></span>").addClass("ui-dialog-title").attr("id",
e).html(d).prependTo(f);if(c.isFunction(b.beforeclose)&&!c.isFunction(b.beforeClose))b.beforeClose=b.beforeclose;f.find("*").add(f).disableSelection();b.draggable&&c.fn.draggable&&a._makeDraggable();b.resizable&&c.fn.resizable&&a._makeResizable();a._createButtons(b.buttons);a._isOpen=false;c.fn.bgiframe&&g.bgiframe()},_init:function(){this.options.autoOpen&&this.open()},destroy:function(){var a=this;a.overlay&&a.overlay.destroy();a.uiDialog.hide();a.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body");
a.uiDialog.remove();a.originalTitle&&a.element.attr("title",a.originalTitle);return a},widget:function(){return this.uiDialog},close:function(a){var b=this,d,e;if(false!==b._trigger("beforeClose",a)){b.overlay&&b.overlay.destroy();b.uiDialog.unbind("keypress.ui-dialog");b._isOpen=false;if(b.options.hide)b.uiDialog.hide(b.options.hide,function(){b._trigger("close",a)});else{b.uiDialog.hide();b._trigger("close",a)}c.ui.dialog.overlay.resize();if(b.options.modal){d=0;c(".ui-dialog").each(function(){if(this!==
b.uiDialog[0]){e=c(this).css("z-index");isNaN(e)||(d=Math.max(d,e))}});c.ui.dialog.maxZ=d}return b}},isOpen:function(){return this._isOpen},moveToTop:function(a,b){var d=this,e=d.options;if(e.modal&&!a||!e.stack&&!e.modal)return d._trigger("focus",b);if(e.zIndex>c.ui.dialog.maxZ)c.ui.dialog.maxZ=e.zIndex;if(d.overlay){c.ui.dialog.maxZ+=1;d.overlay.$el.css("z-index",c.ui.dialog.overlay.maxZ=c.ui.dialog.maxZ)}a={scrollTop:d.element.scrollTop(),scrollLeft:d.element.scrollLeft()};c.ui.dialog.maxZ+=1;
d.uiDialog.css("z-index",c.ui.dialog.maxZ);d.element.attr(a);d._trigger("focus",b);return d},open:function(){if(!this._isOpen){var a=this,b=a.options,d=a.uiDialog;a.overlay=b.modal?new c.ui.dialog.overlay(a):null;a._size();a._position(b.position);d.show(b.show);a.moveToTop(true);b.modal&&d.bind("keypress.ui-dialog",function(e){if(e.keyCode===c.ui.keyCode.TAB){var g=c(":tabbable",this),f=g.filter(":first");g=g.filter(":last");if(e.target===g[0]&&!e.shiftKey){f.focus(1);return false}else if(e.target===
f[0]&&e.shiftKey){g.focus(1);return false}}});c(a.element.find(":tabbable").get().concat(d.find(".ui-dialog-buttonpane :tabbable").get().concat(d.get()))).eq(0).focus();a._isOpen=true;a._trigger("open");return a}},_createButtons:function(a){var b=this,d=false,e=c("<div></div>").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),g=c("<div></div>").addClass("ui-dialog-buttonset").appendTo(e);b.uiDialog.find(".ui-dialog-buttonpane").remove();typeof a==="object"&&a!==null&&c.each(a,
function(){return!(d=true)});if(d){c.each(a,function(f,h){h=c.isFunction(h)?{click:h,text:f}:h;var i=c('<button type="button"></button>').click(function(){h.click.apply(b.element[0],arguments)}).appendTo(g);c.each(h,function(j,k){if(j!=="click")j in o?i[j](k):i.attr(j,k)});c.fn.button&&i.button()});e.appendTo(b.uiDialog)}},_makeDraggable:function(){function a(f){return{position:f.position,offset:f.offset}}var b=this,d=b.options,e=c(document),g;b.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",
handle:".ui-dialog-titlebar",containment:"document",start:function(f,h){g=d.height==="auto"?"auto":c(this).height();c(this).height(c(this).height()).addClass("ui-dialog-dragging");b._trigger("dragStart",f,a(h))},drag:function(f,h){b._trigger("drag",f,a(h))},stop:function(f,h){d.position=[h.position.left-e.scrollLeft(),h.position.top-e.scrollTop()];c(this).removeClass("ui-dialog-dragging").height(g);b._trigger("dragStop",f,a(h));c.ui.dialog.overlay.resize()}})},_makeResizable:function(a){function b(f){return{originalPosition:f.originalPosition,
originalSize:f.originalSize,position:f.position,size:f.size}}a=a===l?this.options.resizable:a;var d=this,e=d.options,g=d.uiDialog.css("position");a=typeof a==="string"?a:"n,e,s,w,se,sw,ne,nw";d.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:d.element,maxWidth:e.maxWidth,maxHeight:e.maxHeight,minWidth:e.minWidth,minHeight:d._minHeight(),handles:a,start:function(f,h){c(this).addClass("ui-dialog-resizing");d._trigger("resizeStart",f,b(h))},resize:function(f,h){d._trigger("resize",
f,b(h))},stop:function(f,h){c(this).removeClass("ui-dialog-resizing");e.height=c(this).height();e.width=c(this).width();d._trigger("resizeStop",f,b(h));c.ui.dialog.overlay.resize()}}).css("position",g).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var a=this.options;return a.height==="auto"?a.minHeight:Math.min(a.minHeight,a.height)},_position:function(a){var b=[],d=[0,0],e;if(a){if(typeof a==="string"||typeof a==="object"&&"0"in a){b=a.split?a.split(" "):
[a[0],a[1]];if(b.length===1)b[1]=b[0];c.each(["left","top"],function(g,f){if(+b[g]===b[g]){d[g]=b[g];b[g]=f}});a={my:b.join(" "),at:b.join(" "),offset:d.join(" ")}}a=c.extend({},c.ui.dialog.prototype.options.position,a)}else a=c.ui.dialog.prototype.options.position;(e=this.uiDialog.is(":visible"))||this.uiDialog.show();this.uiDialog.css({top:0,left:0}).position(c.extend({of:window},a));e||this.uiDialog.hide()},_setOptions:function(a){var b=this,d={},e=false;c.each(a,function(g,f){b._setOption(g,f);
if(g in m)e=true;if(g in n)d[g]=f});e&&this._size();this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",d)},_setOption:function(a,b){var d=this,e=d.uiDialog;switch(a){case "beforeclose":a="beforeClose";break;case "buttons":d._createButtons(b);break;case "closeText":d.uiDialogTitlebarCloseText.text(""+b);break;case "dialogClass":e.removeClass(d.options.dialogClass).addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+b);break;case "disabled":b?e.addClass("ui-dialog-disabled"):
e.removeClass("ui-dialog-disabled");break;case "draggable":var g=e.is(":data(draggable)");g&&!b&&e.draggable("destroy");!g&&b&&d._makeDraggable();break;case "position":d._position(b);break;case "resizable":(g=e.is(":data(resizable)"))&&!b&&e.resizable("destroy");g&&typeof b==="string"&&e.resizable("option","handles",b);!g&&b!==false&&d._makeResizable(b);break;case "title":c(".ui-dialog-title",d.uiDialogTitlebar).html(""+(b||"&#160;"));break}c.Widget.prototype._setOption.apply(d,arguments)},_size:function(){var a=
this.options,b,d,e=this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0});if(a.minWidth>a.width)a.width=a.minWidth;b=this.uiDialog.css({height:"auto",width:a.width}).height();d=Math.max(0,a.minHeight-b);if(a.height==="auto")if(c.support.minHeight)this.element.css({minHeight:d,height:"auto"});else{this.uiDialog.show();a=this.element.css("height","auto").height();e||this.uiDialog.hide();this.element.height(Math.max(a,d))}else this.element.height(Math.max(a.height-
b,0));this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())}});c.extend(c.ui.dialog,{version:"1.8.16",uuid:0,maxZ:0,getTitleId:function(a){a=a.attr("id");if(!a){this.uuid+=1;a=this.uuid}return"ui-dialog-title-"+a},overlay:function(a){this.$el=c.ui.dialog.overlay.create(a)}});c.extend(c.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:c.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(a){return a+".dialog-overlay"}).join(" "),
create:function(a){if(this.instances.length===0){setTimeout(function(){c.ui.dialog.overlay.instances.length&&c(document).bind(c.ui.dialog.overlay.events,function(d){if(c(d.target).zIndex()<c.ui.dialog.overlay.maxZ)return false})},1);c(document).bind("keydown.dialog-overlay",function(d){if(a.options.closeOnEscape&&!d.isDefaultPrevented()&&d.keyCode&&d.keyCode===c.ui.keyCode.ESCAPE){a.close(d);d.preventDefault()}});c(window).bind("resize.dialog-overlay",c.ui.dialog.overlay.resize)}var b=(this.oldInstances.pop()||
c("<div></div>").addClass("ui-widget-overlay")).appendTo(document.body).css({width:this.width(),height:this.height()});c.fn.bgiframe&&b.bgiframe();this.instances.push(b);return b},destroy:function(a){var b=c.inArray(a,this.instances);b!=-1&&this.oldInstances.push(this.instances.splice(b,1)[0]);this.instances.length===0&&c([document,window]).unbind(".dialog-overlay");a.remove();var d=0;c.each(this.instances,function(){d=Math.max(d,this.css("z-index"))});this.maxZ=d},height:function(){var a,b;if(c.browser.msie&&
c.browser.version<7){a=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);b=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight);return a<b?c(window).height()+"px":a+"px"}else return c(document).height()+"px"},width:function(){var a,b;if(c.browser.msie){a=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth);b=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth);return a<b?c(window).width()+"px":a+"px"}else return c(document).width()+
"px"},resize:function(){var a=c([]);c.each(c.ui.dialog.overlay.instances,function(){a=a.add(this)});a.css({width:0,height:0}).css({width:c.ui.dialog.overlay.width(),height:c.ui.dialog.overlay.height()})}});c.extend(c.ui.dialog.overlay.prototype,{destroy:function(){c.ui.dialog.overlay.destroy(this.$el)}})})(jQuery);
;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.