Make WordPress Core

Changeset 29847


Ignore:
Timestamp:
10/07/2014 03:27:56 PM (11 years ago)
Author:
ocean90
Message:

Update jQuery UI to 1.11.1.

Because jQUI's build process no longer provides individual minified files we need some additional changes:

  • Rename all files, remove the "jquery.ui." prefix. Add old files to $_old_files.
  • Add and use non-minified files in /src.
  • Add grunt task to minify jQuery UI files.
  • (Non-minified files will not be shipped.)

Changelogs:

props Fab1en, ocean90.
fixes #29833.

Location:
trunk
Files:
3 added
3 edited
34 moved

Legend:

Unmodified
Added
Removed
  • trunk/Gruntfile.js

    r29795 r29847  
    5959                            '!wp-includes/js/underscore.js',
    6060                            '!wp-includes/js/jquery/jquery.masonry.js',
     61                            '!wp-includes/js/jquery/ui/*.js',
    6162                            '!wp-includes/js/tinymce/tinymce.js',
    6263                            '!wp-includes/version.php' // Exclude version.php
     
    352353                    '!wp-includes/js/zxcvbn.min.js'
    353354                ]
     355            },
     356            jqueryui: {
     357                options: {
     358                    preserveComments: 'some'
     359                },
     360                expand: true,
     361                cwd: SOURCE_DIR,
     362                dest: BUILD_DIR,
     363                ext: '.min.js',
     364                src: ['wp-includes/js/jquery/ui/*.js']
    354365            }
    355366        },
     
    468479    // Build task.
    469480    grunt.registerTask('build', ['clean:all', 'copy:all', 'cssmin:core', 'colors', 'rtl', 'cssmin:rtl', 'cssmin:colors',
    470         'uglify:core', 'concat:tinymce', 'compress:tinymce', 'clean:tinymce', 'jsvalidate:build']);
     481        'uglify:core', 'uglify:jqueryui', 'concat:tinymce', 'compress:tinymce', 'clean:tinymce', 'jsvalidate:build']);
    471482
    472483    // Testing tasks.
  • trunk/src/wp-admin/includes/update-core.php

    r29206 r29847  
    660660'wp-includes/js/tinymce/plugins/paste/pastetext.htm',
    661661'wp-includes/js/tinymce/langs/wp-langs.php',
     662// 4.1
     663'wp-includes/js/jquery/ui/jquery.ui.accordion.min.js',
     664'wp-includes/js/jquery/ui/jquery.ui.autocomplete.min.js',
     665'wp-includes/js/jquery/ui/jquery.ui.button.min.js',
     666'wp-includes/js/jquery/ui/jquery.ui.core.min.js',
     667'wp-includes/js/jquery/ui/jquery.ui.datepicker.min.js',
     668'wp-includes/js/jquery/ui/jquery.ui.dialog.min.js',
     669'wp-includes/js/jquery/ui/jquery.ui.draggable.min.js',
     670'wp-includes/js/jquery/ui/jquery.ui.droppable.min.js',
     671'wp-includes/js/jquery/ui/jquery.ui.effect-blind.min.js',
     672'wp-includes/js/jquery/ui/jquery.ui.effect-bounce.min.js',
     673'wp-includes/js/jquery/ui/jquery.ui.effect-clip.min.js',
     674'wp-includes/js/jquery/ui/jquery.ui.effect-drop.min.js',
     675'wp-includes/js/jquery/ui/jquery.ui.effect-explode.min.js',
     676'wp-includes/js/jquery/ui/jquery.ui.effect-fade.min.js',
     677'wp-includes/js/jquery/ui/jquery.ui.effect-fold.min.js',
     678'wp-includes/js/jquery/ui/jquery.ui.effect-highlight.min.js',
     679'wp-includes/js/jquery/ui/jquery.ui.effect-pulsate.min.js',
     680'wp-includes/js/jquery/ui/jquery.ui.effect-scale.min.js',
     681'wp-includes/js/jquery/ui/jquery.ui.effect-shake.min.js',
     682'wp-includes/js/jquery/ui/jquery.ui.effect-slide.min.js',
     683'wp-includes/js/jquery/ui/jquery.ui.effect-transfer.min.js',
     684'wp-includes/js/jquery/ui/jquery.ui.effect.min.js',
     685'wp-includes/js/jquery/ui/jquery.ui.menu.min.js',
     686'wp-includes/js/jquery/ui/jquery.ui.mouse.min.js',
     687'wp-includes/js/jquery/ui/jquery.ui.position.min.js',
     688'wp-includes/js/jquery/ui/jquery.ui.progressbar.min.js',
     689'wp-includes/js/jquery/ui/jquery.ui.resizable.min.js',
     690'wp-includes/js/jquery/ui/jquery.ui.selectable.min.js',
     691'wp-includes/js/jquery/ui/jquery.ui.slider.min.js',
     692'wp-includes/js/jquery/ui/jquery.ui.sortable.min.js',
     693'wp-includes/js/jquery/ui/jquery.ui.spinner.min.js',
     694'wp-includes/js/jquery/ui/jquery.ui.tabs.min.js',
     695'wp-includes/js/jquery/ui/jquery.ui.tooltip.min.js',
     696'wp-includes/js/jquery/ui/jquery.ui.widget.min.js',
    662697);
    663698
  • trunk/src/wp-includes/js/jquery/ui/accordion.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){var e=0,i={},s={};i.height=i.paddingTop=i.paddingBottom=i.borderTopWidth=i.borderBottomWidth="hide",s.height=s.paddingTop=s.paddingBottom=s.borderTopWidth=s.borderBottomWidth="show",t.widget("ui.accordion",{version:"1.10.4",options:{active:0,animate:{},collapsible:!1,event:"click",header:"> li > :first-child,> :not(li):even",heightStyle:"auto",icons:{activeHeader:"ui-icon-triangle-1-s",header:"ui-icon-triangle-1-e"},activate:null,beforeActivate:null},_create:function(){var e=this.options;this.prevShow=this.prevHide=t(),this.element.addClass("ui-accordion ui-widget ui-helper-reset").attr("role","tablist"),e.collapsible||e.active!==!1&&null!=e.active||(e.active=0),this._processPanels(),0>e.active&&(e.active+=this.headers.length),this._refresh()},_getCreateEventData:function(){return{header:this.active,panel:this.active.length?this.active.next():t(),content:this.active.length?this.active.next():t()}},_createIcons:function(){var e=this.options.icons;e&&(t("<span>").addClass("ui-accordion-header-icon ui-icon "+e.header).prependTo(this.headers),this.active.children(".ui-accordion-header-icon").removeClass(e.header).addClass(e.activeHeader),this.headers.addClass("ui-accordion-icons"))},_destroyIcons:function(){this.headers.removeClass("ui-accordion-icons").children(".ui-accordion-header-icon").remove()},_destroy:function(){var t;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role"),this.headers.removeClass("ui-accordion-header ui-accordion-header-active ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-selected").removeAttr("aria-controls").removeAttr("tabIndex").each(function(){/^ui-accordion/.test(this.id)&&this.removeAttribute("id")}),this._destroyIcons(),t=this.headers.next().css("display","").removeAttr("role").removeAttr("aria-hidden").removeAttr("aria-labelledby").removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled").each(function(){/^ui-accordion/.test(this.id)&&this.removeAttribute("id")}),"content"!==this.options.heightStyle&&t.css("height","")},_setOption:function(t,e){return"active"===t?(this._activate(e),undefined):("event"===t&&(this.options.event&&this._off(this.headers,this.options.event),this._setupEvents(e)),this._super(t,e),"collapsible"!==t||e||this.options.active!==!1||this._activate(0),"icons"===t&&(this._destroyIcons(),e&&this._createIcons()),"disabled"===t&&this.headers.add(this.headers.next()).toggleClass("ui-state-disabled",!!e),undefined)},_keydown:function(e){if(!e.altKey&&!e.ctrlKey){var i=t.ui.keyCode,s=this.headers.length,n=this.headers.index(e.target),a=!1;switch(e.keyCode){case i.RIGHT:case i.DOWN:a=this.headers[(n+1)%s];break;case i.LEFT:case i.UP:a=this.headers[(n-1+s)%s];break;case i.SPACE:case i.ENTER:this._eventHandler(e);break;case i.HOME:a=this.headers[0];break;case i.END:a=this.headers[s-1]}a&&(t(e.target).attr("tabIndex",-1),t(a).attr("tabIndex",0),a.focus(),e.preventDefault())}},_panelKeyDown:function(e){e.keyCode===t.ui.keyCode.UP&&e.ctrlKey&&t(e.currentTarget).prev().focus()},refresh:function(){var e=this.options;this._processPanels(),e.active===!1&&e.collapsible===!0||!this.headers.length?(e.active=!1,this.active=t()):e.active===!1?this._activate(0):this.active.length&&!t.contains(this.element[0],this.active[0])?this.headers.length===this.headers.find(".ui-state-disabled").length?(e.active=!1,this.active=t()):this._activate(Math.max(0,e.active-1)):e.active=this.headers.index(this.active),this._destroyIcons(),this._refresh()},_processPanels:function(){this.headers=this.element.find(this.options.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all"),this.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom").filter(":not(.ui-accordion-content-active)").hide()},_refresh:function(){var i,s=this.options,n=s.heightStyle,a=this.element.parent(),o=this.accordionId="ui-accordion-"+(this.element.attr("id")||++e);this.active=this._findActive(s.active).addClass("ui-accordion-header-active ui-state-active ui-corner-top").removeClass("ui-corner-all"),this.active.next().addClass("ui-accordion-content-active").show(),this.headers.attr("role","tab").each(function(e){var i=t(this),s=i.attr("id"),n=i.next(),a=n.attr("id");s||(s=o+"-header-"+e,i.attr("id",s)),a||(a=o+"-panel-"+e,n.attr("id",a)),i.attr("aria-controls",a),n.attr("aria-labelledby",s)}).next().attr("role","tabpanel"),this.headers.not(this.active).attr({"aria-selected":"false","aria-expanded":"false",tabIndex:-1}).next().attr({"aria-hidden":"true"}).hide(),this.active.length?this.active.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0}).next().attr({"aria-hidden":"false"}):this.headers.eq(0).attr("tabIndex",0),this._createIcons(),this._setupEvents(s.event),"fill"===n?(i=a.height(),this.element.siblings(":visible").each(function(){var e=t(this),s=e.css("position");"absolute"!==s&&"fixed"!==s&&(i-=e.outerHeight(!0))}),this.headers.each(function(){i-=t(this).outerHeight(!0)}),this.headers.next().each(function(){t(this).height(Math.max(0,i-t(this).innerHeight()+t(this).height()))}).css("overflow","auto")):"auto"===n&&(i=0,this.headers.next().each(function(){i=Math.max(i,t(this).css("height","").height())}).height(i))},_activate:function(e){var i=this._findActive(e)[0];i!==this.active[0]&&(i=i||this.active[0],this._eventHandler({target:i,currentTarget:i,preventDefault:t.noop}))},_findActive:function(e){return"number"==typeof e?this.headers.eq(e):t()},_setupEvents:function(e){var i={keydown:"_keydown"};e&&t.each(e.split(" "),function(t,e){i[e]="_eventHandler"}),this._off(this.headers.add(this.headers.next())),this._on(this.headers,i),this._on(this.headers.next(),{keydown:"_panelKeyDown"}),this._hoverable(this.headers),this._focusable(this.headers)},_eventHandler:function(e){var i=this.options,s=this.active,n=t(e.currentTarget),a=n[0]===s[0],o=a&&i.collapsible,r=o?t():n.next(),h=s.next(),l={oldHeader:s,oldPanel:h,newHeader:o?t():n,newPanel:r};e.preventDefault(),a&&!i.collapsible||this._trigger("beforeActivate",e,l)===!1||(i.active=o?!1:this.headers.index(n),this.active=a?t():n,this._toggle(l),s.removeClass("ui-accordion-header-active ui-state-active"),i.icons&&s.children(".ui-accordion-header-icon").removeClass(i.icons.activeHeader).addClass(i.icons.header),a||(n.removeClass("ui-corner-all").addClass("ui-accordion-header-active ui-state-active ui-corner-top"),i.icons&&n.children(".ui-accordion-header-icon").removeClass(i.icons.header).addClass(i.icons.activeHeader),n.next().addClass("ui-accordion-content-active")))},_toggle:function(e){var i=e.newPanel,s=this.prevShow.length?this.prevShow:e.oldPanel;this.prevShow.add(this.prevHide).stop(!0,!0),this.prevShow=i,this.prevHide=s,this.options.animate?this._animate(i,s,e):(s.hide(),i.show(),this._toggleComplete(e)),s.attr({"aria-hidden":"true"}),s.prev().attr("aria-selected","false"),i.length&&s.length?s.prev().attr({tabIndex:-1,"aria-expanded":"false"}):i.length&&this.headers.filter(function(){return 0===t(this).attr("tabIndex")}).attr("tabIndex",-1),i.attr("aria-hidden","false").prev().attr({"aria-selected":"true",tabIndex:0,"aria-expanded":"true"})},_animate:function(t,e,n){var a,o,r,h=this,l=0,c=t.length&&(!e.length||t.index()<e.index()),u=this.options.animate||{},d=c&&u.down||u,p=function(){h._toggleComplete(n)};return"number"==typeof d&&(r=d),"string"==typeof d&&(o=d),o=o||d.easing||u.easing,r=r||d.duration||u.duration,e.length?t.length?(a=t.show().outerHeight(),e.animate(i,{duration:r,easing:o,step:function(t,e){e.now=Math.round(t)}}),t.hide().animate(s,{duration:r,easing:o,complete:p,step:function(t,i){i.now=Math.round(t),"height"!==i.prop?l+=i.now:"content"!==h.options.heightStyle&&(i.now=Math.round(a-e.outerHeight()-l),l=0)}}),undefined):e.animate(i,r,o,p):t.animate(s,r,o,p)},_toggleComplete:function(t){var e=t.oldPanel;e.removeClass("ui-accordion-content-active").prev().removeClass("ui-corner-top").addClass("ui-corner-all"),e.length&&(e.parent()[0].className=e.parent()[0].className),this._trigger("activate",null,t)}})})(jQuery);
     1/*!
     2 * jQuery UI Accordion 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/accordion/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./core",
     18            "./widget"
     19        ], factory );
     20    } else {
     21
     22        // Browser globals
     23        factory( jQuery );
     24    }
     25}(function( $ ) {
     26
     27return $.widget( "ui.accordion", {
     28    version: "1.11.1",
     29    options: {
     30        active: 0,
     31        animate: {},
     32        collapsible: false,
     33        event: "click",
     34        header: "> li > :first-child,> :not(li):even",
     35        heightStyle: "auto",
     36        icons: {
     37            activeHeader: "ui-icon-triangle-1-s",
     38            header: "ui-icon-triangle-1-e"
     39        },
     40
     41        // callbacks
     42        activate: null,
     43        beforeActivate: null
     44    },
     45
     46    hideProps: {
     47        borderTopWidth: "hide",
     48        borderBottomWidth: "hide",
     49        paddingTop: "hide",
     50        paddingBottom: "hide",
     51        height: "hide"
     52    },
     53
     54    showProps: {
     55        borderTopWidth: "show",
     56        borderBottomWidth: "show",
     57        paddingTop: "show",
     58        paddingBottom: "show",
     59        height: "show"
     60    },
     61
     62    _create: function() {
     63        var options = this.options;
     64        this.prevShow = this.prevHide = $();
     65        this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
     66            // ARIA
     67            .attr( "role", "tablist" );
     68
     69        // don't allow collapsible: false and active: false / null
     70        if ( !options.collapsible && (options.active === false || options.active == null) ) {
     71            options.active = 0;
     72        }
     73
     74        this._processPanels();
     75        // handle negative values
     76        if ( options.active < 0 ) {
     77            options.active += this.headers.length;
     78        }
     79        this._refresh();
     80    },
     81
     82    _getCreateEventData: function() {
     83        return {
     84            header: this.active,
     85            panel: !this.active.length ? $() : this.active.next()
     86        };
     87    },
     88
     89    _createIcons: function() {
     90        var icons = this.options.icons;
     91        if ( icons ) {
     92            $( "<span>" )
     93                .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
     94                .prependTo( this.headers );
     95            this.active.children( ".ui-accordion-header-icon" )
     96                .removeClass( icons.header )
     97                .addClass( icons.activeHeader );
     98            this.headers.addClass( "ui-accordion-icons" );
     99        }
     100    },
     101
     102    _destroyIcons: function() {
     103        this.headers
     104            .removeClass( "ui-accordion-icons" )
     105            .children( ".ui-accordion-header-icon" )
     106                .remove();
     107    },
     108
     109    _destroy: function() {
     110        var contents;
     111
     112        // clean up main element
     113        this.element
     114            .removeClass( "ui-accordion ui-widget ui-helper-reset" )
     115            .removeAttr( "role" );
     116
     117        // clean up headers
     118        this.headers
     119            .removeClass( "ui-accordion-header ui-accordion-header-active ui-state-default " +
     120                "ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
     121            .removeAttr( "role" )
     122            .removeAttr( "aria-expanded" )
     123            .removeAttr( "aria-selected" )
     124            .removeAttr( "aria-controls" )
     125            .removeAttr( "tabIndex" )
     126            .removeUniqueId();
     127
     128        this._destroyIcons();
     129
     130        // clean up content panels
     131        contents = this.headers.next()
     132            .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom " +
     133                "ui-accordion-content ui-accordion-content-active ui-state-disabled" )
     134            .css( "display", "" )
     135            .removeAttr( "role" )
     136            .removeAttr( "aria-hidden" )
     137            .removeAttr( "aria-labelledby" )
     138            .removeUniqueId();
     139
     140        if ( this.options.heightStyle !== "content" ) {
     141            contents.css( "height", "" );
     142        }
     143    },
     144
     145    _setOption: function( key, value ) {
     146        if ( key === "active" ) {
     147            // _activate() will handle invalid values and update this.options
     148            this._activate( value );
     149            return;
     150        }
     151
     152        if ( key === "event" ) {
     153            if ( this.options.event ) {
     154                this._off( this.headers, this.options.event );
     155            }
     156            this._setupEvents( value );
     157        }
     158
     159        this._super( key, value );
     160
     161        // setting collapsible: false while collapsed; open first panel
     162        if ( key === "collapsible" && !value && this.options.active === false ) {
     163            this._activate( 0 );
     164        }
     165
     166        if ( key === "icons" ) {
     167            this._destroyIcons();
     168            if ( value ) {
     169                this._createIcons();
     170            }
     171        }
     172
     173        // #5332 - opacity doesn't cascade to positioned elements in IE
     174        // so we need to add the disabled class to the headers and panels
     175        if ( key === "disabled" ) {
     176            this.element
     177                .toggleClass( "ui-state-disabled", !!value )
     178                .attr( "aria-disabled", value );
     179            this.headers.add( this.headers.next() )
     180                .toggleClass( "ui-state-disabled", !!value );
     181        }
     182    },
     183
     184    _keydown: function( event ) {
     185        if ( event.altKey || event.ctrlKey ) {
     186            return;
     187        }
     188
     189        var keyCode = $.ui.keyCode,
     190            length = this.headers.length,
     191            currentIndex = this.headers.index( event.target ),
     192            toFocus = false;
     193
     194        switch ( event.keyCode ) {
     195            case keyCode.RIGHT:
     196            case keyCode.DOWN:
     197                toFocus = this.headers[ ( currentIndex + 1 ) % length ];
     198                break;
     199            case keyCode.LEFT:
     200            case keyCode.UP:
     201                toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
     202                break;
     203            case keyCode.SPACE:
     204            case keyCode.ENTER:
     205                this._eventHandler( event );
     206                break;
     207            case keyCode.HOME:
     208                toFocus = this.headers[ 0 ];
     209                break;
     210            case keyCode.END:
     211                toFocus = this.headers[ length - 1 ];
     212                break;
     213        }
     214
     215        if ( toFocus ) {
     216            $( event.target ).attr( "tabIndex", -1 );
     217            $( toFocus ).attr( "tabIndex", 0 );
     218            toFocus.focus();
     219            event.preventDefault();
     220        }
     221    },
     222
     223    _panelKeyDown: function( event ) {
     224        if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
     225            $( event.currentTarget ).prev().focus();
     226        }
     227    },
     228
     229    refresh: function() {
     230        var options = this.options;
     231        this._processPanels();
     232
     233        // was collapsed or no panel
     234        if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
     235            options.active = false;
     236            this.active = $();
     237        // active false only when collapsible is true
     238        } else if ( options.active === false ) {
     239            this._activate( 0 );
     240        // was active, but active panel is gone
     241        } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
     242            // all remaining panel are disabled
     243            if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
     244                options.active = false;
     245                this.active = $();
     246            // activate previous panel
     247            } else {
     248                this._activate( Math.max( 0, options.active - 1 ) );
     249            }
     250        // was active, active panel still exists
     251        } else {
     252            // make sure active index is correct
     253            options.active = this.headers.index( this.active );
     254        }
     255
     256        this._destroyIcons();
     257
     258        this._refresh();
     259    },
     260
     261    _processPanels: function() {
     262        this.headers = this.element.find( this.options.header )
     263            .addClass( "ui-accordion-header ui-state-default ui-corner-all" );
     264
     265        this.headers.next()
     266            .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
     267            .filter( ":not(.ui-accordion-content-active)" )
     268            .hide();
     269    },
     270
     271    _refresh: function() {
     272        var maxHeight,
     273            options = this.options,
     274            heightStyle = options.heightStyle,
     275            parent = this.element.parent();
     276
     277        this.active = this._findActive( options.active )
     278            .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
     279            .removeClass( "ui-corner-all" );
     280        this.active.next()
     281            .addClass( "ui-accordion-content-active" )
     282            .show();
     283
     284        this.headers
     285            .attr( "role", "tab" )
     286            .each(function() {
     287                var header = $( this ),
     288                    headerId = header.uniqueId().attr( "id" ),
     289                    panel = header.next(),
     290                    panelId = panel.uniqueId().attr( "id" );
     291                header.attr( "aria-controls", panelId );
     292                panel.attr( "aria-labelledby", headerId );
     293            })
     294            .next()
     295                .attr( "role", "tabpanel" );
     296
     297        this.headers
     298            .not( this.active )
     299            .attr({
     300                "aria-selected": "false",
     301                "aria-expanded": "false",
     302                tabIndex: -1
     303            })
     304            .next()
     305                .attr({
     306                    "aria-hidden": "true"
     307                })
     308                .hide();
     309
     310        // make sure at least one header is in the tab order
     311        if ( !this.active.length ) {
     312            this.headers.eq( 0 ).attr( "tabIndex", 0 );
     313        } else {
     314            this.active.attr({
     315                "aria-selected": "true",
     316                "aria-expanded": "true",
     317                tabIndex: 0
     318            })
     319            .next()
     320                .attr({
     321                    "aria-hidden": "false"
     322                });
     323        }
     324
     325        this._createIcons();
     326
     327        this._setupEvents( options.event );
     328
     329        if ( heightStyle === "fill" ) {
     330            maxHeight = parent.height();
     331            this.element.siblings( ":visible" ).each(function() {
     332                var elem = $( this ),
     333                    position = elem.css( "position" );
     334
     335                if ( position === "absolute" || position === "fixed" ) {
     336                    return;
     337                }
     338                maxHeight -= elem.outerHeight( true );
     339            });
     340
     341            this.headers.each(function() {
     342                maxHeight -= $( this ).outerHeight( true );
     343            });
     344
     345            this.headers.next()
     346                .each(function() {
     347                    $( this ).height( Math.max( 0, maxHeight -
     348                        $( this ).innerHeight() + $( this ).height() ) );
     349                })
     350                .css( "overflow", "auto" );
     351        } else if ( heightStyle === "auto" ) {
     352            maxHeight = 0;
     353            this.headers.next()
     354                .each(function() {
     355                    maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
     356                })
     357                .height( maxHeight );
     358        }
     359    },
     360
     361    _activate: function( index ) {
     362        var active = this._findActive( index )[ 0 ];
     363
     364        // trying to activate the already active panel
     365        if ( active === this.active[ 0 ] ) {
     366            return;
     367        }
     368
     369        // trying to collapse, simulate a click on the currently active header
     370        active = active || this.active[ 0 ];
     371
     372        this._eventHandler({
     373            target: active,
     374            currentTarget: active,
     375            preventDefault: $.noop
     376        });
     377    },
     378
     379    _findActive: function( selector ) {
     380        return typeof selector === "number" ? this.headers.eq( selector ) : $();
     381    },
     382
     383    _setupEvents: function( event ) {
     384        var events = {
     385            keydown: "_keydown"
     386        };
     387        if ( event ) {
     388            $.each( event.split( " " ), function( index, eventName ) {
     389                events[ eventName ] = "_eventHandler";
     390            });
     391        }
     392
     393        this._off( this.headers.add( this.headers.next() ) );
     394        this._on( this.headers, events );
     395        this._on( this.headers.next(), { keydown: "_panelKeyDown" });
     396        this._hoverable( this.headers );
     397        this._focusable( this.headers );
     398    },
     399
     400    _eventHandler: function( event ) {
     401        var options = this.options,
     402            active = this.active,
     403            clicked = $( event.currentTarget ),
     404            clickedIsActive = clicked[ 0 ] === active[ 0 ],
     405            collapsing = clickedIsActive && options.collapsible,
     406            toShow = collapsing ? $() : clicked.next(),
     407            toHide = active.next(),
     408            eventData = {
     409                oldHeader: active,
     410                oldPanel: toHide,
     411                newHeader: collapsing ? $() : clicked,
     412                newPanel: toShow
     413            };
     414
     415        event.preventDefault();
     416
     417        if (
     418                // click on active header, but not collapsible
     419                ( clickedIsActive && !options.collapsible ) ||
     420                // allow canceling activation
     421                ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
     422            return;
     423        }
     424
     425        options.active = collapsing ? false : this.headers.index( clicked );
     426
     427        // when the call to ._toggle() comes after the class changes
     428        // it causes a very odd bug in IE 8 (see #6720)
     429        this.active = clickedIsActive ? $() : clicked;
     430        this._toggle( eventData );
     431
     432        // switch classes
     433        // corner classes on the previously active header stay after the animation
     434        active.removeClass( "ui-accordion-header-active ui-state-active" );
     435        if ( options.icons ) {
     436            active.children( ".ui-accordion-header-icon" )
     437                .removeClass( options.icons.activeHeader )
     438                .addClass( options.icons.header );
     439        }
     440
     441        if ( !clickedIsActive ) {
     442            clicked
     443                .removeClass( "ui-corner-all" )
     444                .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
     445            if ( options.icons ) {
     446                clicked.children( ".ui-accordion-header-icon" )
     447                    .removeClass( options.icons.header )
     448                    .addClass( options.icons.activeHeader );
     449            }
     450
     451            clicked
     452                .next()
     453                .addClass( "ui-accordion-content-active" );
     454        }
     455    },
     456
     457    _toggle: function( data ) {
     458        var toShow = data.newPanel,
     459            toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
     460
     461        // handle activating a panel during the animation for another activation
     462        this.prevShow.add( this.prevHide ).stop( true, true );
     463        this.prevShow = toShow;
     464        this.prevHide = toHide;
     465
     466        if ( this.options.animate ) {
     467            this._animate( toShow, toHide, data );
     468        } else {
     469            toHide.hide();
     470            toShow.show();
     471            this._toggleComplete( data );
     472        }
     473
     474        toHide.attr({
     475            "aria-hidden": "true"
     476        });
     477        toHide.prev().attr( "aria-selected", "false" );
     478        // if we're switching panels, remove the old header from the tab order
     479        // if we're opening from collapsed state, remove the previous header from the tab order
     480        // if we're collapsing, then keep the collapsing header in the tab order
     481        if ( toShow.length && toHide.length ) {
     482            toHide.prev().attr({
     483                "tabIndex": -1,
     484                "aria-expanded": "false"
     485            });
     486        } else if ( toShow.length ) {
     487            this.headers.filter(function() {
     488                return $( this ).attr( "tabIndex" ) === 0;
     489            })
     490            .attr( "tabIndex", -1 );
     491        }
     492
     493        toShow
     494            .attr( "aria-hidden", "false" )
     495            .prev()
     496                .attr({
     497                    "aria-selected": "true",
     498                    tabIndex: 0,
     499                    "aria-expanded": "true"
     500                });
     501    },
     502
     503    _animate: function( toShow, toHide, data ) {
     504        var total, easing, duration,
     505            that = this,
     506            adjust = 0,
     507            down = toShow.length &&
     508                ( !toHide.length || ( toShow.index() < toHide.index() ) ),
     509            animate = this.options.animate || {},
     510            options = down && animate.down || animate,
     511            complete = function() {
     512                that._toggleComplete( data );
     513            };
     514
     515        if ( typeof options === "number" ) {
     516            duration = options;
     517        }
     518        if ( typeof options === "string" ) {
     519            easing = options;
     520        }
     521        // fall back from options to animation in case of partial down settings
     522        easing = easing || options.easing || animate.easing;
     523        duration = duration || options.duration || animate.duration;
     524
     525        if ( !toHide.length ) {
     526            return toShow.animate( this.showProps, duration, easing, complete );
     527        }
     528        if ( !toShow.length ) {
     529            return toHide.animate( this.hideProps, duration, easing, complete );
     530        }
     531
     532        total = toShow.show().outerHeight();
     533        toHide.animate( this.hideProps, {
     534            duration: duration,
     535            easing: easing,
     536            step: function( now, fx ) {
     537                fx.now = Math.round( now );
     538            }
     539        });
     540        toShow
     541            .hide()
     542            .animate( this.showProps, {
     543                duration: duration,
     544                easing: easing,
     545                complete: complete,
     546                step: function( now, fx ) {
     547                    fx.now = Math.round( now );
     548                    if ( fx.prop !== "height" ) {
     549                        adjust += fx.now;
     550                    } else if ( that.options.heightStyle !== "content" ) {
     551                        fx.now = Math.round( total - toHide.outerHeight() - adjust );
     552                        adjust = 0;
     553                    }
     554                }
     555            });
     556    },
     557
     558    _toggleComplete: function( data ) {
     559        var toHide = data.oldPanel;
     560
     561        toHide
     562            .removeClass( "ui-accordion-content-active" )
     563            .prev()
     564                .removeClass( "ui-corner-top" )
     565                .addClass( "ui-corner-all" );
     566
     567        // Work around for rendering bug in IE (#5421)
     568        if ( toHide.length ) {
     569            toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
     570        }
     571        this._trigger( "activate", null, data );
     572    }
     573});
     574
     575}));
  • trunk/src/wp-includes/js/jquery/ui/autocomplete.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){t.widget("ui.autocomplete",{version:"1.10.4",defaultElement:"<input>",options:{appendTo:null,autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null,change:null,close:null,focus:null,open:null,response:null,search:null,select:null},requestIndex:0,pending:0,_create:function(){var e,i,s,n=this.element[0].nodeName.toLowerCase(),a="textarea"===n,o="input"===n;this.isMultiLine=a?!0:o?!1:this.element.prop("isContentEditable"),this.valueMethod=this.element[a||o?"val":"text"],this.isNewMenu=!0,this.element.addClass("ui-autocomplete-input").attr("autocomplete","off"),this._on(this.element,{keydown:function(n){if(this.element.prop("readOnly"))return e=!0,s=!0,i=!0,undefined;e=!1,s=!1,i=!1;var a=t.ui.keyCode;switch(n.keyCode){case a.PAGE_UP:e=!0,this._move("previousPage",n);break;case a.PAGE_DOWN:e=!0,this._move("nextPage",n);break;case a.UP:e=!0,this._keyEvent("previous",n);break;case a.DOWN:e=!0,this._keyEvent("next",n);break;case a.ENTER:case a.NUMPAD_ENTER:this.menu.active&&(e=!0,n.preventDefault(),this.menu.select(n));break;case a.TAB:this.menu.active&&this.menu.select(n);break;case a.ESCAPE:this.menu.element.is(":visible")&&(this._value(this.term),this.close(n),n.preventDefault());break;default:i=!0,this._searchTimeout(n)}},keypress:function(s){if(e)return e=!1,(!this.isMultiLine||this.menu.element.is(":visible"))&&s.preventDefault(),undefined;if(!i){var n=t.ui.keyCode;switch(s.keyCode){case n.PAGE_UP:this._move("previousPage",s);break;case n.PAGE_DOWN:this._move("nextPage",s);break;case n.UP:this._keyEvent("previous",s);break;case n.DOWN:this._keyEvent("next",s)}}},input:function(t){return s?(s=!1,t.preventDefault(),undefined):(this._searchTimeout(t),undefined)},focus:function(){this.selectedItem=null,this.previous=this._value()},blur:function(t){return this.cancelBlur?(delete this.cancelBlur,undefined):(clearTimeout(this.searching),this.close(t),this._change(t),undefined)}}),this._initSource(),this.menu=t("<ul>").addClass("ui-autocomplete ui-front").appendTo(this._appendTo()).menu({role:null}).hide().data("ui-menu"),this._on(this.menu.element,{mousedown:function(e){e.preventDefault(),this.cancelBlur=!0,this._delay(function(){delete this.cancelBlur});var i=this.menu.element[0];t(e.target).closest(".ui-menu-item").length||this._delay(function(){var e=this;this.document.one("mousedown",function(s){s.target===e.element[0]||s.target===i||t.contains(i,s.target)||e.close()})})},menufocus:function(e,i){if(this.isNewMenu&&(this.isNewMenu=!1,e.originalEvent&&/^mouse/.test(e.originalEvent.type)))return this.menu.blur(),this.document.one("mousemove",function(){t(e.target).trigger(e.originalEvent)}),undefined;var s=i.item.data("ui-autocomplete-item");!1!==this._trigger("focus",e,{item:s})?e.originalEvent&&/^key/.test(e.originalEvent.type)&&this._value(s.value):this.liveRegion.text(s.value)},menuselect:function(t,e){var i=e.item.data("ui-autocomplete-item"),s=this.previous;this.element[0]!==this.document[0].activeElement&&(this.element.focus(),this.previous=s,this._delay(function(){this.previous=s,this.selectedItem=i})),!1!==this._trigger("select",t,{item:i})&&this._value(i.value),this.term=this._value(),this.close(t),this.selectedItem=i}}),this.liveRegion=t("<span>",{role:"status","aria-live":"polite"}).addClass("ui-helper-hidden-accessible").insertBefore(this.element),this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_destroy:function(){clearTimeout(this.searching),this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete"),this.menu.element.remove(),this.liveRegion.remove()},_setOption:function(t,e){this._super(t,e),"source"===t&&this._initSource(),"appendTo"===t&&this.menu.element.appendTo(this._appendTo()),"disabled"===t&&e&&this.xhr&&this.xhr.abort()},_appendTo:function(){var e=this.options.appendTo;return e&&(e=e.jquery||e.nodeType?t(e):this.document.find(e).eq(0)),e||(e=this.element.closest(".ui-front")),e.length||(e=this.document[0].body),e},_initSource:function(){var e,i,s=this;t.isArray(this.options.source)?(e=this.options.source,this.source=function(i,s){s(t.ui.autocomplete.filter(e,i.term))}):"string"==typeof this.options.source?(i=this.options.source,this.source=function(e,n){s.xhr&&s.xhr.abort(),s.xhr=t.ajax({url:i,data:e,dataType:"json",success:function(t){n(t)},error:function(){n([])}})}):this.source=this.options.source},_searchTimeout:function(t){clearTimeout(this.searching),this.searching=this._delay(function(){this.term!==this._value()&&(this.selectedItem=null,this.search(null,t))},this.options.delay)},search:function(t,e){return t=null!=t?t:this._value(),this.term=this._value(),t.length<this.options.minLength?this.close(e):this._trigger("search",e)!==!1?this._search(t):undefined},_search:function(t){this.pending++,this.element.addClass("ui-autocomplete-loading"),this.cancelSearch=!1,this.source({term:t},this._response())},_response:function(){var e=++this.requestIndex;return t.proxy(function(t){e===this.requestIndex&&this.__response(t),this.pending--,this.pending||this.element.removeClass("ui-autocomplete-loading")},this)},__response:function(t){t&&(t=this._normalize(t)),this._trigger("response",null,{content:t}),!this.options.disabled&&t&&t.length&&!this.cancelSearch?(this._suggest(t),this._trigger("open")):this._close()},close:function(t){this.cancelSearch=!0,this._close(t)},_close:function(t){this.menu.element.is(":visible")&&(this.menu.element.hide(),this.menu.blur(),this.isNewMenu=!0,this._trigger("close",t))},_change:function(t){this.previous!==this._value()&&this._trigger("change",t,{item:this.selectedItem})},_normalize:function(e){return e.length&&e[0].label&&e[0].value?e:t.map(e,function(e){return"string"==typeof e?{label:e,value:e}:t.extend({label:e.label||e.value,value:e.value||e.label},e)})},_suggest:function(e){var i=this.menu.element.empty();this._renderMenu(i,e),this.isNewMenu=!0,this.menu.refresh(),i.show(),this._resizeMenu(),i.position(t.extend({of:this.element},this.options.position)),this.options.autoFocus&&this.menu.next()},_resizeMenu:function(){var t=this.menu.element;t.outerWidth(Math.max(t.width("").outerWidth()+1,this.element.outerWidth()))},_renderMenu:function(e,i){var s=this;t.each(i,function(t,i){s._renderItemData(e,i)})},_renderItemData:function(t,e){return this._renderItem(t,e).data("ui-autocomplete-item",e)},_renderItem:function(e,i){return t("<li>").append(t("<a>").text(i.label)).appendTo(e)},_move:function(t,e){return this.menu.element.is(":visible")?this.menu.isFirstItem()&&/^previous/.test(t)||this.menu.isLastItem()&&/^next/.test(t)?(this._value(this.term),this.menu.blur(),undefined):(this.menu[t](e),undefined):(this.search(null,e),undefined)},widget:function(){return this.menu.element},_value:function(){return this.valueMethod.apply(this.element,arguments)},_keyEvent:function(t,e){(!this.isMultiLine||this.menu.element.is(":visible"))&&(this._move(t,e),e.preventDefault())}}),t.extend(t.ui.autocomplete,{escapeRegex:function(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")},filter:function(e,i){var s=RegExp(t.ui.autocomplete.escapeRegex(i),"i");return t.grep(e,function(t){return s.test(t.label||t.value||t)})}}),t.widget("ui.autocomplete",t.ui.autocomplete,{options:{messages:{noResults:"No search results.",results:function(t){return t+(t>1?" results are":" result is")+" available, use up and down arrow keys to navigate."}}},__response:function(t){var e;this._superApply(arguments),this.options.disabled||this.cancelSearch||(e=t&&t.length?this.options.messages.results(t.length):this.options.messages.noResults,this.liveRegion.text(e))}})})(jQuery);
     1/*!
     2 * jQuery UI Autocomplete 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/autocomplete/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./core",
     18            "./widget",
     19            "./position",
     20            "./menu"
     21        ], factory );
     22    } else {
     23
     24        // Browser globals
     25        factory( jQuery );
     26    }
     27}(function( $ ) {
     28
     29$.widget( "ui.autocomplete", {
     30    version: "1.11.1",
     31    defaultElement: "<input>",
     32    options: {
     33        appendTo: null,
     34        autoFocus: false,
     35        delay: 300,
     36        minLength: 1,
     37        position: {
     38            my: "left top",
     39            at: "left bottom",
     40            collision: "none"
     41        },
     42        source: null,
     43
     44        // callbacks
     45        change: null,
     46        close: null,
     47        focus: null,
     48        open: null,
     49        response: null,
     50        search: null,
     51        select: null
     52    },
     53
     54    requestIndex: 0,
     55    pending: 0,
     56
     57    _create: function() {
     58        // Some browsers only repeat keydown events, not keypress events,
     59        // so we use the suppressKeyPress flag to determine if we've already
     60        // handled the keydown event. #7269
     61        // Unfortunately the code for & in keypress is the same as the up arrow,
     62        // so we use the suppressKeyPressRepeat flag to avoid handling keypress
     63        // events when we know the keydown event was used to modify the
     64        // search term. #7799
     65        var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
     66            nodeName = this.element[ 0 ].nodeName.toLowerCase(),
     67            isTextarea = nodeName === "textarea",
     68            isInput = nodeName === "input";
     69
     70        this.isMultiLine =
     71            // Textareas are always multi-line
     72            isTextarea ? true :
     73            // Inputs are always single-line, even if inside a contentEditable element
     74            // IE also treats inputs as contentEditable
     75            isInput ? false :
     76            // All other element types are determined by whether or not they're contentEditable
     77            this.element.prop( "isContentEditable" );
     78
     79        this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
     80        this.isNewMenu = true;
     81
     82        this.element
     83            .addClass( "ui-autocomplete-input" )
     84            .attr( "autocomplete", "off" );
     85
     86        this._on( this.element, {
     87            keydown: function( event ) {
     88                if ( this.element.prop( "readOnly" ) ) {
     89                    suppressKeyPress = true;
     90                    suppressInput = true;
     91                    suppressKeyPressRepeat = true;
     92                    return;
     93                }
     94
     95                suppressKeyPress = false;
     96                suppressInput = false;
     97                suppressKeyPressRepeat = false;
     98                var keyCode = $.ui.keyCode;
     99                switch ( event.keyCode ) {
     100                case keyCode.PAGE_UP:
     101                    suppressKeyPress = true;
     102                    this._move( "previousPage", event );
     103                    break;
     104                case keyCode.PAGE_DOWN:
     105                    suppressKeyPress = true;
     106                    this._move( "nextPage", event );
     107                    break;
     108                case keyCode.UP:
     109                    suppressKeyPress = true;
     110                    this._keyEvent( "previous", event );
     111                    break;
     112                case keyCode.DOWN:
     113                    suppressKeyPress = true;
     114                    this._keyEvent( "next", event );
     115                    break;
     116                case keyCode.ENTER:
     117                    // when menu is open and has focus
     118                    if ( this.menu.active ) {
     119                        // #6055 - Opera still allows the keypress to occur
     120                        // which causes forms to submit
     121                        suppressKeyPress = true;
     122                        event.preventDefault();
     123                        this.menu.select( event );
     124                    }
     125                    break;
     126                case keyCode.TAB:
     127                    if ( this.menu.active ) {
     128                        this.menu.select( event );
     129                    }
     130                    break;
     131                case keyCode.ESCAPE:
     132                    if ( this.menu.element.is( ":visible" ) ) {
     133                        if ( !this.isMultiLine ) {
     134                            this._value( this.term );
     135                        }
     136                        this.close( event );
     137                        // Different browsers have different default behavior for escape
     138                        // Single press can mean undo or clear
     139                        // Double press in IE means clear the whole form
     140                        event.preventDefault();
     141                    }
     142                    break;
     143                default:
     144                    suppressKeyPressRepeat = true;
     145                    // search timeout should be triggered before the input value is changed
     146                    this._searchTimeout( event );
     147                    break;
     148                }
     149            },
     150            keypress: function( event ) {
     151                if ( suppressKeyPress ) {
     152                    suppressKeyPress = false;
     153                    if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
     154                        event.preventDefault();
     155                    }
     156                    return;
     157                }
     158                if ( suppressKeyPressRepeat ) {
     159                    return;
     160                }
     161
     162                // replicate some key handlers to allow them to repeat in Firefox and Opera
     163                var keyCode = $.ui.keyCode;
     164                switch ( event.keyCode ) {
     165                case keyCode.PAGE_UP:
     166                    this._move( "previousPage", event );
     167                    break;
     168                case keyCode.PAGE_DOWN:
     169                    this._move( "nextPage", event );
     170                    break;
     171                case keyCode.UP:
     172                    this._keyEvent( "previous", event );
     173                    break;
     174                case keyCode.DOWN:
     175                    this._keyEvent( "next", event );
     176                    break;
     177                }
     178            },
     179            input: function( event ) {
     180                if ( suppressInput ) {
     181                    suppressInput = false;
     182                    event.preventDefault();
     183                    return;
     184                }
     185                this._searchTimeout( event );
     186            },
     187            focus: function() {
     188                this.selectedItem = null;
     189                this.previous = this._value();
     190            },
     191            blur: function( event ) {
     192                if ( this.cancelBlur ) {
     193                    delete this.cancelBlur;
     194                    return;
     195                }
     196
     197                clearTimeout( this.searching );
     198                this.close( event );
     199                this._change( event );
     200            }
     201        });
     202
     203        this._initSource();
     204        this.menu = $( "<ul>" )
     205            .addClass( "ui-autocomplete ui-front" )
     206            .appendTo( this._appendTo() )
     207            .menu({
     208                // disable ARIA support, the live region takes care of that
     209                role: null
     210            })
     211            .hide()
     212            .menu( "instance" );
     213
     214        this._on( this.menu.element, {
     215            mousedown: function( event ) {
     216                // prevent moving focus out of the text field
     217                event.preventDefault();
     218
     219                // IE doesn't prevent moving focus even with event.preventDefault()
     220                // so we set a flag to know when we should ignore the blur event
     221                this.cancelBlur = true;
     222                this._delay(function() {
     223                    delete this.cancelBlur;
     224                });
     225
     226                // clicking on the scrollbar causes focus to shift to the body
     227                // but we can't detect a mouseup or a click immediately afterward
     228                // so we have to track the next mousedown and close the menu if
     229                // the user clicks somewhere outside of the autocomplete
     230                var menuElement = this.menu.element[ 0 ];
     231                if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
     232                    this._delay(function() {
     233                        var that = this;
     234                        this.document.one( "mousedown", function( event ) {
     235                            if ( event.target !== that.element[ 0 ] &&
     236                                    event.target !== menuElement &&
     237                                    !$.contains( menuElement, event.target ) ) {
     238                                that.close();
     239                            }
     240                        });
     241                    });
     242                }
     243            },
     244            menufocus: function( event, ui ) {
     245                var label, item;
     246                // support: Firefox
     247                // Prevent accidental activation of menu items in Firefox (#7024 #9118)
     248                if ( this.isNewMenu ) {
     249                    this.isNewMenu = false;
     250                    if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
     251                        this.menu.blur();
     252
     253                        this.document.one( "mousemove", function() {
     254                            $( event.target ).trigger( event.originalEvent );
     255                        });
     256
     257                        return;
     258                    }
     259                }
     260
     261                item = ui.item.data( "ui-autocomplete-item" );
     262                if ( false !== this._trigger( "focus", event, { item: item } ) ) {
     263                    // use value to match what will end up in the input, if it was a key event
     264                    if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
     265                        this._value( item.value );
     266                    }
     267                }
     268
     269                // Announce the value in the liveRegion
     270                label = ui.item.attr( "aria-label" ) || item.value;
     271                if ( label && $.trim( label ).length ) {
     272                    this.liveRegion.children().hide();
     273                    $( "<div>" ).text( label ).appendTo( this.liveRegion );
     274                }
     275            },
     276            menuselect: function( event, ui ) {
     277                var item = ui.item.data( "ui-autocomplete-item" ),
     278                    previous = this.previous;
     279
     280                // only trigger when focus was lost (click on menu)
     281                if ( this.element[ 0 ] !== this.document[ 0 ].activeElement ) {
     282                    this.element.focus();
     283                    this.previous = previous;
     284                    // #6109 - IE triggers two focus events and the second
     285                    // is asynchronous, so we need to reset the previous
     286                    // term synchronously and asynchronously :-(
     287                    this._delay(function() {
     288                        this.previous = previous;
     289                        this.selectedItem = item;
     290                    });
     291                }
     292
     293                if ( false !== this._trigger( "select", event, { item: item } ) ) {
     294                    this._value( item.value );
     295                }
     296                // reset the term after the select event
     297                // this allows custom select handling to work properly
     298                this.term = this._value();
     299
     300                this.close( event );
     301                this.selectedItem = item;
     302            }
     303        });
     304
     305        this.liveRegion = $( "<span>", {
     306                role: "status",
     307                "aria-live": "assertive",
     308                "aria-relevant": "additions"
     309            })
     310            .addClass( "ui-helper-hidden-accessible" )
     311            .appendTo( this.document[ 0 ].body );
     312
     313        // turning off autocomplete prevents the browser from remembering the
     314        // value when navigating through history, so we re-enable autocomplete
     315        // if the page is unloaded before the widget is destroyed. #7790
     316        this._on( this.window, {
     317            beforeunload: function() {
     318                this.element.removeAttr( "autocomplete" );
     319            }
     320        });
     321    },
     322
     323    _destroy: function() {
     324        clearTimeout( this.searching );
     325        this.element
     326            .removeClass( "ui-autocomplete-input" )
     327            .removeAttr( "autocomplete" );
     328        this.menu.element.remove();
     329        this.liveRegion.remove();
     330    },
     331
     332    _setOption: function( key, value ) {
     333        this._super( key, value );
     334        if ( key === "source" ) {
     335            this._initSource();
     336        }
     337        if ( key === "appendTo" ) {
     338            this.menu.element.appendTo( this._appendTo() );
     339        }
     340        if ( key === "disabled" && value && this.xhr ) {
     341            this.xhr.abort();
     342        }
     343    },
     344
     345    _appendTo: function() {
     346        var element = this.options.appendTo;
     347
     348        if ( element ) {
     349            element = element.jquery || element.nodeType ?
     350                $( element ) :
     351                this.document.find( element ).eq( 0 );
     352        }
     353
     354        if ( !element || !element[ 0 ] ) {
     355            element = this.element.closest( ".ui-front" );
     356        }
     357
     358        if ( !element.length ) {
     359            element = this.document[ 0 ].body;
     360        }
     361
     362        return element;
     363    },
     364
     365    _initSource: function() {
     366        var array, url,
     367            that = this;
     368        if ( $.isArray( this.options.source ) ) {
     369            array = this.options.source;
     370            this.source = function( request, response ) {
     371                response( $.ui.autocomplete.filter( array, request.term ) );
     372            };
     373        } else if ( typeof this.options.source === "string" ) {
     374            url = this.options.source;
     375            this.source = function( request, response ) {
     376                if ( that.xhr ) {
     377                    that.xhr.abort();
     378                }
     379                that.xhr = $.ajax({
     380                    url: url,
     381                    data: request,
     382                    dataType: "json",
     383                    success: function( data ) {
     384                        response( data );
     385                    },
     386                    error: function() {
     387                        response([]);
     388                    }
     389                });
     390            };
     391        } else {
     392            this.source = this.options.source;
     393        }
     394    },
     395
     396    _searchTimeout: function( event ) {
     397        clearTimeout( this.searching );
     398        this.searching = this._delay(function() {
     399
     400            // Search if the value has changed, or if the user retypes the same value (see #7434)
     401            var equalValues = this.term === this._value(),
     402                menuVisible = this.menu.element.is( ":visible" ),
     403                modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
     404
     405            if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
     406                this.selectedItem = null;
     407                this.search( null, event );
     408            }
     409        }, this.options.delay );
     410    },
     411
     412    search: function( value, event ) {
     413        value = value != null ? value : this._value();
     414
     415        // always save the actual value, not the one passed as an argument
     416        this.term = this._value();
     417
     418        if ( value.length < this.options.minLength ) {
     419            return this.close( event );
     420        }
     421
     422        if ( this._trigger( "search", event ) === false ) {
     423            return;
     424        }
     425
     426        return this._search( value );
     427    },
     428
     429    _search: function( value ) {
     430        this.pending++;
     431        this.element.addClass( "ui-autocomplete-loading" );
     432        this.cancelSearch = false;
     433
     434        this.source( { term: value }, this._response() );
     435    },
     436
     437    _response: function() {
     438        var index = ++this.requestIndex;
     439
     440        return $.proxy(function( content ) {
     441            if ( index === this.requestIndex ) {
     442                this.__response( content );
     443            }
     444
     445            this.pending--;
     446            if ( !this.pending ) {
     447                this.element.removeClass( "ui-autocomplete-loading" );
     448            }
     449        }, this );
     450    },
     451
     452    __response: function( content ) {
     453        if ( content ) {
     454            content = this._normalize( content );
     455        }
     456        this._trigger( "response", null, { content: content } );
     457        if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
     458            this._suggest( content );
     459            this._trigger( "open" );
     460        } else {
     461            // use ._close() instead of .close() so we don't cancel future searches
     462            this._close();
     463        }
     464    },
     465
     466    close: function( event ) {
     467        this.cancelSearch = true;
     468        this._close( event );
     469    },
     470
     471    _close: function( event ) {
     472        if ( this.menu.element.is( ":visible" ) ) {
     473            this.menu.element.hide();
     474            this.menu.blur();
     475            this.isNewMenu = true;
     476            this._trigger( "close", event );
     477        }
     478    },
     479
     480    _change: function( event ) {
     481        if ( this.previous !== this._value() ) {
     482            this._trigger( "change", event, { item: this.selectedItem } );
     483        }
     484    },
     485
     486    _normalize: function( items ) {
     487        // assume all items have the right format when the first item is complete
     488        if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
     489            return items;
     490        }
     491        return $.map( items, function( item ) {
     492            if ( typeof item === "string" ) {
     493                return {
     494                    label: item,
     495                    value: item
     496                };
     497            }
     498            return $.extend( {}, item, {
     499                label: item.label || item.value,
     500                value: item.value || item.label
     501            });
     502        });
     503    },
     504
     505    _suggest: function( items ) {
     506        var ul = this.menu.element.empty();
     507        this._renderMenu( ul, items );
     508        this.isNewMenu = true;
     509        this.menu.refresh();
     510
     511        // size and position menu
     512        ul.show();
     513        this._resizeMenu();
     514        ul.position( $.extend({
     515            of: this.element
     516        }, this.options.position ) );
     517
     518        if ( this.options.autoFocus ) {
     519            this.menu.next();
     520        }
     521    },
     522
     523    _resizeMenu: function() {
     524        var ul = this.menu.element;
     525        ul.outerWidth( Math.max(
     526            // Firefox wraps long text (possibly a rounding bug)
     527            // so we add 1px to avoid the wrapping (#7513)
     528            ul.width( "" ).outerWidth() + 1,
     529            this.element.outerWidth()
     530        ) );
     531    },
     532
     533    _renderMenu: function( ul, items ) {
     534        var that = this;
     535        $.each( items, function( index, item ) {
     536            that._renderItemData( ul, item );
     537        });
     538    },
     539
     540    _renderItemData: function( ul, item ) {
     541        return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
     542    },
     543
     544    _renderItem: function( ul, item ) {
     545        return $( "<li>" ).text( item.label ).appendTo( ul );
     546    },
     547
     548    _move: function( direction, event ) {
     549        if ( !this.menu.element.is( ":visible" ) ) {
     550            this.search( null, event );
     551            return;
     552        }
     553        if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
     554                this.menu.isLastItem() && /^next/.test( direction ) ) {
     555
     556            if ( !this.isMultiLine ) {
     557                this._value( this.term );
     558            }
     559
     560            this.menu.blur();
     561            return;
     562        }
     563        this.menu[ direction ]( event );
     564    },
     565
     566    widget: function() {
     567        return this.menu.element;
     568    },
     569
     570    _value: function() {
     571        return this.valueMethod.apply( this.element, arguments );
     572    },
     573
     574    _keyEvent: function( keyEvent, event ) {
     575        if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
     576            this._move( keyEvent, event );
     577
     578            // prevents moving cursor to beginning/end of the text field in some browsers
     579            event.preventDefault();
     580        }
     581    }
     582});
     583
     584$.extend( $.ui.autocomplete, {
     585    escapeRegex: function( value ) {
     586        return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
     587    },
     588    filter: function( array, term ) {
     589        var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
     590        return $.grep( array, function( value ) {
     591            return matcher.test( value.label || value.value || value );
     592        });
     593    }
     594});
     595
     596// live region extension, adding a `messages` option
     597// NOTE: This is an experimental API. We are still investigating
     598// a full solution for string manipulation and internationalization.
     599$.widget( "ui.autocomplete", $.ui.autocomplete, {
     600    options: {
     601        messages: {
     602            noResults: "No search results.",
     603            results: function( amount ) {
     604                return amount + ( amount > 1 ? " results are" : " result is" ) +
     605                    " available, use up and down arrow keys to navigate.";
     606            }
     607        }
     608    },
     609
     610    __response: function( content ) {
     611        var message;
     612        this._superApply( arguments );
     613        if ( this.options.disabled || this.cancelSearch ) {
     614            return;
     615        }
     616        if ( content && content.length ) {
     617            message = this.options.messages.results( content.length );
     618        } else {
     619            message = this.options.messages.noResults;
     620        }
     621        this.liveRegion.children().hide();
     622        $( "<div>" ).text( message ).appendTo( this.liveRegion );
     623    }
     624});
     625
     626return $.ui.autocomplete;
     627
     628}));
  • trunk/src/wp-includes/js/jquery/ui/button.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){var e,i="ui-button ui-widget ui-state-default ui-corner-all",s="ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",n=function(){var e=t(this);setTimeout(function(){e.find(":ui-button").button("refresh")},1)},a=function(e){var i=e.name,s=e.form,n=t([]);return i&&(i=i.replace(/'/g,"\\'"),n=s?t(s).find("[name='"+i+"']"):t("[name='"+i+"']",e.ownerDocument).filter(function(){return!this.form})),n};t.widget("ui.button",{version:"1.10.4",defaultElement:"<button>",options:{disabled:null,text:!0,label:null,icons:{primary:null,secondary:null}},_create:function(){this.element.closest("form").unbind("reset"+this.eventNamespace).bind("reset"+this.eventNamespace,n),"boolean"!=typeof this.options.disabled?this.options.disabled=!!this.element.prop("disabled"):this.element.prop("disabled",this.options.disabled),this._determineButtonType(),this.hasTitle=!!this.buttonElement.attr("title");var s=this,o=this.options,r="checkbox"===this.type||"radio"===this.type,h=r?"":"ui-state-active";null===o.label&&(o.label="input"===this.type?this.buttonElement.val():this.buttonElement.html()),this._hoverable(this.buttonElement),this.buttonElement.addClass(i).attr("role","button").bind("mouseenter"+this.eventNamespace,function(){o.disabled||this===e&&t(this).addClass("ui-state-active")}).bind("mouseleave"+this.eventNamespace,function(){o.disabled||t(this).removeClass(h)}).bind("click"+this.eventNamespace,function(t){o.disabled&&(t.preventDefault(),t.stopImmediatePropagation())}),this._on({focus:function(){this.buttonElement.addClass("ui-state-focus")},blur:function(){this.buttonElement.removeClass("ui-state-focus")}}),r&&this.element.bind("change"+this.eventNamespace,function(){s.refresh()}),"checkbox"===this.type?this.buttonElement.bind("click"+this.eventNamespace,function(){return o.disabled?!1:undefined}):"radio"===this.type?this.buttonElement.bind("click"+this.eventNamespace,function(){if(o.disabled)return!1;t(this).addClass("ui-state-active"),s.buttonElement.attr("aria-pressed","true");var e=s.element[0];a(e).not(e).map(function(){return t(this).button("widget")[0]}).removeClass("ui-state-active").attr("aria-pressed","false")}):(this.buttonElement.bind("mousedown"+this.eventNamespace,function(){return o.disabled?!1:(t(this).addClass("ui-state-active"),e=this,s.document.one("mouseup",function(){e=null}),undefined)}).bind("mouseup"+this.eventNamespace,function(){return o.disabled?!1:(t(this).removeClass("ui-state-active"),undefined)}).bind("keydown"+this.eventNamespace,function(e){return o.disabled?!1:((e.keyCode===t.ui.keyCode.SPACE||e.keyCode===t.ui.keyCode.ENTER)&&t(this).addClass("ui-state-active"),undefined)}).bind("keyup"+this.eventNamespace+" blur"+this.eventNamespace,function(){t(this).removeClass("ui-state-active")}),this.buttonElement.is("a")&&this.buttonElement.keyup(function(e){e.keyCode===t.ui.keyCode.SPACE&&t(this).click()})),this._setOption("disabled",o.disabled),this._resetButton()},_determineButtonType:function(){var t,e,i;this.type=this.element.is("[type=checkbox]")?"checkbox":this.element.is("[type=radio]")?"radio":this.element.is("input")?"input":"button","checkbox"===this.type||"radio"===this.type?(t=this.element.parents().last(),e="label[for='"+this.element.attr("id")+"']",this.buttonElement=t.find(e),this.buttonElement.length||(t=t.length?t.siblings():this.element.siblings(),this.buttonElement=t.filter(e),this.buttonElement.length||(this.buttonElement=t.find(e))),this.element.addClass("ui-helper-hidden-accessible"),i=this.element.is(":checked"),i&&this.buttonElement.addClass("ui-state-active"),this.buttonElement.prop("aria-pressed",i)):this.buttonElement=this.element},widget:function(){return this.buttonElement},_destroy:function(){this.element.removeClass("ui-helper-hidden-accessible"),this.buttonElement.removeClass(i+" ui-state-active "+s).removeAttr("role").removeAttr("aria-pressed").html(this.buttonElement.find(".ui-button-text").html()),this.hasTitle||this.buttonElement.removeAttr("title")},_setOption:function(t,e){return this._super(t,e),"disabled"===t?(this.element.prop("disabled",!!e),e&&this.buttonElement.removeClass("ui-state-focus"),undefined):(this._resetButton(),undefined)},refresh:function(){var e=this.element.is("input, button")?this.element.is(":disabled"):this.element.hasClass("ui-button-disabled");e!==this.options.disabled&&this._setOption("disabled",e),"radio"===this.type?a(this.element[0]).each(function(){t(this).is(":checked")?t(this).button("widget").addClass("ui-state-active").attr("aria-pressed","true"):t(this).button("widget").removeClass("ui-state-active").attr("aria-pressed","false")}):"checkbox"===this.type&&(this.element.is(":checked")?this.buttonElement.addClass("ui-state-active").attr("aria-pressed","true"):this.buttonElement.removeClass("ui-state-active").attr("aria-pressed","false"))},_resetButton:function(){if("input"===this.type)return this.options.label&&this.element.val(this.options.label),undefined;var e=this.buttonElement.removeClass(s),i=t("<span></span>",this.document[0]).addClass("ui-button-text").html(this.options.label).appendTo(e.empty()).text(),n=this.options.icons,a=n.primary&&n.secondary,o=[];n.primary||n.secondary?(this.options.text&&o.push("ui-button-text-icon"+(a?"s":n.primary?"-primary":"-secondary")),n.primary&&e.prepend("<span class='ui-button-icon-primary ui-icon "+n.primary+"'></span>"),n.secondary&&e.append("<span class='ui-button-icon-secondary ui-icon "+n.secondary+"'></span>"),this.options.text||(o.push(a?"ui-button-icons-only":"ui-button-icon-only"),this.hasTitle||e.attr("title",t.trim(i)))):o.push("ui-button-text-only"),e.addClass(o.join(" "))}}),t.widget("ui.buttonset",{version:"1.10.4",options:{items:"button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"},_create:function(){this.element.addClass("ui-buttonset")},_init:function(){this.refresh()},_setOption:function(t,e){"disabled"===t&&this.buttons.button("option",t,e),this._super(t,e)},refresh:function(){var e="rtl"===this.element.css("direction");this.buttons=this.element.find(this.options.items).filter(":ui-button").button("refresh").end().not(":ui-button").button().end().map(function(){return t(this).button("widget")[0]}).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":first").addClass(e?"ui-corner-right":"ui-corner-left").end().filter(":last").addClass(e?"ui-corner-left":"ui-corner-right").end().end()},_destroy:function(){this.element.removeClass("ui-buttonset"),this.buttons.map(function(){return t(this).button("widget")[0]}).removeClass("ui-corner-left ui-corner-right").end().button("destroy")}})})(jQuery);
     1/*!
     2 * jQuery UI Button 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/button/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./core",
     18            "./widget"
     19        ], factory );
     20    } else {
     21
     22        // Browser globals
     23        factory( jQuery );
     24    }
     25}(function( $ ) {
     26
     27var lastActive,
     28    baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
     29    typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
     30    formResetHandler = function() {
     31        var form = $( this );
     32        setTimeout(function() {
     33            form.find( ":ui-button" ).button( "refresh" );
     34        }, 1 );
     35    },
     36    radioGroup = function( radio ) {
     37        var name = radio.name,
     38            form = radio.form,
     39            radios = $( [] );
     40        if ( name ) {
     41            name = name.replace( /'/g, "\\'" );
     42            if ( form ) {
     43                radios = $( form ).find( "[name='" + name + "'][type=radio]" );
     44            } else {
     45                radios = $( "[name='" + name + "'][type=radio]", radio.ownerDocument )
     46                    .filter(function() {
     47                        return !this.form;
     48                    });
     49            }
     50        }
     51        return radios;
     52    };
     53
     54$.widget( "ui.button", {
     55    version: "1.11.1",
     56    defaultElement: "<button>",
     57    options: {
     58        disabled: null,
     59        text: true,
     60        label: null,
     61        icons: {
     62            primary: null,
     63            secondary: null
     64        }
     65    },
     66    _create: function() {
     67        this.element.closest( "form" )
     68            .unbind( "reset" + this.eventNamespace )
     69            .bind( "reset" + this.eventNamespace, formResetHandler );
     70
     71        if ( typeof this.options.disabled !== "boolean" ) {
     72            this.options.disabled = !!this.element.prop( "disabled" );
     73        } else {
     74            this.element.prop( "disabled", this.options.disabled );
     75        }
     76
     77        this._determineButtonType();
     78        this.hasTitle = !!this.buttonElement.attr( "title" );
     79
     80        var that = this,
     81            options = this.options,
     82            toggleButton = this.type === "checkbox" || this.type === "radio",
     83            activeClass = !toggleButton ? "ui-state-active" : "";
     84
     85        if ( options.label === null ) {
     86            options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
     87        }
     88
     89        this._hoverable( this.buttonElement );
     90
     91        this.buttonElement
     92            .addClass( baseClasses )
     93            .attr( "role", "button" )
     94            .bind( "mouseenter" + this.eventNamespace, function() {
     95                if ( options.disabled ) {
     96                    return;
     97                }
     98                if ( this === lastActive ) {
     99                    $( this ).addClass( "ui-state-active" );
     100                }
     101            })
     102            .bind( "mouseleave" + this.eventNamespace, function() {
     103                if ( options.disabled ) {
     104                    return;
     105                }
     106                $( this ).removeClass( activeClass );
     107            })
     108            .bind( "click" + this.eventNamespace, function( event ) {
     109                if ( options.disabled ) {
     110                    event.preventDefault();
     111                    event.stopImmediatePropagation();
     112                }
     113            });
     114
     115        // Can't use _focusable() because the element that receives focus
     116        // and the element that gets the ui-state-focus class are different
     117        this._on({
     118            focus: function() {
     119                this.buttonElement.addClass( "ui-state-focus" );
     120            },
     121            blur: function() {
     122                this.buttonElement.removeClass( "ui-state-focus" );
     123            }
     124        });
     125
     126        if ( toggleButton ) {
     127            this.element.bind( "change" + this.eventNamespace, function() {
     128                that.refresh();
     129            });
     130        }
     131
     132        if ( this.type === "checkbox" ) {
     133            this.buttonElement.bind( "click" + this.eventNamespace, function() {
     134                if ( options.disabled ) {
     135                    return false;
     136                }
     137            });
     138        } else if ( this.type === "radio" ) {
     139            this.buttonElement.bind( "click" + this.eventNamespace, function() {
     140                if ( options.disabled ) {
     141                    return false;
     142                }
     143                $( this ).addClass( "ui-state-active" );
     144                that.buttonElement.attr( "aria-pressed", "true" );
     145
     146                var radio = that.element[ 0 ];
     147                radioGroup( radio )
     148                    .not( radio )
     149                    .map(function() {
     150                        return $( this ).button( "widget" )[ 0 ];
     151                    })
     152                    .removeClass( "ui-state-active" )
     153                    .attr( "aria-pressed", "false" );
     154            });
     155        } else {
     156            this.buttonElement
     157                .bind( "mousedown" + this.eventNamespace, function() {
     158                    if ( options.disabled ) {
     159                        return false;
     160                    }
     161                    $( this ).addClass( "ui-state-active" );
     162                    lastActive = this;
     163                    that.document.one( "mouseup", function() {
     164                        lastActive = null;
     165                    });
     166                })
     167                .bind( "mouseup" + this.eventNamespace, function() {
     168                    if ( options.disabled ) {
     169                        return false;
     170                    }
     171                    $( this ).removeClass( "ui-state-active" );
     172                })
     173                .bind( "keydown" + this.eventNamespace, function(event) {
     174                    if ( options.disabled ) {
     175                        return false;
     176                    }
     177                    if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
     178                        $( this ).addClass( "ui-state-active" );
     179                    }
     180                })
     181                // see #8559, we bind to blur here in case the button element loses
     182                // focus between keydown and keyup, it would be left in an "active" state
     183                .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
     184                    $( this ).removeClass( "ui-state-active" );
     185                });
     186
     187            if ( this.buttonElement.is("a") ) {
     188                this.buttonElement.keyup(function(event) {
     189                    if ( event.keyCode === $.ui.keyCode.SPACE ) {
     190                        // TODO pass through original event correctly (just as 2nd argument doesn't work)
     191                        $( this ).click();
     192                    }
     193                });
     194            }
     195        }
     196
     197        this._setOption( "disabled", options.disabled );
     198        this._resetButton();
     199    },
     200
     201    _determineButtonType: function() {
     202        var ancestor, labelSelector, checked;
     203
     204        if ( this.element.is("[type=checkbox]") ) {
     205            this.type = "checkbox";
     206        } else if ( this.element.is("[type=radio]") ) {
     207            this.type = "radio";
     208        } else if ( this.element.is("input") ) {
     209            this.type = "input";
     210        } else {
     211            this.type = "button";
     212        }
     213
     214        if ( this.type === "checkbox" || this.type === "radio" ) {
     215            // we don't search against the document in case the element
     216            // is disconnected from the DOM
     217            ancestor = this.element.parents().last();
     218            labelSelector = "label[for='" + this.element.attr("id") + "']";
     219            this.buttonElement = ancestor.find( labelSelector );
     220            if ( !this.buttonElement.length ) {
     221                ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
     222                this.buttonElement = ancestor.filter( labelSelector );
     223                if ( !this.buttonElement.length ) {
     224                    this.buttonElement = ancestor.find( labelSelector );
     225                }
     226            }
     227            this.element.addClass( "ui-helper-hidden-accessible" );
     228
     229            checked = this.element.is( ":checked" );
     230            if ( checked ) {
     231                this.buttonElement.addClass( "ui-state-active" );
     232            }
     233            this.buttonElement.prop( "aria-pressed", checked );
     234        } else {
     235            this.buttonElement = this.element;
     236        }
     237    },
     238
     239    widget: function() {
     240        return this.buttonElement;
     241    },
     242
     243    _destroy: function() {
     244        this.element
     245            .removeClass( "ui-helper-hidden-accessible" );
     246        this.buttonElement
     247            .removeClass( baseClasses + " ui-state-active " + typeClasses )
     248            .removeAttr( "role" )
     249            .removeAttr( "aria-pressed" )
     250            .html( this.buttonElement.find(".ui-button-text").html() );
     251
     252        if ( !this.hasTitle ) {
     253            this.buttonElement.removeAttr( "title" );
     254        }
     255    },
     256
     257    _setOption: function( key, value ) {
     258        this._super( key, value );
     259        if ( key === "disabled" ) {
     260            this.widget().toggleClass( "ui-state-disabled", !!value );
     261            this.element.prop( "disabled", !!value );
     262            if ( value ) {
     263                if ( this.type === "checkbox" || this.type === "radio" ) {
     264                    this.buttonElement.removeClass( "ui-state-focus" );
     265                } else {
     266                    this.buttonElement.removeClass( "ui-state-focus ui-state-active" );
     267                }
     268            }
     269            return;
     270        }
     271        this._resetButton();
     272    },
     273
     274    refresh: function() {
     275        //See #8237 & #8828
     276        var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
     277
     278        if ( isDisabled !== this.options.disabled ) {
     279            this._setOption( "disabled", isDisabled );
     280        }
     281        if ( this.type === "radio" ) {
     282            radioGroup( this.element[0] ).each(function() {
     283                if ( $( this ).is( ":checked" ) ) {
     284                    $( this ).button( "widget" )
     285                        .addClass( "ui-state-active" )
     286                        .attr( "aria-pressed", "true" );
     287                } else {
     288                    $( this ).button( "widget" )
     289                        .removeClass( "ui-state-active" )
     290                        .attr( "aria-pressed", "false" );
     291                }
     292            });
     293        } else if ( this.type === "checkbox" ) {
     294            if ( this.element.is( ":checked" ) ) {
     295                this.buttonElement
     296                    .addClass( "ui-state-active" )
     297                    .attr( "aria-pressed", "true" );
     298            } else {
     299                this.buttonElement
     300                    .removeClass( "ui-state-active" )
     301                    .attr( "aria-pressed", "false" );
     302            }
     303        }
     304    },
     305
     306    _resetButton: function() {
     307        if ( this.type === "input" ) {
     308            if ( this.options.label ) {
     309                this.element.val( this.options.label );
     310            }
     311            return;
     312        }
     313        var buttonElement = this.buttonElement.removeClass( typeClasses ),
     314            buttonText = $( "<span></span>", this.document[0] )
     315                .addClass( "ui-button-text" )
     316                .html( this.options.label )
     317                .appendTo( buttonElement.empty() )
     318                .text(),
     319            icons = this.options.icons,
     320            multipleIcons = icons.primary && icons.secondary,
     321            buttonClasses = [];
     322
     323        if ( icons.primary || icons.secondary ) {
     324            if ( this.options.text ) {
     325                buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
     326            }
     327
     328            if ( icons.primary ) {
     329                buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
     330            }
     331
     332            if ( icons.secondary ) {
     333                buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
     334            }
     335
     336            if ( !this.options.text ) {
     337                buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
     338
     339                if ( !this.hasTitle ) {
     340                    buttonElement.attr( "title", $.trim( buttonText ) );
     341                }
     342            }
     343        } else {
     344            buttonClasses.push( "ui-button-text-only" );
     345        }
     346        buttonElement.addClass( buttonClasses.join( " " ) );
     347    }
     348});
     349
     350$.widget( "ui.buttonset", {
     351    version: "1.11.1",
     352    options: {
     353        items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
     354    },
     355
     356    _create: function() {
     357        this.element.addClass( "ui-buttonset" );
     358    },
     359
     360    _init: function() {
     361        this.refresh();
     362    },
     363
     364    _setOption: function( key, value ) {
     365        if ( key === "disabled" ) {
     366            this.buttons.button( "option", key, value );
     367        }
     368
     369        this._super( key, value );
     370    },
     371
     372    refresh: function() {
     373        var rtl = this.element.css( "direction" ) === "rtl",
     374            allButtons = this.element.find( this.options.items ),
     375            existingButtons = allButtons.filter( ":ui-button" );
     376
     377        // Initialize new buttons
     378        allButtons.not( ":ui-button" ).button();
     379
     380        // Refresh existing buttons
     381        existingButtons.button( "refresh" );
     382
     383        this.buttons = allButtons
     384            .map(function() {
     385                return $( this ).button( "widget" )[ 0 ];
     386            })
     387                .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
     388                .filter( ":first" )
     389                    .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
     390                .end()
     391                .filter( ":last" )
     392                    .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
     393                .end()
     394            .end();
     395    },
     396
     397    _destroy: function() {
     398        this.element.removeClass( "ui-buttonset" );
     399        this.buttons
     400            .map(function() {
     401                return $( this ).button( "widget" )[ 0 ];
     402            })
     403                .removeClass( "ui-corner-left ui-corner-right" )
     404            .end()
     405            .button( "destroy" );
     406    }
     407});
     408
     409return $.ui.button;
     410
     411}));
  • trunk/src/wp-includes/js/jquery/ui/core.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(e,t){function i(t,i){var a,n,r,o=t.nodeName.toLowerCase();return"area"===o?(a=t.parentNode,n=a.name,t.href&&n&&"map"===a.nodeName.toLowerCase()?(r=e("img[usemap=#"+n+"]")[0],!!r&&s(r)):!1):(/input|select|textarea|button|object/.test(o)?!t.disabled:"a"===o?t.href||i:i)&&s(t)}function s(t){return e.expr.filters.visible(t)&&!e(t).parents().addBack().filter(function(){return"hidden"===e.css(this,"visibility")}).length}var a=0,n=/^ui-id-\d+$/;e.ui=e.ui||{},e.extend(e.ui,{version:"1.10.4",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,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,SPACE:32,TAB:9,UP:38}}),e.fn.extend({focus:function(t){return function(i,s){return"number"==typeof i?this.each(function(){var t=this;setTimeout(function(){e(t).focus(),s&&s.call(t)},i)}):t.apply(this,arguments)}}(e.fn.focus),scrollParent:function(){var t;return t=e.ui.ie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(e.css(this,"position"))&&/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0),/fixed/.test(this.css("position"))||!t.length?e(document):t},zIndex:function(i){if(i!==t)return this.css("zIndex",i);if(this.length)for(var s,a,n=e(this[0]);n.length&&n[0]!==document;){if(s=n.css("position"),("absolute"===s||"relative"===s||"fixed"===s)&&(a=parseInt(n.css("zIndex"),10),!isNaN(a)&&0!==a))return a;n=n.parent()}return 0},uniqueId:function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++a)})},removeUniqueId:function(){return this.each(function(){n.test(this.id)&&e(this).removeAttr("id")})}}),e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(i){return!!e.data(i,t)}}):function(t,i,s){return!!e.data(t,s[3])},focusable:function(t){return i(t,!isNaN(e.attr(t,"tabindex")))},tabbable:function(t){var s=e.attr(t,"tabindex"),a=isNaN(s);return(a||s>=0)&&i(t,!a)}}),e("<a>").outerWidth(1).jquery||e.each(["Width","Height"],function(i,s){function a(t,i,s,a){return e.each(n,function(){i-=parseFloat(e.css(t,"padding"+this))||0,s&&(i-=parseFloat(e.css(t,"border"+this+"Width"))||0),a&&(i-=parseFloat(e.css(t,"margin"+this))||0)}),i}var n="Width"===s?["Left","Right"]:["Top","Bottom"],r=s.toLowerCase(),o={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+s]=function(i){return i===t?o["inner"+s].call(this):this.each(function(){e(this).css(r,a(this,i)+"px")})},e.fn["outer"+s]=function(t,i){return"number"!=typeof t?o["outer"+s].call(this,t):this.each(function(){e(this).css(r,a(this,t,!0,i)+"px")})}}),e.fn.addBack||(e.fn.addBack=function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}),e("<a>").data("a-b","a").removeData("a-b").data("a-b")&&(e.fn.removeData=function(t){return function(i){return arguments.length?t.call(this,e.camelCase(i)):t.call(this)}}(e.fn.removeData)),e.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),e.support.selectstart="onselectstart"in document.createElement("div"),e.fn.extend({disableSelection:function(){return this.bind((e.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(e){e.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),e.extend(e.ui,{plugin:{add:function(t,i,s){var a,n=e.ui[t].prototype;for(a in s)n.plugins[a]=n.plugins[a]||[],n.plugins[a].push([i,s[a]])},call:function(e,t,i){var s,a=e.plugins[t];if(a&&e.element[0].parentNode&&11!==e.element[0].parentNode.nodeType)for(s=0;a.length>s;s++)e.options[a[s][0]]&&a[s][1].apply(e.element,i)}},hasScroll:function(t,i){if("hidden"===e(t).css("overflow"))return!1;var s=i&&"left"===i?"scrollLeft":"scrollTop",a=!1;return t[s]>0?!0:(t[s]=1,a=t[s]>0,t[s]=0,a)}})})(jQuery);
     1/*!
     2 * jQuery UI Core 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/category/ui-core/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define( [ "jquery" ], factory );
     16    } else {
     17
     18        // Browser globals
     19        factory( jQuery );
     20    }
     21}(function( $ ) {
     22
     23// $.ui might exist from components with no dependencies, e.g., $.ui.position
     24$.ui = $.ui || {};
     25
     26$.extend( $.ui, {
     27    version: "1.11.1",
     28
     29    keyCode: {
     30        BACKSPACE: 8,
     31        COMMA: 188,
     32        DELETE: 46,
     33        DOWN: 40,
     34        END: 35,
     35        ENTER: 13,
     36        ESCAPE: 27,
     37        HOME: 36,
     38        LEFT: 37,
     39        PAGE_DOWN: 34,
     40        PAGE_UP: 33,
     41        PERIOD: 190,
     42        RIGHT: 39,
     43        SPACE: 32,
     44        TAB: 9,
     45        UP: 38
     46    }
     47});
     48
     49// plugins
     50$.fn.extend({
     51    scrollParent: function( includeHidden ) {
     52        var position = this.css( "position" ),
     53            excludeStaticParent = position === "absolute",
     54            overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
     55            scrollParent = this.parents().filter( function() {
     56                var parent = $( this );
     57                if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
     58                    return false;
     59                }
     60                return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
     61            }).eq( 0 );
     62
     63        return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
     64    },
     65
     66    uniqueId: (function() {
     67        var uuid = 0;
     68
     69        return function() {
     70            return this.each(function() {
     71                if ( !this.id ) {
     72                    this.id = "ui-id-" + ( ++uuid );
     73                }
     74            });
     75        };
     76    })(),
     77
     78    removeUniqueId: function() {
     79        return this.each(function() {
     80            if ( /^ui-id-\d+$/.test( this.id ) ) {
     81                $( this ).removeAttr( "id" );
     82            }
     83        });
     84    }
     85});
     86
     87// selectors
     88function focusable( element, isTabIndexNotNaN ) {
     89    var map, mapName, img,
     90        nodeName = element.nodeName.toLowerCase();
     91    if ( "area" === nodeName ) {
     92        map = element.parentNode;
     93        mapName = map.name;
     94        if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
     95            return false;
     96        }
     97        img = $( "img[usemap='#" + mapName + "']" )[ 0 ];
     98        return !!img && visible( img );
     99    }
     100    return ( /input|select|textarea|button|object/.test( nodeName ) ?
     101        !element.disabled :
     102        "a" === nodeName ?
     103            element.href || isTabIndexNotNaN :
     104            isTabIndexNotNaN) &&
     105        // the element and all of its ancestors must be visible
     106        visible( element );
     107}
     108
     109function visible( element ) {
     110    return $.expr.filters.visible( element ) &&
     111        !$( element ).parents().addBack().filter(function() {
     112            return $.css( this, "visibility" ) === "hidden";
     113        }).length;
     114}
     115
     116$.extend( $.expr[ ":" ], {
     117    data: $.expr.createPseudo ?
     118        $.expr.createPseudo(function( dataName ) {
     119            return function( elem ) {
     120                return !!$.data( elem, dataName );
     121            };
     122        }) :
     123        // support: jQuery <1.8
     124        function( elem, i, match ) {
     125            return !!$.data( elem, match[ 3 ] );
     126        },
     127
     128    focusable: function( element ) {
     129        return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
     130    },
     131
     132    tabbable: function( element ) {
     133        var tabIndex = $.attr( element, "tabindex" ),
     134            isTabIndexNaN = isNaN( tabIndex );
     135        return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
     136    }
     137});
     138
     139// support: jQuery <1.8
     140if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
     141    $.each( [ "Width", "Height" ], function( i, name ) {
     142        var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
     143            type = name.toLowerCase(),
     144            orig = {
     145                innerWidth: $.fn.innerWidth,
     146                innerHeight: $.fn.innerHeight,
     147                outerWidth: $.fn.outerWidth,
     148                outerHeight: $.fn.outerHeight
     149            };
     150
     151        function reduce( elem, size, border, margin ) {
     152            $.each( side, function() {
     153                size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
     154                if ( border ) {
     155                    size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
     156                }
     157                if ( margin ) {
     158                    size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
     159                }
     160            });
     161            return size;
     162        }
     163
     164        $.fn[ "inner" + name ] = function( size ) {
     165            if ( size === undefined ) {
     166                return orig[ "inner" + name ].call( this );
     167            }
     168
     169            return this.each(function() {
     170                $( this ).css( type, reduce( this, size ) + "px" );
     171            });
     172        };
     173
     174        $.fn[ "outer" + name] = function( size, margin ) {
     175            if ( typeof size !== "number" ) {
     176                return orig[ "outer" + name ].call( this, size );
     177            }
     178
     179            return this.each(function() {
     180                $( this).css( type, reduce( this, size, true, margin ) + "px" );
     181            });
     182        };
     183    });
     184}
     185
     186// support: jQuery <1.8
     187if ( !$.fn.addBack ) {
     188    $.fn.addBack = function( selector ) {
     189        return this.add( selector == null ?
     190            this.prevObject : this.prevObject.filter( selector )
     191        );
     192    };
     193}
     194
     195// support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
     196if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
     197    $.fn.removeData = (function( removeData ) {
     198        return function( key ) {
     199            if ( arguments.length ) {
     200                return removeData.call( this, $.camelCase( key ) );
     201            } else {
     202                return removeData.call( this );
     203            }
     204        };
     205    })( $.fn.removeData );
     206}
     207
     208// deprecated
     209$.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
     210
     211$.fn.extend({
     212    focus: (function( orig ) {
     213        return function( delay, fn ) {
     214            return typeof delay === "number" ?
     215                this.each(function() {
     216                    var elem = this;
     217                    setTimeout(function() {
     218                        $( elem ).focus();
     219                        if ( fn ) {
     220                            fn.call( elem );
     221                        }
     222                    }, delay );
     223                }) :
     224                orig.apply( this, arguments );
     225        };
     226    })( $.fn.focus ),
     227
     228    disableSelection: (function() {
     229        var eventType = "onselectstart" in document.createElement( "div" ) ?
     230            "selectstart" :
     231            "mousedown";
     232
     233        return function() {
     234            return this.bind( eventType + ".ui-disableSelection", function( event ) {
     235                event.preventDefault();
     236            });
     237        };
     238    })(),
     239
     240    enableSelection: function() {
     241        return this.unbind( ".ui-disableSelection" );
     242    },
     243
     244    zIndex: function( zIndex ) {
     245        if ( zIndex !== undefined ) {
     246            return this.css( "zIndex", zIndex );
     247        }
     248
     249        if ( this.length ) {
     250            var elem = $( this[ 0 ] ), position, value;
     251            while ( elem.length && elem[ 0 ] !== document ) {
     252                // Ignore z-index if position is set to a value where z-index is ignored by the browser
     253                // This makes behavior of this function consistent across browsers
     254                // WebKit always returns auto if the element is positioned
     255                position = elem.css( "position" );
     256                if ( position === "absolute" || position === "relative" || position === "fixed" ) {
     257                    // IE returns 0 when zIndex is not specified
     258                    // other browsers return a string
     259                    // we ignore the case of nested elements with an explicit value of 0
     260                    // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
     261                    value = parseInt( elem.css( "zIndex" ), 10 );
     262                    if ( !isNaN( value ) && value !== 0 ) {
     263                        return value;
     264                    }
     265                }
     266                elem = elem.parent();
     267            }
     268        }
     269
     270        return 0;
     271    }
     272});
     273
     274// $.ui.plugin is deprecated. Use $.widget() extensions instead.
     275$.ui.plugin = {
     276    add: function( module, option, set ) {
     277        var i,
     278            proto = $.ui[ module ].prototype;
     279        for ( i in set ) {
     280            proto.plugins[ i ] = proto.plugins[ i ] || [];
     281            proto.plugins[ i ].push( [ option, set[ i ] ] );
     282        }
     283    },
     284    call: function( instance, name, args, allowDisconnected ) {
     285        var i,
     286            set = instance.plugins[ name ];
     287
     288        if ( !set ) {
     289            return;
     290        }
     291
     292        if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
     293            return;
     294        }
     295
     296        for ( i = 0; i < set.length; i++ ) {
     297            if ( instance.options[ set[ i ][ 0 ] ] ) {
     298                set[ i ][ 1 ].apply( instance.element, args );
     299            }
     300        }
     301    }
     302};
     303
     304}));
  • trunk/src/wp-includes/js/jquery/ui/datepicker.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t,e){function i(){this._curInst=null,this._keyEvent=!1,this._disabledInputs=[],this._datepickerShowing=!1,this._inDialog=!1,this._mainDivId="ui-datepicker-div",this._inlineClass="ui-datepicker-inline",this._appendClass="ui-datepicker-append",this._triggerClass="ui-datepicker-trigger",this._dialogClass="ui-datepicker-dialog",this._disableClass="ui-datepicker-disabled",this._unselectableClass="ui-datepicker-unselectable",this._currentClass="ui-datepicker-current-day",this._dayOverClass="ui-datepicker-days-cell-over",this.regional=[],this.regional[""]={closeText:"Done",prevText:"Prev",nextText:"Next",currentText:"Today",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],weekHeader:"Wk",dateFormat:"mm/dd/yy",firstDay:0,isRTL:!1,showMonthAfterYear:!1,yearSuffix:""},this._defaults={showOn:"focus",showAnim:"fadeIn",showOptions:{},defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:!1,hideIfNoPrevNext:!1,navigationAsDateFormat:!1,gotoCurrent:!1,changeMonth:!1,changeYear:!1,yearRange:"c-10:c+10",showOtherMonths:!1,selectOtherMonths:!1,showWeek:!1,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",minDate:null,maxDate:null,duration:"fast",beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:"",altFormat:"",constrainInput:!0,showButtonPanel:!1,autoSize:!1,disabled:!1},t.extend(this._defaults,this.regional[""]),this.dpDiv=s(t("<div id='"+this._mainDivId+"' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"))}function s(e){var i="button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";return e.delegate(i,"mouseout",function(){t(this).removeClass("ui-state-hover"),-1!==this.className.indexOf("ui-datepicker-prev")&&t(this).removeClass("ui-datepicker-prev-hover"),-1!==this.className.indexOf("ui-datepicker-next")&&t(this).removeClass("ui-datepicker-next-hover")}).delegate(i,"mouseover",function(){t.datepicker._isDisabledDatepicker(a.inline?e.parent()[0]:a.input[0])||(t(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"),t(this).addClass("ui-state-hover"),-1!==this.className.indexOf("ui-datepicker-prev")&&t(this).addClass("ui-datepicker-prev-hover"),-1!==this.className.indexOf("ui-datepicker-next")&&t(this).addClass("ui-datepicker-next-hover"))})}function n(e,i){t.extend(e,i);for(var s in i)null==i[s]&&(e[s]=i[s]);return e}t.extend(t.ui,{datepicker:{version:"1.10.4"}});var a,r="datepicker";t.extend(i.prototype,{markerClassName:"hasDatepicker",maxRows:4,_widgetDatepicker:function(){return this.dpDiv},setDefaults:function(t){return n(this._defaults,t||{}),this},_attachDatepicker:function(e,i){var s,n,a;s=e.nodeName.toLowerCase(),n="div"===s||"span"===s,e.id||(this.uuid+=1,e.id="dp"+this.uuid),a=this._newInst(t(e),n),a.settings=t.extend({},i||{}),"input"===s?this._connectDatepicker(e,a):n&&this._inlineDatepicker(e,a)},_newInst:function(e,i){var n=e[0].id.replace(/([^A-Za-z0-9_\-])/g,"\\\\$1");return{id:n,input:e,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:i,dpDiv:i?s(t("<div class='"+this._inlineClass+" ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")):this.dpDiv}},_connectDatepicker:function(e,i){var s=t(e);i.append=t([]),i.trigger=t([]),s.hasClass(this.markerClassName)||(this._attachments(s,i),s.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp),this._autoSize(i),t.data(e,r,i),i.settings.disabled&&this._disableDatepicker(e))},_attachments:function(e,i){var s,n,a,r=this._get(i,"appendText"),o=this._get(i,"isRTL");i.append&&i.append.remove(),r&&(i.append=t("<span class='"+this._appendClass+"'>"+r+"</span>"),e[o?"before":"after"](i.append)),e.unbind("focus",this._showDatepicker),i.trigger&&i.trigger.remove(),s=this._get(i,"showOn"),("focus"===s||"both"===s)&&e.focus(this._showDatepicker),("button"===s||"both"===s)&&(n=this._get(i,"buttonText"),a=this._get(i,"buttonImage"),i.trigger=t(this._get(i,"buttonImageOnly")?t("<img/>").addClass(this._triggerClass).attr({src:a,alt:n,title:n}):t("<button type='button'></button>").addClass(this._triggerClass).html(a?t("<img/>").attr({src:a,alt:n,title:n}):n)),e[o?"before":"after"](i.trigger),i.trigger.click(function(){return t.datepicker._datepickerShowing&&t.datepicker._lastInput===e[0]?t.datepicker._hideDatepicker():t.datepicker._datepickerShowing&&t.datepicker._lastInput!==e[0]?(t.datepicker._hideDatepicker(),t.datepicker._showDatepicker(e[0])):t.datepicker._showDatepicker(e[0]),!1}))},_autoSize:function(t){if(this._get(t,"autoSize")&&!t.inline){var e,i,s,n,a=new Date(2009,11,20),r=this._get(t,"dateFormat");r.match(/[DM]/)&&(e=function(t){for(i=0,s=0,n=0;t.length>n;n++)t[n].length>i&&(i=t[n].length,s=n);return s},a.setMonth(e(this._get(t,r.match(/MM/)?"monthNames":"monthNamesShort"))),a.setDate(e(this._get(t,r.match(/DD/)?"dayNames":"dayNamesShort"))+20-a.getDay())),t.input.attr("size",this._formatDate(t,a).length)}},_inlineDatepicker:function(e,i){var s=t(e);s.hasClass(this.markerClassName)||(s.addClass(this.markerClassName).append(i.dpDiv),t.data(e,r,i),this._setDate(i,this._getDefaultDate(i),!0),this._updateDatepicker(i),this._updateAlternate(i),i.settings.disabled&&this._disableDatepicker(e),i.dpDiv.css("display","block"))},_dialogDatepicker:function(e,i,s,a,o){var h,l,c,u,d,p=this._dialogInst;return p||(this.uuid+=1,h="dp"+this.uuid,this._dialogInput=t("<input type='text' id='"+h+"' style='position: absolute; top: -100px; width: 0px;'/>"),this._dialogInput.keydown(this._doKeyDown),t("body").append(this._dialogInput),p=this._dialogInst=this._newInst(this._dialogInput,!1),p.settings={},t.data(this._dialogInput[0],r,p)),n(p.settings,a||{}),i=i&&i.constructor===Date?this._formatDate(p,i):i,this._dialogInput.val(i),this._pos=o?o.length?o:[o.pageX,o.pageY]:null,this._pos||(l=document.documentElement.clientWidth,c=document.documentElement.clientHeight,u=document.documentElement.scrollLeft||document.body.scrollLeft,d=document.documentElement.scrollTop||document.body.scrollTop,this._pos=[l/2-100+u,c/2-150+d]),this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px"),p.settings.onSelect=s,this._inDialog=!0,this.dpDiv.addClass(this._dialogClass),this._showDatepicker(this._dialogInput[0]),t.blockUI&&t.blockUI(this.dpDiv),t.data(this._dialogInput[0],r,p),this},_destroyDatepicker:function(e){var i,s=t(e),n=t.data(e,r);s.hasClass(this.markerClassName)&&(i=e.nodeName.toLowerCase(),t.removeData(e,r),"input"===i?(n.append.remove(),n.trigger.remove(),s.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)):("div"===i||"span"===i)&&s.removeClass(this.markerClassName).empty())},_enableDatepicker:function(e){var i,s,n=t(e),a=t.data(e,r);n.hasClass(this.markerClassName)&&(i=e.nodeName.toLowerCase(),"input"===i?(e.disabled=!1,a.trigger.filter("button").each(function(){this.disabled=!1}).end().filter("img").css({opacity:"1.0",cursor:""})):("div"===i||"span"===i)&&(s=n.children("."+this._inlineClass),s.children().removeClass("ui-state-disabled"),s.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled",!1)),this._disabledInputs=t.map(this._disabledInputs,function(t){return t===e?null:t}))},_disableDatepicker:function(e){var i,s,n=t(e),a=t.data(e,r);n.hasClass(this.markerClassName)&&(i=e.nodeName.toLowerCase(),"input"===i?(e.disabled=!0,a.trigger.filter("button").each(function(){this.disabled=!0}).end().filter("img").css({opacity:"0.5",cursor:"default"})):("div"===i||"span"===i)&&(s=n.children("."+this._inlineClass),s.children().addClass("ui-state-disabled"),s.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled",!0)),this._disabledInputs=t.map(this._disabledInputs,function(t){return t===e?null:t}),this._disabledInputs[this._disabledInputs.length]=e)},_isDisabledDatepicker:function(t){if(!t)return!1;for(var e=0;this._disabledInputs.length>e;e++)if(this._disabledInputs[e]===t)return!0;return!1},_getInst:function(e){try{return t.data(e,r)}catch(i){throw"Missing instance data for this datepicker"}},_optionDatepicker:function(i,s,a){var r,o,h,l,c=this._getInst(i);return 2===arguments.length&&"string"==typeof s?"defaults"===s?t.extend({},t.datepicker._defaults):c?"all"===s?t.extend({},c.settings):this._get(c,s):null:(r=s||{},"string"==typeof s&&(r={},r[s]=a),c&&(this._curInst===c&&this._hideDatepicker(),o=this._getDateDatepicker(i,!0),h=this._getMinMaxDate(c,"min"),l=this._getMinMaxDate(c,"max"),n(c.settings,r),null!==h&&r.dateFormat!==e&&r.minDate===e&&(c.settings.minDate=this._formatDate(c,h)),null!==l&&r.dateFormat!==e&&r.maxDate===e&&(c.settings.maxDate=this._formatDate(c,l)),"disabled"in r&&(r.disabled?this._disableDatepicker(i):this._enableDatepicker(i)),this._attachments(t(i),c),this._autoSize(c),this._setDate(c,o),this._updateAlternate(c),this._updateDatepicker(c)),e)},_changeDatepicker:function(t,e,i){this._optionDatepicker(t,e,i)},_refreshDatepicker:function(t){var e=this._getInst(t);e&&this._updateDatepicker(e)},_setDateDatepicker:function(t,e){var i=this._getInst(t);i&&(this._setDate(i,e),this._updateDatepicker(i),this._updateAlternate(i))},_getDateDatepicker:function(t,e){var i=this._getInst(t);return i&&!i.inline&&this._setDateFromField(i,e),i?this._getDate(i):null},_doKeyDown:function(e){var i,s,n,a=t.datepicker._getInst(e.target),r=!0,o=a.dpDiv.is(".ui-datepicker-rtl");if(a._keyEvent=!0,t.datepicker._datepickerShowing)switch(e.keyCode){case 9:t.datepicker._hideDatepicker(),r=!1;break;case 13:return n=t("td."+t.datepicker._dayOverClass+":not(."+t.datepicker._currentClass+")",a.dpDiv),n[0]&&t.datepicker._selectDay(e.target,a.selectedMonth,a.selectedYear,n[0]),i=t.datepicker._get(a,"onSelect"),i?(s=t.datepicker._formatDate(a),i.apply(a.input?a.input[0]:null,[s,a])):t.datepicker._hideDatepicker(),!1;case 27:t.datepicker._hideDatepicker();break;case 33:t.datepicker._adjustDate(e.target,e.ctrlKey?-t.datepicker._get(a,"stepBigMonths"):-t.datepicker._get(a,"stepMonths"),"M");break;case 34:t.datepicker._adjustDate(e.target,e.ctrlKey?+t.datepicker._get(a,"stepBigMonths"):+t.datepicker._get(a,"stepMonths"),"M");break;case 35:(e.ctrlKey||e.metaKey)&&t.datepicker._clearDate(e.target),r=e.ctrlKey||e.metaKey;break;case 36:(e.ctrlKey||e.metaKey)&&t.datepicker._gotoToday(e.target),r=e.ctrlKey||e.metaKey;break;case 37:(e.ctrlKey||e.metaKey)&&t.datepicker._adjustDate(e.target,o?1:-1,"D"),r=e.ctrlKey||e.metaKey,e.originalEvent.altKey&&t.datepicker._adjustDate(e.target,e.ctrlKey?-t.datepicker._get(a,"stepBigMonths"):-t.datepicker._get(a,"stepMonths"),"M");break;case 38:(e.ctrlKey||e.metaKey)&&t.datepicker._adjustDate(e.target,-7,"D"),r=e.ctrlKey||e.metaKey;break;case 39:(e.ctrlKey||e.metaKey)&&t.datepicker._adjustDate(e.target,o?-1:1,"D"),r=e.ctrlKey||e.metaKey,e.originalEvent.altKey&&t.datepicker._adjustDate(e.target,e.ctrlKey?+t.datepicker._get(a,"stepBigMonths"):+t.datepicker._get(a,"stepMonths"),"M");break;case 40:(e.ctrlKey||e.metaKey)&&t.datepicker._adjustDate(e.target,7,"D"),r=e.ctrlKey||e.metaKey;break;default:r=!1}else 36===e.keyCode&&e.ctrlKey?t.datepicker._showDatepicker(this):r=!1;r&&(e.preventDefault(),e.stopPropagation())},_doKeyPress:function(i){var s,n,a=t.datepicker._getInst(i.target);return t.datepicker._get(a,"constrainInput")?(s=t.datepicker._possibleChars(t.datepicker._get(a,"dateFormat")),n=String.fromCharCode(null==i.charCode?i.keyCode:i.charCode),i.ctrlKey||i.metaKey||" ">n||!s||s.indexOf(n)>-1):e},_doKeyUp:function(e){var i,s=t.datepicker._getInst(e.target);if(s.input.val()!==s.lastVal)try{i=t.datepicker.parseDate(t.datepicker._get(s,"dateFormat"),s.input?s.input.val():null,t.datepicker._getFormatConfig(s)),i&&(t.datepicker._setDateFromField(s),t.datepicker._updateAlternate(s),t.datepicker._updateDatepicker(s))}catch(n){}return!0},_showDatepicker:function(e){if(e=e.target||e,"input"!==e.nodeName.toLowerCase()&&(e=t("input",e.parentNode)[0]),!t.datepicker._isDisabledDatepicker(e)&&t.datepicker._lastInput!==e){var i,s,a,r,o,h,l;i=t.datepicker._getInst(e),t.datepicker._curInst&&t.datepicker._curInst!==i&&(t.datepicker._curInst.dpDiv.stop(!0,!0),i&&t.datepicker._datepickerShowing&&t.datepicker._hideDatepicker(t.datepicker._curInst.input[0])),s=t.datepicker._get(i,"beforeShow"),a=s?s.apply(e,[e,i]):{},a!==!1&&(n(i.settings,a),i.lastVal=null,t.datepicker._lastInput=e,t.datepicker._setDateFromField(i),t.datepicker._inDialog&&(e.value=""),t.datepicker._pos||(t.datepicker._pos=t.datepicker._findPos(e),t.datepicker._pos[1]+=e.offsetHeight),r=!1,t(e).parents().each(function(){return r|="fixed"===t(this).css("position"),!r}),o={left:t.datepicker._pos[0],top:t.datepicker._pos[1]},t.datepicker._pos=null,i.dpDiv.empty(),i.dpDiv.css({position:"absolute",display:"block",top:"-1000px"}),t.datepicker._updateDatepicker(i),o=t.datepicker._checkOffset(i,o,r),i.dpDiv.css({position:t.datepicker._inDialog&&t.blockUI?"static":r?"fixed":"absolute",display:"none",left:o.left+"px",top:o.top+"px"}),i.inline||(h=t.datepicker._get(i,"showAnim"),l=t.datepicker._get(i,"duration"),i.dpDiv.zIndex(t(e).zIndex()+1),t.datepicker._datepickerShowing=!0,t.effects&&t.effects.effect[h]?i.dpDiv.show(h,t.datepicker._get(i,"showOptions"),l):i.dpDiv[h||"show"](h?l:null),t.datepicker._shouldFocusInput(i)&&i.input.focus(),t.datepicker._curInst=i))}},_updateDatepicker:function(e){this.maxRows=4,a=e,e.dpDiv.empty().append(this._generateHTML(e)),this._attachHandlers(e),e.dpDiv.find("."+this._dayOverClass+" a").mouseover();var i,s=this._getNumberOfMonths(e),n=s[1],r=17;e.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width(""),n>1&&e.dpDiv.addClass("ui-datepicker-multi-"+n).css("width",r*n+"em"),e.dpDiv[(1!==s[0]||1!==s[1]?"add":"remove")+"Class"]("ui-datepicker-multi"),e.dpDiv[(this._get(e,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl"),e===t.datepicker._curInst&&t.datepicker._datepickerShowing&&t.datepicker._shouldFocusInput(e)&&e.input.focus(),e.yearshtml&&(i=e.yearshtml,setTimeout(function(){i===e.yearshtml&&e.yearshtml&&e.dpDiv.find("select.ui-datepicker-year:first").replaceWith(e.yearshtml),i=e.yearshtml=null},0))},_shouldFocusInput:function(t){return t.input&&t.input.is(":visible")&&!t.input.is(":disabled")&&!t.input.is(":focus")},_checkOffset:function(e,i,s){var n=e.dpDiv.outerWidth(),a=e.dpDiv.outerHeight(),r=e.input?e.input.outerWidth():0,o=e.input?e.input.outerHeight():0,h=document.documentElement.clientWidth+(s?0:t(document).scrollLeft()),l=document.documentElement.clientHeight+(s?0:t(document).scrollTop());return i.left-=this._get(e,"isRTL")?n-r:0,i.left-=s&&i.left===e.input.offset().left?t(document).scrollLeft():0,i.top-=s&&i.top===e.input.offset().top+o?t(document).scrollTop():0,i.left-=Math.min(i.left,i.left+n>h&&h>n?Math.abs(i.left+n-h):0),i.top-=Math.min(i.top,i.top+a>l&&l>a?Math.abs(a+o):0),i},_findPos:function(e){for(var i,s=this._getInst(e),n=this._get(s,"isRTL");e&&("hidden"===e.type||1!==e.nodeType||t.expr.filters.hidden(e));)e=e[n?"previousSibling":"nextSibling"];return i=t(e).offset(),[i.left,i.top]},_hideDatepicker:function(e){var i,s,n,a,o=this._curInst;!o||e&&o!==t.data(e,r)||this._datepickerShowing&&(i=this._get(o,"showAnim"),s=this._get(o,"duration"),n=function(){t.datepicker._tidyDialog(o)},t.effects&&(t.effects.effect[i]||t.effects[i])?o.dpDiv.hide(i,t.datepicker._get(o,"showOptions"),s,n):o.dpDiv["slideDown"===i?"slideUp":"fadeIn"===i?"fadeOut":"hide"](i?s:null,n),i||n(),this._datepickerShowing=!1,a=this._get(o,"onClose"),a&&a.apply(o.input?o.input[0]:null,[o.input?o.input.val():"",o]),this._lastInput=null,this._inDialog&&(this._dialogInput.css({position:"absolute",left:"0",top:"-100px"}),t.blockUI&&(t.unblockUI(),t("body").append(this.dpDiv))),this._inDialog=!1)},_tidyDialog:function(t){t.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")},_checkExternalClick:function(e){if(t.datepicker._curInst){var i=t(e.target),s=t.datepicker._getInst(i[0]);(i[0].id!==t.datepicker._mainDivId&&0===i.parents("#"+t.datepicker._mainDivId).length&&!i.hasClass(t.datepicker.markerClassName)&&!i.closest("."+t.datepicker._triggerClass).length&&t.datepicker._datepickerShowing&&(!t.datepicker._inDialog||!t.blockUI)||i.hasClass(t.datepicker.markerClassName)&&t.datepicker._curInst!==s)&&t.datepicker._hideDatepicker()}},_adjustDate:function(e,i,s){var n=t(e),a=this._getInst(n[0]);this._isDisabledDatepicker(n[0])||(this._adjustInstDate(a,i+("M"===s?this._get(a,"showCurrentAtPos"):0),s),this._updateDatepicker(a))},_gotoToday:function(e){var i,s=t(e),n=this._getInst(s[0]);this._get(n,"gotoCurrent")&&n.currentDay?(n.selectedDay=n.currentDay,n.drawMonth=n.selectedMonth=n.currentMonth,n.drawYear=n.selectedYear=n.currentYear):(i=new Date,n.selectedDay=i.getDate(),n.drawMonth=n.selectedMonth=i.getMonth(),n.drawYear=n.selectedYear=i.getFullYear()),this._notifyChange(n),this._adjustDate(s)},_selectMonthYear:function(e,i,s){var n=t(e),a=this._getInst(n[0]);a["selected"+("M"===s?"Month":"Year")]=a["draw"+("M"===s?"Month":"Year")]=parseInt(i.options[i.selectedIndex].value,10),this._notifyChange(a),this._adjustDate(n)},_selectDay:function(e,i,s,n){var a,r=t(e);t(n).hasClass(this._unselectableClass)||this._isDisabledDatepicker(r[0])||(a=this._getInst(r[0]),a.selectedDay=a.currentDay=t("a",n).html(),a.selectedMonth=a.currentMonth=i,a.selectedYear=a.currentYear=s,this._selectDate(e,this._formatDate(a,a.currentDay,a.currentMonth,a.currentYear)))},_clearDate:function(e){var i=t(e);this._selectDate(i,"")},_selectDate:function(e,i){var s,n=t(e),a=this._getInst(n[0]);i=null!=i?i:this._formatDate(a),a.input&&a.input.val(i),this._updateAlternate(a),s=this._get(a,"onSelect"),s?s.apply(a.input?a.input[0]:null,[i,a]):a.input&&a.input.trigger("change"),a.inline?this._updateDatepicker(a):(this._hideDatepicker(),this._lastInput=a.input[0],"object"!=typeof a.input[0]&&a.input.focus(),this._lastInput=null)},_updateAlternate:function(e){var i,s,n,a=this._get(e,"altField");a&&(i=this._get(e,"altFormat")||this._get(e,"dateFormat"),s=this._getDate(e),n=this.formatDate(i,s,this._getFormatConfig(e)),t(a).each(function(){t(this).val(n)}))},noWeekends:function(t){var e=t.getDay();return[e>0&&6>e,""]},iso8601Week:function(t){var e,i=new Date(t.getTime());return i.setDate(i.getDate()+4-(i.getDay()||7)),e=i.getTime(),i.setMonth(0),i.setDate(1),Math.floor(Math.round((e-i)/864e5)/7)+1},parseDate:function(i,s,n){if(null==i||null==s)throw"Invalid arguments";if(s="object"==typeof s?""+s:s+"",""===s)return null;var a,r,o,h,l=0,c=(n?n.shortYearCutoff:null)||this._defaults.shortYearCutoff,u="string"!=typeof c?c:(new Date).getFullYear()%100+parseInt(c,10),d=(n?n.dayNamesShort:null)||this._defaults.dayNamesShort,p=(n?n.dayNames:null)||this._defaults.dayNames,f=(n?n.monthNamesShort:null)||this._defaults.monthNamesShort,m=(n?n.monthNames:null)||this._defaults.monthNames,g=-1,v=-1,_=-1,b=-1,y=!1,x=function(t){var e=i.length>a+1&&i.charAt(a+1)===t;return e&&a++,e},k=function(t){var e=x(t),i="@"===t?14:"!"===t?20:"y"===t&&e?4:"o"===t?3:2,n=RegExp("^\\d{1,"+i+"}"),a=s.substring(l).match(n);if(!a)throw"Missing number at position "+l;return l+=a[0].length,parseInt(a[0],10)},w=function(i,n,a){var r=-1,o=t.map(x(i)?a:n,function(t,e){return[[e,t]]}).sort(function(t,e){return-(t[1].length-e[1].length)});if(t.each(o,function(t,i){var n=i[1];return s.substr(l,n.length).toLowerCase()===n.toLowerCase()?(r=i[0],l+=n.length,!1):e}),-1!==r)return r+1;throw"Unknown name at position "+l},D=function(){if(s.charAt(l)!==i.charAt(a))throw"Unexpected literal at position "+l;l++};for(a=0;i.length>a;a++)if(y)"'"!==i.charAt(a)||x("'")?D():y=!1;else switch(i.charAt(a)){case"d":_=k("d");break;case"D":w("D",d,p);break;case"o":b=k("o");break;case"m":v=k("m");break;case"M":v=w("M",f,m);break;case"y":g=k("y");break;case"@":h=new Date(k("@")),g=h.getFullYear(),v=h.getMonth()+1,_=h.getDate();break;case"!":h=new Date((k("!")-this._ticksTo1970)/1e4),g=h.getFullYear(),v=h.getMonth()+1,_=h.getDate();break;case"'":x("'")?D():y=!0;break;default:D()}if(s.length>l&&(o=s.substr(l),!/^\s+/.test(o)))throw"Extra/unparsed characters found in date: "+o;if(-1===g?g=(new Date).getFullYear():100>g&&(g+=(new Date).getFullYear()-(new Date).getFullYear()%100+(u>=g?0:-100)),b>-1)for(v=1,_=b;;){if(r=this._getDaysInMonth(g,v-1),r>=_)break;v++,_-=r}if(h=this._daylightSavingAdjust(new Date(g,v-1,_)),h.getFullYear()!==g||h.getMonth()+1!==v||h.getDate()!==_)throw"Invalid date";return h},ATOM:"yy-mm-dd",COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:1e7*60*60*24*(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925)),formatDate:function(t,e,i){if(!e)return"";var s,n=(i?i.dayNamesShort:null)||this._defaults.dayNamesShort,a=(i?i.dayNames:null)||this._defaults.dayNames,r=(i?i.monthNamesShort:null)||this._defaults.monthNamesShort,o=(i?i.monthNames:null)||this._defaults.monthNames,h=function(e){var i=t.length>s+1&&t.charAt(s+1)===e;return i&&s++,i},l=function(t,e,i){var s=""+e;if(h(t))for(;i>s.length;)s="0"+s;return s},c=function(t,e,i,s){return h(t)?s[e]:i[e]},u="",d=!1;if(e)for(s=0;t.length>s;s++)if(d)"'"!==t.charAt(s)||h("'")?u+=t.charAt(s):d=!1;else switch(t.charAt(s)){case"d":u+=l("d",e.getDate(),2);break;case"D":u+=c("D",e.getDay(),n,a);break;case"o":u+=l("o",Math.round((new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()-new Date(e.getFullYear(),0,0).getTime())/864e5),3);break;case"m":u+=l("m",e.getMonth()+1,2);break;case"M":u+=c("M",e.getMonth(),r,o);break;case"y":u+=h("y")?e.getFullYear():(10>e.getYear()%100?"0":"")+e.getYear()%100;break;case"@":u+=e.getTime();break;case"!":u+=1e4*e.getTime()+this._ticksTo1970;break;case"'":h("'")?u+="'":d=!0;break;default:u+=t.charAt(s)}return u},_possibleChars:function(t){var e,i="",s=!1,n=function(i){var s=t.length>e+1&&t.charAt(e+1)===i;return s&&e++,s};for(e=0;t.length>e;e++)if(s)"'"!==t.charAt(e)||n("'")?i+=t.charAt(e):s=!1;else switch(t.charAt(e)){case"d":case"m":case"y":case"@":i+="0123456789";break;case"D":case"M":return null;case"'":n("'")?i+="'":s=!0;break;default:i+=t.charAt(e)}return i},_get:function(t,i){return t.settings[i]!==e?t.settings[i]:this._defaults[i]},_setDateFromField:function(t,e){if(t.input.val()!==t.lastVal){var i=this._get(t,"dateFormat"),s=t.lastVal=t.input?t.input.val():null,n=this._getDefaultDate(t),a=n,r=this._getFormatConfig(t);try{a=this.parseDate(i,s,r)||n}catch(o){s=e?"":s}t.selectedDay=a.getDate(),t.drawMonth=t.selectedMonth=a.getMonth(),t.drawYear=t.selectedYear=a.getFullYear(),t.currentDay=s?a.getDate():0,t.currentMonth=s?a.getMonth():0,t.currentYear=s?a.getFullYear():0,this._adjustInstDate(t)}},_getDefaultDate:function(t){return this._restrictMinMax(t,this._determineDate(t,this._get(t,"defaultDate"),new Date))},_determineDate:function(e,i,s){var n=function(t){var e=new Date;return e.setDate(e.getDate()+t),e},a=function(i){try{return t.datepicker.parseDate(t.datepicker._get(e,"dateFormat"),i,t.datepicker._getFormatConfig(e))}catch(s){}for(var n=(i.toLowerCase().match(/^c/)?t.datepicker._getDate(e):null)||new Date,a=n.getFullYear(),r=n.getMonth(),o=n.getDate(),h=/([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,l=h.exec(i);l;){switch(l[2]||"d"){case"d":case"D":o+=parseInt(l[1],10);break;case"w":case"W":o+=7*parseInt(l[1],10);break;case"m":case"M":r+=parseInt(l[1],10),o=Math.min(o,t.datepicker._getDaysInMonth(a,r));break;case"y":case"Y":a+=parseInt(l[1],10),o=Math.min(o,t.datepicker._getDaysInMonth(a,r))}l=h.exec(i)}return new Date(a,r,o)},r=null==i||""===i?s:"string"==typeof i?a(i):"number"==typeof i?isNaN(i)?s:n(i):new Date(i.getTime());return r=r&&"Invalid Date"==""+r?s:r,r&&(r.setHours(0),r.setMinutes(0),r.setSeconds(0),r.setMilliseconds(0)),this._daylightSavingAdjust(r)},_daylightSavingAdjust:function(t){return t?(t.setHours(t.getHours()>12?t.getHours()+2:0),t):null},_setDate:function(t,e,i){var s=!e,n=t.selectedMonth,a=t.selectedYear,r=this._restrictMinMax(t,this._determineDate(t,e,new Date));t.selectedDay=t.currentDay=r.getDate(),t.drawMonth=t.selectedMonth=t.currentMonth=r.getMonth(),t.drawYear=t.selectedYear=t.currentYear=r.getFullYear(),n===t.selectedMonth&&a===t.selectedYear||i||this._notifyChange(t),this._adjustInstDate(t),t.input&&t.input.val(s?"":this._formatDate(t))},_getDate:function(t){var e=!t.currentYear||t.input&&""===t.input.val()?null:this._daylightSavingAdjust(new Date(t.currentYear,t.currentMonth,t.currentDay));return e},_attachHandlers:function(e){var i=this._get(e,"stepMonths"),s="#"+e.id.replace(/\\\\/g,"\\");e.dpDiv.find("[data-handler]").map(function(){var e={prev:function(){t.datepicker._adjustDate(s,-i,"M")},next:function(){t.datepicker._adjustDate(s,+i,"M")},hide:function(){t.datepicker._hideDatepicker()},today:function(){t.datepicker._gotoToday(s)},selectDay:function(){return t.datepicker._selectDay(s,+this.getAttribute("data-month"),+this.getAttribute("data-year"),this),!1},selectMonth:function(){return t.datepicker._selectMonthYear(s,this,"M"),!1},selectYear:function(){return t.datepicker._selectMonthYear(s,this,"Y"),!1}};t(this).bind(this.getAttribute("data-event"),e[this.getAttribute("data-handler")])})},_generateHTML:function(t){var e,i,s,n,a,r,o,h,l,c,u,d,p,f,m,g,v,_,b,y,x,k,w,D,T,C,S,M,N,I,P,A,z,H,E,F,O,j,W,R=new Date,L=this._daylightSavingAdjust(new Date(R.getFullYear(),R.getMonth(),R.getDate())),Y=this._get(t,"isRTL"),B=this._get(t,"showButtonPanel"),K=this._get(t,"hideIfNoPrevNext"),J=this._get(t,"navigationAsDateFormat"),Q=this._getNumberOfMonths(t),V=this._get(t,"showCurrentAtPos"),U=this._get(t,"stepMonths"),q=1!==Q[0]||1!==Q[1],X=this._daylightSavingAdjust(t.currentDay?new Date(t.currentYear,t.currentMonth,t.currentDay):new Date(9999,9,9)),G=this._getMinMaxDate(t,"min"),$=this._getMinMaxDate(t,"max"),Z=t.drawMonth-V,te=t.drawYear;if(0>Z&&(Z+=12,te--),$)for(e=this._daylightSavingAdjust(new Date($.getFullYear(),$.getMonth()-Q[0]*Q[1]+1,$.getDate())),e=G&&G>e?G:e;this._daylightSavingAdjust(new Date(te,Z,1))>e;)Z--,0>Z&&(Z=11,te--);for(t.drawMonth=Z,t.drawYear=te,i=this._get(t,"prevText"),i=J?this.formatDate(i,this._daylightSavingAdjust(new Date(te,Z-U,1)),this._getFormatConfig(t)):i,s=this._canAdjustMonth(t,-1,te,Z)?"<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click' title='"+i+"'><span class='ui-icon ui-icon-circle-triangle-"+(Y?"e":"w")+"'>"+i+"</span></a>":K?"":"<a class='ui-datepicker-prev ui-corner-all ui-state-disabled' title='"+i+"'><span class='ui-icon ui-icon-circle-triangle-"+(Y?"e":"w")+"'>"+i+"</span></a>",n=this._get(t,"nextText"),n=J?this.formatDate(n,this._daylightSavingAdjust(new Date(te,Z+U,1)),this._getFormatConfig(t)):n,a=this._canAdjustMonth(t,1,te,Z)?"<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click' title='"+n+"'><span class='ui-icon ui-icon-circle-triangle-"+(Y?"w":"e")+"'>"+n+"</span></a>":K?"":"<a class='ui-datepicker-next ui-corner-all ui-state-disabled' title='"+n+"'><span class='ui-icon ui-icon-circle-triangle-"+(Y?"w":"e")+"'>"+n+"</span></a>",r=this._get(t,"currentText"),o=this._get(t,"gotoCurrent")&&t.currentDay?X:L,r=J?this.formatDate(r,o,this._getFormatConfig(t)):r,h=t.inline?"":"<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>"+this._get(t,"closeText")+"</button>",l=B?"<div class='ui-datepicker-buttonpane ui-widget-content'>"+(Y?h:"")+(this._isInRange(t,o)?"<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'>"+r+"</button>":"")+(Y?"":h)+"</div>":"",c=parseInt(this._get(t,"firstDay"),10),c=isNaN(c)?0:c,u=this._get(t,"showWeek"),d=this._get(t,"dayNames"),p=this._get(t,"dayNamesMin"),f=this._get(t,"monthNames"),m=this._get(t,"monthNamesShort"),g=this._get(t,"beforeShowDay"),v=this._get(t,"showOtherMonths"),_=this._get(t,"selectOtherMonths"),b=this._getDefaultDate(t),y="",k=0;Q[0]>k;k++){for(w="",this.maxRows=4,D=0;Q[1]>D;D++){if(T=this._daylightSavingAdjust(new Date(te,Z,t.selectedDay)),C=" ui-corner-all",S="",q){if(S+="<div class='ui-datepicker-group",Q[1]>1)switch(D){case 0:S+=" ui-datepicker-group-first",C=" ui-corner-"+(Y?"right":"left");break;case Q[1]-1:S+=" ui-datepicker-group-last",C=" ui-corner-"+(Y?"left":"right");break;default:S+=" ui-datepicker-group-middle",C=""}S+="'>"}for(S+="<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix"+C+"'>"+(/all|left/.test(C)&&0===k?Y?a:s:"")+(/all|right/.test(C)&&0===k?Y?s:a:"")+this._generateMonthYearHeader(t,Z,te,G,$,k>0||D>0,f,m)+"</div><table class='ui-datepicker-calendar'><thead>"+"<tr>",M=u?"<th class='ui-datepicker-week-col'>"+this._get(t,"weekHeader")+"</th>":"",x=0;7>x;x++)N=(x+c)%7,M+="<th"+((x+c+6)%7>=5?" class='ui-datepicker-week-end'":"")+">"+"<span title='"+d[N]+"'>"+p[N]+"</span></th>";for(S+=M+"</tr></thead><tbody>",I=this._getDaysInMonth(te,Z),te===t.selectedYear&&Z===t.selectedMonth&&(t.selectedDay=Math.min(t.selectedDay,I)),P=(this._getFirstDayOfMonth(te,Z)-c+7)%7,A=Math.ceil((P+I)/7),z=q?this.maxRows>A?this.maxRows:A:A,this.maxRows=z,H=this._daylightSavingAdjust(new Date(te,Z,1-P)),E=0;z>E;E++){for(S+="<tr>",F=u?"<td class='ui-datepicker-week-col'>"+this._get(t,"calculateWeek")(H)+"</td>":"",x=0;7>x;x++)O=g?g.apply(t.input?t.input[0]:null,[H]):[!0,""],j=H.getMonth()!==Z,W=j&&!_||!O[0]||G&&G>H||$&&H>$,F+="<td class='"+((x+c+6)%7>=5?" ui-datepicker-week-end":"")+(j?" ui-datepicker-other-month":"")+(H.getTime()===T.getTime()&&Z===t.selectedMonth&&t._keyEvent||b.getTime()===H.getTime()&&b.getTime()===T.getTime()?" "+this._dayOverClass:"")+(W?" "+this._unselectableClass+" ui-state-disabled":"")+(j&&!v?"":" "+O[1]+(H.getTime()===X.getTime()?" "+this._currentClass:"")+(H.getTime()===L.getTime()?" ui-datepicker-today":""))+"'"+(j&&!v||!O[2]?"":" title='"+O[2].replace(/'/g,"&#39;")+"'")+(W?"":" data-handler='selectDay' data-event='click' data-month='"+H.getMonth()+"' data-year='"+H.getFullYear()+"'")+">"+(j&&!v?"&#xa0;":W?"<span class='ui-state-default'>"+H.getDate()+"</span>":"<a class='ui-state-default"+(H.getTime()===L.getTime()?" ui-state-highlight":"")+(H.getTime()===X.getTime()?" ui-state-active":"")+(j?" ui-priority-secondary":"")+"' href='#'>"+H.getDate()+"</a>")+"</td>",H.setDate(H.getDate()+1),H=this._daylightSavingAdjust(H);S+=F+"</tr>"}Z++,Z>11&&(Z=0,te++),S+="</tbody></table>"+(q?"</div>"+(Q[0]>0&&D===Q[1]-1?"<div class='ui-datepicker-row-break'></div>":""):""),w+=S}y+=w}return y+=l,t._keyEvent=!1,y},_generateMonthYearHeader:function(t,e,i,s,n,a,r,o){var h,l,c,u,d,p,f,m,g=this._get(t,"changeMonth"),v=this._get(t,"changeYear"),_=this._get(t,"showMonthAfterYear"),b="<div class='ui-datepicker-title'>",y="";if(a||!g)y+="<span class='ui-datepicker-month'>"+r[e]+"</span>";else{for(h=s&&s.getFullYear()===i,l=n&&n.getFullYear()===i,y+="<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>",c=0;12>c;c++)(!h||c>=s.getMonth())&&(!l||n.getMonth()>=c)&&(y+="<option value='"+c+"'"+(c===e?" selected='selected'":"")+">"+o[c]+"</option>");y+="</select>"}if(_||(b+=y+(!a&&g&&v?"":"&#xa0;")),!t.yearshtml)if(t.yearshtml="",a||!v)b+="<span class='ui-datepicker-year'>"+i+"</span>";else{for(u=this._get(t,"yearRange").split(":"),d=(new Date).getFullYear(),p=function(t){var e=t.match(/c[+\-].*/)?i+parseInt(t.substring(1),10):t.match(/[+\-].*/)?d+parseInt(t,10):parseInt(t,10);
    5 return isNaN(e)?d:e},f=p(u[0]),m=Math.max(f,p(u[1]||"")),f=s?Math.max(f,s.getFullYear()):f,m=n?Math.min(m,n.getFullYear()):m,t.yearshtml+="<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";m>=f;f++)t.yearshtml+="<option value='"+f+"'"+(f===i?" selected='selected'":"")+">"+f+"</option>";t.yearshtml+="</select>",b+=t.yearshtml,t.yearshtml=null}return b+=this._get(t,"yearSuffix"),_&&(b+=(!a&&g&&v?"":"&#xa0;")+y),b+="</div>"},_adjustInstDate:function(t,e,i){var s=t.drawYear+("Y"===i?e:0),n=t.drawMonth+("M"===i?e:0),a=Math.min(t.selectedDay,this._getDaysInMonth(s,n))+("D"===i?e:0),r=this._restrictMinMax(t,this._daylightSavingAdjust(new Date(s,n,a)));t.selectedDay=r.getDate(),t.drawMonth=t.selectedMonth=r.getMonth(),t.drawYear=t.selectedYear=r.getFullYear(),("M"===i||"Y"===i)&&this._notifyChange(t)},_restrictMinMax:function(t,e){var i=this._getMinMaxDate(t,"min"),s=this._getMinMaxDate(t,"max"),n=i&&i>e?i:e;return s&&n>s?s:n},_notifyChange:function(t){var e=this._get(t,"onChangeMonthYear");e&&e.apply(t.input?t.input[0]:null,[t.selectedYear,t.selectedMonth+1,t])},_getNumberOfMonths:function(t){var e=this._get(t,"numberOfMonths");return null==e?[1,1]:"number"==typeof e?[1,e]:e},_getMinMaxDate:function(t,e){return this._determineDate(t,this._get(t,e+"Date"),null)},_getDaysInMonth:function(t,e){return 32-this._daylightSavingAdjust(new Date(t,e,32)).getDate()},_getFirstDayOfMonth:function(t,e){return new Date(t,e,1).getDay()},_canAdjustMonth:function(t,e,i,s){var n=this._getNumberOfMonths(t),a=this._daylightSavingAdjust(new Date(i,s+(0>e?e:n[0]*n[1]),1));return 0>e&&a.setDate(this._getDaysInMonth(a.getFullYear(),a.getMonth())),this._isInRange(t,a)},_isInRange:function(t,e){var i,s,n=this._getMinMaxDate(t,"min"),a=this._getMinMaxDate(t,"max"),r=null,o=null,h=this._get(t,"yearRange");return h&&(i=h.split(":"),s=(new Date).getFullYear(),r=parseInt(i[0],10),o=parseInt(i[1],10),i[0].match(/[+\-].*/)&&(r+=s),i[1].match(/[+\-].*/)&&(o+=s)),(!n||e.getTime()>=n.getTime())&&(!a||e.getTime()<=a.getTime())&&(!r||e.getFullYear()>=r)&&(!o||o>=e.getFullYear())},_getFormatConfig:function(t){var e=this._get(t,"shortYearCutoff");return e="string"!=typeof e?e:(new Date).getFullYear()%100+parseInt(e,10),{shortYearCutoff:e,dayNamesShort:this._get(t,"dayNamesShort"),dayNames:this._get(t,"dayNames"),monthNamesShort:this._get(t,"monthNamesShort"),monthNames:this._get(t,"monthNames")}},_formatDate:function(t,e,i,s){e||(t.currentDay=t.selectedDay,t.currentMonth=t.selectedMonth,t.currentYear=t.selectedYear);var n=e?"object"==typeof e?e:this._daylightSavingAdjust(new Date(s,i,e)):this._daylightSavingAdjust(new Date(t.currentYear,t.currentMonth,t.currentDay));return this.formatDate(this._get(t,"dateFormat"),n,this._getFormatConfig(t))}}),t.fn.datepicker=function(e){if(!this.length)return this;t.datepicker.initialized||(t(document).mousedown(t.datepicker._checkExternalClick),t.datepicker.initialized=!0),0===t("#"+t.datepicker._mainDivId).length&&t("body").append(t.datepicker.dpDiv);var i=Array.prototype.slice.call(arguments,1);return"string"!=typeof e||"isDisabled"!==e&&"getDate"!==e&&"widget"!==e?"option"===e&&2===arguments.length&&"string"==typeof arguments[1]?t.datepicker["_"+e+"Datepicker"].apply(t.datepicker,[this[0]].concat(i)):this.each(function(){"string"==typeof e?t.datepicker["_"+e+"Datepicker"].apply(t.datepicker,[this].concat(i)):t.datepicker._attachDatepicker(this,e)}):t.datepicker["_"+e+"Datepicker"].apply(t.datepicker,[this[0]].concat(i))},t.datepicker=new i,t.datepicker.initialized=!1,t.datepicker.uuid=(new Date).getTime(),t.datepicker.version="1.10.4"})(jQuery);
     1/*!
     2 * jQuery UI Datepicker 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/datepicker/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./core"
     18        ], factory );
     19    } else {
     20
     21        // Browser globals
     22        factory( jQuery );
     23    }
     24}(function( $ ) {
     25
     26$.extend($.ui, { datepicker: { version: "1.11.1" } });
     27
     28var datepicker_instActive;
     29
     30function datepicker_getZindex( elem ) {
     31    var position, value;
     32    while ( elem.length && elem[ 0 ] !== document ) {
     33        // Ignore z-index if position is set to a value where z-index is ignored by the browser
     34        // This makes behavior of this function consistent across browsers
     35        // WebKit always returns auto if the element is positioned
     36        position = elem.css( "position" );
     37        if ( position === "absolute" || position === "relative" || position === "fixed" ) {
     38            // IE returns 0 when zIndex is not specified
     39            // other browsers return a string
     40            // we ignore the case of nested elements with an explicit value of 0
     41            // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
     42            value = parseInt( elem.css( "zIndex" ), 10 );
     43            if ( !isNaN( value ) && value !== 0 ) {
     44                return value;
     45            }
     46        }
     47        elem = elem.parent();
     48    }
     49
     50    return 0;
     51}
     52/* Date picker manager.
     53   Use the singleton instance of this class, $.datepicker, to interact with the date picker.
     54   Settings for (groups of) date pickers are maintained in an instance object,
     55   allowing multiple different settings on the same page. */
     56
     57function Datepicker() {
     58    this._curInst = null; // The current instance in use
     59    this._keyEvent = false; // If the last event was a key event
     60    this._disabledInputs = []; // List of date picker inputs that have been disabled
     61    this._datepickerShowing = false; // True if the popup picker is showing , false if not
     62    this._inDialog = false; // True if showing within a "dialog", false if not
     63    this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
     64    this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
     65    this._appendClass = "ui-datepicker-append"; // The name of the append marker class
     66    this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
     67    this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
     68    this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
     69    this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
     70    this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
     71    this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
     72    this.regional = []; // Available regional settings, indexed by language code
     73    this.regional[""] = { // Default regional settings
     74        closeText: "Done", // Display text for close link
     75        prevText: "Prev", // Display text for previous month link
     76        nextText: "Next", // Display text for next month link
     77        currentText: "Today", // Display text for current month link
     78        monthNames: ["January","February","March","April","May","June",
     79            "July","August","September","October","November","December"], // Names of months for drop-down and formatting
     80        monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
     81        dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
     82        dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
     83        dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
     84        weekHeader: "Wk", // Column header for week of the year
     85        dateFormat: "mm/dd/yy", // See format options on parseDate
     86        firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
     87        isRTL: false, // True if right-to-left language, false if left-to-right
     88        showMonthAfterYear: false, // True if the year select precedes month, false for month then year
     89        yearSuffix: "" // Additional text to append to the year in the month headers
     90    };
     91    this._defaults = { // Global defaults for all the date picker instances
     92        showOn: "focus", // "focus" for popup on focus,
     93            // "button" for trigger button, or "both" for either
     94        showAnim: "fadeIn", // Name of jQuery animation for popup
     95        showOptions: {}, // Options for enhanced animations
     96        defaultDate: null, // Used when field is blank: actual date,
     97            // +/-number for offset from today, null for today
     98        appendText: "", // Display text following the input box, e.g. showing the format
     99        buttonText: "...", // Text for trigger button
     100        buttonImage: "", // URL for trigger button image
     101        buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
     102        hideIfNoPrevNext: false, // True to hide next/previous month links
     103            // if not applicable, false to just disable them
     104        navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
     105        gotoCurrent: false, // True if today link goes back to current selection instead
     106        changeMonth: false, // True if month can be selected directly, false if only prev/next
     107        changeYear: false, // True if year can be selected directly, false if only prev/next
     108        yearRange: "c-10:c+10", // Range of years to display in drop-down,
     109            // either relative to today's year (-nn:+nn), relative to currently displayed year
     110            // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
     111        showOtherMonths: false, // True to show dates in other months, false to leave blank
     112        selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
     113        showWeek: false, // True to show week of the year, false to not show it
     114        calculateWeek: this.iso8601Week, // How to calculate the week of the year,
     115            // takes a Date and returns the number of the week for it
     116        shortYearCutoff: "+10", // Short year values < this are in the current century,
     117            // > this are in the previous century,
     118            // string value starting with "+" for current year + value
     119        minDate: null, // The earliest selectable date, or null for no limit
     120        maxDate: null, // The latest selectable date, or null for no limit
     121        duration: "fast", // Duration of display/closure
     122        beforeShowDay: null, // Function that takes a date and returns an array with
     123            // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
     124            // [2] = cell title (optional), e.g. $.datepicker.noWeekends
     125        beforeShow: null, // Function that takes an input field and
     126            // returns a set of custom settings for the date picker
     127        onSelect: null, // Define a callback function when a date is selected
     128        onChangeMonthYear: null, // Define a callback function when the month or year is changed
     129        onClose: null, // Define a callback function when the datepicker is closed
     130        numberOfMonths: 1, // Number of months to show at a time
     131        showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
     132        stepMonths: 1, // Number of months to step back/forward
     133        stepBigMonths: 12, // Number of months to step back/forward for the big links
     134        altField: "", // Selector for an alternate field to store selected dates into
     135        altFormat: "", // The date format to use for the alternate field
     136        constrainInput: true, // The input is constrained by the current date format
     137        showButtonPanel: false, // True to show button panel, false to not show it
     138        autoSize: false, // True to size the input for the date format, false to leave as is
     139        disabled: false // The initial disabled state
     140    };
     141    $.extend(this._defaults, this.regional[""]);
     142    this.regional.en = $.extend( true, {}, this.regional[ "" ]);
     143    this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
     144    this.dpDiv = datepicker_bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
     145}
     146
     147$.extend(Datepicker.prototype, {
     148    /* Class name added to elements to indicate already configured with a date picker. */
     149    markerClassName: "hasDatepicker",
     150
     151    //Keep track of the maximum number of rows displayed (see #7043)
     152    maxRows: 4,
     153
     154    // TODO rename to "widget" when switching to widget factory
     155    _widgetDatepicker: function() {
     156        return this.dpDiv;
     157    },
     158
     159    /* Override the default settings for all instances of the date picker.
     160     * @param  settings  object - the new settings to use as defaults (anonymous object)
     161     * @return the manager object
     162     */
     163    setDefaults: function(settings) {
     164        datepicker_extendRemove(this._defaults, settings || {});
     165        return this;
     166    },
     167
     168    /* Attach the date picker to a jQuery selection.
     169     * @param  target   element - the target input field or division or span
     170     * @param  settings  object - the new settings to use for this date picker instance (anonymous)
     171     */
     172    _attachDatepicker: function(target, settings) {
     173        var nodeName, inline, inst;
     174        nodeName = target.nodeName.toLowerCase();
     175        inline = (nodeName === "div" || nodeName === "span");
     176        if (!target.id) {
     177            this.uuid += 1;
     178            target.id = "dp" + this.uuid;
     179        }
     180        inst = this._newInst($(target), inline);
     181        inst.settings = $.extend({}, settings || {});
     182        if (nodeName === "input") {
     183            this._connectDatepicker(target, inst);
     184        } else if (inline) {
     185            this._inlineDatepicker(target, inst);
     186        }
     187    },
     188
     189    /* Create a new instance object. */
     190    _newInst: function(target, inline) {
     191        var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
     192        return {id: id, input: target, // associated target
     193            selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
     194            drawMonth: 0, drawYear: 0, // month being drawn
     195            inline: inline, // is datepicker inline or not
     196            dpDiv: (!inline ? this.dpDiv : // presentation div
     197            datepicker_bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
     198    },
     199
     200    /* Attach the date picker to an input field. */
     201    _connectDatepicker: function(target, inst) {
     202        var input = $(target);
     203        inst.append = $([]);
     204        inst.trigger = $([]);
     205        if (input.hasClass(this.markerClassName)) {
     206            return;
     207        }
     208        this._attachments(input, inst);
     209        input.addClass(this.markerClassName).keydown(this._doKeyDown).
     210            keypress(this._doKeyPress).keyup(this._doKeyUp);
     211        this._autoSize(inst);
     212        $.data(target, "datepicker", inst);
     213        //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
     214        if( inst.settings.disabled ) {
     215            this._disableDatepicker( target );
     216        }
     217    },
     218
     219    /* Make attachments based on settings. */
     220    _attachments: function(input, inst) {
     221        var showOn, buttonText, buttonImage,
     222            appendText = this._get(inst, "appendText"),
     223            isRTL = this._get(inst, "isRTL");
     224
     225        if (inst.append) {
     226            inst.append.remove();
     227        }
     228        if (appendText) {
     229            inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
     230            input[isRTL ? "before" : "after"](inst.append);
     231        }
     232
     233        input.unbind("focus", this._showDatepicker);
     234
     235        if (inst.trigger) {
     236            inst.trigger.remove();
     237        }
     238
     239        showOn = this._get(inst, "showOn");
     240        if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
     241            input.focus(this._showDatepicker);
     242        }
     243        if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
     244            buttonText = this._get(inst, "buttonText");
     245            buttonImage = this._get(inst, "buttonImage");
     246            inst.trigger = $(this._get(inst, "buttonImageOnly") ?
     247                $("<img/>").addClass(this._triggerClass).
     248                    attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
     249                $("<button type='button'></button>").addClass(this._triggerClass).
     250                    html(!buttonImage ? buttonText : $("<img/>").attr(
     251                    { src:buttonImage, alt:buttonText, title:buttonText })));
     252            input[isRTL ? "before" : "after"](inst.trigger);
     253            inst.trigger.click(function() {
     254                if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
     255                    $.datepicker._hideDatepicker();
     256                } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
     257                    $.datepicker._hideDatepicker();
     258                    $.datepicker._showDatepicker(input[0]);
     259                } else {
     260                    $.datepicker._showDatepicker(input[0]);
     261                }
     262                return false;
     263            });
     264        }
     265    },
     266
     267    /* Apply the maximum length for the date format. */
     268    _autoSize: function(inst) {
     269        if (this._get(inst, "autoSize") && !inst.inline) {
     270            var findMax, max, maxI, i,
     271                date = new Date(2009, 12 - 1, 20), // Ensure double digits
     272                dateFormat = this._get(inst, "dateFormat");
     273
     274            if (dateFormat.match(/[DM]/)) {
     275                findMax = function(names) {
     276                    max = 0;
     277                    maxI = 0;
     278                    for (i = 0; i < names.length; i++) {
     279                        if (names[i].length > max) {
     280                            max = names[i].length;
     281                            maxI = i;
     282                        }
     283                    }
     284                    return maxI;
     285                };
     286                date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
     287                    "monthNames" : "monthNamesShort"))));
     288                date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
     289                    "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
     290            }
     291            inst.input.attr("size", this._formatDate(inst, date).length);
     292        }
     293    },
     294
     295    /* Attach an inline date picker to a div. */
     296    _inlineDatepicker: function(target, inst) {
     297        var divSpan = $(target);
     298        if (divSpan.hasClass(this.markerClassName)) {
     299            return;
     300        }
     301        divSpan.addClass(this.markerClassName).append(inst.dpDiv);
     302        $.data(target, "datepicker", inst);
     303        this._setDate(inst, this._getDefaultDate(inst), true);
     304        this._updateDatepicker(inst);
     305        this._updateAlternate(inst);
     306        //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
     307        if( inst.settings.disabled ) {
     308            this._disableDatepicker( target );
     309        }
     310        // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
     311        // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
     312        inst.dpDiv.css( "display", "block" );
     313    },
     314
     315    /* Pop-up the date picker in a "dialog" box.
     316     * @param  input element - ignored
     317     * @param  date string or Date - the initial date to display
     318     * @param  onSelect  function - the function to call when a date is selected
     319     * @param  settings  object - update the dialog date picker instance's settings (anonymous object)
     320     * @param  pos int[2] - coordinates for the dialog's position within the screen or
     321     *                  event - with x/y coordinates or
     322     *                  leave empty for default (screen centre)
     323     * @return the manager object
     324     */
     325    _dialogDatepicker: function(input, date, onSelect, settings, pos) {
     326        var id, browserWidth, browserHeight, scrollX, scrollY,
     327            inst = this._dialogInst; // internal instance
     328
     329        if (!inst) {
     330            this.uuid += 1;
     331            id = "dp" + this.uuid;
     332            this._dialogInput = $("<input type='text' id='" + id +
     333                "' style='position: absolute; top: -100px; width: 0px;'/>");
     334            this._dialogInput.keydown(this._doKeyDown);
     335            $("body").append(this._dialogInput);
     336            inst = this._dialogInst = this._newInst(this._dialogInput, false);
     337            inst.settings = {};
     338            $.data(this._dialogInput[0], "datepicker", inst);
     339        }
     340        datepicker_extendRemove(inst.settings, settings || {});
     341        date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
     342        this._dialogInput.val(date);
     343
     344        this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
     345        if (!this._pos) {
     346            browserWidth = document.documentElement.clientWidth;
     347            browserHeight = document.documentElement.clientHeight;
     348            scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
     349            scrollY = document.documentElement.scrollTop || document.body.scrollTop;
     350            this._pos = // should use actual width/height below
     351                [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
     352        }
     353
     354        // move input on screen for focus, but hidden behind dialog
     355        this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
     356        inst.settings.onSelect = onSelect;
     357        this._inDialog = true;
     358        this.dpDiv.addClass(this._dialogClass);
     359        this._showDatepicker(this._dialogInput[0]);
     360        if ($.blockUI) {
     361            $.blockUI(this.dpDiv);
     362        }
     363        $.data(this._dialogInput[0], "datepicker", inst);
     364        return this;
     365    },
     366
     367    /* Detach a datepicker from its control.
     368     * @param  target   element - the target input field or division or span
     369     */
     370    _destroyDatepicker: function(target) {
     371        var nodeName,
     372            $target = $(target),
     373            inst = $.data(target, "datepicker");
     374
     375        if (!$target.hasClass(this.markerClassName)) {
     376            return;
     377        }
     378
     379        nodeName = target.nodeName.toLowerCase();
     380        $.removeData(target, "datepicker");
     381        if (nodeName === "input") {
     382            inst.append.remove();
     383            inst.trigger.remove();
     384            $target.removeClass(this.markerClassName).
     385                unbind("focus", this._showDatepicker).
     386                unbind("keydown", this._doKeyDown).
     387                unbind("keypress", this._doKeyPress).
     388                unbind("keyup", this._doKeyUp);
     389        } else if (nodeName === "div" || nodeName === "span") {
     390            $target.removeClass(this.markerClassName).empty();
     391        }
     392    },
     393
     394    /* Enable the date picker to a jQuery selection.
     395     * @param  target   element - the target input field or division or span
     396     */
     397    _enableDatepicker: function(target) {
     398        var nodeName, inline,
     399            $target = $(target),
     400            inst = $.data(target, "datepicker");
     401
     402        if (!$target.hasClass(this.markerClassName)) {
     403            return;
     404        }
     405
     406        nodeName = target.nodeName.toLowerCase();
     407        if (nodeName === "input") {
     408            target.disabled = false;
     409            inst.trigger.filter("button").
     410                each(function() { this.disabled = false; }).end().
     411                filter("img").css({opacity: "1.0", cursor: ""});
     412        } else if (nodeName === "div" || nodeName === "span") {
     413            inline = $target.children("." + this._inlineClass);
     414            inline.children().removeClass("ui-state-disabled");
     415            inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
     416                prop("disabled", false);
     417        }
     418        this._disabledInputs = $.map(this._disabledInputs,
     419            function(value) { return (value === target ? null : value); }); // delete entry
     420    },
     421
     422    /* Disable the date picker to a jQuery selection.
     423     * @param  target   element - the target input field or division or span
     424     */
     425    _disableDatepicker: function(target) {
     426        var nodeName, inline,
     427            $target = $(target),
     428            inst = $.data(target, "datepicker");
     429
     430        if (!$target.hasClass(this.markerClassName)) {
     431            return;
     432        }
     433
     434        nodeName = target.nodeName.toLowerCase();
     435        if (nodeName === "input") {
     436            target.disabled = true;
     437            inst.trigger.filter("button").
     438                each(function() { this.disabled = true; }).end().
     439                filter("img").css({opacity: "0.5", cursor: "default"});
     440        } else if (nodeName === "div" || nodeName === "span") {
     441            inline = $target.children("." + this._inlineClass);
     442            inline.children().addClass("ui-state-disabled");
     443            inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
     444                prop("disabled", true);
     445        }
     446        this._disabledInputs = $.map(this._disabledInputs,
     447            function(value) { return (value === target ? null : value); }); // delete entry
     448        this._disabledInputs[this._disabledInputs.length] = target;
     449    },
     450
     451    /* Is the first field in a jQuery collection disabled as a datepicker?
     452     * @param  target   element - the target input field or division or span
     453     * @return boolean - true if disabled, false if enabled
     454     */
     455    _isDisabledDatepicker: function(target) {
     456        if (!target) {
     457            return false;
     458        }
     459        for (var i = 0; i < this._disabledInputs.length; i++) {
     460            if (this._disabledInputs[i] === target) {
     461                return true;
     462            }
     463        }
     464        return false;
     465    },
     466
     467    /* Retrieve the instance data for the target control.
     468     * @param  target  element - the target input field or division or span
     469     * @return  object - the associated instance data
     470     * @throws  error if a jQuery problem getting data
     471     */
     472    _getInst: function(target) {
     473        try {
     474            return $.data(target, "datepicker");
     475        }
     476        catch (err) {
     477            throw "Missing instance data for this datepicker";
     478        }
     479    },
     480
     481    /* Update or retrieve the settings for a date picker attached to an input field or division.
     482     * @param  target  element - the target input field or division or span
     483     * @param  name object - the new settings to update or
     484     *              string - the name of the setting to change or retrieve,
     485     *              when retrieving also "all" for all instance settings or
     486     *              "defaults" for all global defaults
     487     * @param  value   any - the new value for the setting
     488     *              (omit if above is an object or to retrieve a value)
     489     */
     490    _optionDatepicker: function(target, name, value) {
     491        var settings, date, minDate, maxDate,
     492            inst = this._getInst(target);
     493
     494        if (arguments.length === 2 && typeof name === "string") {
     495            return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
     496                (inst ? (name === "all" ? $.extend({}, inst.settings) :
     497                this._get(inst, name)) : null));
     498        }
     499
     500        settings = name || {};
     501        if (typeof name === "string") {
     502            settings = {};
     503            settings[name] = value;
     504        }
     505
     506        if (inst) {
     507            if (this._curInst === inst) {
     508                this._hideDatepicker();
     509            }
     510
     511            date = this._getDateDatepicker(target, true);
     512            minDate = this._getMinMaxDate(inst, "min");
     513            maxDate = this._getMinMaxDate(inst, "max");
     514            datepicker_extendRemove(inst.settings, settings);
     515            // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
     516            if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
     517                inst.settings.minDate = this._formatDate(inst, minDate);
     518            }
     519            if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
     520                inst.settings.maxDate = this._formatDate(inst, maxDate);
     521            }
     522            if ( "disabled" in settings ) {
     523                if ( settings.disabled ) {
     524                    this._disableDatepicker(target);
     525                } else {
     526                    this._enableDatepicker(target);
     527                }
     528            }
     529            this._attachments($(target), inst);
     530            this._autoSize(inst);
     531            this._setDate(inst, date);
     532            this._updateAlternate(inst);
     533            this._updateDatepicker(inst);
     534        }
     535    },
     536
     537    // change method deprecated
     538    _changeDatepicker: function(target, name, value) {
     539        this._optionDatepicker(target, name, value);
     540    },
     541
     542    /* Redraw the date picker attached to an input field or division.
     543     * @param  target  element - the target input field or division or span
     544     */
     545    _refreshDatepicker: function(target) {
     546        var inst = this._getInst(target);
     547        if (inst) {
     548            this._updateDatepicker(inst);
     549        }
     550    },
     551
     552    /* Set the dates for a jQuery selection.
     553     * @param  target element - the target input field or division or span
     554     * @param  date Date - the new date
     555     */
     556    _setDateDatepicker: function(target, date) {
     557        var inst = this._getInst(target);
     558        if (inst) {
     559            this._setDate(inst, date);
     560            this._updateDatepicker(inst);
     561            this._updateAlternate(inst);
     562        }
     563    },
     564
     565    /* Get the date(s) for the first entry in a jQuery selection.
     566     * @param  target element - the target input field or division or span
     567     * @param  noDefault boolean - true if no default date is to be used
     568     * @return Date - the current date
     569     */
     570    _getDateDatepicker: function(target, noDefault) {
     571        var inst = this._getInst(target);
     572        if (inst && !inst.inline) {
     573            this._setDateFromField(inst, noDefault);
     574        }
     575        return (inst ? this._getDate(inst) : null);
     576    },
     577
     578    /* Handle keystrokes. */
     579    _doKeyDown: function(event) {
     580        var onSelect, dateStr, sel,
     581            inst = $.datepicker._getInst(event.target),
     582            handled = true,
     583            isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
     584
     585        inst._keyEvent = true;
     586        if ($.datepicker._datepickerShowing) {
     587            switch (event.keyCode) {
     588                case 9: $.datepicker._hideDatepicker();
     589                        handled = false;
     590                        break; // hide on tab out
     591                case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
     592                                    $.datepicker._currentClass + ")", inst.dpDiv);
     593                        if (sel[0]) {
     594                            $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
     595                        }
     596
     597                        onSelect = $.datepicker._get(inst, "onSelect");
     598                        if (onSelect) {
     599                            dateStr = $.datepicker._formatDate(inst);
     600
     601                            // trigger custom callback
     602                            onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
     603                        } else {
     604                            $.datepicker._hideDatepicker();
     605                        }
     606
     607                        return false; // don't submit the form
     608                case 27: $.datepicker._hideDatepicker();
     609                        break; // hide on escape
     610                case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
     611                            -$.datepicker._get(inst, "stepBigMonths") :
     612                            -$.datepicker._get(inst, "stepMonths")), "M");
     613                        break; // previous month/year on page up/+ ctrl
     614                case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
     615                            +$.datepicker._get(inst, "stepBigMonths") :
     616                            +$.datepicker._get(inst, "stepMonths")), "M");
     617                        break; // next month/year on page down/+ ctrl
     618                case 35: if (event.ctrlKey || event.metaKey) {
     619                            $.datepicker._clearDate(event.target);
     620                        }
     621                        handled = event.ctrlKey || event.metaKey;
     622                        break; // clear on ctrl or command +end
     623                case 36: if (event.ctrlKey || event.metaKey) {
     624                            $.datepicker._gotoToday(event.target);
     625                        }
     626                        handled = event.ctrlKey || event.metaKey;
     627                        break; // current on ctrl or command +home
     628                case 37: if (event.ctrlKey || event.metaKey) {
     629                            $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
     630                        }
     631                        handled = event.ctrlKey || event.metaKey;
     632                        // -1 day on ctrl or command +left
     633                        if (event.originalEvent.altKey) {
     634                            $.datepicker._adjustDate(event.target, (event.ctrlKey ?
     635                                -$.datepicker._get(inst, "stepBigMonths") :
     636                                -$.datepicker._get(inst, "stepMonths")), "M");
     637                        }
     638                        // next month/year on alt +left on Mac
     639                        break;
     640                case 38: if (event.ctrlKey || event.metaKey) {
     641                            $.datepicker._adjustDate(event.target, -7, "D");
     642                        }
     643                        handled = event.ctrlKey || event.metaKey;
     644                        break; // -1 week on ctrl or command +up
     645                case 39: if (event.ctrlKey || event.metaKey) {
     646                            $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
     647                        }
     648                        handled = event.ctrlKey || event.metaKey;
     649                        // +1 day on ctrl or command +right
     650                        if (event.originalEvent.altKey) {
     651                            $.datepicker._adjustDate(event.target, (event.ctrlKey ?
     652                                +$.datepicker._get(inst, "stepBigMonths") :
     653                                +$.datepicker._get(inst, "stepMonths")), "M");
     654                        }
     655                        // next month/year on alt +right
     656                        break;
     657                case 40: if (event.ctrlKey || event.metaKey) {
     658                            $.datepicker._adjustDate(event.target, +7, "D");
     659                        }
     660                        handled = event.ctrlKey || event.metaKey;
     661                        break; // +1 week on ctrl or command +down
     662                default: handled = false;
     663            }
     664        } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
     665            $.datepicker._showDatepicker(this);
     666        } else {
     667            handled = false;
     668        }
     669
     670        if (handled) {
     671            event.preventDefault();
     672            event.stopPropagation();
     673        }
     674    },
     675
     676    /* Filter entered characters - based on date format. */
     677    _doKeyPress: function(event) {
     678        var chars, chr,
     679            inst = $.datepicker._getInst(event.target);
     680
     681        if ($.datepicker._get(inst, "constrainInput")) {
     682            chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
     683            chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
     684            return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
     685        }
     686    },
     687
     688    /* Synchronise manual entry and field/alternate field. */
     689    _doKeyUp: function(event) {
     690        var date,
     691            inst = $.datepicker._getInst(event.target);
     692
     693        if (inst.input.val() !== inst.lastVal) {
     694            try {
     695                date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
     696                    (inst.input ? inst.input.val() : null),
     697                    $.datepicker._getFormatConfig(inst));
     698
     699                if (date) { // only if valid
     700                    $.datepicker._setDateFromField(inst);
     701                    $.datepicker._updateAlternate(inst);
     702                    $.datepicker._updateDatepicker(inst);
     703                }
     704            }
     705            catch (err) {
     706            }
     707        }
     708        return true;
     709    },
     710
     711    /* Pop-up the date picker for a given input field.
     712     * If false returned from beforeShow event handler do not show.
     713     * @param  input  element - the input field attached to the date picker or
     714     *                  event - if triggered by focus
     715     */
     716    _showDatepicker: function(input) {
     717        input = input.target || input;
     718        if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
     719            input = $("input", input.parentNode)[0];
     720        }
     721
     722        if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
     723            return;
     724        }
     725
     726        var inst, beforeShow, beforeShowSettings, isFixed,
     727            offset, showAnim, duration;
     728
     729        inst = $.datepicker._getInst(input);
     730        if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
     731            $.datepicker._curInst.dpDiv.stop(true, true);
     732            if ( inst && $.datepicker._datepickerShowing ) {
     733                $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
     734            }
     735        }
     736
     737        beforeShow = $.datepicker._get(inst, "beforeShow");
     738        beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
     739        if(beforeShowSettings === false){
     740            return;
     741        }
     742        datepicker_extendRemove(inst.settings, beforeShowSettings);
     743
     744        inst.lastVal = null;
     745        $.datepicker._lastInput = input;
     746        $.datepicker._setDateFromField(inst);
     747
     748        if ($.datepicker._inDialog) { // hide cursor
     749            input.value = "";
     750        }
     751        if (!$.datepicker._pos) { // position below input
     752            $.datepicker._pos = $.datepicker._findPos(input);
     753            $.datepicker._pos[1] += input.offsetHeight; // add the height
     754        }
     755
     756        isFixed = false;
     757        $(input).parents().each(function() {
     758            isFixed |= $(this).css("position") === "fixed";
     759            return !isFixed;
     760        });
     761
     762        offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
     763        $.datepicker._pos = null;
     764        //to avoid flashes on Firefox
     765        inst.dpDiv.empty();
     766        // determine sizing offscreen
     767        inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
     768        $.datepicker._updateDatepicker(inst);
     769        // fix width for dynamic number of date pickers
     770        // and adjust position before showing
     771        offset = $.datepicker._checkOffset(inst, offset, isFixed);
     772        inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
     773            "static" : (isFixed ? "fixed" : "absolute")), display: "none",
     774            left: offset.left + "px", top: offset.top + "px"});
     775
     776        if (!inst.inline) {
     777            showAnim = $.datepicker._get(inst, "showAnim");
     778            duration = $.datepicker._get(inst, "duration");
     779            inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
     780            $.datepicker._datepickerShowing = true;
     781
     782            if ( $.effects && $.effects.effect[ showAnim ] ) {
     783                inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
     784            } else {
     785                inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
     786            }
     787
     788            if ( $.datepicker._shouldFocusInput( inst ) ) {
     789                inst.input.focus();
     790            }
     791
     792            $.datepicker._curInst = inst;
     793        }
     794    },
     795
     796    /* Generate the date picker content. */
     797    _updateDatepicker: function(inst) {
     798        this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
     799        datepicker_instActive = inst; // for delegate hover events
     800        inst.dpDiv.empty().append(this._generateHTML(inst));
     801        this._attachHandlers(inst);
     802
     803        var origyearshtml,
     804            numMonths = this._getNumberOfMonths(inst),
     805            cols = numMonths[1],
     806            width = 17,
     807            activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" );
     808
     809        if ( activeCell.length > 0 ) {
     810            datepicker_handleMouseover.apply( activeCell.get( 0 ) );
     811        }
     812
     813        inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
     814        if (cols > 1) {
     815            inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
     816        }
     817        inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
     818            "Class"]("ui-datepicker-multi");
     819        inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
     820            "Class"]("ui-datepicker-rtl");
     821
     822        if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
     823            inst.input.focus();
     824        }
     825
     826        // deffered render of the years select (to avoid flashes on Firefox)
     827        if( inst.yearshtml ){
     828            origyearshtml = inst.yearshtml;
     829            setTimeout(function(){
     830                //assure that inst.yearshtml didn't change.
     831                if( origyearshtml === inst.yearshtml && inst.yearshtml ){
     832                    inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
     833                }
     834                origyearshtml = inst.yearshtml = null;
     835            }, 0);
     836        }
     837    },
     838
     839    // #6694 - don't focus the input if it's already focused
     840    // this breaks the change event in IE
     841    // Support: IE and jQuery <1.9
     842    _shouldFocusInput: function( inst ) {
     843        return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
     844    },
     845
     846    /* Check positioning to remain on screen. */
     847    _checkOffset: function(inst, offset, isFixed) {
     848        var dpWidth = inst.dpDiv.outerWidth(),
     849            dpHeight = inst.dpDiv.outerHeight(),
     850            inputWidth = inst.input ? inst.input.outerWidth() : 0,
     851            inputHeight = inst.input ? inst.input.outerHeight() : 0,
     852            viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
     853            viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
     854
     855        offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
     856        offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
     857        offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
     858
     859        // now check if datepicker is showing outside window viewport - move to a better place if so.
     860        offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
     861            Math.abs(offset.left + dpWidth - viewWidth) : 0);
     862        offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
     863            Math.abs(dpHeight + inputHeight) : 0);
     864
     865        return offset;
     866    },
     867
     868    /* Find an object's position on the screen. */
     869    _findPos: function(obj) {
     870        var position,
     871            inst = this._getInst(obj),
     872            isRTL = this._get(inst, "isRTL");
     873
     874        while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
     875            obj = obj[isRTL ? "previousSibling" : "nextSibling"];
     876        }
     877
     878        position = $(obj).offset();
     879        return [position.left, position.top];
     880    },
     881
     882    /* Hide the date picker from view.
     883     * @param  input  element - the input field attached to the date picker
     884     */
     885    _hideDatepicker: function(input) {
     886        var showAnim, duration, postProcess, onClose,
     887            inst = this._curInst;
     888
     889        if (!inst || (input && inst !== $.data(input, "datepicker"))) {
     890            return;
     891        }
     892
     893        if (this._datepickerShowing) {
     894            showAnim = this._get(inst, "showAnim");
     895            duration = this._get(inst, "duration");
     896            postProcess = function() {
     897                $.datepicker._tidyDialog(inst);
     898            };
     899
     900            // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
     901            if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
     902                inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
     903            } else {
     904                inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
     905                    (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
     906            }
     907
     908            if (!showAnim) {
     909                postProcess();
     910            }
     911            this._datepickerShowing = false;
     912
     913            onClose = this._get(inst, "onClose");
     914            if (onClose) {
     915                onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
     916            }
     917
     918            this._lastInput = null;
     919            if (this._inDialog) {
     920                this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
     921                if ($.blockUI) {
     922                    $.unblockUI();
     923                    $("body").append(this.dpDiv);
     924                }
     925            }
     926            this._inDialog = false;
     927        }
     928    },
     929
     930    /* Tidy up after a dialog display. */
     931    _tidyDialog: function(inst) {
     932        inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
     933    },
     934
     935    /* Close date picker if clicked elsewhere. */
     936    _checkExternalClick: function(event) {
     937        if (!$.datepicker._curInst) {
     938            return;
     939        }
     940
     941        var $target = $(event.target),
     942            inst = $.datepicker._getInst($target[0]);
     943
     944        if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
     945                $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
     946                !$target.hasClass($.datepicker.markerClassName) &&
     947                !$target.closest("." + $.datepicker._triggerClass).length &&
     948                $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
     949            ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
     950                $.datepicker._hideDatepicker();
     951        }
     952    },
     953
     954    /* Adjust one of the date sub-fields. */
     955    _adjustDate: function(id, offset, period) {
     956        var target = $(id),
     957            inst = this._getInst(target[0]);
     958
     959        if (this._isDisabledDatepicker(target[0])) {
     960            return;
     961        }
     962        this._adjustInstDate(inst, offset +
     963            (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
     964            period);
     965        this._updateDatepicker(inst);
     966    },
     967
     968    /* Action for current link. */
     969    _gotoToday: function(id) {
     970        var date,
     971            target = $(id),
     972            inst = this._getInst(target[0]);
     973
     974        if (this._get(inst, "gotoCurrent") && inst.currentDay) {
     975            inst.selectedDay = inst.currentDay;
     976            inst.drawMonth = inst.selectedMonth = inst.currentMonth;
     977            inst.drawYear = inst.selectedYear = inst.currentYear;
     978        } else {
     979            date = new Date();
     980            inst.selectedDay = date.getDate();
     981            inst.drawMonth = inst.selectedMonth = date.getMonth();
     982            inst.drawYear = inst.selectedYear = date.getFullYear();
     983        }
     984        this._notifyChange(inst);
     985        this._adjustDate(target);
     986    },
     987
     988    /* Action for selecting a new month/year. */
     989    _selectMonthYear: function(id, select, period) {
     990        var target = $(id),
     991            inst = this._getInst(target[0]);
     992
     993        inst["selected" + (period === "M" ? "Month" : "Year")] =
     994        inst["draw" + (period === "M" ? "Month" : "Year")] =
     995            parseInt(select.options[select.selectedIndex].value,10);
     996
     997        this._notifyChange(inst);
     998        this._adjustDate(target);
     999    },
     1000
     1001    /* Action for selecting a day. */
     1002    _selectDay: function(id, month, year, td) {
     1003        var inst,
     1004            target = $(id);
     1005
     1006        if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
     1007            return;
     1008        }
     1009
     1010        inst = this._getInst(target[0]);
     1011        inst.selectedDay = inst.currentDay = $("a", td).html();
     1012        inst.selectedMonth = inst.currentMonth = month;
     1013        inst.selectedYear = inst.currentYear = year;
     1014        this._selectDate(id, this._formatDate(inst,
     1015            inst.currentDay, inst.currentMonth, inst.currentYear));
     1016    },
     1017
     1018    /* Erase the input field and hide the date picker. */
     1019    _clearDate: function(id) {
     1020        var target = $(id);
     1021        this._selectDate(target, "");
     1022    },
     1023
     1024    /* Update the input field with the selected date. */
     1025    _selectDate: function(id, dateStr) {
     1026        var onSelect,
     1027            target = $(id),
     1028            inst = this._getInst(target[0]);
     1029
     1030        dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
     1031        if (inst.input) {
     1032            inst.input.val(dateStr);
     1033        }
     1034        this._updateAlternate(inst);
     1035
     1036        onSelect = this._get(inst, "onSelect");
     1037        if (onSelect) {
     1038            onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);  // trigger custom callback
     1039        } else if (inst.input) {
     1040            inst.input.trigger("change"); // fire the change event
     1041        }
     1042
     1043        if (inst.inline){
     1044            this._updateDatepicker(inst);
     1045        } else {
     1046            this._hideDatepicker();
     1047            this._lastInput = inst.input[0];
     1048            if (typeof(inst.input[0]) !== "object") {
     1049                inst.input.focus(); // restore focus
     1050            }
     1051            this._lastInput = null;
     1052        }
     1053    },
     1054
     1055    /* Update any alternate field to synchronise with the main field. */
     1056    _updateAlternate: function(inst) {
     1057        var altFormat, date, dateStr,
     1058            altField = this._get(inst, "altField");
     1059
     1060        if (altField) { // update alternate field too
     1061            altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
     1062            date = this._getDate(inst);
     1063            dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
     1064            $(altField).each(function() { $(this).val(dateStr); });
     1065        }
     1066    },
     1067
     1068    /* Set as beforeShowDay function to prevent selection of weekends.
     1069     * @param  date  Date - the date to customise
     1070     * @return [boolean, string] - is this date selectable?, what is its CSS class?
     1071     */
     1072    noWeekends: function(date) {
     1073        var day = date.getDay();
     1074        return [(day > 0 && day < 6), ""];
     1075    },
     1076
     1077    /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
     1078     * @param  date  Date - the date to get the week for
     1079     * @return  number - the number of the week within the year that contains this date
     1080     */
     1081    iso8601Week: function(date) {
     1082        var time,
     1083            checkDate = new Date(date.getTime());
     1084
     1085        // Find Thursday of this week starting on Monday
     1086        checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
     1087
     1088        time = checkDate.getTime();
     1089        checkDate.setMonth(0); // Compare with Jan 1
     1090        checkDate.setDate(1);
     1091        return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
     1092    },
     1093
     1094    /* Parse a string value into a date object.
     1095     * See formatDate below for the possible formats.
     1096     *
     1097     * @param  format string - the expected format of the date
     1098     * @param  value string - the date in the above format
     1099     * @param  settings Object - attributes include:
     1100     *                  shortYearCutoff  number - the cutoff year for determining the century (optional)
     1101     *                  dayNamesShort   string[7] - abbreviated names of the days from Sunday (optional)
     1102     *                  dayNames        string[7] - names of the days from Sunday (optional)
     1103     *                  monthNamesShort string[12] - abbreviated names of the months (optional)
     1104     *                  monthNames      string[12] - names of the months (optional)
     1105     * @return  Date - the extracted date value or null if value is blank
     1106     */
     1107    parseDate: function (format, value, settings) {
     1108        if (format == null || value == null) {
     1109            throw "Invalid arguments";
     1110        }
     1111
     1112        value = (typeof value === "object" ? value.toString() : value + "");
     1113        if (value === "") {
     1114            return null;
     1115        }
     1116
     1117        var iFormat, dim, extra,
     1118            iValue = 0,
     1119            shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
     1120            shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
     1121                new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
     1122            dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
     1123            dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
     1124            monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
     1125            monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
     1126            year = -1,
     1127            month = -1,
     1128            day = -1,
     1129            doy = -1,
     1130            literal = false,
     1131            date,
     1132            // Check whether a format character is doubled
     1133            lookAhead = function(match) {
     1134                var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
     1135                if (matches) {
     1136                    iFormat++;
     1137                }
     1138                return matches;
     1139            },
     1140            // Extract a number from the string value
     1141            getNumber = function(match) {
     1142                var isDoubled = lookAhead(match),
     1143                    size = (match === "@" ? 14 : (match === "!" ? 20 :
     1144                    (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
     1145                    minSize = (match === "y" ? size : 1),
     1146                    digits = new RegExp("^\\d{" + minSize + "," + size + "}"),
     1147                    num = value.substring(iValue).match(digits);
     1148                if (!num) {
     1149                    throw "Missing number at position " + iValue;
     1150                }
     1151                iValue += num[0].length;
     1152                return parseInt(num[0], 10);
     1153            },
     1154            // Extract a name from the string value and convert to an index
     1155            getName = function(match, shortNames, longNames) {
     1156                var index = -1,
     1157                    names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
     1158                        return [ [k, v] ];
     1159                    }).sort(function (a, b) {
     1160                        return -(a[1].length - b[1].length);
     1161                    });
     1162
     1163                $.each(names, function (i, pair) {
     1164                    var name = pair[1];
     1165                    if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
     1166                        index = pair[0];
     1167                        iValue += name.length;
     1168                        return false;
     1169                    }
     1170                });
     1171                if (index !== -1) {
     1172                    return index + 1;
     1173                } else {
     1174                    throw "Unknown name at position " + iValue;
     1175                }
     1176            },
     1177            // Confirm that a literal character matches the string value
     1178            checkLiteral = function() {
     1179                if (value.charAt(iValue) !== format.charAt(iFormat)) {
     1180                    throw "Unexpected literal at position " + iValue;
     1181                }
     1182                iValue++;
     1183            };
     1184
     1185        for (iFormat = 0; iFormat < format.length; iFormat++) {
     1186            if (literal) {
     1187                if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
     1188                    literal = false;
     1189                } else {
     1190                    checkLiteral();
     1191                }
     1192            } else {
     1193                switch (format.charAt(iFormat)) {
     1194                    case "d":
     1195                        day = getNumber("d");
     1196                        break;
     1197                    case "D":
     1198                        getName("D", dayNamesShort, dayNames);
     1199                        break;
     1200                    case "o":
     1201                        doy = getNumber("o");
     1202                        break;
     1203                    case "m":
     1204                        month = getNumber("m");
     1205                        break;
     1206                    case "M":
     1207                        month = getName("M", monthNamesShort, monthNames);
     1208                        break;
     1209                    case "y":
     1210                        year = getNumber("y");
     1211                        break;
     1212                    case "@":
     1213                        date = new Date(getNumber("@"));
     1214                        year = date.getFullYear();
     1215                        month = date.getMonth() + 1;
     1216                        day = date.getDate();
     1217                        break;
     1218                    case "!":
     1219                        date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
     1220                        year = date.getFullYear();
     1221                        month = date.getMonth() + 1;
     1222                        day = date.getDate();
     1223                        break;
     1224                    case "'":
     1225                        if (lookAhead("'")){
     1226                            checkLiteral();
     1227                        } else {
     1228                            literal = true;
     1229                        }
     1230                        break;
     1231                    default:
     1232                        checkLiteral();
     1233                }
     1234            }
     1235        }
     1236
     1237        if (iValue < value.length){
     1238            extra = value.substr(iValue);
     1239            if (!/^\s+/.test(extra)) {
     1240                throw "Extra/unparsed characters found in date: " + extra;
     1241            }
     1242        }
     1243
     1244        if (year === -1) {
     1245            year = new Date().getFullYear();
     1246        } else if (year < 100) {
     1247            year += new Date().getFullYear() - new Date().getFullYear() % 100 +
     1248                (year <= shortYearCutoff ? 0 : -100);
     1249        }
     1250
     1251        if (doy > -1) {
     1252            month = 1;
     1253            day = doy;
     1254            do {
     1255                dim = this._getDaysInMonth(year, month - 1);
     1256                if (day <= dim) {
     1257                    break;
     1258                }
     1259                month++;
     1260                day -= dim;
     1261            } while (true);
     1262        }
     1263
     1264        date = this._daylightSavingAdjust(new Date(year, month - 1, day));
     1265        if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
     1266            throw "Invalid date"; // E.g. 31/02/00
     1267        }
     1268        return date;
     1269    },
     1270
     1271    /* Standard date formats. */
     1272    ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
     1273    COOKIE: "D, dd M yy",
     1274    ISO_8601: "yy-mm-dd",
     1275    RFC_822: "D, d M y",
     1276    RFC_850: "DD, dd-M-y",
     1277    RFC_1036: "D, d M y",
     1278    RFC_1123: "D, d M yy",
     1279    RFC_2822: "D, d M yy",
     1280    RSS: "D, d M y", // RFC 822
     1281    TICKS: "!",
     1282    TIMESTAMP: "@",
     1283    W3C: "yy-mm-dd", // ISO 8601
     1284
     1285    _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
     1286        Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
     1287
     1288    /* Format a date object into a string value.
     1289     * The format can be combinations of the following:
     1290     * d  - day of month (no leading zero)
     1291     * dd - day of month (two digit)
     1292     * o  - day of year (no leading zeros)
     1293     * oo - day of year (three digit)
     1294     * D  - day name short
     1295     * DD - day name long
     1296     * m  - month of year (no leading zero)
     1297     * mm - month of year (two digit)
     1298     * M  - month name short
     1299     * MM - month name long
     1300     * y  - year (two digit)
     1301     * yy - year (four digit)
     1302     * @ - Unix timestamp (ms since 01/01/1970)
     1303     * ! - Windows ticks (100ns since 01/01/0001)
     1304     * "..." - literal text
     1305     * '' - single quote
     1306     *
     1307     * @param  format string - the desired format of the date
     1308     * @param  date Date - the date value to format
     1309     * @param  settings Object - attributes include:
     1310     *                  dayNamesShort   string[7] - abbreviated names of the days from Sunday (optional)
     1311     *                  dayNames        string[7] - names of the days from Sunday (optional)
     1312     *                  monthNamesShort string[12] - abbreviated names of the months (optional)
     1313     *                  monthNames      string[12] - names of the months (optional)
     1314     * @return  string - the date in the above format
     1315     */
     1316    formatDate: function (format, date, settings) {
     1317        if (!date) {
     1318            return "";
     1319        }
     1320
     1321        var iFormat,
     1322            dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
     1323            dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
     1324            monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
     1325            monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
     1326            // Check whether a format character is doubled
     1327            lookAhead = function(match) {
     1328                var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
     1329                if (matches) {
     1330                    iFormat++;
     1331                }
     1332                return matches;
     1333            },
     1334            // Format a number, with leading zero if necessary
     1335            formatNumber = function(match, value, len) {
     1336                var num = "" + value;
     1337                if (lookAhead(match)) {
     1338                    while (num.length < len) {
     1339                        num = "0" + num;
     1340                    }
     1341                }
     1342                return num;
     1343            },
     1344            // Format a name, short or long as requested
     1345            formatName = function(match, value, shortNames, longNames) {
     1346                return (lookAhead(match) ? longNames[value] : shortNames[value]);
     1347            },
     1348            output = "",
     1349            literal = false;
     1350
     1351        if (date) {
     1352            for (iFormat = 0; iFormat < format.length; iFormat++) {
     1353                if (literal) {
     1354                    if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
     1355                        literal = false;
     1356                    } else {
     1357                        output += format.charAt(iFormat);
     1358                    }
     1359                } else {
     1360                    switch (format.charAt(iFormat)) {
     1361                        case "d":
     1362                            output += formatNumber("d", date.getDate(), 2);
     1363                            break;
     1364                        case "D":
     1365                            output += formatName("D", date.getDay(), dayNamesShort, dayNames);
     1366                            break;
     1367                        case "o":
     1368                            output += formatNumber("o",
     1369                                Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
     1370                            break;
     1371                        case "m":
     1372                            output += formatNumber("m", date.getMonth() + 1, 2);
     1373                            break;
     1374                        case "M":
     1375                            output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
     1376                            break;
     1377                        case "y":
     1378                            output += (lookAhead("y") ? date.getFullYear() :
     1379                                (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
     1380                            break;
     1381                        case "@":
     1382                            output += date.getTime();
     1383                            break;
     1384                        case "!":
     1385                            output += date.getTime() * 10000 + this._ticksTo1970;
     1386                            break;
     1387                        case "'":
     1388                            if (lookAhead("'")) {
     1389                                output += "'";
     1390                            } else {
     1391                                literal = true;
     1392                            }
     1393                            break;
     1394                        default:
     1395                            output += format.charAt(iFormat);
     1396                    }
     1397                }
     1398            }
     1399        }
     1400        return output;
     1401    },
     1402
     1403    /* Extract all possible characters from the date format. */
     1404    _possibleChars: function (format) {
     1405        var iFormat,
     1406            chars = "",
     1407            literal = false,
     1408            // Check whether a format character is doubled
     1409            lookAhead = function(match) {
     1410                var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
     1411                if (matches) {
     1412                    iFormat++;
     1413                }
     1414                return matches;
     1415            };
     1416
     1417        for (iFormat = 0; iFormat < format.length; iFormat++) {
     1418            if (literal) {
     1419                if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
     1420                    literal = false;
     1421                } else {
     1422                    chars += format.charAt(iFormat);
     1423                }
     1424            } else {
     1425                switch (format.charAt(iFormat)) {
     1426                    case "d": case "m": case "y": case "@":
     1427                        chars += "0123456789";
     1428                        break;
     1429                    case "D": case "M":
     1430                        return null; // Accept anything
     1431                    case "'":
     1432                        if (lookAhead("'")) {
     1433                            chars += "'";
     1434                        } else {
     1435                            literal = true;
     1436                        }
     1437                        break;
     1438                    default:
     1439                        chars += format.charAt(iFormat);
     1440                }
     1441            }
     1442        }
     1443        return chars;
     1444    },
     1445
     1446    /* Get a setting value, defaulting if necessary. */
     1447    _get: function(inst, name) {
     1448        return inst.settings[name] !== undefined ?
     1449            inst.settings[name] : this._defaults[name];
     1450    },
     1451
     1452    /* Parse existing date and initialise date picker. */
     1453    _setDateFromField: function(inst, noDefault) {
     1454        if (inst.input.val() === inst.lastVal) {
     1455            return;
     1456        }
     1457
     1458        var dateFormat = this._get(inst, "dateFormat"),
     1459            dates = inst.lastVal = inst.input ? inst.input.val() : null,
     1460            defaultDate = this._getDefaultDate(inst),
     1461            date = defaultDate,
     1462            settings = this._getFormatConfig(inst);
     1463
     1464        try {
     1465            date = this.parseDate(dateFormat, dates, settings) || defaultDate;
     1466        } catch (event) {
     1467            dates = (noDefault ? "" : dates);
     1468        }
     1469        inst.selectedDay = date.getDate();
     1470        inst.drawMonth = inst.selectedMonth = date.getMonth();
     1471        inst.drawYear = inst.selectedYear = date.getFullYear();
     1472        inst.currentDay = (dates ? date.getDate() : 0);
     1473        inst.currentMonth = (dates ? date.getMonth() : 0);
     1474        inst.currentYear = (dates ? date.getFullYear() : 0);
     1475        this._adjustInstDate(inst);
     1476    },
     1477
     1478    /* Retrieve the default date shown on opening. */
     1479    _getDefaultDate: function(inst) {
     1480        return this._restrictMinMax(inst,
     1481            this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
     1482    },
     1483
     1484    /* A date may be specified as an exact value or a relative one. */
     1485    _determineDate: function(inst, date, defaultDate) {
     1486        var offsetNumeric = function(offset) {
     1487                var date = new Date();
     1488                date.setDate(date.getDate() + offset);
     1489                return date;
     1490            },
     1491            offsetString = function(offset) {
     1492                try {
     1493                    return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
     1494                        offset, $.datepicker._getFormatConfig(inst));
     1495                }
     1496                catch (e) {
     1497                    // Ignore
     1498                }
     1499
     1500                var date = (offset.toLowerCase().match(/^c/) ?
     1501                    $.datepicker._getDate(inst) : null) || new Date(),
     1502                    year = date.getFullYear(),
     1503                    month = date.getMonth(),
     1504                    day = date.getDate(),
     1505                    pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
     1506                    matches = pattern.exec(offset);
     1507
     1508                while (matches) {
     1509                    switch (matches[2] || "d") {
     1510                        case "d" : case "D" :
     1511                            day += parseInt(matches[1],10); break;
     1512                        case "w" : case "W" :
     1513                            day += parseInt(matches[1],10) * 7; break;
     1514                        case "m" : case "M" :
     1515                            month += parseInt(matches[1],10);
     1516                            day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
     1517                            break;
     1518                        case "y": case "Y" :
     1519                            year += parseInt(matches[1],10);
     1520                            day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
     1521                            break;
     1522                    }
     1523                    matches = pattern.exec(offset);
     1524                }
     1525                return new Date(year, month, day);
     1526            },
     1527            newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
     1528                (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
     1529
     1530        newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
     1531        if (newDate) {
     1532            newDate.setHours(0);
     1533            newDate.setMinutes(0);
     1534            newDate.setSeconds(0);
     1535            newDate.setMilliseconds(0);
     1536        }
     1537        return this._daylightSavingAdjust(newDate);
     1538    },
     1539
     1540    /* Handle switch to/from daylight saving.
     1541     * Hours may be non-zero on daylight saving cut-over:
     1542     * > 12 when midnight changeover, but then cannot generate
     1543     * midnight datetime, so jump to 1AM, otherwise reset.
     1544     * @param  date  (Date) the date to check
     1545     * @return  (Date) the corrected date
     1546     */
     1547    _daylightSavingAdjust: function(date) {
     1548        if (!date) {
     1549            return null;
     1550        }
     1551        date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
     1552        return date;
     1553    },
     1554
     1555    /* Set the date(s) directly. */
     1556    _setDate: function(inst, date, noChange) {
     1557        var clear = !date,
     1558            origMonth = inst.selectedMonth,
     1559            origYear = inst.selectedYear,
     1560            newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
     1561
     1562        inst.selectedDay = inst.currentDay = newDate.getDate();
     1563        inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
     1564        inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
     1565        if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
     1566            this._notifyChange(inst);
     1567        }
     1568        this._adjustInstDate(inst);
     1569        if (inst.input) {
     1570            inst.input.val(clear ? "" : this._formatDate(inst));
     1571        }
     1572    },
     1573
     1574    /* Retrieve the date(s) directly. */
     1575    _getDate: function(inst) {
     1576        var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
     1577            this._daylightSavingAdjust(new Date(
     1578            inst.currentYear, inst.currentMonth, inst.currentDay)));
     1579            return startDate;
     1580    },
     1581
     1582    /* Attach the onxxx handlers.  These are declared statically so
     1583     * they work with static code transformers like Caja.
     1584     */
     1585    _attachHandlers: function(inst) {
     1586        var stepMonths = this._get(inst, "stepMonths"),
     1587            id = "#" + inst.id.replace( /\\\\/g, "\\" );
     1588        inst.dpDiv.find("[data-handler]").map(function () {
     1589            var handler = {
     1590                prev: function () {
     1591                    $.datepicker._adjustDate(id, -stepMonths, "M");
     1592                },
     1593                next: function () {
     1594                    $.datepicker._adjustDate(id, +stepMonths, "M");
     1595                },
     1596                hide: function () {
     1597                    $.datepicker._hideDatepicker();
     1598                },
     1599                today: function () {
     1600                    $.datepicker._gotoToday(id);
     1601                },
     1602                selectDay: function () {
     1603                    $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
     1604                    return false;
     1605                },
     1606                selectMonth: function () {
     1607                    $.datepicker._selectMonthYear(id, this, "M");
     1608                    return false;
     1609                },
     1610                selectYear: function () {
     1611                    $.datepicker._selectMonthYear(id, this, "Y");
     1612                    return false;
     1613                }
     1614            };
     1615            $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
     1616        });
     1617    },
     1618
     1619    /* Generate the HTML for the current state of the date picker. */
     1620    _generateHTML: function(inst) {
     1621        var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
     1622            controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
     1623            monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
     1624            selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
     1625            cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
     1626            printDate, dRow, tbody, daySettings, otherMonth, unselectable,
     1627            tempDate = new Date(),
     1628            today = this._daylightSavingAdjust(
     1629                new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
     1630            isRTL = this._get(inst, "isRTL"),
     1631            showButtonPanel = this._get(inst, "showButtonPanel"),
     1632            hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
     1633            navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
     1634            numMonths = this._getNumberOfMonths(inst),
     1635            showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
     1636            stepMonths = this._get(inst, "stepMonths"),
     1637            isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
     1638            currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
     1639                new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
     1640            minDate = this._getMinMaxDate(inst, "min"),
     1641            maxDate = this._getMinMaxDate(inst, "max"),
     1642            drawMonth = inst.drawMonth - showCurrentAtPos,
     1643            drawYear = inst.drawYear;
     1644
     1645        if (drawMonth < 0) {
     1646            drawMonth += 12;
     1647            drawYear--;
     1648        }
     1649        if (maxDate) {
     1650            maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
     1651                maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
     1652            maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
     1653            while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
     1654                drawMonth--;
     1655                if (drawMonth < 0) {
     1656                    drawMonth = 11;
     1657                    drawYear--;
     1658                }
     1659            }
     1660        }
     1661        inst.drawMonth = drawMonth;
     1662        inst.drawYear = drawYear;
     1663
     1664        prevText = this._get(inst, "prevText");
     1665        prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
     1666            this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
     1667            this._getFormatConfig(inst)));
     1668
     1669        prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
     1670            "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
     1671            " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
     1672            (hideIfNoPrevNext ? "" : "<a class='ui-datepicker-prev ui-corner-all ui-state-disabled' title='"+ prevText +"'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>"));
     1673
     1674        nextText = this._get(inst, "nextText");
     1675        nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
     1676            this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
     1677            this._getFormatConfig(inst)));
     1678
     1679        next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
     1680            "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
     1681            " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
     1682            (hideIfNoPrevNext ? "" : "<a class='ui-datepicker-next ui-corner-all ui-state-disabled' title='"+ nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>"));
     1683
     1684        currentText = this._get(inst, "currentText");
     1685        gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
     1686        currentText = (!navigationAsDateFormat ? currentText :
     1687            this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
     1688
     1689        controls = (!inst.inline ? "<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>" +
     1690            this._get(inst, "closeText") + "</button>" : "");
     1691
     1692        buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
     1693            (this._isInRange(inst, gotoDate) ? "<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'" +
     1694            ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
     1695
     1696        firstDay = parseInt(this._get(inst, "firstDay"),10);
     1697        firstDay = (isNaN(firstDay) ? 0 : firstDay);
     1698
     1699        showWeek = this._get(inst, "showWeek");
     1700        dayNames = this._get(inst, "dayNames");
     1701        dayNamesMin = this._get(inst, "dayNamesMin");
     1702        monthNames = this._get(inst, "monthNames");
     1703        monthNamesShort = this._get(inst, "monthNamesShort");
     1704        beforeShowDay = this._get(inst, "beforeShowDay");
     1705        showOtherMonths = this._get(inst, "showOtherMonths");
     1706        selectOtherMonths = this._get(inst, "selectOtherMonths");
     1707        defaultDate = this._getDefaultDate(inst);
     1708        html = "";
     1709        dow;
     1710        for (row = 0; row < numMonths[0]; row++) {
     1711            group = "";
     1712            this.maxRows = 4;
     1713            for (col = 0; col < numMonths[1]; col++) {
     1714                selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
     1715                cornerClass = " ui-corner-all";
     1716                calender = "";
     1717                if (isMultiMonth) {
     1718                    calender += "<div class='ui-datepicker-group";
     1719                    if (numMonths[1] > 1) {
     1720                        switch (col) {
     1721                            case 0: calender += " ui-datepicker-group-first";
     1722                                cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
     1723                            case numMonths[1]-1: calender += " ui-datepicker-group-last";
     1724                                cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
     1725                            default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
     1726                        }
     1727                    }
     1728                    calender += "'>";
     1729                }
     1730                calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
     1731                    (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
     1732                    (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
     1733                    this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
     1734                    row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
     1735                    "</div><table class='ui-datepicker-calendar'><thead>" +
     1736                    "<tr>";
     1737                thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
     1738                for (dow = 0; dow < 7; dow++) { // days of the week
     1739                    day = (dow + firstDay) % 7;
     1740                    thead += "<th scope='col'" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
     1741                        "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
     1742                }
     1743                calender += thead + "</tr></thead><tbody>";
     1744                daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
     1745                if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
     1746                    inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
     1747                }
     1748                leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
     1749                curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
     1750                numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
     1751                this.maxRows = numRows;
     1752                printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
     1753                for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
     1754                    calender += "<tr>";
     1755                    tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
     1756                        this._get(inst, "calculateWeek")(printDate) + "</td>");
     1757                    for (dow = 0; dow < 7; dow++) { // create date picker days
     1758                        daySettings = (beforeShowDay ?
     1759                            beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
     1760                        otherMonth = (printDate.getMonth() !== drawMonth);
     1761                        unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
     1762                            (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
     1763                        tbody += "<td class='" +
     1764                            ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
     1765                            (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
     1766                            ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
     1767                            (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
     1768                            // or defaultDate is current printedDate and defaultDate is selectedDate
     1769                            " " + this._dayOverClass : "") + // highlight selected day
     1770                            (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") +  // highlight unselectable days
     1771                            (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
     1772                            (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
     1773                            (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
     1774                            ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
     1775                            (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
     1776                            (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
     1777                            (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
     1778                            (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
     1779                            (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
     1780                            (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
     1781                            "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
     1782                        printDate.setDate(printDate.getDate() + 1);
     1783                        printDate = this._daylightSavingAdjust(printDate);
     1784                    }
     1785                    calender += tbody + "</tr>";
     1786                }
     1787                drawMonth++;
     1788                if (drawMonth > 11) {
     1789                    drawMonth = 0;
     1790                    drawYear++;
     1791                }
     1792                calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
     1793                            ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
     1794                group += calender;
     1795            }
     1796            html += group;
     1797        }
     1798        html += buttonPanel;
     1799        inst._keyEvent = false;
     1800        return html;
     1801    },
     1802
     1803    /* Generate the month and year header. */
     1804    _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
     1805            secondary, monthNames, monthNamesShort) {
     1806
     1807        var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
     1808            changeMonth = this._get(inst, "changeMonth"),
     1809            changeYear = this._get(inst, "changeYear"),
     1810            showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
     1811            html = "<div class='ui-datepicker-title'>",
     1812            monthHtml = "";
     1813
     1814        // month selection
     1815        if (secondary || !changeMonth) {
     1816            monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
     1817        } else {
     1818            inMinYear = (minDate && minDate.getFullYear() === drawYear);
     1819            inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
     1820            monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
     1821            for ( month = 0; month < 12; month++) {
     1822                if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
     1823                    monthHtml += "<option value='" + month + "'" +
     1824                        (month === drawMonth ? " selected='selected'" : "") +
     1825                        ">" + monthNamesShort[month] + "</option>";
     1826                }
     1827            }
     1828            monthHtml += "</select>";
     1829        }
     1830
     1831        if (!showMonthAfterYear) {
     1832            html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
     1833        }
     1834
     1835        // year selection
     1836        if ( !inst.yearshtml ) {
     1837            inst.yearshtml = "";
     1838            if (secondary || !changeYear) {
     1839                html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
     1840            } else {
     1841                // determine range of years to display
     1842                years = this._get(inst, "yearRange").split(":");
     1843                thisYear = new Date().getFullYear();
     1844                determineYear = function(value) {
     1845                    var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
     1846                        (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
     1847                        parseInt(value, 10)));
     1848                    return (isNaN(year) ? thisYear : year);
     1849                };
     1850                year = determineYear(years[0]);
     1851                endYear = Math.max(year, determineYear(years[1] || ""));
     1852                year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
     1853                endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
     1854                inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
     1855                for (; year <= endYear; year++) {
     1856                    inst.yearshtml += "<option value='" + year + "'" +
     1857                        (year === drawYear ? " selected='selected'" : "") +
     1858                        ">" + year + "</option>";
     1859                }
     1860                inst.yearshtml += "</select>";
     1861
     1862                html += inst.yearshtml;
     1863                inst.yearshtml = null;
     1864            }
     1865        }
     1866
     1867        html += this._get(inst, "yearSuffix");
     1868        if (showMonthAfterYear) {
     1869            html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
     1870        }
     1871        html += "</div>"; // Close datepicker_header
     1872        return html;
     1873    },
     1874
     1875    /* Adjust one of the date sub-fields. */
     1876    _adjustInstDate: function(inst, offset, period) {
     1877        var year = inst.drawYear + (period === "Y" ? offset : 0),
     1878            month = inst.drawMonth + (period === "M" ? offset : 0),
     1879            day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
     1880            date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
     1881
     1882        inst.selectedDay = date.getDate();
     1883        inst.drawMonth = inst.selectedMonth = date.getMonth();
     1884        inst.drawYear = inst.selectedYear = date.getFullYear();
     1885        if (period === "M" || period === "Y") {
     1886            this._notifyChange(inst);
     1887        }
     1888    },
     1889
     1890    /* Ensure a date is within any min/max bounds. */
     1891    _restrictMinMax: function(inst, date) {
     1892        var minDate = this._getMinMaxDate(inst, "min"),
     1893            maxDate = this._getMinMaxDate(inst, "max"),
     1894            newDate = (minDate && date < minDate ? minDate : date);
     1895        return (maxDate && newDate > maxDate ? maxDate : newDate);
     1896    },
     1897
     1898    /* Notify change of month/year. */
     1899    _notifyChange: function(inst) {
     1900        var onChange = this._get(inst, "onChangeMonthYear");
     1901        if (onChange) {
     1902            onChange.apply((inst.input ? inst.input[0] : null),
     1903                [inst.selectedYear, inst.selectedMonth + 1, inst]);
     1904        }
     1905    },
     1906
     1907    /* Determine the number of months to show. */
     1908    _getNumberOfMonths: function(inst) {
     1909        var numMonths = this._get(inst, "numberOfMonths");
     1910        return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
     1911    },
     1912
     1913    /* Determine the current maximum date - ensure no time components are set. */
     1914    _getMinMaxDate: function(inst, minMax) {
     1915        return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
     1916    },
     1917
     1918    /* Find the number of days in a given month. */
     1919    _getDaysInMonth: function(year, month) {
     1920        return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
     1921    },
     1922
     1923    /* Find the day of the week of the first of a month. */
     1924    _getFirstDayOfMonth: function(year, month) {
     1925        return new Date(year, month, 1).getDay();
     1926    },
     1927
     1928    /* Determines if we should allow a "next/prev" month display change. */
     1929    _canAdjustMonth: function(inst, offset, curYear, curMonth) {
     1930        var numMonths = this._getNumberOfMonths(inst),
     1931            date = this._daylightSavingAdjust(new Date(curYear,
     1932            curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
     1933
     1934        if (offset < 0) {
     1935            date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
     1936        }
     1937        return this._isInRange(inst, date);
     1938    },
     1939
     1940    /* Is the given date in the accepted range? */
     1941    _isInRange: function(inst, date) {
     1942        var yearSplit, currentYear,
     1943            minDate = this._getMinMaxDate(inst, "min"),
     1944            maxDate = this._getMinMaxDate(inst, "max"),
     1945            minYear = null,
     1946            maxYear = null,
     1947            years = this._get(inst, "yearRange");
     1948            if (years){
     1949                yearSplit = years.split(":");
     1950                currentYear = new Date().getFullYear();
     1951                minYear = parseInt(yearSplit[0], 10);
     1952                maxYear = parseInt(yearSplit[1], 10);
     1953                if ( yearSplit[0].match(/[+\-].*/) ) {
     1954                    minYear += currentYear;
     1955                }
     1956                if ( yearSplit[1].match(/[+\-].*/) ) {
     1957                    maxYear += currentYear;
     1958                }
     1959            }
     1960
     1961        return ((!minDate || date.getTime() >= minDate.getTime()) &&
     1962            (!maxDate || date.getTime() <= maxDate.getTime()) &&
     1963            (!minYear || date.getFullYear() >= minYear) &&
     1964            (!maxYear || date.getFullYear() <= maxYear));
     1965    },
     1966
     1967    /* Provide the configuration settings for formatting/parsing. */
     1968    _getFormatConfig: function(inst) {
     1969        var shortYearCutoff = this._get(inst, "shortYearCutoff");
     1970        shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
     1971            new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
     1972        return {shortYearCutoff: shortYearCutoff,
     1973            dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
     1974            monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
     1975    },
     1976
     1977    /* Format the given date for display. */
     1978    _formatDate: function(inst, day, month, year) {
     1979        if (!day) {
     1980            inst.currentDay = inst.selectedDay;
     1981            inst.currentMonth = inst.selectedMonth;
     1982            inst.currentYear = inst.selectedYear;
     1983        }
     1984        var date = (day ? (typeof day === "object" ? day :
     1985            this._daylightSavingAdjust(new Date(year, month, day))) :
     1986            this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
     1987        return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
     1988    }
     1989});
     1990
     1991/*
     1992 * Bind hover events for datepicker elements.
     1993 * Done via delegate so the binding only occurs once in the lifetime of the parent div.
     1994 * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
     1995 */
     1996function datepicker_bindHover(dpDiv) {
     1997    var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
     1998    return dpDiv.delegate(selector, "mouseout", function() {
     1999            $(this).removeClass("ui-state-hover");
     2000            if (this.className.indexOf("ui-datepicker-prev") !== -1) {
     2001                $(this).removeClass("ui-datepicker-prev-hover");
     2002            }
     2003            if (this.className.indexOf("ui-datepicker-next") !== -1) {
     2004                $(this).removeClass("ui-datepicker-next-hover");
     2005            }
     2006        })
     2007        .delegate( selector, "mouseover", datepicker_handleMouseover );
     2008}
     2009
     2010function datepicker_handleMouseover() {
     2011    if (!$.datepicker._isDisabledDatepicker( datepicker_instActive.inline? datepicker_instActive.dpDiv.parent()[0] : datepicker_instActive.input[0])) {
     2012        $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
     2013        $(this).addClass("ui-state-hover");
     2014        if (this.className.indexOf("ui-datepicker-prev") !== -1) {
     2015            $(this).addClass("ui-datepicker-prev-hover");
     2016        }
     2017        if (this.className.indexOf("ui-datepicker-next") !== -1) {
     2018            $(this).addClass("ui-datepicker-next-hover");
     2019        }
     2020    }
     2021}
     2022
     2023/* jQuery extend now ignores nulls! */
     2024function datepicker_extendRemove(target, props) {
     2025    $.extend(target, props);
     2026    for (var name in props) {
     2027        if (props[name] == null) {
     2028            target[name] = props[name];
     2029        }
     2030    }
     2031    return target;
     2032}
     2033
     2034/* Invoke the datepicker functionality.
     2035   @param  options  string - a command, optionally followed by additional parameters or
     2036                    Object - settings for attaching new datepicker functionality
     2037   @return  jQuery object */
     2038$.fn.datepicker = function(options){
     2039
     2040    /* Verify an empty collection wasn't passed - Fixes #6976 */
     2041    if ( !this.length ) {
     2042        return this;
     2043    }
     2044
     2045    /* Initialise the date picker. */
     2046    if (!$.datepicker.initialized) {
     2047        $(document).mousedown($.datepicker._checkExternalClick);
     2048        $.datepicker.initialized = true;
     2049    }
     2050
     2051    /* Append datepicker main container to body if not exist. */
     2052    if ($("#"+$.datepicker._mainDivId).length === 0) {
     2053        $("body").append($.datepicker.dpDiv);
     2054    }
     2055
     2056    var otherArgs = Array.prototype.slice.call(arguments, 1);
     2057    if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
     2058        return $.datepicker["_" + options + "Datepicker"].
     2059            apply($.datepicker, [this[0]].concat(otherArgs));
     2060    }
     2061    if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
     2062        return $.datepicker["_" + options + "Datepicker"].
     2063            apply($.datepicker, [this[0]].concat(otherArgs));
     2064    }
     2065    return this.each(function() {
     2066        typeof options === "string" ?
     2067            $.datepicker["_" + options + "Datepicker"].
     2068                apply($.datepicker, [this].concat(otherArgs)) :
     2069            $.datepicker._attachDatepicker(this, options);
     2070    });
     2071};
     2072
     2073$.datepicker = new Datepicker(); // singleton instance
     2074$.datepicker.initialized = false;
     2075$.datepicker.uuid = new Date().getTime();
     2076$.datepicker.version = "1.11.1";
     2077
     2078return $.datepicker;
     2079
     2080}));
  • trunk/src/wp-includes/js/jquery/ui/dialog.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){var e={buttons:!0,height:!0,maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0,width:!0},i={maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0};t.widget("ui.dialog",{version:"1.10.4",options:{appendTo:"body",autoOpen:!0,buttons:[],closeOnEscape:!0,closeText:"close",dialogClass:"",draggable:!0,hide:null,height:"auto",maxHeight:null,maxWidth:null,minHeight:150,minWidth:150,modal:!1,position:{my:"center",at:"center",of:window,collision:"fit",using:function(e){var i=t(this).css(e).offset().top;0>i&&t(this).css("top",e.top-i)}},resizable:!0,show:null,title:null,width:300,beforeClose:null,close:null,drag:null,dragStart:null,dragStop:null,focus:null,open:null,resize:null,resizeStart:null,resizeStop:null},_create:function(){this.originalCss={display:this.element[0].style.display,width:this.element[0].style.width,minHeight:this.element[0].style.minHeight,maxHeight:this.element[0].style.maxHeight,height:this.element[0].style.height},this.originalPosition={parent:this.element.parent(),index:this.element.parent().children().index(this.element)},this.originalTitle=this.element.attr("title"),this.options.title=this.options.title||this.originalTitle,this._createWrapper(),this.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(this.uiDialog),this._createTitlebar(),this._createButtonPane(),this.options.draggable&&t.fn.draggable&&this._makeDraggable(),this.options.resizable&&t.fn.resizable&&this._makeResizable(),this._isOpen=!1},_init:function(){this.options.autoOpen&&this.open()},_appendTo:function(){var e=this.options.appendTo;return e&&(e.jquery||e.nodeType)?t(e):this.document.find(e||"body").eq(0)},_destroy:function(){var t,e=this.originalPosition;this._destroyOverlay(),this.element.removeUniqueId().removeClass("ui-dialog-content ui-widget-content").css(this.originalCss).detach(),this.uiDialog.stop(!0,!0).remove(),this.originalTitle&&this.element.attr("title",this.originalTitle),t=e.parent.children().eq(e.index),t.length&&t[0]!==this.element[0]?t.before(this.element):e.parent.append(this.element)},widget:function(){return this.uiDialog},disable:t.noop,enable:t.noop,close:function(e){var i,s=this;if(this._isOpen&&this._trigger("beforeClose",e)!==!1){if(this._isOpen=!1,this._destroyOverlay(),!this.opener.filter(":focusable").focus().length)try{i=this.document[0].activeElement,i&&"body"!==i.nodeName.toLowerCase()&&t(i).blur()}catch(n){}this._hide(this.uiDialog,this.options.hide,function(){s._trigger("close",e)})}},isOpen:function(){return this._isOpen},moveToTop:function(){this._moveToTop()},_moveToTop:function(t,e){var i=!!this.uiDialog.nextAll(":visible").insertBefore(this.uiDialog).length;return i&&!e&&this._trigger("focus",t),i},open:function(){var e=this;return this._isOpen?(this._moveToTop()&&this._focusTabbable(),undefined):(this._isOpen=!0,this.opener=t(this.document[0].activeElement),this._size(),this._position(),this._createOverlay(),this._moveToTop(null,!0),this._show(this.uiDialog,this.options.show,function(){e._focusTabbable(),e._trigger("focus")}),this._trigger("open"),undefined)},_focusTabbable:function(){var t=this.element.find("[autofocus]");t.length||(t=this.element.find(":tabbable")),t.length||(t=this.uiDialogButtonPane.find(":tabbable")),t.length||(t=this.uiDialogTitlebarClose.filter(":tabbable")),t.length||(t=this.uiDialog),t.eq(0).focus()},_keepFocus:function(e){function i(){var e=this.document[0].activeElement,i=this.uiDialog[0]===e||t.contains(this.uiDialog[0],e);i||this._focusTabbable()}e.preventDefault(),i.call(this),this._delay(i)},_createWrapper:function(){this.uiDialog=t("<div>").addClass("ui-dialog ui-widget ui-widget-content ui-corner-all ui-front "+this.options.dialogClass).hide().attr({tabIndex:-1,role:"dialog"}).appendTo(this._appendTo()),this._on(this.uiDialog,{keydown:function(e){if(this.options.closeOnEscape&&!e.isDefaultPrevented()&&e.keyCode&&e.keyCode===t.ui.keyCode.ESCAPE)return e.preventDefault(),this.close(e),undefined;if(e.keyCode===t.ui.keyCode.TAB){var i=this.uiDialog.find(":tabbable"),s=i.filter(":first"),n=i.filter(":last");e.target!==n[0]&&e.target!==this.uiDialog[0]||e.shiftKey?e.target!==s[0]&&e.target!==this.uiDialog[0]||!e.shiftKey||(n.focus(1),e.preventDefault()):(s.focus(1),e.preventDefault())}},mousedown:function(t){this._moveToTop(t)&&this._focusTabbable()}}),this.element.find("[aria-describedby]").length||this.uiDialog.attr({"aria-describedby":this.element.uniqueId().attr("id")})},_createTitlebar:function(){var e;this.uiDialogTitlebar=t("<div>").addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(this.uiDialog),this._on(this.uiDialogTitlebar,{mousedown:function(e){t(e.target).closest(".ui-dialog-titlebar-close")||this.uiDialog.focus()}}),this.uiDialogTitlebarClose=t("<button type='button'></button>").button({label:this.options.closeText,icons:{primary:"ui-icon-closethick"},text:!1}).addClass("ui-dialog-titlebar-close").appendTo(this.uiDialogTitlebar),this._on(this.uiDialogTitlebarClose,{click:function(t){t.preventDefault(),this.close(t)}}),e=t("<span>").uniqueId().addClass("ui-dialog-title").prependTo(this.uiDialogTitlebar),this._title(e),this.uiDialog.attr({"aria-labelledby":e.attr("id")})},_title:function(t){this.options.title||t.html("&#160;"),t.text(this.options.title)},_createButtonPane:function(){this.uiDialogButtonPane=t("<div>").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),this.uiButtonSet=t("<div>").addClass("ui-dialog-buttonset").appendTo(this.uiDialogButtonPane),this._createButtons()},_createButtons:function(){var e=this,i=this.options.buttons;return this.uiDialogButtonPane.remove(),this.uiButtonSet.empty(),t.isEmptyObject(i)||t.isArray(i)&&!i.length?(this.uiDialog.removeClass("ui-dialog-buttons"),undefined):(t.each(i,function(i,s){var n,a;s=t.isFunction(s)?{click:s,text:i}:s,s=t.extend({type:"button"},s),n=s.click,s.click=function(){n.apply(e.element[0],arguments)},a={icons:s.icons,text:s.showText},delete s.icons,delete s.showText,t("<button></button>",s).button(a).appendTo(e.uiButtonSet)}),this.uiDialog.addClass("ui-dialog-buttons"),this.uiDialogButtonPane.appendTo(this.uiDialog),undefined)},_makeDraggable:function(){function e(t){return{position:t.position,offset:t.offset}}var i=this,s=this.options;this.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(s,n){t(this).addClass("ui-dialog-dragging"),i._blockFrames(),i._trigger("dragStart",s,e(n))},drag:function(t,s){i._trigger("drag",t,e(s))},stop:function(n,a){s.position=[a.position.left-i.document.scrollLeft(),a.position.top-i.document.scrollTop()],t(this).removeClass("ui-dialog-dragging"),i._unblockFrames(),i._trigger("dragStop",n,e(a))}})},_makeResizable:function(){function e(t){return{originalPosition:t.originalPosition,originalSize:t.originalSize,position:t.position,size:t.size}}var i=this,s=this.options,n=s.resizable,a=this.uiDialog.css("position"),o="string"==typeof n?n:"n,e,s,w,se,sw,ne,nw";this.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:this.element,maxWidth:s.maxWidth,maxHeight:s.maxHeight,minWidth:s.minWidth,minHeight:this._minHeight(),handles:o,start:function(s,n){t(this).addClass("ui-dialog-resizing"),i._blockFrames(),i._trigger("resizeStart",s,e(n))},resize:function(t,s){i._trigger("resize",t,e(s))},stop:function(n,a){s.height=t(this).height(),s.width=t(this).width(),t(this).removeClass("ui-dialog-resizing"),i._unblockFrames(),i._trigger("resizeStop",n,e(a))}}).css("position",a)},_minHeight:function(){var t=this.options;return"auto"===t.height?t.minHeight:Math.min(t.minHeight,t.height)},_position:function(){var t=this.uiDialog.is(":visible");t||this.uiDialog.show(),this.uiDialog.position(this.options.position),t||this.uiDialog.hide()},_setOptions:function(s){var n=this,a=!1,o={};t.each(s,function(t,s){n._setOption(t,s),t in e&&(a=!0),t in i&&(o[t]=s)}),a&&(this._size(),this._position()),this.uiDialog.is(":data(ui-resizable)")&&this.uiDialog.resizable("option",o)},_setOption:function(t,e){var i,s,n=this.uiDialog;"dialogClass"===t&&n.removeClass(this.options.dialogClass).addClass(e),"disabled"!==t&&(this._super(t,e),"appendTo"===t&&this.uiDialog.appendTo(this._appendTo()),"buttons"===t&&this._createButtons(),"closeText"===t&&this.uiDialogTitlebarClose.button({label:""+e}),"draggable"===t&&(i=n.is(":data(ui-draggable)"),i&&!e&&n.draggable("destroy"),!i&&e&&this._makeDraggable()),"position"===t&&this._position(),"resizable"===t&&(s=n.is(":data(ui-resizable)"),s&&!e&&n.resizable("destroy"),s&&"string"==typeof e&&n.resizable("option","handles",e),s||e===!1||this._makeResizable()),"title"===t&&this._title(this.uiDialogTitlebar.find(".ui-dialog-title")))},_size:function(){var t,e,i,s=this.options;this.element.show().css({width:"auto",minHeight:0,maxHeight:"none",height:0}),s.minWidth>s.width&&(s.width=s.minWidth),t=this.uiDialog.css({height:"auto",width:s.width}).outerHeight(),e=Math.max(0,s.minHeight-t),i="number"==typeof s.maxHeight?Math.max(0,s.maxHeight-t):"none","auto"===s.height?this.element.css({minHeight:e,maxHeight:i,height:"auto"}):this.element.height(Math.max(0,s.height-t)),this.uiDialog.is(":data(ui-resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())},_blockFrames:function(){this.iframeBlocks=this.document.find("iframe").map(function(){var e=t(this);return t("<div>").css({position:"absolute",width:e.outerWidth(),height:e.outerHeight()}).appendTo(e.parent()).offset(e.offset())[0]})},_unblockFrames:function(){this.iframeBlocks&&(this.iframeBlocks.remove(),delete this.iframeBlocks)},_allowInteraction:function(e){return t(e.target).closest(".ui-dialog").length?!0:!!t(e.target).closest(".ui-datepicker").length},_createOverlay:function(){if(this.options.modal){var e=this,i=this.widgetFullName;t.ui.dialog.overlayInstances||this._delay(function(){t.ui.dialog.overlayInstances&&this.document.bind("focusin.dialog",function(s){e._allowInteraction(s)||(s.preventDefault(),t(".ui-dialog:visible:last .ui-dialog-content").data(i)._focusTabbable())})}),this.overlay=t("<div>").addClass("ui-widget-overlay ui-front").appendTo(this._appendTo()),this._on(this.overlay,{mousedown:"_keepFocus"}),t.ui.dialog.overlayInstances++}},_destroyOverlay:function(){this.options.modal&&this.overlay&&(t.ui.dialog.overlayInstances--,t.ui.dialog.overlayInstances||this.document.unbind("focusin.dialog"),this.overlay.remove(),this.overlay=null)}}),t.ui.dialog.overlayInstances=0,t.uiBackCompat!==!1&&t.widget("ui.dialog",t.ui.dialog,{_position:function(){var e,i=this.options.position,s=[],n=[0,0];i?(("string"==typeof i||"object"==typeof i&&"0"in i)&&(s=i.split?i.split(" "):[i[0],i[1]],1===s.length&&(s[1]=s[0]),t.each(["left","top"],function(t,e){+s[t]===s[t]&&(n[t]=s[t],s[t]=e)}),i={my:s[0]+(0>n[0]?n[0]:"+"+n[0])+" "+s[1]+(0>n[1]?n[1]:"+"+n[1]),at:s.join(" ")}),i=t.extend({},t.ui.dialog.prototype.options.position,i)):i=t.ui.dialog.prototype.options.position,e=this.uiDialog.is(":visible"),e||this.uiDialog.show(),this.uiDialog.position(i),e||this.uiDialog.hide()}})})(jQuery);
     1/*!
     2 * jQuery UI Dialog 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/dialog/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./core",
     18            "./widget",
     19            "./button",
     20            "./draggable",
     21            "./mouse",
     22            "./position",
     23            "./resizable"
     24        ], factory );
     25    } else {
     26
     27        // Browser globals
     28        factory( jQuery );
     29    }
     30}(function( $ ) {
     31
     32return $.widget( "ui.dialog", {
     33    version: "1.11.1",
     34    options: {
     35        appendTo: "body",
     36        autoOpen: true,
     37        buttons: [],
     38        closeOnEscape: true,
     39        closeText: "Close",
     40        dialogClass: "",
     41        draggable: true,
     42        hide: null,
     43        height: "auto",
     44        maxHeight: null,
     45        maxWidth: null,
     46        minHeight: 150,
     47        minWidth: 150,
     48        modal: false,
     49        position: {
     50            my: "center",
     51            at: "center",
     52            of: window,
     53            collision: "fit",
     54            // Ensure the titlebar is always visible
     55            using: function( pos ) {
     56                var topOffset = $( this ).css( pos ).offset().top;
     57                if ( topOffset < 0 ) {
     58                    $( this ).css( "top", pos.top - topOffset );
     59                }
     60            }
     61        },
     62        resizable: true,
     63        show: null,
     64        title: null,
     65        width: 300,
     66
     67        // callbacks
     68        beforeClose: null,
     69        close: null,
     70        drag: null,
     71        dragStart: null,
     72        dragStop: null,
     73        focus: null,
     74        open: null,
     75        resize: null,
     76        resizeStart: null,
     77        resizeStop: null
     78    },
     79
     80    sizeRelatedOptions: {
     81        buttons: true,
     82        height: true,
     83        maxHeight: true,
     84        maxWidth: true,
     85        minHeight: true,
     86        minWidth: true,
     87        width: true
     88    },
     89
     90    resizableRelatedOptions: {
     91        maxHeight: true,
     92        maxWidth: true,
     93        minHeight: true,
     94        minWidth: true
     95    },
     96
     97    _create: function() {
     98        this.originalCss = {
     99            display: this.element[ 0 ].style.display,
     100            width: this.element[ 0 ].style.width,
     101            minHeight: this.element[ 0 ].style.minHeight,
     102            maxHeight: this.element[ 0 ].style.maxHeight,
     103            height: this.element[ 0 ].style.height
     104        };
     105        this.originalPosition = {
     106            parent: this.element.parent(),
     107            index: this.element.parent().children().index( this.element )
     108        };
     109        this.originalTitle = this.element.attr( "title" );
     110        this.options.title = this.options.title || this.originalTitle;
     111
     112        this._createWrapper();
     113
     114        this.element
     115            .show()
     116            .removeAttr( "title" )
     117            .addClass( "ui-dialog-content ui-widget-content" )
     118            .appendTo( this.uiDialog );
     119
     120        this._createTitlebar();
     121        this._createButtonPane();
     122
     123        if ( this.options.draggable && $.fn.draggable ) {
     124            this._makeDraggable();
     125        }
     126        if ( this.options.resizable && $.fn.resizable ) {
     127            this._makeResizable();
     128        }
     129
     130        this._isOpen = false;
     131
     132        this._trackFocus();
     133    },
     134
     135    _init: function() {
     136        if ( this.options.autoOpen ) {
     137            this.open();
     138        }
     139    },
     140
     141    _appendTo: function() {
     142        var element = this.options.appendTo;
     143        if ( element && (element.jquery || element.nodeType) ) {
     144            return $( element );
     145        }
     146        return this.document.find( element || "body" ).eq( 0 );
     147    },
     148
     149    _destroy: function() {
     150        var next,
     151            originalPosition = this.originalPosition;
     152
     153        this._destroyOverlay();
     154
     155        this.element
     156            .removeUniqueId()
     157            .removeClass( "ui-dialog-content ui-widget-content" )
     158            .css( this.originalCss )
     159            // Without detaching first, the following becomes really slow
     160            .detach();
     161
     162        this.uiDialog.stop( true, true ).remove();
     163
     164        if ( this.originalTitle ) {
     165            this.element.attr( "title", this.originalTitle );
     166        }
     167
     168        next = originalPosition.parent.children().eq( originalPosition.index );
     169        // Don't try to place the dialog next to itself (#8613)
     170        if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
     171            next.before( this.element );
     172        } else {
     173            originalPosition.parent.append( this.element );
     174        }
     175    },
     176
     177    widget: function() {
     178        return this.uiDialog;
     179    },
     180
     181    disable: $.noop,
     182    enable: $.noop,
     183
     184    close: function( event ) {
     185        var activeElement,
     186            that = this;
     187
     188        if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
     189            return;
     190        }
     191
     192        this._isOpen = false;
     193        this._focusedElement = null;
     194        this._destroyOverlay();
     195        this._untrackInstance();
     196
     197        if ( !this.opener.filter( ":focusable" ).focus().length ) {
     198
     199            // support: IE9
     200            // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
     201            try {
     202                activeElement = this.document[ 0 ].activeElement;
     203
     204                // Support: IE9, IE10
     205                // If the <body> is blurred, IE will switch windows, see #4520
     206                if ( activeElement && activeElement.nodeName.toLowerCase() !== "body" ) {
     207
     208                    // Hiding a focused element doesn't trigger blur in WebKit
     209                    // so in case we have nothing to focus on, explicitly blur the active element
     210                    // https://bugs.webkit.org/show_bug.cgi?id=47182
     211                    $( activeElement ).blur();
     212                }
     213            } catch ( error ) {}
     214        }
     215
     216        this._hide( this.uiDialog, this.options.hide, function() {
     217            that._trigger( "close", event );
     218        });
     219    },
     220
     221    isOpen: function() {
     222        return this._isOpen;
     223    },
     224
     225    moveToTop: function() {
     226        this._moveToTop();
     227    },
     228
     229    _moveToTop: function( event, silent ) {
     230        var moved = false,
     231            zIndicies = this.uiDialog.siblings( ".ui-front:visible" ).map(function() {
     232                return +$( this ).css( "z-index" );
     233            }).get(),
     234            zIndexMax = Math.max.apply( null, zIndicies );
     235
     236        if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
     237            this.uiDialog.css( "z-index", zIndexMax + 1 );
     238            moved = true;
     239        }
     240
     241        if ( moved && !silent ) {
     242            this._trigger( "focus", event );
     243        }
     244        return moved;
     245    },
     246
     247    open: function() {
     248        var that = this;
     249        if ( this._isOpen ) {
     250            if ( this._moveToTop() ) {
     251                this._focusTabbable();
     252            }
     253            return;
     254        }
     255
     256        this._isOpen = true;
     257        this.opener = $( this.document[ 0 ].activeElement );
     258
     259        this._size();
     260        this._position();
     261        this._createOverlay();
     262        this._moveToTop( null, true );
     263
     264        // Ensure the overlay is moved to the top with the dialog, but only when
     265        // opening. The overlay shouldn't move after the dialog is open so that
     266        // modeless dialogs opened after the modal dialog stack properly.
     267        if ( this.overlay ) {
     268            this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
     269        }
     270
     271        this._show( this.uiDialog, this.options.show, function() {
     272            that._focusTabbable();
     273            that._trigger( "focus" );
     274        });
     275
     276        // Track the dialog immediately upon openening in case a focus event
     277        // somehow occurs outside of the dialog before an element inside the
     278        // dialog is focused (#10152)
     279        this._makeFocusTarget();
     280
     281        this._trigger( "open" );
     282    },
     283
     284    _focusTabbable: function() {
     285        // Set focus to the first match:
     286        // 1. An element that was focused previously
     287        // 2. First element inside the dialog matching [autofocus]
     288        // 3. Tabbable element inside the content element
     289        // 4. Tabbable element inside the buttonpane
     290        // 5. The close button
     291        // 6. The dialog itself
     292        var hasFocus = this._focusedElement;
     293        if ( !hasFocus ) {
     294            hasFocus = this.element.find( "[autofocus]" );
     295        }
     296        if ( !hasFocus.length ) {
     297            hasFocus = this.element.find( ":tabbable" );
     298        }
     299        if ( !hasFocus.length ) {
     300            hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
     301        }
     302        if ( !hasFocus.length ) {
     303            hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
     304        }
     305        if ( !hasFocus.length ) {
     306            hasFocus = this.uiDialog;
     307        }
     308        hasFocus.eq( 0 ).focus();
     309    },
     310
     311    _keepFocus: function( event ) {
     312        function checkFocus() {
     313            var activeElement = this.document[0].activeElement,
     314                isActive = this.uiDialog[0] === activeElement ||
     315                    $.contains( this.uiDialog[0], activeElement );
     316            if ( !isActive ) {
     317                this._focusTabbable();
     318            }
     319        }
     320        event.preventDefault();
     321        checkFocus.call( this );
     322        // support: IE
     323        // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
     324        // so we check again later
     325        this._delay( checkFocus );
     326    },
     327
     328    _createWrapper: function() {
     329        this.uiDialog = $("<div>")
     330            .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
     331                this.options.dialogClass )
     332            .hide()
     333            .attr({
     334                // Setting tabIndex makes the div focusable
     335                tabIndex: -1,
     336                role: "dialog"
     337            })
     338            .appendTo( this._appendTo() );
     339
     340        this._on( this.uiDialog, {
     341            keydown: function( event ) {
     342                if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
     343                        event.keyCode === $.ui.keyCode.ESCAPE ) {
     344                    event.preventDefault();
     345                    this.close( event );
     346                    return;
     347                }
     348
     349                // prevent tabbing out of dialogs
     350                if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
     351                    return;
     352                }
     353                var tabbables = this.uiDialog.find( ":tabbable" ),
     354                    first = tabbables.filter( ":first" ),
     355                    last = tabbables.filter( ":last" );
     356
     357                if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
     358                    this._delay(function() {
     359                        first.focus();
     360                    });
     361                    event.preventDefault();
     362                } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
     363                    this._delay(function() {
     364                        last.focus();
     365                    });
     366                    event.preventDefault();
     367                }
     368            },
     369            mousedown: function( event ) {
     370                if ( this._moveToTop( event ) ) {
     371                    this._focusTabbable();
     372                }
     373            }
     374        });
     375
     376        // We assume that any existing aria-describedby attribute means
     377        // that the dialog content is marked up properly
     378        // otherwise we brute force the content as the description
     379        if ( !this.element.find( "[aria-describedby]" ).length ) {
     380            this.uiDialog.attr({
     381                "aria-describedby": this.element.uniqueId().attr( "id" )
     382            });
     383        }
     384    },
     385
     386    _createTitlebar: function() {
     387        var uiDialogTitle;
     388
     389        this.uiDialogTitlebar = $( "<div>" )
     390            .addClass( "ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" )
     391            .prependTo( this.uiDialog );
     392        this._on( this.uiDialogTitlebar, {
     393            mousedown: function( event ) {
     394                // Don't prevent click on close button (#8838)
     395                // Focusing a dialog that is partially scrolled out of view
     396                // causes the browser to scroll it into view, preventing the click event
     397                if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
     398                    // Dialog isn't getting focus when dragging (#8063)
     399                    this.uiDialog.focus();
     400                }
     401            }
     402        });
     403
     404        // support: IE
     405        // Use type="button" to prevent enter keypresses in textboxes from closing the
     406        // dialog in IE (#9312)
     407        this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
     408            .button({
     409                label: this.options.closeText,
     410                icons: {
     411                    primary: "ui-icon-closethick"
     412                },
     413                text: false
     414            })
     415            .addClass( "ui-dialog-titlebar-close" )
     416            .appendTo( this.uiDialogTitlebar );
     417        this._on( this.uiDialogTitlebarClose, {
     418            click: function( event ) {
     419                event.preventDefault();
     420                this.close( event );
     421            }
     422        });
     423
     424        uiDialogTitle = $( "<span>" )
     425            .uniqueId()
     426            .addClass( "ui-dialog-title" )
     427            .prependTo( this.uiDialogTitlebar );
     428        this._title( uiDialogTitle );
     429
     430        this.uiDialog.attr({
     431            "aria-labelledby": uiDialogTitle.attr( "id" )
     432        });
     433    },
     434
     435    _title: function( title ) {
     436        if ( !this.options.title ) {
     437            title.html( "&#160;" );
     438        }
     439        title.text( this.options.title );
     440    },
     441
     442    _createButtonPane: function() {
     443        this.uiDialogButtonPane = $( "<div>" )
     444            .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" );
     445
     446        this.uiButtonSet = $( "<div>" )
     447            .addClass( "ui-dialog-buttonset" )
     448            .appendTo( this.uiDialogButtonPane );
     449
     450        this._createButtons();
     451    },
     452
     453    _createButtons: function() {
     454        var that = this,
     455            buttons = this.options.buttons;
     456
     457        // if we already have a button pane, remove it
     458        this.uiDialogButtonPane.remove();
     459        this.uiButtonSet.empty();
     460
     461        if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
     462            this.uiDialog.removeClass( "ui-dialog-buttons" );
     463            return;
     464        }
     465
     466        $.each( buttons, function( name, props ) {
     467            var click, buttonOptions;
     468            props = $.isFunction( props ) ?
     469                { click: props, text: name } :
     470                props;
     471            // Default to a non-submitting button
     472            props = $.extend( { type: "button" }, props );
     473            // Change the context for the click callback to be the main element
     474            click = props.click;
     475            props.click = function() {
     476                click.apply( that.element[ 0 ], arguments );
     477            };
     478            buttonOptions = {
     479                icons: props.icons,
     480                text: props.showText
     481            };
     482            delete props.icons;
     483            delete props.showText;
     484            $( "<button></button>", props )
     485                .button( buttonOptions )
     486                .appendTo( that.uiButtonSet );
     487        });
     488        this.uiDialog.addClass( "ui-dialog-buttons" );
     489        this.uiDialogButtonPane.appendTo( this.uiDialog );
     490    },
     491
     492    _makeDraggable: function() {
     493        var that = this,
     494            options = this.options;
     495
     496        function filteredUi( ui ) {
     497            return {
     498                position: ui.position,
     499                offset: ui.offset
     500            };
     501        }
     502
     503        this.uiDialog.draggable({
     504            cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
     505            handle: ".ui-dialog-titlebar",
     506            containment: "document",
     507            start: function( event, ui ) {
     508                $( this ).addClass( "ui-dialog-dragging" );
     509                that._blockFrames();
     510                that._trigger( "dragStart", event, filteredUi( ui ) );
     511            },
     512            drag: function( event, ui ) {
     513                that._trigger( "drag", event, filteredUi( ui ) );
     514            },
     515            stop: function( event, ui ) {
     516                var left = ui.offset.left - that.document.scrollLeft(),
     517                    top = ui.offset.top - that.document.scrollTop();
     518
     519                options.position = {
     520                    my: "left top",
     521                    at: "left" + (left >= 0 ? "+" : "") + left + " " +
     522                        "top" + (top >= 0 ? "+" : "") + top,
     523                    of: that.window
     524                };
     525                $( this ).removeClass( "ui-dialog-dragging" );
     526                that._unblockFrames();
     527                that._trigger( "dragStop", event, filteredUi( ui ) );
     528            }
     529        });
     530    },
     531
     532    _makeResizable: function() {
     533        var that = this,
     534            options = this.options,
     535            handles = options.resizable,
     536            // .ui-resizable has position: relative defined in the stylesheet
     537            // but dialogs have to use absolute or fixed positioning
     538            position = this.uiDialog.css("position"),
     539            resizeHandles = typeof handles === "string" ?
     540                handles :
     541                "n,e,s,w,se,sw,ne,nw";
     542
     543        function filteredUi( ui ) {
     544            return {
     545                originalPosition: ui.originalPosition,
     546                originalSize: ui.originalSize,
     547                position: ui.position,
     548                size: ui.size
     549            };
     550        }
     551
     552        this.uiDialog.resizable({
     553            cancel: ".ui-dialog-content",
     554            containment: "document",
     555            alsoResize: this.element,
     556            maxWidth: options.maxWidth,
     557            maxHeight: options.maxHeight,
     558            minWidth: options.minWidth,
     559            minHeight: this._minHeight(),
     560            handles: resizeHandles,
     561            start: function( event, ui ) {
     562                $( this ).addClass( "ui-dialog-resizing" );
     563                that._blockFrames();
     564                that._trigger( "resizeStart", event, filteredUi( ui ) );
     565            },
     566            resize: function( event, ui ) {
     567                that._trigger( "resize", event, filteredUi( ui ) );
     568            },
     569            stop: function( event, ui ) {
     570                var offset = that.uiDialog.offset(),
     571                    left = offset.left - that.document.scrollLeft(),
     572                    top = offset.top - that.document.scrollTop();
     573
     574                options.height = that.uiDialog.height();
     575                options.width = that.uiDialog.width();
     576                options.position = {
     577                    my: "left top",
     578                    at: "left" + (left >= 0 ? "+" : "") + left + " " +
     579                        "top" + (top >= 0 ? "+" : "") + top,
     580                    of: that.window
     581                };
     582                $( this ).removeClass( "ui-dialog-resizing" );
     583                that._unblockFrames();
     584                that._trigger( "resizeStop", event, filteredUi( ui ) );
     585            }
     586        })
     587        .css( "position", position );
     588    },
     589
     590    _trackFocus: function() {
     591        this._on( this.widget(), {
     592            focusin: function( event ) {
     593                this._makeFocusTarget();
     594                this._focusedElement = $( event.target );
     595            }
     596        });
     597    },
     598
     599    _makeFocusTarget: function() {
     600        this._untrackInstance();
     601        this._trackingInstances().unshift( this );
     602    },
     603
     604    _untrackInstance: function() {
     605        var instances = this._trackingInstances(),
     606            exists = $.inArray( this, instances );
     607        if ( exists !== -1 ) {
     608            instances.splice( exists, 1 );
     609        }
     610    },
     611
     612    _trackingInstances: function() {
     613        var instances = this.document.data( "ui-dialog-instances" );
     614        if ( !instances ) {
     615            instances = [];
     616            this.document.data( "ui-dialog-instances", instances );
     617        }
     618        return instances;
     619    },
     620
     621    _minHeight: function() {
     622        var options = this.options;
     623
     624        return options.height === "auto" ?
     625            options.minHeight :
     626            Math.min( options.minHeight, options.height );
     627    },
     628
     629    _position: function() {
     630        // Need to show the dialog to get the actual offset in the position plugin
     631        var isVisible = this.uiDialog.is( ":visible" );
     632        if ( !isVisible ) {
     633            this.uiDialog.show();
     634        }
     635        this.uiDialog.position( this.options.position );
     636        if ( !isVisible ) {
     637            this.uiDialog.hide();
     638        }
     639    },
     640
     641    _setOptions: function( options ) {
     642        var that = this,
     643            resize = false,
     644            resizableOptions = {};
     645
     646        $.each( options, function( key, value ) {
     647            that._setOption( key, value );
     648
     649            if ( key in that.sizeRelatedOptions ) {
     650                resize = true;
     651            }
     652            if ( key in that.resizableRelatedOptions ) {
     653                resizableOptions[ key ] = value;
     654            }
     655        });
     656
     657        if ( resize ) {
     658            this._size();
     659            this._position();
     660        }
     661        if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
     662            this.uiDialog.resizable( "option", resizableOptions );
     663        }
     664    },
     665
     666    _setOption: function( key, value ) {
     667        var isDraggable, isResizable,
     668            uiDialog = this.uiDialog;
     669
     670        if ( key === "dialogClass" ) {
     671            uiDialog
     672                .removeClass( this.options.dialogClass )
     673                .addClass( value );
     674        }
     675
     676        if ( key === "disabled" ) {
     677            return;
     678        }
     679
     680        this._super( key, value );
     681
     682        if ( key === "appendTo" ) {
     683            this.uiDialog.appendTo( this._appendTo() );
     684        }
     685
     686        if ( key === "buttons" ) {
     687            this._createButtons();
     688        }
     689
     690        if ( key === "closeText" ) {
     691            this.uiDialogTitlebarClose.button({
     692                // Ensure that we always pass a string
     693                label: "" + value
     694            });
     695        }
     696
     697        if ( key === "draggable" ) {
     698            isDraggable = uiDialog.is( ":data(ui-draggable)" );
     699            if ( isDraggable && !value ) {
     700                uiDialog.draggable( "destroy" );
     701            }
     702
     703            if ( !isDraggable && value ) {
     704                this._makeDraggable();
     705            }
     706        }
     707
     708        if ( key === "position" ) {
     709            this._position();
     710        }
     711
     712        if ( key === "resizable" ) {
     713            // currently resizable, becoming non-resizable
     714            isResizable = uiDialog.is( ":data(ui-resizable)" );
     715            if ( isResizable && !value ) {
     716                uiDialog.resizable( "destroy" );
     717            }
     718
     719            // currently resizable, changing handles
     720            if ( isResizable && typeof value === "string" ) {
     721                uiDialog.resizable( "option", "handles", value );
     722            }
     723
     724            // currently non-resizable, becoming resizable
     725            if ( !isResizable && value !== false ) {
     726                this._makeResizable();
     727            }
     728        }
     729
     730        if ( key === "title" ) {
     731            this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
     732        }
     733    },
     734
     735    _size: function() {
     736        // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
     737        // divs will both have width and height set, so we need to reset them
     738        var nonContentHeight, minContentHeight, maxContentHeight,
     739            options = this.options;
     740
     741        // Reset content sizing
     742        this.element.show().css({
     743            width: "auto",
     744            minHeight: 0,
     745            maxHeight: "none",
     746            height: 0
     747        });
     748
     749        if ( options.minWidth > options.width ) {
     750            options.width = options.minWidth;
     751        }
     752
     753        // reset wrapper sizing
     754        // determine the height of all the non-content elements
     755        nonContentHeight = this.uiDialog.css({
     756                height: "auto",
     757                width: options.width
     758            })
     759            .outerHeight();
     760        minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
     761        maxContentHeight = typeof options.maxHeight === "number" ?
     762            Math.max( 0, options.maxHeight - nonContentHeight ) :
     763            "none";
     764
     765        if ( options.height === "auto" ) {
     766            this.element.css({
     767                minHeight: minContentHeight,
     768                maxHeight: maxContentHeight,
     769                height: "auto"
     770            });
     771        } else {
     772            this.element.height( Math.max( 0, options.height - nonContentHeight ) );
     773        }
     774
     775        if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
     776            this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
     777        }
     778    },
     779
     780    _blockFrames: function() {
     781        this.iframeBlocks = this.document.find( "iframe" ).map(function() {
     782            var iframe = $( this );
     783
     784            return $( "<div>" )
     785                .css({
     786                    position: "absolute",
     787                    width: iframe.outerWidth(),
     788                    height: iframe.outerHeight()
     789                })
     790                .appendTo( iframe.parent() )
     791                .offset( iframe.offset() )[0];
     792        });
     793    },
     794
     795    _unblockFrames: function() {
     796        if ( this.iframeBlocks ) {
     797            this.iframeBlocks.remove();
     798            delete this.iframeBlocks;
     799        }
     800    },
     801
     802    _allowInteraction: function( event ) {
     803        if ( $( event.target ).closest( ".ui-dialog" ).length ) {
     804            return true;
     805        }
     806
     807        // TODO: Remove hack when datepicker implements
     808        // the .ui-front logic (#8989)
     809        return !!$( event.target ).closest( ".ui-datepicker" ).length;
     810    },
     811
     812    _createOverlay: function() {
     813        if ( !this.options.modal ) {
     814            return;
     815        }
     816
     817        // We use a delay in case the overlay is created from an
     818        // event that we're going to be cancelling (#2804)
     819        var isOpening = true;
     820        this._delay(function() {
     821            isOpening = false;
     822        });
     823
     824        if ( !this.document.data( "ui-dialog-overlays" ) ) {
     825
     826            // Prevent use of anchors and inputs
     827            // Using _on() for an event handler shared across many instances is
     828            // safe because the dialogs stack and must be closed in reverse order
     829            this._on( this.document, {
     830                focusin: function( event ) {
     831                    if ( isOpening ) {
     832                        return;
     833                    }
     834
     835                    if ( !this._allowInteraction( event ) ) {
     836                        event.preventDefault();
     837                        this._trackingInstances()[ 0 ]._focusTabbable();
     838                    }
     839                }
     840            });
     841        }
     842
     843        this.overlay = $( "<div>" )
     844            .addClass( "ui-widget-overlay ui-front" )
     845            .appendTo( this._appendTo() );
     846        this._on( this.overlay, {
     847            mousedown: "_keepFocus"
     848        });
     849        this.document.data( "ui-dialog-overlays",
     850            (this.document.data( "ui-dialog-overlays" ) || 0) + 1 );
     851    },
     852
     853    _destroyOverlay: function() {
     854        if ( !this.options.modal ) {
     855            return;
     856        }
     857
     858        if ( this.overlay ) {
     859            var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
     860
     861            if ( !overlays ) {
     862                this.document
     863                    .unbind( "focusin" )
     864                    .removeData( "ui-dialog-overlays" );
     865            } else {
     866                this.document.data( "ui-dialog-overlays", overlays );
     867            }
     868
     869            this.overlay.remove();
     870            this.overlay = null;
     871        }
     872    }
     873});
     874
     875}));
  • trunk/src/wp-includes/js/jquery/ui/draggable.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(e){e.widget("ui.draggable",e.ui.mouse,{version:"1.10.4",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1,drag:null,start:null,stop:null},_create:function(){"original"!==this.options.helper||/^(?:r|a|f)/.test(this.element.css("position"))||(this.element[0].style.position="relative"),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._mouseInit()},_destroy:function(){this.element.removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled"),this._mouseDestroy()},_mouseCapture:function(t){var i=this.options;return this.helper||i.disabled||e(t.target).closest(".ui-resizable-handle").length>0?!1:(this.handle=this._getHandle(t),this.handle?(e(i.iframeFix===!0?"iframe":i.iframeFix).each(function(){e("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>").css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1e3}).css(e(this).offset()).appendTo("body")}),!0):!1)},_mouseStart:function(t){var i=this.options;return this.helper=this._createHelper(t),this.helper.addClass("ui-draggable-dragging"),this._cacheHelperProportions(),e.ui.ddmanager&&(e.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(),this.offsetParent=this.helper.offsetParent(),this.offsetParentCssPosition=this.offsetParent.css("position"),this.offset=this.positionAbs=this.element.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},this.offset.scroll=!1,e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this.position=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,i.cursorAt&&this._adjustOffsetFromHelper(i.cursorAt),this._setContainment(),this._trigger("start",t)===!1?(this._clear(),!1):(this._cacheHelperProportions(),e.ui.ddmanager&&!i.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this._mouseDrag(t,!0),e.ui.ddmanager&&e.ui.ddmanager.dragStart(this,t),!0)},_mouseDrag:function(t,i){if("fixed"===this.offsetParentCssPosition&&(this.offset.parent=this._getParentOffset()),this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute"),!i){var s=this._uiHash();if(this._trigger("drag",t,s)===!1)return this._mouseUp({}),!1;this.position=s.position}return this.options.axis&&"y"===this.options.axis||(this.helper[0].style.left=this.position.left+"px"),this.options.axis&&"x"===this.options.axis||(this.helper[0].style.top=this.position.top+"px"),e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),!1},_mouseStop:function(t){var i=this,s=!1;return e.ui.ddmanager&&!this.options.dropBehaviour&&(s=e.ui.ddmanager.drop(this,t)),this.dropped&&(s=this.dropped,this.dropped=!1),"original"!==this.options.helper||e.contains(this.element[0].ownerDocument,this.element[0])?("invalid"===this.options.revert&&!s||"valid"===this.options.revert&&s||this.options.revert===!0||e.isFunction(this.options.revert)&&this.options.revert.call(this.element,s)?e(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){i._trigger("stop",t)!==!1&&i._clear()}):this._trigger("stop",t)!==!1&&this._clear(),!1):!1},_mouseUp:function(t){return e("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)}),e.ui.ddmanager&&e.ui.ddmanager.dragStop(this,t),e.ui.mouse.prototype._mouseUp.call(this,t)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(t){return this.options.handle?!!e(t.target).closest(this.element.find(this.options.handle)).length:!0},_createHelper:function(t){var i=this.options,s=e.isFunction(i.helper)?e(i.helper.apply(this.element[0],[t])):"clone"===i.helper?this.element.clone().removeAttr("id"):this.element;return s.parents("body").length||s.appendTo("parent"===i.appendTo?this.element[0].parentNode:i.appendTo),s[0]===this.element[0]||/(fixed|absolute)/.test(s.css("position"))||s.css("position","absolute"),s},_adjustOffsetFromHelper:function(t){"string"==typeof t&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_getParentOffset:function(){var t=this.offsetParent.offset();return"absolute"===this.cssPosition&&this.scrollParent[0]!==document&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]===document.body||this.offsetParent[0].tagName&&"html"===this.offsetParent[0].tagName.toLowerCase()&&e.ui.ie)&&(t={top:0,left:0}),{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"===this.cssPosition){var e=this.element.position();return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:e.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t,i,s,n=this.options;return n.containment?"window"===n.containment?(this.containment=[e(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,e(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,e(window).scrollLeft()+e(window).width()-this.helperProportions.width-this.margins.left,e(window).scrollTop()+(e(window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],undefined):"document"===n.containment?(this.containment=[0,0,e(document).width()-this.helperProportions.width-this.margins.left,(e(document).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],undefined):n.containment.constructor===Array?(this.containment=n.containment,undefined):("parent"===n.containment&&(n.containment=this.helper[0].parentNode),i=e(n.containment),s=i[0],s&&(t="hidden"!==i.css("overflow"),this.containment=[(parseInt(i.css("borderLeftWidth"),10)||0)+(parseInt(i.css("paddingLeft"),10)||0),(parseInt(i.css("borderTopWidth"),10)||0)+(parseInt(i.css("paddingTop"),10)||0),(t?Math.max(s.scrollWidth,s.offsetWidth):s.offsetWidth)-(parseInt(i.css("borderRightWidth"),10)||0)-(parseInt(i.css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(t?Math.max(s.scrollHeight,s.offsetHeight):s.offsetHeight)-(parseInt(i.css("borderBottomWidth"),10)||0)-(parseInt(i.css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relative_container=i),undefined):(this.containment=null,undefined)},_convertPositionTo:function(t,i){i||(i=this.position);var s="absolute"===t?1:-1,n="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent;return this.offset.scroll||(this.offset.scroll={top:n.scrollTop(),left:n.scrollLeft()}),{top:i.top+this.offset.relative.top*s+this.offset.parent.top*s-("fixed"===this.cssPosition?-this.scrollParent.scrollTop():this.offset.scroll.top)*s,left:i.left+this.offset.relative.left*s+this.offset.parent.left*s-("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():this.offset.scroll.left)*s}},_generatePosition:function(t){var i,s,n,a,o=this.options,r="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,h=t.pageX,l=t.pageY;return this.offset.scroll||(this.offset.scroll={top:r.scrollTop(),left:r.scrollLeft()}),this.originalPosition&&(this.containment&&(this.relative_container?(s=this.relative_container.offset(),i=[this.containment[0]+s.left,this.containment[1]+s.top,this.containment[2]+s.left,this.containment[3]+s.top]):i=this.containment,t.pageX-this.offset.click.left<i[0]&&(h=i[0]+this.offset.click.left),t.pageY-this.offset.click.top<i[1]&&(l=i[1]+this.offset.click.top),t.pageX-this.offset.click.left>i[2]&&(h=i[2]+this.offset.click.left),t.pageY-this.offset.click.top>i[3]&&(l=i[3]+this.offset.click.top)),o.grid&&(n=o.grid[1]?this.originalPageY+Math.round((l-this.originalPageY)/o.grid[1])*o.grid[1]:this.originalPageY,l=i?n-this.offset.click.top>=i[1]||n-this.offset.click.top>i[3]?n:n-this.offset.click.top>=i[1]?n-o.grid[1]:n+o.grid[1]:n,a=o.grid[0]?this.originalPageX+Math.round((h-this.originalPageX)/o.grid[0])*o.grid[0]:this.originalPageX,h=i?a-this.offset.click.left>=i[0]||a-this.offset.click.left>i[2]?a:a-this.offset.click.left>=i[0]?a-o.grid[0]:a+o.grid[0]:a)),{top:l-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():this.offset.scroll.top),left:h-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():this.offset.scroll.left)}},_clear:function(){this.helper.removeClass("ui-draggable-dragging"),this.helper[0]===this.element[0]||this.cancelHelperRemoval||this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1},_trigger:function(t,i,s){return s=s||this._uiHash(),e.ui.plugin.call(this,t,[i,s]),"drag"===t&&(this.positionAbs=this._convertPositionTo("absolute")),e.Widget.prototype._trigger.call(this,t,i,s)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),e.ui.plugin.add("draggable","connectToSortable",{start:function(t,i){var s=e(this).data("ui-draggable"),n=s.options,a=e.extend({},i,{item:s.element});s.sortables=[],e(n.connectToSortable).each(function(){var i=e.data(this,"ui-sortable");i&&!i.options.disabled&&(s.sortables.push({instance:i,shouldRevert:i.options.revert}),i.refreshPositions(),i._trigger("activate",t,a))})},stop:function(t,i){var s=e(this).data("ui-draggable"),n=e.extend({},i,{item:s.element});e.each(s.sortables,function(){this.instance.isOver?(this.instance.isOver=0,s.cancelHelperRemoval=!0,this.instance.cancelHelperRemoval=!1,this.shouldRevert&&(this.instance.options.revert=this.shouldRevert),this.instance._mouseStop(t),this.instance.options.helper=this.instance.options._helper,"original"===s.options.helper&&this.instance.currentItem.css({top:"auto",left:"auto"})):(this.instance.cancelHelperRemoval=!1,this.instance._trigger("deactivate",t,n))})},drag:function(t,i){var s=e(this).data("ui-draggable"),n=this;e.each(s.sortables,function(){var a=!1,o=this;this.instance.positionAbs=s.positionAbs,this.instance.helperProportions=s.helperProportions,this.instance.offset.click=s.offset.click,this.instance._intersectsWith(this.instance.containerCache)&&(a=!0,e.each(s.sortables,function(){return this.instance.positionAbs=s.positionAbs,this.instance.helperProportions=s.helperProportions,this.instance.offset.click=s.offset.click,this!==o&&this.instance._intersectsWith(this.instance.containerCache)&&e.contains(o.instance.element[0],this.instance.element[0])&&(a=!1),a})),a?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=e(n).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item",!0),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return i.helper[0]},t.target=this.instance.currentItem[0],this.instance._mouseCapture(t,!0),this.instance._mouseStart(t,!0,!0),this.instance.offset.click.top=s.offset.click.top,this.instance.offset.click.left=s.offset.click.left,this.instance.offset.parent.left-=s.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=s.offset.parent.top-this.instance.offset.parent.top,s._trigger("toSortable",t),s.dropped=this.instance.element,s.currentItem=s.element,this.instance.fromOutside=s),this.instance.currentItem&&this.instance._mouseDrag(t)):this.instance.isOver&&(this.instance.isOver=0,this.instance.cancelHelperRemoval=!0,this.instance.options.revert=!1,this.instance._trigger("out",t,this.instance._uiHash(this.instance)),this.instance._mouseStop(t,!0),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&this.instance.placeholder.remove(),s._trigger("fromSortable",t),s.dropped=!1)})}}),e.ui.plugin.add("draggable","cursor",{start:function(){var t=e("body"),i=e(this).data("ui-draggable").options;t.css("cursor")&&(i._cursor=t.css("cursor")),t.css("cursor",i.cursor)},stop:function(){var t=e(this).data("ui-draggable").options;t._cursor&&e("body").css("cursor",t._cursor)}}),e.ui.plugin.add("draggable","opacity",{start:function(t,i){var s=e(i.helper),n=e(this).data("ui-draggable").options;s.css("opacity")&&(n._opacity=s.css("opacity")),s.css("opacity",n.opacity)},stop:function(t,i){var s=e(this).data("ui-draggable").options;s._opacity&&e(i.helper).css("opacity",s._opacity)}}),e.ui.plugin.add("draggable","scroll",{start:function(){var t=e(this).data("ui-draggable");t.scrollParent[0]!==document&&"HTML"!==t.scrollParent[0].tagName&&(t.overflowOffset=t.scrollParent.offset())},drag:function(t){var i=e(this).data("ui-draggable"),s=i.options,n=!1;i.scrollParent[0]!==document&&"HTML"!==i.scrollParent[0].tagName?(s.axis&&"x"===s.axis||(i.overflowOffset.top+i.scrollParent[0].offsetHeight-t.pageY<s.scrollSensitivity?i.scrollParent[0].scrollTop=n=i.scrollParent[0].scrollTop+s.scrollSpeed:t.pageY-i.overflowOffset.top<s.scrollSensitivity&&(i.scrollParent[0].scrollTop=n=i.scrollParent[0].scrollTop-s.scrollSpeed)),s.axis&&"y"===s.axis||(i.overflowOffset.left+i.scrollParent[0].offsetWidth-t.pageX<s.scrollSensitivity?i.scrollParent[0].scrollLeft=n=i.scrollParent[0].scrollLeft+s.scrollSpeed:t.pageX-i.overflowOffset.left<s.scrollSensitivity&&(i.scrollParent[0].scrollLeft=n=i.scrollParent[0].scrollLeft-s.scrollSpeed))):(s.axis&&"x"===s.axis||(t.pageY-e(document).scrollTop()<s.scrollSensitivity?n=e(document).scrollTop(e(document).scrollTop()-s.scrollSpeed):e(window).height()-(t.pageY-e(document).scrollTop())<s.scrollSensitivity&&(n=e(document).scrollTop(e(document).scrollTop()+s.scrollSpeed))),s.axis&&"y"===s.axis||(t.pageX-e(document).scrollLeft()<s.scrollSensitivity?n=e(document).scrollLeft(e(document).scrollLeft()-s.scrollSpeed):e(window).width()-(t.pageX-e(document).scrollLeft())<s.scrollSensitivity&&(n=e(document).scrollLeft(e(document).scrollLeft()+s.scrollSpeed)))),n!==!1&&e.ui.ddmanager&&!s.dropBehaviour&&e.ui.ddmanager.prepareOffsets(i,t)}}),e.ui.plugin.add("draggable","snap",{start:function(){var t=e(this).data("ui-draggable"),i=t.options;t.snapElements=[],e(i.snap.constructor!==String?i.snap.items||":data(ui-draggable)":i.snap).each(function(){var i=e(this),s=i.offset();this!==t.element[0]&&t.snapElements.push({item:this,width:i.outerWidth(),height:i.outerHeight(),top:s.top,left:s.left})})},drag:function(t,i){var s,n,a,o,r,h,l,u,c,d,p=e(this).data("ui-draggable"),f=p.options,m=f.snapTolerance,g=i.offset.left,v=g+p.helperProportions.width,y=i.offset.top,b=y+p.helperProportions.height;for(c=p.snapElements.length-1;c>=0;c--)r=p.snapElements[c].left,h=r+p.snapElements[c].width,l=p.snapElements[c].top,u=l+p.snapElements[c].height,r-m>v||g>h+m||l-m>b||y>u+m||!e.contains(p.snapElements[c].item.ownerDocument,p.snapElements[c].item)?(p.snapElements[c].snapping&&p.options.snap.release&&p.options.snap.release.call(p.element,t,e.extend(p._uiHash(),{snapItem:p.snapElements[c].item})),p.snapElements[c].snapping=!1):("inner"!==f.snapMode&&(s=m>=Math.abs(l-b),n=m>=Math.abs(u-y),a=m>=Math.abs(r-v),o=m>=Math.abs(h-g),s&&(i.position.top=p._convertPositionTo("relative",{top:l-p.helperProportions.height,left:0}).top-p.margins.top),n&&(i.position.top=p._convertPositionTo("relative",{top:u,left:0}).top-p.margins.top),a&&(i.position.left=p._convertPositionTo("relative",{top:0,left:r-p.helperProportions.width}).left-p.margins.left),o&&(i.position.left=p._convertPositionTo("relative",{top:0,left:h}).left-p.margins.left)),d=s||n||a||o,"outer"!==f.snapMode&&(s=m>=Math.abs(l-y),n=m>=Math.abs(u-b),a=m>=Math.abs(r-g),o=m>=Math.abs(h-v),s&&(i.position.top=p._convertPositionTo("relative",{top:l,left:0}).top-p.margins.top),n&&(i.position.top=p._convertPositionTo("relative",{top:u-p.helperProportions.height,left:0}).top-p.margins.top),a&&(i.position.left=p._convertPositionTo("relative",{top:0,left:r}).left-p.margins.left),o&&(i.position.left=p._convertPositionTo("relative",{top:0,left:h-p.helperProportions.width}).left-p.margins.left)),!p.snapElements[c].snapping&&(s||n||a||o||d)&&p.options.snap.snap&&p.options.snap.snap.call(p.element,t,e.extend(p._uiHash(),{snapItem:p.snapElements[c].item})),p.snapElements[c].snapping=s||n||a||o||d)}}),e.ui.plugin.add("draggable","stack",{start:function(){var t,i=this.data("ui-draggable").options,s=e.makeArray(e(i.stack)).sort(function(t,i){return(parseInt(e(t).css("zIndex"),10)||0)-(parseInt(e(i).css("zIndex"),10)||0)});s.length&&(t=parseInt(e(s[0]).css("zIndex"),10)||0,e(s).each(function(i){e(this).css("zIndex",t+i)}),this.css("zIndex",t+s.length))}}),e.ui.plugin.add("draggable","zIndex",{start:function(t,i){var s=e(i.helper),n=e(this).data("ui-draggable").options;s.css("zIndex")&&(n._zIndex=s.css("zIndex")),s.css("zIndex",n.zIndex)},stop:function(t,i){var s=e(this).data("ui-draggable").options;s._zIndex&&e(i.helper).css("zIndex",s._zIndex)}})})(jQuery);
     1/*!
     2 * jQuery UI Draggable 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/draggable/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./core",
     18            "./mouse",
     19            "./widget"
     20        ], factory );
     21    } else {
     22
     23        // Browser globals
     24        factory( jQuery );
     25    }
     26}(function( $ ) {
     27
     28$.widget("ui.draggable", $.ui.mouse, {
     29    version: "1.11.1",
     30    widgetEventPrefix: "drag",
     31    options: {
     32        addClasses: true,
     33        appendTo: "parent",
     34        axis: false,
     35        connectToSortable: false,
     36        containment: false,
     37        cursor: "auto",
     38        cursorAt: false,
     39        grid: false,
     40        handle: false,
     41        helper: "original",
     42        iframeFix: false,
     43        opacity: false,
     44        refreshPositions: false,
     45        revert: false,
     46        revertDuration: 500,
     47        scope: "default",
     48        scroll: true,
     49        scrollSensitivity: 20,
     50        scrollSpeed: 20,
     51        snap: false,
     52        snapMode: "both",
     53        snapTolerance: 20,
     54        stack: false,
     55        zIndex: false,
     56
     57        // callbacks
     58        drag: null,
     59        start: null,
     60        stop: null
     61    },
     62    _create: function() {
     63
     64        if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) {
     65            this.element[0].style.position = "relative";
     66        }
     67        if (this.options.addClasses){
     68            this.element.addClass("ui-draggable");
     69        }
     70        if (this.options.disabled){
     71            this.element.addClass("ui-draggable-disabled");
     72        }
     73        this._setHandleClassName();
     74
     75        this._mouseInit();
     76    },
     77
     78    _setOption: function( key, value ) {
     79        this._super( key, value );
     80        if ( key === "handle" ) {
     81            this._removeHandleClassName();
     82            this._setHandleClassName();
     83        }
     84    },
     85
     86    _destroy: function() {
     87        if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
     88            this.destroyOnClear = true;
     89            return;
     90        }
     91        this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
     92        this._removeHandleClassName();
     93        this._mouseDestroy();
     94    },
     95
     96    _mouseCapture: function(event) {
     97
     98        var document = this.document[ 0 ],
     99            o = this.options;
     100
     101        // support: IE9
     102        // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
     103        try {
     104            // Support: IE9+
     105            // If the <body> is blurred, IE will switch windows, see #9520
     106            if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) {
     107                // Blur any element that currently has focus, see #4261
     108                $( document.activeElement ).blur();
     109            }
     110        } catch ( error ) {}
     111
     112        // among others, prevent a drag on a resizable-handle
     113        if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
     114            return false;
     115        }
     116
     117        //Quit if we're not on a valid handle
     118        this.handle = this._getHandle(event);
     119        if (!this.handle) {
     120            return false;
     121        }
     122
     123        $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
     124            $("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>")
     125            .css({
     126                width: this.offsetWidth + "px", height: this.offsetHeight + "px",
     127                position: "absolute", opacity: "0.001", zIndex: 1000
     128            })
     129            .css($(this).offset())
     130            .appendTo("body");
     131        });
     132
     133        return true;
     134
     135    },
     136
     137    _mouseStart: function(event) {
     138
     139        var o = this.options;
     140
     141        //Create and append the visible helper
     142        this.helper = this._createHelper(event);
     143
     144        this.helper.addClass("ui-draggable-dragging");
     145
     146        //Cache the helper size
     147        this._cacheHelperProportions();
     148
     149        //If ddmanager is used for droppables, set the global draggable
     150        if ($.ui.ddmanager) {
     151            $.ui.ddmanager.current = this;
     152        }
     153
     154        /*
     155         * - Position generation -
     156         * This block generates everything position related - it's the core of draggables.
     157         */
     158
     159        //Cache the margins of the original element
     160        this._cacheMargins();
     161
     162        //Store the helper's css position
     163        this.cssPosition = this.helper.css( "position" );
     164        this.scrollParent = this.helper.scrollParent( true );
     165        this.offsetParent = this.helper.offsetParent();
     166        this.offsetParentCssPosition = this.offsetParent.css( "position" );
     167
     168        //The element's absolute position on the page minus margins
     169        this.offset = this.positionAbs = this.element.offset();
     170        this.offset = {
     171            top: this.offset.top - this.margins.top,
     172            left: this.offset.left - this.margins.left
     173        };
     174
     175        //Reset scroll cache
     176        this.offset.scroll = false;
     177
     178        $.extend(this.offset, {
     179            click: { //Where the click happened, relative to the element
     180                left: event.pageX - this.offset.left,
     181                top: event.pageY - this.offset.top
     182            },
     183            parent: this._getParentOffset(),
     184            relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
     185        });
     186
     187        //Generate the original position
     188        this.originalPosition = this.position = this._generatePosition( event, false );
     189        this.originalPageX = event.pageX;
     190        this.originalPageY = event.pageY;
     191
     192        //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
     193        (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
     194
     195        //Set a containment if given in the options
     196        this._setContainment();
     197
     198        //Trigger event + callbacks
     199        if (this._trigger("start", event) === false) {
     200            this._clear();
     201            return false;
     202        }
     203
     204        //Recache the helper size
     205        this._cacheHelperProportions();
     206
     207        //Prepare the droppable offsets
     208        if ($.ui.ddmanager && !o.dropBehaviour) {
     209            $.ui.ddmanager.prepareOffsets(this, event);
     210        }
     211
     212        this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
     213
     214        //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
     215        if ( $.ui.ddmanager ) {
     216            $.ui.ddmanager.dragStart(this, event);
     217        }
     218
     219        return true;
     220    },
     221
     222    _mouseDrag: function(event, noPropagation) {
     223        // reset any necessary cached properties (see #5009)
     224        if ( this.offsetParentCssPosition === "fixed" ) {
     225            this.offset.parent = this._getParentOffset();
     226        }
     227
     228        //Compute the helpers position
     229        this.position = this._generatePosition( event, true );
     230        this.positionAbs = this._convertPositionTo("absolute");
     231
     232        //Call plugins and callbacks and use the resulting position if something is returned
     233        if (!noPropagation) {
     234            var ui = this._uiHash();
     235            if (this._trigger("drag", event, ui) === false) {
     236                this._mouseUp({});
     237                return false;
     238            }
     239            this.position = ui.position;
     240        }
     241
     242        this.helper[ 0 ].style.left = this.position.left + "px";
     243        this.helper[ 0 ].style.top = this.position.top + "px";
     244
     245        if ($.ui.ddmanager) {
     246            $.ui.ddmanager.drag(this, event);
     247        }
     248
     249        return false;
     250    },
     251
     252    _mouseStop: function(event) {
     253
     254        //If we are using droppables, inform the manager about the drop
     255        var that = this,
     256            dropped = false;
     257        if ($.ui.ddmanager && !this.options.dropBehaviour) {
     258            dropped = $.ui.ddmanager.drop(this, event);
     259        }
     260
     261        //if a drop comes from outside (a sortable)
     262        if (this.dropped) {
     263            dropped = this.dropped;
     264            this.dropped = false;
     265        }
     266
     267        if ((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
     268            $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
     269                if (that._trigger("stop", event) !== false) {
     270                    that._clear();
     271                }
     272            });
     273        } else {
     274            if (this._trigger("stop", event) !== false) {
     275                this._clear();
     276            }
     277        }
     278
     279        return false;
     280    },
     281
     282    _mouseUp: function(event) {
     283        //Remove frame helpers
     284        $("div.ui-draggable-iframeFix").each(function() {
     285            this.parentNode.removeChild(this);
     286        });
     287
     288        //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
     289        if ( $.ui.ddmanager ) {
     290            $.ui.ddmanager.dragStop(this, event);
     291        }
     292
     293        // The interaction is over; whether or not the click resulted in a drag, focus the element
     294        this.element.focus();
     295
     296        return $.ui.mouse.prototype._mouseUp.call(this, event);
     297    },
     298
     299    cancel: function() {
     300
     301        if (this.helper.is(".ui-draggable-dragging")) {
     302            this._mouseUp({});
     303        } else {
     304            this._clear();
     305        }
     306
     307        return this;
     308
     309    },
     310
     311    _getHandle: function(event) {
     312        return this.options.handle ?
     313            !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
     314            true;
     315    },
     316
     317    _setHandleClassName: function() {
     318        this.handleElement = this.options.handle ?
     319            this.element.find( this.options.handle ) : this.element;
     320        this.handleElement.addClass( "ui-draggable-handle" );
     321    },
     322
     323    _removeHandleClassName: function() {
     324        this.handleElement.removeClass( "ui-draggable-handle" );
     325    },
     326
     327    _createHelper: function(event) {
     328
     329        var o = this.options,
     330            helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[ 0 ], [ event ])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
     331
     332        if (!helper.parents("body").length) {
     333            helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
     334        }
     335
     336        if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
     337            helper.css("position", "absolute");
     338        }
     339
     340        return helper;
     341
     342    },
     343
     344    _adjustOffsetFromHelper: function(obj) {
     345        if (typeof obj === "string") {
     346            obj = obj.split(" ");
     347        }
     348        if ($.isArray(obj)) {
     349            obj = { left: +obj[0], top: +obj[1] || 0 };
     350        }
     351        if ("left" in obj) {
     352            this.offset.click.left = obj.left + this.margins.left;
     353        }
     354        if ("right" in obj) {
     355            this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
     356        }
     357        if ("top" in obj) {
     358            this.offset.click.top = obj.top + this.margins.top;
     359        }
     360        if ("bottom" in obj) {
     361            this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
     362        }
     363    },
     364
     365    _isRootNode: function( element ) {
     366        return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
     367    },
     368
     369    _getParentOffset: function() {
     370
     371        //Get the offsetParent and cache its position
     372        var po = this.offsetParent.offset(),
     373            document = this.document[ 0 ];
     374
     375        // This is a special case where we need to modify a offset calculated on start, since the following happened:
     376        // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
     377        // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
     378        //    the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
     379        if (this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
     380            po.left += this.scrollParent.scrollLeft();
     381            po.top += this.scrollParent.scrollTop();
     382        }
     383
     384        if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
     385            po = { top: 0, left: 0 };
     386        }
     387
     388        return {
     389            top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
     390            left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
     391        };
     392
     393    },
     394
     395    _getRelativeOffset: function() {
     396        if ( this.cssPosition !== "relative" ) {
     397            return { top: 0, left: 0 };
     398        }
     399
     400        var p = this.element.position(),
     401            scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
     402
     403        return {
     404            top: p.top - ( parseInt(this.helper.css( "top" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
     405            left: p.left - ( parseInt(this.helper.css( "left" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
     406        };
     407
     408    },
     409
     410    _cacheMargins: function() {
     411        this.margins = {
     412            left: (parseInt(this.element.css("marginLeft"), 10) || 0),
     413            top: (parseInt(this.element.css("marginTop"), 10) || 0),
     414            right: (parseInt(this.element.css("marginRight"), 10) || 0),
     415            bottom: (parseInt(this.element.css("marginBottom"), 10) || 0)
     416        };
     417    },
     418
     419    _cacheHelperProportions: function() {
     420        this.helperProportions = {
     421            width: this.helper.outerWidth(),
     422            height: this.helper.outerHeight()
     423        };
     424    },
     425
     426    _setContainment: function() {
     427
     428        var over, c, ce,
     429            o = this.options,
     430            document = this.document[ 0 ];
     431
     432        this.relativeContainer = null;
     433
     434        if ( !o.containment ) {
     435            this.containment = null;
     436            return;
     437        }
     438
     439        if ( o.containment === "window" ) {
     440            this.containment = [
     441                $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
     442                $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
     443                $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
     444                $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
     445            ];
     446            return;
     447        }
     448
     449        if ( o.containment === "document") {
     450            this.containment = [
     451                0,
     452                0,
     453                $( document ).width() - this.helperProportions.width - this.margins.left,
     454                ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
     455            ];
     456            return;
     457        }
     458
     459        if ( o.containment.constructor === Array ) {
     460            this.containment = o.containment;
     461            return;
     462        }
     463
     464        if ( o.containment === "parent" ) {
     465            o.containment = this.helper[ 0 ].parentNode;
     466        }
     467
     468        c = $( o.containment );
     469        ce = c[ 0 ];
     470
     471        if ( !ce ) {
     472            return;
     473        }
     474
     475        over = c.css( "overflow" ) !== "hidden";
     476
     477        this.containment = [
     478            ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
     479            ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
     480            ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - this.helperProportions.width - this.margins.left - this.margins.right,
     481            ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) - this.helperProportions.height - this.margins.top  - this.margins.bottom
     482        ];
     483        this.relativeContainer = c;
     484    },
     485
     486    _convertPositionTo: function(d, pos) {
     487
     488        if (!pos) {
     489            pos = this.position;
     490        }
     491
     492        var mod = d === "absolute" ? 1 : -1,
     493            scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
     494
     495        return {
     496            top: (
     497                pos.top +                                                               // The absolute mouse position
     498                this.offset.relative.top * mod +                                        // Only for relative positioned nodes: Relative offset from element to offset parent
     499                this.offset.parent.top * mod -                                      // The offsetParent's offset without borders (offset + border)
     500                ( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod)
     501            ),
     502            left: (
     503                pos.left +                                                              // The absolute mouse position
     504                this.offset.relative.left * mod +                                       // Only for relative positioned nodes: Relative offset from element to offset parent
     505                this.offset.parent.left * mod   -                                       // The offsetParent's offset without borders (offset + border)
     506                ( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod)
     507            )
     508        };
     509
     510    },
     511
     512    _generatePosition: function( event, constrainPosition ) {
     513
     514        var containment, co, top, left,
     515            o = this.options,
     516            scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
     517            pageX = event.pageX,
     518            pageY = event.pageY;
     519
     520        // Cache the scroll
     521        if ( !scrollIsRootNode || !this.offset.scroll ) {
     522            this.offset.scroll = {
     523                top: this.scrollParent.scrollTop(),
     524                left: this.scrollParent.scrollLeft()
     525            };
     526        }
     527
     528        /*
     529         * - Position constraining -
     530         * Constrain the position to a mix of grid, containment.
     531         */
     532
     533        // If we are not dragging yet, we won't check for options
     534        if ( constrainPosition ) {
     535            if ( this.containment ) {
     536                if ( this.relativeContainer ){
     537                    co = this.relativeContainer.offset();
     538                    containment = [
     539                        this.containment[ 0 ] + co.left,
     540                        this.containment[ 1 ] + co.top,
     541                        this.containment[ 2 ] + co.left,
     542                        this.containment[ 3 ] + co.top
     543                    ];
     544                } else {
     545                    containment = this.containment;
     546                }
     547
     548                if (event.pageX - this.offset.click.left < containment[0]) {
     549                    pageX = containment[0] + this.offset.click.left;
     550                }
     551                if (event.pageY - this.offset.click.top < containment[1]) {
     552                    pageY = containment[1] + this.offset.click.top;
     553                }
     554                if (event.pageX - this.offset.click.left > containment[2]) {
     555                    pageX = containment[2] + this.offset.click.left;
     556                }
     557                if (event.pageY - this.offset.click.top > containment[3]) {
     558                    pageY = containment[3] + this.offset.click.top;
     559                }
     560            }
     561
     562            if (o.grid) {
     563                //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
     564                top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
     565                pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
     566
     567                left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
     568                pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
     569            }
     570
     571            if ( o.axis === "y" ) {
     572                pageX = this.originalPageX;
     573            }
     574
     575            if ( o.axis === "x" ) {
     576                pageY = this.originalPageY;
     577            }
     578        }
     579
     580        return {
     581            top: (
     582                pageY -                                                                 // The absolute mouse position
     583                this.offset.click.top   -                                               // Click offset (relative to the element)
     584                this.offset.relative.top -                                              // Only for relative positioned nodes: Relative offset from element to offset parent
     585                this.offset.parent.top +                                                // The offsetParent's offset without borders (offset + border)
     586                ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
     587            ),
     588            left: (
     589                pageX -                                                                 // The absolute mouse position
     590                this.offset.click.left -                                                // Click offset (relative to the element)
     591                this.offset.relative.left -                                             // Only for relative positioned nodes: Relative offset from element to offset parent
     592                this.offset.parent.left +                                               // The offsetParent's offset without borders (offset + border)
     593                ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
     594            )
     595        };
     596
     597    },
     598
     599    _clear: function() {
     600        this.helper.removeClass("ui-draggable-dragging");
     601        if (this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
     602            this.helper.remove();
     603        }
     604        this.helper = null;
     605        this.cancelHelperRemoval = false;
     606        if ( this.destroyOnClear ) {
     607            this.destroy();
     608        }
     609    },
     610
     611    // From now on bulk stuff - mainly helpers
     612
     613    _trigger: function(type, event, ui) {
     614        ui = ui || this._uiHash();
     615        $.ui.plugin.call( this, type, [ event, ui, this ], true );
     616        //The absolute position has to be recalculated after plugins
     617        if (type === "drag") {
     618            this.positionAbs = this._convertPositionTo("absolute");
     619        }
     620        return $.Widget.prototype._trigger.call(this, type, event, ui);
     621    },
     622
     623    plugins: {},
     624
     625    _uiHash: function() {
     626        return {
     627            helper: this.helper,
     628            position: this.position,
     629            originalPosition: this.originalPosition,
     630            offset: this.positionAbs
     631        };
     632    }
     633
     634});
     635
     636$.ui.plugin.add("draggable", "connectToSortable", {
     637    start: function( event, ui, inst ) {
     638
     639        var o = inst.options,
     640            uiSortable = $.extend({}, ui, { item: inst.element });
     641        inst.sortables = [];
     642        $(o.connectToSortable).each(function() {
     643            var sortable = $( this ).sortable( "instance" );
     644            if (sortable && !sortable.options.disabled) {
     645                inst.sortables.push({
     646                    instance: sortable,
     647                    shouldRevert: sortable.options.revert
     648                });
     649                sortable.refreshPositions();    // Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page).
     650                sortable._trigger("activate", event, uiSortable);
     651            }
     652        });
     653
     654    },
     655    stop: function( event, ui, inst ) {
     656
     657        //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
     658        var uiSortable = $.extend( {}, ui, {
     659            item: inst.element
     660        });
     661
     662        $.each(inst.sortables, function() {
     663            if (this.instance.isOver) {
     664
     665                this.instance.isOver = 0;
     666
     667                inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
     668                this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
     669
     670                //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
     671                if (this.shouldRevert) {
     672                    this.instance.options.revert = this.shouldRevert;
     673                }
     674
     675                //Trigger the stop of the sortable
     676                this.instance._mouseStop(event);
     677
     678                this.instance.options.helper = this.instance.options._helper;
     679
     680                //If the helper has been the original item, restore properties in the sortable
     681                if (inst.options.helper === "original") {
     682                    this.instance.currentItem.css({ top: "auto", left: "auto" });
     683                }
     684
     685            } else {
     686                this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
     687                this.instance._trigger("deactivate", event, uiSortable);
     688            }
     689
     690        });
     691
     692    },
     693    drag: function( event, ui, inst ) {
     694
     695        var that = this;
     696
     697        $.each(inst.sortables, function() {
     698
     699            var innermostIntersecting = false,
     700                thisSortable = this;
     701
     702            //Copy over some variables to allow calling the sortable's native _intersectsWith
     703            this.instance.positionAbs = inst.positionAbs;
     704            this.instance.helperProportions = inst.helperProportions;
     705            this.instance.offset.click = inst.offset.click;
     706
     707            if (this.instance._intersectsWith(this.instance.containerCache)) {
     708                innermostIntersecting = true;
     709                $.each(inst.sortables, function() {
     710                    this.instance.positionAbs = inst.positionAbs;
     711                    this.instance.helperProportions = inst.helperProportions;
     712                    this.instance.offset.click = inst.offset.click;
     713                    if (this !== thisSortable &&
     714                        this.instance._intersectsWith(this.instance.containerCache) &&
     715                        $.contains(thisSortable.instance.element[0], this.instance.element[0])
     716                    ) {
     717                        innermostIntersecting = false;
     718                    }
     719                    return innermostIntersecting;
     720                });
     721            }
     722
     723            if (innermostIntersecting) {
     724                //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
     725                if (!this.instance.isOver) {
     726
     727                    this.instance.isOver = 1;
     728                    //Now we fake the start of dragging for the sortable instance,
     729                    //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
     730                    //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
     731                    this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
     732                    this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
     733                    this.instance.options.helper = function() { return ui.helper[0]; };
     734
     735                    event.target = this.instance.currentItem[0];
     736                    this.instance._mouseCapture(event, true);
     737                    this.instance._mouseStart(event, true, true);
     738
     739                    //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
     740                    this.instance.offset.click.top = inst.offset.click.top;
     741                    this.instance.offset.click.left = inst.offset.click.left;
     742                    this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
     743                    this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
     744
     745                    inst._trigger("toSortable", event);
     746                    inst.dropped = this.instance.element; //draggable revert needs that
     747                    //hack so receive/update callbacks work (mostly)
     748                    inst.currentItem = inst.element;
     749                    this.instance.fromOutside = inst;
     750
     751                }
     752
     753                //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable
     754                if (this.instance.currentItem) {
     755                    this.instance._mouseDrag(event);
     756                }
     757
     758            } else {
     759
     760                //If it doesn't intersect with the sortable, and it intersected before,
     761                //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
     762                if (this.instance.isOver) {
     763
     764                    this.instance.isOver = 0;
     765                    this.instance.cancelHelperRemoval = true;
     766
     767                    //Prevent reverting on this forced stop
     768                    this.instance.options.revert = false;
     769
     770                    // The out event needs to be triggered independently
     771                    this.instance._trigger("out", event, this.instance._uiHash(this.instance));
     772
     773                    this.instance._mouseStop(event, true);
     774                    this.instance.options.helper = this.instance.options._helper;
     775
     776                    //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
     777                    this.instance.currentItem.remove();
     778                    if (this.instance.placeholder) {
     779                        this.instance.placeholder.remove();
     780                    }
     781
     782                    inst._trigger("fromSortable", event);
     783                    inst.dropped = false; //draggable revert needs that
     784                }
     785
     786            }
     787
     788        });
     789
     790    }
     791});
     792
     793$.ui.plugin.add("draggable", "cursor", {
     794    start: function( event, ui, instance ) {
     795        var t = $( "body" ),
     796            o = instance.options;
     797
     798        if (t.css("cursor")) {
     799            o._cursor = t.css("cursor");
     800        }
     801        t.css("cursor", o.cursor);
     802    },
     803    stop: function( event, ui, instance ) {
     804        var o = instance.options;
     805        if (o._cursor) {
     806            $("body").css("cursor", o._cursor);
     807        }
     808    }
     809});
     810
     811$.ui.plugin.add("draggable", "opacity", {
     812    start: function( event, ui, instance ) {
     813        var t = $( ui.helper ),
     814            o = instance.options;
     815        if (t.css("opacity")) {
     816            o._opacity = t.css("opacity");
     817        }
     818        t.css("opacity", o.opacity);
     819    },
     820    stop: function( event, ui, instance ) {
     821        var o = instance.options;
     822        if (o._opacity) {
     823            $(ui.helper).css("opacity", o._opacity);
     824        }
     825    }
     826});
     827
     828$.ui.plugin.add("draggable", "scroll", {
     829    start: function( event, ui, i ) {
     830        if ( !i.scrollParentNotHidden ) {
     831            i.scrollParentNotHidden = i.helper.scrollParent( false );
     832        }
     833
     834        if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
     835            i.overflowOffset = i.scrollParentNotHidden.offset();
     836        }
     837    },
     838    drag: function( event, ui, i  ) {
     839
     840        var o = i.options,
     841            scrolled = false,
     842            scrollParent = i.scrollParentNotHidden[ 0 ],
     843            document = i.document[ 0 ];
     844
     845        if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
     846            if ( !o.axis || o.axis !== "x" ) {
     847                if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < o.scrollSensitivity ) {
     848                    scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
     849                } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
     850                    scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
     851                }
     852            }
     853
     854            if ( !o.axis || o.axis !== "y" ) {
     855                if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < o.scrollSensitivity ) {
     856                    scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
     857                } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
     858                    scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
     859                }
     860            }
     861
     862        } else {
     863
     864            if (!o.axis || o.axis !== "x") {
     865                if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
     866                    scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
     867                } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
     868                    scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
     869                }
     870            }
     871
     872            if (!o.axis || o.axis !== "y") {
     873                if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
     874                    scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
     875                } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
     876                    scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
     877                }
     878            }
     879
     880        }
     881
     882        if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
     883            $.ui.ddmanager.prepareOffsets(i, event);
     884        }
     885
     886    }
     887});
     888
     889$.ui.plugin.add("draggable", "snap", {
     890    start: function( event, ui, i ) {
     891
     892        var o = i.options;
     893
     894        i.snapElements = [];
     895
     896        $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
     897            var $t = $(this),
     898                $o = $t.offset();
     899            if (this !== i.element[0]) {
     900                i.snapElements.push({
     901                    item: this,
     902                    width: $t.outerWidth(), height: $t.outerHeight(),
     903                    top: $o.top, left: $o.left
     904                });
     905            }
     906        });
     907
     908    },
     909    drag: function( event, ui, inst ) {
     910
     911        var ts, bs, ls, rs, l, r, t, b, i, first,
     912            o = inst.options,
     913            d = o.snapTolerance,
     914            x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
     915            y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
     916
     917        for (i = inst.snapElements.length - 1; i >= 0; i--){
     918
     919            l = inst.snapElements[i].left;
     920            r = l + inst.snapElements[i].width;
     921            t = inst.snapElements[i].top;
     922            b = t + inst.snapElements[i].height;
     923
     924            if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
     925                if (inst.snapElements[i].snapping) {
     926                    (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
     927                }
     928                inst.snapElements[i].snapping = false;
     929                continue;
     930            }
     931
     932            if (o.snapMode !== "inner") {
     933                ts = Math.abs(t - y2) <= d;
     934                bs = Math.abs(b - y1) <= d;
     935                ls = Math.abs(l - x2) <= d;
     936                rs = Math.abs(r - x1) <= d;
     937                if (ts) {
     938                    ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
     939                }
     940                if (bs) {
     941                    ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
     942                }
     943                if (ls) {
     944                    ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
     945                }
     946                if (rs) {
     947                    ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
     948                }
     949            }
     950
     951            first = (ts || bs || ls || rs);
     952
     953            if (o.snapMode !== "outer") {
     954                ts = Math.abs(t - y1) <= d;
     955                bs = Math.abs(b - y2) <= d;
     956                ls = Math.abs(l - x1) <= d;
     957                rs = Math.abs(r - x2) <= d;
     958                if (ts) {
     959                    ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
     960                }
     961                if (bs) {
     962                    ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
     963                }
     964                if (ls) {
     965                    ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
     966                }
     967                if (rs) {
     968                    ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
     969                }
     970            }
     971
     972            if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
     973                (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
     974            }
     975            inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
     976
     977        }
     978
     979    }
     980});
     981
     982$.ui.plugin.add("draggable", "stack", {
     983    start: function( event, ui, instance ) {
     984        var min,
     985            o = instance.options,
     986            group = $.makeArray($(o.stack)).sort(function(a, b) {
     987                return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0);
     988            });
     989
     990        if (!group.length) { return; }
     991
     992        min = parseInt($(group[0]).css("zIndex"), 10) || 0;
     993        $(group).each(function(i) {
     994            $(this).css("zIndex", min + i);
     995        });
     996        this.css("zIndex", (min + group.length));
     997    }
     998});
     999
     1000$.ui.plugin.add("draggable", "zIndex", {
     1001    start: function( event, ui, instance ) {
     1002        var t = $( ui.helper ),
     1003            o = instance.options;
     1004
     1005        if (t.css("zIndex")) {
     1006            o._zIndex = t.css("zIndex");
     1007        }
     1008        t.css("zIndex", o.zIndex);
     1009    },
     1010    stop: function( event, ui, instance ) {
     1011        var o = instance.options;
     1012
     1013        if (o._zIndex) {
     1014            $(ui.helper).css("zIndex", o._zIndex);
     1015        }
     1016    }
     1017});
     1018
     1019return $.ui.draggable;
     1020
     1021}));
  • trunk/src/wp-includes/js/jquery/ui/droppable.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(e){function t(e,t,i){return e>t&&t+i>e}e.widget("ui.droppable",{version:"1.10.4",widgetEventPrefix:"drop",options:{accept:"*",activeClass:!1,addClasses:!0,greedy:!1,hoverClass:!1,scope:"default",tolerance:"intersect",activate:null,deactivate:null,drop:null,out:null,over:null},_create:function(){var t,i=this.options,s=i.accept;this.isover=!1,this.isout=!0,this.accept=e.isFunction(s)?s:function(e){return e.is(s)},this.proportions=function(){return arguments.length?(t=arguments[0],undefined):t?t:t={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight}},e.ui.ddmanager.droppables[i.scope]=e.ui.ddmanager.droppables[i.scope]||[],e.ui.ddmanager.droppables[i.scope].push(this),i.addClasses&&this.element.addClass("ui-droppable")},_destroy:function(){for(var t=0,i=e.ui.ddmanager.droppables[this.options.scope];i.length>t;t++)i[t]===this&&i.splice(t,1);this.element.removeClass("ui-droppable ui-droppable-disabled")},_setOption:function(t,i){"accept"===t&&(this.accept=e.isFunction(i)?i:function(e){return e.is(i)}),e.Widget.prototype._setOption.apply(this,arguments)},_activate:function(t){var i=e.ui.ddmanager.current;this.options.activeClass&&this.element.addClass(this.options.activeClass),i&&this._trigger("activate",t,this.ui(i))},_deactivate:function(t){var i=e.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass),i&&this._trigger("deactivate",t,this.ui(i))},_over:function(t){var i=e.ui.ddmanager.current;i&&(i.currentItem||i.element)[0]!==this.element[0]&&this.accept.call(this.element[0],i.currentItem||i.element)&&(this.options.hoverClass&&this.element.addClass(this.options.hoverClass),this._trigger("over",t,this.ui(i)))},_out:function(t){var i=e.ui.ddmanager.current;i&&(i.currentItem||i.element)[0]!==this.element[0]&&this.accept.call(this.element[0],i.currentItem||i.element)&&(this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("out",t,this.ui(i)))},_drop:function(t,i){var s=i||e.ui.ddmanager.current,n=!1;return s&&(s.currentItem||s.element)[0]!==this.element[0]?(this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function(){var t=e.data(this,"ui-droppable");return t.options.greedy&&!t.options.disabled&&t.options.scope===s.options.scope&&t.accept.call(t.element[0],s.currentItem||s.element)&&e.ui.intersect(s,e.extend(t,{offset:t.element.offset()}),t.options.tolerance)?(n=!0,!1):undefined}),n?!1:this.accept.call(this.element[0],s.currentItem||s.element)?(this.options.activeClass&&this.element.removeClass(this.options.activeClass),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("drop",t,this.ui(s)),this.element):!1):!1},ui:function(e){return{draggable:e.currentItem||e.element,helper:e.helper,position:e.position,offset:e.positionAbs}}}),e.ui.intersect=function(e,i,s){if(!i.offset)return!1;var n,a,o=(e.positionAbs||e.position.absolute).left,r=(e.positionAbs||e.position.absolute).top,h=o+e.helperProportions.width,l=r+e.helperProportions.height,u=i.offset.left,c=i.offset.top,d=u+i.proportions().width,p=c+i.proportions().height;switch(s){case"fit":return o>=u&&d>=h&&r>=c&&p>=l;case"intersect":return o+e.helperProportions.width/2>u&&d>h-e.helperProportions.width/2&&r+e.helperProportions.height/2>c&&p>l-e.helperProportions.height/2;case"pointer":return n=(e.positionAbs||e.position.absolute).left+(e.clickOffset||e.offset.click).left,a=(e.positionAbs||e.position.absolute).top+(e.clickOffset||e.offset.click).top,t(a,c,i.proportions().height)&&t(n,u,i.proportions().width);case"touch":return(r>=c&&p>=r||l>=c&&p>=l||c>r&&l>p)&&(o>=u&&d>=o||h>=u&&d>=h||u>o&&h>d);default:return!1}},e.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(t,i){var s,n,a=e.ui.ddmanager.droppables[t.options.scope]||[],o=i?i.type:null,r=(t.currentItem||t.element).find(":data(ui-droppable)").addBack();e:for(s=0;a.length>s;s++)if(!(a[s].options.disabled||t&&!a[s].accept.call(a[s].element[0],t.currentItem||t.element))){for(n=0;r.length>n;n++)if(r[n]===a[s].element[0]){a[s].proportions().height=0;continue e}a[s].visible="none"!==a[s].element.css("display"),a[s].visible&&("mousedown"===o&&a[s]._activate.call(a[s],i),a[s].offset=a[s].element.offset(),a[s].proportions({width:a[s].element[0].offsetWidth,height:a[s].element[0].offsetHeight}))}},drop:function(t,i){var s=!1;return e.each((e.ui.ddmanager.droppables[t.options.scope]||[]).slice(),function(){this.options&&(!this.options.disabled&&this.visible&&e.ui.intersect(t,this,this.options.tolerance)&&(s=this._drop.call(this,i)||s),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],t.currentItem||t.element)&&(this.isout=!0,this.isover=!1,this._deactivate.call(this,i)))}),s},dragStart:function(t,i){t.element.parentsUntil("body").bind("scroll.droppable",function(){t.options.refreshPositions||e.ui.ddmanager.prepareOffsets(t,i)})},drag:function(t,i){t.options.refreshPositions&&e.ui.ddmanager.prepareOffsets(t,i),e.each(e.ui.ddmanager.droppables[t.options.scope]||[],function(){if(!this.options.disabled&&!this.greedyChild&&this.visible){var s,n,a,o=e.ui.intersect(t,this,this.options.tolerance),r=!o&&this.isover?"isout":o&&!this.isover?"isover":null;r&&(this.options.greedy&&(n=this.options.scope,a=this.element.parents(":data(ui-droppable)").filter(function(){return e.data(this,"ui-droppable").options.scope===n}),a.length&&(s=e.data(a[0],"ui-droppable"),s.greedyChild="isover"===r)),s&&"isover"===r&&(s.isover=!1,s.isout=!0,s._out.call(s,i)),this[r]=!0,this["isout"===r?"isover":"isout"]=!1,this["isover"===r?"_over":"_out"].call(this,i),s&&"isout"===r&&(s.isout=!1,s.isover=!0,s._over.call(s,i)))}})},dragStop:function(t,i){t.element.parentsUntil("body").unbind("scroll.droppable"),t.options.refreshPositions||e.ui.ddmanager.prepareOffsets(t,i)}}})(jQuery);
     1/*!
     2 * jQuery UI Droppable 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/droppable/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./core",
     18            "./widget",
     19            "./mouse",
     20            "./draggable"
     21        ], factory );
     22    } else {
     23
     24        // Browser globals
     25        factory( jQuery );
     26    }
     27}(function( $ ) {
     28
     29$.widget( "ui.droppable", {
     30    version: "1.11.1",
     31    widgetEventPrefix: "drop",
     32    options: {
     33        accept: "*",
     34        activeClass: false,
     35        addClasses: true,
     36        greedy: false,
     37        hoverClass: false,
     38        scope: "default",
     39        tolerance: "intersect",
     40
     41        // callbacks
     42        activate: null,
     43        deactivate: null,
     44        drop: null,
     45        out: null,
     46        over: null
     47    },
     48    _create: function() {
     49
     50        var proportions,
     51            o = this.options,
     52            accept = o.accept;
     53
     54        this.isover = false;
     55        this.isout = true;
     56
     57        this.accept = $.isFunction( accept ) ? accept : function( d ) {
     58            return d.is( accept );
     59        };
     60
     61        this.proportions = function( /* valueToWrite */ ) {
     62            if ( arguments.length ) {
     63                // Store the droppable's proportions
     64                proportions = arguments[ 0 ];
     65            } else {
     66                // Retrieve or derive the droppable's proportions
     67                return proportions ?
     68                    proportions :
     69                    proportions = {
     70                        width: this.element[ 0 ].offsetWidth,
     71                        height: this.element[ 0 ].offsetHeight
     72                    };
     73            }
     74        };
     75
     76        this._addToManager( o.scope );
     77
     78        o.addClasses && this.element.addClass( "ui-droppable" );
     79
     80    },
     81
     82    _addToManager: function( scope ) {
     83        // Add the reference and positions to the manager
     84        $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
     85        $.ui.ddmanager.droppables[ scope ].push( this );
     86    },
     87
     88    _splice: function( drop ) {
     89        var i = 0;
     90        for ( ; i < drop.length; i++ ) {
     91            if ( drop[ i ] === this ) {
     92                drop.splice( i, 1 );
     93            }
     94        }
     95    },
     96
     97    _destroy: function() {
     98        var drop = $.ui.ddmanager.droppables[ this.options.scope ];
     99
     100        this._splice( drop );
     101
     102        this.element.removeClass( "ui-droppable ui-droppable-disabled" );
     103    },
     104
     105    _setOption: function( key, value ) {
     106
     107        if ( key === "accept" ) {
     108            this.accept = $.isFunction( value ) ? value : function( d ) {
     109                return d.is( value );
     110            };
     111        } else if ( key === "scope" ) {
     112            var drop = $.ui.ddmanager.droppables[ this.options.scope ];
     113
     114            this._splice( drop );
     115            this._addToManager( value );
     116        }
     117
     118        this._super( key, value );
     119    },
     120
     121    _activate: function( event ) {
     122        var draggable = $.ui.ddmanager.current;
     123        if ( this.options.activeClass ) {
     124            this.element.addClass( this.options.activeClass );
     125        }
     126        if ( draggable ){
     127            this._trigger( "activate", event, this.ui( draggable ) );
     128        }
     129    },
     130
     131    _deactivate: function( event ) {
     132        var draggable = $.ui.ddmanager.current;
     133        if ( this.options.activeClass ) {
     134            this.element.removeClass( this.options.activeClass );
     135        }
     136        if ( draggable ){
     137            this._trigger( "deactivate", event, this.ui( draggable ) );
     138        }
     139    },
     140
     141    _over: function( event ) {
     142
     143        var draggable = $.ui.ddmanager.current;
     144
     145        // Bail if draggable and droppable are same element
     146        if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
     147            return;
     148        }
     149
     150        if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
     151            if ( this.options.hoverClass ) {
     152                this.element.addClass( this.options.hoverClass );
     153            }
     154            this._trigger( "over", event, this.ui( draggable ) );
     155        }
     156
     157    },
     158
     159    _out: function( event ) {
     160
     161        var draggable = $.ui.ddmanager.current;
     162
     163        // Bail if draggable and droppable are same element
     164        if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
     165            return;
     166        }
     167
     168        if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
     169            if ( this.options.hoverClass ) {
     170                this.element.removeClass( this.options.hoverClass );
     171            }
     172            this._trigger( "out", event, this.ui( draggable ) );
     173        }
     174
     175    },
     176
     177    _drop: function( event, custom ) {
     178
     179        var draggable = custom || $.ui.ddmanager.current,
     180            childrenIntersection = false;
     181
     182        // Bail if draggable and droppable are same element
     183        if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
     184            return false;
     185        }
     186
     187        this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each(function() {
     188            var inst = $( this ).droppable( "instance" );
     189            if (
     190                inst.options.greedy &&
     191                !inst.options.disabled &&
     192                inst.options.scope === draggable.options.scope &&
     193                inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) &&
     194                $.ui.intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance, event )
     195            ) { childrenIntersection = true; return false; }
     196        });
     197        if ( childrenIntersection ) {
     198            return false;
     199        }
     200
     201        if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
     202            if ( this.options.activeClass ) {
     203                this.element.removeClass( this.options.activeClass );
     204            }
     205            if ( this.options.hoverClass ) {
     206                this.element.removeClass( this.options.hoverClass );
     207            }
     208            this._trigger( "drop", event, this.ui( draggable ) );
     209            return this.element;
     210        }
     211
     212        return false;
     213
     214    },
     215
     216    ui: function( c ) {
     217        return {
     218            draggable: ( c.currentItem || c.element ),
     219            helper: c.helper,
     220            position: c.position,
     221            offset: c.positionAbs
     222        };
     223    }
     224
     225});
     226
     227$.ui.intersect = (function() {
     228    function isOverAxis( x, reference, size ) {
     229        return ( x >= reference ) && ( x < ( reference + size ) );
     230    }
     231
     232    return function( draggable, droppable, toleranceMode, event ) {
     233
     234        if ( !droppable.offset ) {
     235            return false;
     236        }
     237
     238        var x1 = ( draggable.positionAbs || draggable.position.absolute ).left,
     239            y1 = ( draggable.positionAbs || draggable.position.absolute ).top,
     240            x2 = x1 + draggable.helperProportions.width,
     241            y2 = y1 + draggable.helperProportions.height,
     242            l = droppable.offset.left,
     243            t = droppable.offset.top,
     244            r = l + droppable.proportions().width,
     245            b = t + droppable.proportions().height;
     246
     247        switch ( toleranceMode ) {
     248        case "fit":
     249            return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
     250        case "intersect":
     251            return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
     252                x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
     253                t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
     254                y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
     255        case "pointer":
     256            return isOverAxis( event.pageY, t, droppable.proportions().height ) && isOverAxis( event.pageX, l, droppable.proportions().width );
     257        case "touch":
     258            return (
     259                ( y1 >= t && y1 <= b ) || // Top edge touching
     260                ( y2 >= t && y2 <= b ) || // Bottom edge touching
     261                ( y1 < t && y2 > b ) // Surrounded vertically
     262            ) && (
     263                ( x1 >= l && x1 <= r ) || // Left edge touching
     264                ( x2 >= l && x2 <= r ) || // Right edge touching
     265                ( x1 < l && x2 > r ) // Surrounded horizontally
     266            );
     267        default:
     268            return false;
     269        }
     270    };
     271})();
     272
     273/*
     274    This manager tracks offsets of draggables and droppables
     275*/
     276$.ui.ddmanager = {
     277    current: null,
     278    droppables: { "default": [] },
     279    prepareOffsets: function( t, event ) {
     280
     281        var i, j,
     282            m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
     283            type = event ? event.type : null, // workaround for #2317
     284            list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
     285
     286        droppablesLoop: for ( i = 0; i < m.length; i++ ) {
     287
     288            // No disabled and non-accepted
     289            if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], ( t.currentItem || t.element ) ) ) ) {
     290                continue;
     291            }
     292
     293            // Filter out elements in the current dragged item
     294            for ( j = 0; j < list.length; j++ ) {
     295                if ( list[ j ] === m[ i ].element[ 0 ] ) {
     296                    m[ i ].proportions().height = 0;
     297                    continue droppablesLoop;
     298                }
     299            }
     300
     301            m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
     302            if ( !m[ i ].visible ) {
     303                continue;
     304            }
     305
     306            // Activate the droppable if used directly from draggables
     307            if ( type === "mousedown" ) {
     308                m[ i ]._activate.call( m[ i ], event );
     309            }
     310
     311            m[ i ].offset = m[ i ].element.offset();
     312            m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
     313
     314        }
     315
     316    },
     317    drop: function( draggable, event ) {
     318
     319        var dropped = false;
     320        // Create a copy of the droppables in case the list changes during the drop (#9116)
     321        $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
     322
     323            if ( !this.options ) {
     324                return;
     325            }
     326            if ( !this.options.disabled && this.visible && $.ui.intersect( draggable, this, this.options.tolerance, event ) ) {
     327                dropped = this._drop.call( this, event ) || dropped;
     328            }
     329
     330            if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
     331                this.isout = true;
     332                this.isover = false;
     333                this._deactivate.call( this, event );
     334            }
     335
     336        });
     337        return dropped;
     338
     339    },
     340    dragStart: function( draggable, event ) {
     341        // Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
     342        draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
     343            if ( !draggable.options.refreshPositions ) {
     344                $.ui.ddmanager.prepareOffsets( draggable, event );
     345            }
     346        });
     347    },
     348    drag: function( draggable, event ) {
     349
     350        // If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
     351        if ( draggable.options.refreshPositions ) {
     352            $.ui.ddmanager.prepareOffsets( draggable, event );
     353        }
     354
     355        // Run through all droppables and check their positions based on specific tolerance options
     356        $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
     357
     358            if ( this.options.disabled || this.greedyChild || !this.visible ) {
     359                return;
     360            }
     361
     362            var parentInstance, scope, parent,
     363                intersects = $.ui.intersect( draggable, this, this.options.tolerance, event ),
     364                c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null );
     365            if ( !c ) {
     366                return;
     367            }
     368
     369            if ( this.options.greedy ) {
     370                // find droppable parents with same scope
     371                scope = this.options.scope;
     372                parent = this.element.parents( ":data(ui-droppable)" ).filter(function() {
     373                    return $( this ).droppable( "instance" ).options.scope === scope;
     374                });
     375
     376                if ( parent.length ) {
     377                    parentInstance = $( parent[ 0 ] ).droppable( "instance" );
     378                    parentInstance.greedyChild = ( c === "isover" );
     379                }
     380            }
     381
     382            // we just moved into a greedy child
     383            if ( parentInstance && c === "isover" ) {
     384                parentInstance.isover = false;
     385                parentInstance.isout = true;
     386                parentInstance._out.call( parentInstance, event );
     387            }
     388
     389            this[ c ] = true;
     390            this[c === "isout" ? "isover" : "isout"] = false;
     391            this[c === "isover" ? "_over" : "_out"].call( this, event );
     392
     393            // we just moved out of a greedy child
     394            if ( parentInstance && c === "isout" ) {
     395                parentInstance.isout = false;
     396                parentInstance.isover = true;
     397                parentInstance._over.call( parentInstance, event );
     398            }
     399        });
     400
     401    },
     402    dragStop: function( draggable, event ) {
     403        draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
     404        // Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
     405        if ( !draggable.options.refreshPositions ) {
     406            $.ui.ddmanager.prepareOffsets( draggable, event );
     407        }
     408    }
     409};
     410
     411return $.ui.droppable;
     412
     413}));
  • trunk/src/wp-includes/js/jquery/ui/effect-blind.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){var e=/up|down|vertical/,i=/up|left|vertical|horizontal/;t.effects.effect.blind=function(s,n){var a,o,r,h=t(this),l=["position","top","bottom","left","right","height","width"],c=t.effects.setMode(h,s.mode||"hide"),u=s.direction||"up",d=e.test(u),p=d?"height":"width",f=d?"top":"left",m=i.test(u),g={},v="show"===c;h.parent().is(".ui-effects-wrapper")?t.effects.save(h.parent(),l):t.effects.save(h,l),h.show(),a=t.effects.createWrapper(h).css({overflow:"hidden"}),o=a[p](),r=parseFloat(a.css(f))||0,g[p]=v?o:0,m||(h.css(d?"bottom":"right",0).css(d?"top":"left","auto").css({position:"absolute"}),g[f]=v?r:o+r),v&&(a.css(p,0),m||a.css(f,r+o)),a.animate(g,{duration:s.duration,easing:s.easing,queue:!1,complete:function(){"hide"===c&&h.hide(),t.effects.restore(h,l),t.effects.removeWrapper(h),n()}})}})(jQuery);
     1/*!
     2 * jQuery UI Effects Blind 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/blind-effect/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./effect"
     18        ], factory );
     19    } else {
     20
     21        // Browser globals
     22        factory( jQuery );
     23    }
     24}(function( $ ) {
     25
     26return $.effects.effect.blind = function( o, done ) {
     27    // Create element
     28    var el = $( this ),
     29        rvertical = /up|down|vertical/,
     30        rpositivemotion = /up|left|vertical|horizontal/,
     31        props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
     32        mode = $.effects.setMode( el, o.mode || "hide" ),
     33        direction = o.direction || "up",
     34        vertical = rvertical.test( direction ),
     35        ref = vertical ? "height" : "width",
     36        ref2 = vertical ? "top" : "left",
     37        motion = rpositivemotion.test( direction ),
     38        animation = {},
     39        show = mode === "show",
     40        wrapper, distance, margin;
     41
     42    // if already wrapped, the wrapper's properties are my property. #6245
     43    if ( el.parent().is( ".ui-effects-wrapper" ) ) {
     44        $.effects.save( el.parent(), props );
     45    } else {
     46        $.effects.save( el, props );
     47    }
     48    el.show();
     49    wrapper = $.effects.createWrapper( el ).css({
     50        overflow: "hidden"
     51    });
     52
     53    distance = wrapper[ ref ]();
     54    margin = parseFloat( wrapper.css( ref2 ) ) || 0;
     55
     56    animation[ ref ] = show ? distance : 0;
     57    if ( !motion ) {
     58        el
     59            .css( vertical ? "bottom" : "right", 0 )
     60            .css( vertical ? "top" : "left", "auto" )
     61            .css({ position: "absolute" });
     62
     63        animation[ ref2 ] = show ? margin : distance + margin;
     64    }
     65
     66    // start at 0 if we are showing
     67    if ( show ) {
     68        wrapper.css( ref, 0 );
     69        if ( !motion ) {
     70            wrapper.css( ref2, margin + distance );
     71        }
     72    }
     73
     74    // Animate
     75    wrapper.animate( animation, {
     76        duration: o.duration,
     77        easing: o.easing,
     78        queue: false,
     79        complete: function() {
     80            if ( mode === "hide" ) {
     81                el.hide();
     82            }
     83            $.effects.restore( el, props );
     84            $.effects.removeWrapper( el );
     85            done();
     86        }
     87    });
     88};
     89
     90}));
  • trunk/src/wp-includes/js/jquery/ui/effect-bounce.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){t.effects.effect.bounce=function(e,i){var s,n,a,o=t(this),r=["position","top","bottom","left","right","height","width"],h=t.effects.setMode(o,e.mode||"effect"),l="hide"===h,c="show"===h,u=e.direction||"up",d=e.distance,p=e.times||5,f=2*p+(c||l?1:0),m=e.duration/f,g=e.easing,v="up"===u||"down"===u?"top":"left",_="up"===u||"left"===u,b=o.queue(),y=b.length;for((c||l)&&r.push("opacity"),t.effects.save(o,r),o.show(),t.effects.createWrapper(o),d||(d=o["top"===v?"outerHeight":"outerWidth"]()/3),c&&(a={opacity:1},a[v]=0,o.css("opacity",0).css(v,_?2*-d:2*d).animate(a,m,g)),l&&(d/=Math.pow(2,p-1)),a={},a[v]=0,s=0;p>s;s++)n={},n[v]=(_?"-=":"+=")+d,o.animate(n,m,g).animate(a,m,g),d=l?2*d:d/2;l&&(n={opacity:0},n[v]=(_?"-=":"+=")+d,o.animate(n,m,g)),o.queue(function(){l&&o.hide(),t.effects.restore(o,r),t.effects.removeWrapper(o),i()}),y>1&&b.splice.apply(b,[1,0].concat(b.splice(y,f+1))),o.dequeue()}})(jQuery);
     1/*!
     2 * jQuery UI Effects Bounce 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/bounce-effect/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./effect"
     18        ], factory );
     19    } else {
     20
     21        // Browser globals
     22        factory( jQuery );
     23    }
     24}(function( $ ) {
     25
     26return $.effects.effect.bounce = function( o, done ) {
     27    var el = $( this ),
     28        props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
     29
     30        // defaults:
     31        mode = $.effects.setMode( el, o.mode || "effect" ),
     32        hide = mode === "hide",
     33        show = mode === "show",
     34        direction = o.direction || "up",
     35        distance = o.distance,
     36        times = o.times || 5,
     37
     38        // number of internal animations
     39        anims = times * 2 + ( show || hide ? 1 : 0 ),
     40        speed = o.duration / anims,
     41        easing = o.easing,
     42
     43        // utility:
     44        ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
     45        motion = ( direction === "up" || direction === "left" ),
     46        i,
     47        upAnim,
     48        downAnim,
     49
     50        // we will need to re-assemble the queue to stack our animations in place
     51        queue = el.queue(),
     52        queuelen = queue.length;
     53
     54    // Avoid touching opacity to prevent clearType and PNG issues in IE
     55    if ( show || hide ) {
     56        props.push( "opacity" );
     57    }
     58
     59    $.effects.save( el, props );
     60    el.show();
     61    $.effects.createWrapper( el ); // Create Wrapper
     62
     63    // default distance for the BIGGEST bounce is the outer Distance / 3
     64    if ( !distance ) {
     65        distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
     66    }
     67
     68    if ( show ) {
     69        downAnim = { opacity: 1 };
     70        downAnim[ ref ] = 0;
     71
     72        // if we are showing, force opacity 0 and set the initial position
     73        // then do the "first" animation
     74        el.css( "opacity", 0 )
     75            .css( ref, motion ? -distance * 2 : distance * 2 )
     76            .animate( downAnim, speed, easing );
     77    }
     78
     79    // start at the smallest distance if we are hiding
     80    if ( hide ) {
     81        distance = distance / Math.pow( 2, times - 1 );
     82    }
     83
     84    downAnim = {};
     85    downAnim[ ref ] = 0;
     86    // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
     87    for ( i = 0; i < times; i++ ) {
     88        upAnim = {};
     89        upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
     90
     91        el.animate( upAnim, speed, easing )
     92            .animate( downAnim, speed, easing );
     93
     94        distance = hide ? distance * 2 : distance / 2;
     95    }
     96
     97    // Last Bounce when Hiding
     98    if ( hide ) {
     99        upAnim = { opacity: 0 };
     100        upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
     101
     102        el.animate( upAnim, speed, easing );
     103    }
     104
     105    el.queue(function() {
     106        if ( hide ) {
     107            el.hide();
     108        }
     109        $.effects.restore( el, props );
     110        $.effects.removeWrapper( el );
     111        done();
     112    });
     113
     114    // inject all the animations we just queued to be first in line (after "inprogress")
     115    if ( queuelen > 1) {
     116        queue.splice.apply( queue,
     117            [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
     118    }
     119    el.dequeue();
     120
     121};
     122
     123}));
  • trunk/src/wp-includes/js/jquery/ui/effect-clip.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){t.effects.effect.clip=function(e,i){var s,n,a,o=t(this),r=["position","top","bottom","left","right","height","width"],h=t.effects.setMode(o,e.mode||"hide"),l="show"===h,c=e.direction||"vertical",u="vertical"===c,d=u?"height":"width",p=u?"top":"left",f={};t.effects.save(o,r),o.show(),s=t.effects.createWrapper(o).css({overflow:"hidden"}),n="IMG"===o[0].tagName?s:o,a=n[d](),l&&(n.css(d,0),n.css(p,a/2)),f[d]=l?a:0,f[p]=l?0:a/2,n.animate(f,{queue:!1,duration:e.duration,easing:e.easing,complete:function(){l||o.hide(),t.effects.restore(o,r),t.effects.removeWrapper(o),i()}})}})(jQuery);
     1/*!
     2 * jQuery UI Effects Clip 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/clip-effect/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./effect"
     18        ], factory );
     19    } else {
     20
     21        // Browser globals
     22        factory( jQuery );
     23    }
     24}(function( $ ) {
     25
     26return $.effects.effect.clip = function( o, done ) {
     27    // Create element
     28    var el = $( this ),
     29        props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
     30        mode = $.effects.setMode( el, o.mode || "hide" ),
     31        show = mode === "show",
     32        direction = o.direction || "vertical",
     33        vert = direction === "vertical",
     34        size = vert ? "height" : "width",
     35        position = vert ? "top" : "left",
     36        animation = {},
     37        wrapper, animate, distance;
     38
     39    // Save & Show
     40    $.effects.save( el, props );
     41    el.show();
     42
     43    // Create Wrapper
     44    wrapper = $.effects.createWrapper( el ).css({
     45        overflow: "hidden"
     46    });
     47    animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
     48    distance = animate[ size ]();
     49
     50    // Shift
     51    if ( show ) {
     52        animate.css( size, 0 );
     53        animate.css( position, distance / 2 );
     54    }
     55
     56    // Create Animation Object:
     57    animation[ size ] = show ? distance : 0;
     58    animation[ position ] = show ? 0 : distance / 2;
     59
     60    // Animate
     61    animate.animate( animation, {
     62        queue: false,
     63        duration: o.duration,
     64        easing: o.easing,
     65        complete: function() {
     66            if ( !show ) {
     67                el.hide();
     68            }
     69            $.effects.restore( el, props );
     70            $.effects.removeWrapper( el );
     71            done();
     72        }
     73    });
     74
     75};
     76
     77}));
  • trunk/src/wp-includes/js/jquery/ui/effect-drop.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){t.effects.effect.drop=function(e,i){var s,n=t(this),a=["position","top","bottom","left","right","opacity","height","width"],o=t.effects.setMode(n,e.mode||"hide"),r="show"===o,h=e.direction||"left",l="up"===h||"down"===h?"top":"left",c="up"===h||"left"===h?"pos":"neg",u={opacity:r?1:0};t.effects.save(n,a),n.show(),t.effects.createWrapper(n),s=e.distance||n["top"===l?"outerHeight":"outerWidth"](!0)/2,r&&n.css("opacity",0).css(l,"pos"===c?-s:s),u[l]=(r?"pos"===c?"+=":"-=":"pos"===c?"-=":"+=")+s,n.animate(u,{queue:!1,duration:e.duration,easing:e.easing,complete:function(){"hide"===o&&n.hide(),t.effects.restore(n,a),t.effects.removeWrapper(n),i()}})}})(jQuery);
     1/*!
     2 * jQuery UI Effects Drop 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/drop-effect/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./effect"
     18        ], factory );
     19    } else {
     20
     21        // Browser globals
     22        factory( jQuery );
     23    }
     24}(function( $ ) {
     25
     26return $.effects.effect.drop = function( o, done ) {
     27
     28    var el = $( this ),
     29        props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
     30        mode = $.effects.setMode( el, o.mode || "hide" ),
     31        show = mode === "show",
     32        direction = o.direction || "left",
     33        ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
     34        motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
     35        animation = {
     36            opacity: show ? 1 : 0
     37        },
     38        distance;
     39
     40    // Adjust
     41    $.effects.save( el, props );
     42    el.show();
     43    $.effects.createWrapper( el );
     44
     45    distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
     46
     47    if ( show ) {
     48        el
     49            .css( "opacity", 0 )
     50            .css( ref, motion === "pos" ? -distance : distance );
     51    }
     52
     53    // Animation
     54    animation[ ref ] = ( show ?
     55        ( motion === "pos" ? "+=" : "-=" ) :
     56        ( motion === "pos" ? "-=" : "+=" ) ) +
     57        distance;
     58
     59    // Animate
     60    el.animate( animation, {
     61        queue: false,
     62        duration: o.duration,
     63        easing: o.easing,
     64        complete: function() {
     65            if ( mode === "hide" ) {
     66                el.hide();
     67            }
     68            $.effects.restore( el, props );
     69            $.effects.removeWrapper( el );
     70            done();
     71        }
     72    });
     73};
     74
     75}));
  • trunk/src/wp-includes/js/jquery/ui/effect-explode.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){t.effects.effect.explode=function(e,i){function s(){b.push(this),b.length===u*d&&n()}function n(){p.css({visibility:"visible"}),t(b).remove(),m||p.hide(),i()}var a,o,r,h,l,c,u=e.pieces?Math.round(Math.sqrt(e.pieces)):3,d=u,p=t(this),f=t.effects.setMode(p,e.mode||"hide"),m="show"===f,g=p.show().css("visibility","hidden").offset(),v=Math.ceil(p.outerWidth()/d),_=Math.ceil(p.outerHeight()/u),b=[];for(a=0;u>a;a++)for(h=g.top+a*_,c=a-(u-1)/2,o=0;d>o;o++)r=g.left+o*v,l=o-(d-1)/2,p.clone().appendTo("body").wrap("<div></div>").css({position:"absolute",visibility:"visible",left:-o*v,top:-a*_}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:v,height:_,left:r+(m?l*v:0),top:h+(m?c*_:0),opacity:m?0:1}).animate({left:r+(m?0:l*v),top:h+(m?0:c*_),opacity:m?1:0},e.duration||500,e.easing,s)}})(jQuery);
     1/*!
     2 * jQuery UI Effects Explode 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/explode-effect/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./effect"
     18        ], factory );
     19    } else {
     20
     21        // Browser globals
     22        factory( jQuery );
     23    }
     24}(function( $ ) {
     25
     26return $.effects.effect.explode = function( o, done ) {
     27
     28    var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
     29        cells = rows,
     30        el = $( this ),
     31        mode = $.effects.setMode( el, o.mode || "hide" ),
     32        show = mode === "show",
     33
     34        // show and then visibility:hidden the element before calculating offset
     35        offset = el.show().css( "visibility", "hidden" ).offset(),
     36
     37        // width and height of a piece
     38        width = Math.ceil( el.outerWidth() / cells ),
     39        height = Math.ceil( el.outerHeight() / rows ),
     40        pieces = [],
     41
     42        // loop
     43        i, j, left, top, mx, my;
     44
     45    // children animate complete:
     46    function childComplete() {
     47        pieces.push( this );
     48        if ( pieces.length === rows * cells ) {
     49            animComplete();
     50        }
     51    }
     52
     53    // clone the element for each row and cell.
     54    for ( i = 0; i < rows ; i++ ) { // ===>
     55        top = offset.top + i * height;
     56        my = i - ( rows - 1 ) / 2 ;
     57
     58        for ( j = 0; j < cells ; j++ ) { // |||
     59            left = offset.left + j * width;
     60            mx = j - ( cells - 1 ) / 2 ;
     61
     62            // Create a clone of the now hidden main element that will be absolute positioned
     63            // within a wrapper div off the -left and -top equal to size of our pieces
     64            el
     65                .clone()
     66                .appendTo( "body" )
     67                .wrap( "<div></div>" )
     68                .css({
     69                    position: "absolute",
     70                    visibility: "visible",
     71                    left: -j * width,
     72                    top: -i * height
     73                })
     74
     75            // select the wrapper - make it overflow: hidden and absolute positioned based on
     76            // where the original was located +left and +top equal to the size of pieces
     77                .parent()
     78                .addClass( "ui-effects-explode" )
     79                .css({
     80                    position: "absolute",
     81                    overflow: "hidden",
     82                    width: width,
     83                    height: height,
     84                    left: left + ( show ? mx * width : 0 ),
     85                    top: top + ( show ? my * height : 0 ),
     86                    opacity: show ? 0 : 1
     87                }).animate({
     88                    left: left + ( show ? 0 : mx * width ),
     89                    top: top + ( show ? 0 : my * height ),
     90                    opacity: show ? 1 : 0
     91                }, o.duration || 500, o.easing, childComplete );
     92        }
     93    }
     94
     95    function animComplete() {
     96        el.css({
     97            visibility: "visible"
     98        });
     99        $( pieces ).remove();
     100        if ( !show ) {
     101            el.hide();
     102        }
     103        done();
     104    }
     105};
     106
     107}));
  • trunk/src/wp-includes/js/jquery/ui/effect-fade.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){t.effects.effect.fade=function(e,i){var s=t(this),n=t.effects.setMode(s,e.mode||"toggle");s.animate({opacity:n},{queue:!1,duration:e.duration,easing:e.easing,complete:i})}})(jQuery);
     1/*!
     2 * jQuery UI Effects Fade 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/fade-effect/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./effect"
     18        ], factory );
     19    } else {
     20
     21        // Browser globals
     22        factory( jQuery );
     23    }
     24}(function( $ ) {
     25
     26return $.effects.effect.fade = function( o, done ) {
     27    var el = $( this ),
     28        mode = $.effects.setMode( el, o.mode || "toggle" );
     29
     30    el.animate({
     31        opacity: mode
     32    }, {
     33        queue: false,
     34        duration: o.duration,
     35        easing: o.easing,
     36        complete: done
     37    });
     38};
     39
     40}));
  • trunk/src/wp-includes/js/jquery/ui/effect-fold.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){t.effects.effect.fold=function(e,i){var s,n,a=t(this),o=["position","top","bottom","left","right","height","width"],r=t.effects.setMode(a,e.mode||"hide"),h="show"===r,l="hide"===r,c=e.size||15,u=/([0-9]+)%/.exec(c),d=!!e.horizFirst,p=h!==d,f=p?["width","height"]:["height","width"],m=e.duration/2,g={},v={};t.effects.save(a,o),a.show(),s=t.effects.createWrapper(a).css({overflow:"hidden"}),n=p?[s.width(),s.height()]:[s.height(),s.width()],u&&(c=parseInt(u[1],10)/100*n[l?0:1]),h&&s.css(d?{height:0,width:c}:{height:c,width:0}),g[f[0]]=h?n[0]:c,v[f[1]]=h?n[1]:0,s.animate(g,m,e.easing).animate(v,m,e.easing,function(){l&&a.hide(),t.effects.restore(a,o),t.effects.removeWrapper(a),i()})}})(jQuery);
     1/*!
     2 * jQuery UI Effects Fold 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/fold-effect/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./effect"
     18        ], factory );
     19    } else {
     20
     21        // Browser globals
     22        factory( jQuery );
     23    }
     24}(function( $ ) {
     25
     26return $.effects.effect.fold = function( o, done ) {
     27
     28    // Create element
     29    var el = $( this ),
     30        props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
     31        mode = $.effects.setMode( el, o.mode || "hide" ),
     32        show = mode === "show",
     33        hide = mode === "hide",
     34        size = o.size || 15,
     35        percent = /([0-9]+)%/.exec( size ),
     36        horizFirst = !!o.horizFirst,
     37        widthFirst = show !== horizFirst,
     38        ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
     39        duration = o.duration / 2,
     40        wrapper, distance,
     41        animation1 = {},
     42        animation2 = {};
     43
     44    $.effects.save( el, props );
     45    el.show();
     46
     47    // Create Wrapper
     48    wrapper = $.effects.createWrapper( el ).css({
     49        overflow: "hidden"
     50    });
     51    distance = widthFirst ?
     52        [ wrapper.width(), wrapper.height() ] :
     53        [ wrapper.height(), wrapper.width() ];
     54
     55    if ( percent ) {
     56        size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
     57    }
     58    if ( show ) {
     59        wrapper.css( horizFirst ? {
     60            height: 0,
     61            width: size
     62        } : {
     63            height: size,
     64            width: 0
     65        });
     66    }
     67
     68    // Animation
     69    animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
     70    animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
     71
     72    // Animate
     73    wrapper
     74        .animate( animation1, duration, o.easing )
     75        .animate( animation2, duration, o.easing, function() {
     76            if ( hide ) {
     77                el.hide();
     78            }
     79            $.effects.restore( el, props );
     80            $.effects.removeWrapper( el );
     81            done();
     82        });
     83
     84};
     85
     86}));
  • trunk/src/wp-includes/js/jquery/ui/effect-highlight.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){t.effects.effect.highlight=function(e,i){var s=t(this),n=["backgroundImage","backgroundColor","opacity"],a=t.effects.setMode(s,e.mode||"show"),o={backgroundColor:s.css("backgroundColor")};"hide"===a&&(o.opacity=0),t.effects.save(s,n),s.show().css({backgroundImage:"none",backgroundColor:e.color||"#ffff99"}).animate(o,{queue:!1,duration:e.duration,easing:e.easing,complete:function(){"hide"===a&&s.hide(),t.effects.restore(s,n),i()}})}})(jQuery);
     1/*!
     2 * jQuery UI Effects Highlight 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/highlight-effect/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./effect"
     18        ], factory );
     19    } else {
     20
     21        // Browser globals
     22        factory( jQuery );
     23    }
     24}(function( $ ) {
     25
     26return $.effects.effect.highlight = function( o, done ) {
     27    var elem = $( this ),
     28        props = [ "backgroundImage", "backgroundColor", "opacity" ],
     29        mode = $.effects.setMode( elem, o.mode || "show" ),
     30        animation = {
     31            backgroundColor: elem.css( "backgroundColor" )
     32        };
     33
     34    if (mode === "hide") {
     35        animation.opacity = 0;
     36    }
     37
     38    $.effects.save( elem, props );
     39
     40    elem
     41        .show()
     42        .css({
     43            backgroundImage: "none",
     44            backgroundColor: o.color || "#ffff99"
     45        })
     46        .animate( animation, {
     47            queue: false,
     48            duration: o.duration,
     49            easing: o.easing,
     50            complete: function() {
     51                if ( mode === "hide" ) {
     52                    elem.hide();
     53                }
     54                $.effects.restore( elem, props );
     55                done();
     56            }
     57        });
     58};
     59
     60}));
  • trunk/src/wp-includes/js/jquery/ui/effect-pulsate.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){t.effects.effect.pulsate=function(e,i){var s,n=t(this),a=t.effects.setMode(n,e.mode||"show"),o="show"===a,r="hide"===a,h=o||"hide"===a,l=2*(e.times||5)+(h?1:0),c=e.duration/l,u=0,d=n.queue(),p=d.length;for((o||!n.is(":visible"))&&(n.css("opacity",0).show(),u=1),s=1;l>s;s++)n.animate({opacity:u},c,e.easing),u=1-u;n.animate({opacity:u},c,e.easing),n.queue(function(){r&&n.hide(),i()}),p>1&&d.splice.apply(d,[1,0].concat(d.splice(p,l+1))),n.dequeue()}})(jQuery);
     1/*!
     2 * jQuery UI Effects Pulsate 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/pulsate-effect/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./effect"
     18        ], factory );
     19    } else {
     20
     21        // Browser globals
     22        factory( jQuery );
     23    }
     24}(function( $ ) {
     25
     26return $.effects.effect.pulsate = function( o, done ) {
     27    var elem = $( this ),
     28        mode = $.effects.setMode( elem, o.mode || "show" ),
     29        show = mode === "show",
     30        hide = mode === "hide",
     31        showhide = ( show || mode === "hide" ),
     32
     33        // showing or hiding leaves of the "last" animation
     34        anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
     35        duration = o.duration / anims,
     36        animateTo = 0,
     37        queue = elem.queue(),
     38        queuelen = queue.length,
     39        i;
     40
     41    if ( show || !elem.is(":visible")) {
     42        elem.css( "opacity", 0 ).show();
     43        animateTo = 1;
     44    }
     45
     46    // anims - 1 opacity "toggles"
     47    for ( i = 1; i < anims; i++ ) {
     48        elem.animate({
     49            opacity: animateTo
     50        }, duration, o.easing );
     51        animateTo = 1 - animateTo;
     52    }
     53
     54    elem.animate({
     55        opacity: animateTo
     56    }, duration, o.easing);
     57
     58    elem.queue(function() {
     59        if ( hide ) {
     60            elem.hide();
     61        }
     62        done();
     63    });
     64
     65    // We just queued up "anims" animations, we need to put them next in the queue
     66    if ( queuelen > 1 ) {
     67        queue.splice.apply( queue,
     68            [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
     69    }
     70    elem.dequeue();
     71};
     72
     73}));
  • trunk/src/wp-includes/js/jquery/ui/effect-scale.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){t.effects.effect.puff=function(e,i){var s=t(this),n=t.effects.setMode(s,e.mode||"hide"),a="hide"===n,o=parseInt(e.percent,10)||150,r=o/100,h={height:s.height(),width:s.width(),outerHeight:s.outerHeight(),outerWidth:s.outerWidth()};t.extend(e,{effect:"scale",queue:!1,fade:!0,mode:n,complete:i,percent:a?o:100,from:a?h:{height:h.height*r,width:h.width*r,outerHeight:h.outerHeight*r,outerWidth:h.outerWidth*r}}),s.effect(e)},t.effects.effect.scale=function(e,i){var s=t(this),n=t.extend(!0,{},e),a=t.effects.setMode(s,e.mode||"effect"),o=parseInt(e.percent,10)||(0===parseInt(e.percent,10)?0:"hide"===a?0:100),r=e.direction||"both",h=e.origin,l={height:s.height(),width:s.width(),outerHeight:s.outerHeight(),outerWidth:s.outerWidth()},c={y:"horizontal"!==r?o/100:1,x:"vertical"!==r?o/100:1};n.effect="size",n.queue=!1,n.complete=i,"effect"!==a&&(n.origin=h||["middle","center"],n.restore=!0),n.from=e.from||("show"===a?{height:0,width:0,outerHeight:0,outerWidth:0}:l),n.to={height:l.height*c.y,width:l.width*c.x,outerHeight:l.outerHeight*c.y,outerWidth:l.outerWidth*c.x},n.fade&&("show"===a&&(n.from.opacity=0,n.to.opacity=1),"hide"===a&&(n.from.opacity=1,n.to.opacity=0)),s.effect(n)},t.effects.effect.size=function(e,i){var s,n,a,o=t(this),r=["position","top","bottom","left","right","width","height","overflow","opacity"],h=["position","top","bottom","left","right","overflow","opacity"],l=["width","height","overflow"],c=["fontSize"],u=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"],d=["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"],p=t.effects.setMode(o,e.mode||"effect"),f=e.restore||"effect"!==p,m=e.scale||"both",g=e.origin||["middle","center"],v=o.css("position"),_=f?r:h,b={height:0,width:0,outerHeight:0,outerWidth:0};"show"===p&&o.show(),s={height:o.height(),width:o.width(),outerHeight:o.outerHeight(),outerWidth:o.outerWidth()},"toggle"===e.mode&&"show"===p?(o.from=e.to||b,o.to=e.from||s):(o.from=e.from||("show"===p?b:s),o.to=e.to||("hide"===p?b:s)),a={from:{y:o.from.height/s.height,x:o.from.width/s.width},to:{y:o.to.height/s.height,x:o.to.width/s.width}},("box"===m||"both"===m)&&(a.from.y!==a.to.y&&(_=_.concat(u),o.from=t.effects.setTransition(o,u,a.from.y,o.from),o.to=t.effects.setTransition(o,u,a.to.y,o.to)),a.from.x!==a.to.x&&(_=_.concat(d),o.from=t.effects.setTransition(o,d,a.from.x,o.from),o.to=t.effects.setTransition(o,d,a.to.x,o.to))),("content"===m||"both"===m)&&a.from.y!==a.to.y&&(_=_.concat(c).concat(l),o.from=t.effects.setTransition(o,c,a.from.y,o.from),o.to=t.effects.setTransition(o,c,a.to.y,o.to)),t.effects.save(o,_),o.show(),t.effects.createWrapper(o),o.css("overflow","hidden").css(o.from),g&&(n=t.effects.getBaseline(g,s),o.from.top=(s.outerHeight-o.outerHeight())*n.y,o.from.left=(s.outerWidth-o.outerWidth())*n.x,o.to.top=(s.outerHeight-o.to.outerHeight)*n.y,o.to.left=(s.outerWidth-o.to.outerWidth)*n.x),o.css(o.from),("content"===m||"both"===m)&&(u=u.concat(["marginTop","marginBottom"]).concat(c),d=d.concat(["marginLeft","marginRight"]),l=r.concat(u).concat(d),o.find("*[width]").each(function(){var i=t(this),s={height:i.height(),width:i.width(),outerHeight:i.outerHeight(),outerWidth:i.outerWidth()};f&&t.effects.save(i,l),i.from={height:s.height*a.from.y,width:s.width*a.from.x,outerHeight:s.outerHeight*a.from.y,outerWidth:s.outerWidth*a.from.x},i.to={height:s.height*a.to.y,width:s.width*a.to.x,outerHeight:s.height*a.to.y,outerWidth:s.width*a.to.x},a.from.y!==a.to.y&&(i.from=t.effects.setTransition(i,u,a.from.y,i.from),i.to=t.effects.setTransition(i,u,a.to.y,i.to)),a.from.x!==a.to.x&&(i.from=t.effects.setTransition(i,d,a.from.x,i.from),i.to=t.effects.setTransition(i,d,a.to.x,i.to)),i.css(i.from),i.animate(i.to,e.duration,e.easing,function(){f&&t.effects.restore(i,l)})})),o.animate(o.to,{queue:!1,duration:e.duration,easing:e.easing,complete:function(){0===o.to.opacity&&o.css("opacity",o.from.opacity),"hide"===p&&o.hide(),t.effects.restore(o,_),f||("static"===v?o.css({position:"relative",top:o.to.top,left:o.to.left}):t.each(["top","left"],function(t,e){o.css(e,function(e,i){var s=parseInt(i,10),n=t?o.to.left:o.to.top;return"auto"===i?n+"px":s+n+"px"})})),t.effects.removeWrapper(o),i()}})}})(jQuery);
     1/*!
     2 * jQuery UI Effects Scale 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/scale-effect/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./effect",
     18            "./effect-size"
     19        ], factory );
     20    } else {
     21
     22        // Browser globals
     23        factory( jQuery );
     24    }
     25}(function( $ ) {
     26
     27return $.effects.effect.scale = function( o, done ) {
     28
     29    // Create element
     30    var el = $( this ),
     31        options = $.extend( true, {}, o ),
     32        mode = $.effects.setMode( el, o.mode || "effect" ),
     33        percent = parseInt( o.percent, 10 ) ||
     34            ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
     35        direction = o.direction || "both",
     36        origin = o.origin,
     37        original = {
     38            height: el.height(),
     39            width: el.width(),
     40            outerHeight: el.outerHeight(),
     41            outerWidth: el.outerWidth()
     42        },
     43        factor = {
     44            y: direction !== "horizontal" ? (percent / 100) : 1,
     45            x: direction !== "vertical" ? (percent / 100) : 1
     46        };
     47
     48    // We are going to pass this effect to the size effect:
     49    options.effect = "size";
     50    options.queue = false;
     51    options.complete = done;
     52
     53    // Set default origin and restore for show/hide
     54    if ( mode !== "effect" ) {
     55        options.origin = origin || [ "middle", "center" ];
     56        options.restore = true;
     57    }
     58
     59    options.from = o.from || ( mode === "show" ? {
     60        height: 0,
     61        width: 0,
     62        outerHeight: 0,
     63        outerWidth: 0
     64    } : original );
     65    options.to = {
     66        height: original.height * factor.y,
     67        width: original.width * factor.x,
     68        outerHeight: original.outerHeight * factor.y,
     69        outerWidth: original.outerWidth * factor.x
     70    };
     71
     72    // Fade option to support puff
     73    if ( options.fade ) {
     74        if ( mode === "show" ) {
     75            options.from.opacity = 0;
     76            options.to.opacity = 1;
     77        }
     78        if ( mode === "hide" ) {
     79            options.from.opacity = 1;
     80            options.to.opacity = 0;
     81        }
     82    }
     83
     84    // Animate
     85    el.effect( options );
     86
     87};
     88
     89}));
  • trunk/src/wp-includes/js/jquery/ui/effect-shake.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){t.effects.effect.shake=function(e,i){var s,n=t(this),a=["position","top","bottom","left","right","height","width"],o=t.effects.setMode(n,e.mode||"effect"),r=e.direction||"left",h=e.distance||20,l=e.times||3,c=2*l+1,u=Math.round(e.duration/c),d="up"===r||"down"===r?"top":"left",p="up"===r||"left"===r,f={},m={},g={},v=n.queue(),_=v.length;for(t.effects.save(n,a),n.show(),t.effects.createWrapper(n),f[d]=(p?"-=":"+=")+h,m[d]=(p?"+=":"-=")+2*h,g[d]=(p?"-=":"+=")+2*h,n.animate(f,u,e.easing),s=1;l>s;s++)n.animate(m,u,e.easing).animate(g,u,e.easing);n.animate(m,u,e.easing).animate(f,u/2,e.easing).queue(function(){"hide"===o&&n.hide(),t.effects.restore(n,a),t.effects.removeWrapper(n),i()}),_>1&&v.splice.apply(v,[1,0].concat(v.splice(_,c+1))),n.dequeue()}})(jQuery);
     1/*!
     2 * jQuery UI Effects Shake 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/shake-effect/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./effect"
     18        ], factory );
     19    } else {
     20
     21        // Browser globals
     22        factory( jQuery );
     23    }
     24}(function( $ ) {
     25
     26return $.effects.effect.shake = function( o, done ) {
     27
     28    var el = $( this ),
     29        props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
     30        mode = $.effects.setMode( el, o.mode || "effect" ),
     31        direction = o.direction || "left",
     32        distance = o.distance || 20,
     33        times = o.times || 3,
     34        anims = times * 2 + 1,
     35        speed = Math.round( o.duration / anims ),
     36        ref = (direction === "up" || direction === "down") ? "top" : "left",
     37        positiveMotion = (direction === "up" || direction === "left"),
     38        animation = {},
     39        animation1 = {},
     40        animation2 = {},
     41        i,
     42
     43        // we will need to re-assemble the queue to stack our animations in place
     44        queue = el.queue(),
     45        queuelen = queue.length;
     46
     47    $.effects.save( el, props );
     48    el.show();
     49    $.effects.createWrapper( el );
     50
     51    // Animation
     52    animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
     53    animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
     54    animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
     55
     56    // Animate
     57    el.animate( animation, speed, o.easing );
     58
     59    // Shakes
     60    for ( i = 1; i < times; i++ ) {
     61        el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
     62    }
     63    el
     64        .animate( animation1, speed, o.easing )
     65        .animate( animation, speed / 2, o.easing )
     66        .queue(function() {
     67            if ( mode === "hide" ) {
     68                el.hide();
     69            }
     70            $.effects.restore( el, props );
     71            $.effects.removeWrapper( el );
     72            done();
     73        });
     74
     75    // inject all the animations we just queued to be first in line (after "inprogress")
     76    if ( queuelen > 1) {
     77        queue.splice.apply( queue,
     78            [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
     79    }
     80    el.dequeue();
     81
     82};
     83
     84}));
  • trunk/src/wp-includes/js/jquery/ui/effect-slide.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){t.effects.effect.slide=function(e,i){var s,n=t(this),a=["position","top","bottom","left","right","width","height"],o=t.effects.setMode(n,e.mode||"show"),r="show"===o,h=e.direction||"left",l="up"===h||"down"===h?"top":"left",c="up"===h||"left"===h,u={};t.effects.save(n,a),n.show(),s=e.distance||n["top"===l?"outerHeight":"outerWidth"](!0),t.effects.createWrapper(n).css({overflow:"hidden"}),r&&n.css(l,c?isNaN(s)?"-"+s:-s:s),u[l]=(r?c?"+=":"-=":c?"-=":"+=")+s,n.animate(u,{queue:!1,duration:e.duration,easing:e.easing,complete:function(){"hide"===o&&n.hide(),t.effects.restore(n,a),t.effects.removeWrapper(n),i()}})}})(jQuery);
     1/*!
     2 * jQuery UI Effects Slide 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/slide-effect/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./effect"
     18        ], factory );
     19    } else {
     20
     21        // Browser globals
     22        factory( jQuery );
     23    }
     24}(function( $ ) {
     25
     26return $.effects.effect.slide = function( o, done ) {
     27
     28    // Create element
     29    var el = $( this ),
     30        props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
     31        mode = $.effects.setMode( el, o.mode || "show" ),
     32        show = mode === "show",
     33        direction = o.direction || "left",
     34        ref = (direction === "up" || direction === "down") ? "top" : "left",
     35        positiveMotion = (direction === "up" || direction === "left"),
     36        distance,
     37        animation = {};
     38
     39    // Adjust
     40    $.effects.save( el, props );
     41    el.show();
     42    distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
     43
     44    $.effects.createWrapper( el ).css({
     45        overflow: "hidden"
     46    });
     47
     48    if ( show ) {
     49        el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
     50    }
     51
     52    // Animation
     53    animation[ ref ] = ( show ?
     54        ( positiveMotion ? "+=" : "-=") :
     55        ( positiveMotion ? "-=" : "+=")) +
     56        distance;
     57
     58    // Animate
     59    el.animate( animation, {
     60        queue: false,
     61        duration: o.duration,
     62        easing: o.easing,
     63        complete: function() {
     64            if ( mode === "hide" ) {
     65                el.hide();
     66            }
     67            $.effects.restore( el, props );
     68            $.effects.removeWrapper( el );
     69            done();
     70        }
     71    });
     72};
     73
     74}));
  • trunk/src/wp-includes/js/jquery/ui/effect-transfer.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){t.effects.effect.transfer=function(e,i){var s=t(this),n=t(e.to),a="fixed"===n.css("position"),o=t("body"),r=a?o.scrollTop():0,h=a?o.scrollLeft():0,l=n.offset(),c={top:l.top-r,left:l.left-h,height:n.innerHeight(),width:n.innerWidth()},u=s.offset(),d=t("<div class='ui-effects-transfer'></div>").appendTo(document.body).addClass(e.className).css({top:u.top-r,left:u.left-h,height:s.innerHeight(),width:s.innerWidth(),position:a?"fixed":"absolute"}).animate(c,e.duration,e.easing,function(){d.remove(),i()})}})(jQuery);
     1/*!
     2 * jQuery UI Effects Transfer 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/transfer-effect/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./effect"
     18        ], factory );
     19    } else {
     20
     21        // Browser globals
     22        factory( jQuery );
     23    }
     24}(function( $ ) {
     25
     26return $.effects.effect.transfer = function( o, done ) {
     27    var elem = $( this ),
     28        target = $( o.to ),
     29        targetFixed = target.css( "position" ) === "fixed",
     30        body = $("body"),
     31        fixTop = targetFixed ? body.scrollTop() : 0,
     32        fixLeft = targetFixed ? body.scrollLeft() : 0,
     33        endPosition = target.offset(),
     34        animation = {
     35            top: endPosition.top - fixTop,
     36            left: endPosition.left - fixLeft,
     37            height: target.innerHeight(),
     38            width: target.innerWidth()
     39        },
     40        startPosition = elem.offset(),
     41        transfer = $( "<div class='ui-effects-transfer'></div>" )
     42            .appendTo( document.body )
     43            .addClass( o.className )
     44            .css({
     45                top: startPosition.top - fixTop,
     46                left: startPosition.left - fixLeft,
     47                height: elem.innerHeight(),
     48                width: elem.innerWidth(),
     49                position: targetFixed ? "fixed" : "absolute"
     50            })
     51            .animate( animation, o.duration, o.easing, function() {
     52                transfer.remove();
     53                done();
     54            });
     55};
     56
     57}));
  • trunk/src/wp-includes/js/jquery/ui/effect.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t,e){var i="ui-effects-";t.effects={effect:{}},function(t,e){function i(t,e,i){var s=u[e.type]||{};return null==t?i||!e.def?null:e.def:(t=s.floor?~~t:parseFloat(t),isNaN(t)?e.def:s.mod?(t+s.mod)%s.mod:0>t?0:t>s.max?s.max:t)}function s(i){var s=l(),n=s._rgba=[];return i=i.toLowerCase(),f(h,function(t,a){var o,r=a.re.exec(i),h=r&&a.parse(r),l=a.space||"rgba";return h?(o=s[l](h),s[c[l].cache]=o[c[l].cache],n=s._rgba=o._rgba,!1):e}),n.length?("0,0,0,0"===n.join()&&t.extend(n,a.transparent),s):a[i]}function n(t,e,i){return i=(i+1)%1,1>6*i?t+6*(e-t)*i:1>2*i?e:2>3*i?t+6*(e-t)*(2/3-i):t}var a,o="backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",r=/^([\-+])=\s*(\d+\.?\d*)/,h=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(t){return[t[1],t[2],t[3],t[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(t){return[2.55*t[1],2.55*t[2],2.55*t[3],t[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,parse:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])/,parse:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(t){return[t[1],t[2]/100,t[3]/100,t[4]]}}],l=t.Color=function(e,i,s,n){return new t.Color.fn.parse(e,i,s,n)},c={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},u={"byte":{floor:!0,max:255},percent:{max:1},degrees:{mod:360,floor:!0}},d=l.support={},p=t("<p>")[0],f=t.each;p.style.cssText="background-color:rgba(1,1,1,.5)",d.rgba=p.style.backgroundColor.indexOf("rgba")>-1,f(c,function(t,e){e.cache="_"+t,e.props.alpha={idx:3,type:"percent",def:1}}),l.fn=t.extend(l.prototype,{parse:function(n,o,r,h){if(n===e)return this._rgba=[null,null,null,null],this;(n.jquery||n.nodeType)&&(n=t(n).css(o),o=e);var u=this,d=t.type(n),p=this._rgba=[];return o!==e&&(n=[n,o,r,h],d="array"),"string"===d?this.parse(s(n)||a._default):"array"===d?(f(c.rgba.props,function(t,e){p[e.idx]=i(n[e.idx],e)}),this):"object"===d?(n instanceof l?f(c,function(t,e){n[e.cache]&&(u[e.cache]=n[e.cache].slice())}):f(c,function(e,s){var a=s.cache;f(s.props,function(t,e){if(!u[a]&&s.to){if("alpha"===t||null==n[t])return;u[a]=s.to(u._rgba)}u[a][e.idx]=i(n[t],e,!0)}),u[a]&&0>t.inArray(null,u[a].slice(0,3))&&(u[a][3]=1,s.from&&(u._rgba=s.from(u[a])))}),this):e},is:function(t){var i=l(t),s=!0,n=this;return f(c,function(t,a){var o,r=i[a.cache];return r&&(o=n[a.cache]||a.to&&a.to(n._rgba)||[],f(a.props,function(t,i){return null!=r[i.idx]?s=r[i.idx]===o[i.idx]:e})),s}),s},_space:function(){var t=[],e=this;return f(c,function(i,s){e[s.cache]&&t.push(i)}),t.pop()},transition:function(t,e){var s=l(t),n=s._space(),a=c[n],o=0===this.alpha()?l("transparent"):this,r=o[a.cache]||a.to(o._rgba),h=r.slice();return s=s[a.cache],f(a.props,function(t,n){var a=n.idx,o=r[a],l=s[a],c=u[n.type]||{};null!==l&&(null===o?h[a]=l:(c.mod&&(l-o>c.mod/2?o+=c.mod:o-l>c.mod/2&&(o-=c.mod)),h[a]=i((l-o)*e+o,n)))}),this[n](h)},blend:function(e){if(1===this._rgba[3])return this;var i=this._rgba.slice(),s=i.pop(),n=l(e)._rgba;return l(t.map(i,function(t,e){return(1-s)*n[e]+s*t}))},toRgbaString:function(){var e="rgba(",i=t.map(this._rgba,function(t,e){return null==t?e>2?1:0:t});return 1===i[3]&&(i.pop(),e="rgb("),e+i.join()+")"},toHslaString:function(){var e="hsla(",i=t.map(this.hsla(),function(t,e){return null==t&&(t=e>2?1:0),e&&3>e&&(t=Math.round(100*t)+"%"),t});return 1===i[3]&&(i.pop(),e="hsl("),e+i.join()+")"},toHexString:function(e){var i=this._rgba.slice(),s=i.pop();return e&&i.push(~~(255*s)),"#"+t.map(i,function(t){return t=(t||0).toString(16),1===t.length?"0"+t:t}).join("")},toString:function(){return 0===this._rgba[3]?"transparent":this.toRgbaString()}}),l.fn.parse.prototype=l.fn,c.hsla.to=function(t){if(null==t[0]||null==t[1]||null==t[2])return[null,null,null,t[3]];var e,i,s=t[0]/255,n=t[1]/255,a=t[2]/255,o=t[3],r=Math.max(s,n,a),h=Math.min(s,n,a),l=r-h,c=r+h,u=.5*c;return e=h===r?0:s===r?60*(n-a)/l+360:n===r?60*(a-s)/l+120:60*(s-n)/l+240,i=0===l?0:.5>=u?l/c:l/(2-c),[Math.round(e)%360,i,u,null==o?1:o]},c.hsla.from=function(t){if(null==t[0]||null==t[1]||null==t[2])return[null,null,null,t[3]];var e=t[0]/360,i=t[1],s=t[2],a=t[3],o=.5>=s?s*(1+i):s+i-s*i,r=2*s-o;return[Math.round(255*n(r,o,e+1/3)),Math.round(255*n(r,o,e)),Math.round(255*n(r,o,e-1/3)),a]},f(c,function(s,n){var a=n.props,o=n.cache,h=n.to,c=n.from;l.fn[s]=function(s){if(h&&!this[o]&&(this[o]=h(this._rgba)),s===e)return this[o].slice();var n,r=t.type(s),u="array"===r||"object"===r?s:arguments,d=this[o].slice();return f(a,function(t,e){var s=u["object"===r?t:e.idx];null==s&&(s=d[e.idx]),d[e.idx]=i(s,e)}),c?(n=l(c(d)),n[o]=d,n):l(d)},f(a,function(e,i){l.fn[e]||(l.fn[e]=function(n){var a,o=t.type(n),h="alpha"===e?this._hsla?"hsla":"rgba":s,l=this[h](),c=l[i.idx];return"undefined"===o?c:("function"===o&&(n=n.call(this,c),o=t.type(n)),null==n&&i.empty?this:("string"===o&&(a=r.exec(n),a&&(n=c+parseFloat(a[2])*("+"===a[1]?1:-1))),l[i.idx]=n,this[h](l)))})})}),l.hook=function(e){var i=e.split(" ");f(i,function(e,i){t.cssHooks[i]={set:function(e,n){var a,o,r="";if("transparent"!==n&&("string"!==t.type(n)||(a=s(n)))){if(n=l(a||n),!d.rgba&&1!==n._rgba[3]){for(o="backgroundColor"===i?e.parentNode:e;(""===r||"transparent"===r)&&o&&o.style;)try{r=t.css(o,"backgroundColor"),o=o.parentNode}catch(h){}n=n.blend(r&&"transparent"!==r?r:"_default")}n=n.toRgbaString()}try{e.style[i]=n}catch(h){}}},t.fx.step[i]=function(e){e.colorInit||(e.start=l(e.elem,i),e.end=l(e.end),e.colorInit=!0),t.cssHooks[i].set(e.elem,e.start.transition(e.end,e.pos))}})},l.hook(o),t.cssHooks.borderColor={expand:function(t){var e={};return f(["Top","Right","Bottom","Left"],function(i,s){e["border"+s+"Color"]=t}),e}},a=t.Color.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"}}(jQuery),function(){function i(e){var i,s,n=e.ownerDocument.defaultView?e.ownerDocument.defaultView.getComputedStyle(e,null):e.currentStyle,a={};if(n&&n.length&&n[0]&&n[n[0]])for(s=n.length;s--;)i=n[s],"string"==typeof n[i]&&(a[t.camelCase(i)]=n[i]);else for(i in n)"string"==typeof n[i]&&(a[i]=n[i]);return a}function s(e,i){var s,n,o={};for(s in i)n=i[s],e[s]!==n&&(a[s]||(t.fx.step[s]||!isNaN(parseFloat(n)))&&(o[s]=n));return o}var n=["add","remove","toggle"],a={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};t.each(["borderLeftStyle","borderRightStyle","borderBottomStyle","borderTopStyle"],function(e,i){t.fx.step[i]=function(t){("none"!==t.end&&!t.setAttr||1===t.pos&&!t.setAttr)&&(jQuery.style(t.elem,i,t.end),t.setAttr=!0)}}),t.fn.addBack||(t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t.effects.animateClass=function(e,a,o,r){var h=t.speed(a,o,r);return this.queue(function(){var a,o=t(this),r=o.attr("class")||"",l=h.children?o.find("*").addBack():o;l=l.map(function(){var e=t(this);return{el:e,start:i(this)}}),a=function(){t.each(n,function(t,i){e[i]&&o[i+"Class"](e[i])})},a(),l=l.map(function(){return this.end=i(this.el[0]),this.diff=s(this.start,this.end),this}),o.attr("class",r),l=l.map(function(){var e=this,i=t.Deferred(),s=t.extend({},h,{queue:!1,complete:function(){i.resolve(e)}});return this.el.animate(this.diff,s),i.promise()}),t.when.apply(t,l.get()).done(function(){a(),t.each(arguments,function(){var e=this.el;t.each(this.diff,function(t){e.css(t,"")})}),h.complete.call(o[0])})})},t.fn.extend({addClass:function(e){return function(i,s,n,a){return s?t.effects.animateClass.call(this,{add:i},s,n,a):e.apply(this,arguments)}}(t.fn.addClass),removeClass:function(e){return function(i,s,n,a){return arguments.length>1?t.effects.animateClass.call(this,{remove:i},s,n,a):e.apply(this,arguments)}}(t.fn.removeClass),toggleClass:function(i){return function(s,n,a,o,r){return"boolean"==typeof n||n===e?a?t.effects.animateClass.call(this,n?{add:s}:{remove:s},a,o,r):i.apply(this,arguments):t.effects.animateClass.call(this,{toggle:s},n,a,o)}}(t.fn.toggleClass),switchClass:function(e,i,s,n,a){return t.effects.animateClass.call(this,{add:i,remove:e},s,n,a)}})}(),function(){function s(e,i,s,n){return t.isPlainObject(e)&&(i=e,e=e.effect),e={effect:e},null==i&&(i={}),t.isFunction(i)&&(n=i,s=null,i={}),("number"==typeof i||t.fx.speeds[i])&&(n=s,s=i,i={}),t.isFunction(s)&&(n=s,s=null),i&&t.extend(e,i),s=s||i.duration,e.duration=t.fx.off?0:"number"==typeof s?s:s in t.fx.speeds?t.fx.speeds[s]:t.fx.speeds._default,e.complete=n||i.complete,e}function n(e){return!e||"number"==typeof e||t.fx.speeds[e]?!0:"string"!=typeof e||t.effects.effect[e]?t.isFunction(e)?!0:"object"!=typeof e||e.effect?!1:!0:!0}t.extend(t.effects,{version:"1.10.4",save:function(t,e){for(var s=0;e.length>s;s++)null!==e[s]&&t.data(i+e[s],t[0].style[e[s]])},restore:function(t,s){var n,a;for(a=0;s.length>a;a++)null!==s[a]&&(n=t.data(i+s[a]),n===e&&(n=""),t.css(s[a],n))},setMode:function(t,e){return"toggle"===e&&(e=t.is(":hidden")?"show":"hide"),e},getBaseline:function(t,e){var i,s;switch(t[0]){case"top":i=0;break;case"middle":i=.5;break;case"bottom":i=1;break;default:i=t[0]/e.height}switch(t[1]){case"left":s=0;break;case"center":s=.5;break;case"right":s=1;break;default:s=t[1]/e.width}return{x:s,y:i}},createWrapper:function(e){if(e.parent().is(".ui-effects-wrapper"))return e.parent();var i={width:e.outerWidth(!0),height:e.outerHeight(!0),"float":e.css("float")},s=t("<div></div>").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),n={width:e.width(),height:e.height()},a=document.activeElement;try{a.id}catch(o){a=document.body}return e.wrap(s),(e[0]===a||t.contains(e[0],a))&&t(a).focus(),s=e.parent(),"static"===e.css("position")?(s.css({position:"relative"}),e.css({position:"relative"})):(t.extend(i,{position:e.css("position"),zIndex:e.css("z-index")}),t.each(["top","left","bottom","right"],function(t,s){i[s]=e.css(s),isNaN(parseInt(i[s],10))&&(i[s]="auto")}),e.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})),e.css(n),s.css(i).show()},removeWrapper:function(e){var i=document.activeElement;return e.parent().is(".ui-effects-wrapper")&&(e.parent().replaceWith(e),(e[0]===i||t.contains(e[0],i))&&t(i).focus()),e},setTransition:function(e,i,s,n){return n=n||{},t.each(i,function(t,i){var a=e.cssUnit(i);a[0]>0&&(n[i]=a[0]*s+a[1])}),n}}),t.fn.extend({effect:function(){function e(e){function s(){t.isFunction(a)&&a.call(n[0]),t.isFunction(e)&&e()}var n=t(this),a=i.complete,r=i.mode;(n.is(":hidden")?"hide"===r:"show"===r)?(n[r](),s()):o.call(n[0],i,s)}var i=s.apply(this,arguments),n=i.mode,a=i.queue,o=t.effects.effect[i.effect];return t.fx.off||!o?n?this[n](i.duration,i.complete):this.each(function(){i.complete&&i.complete.call(this)}):a===!1?this.each(e):this.queue(a||"fx",e)},show:function(t){return function(e){if(n(e))return t.apply(this,arguments);var i=s.apply(this,arguments);return i.mode="show",this.effect.call(this,i)}}(t.fn.show),hide:function(t){return function(e){if(n(e))return t.apply(this,arguments);var i=s.apply(this,arguments);return i.mode="hide",this.effect.call(this,i)}}(t.fn.hide),toggle:function(t){return function(e){if(n(e)||"boolean"==typeof e)return t.apply(this,arguments);var i=s.apply(this,arguments);return i.mode="toggle",this.effect.call(this,i)}}(t.fn.toggle),cssUnit:function(e){var i=this.css(e),s=[];return t.each(["em","px","%","pt"],function(t,e){i.indexOf(e)>0&&(s=[parseFloat(i),e])}),s}})}(),function(){var e={};t.each(["Quad","Cubic","Quart","Quint","Expo"],function(t,i){e[i]=function(e){return Math.pow(e,t+2)}}),t.extend(e,{Sine:function(t){return 1-Math.cos(t*Math.PI/2)},Circ:function(t){return 1-Math.sqrt(1-t*t)},Elastic:function(t){return 0===t||1===t?t:-Math.pow(2,8*(t-1))*Math.sin((80*(t-1)-7.5)*Math.PI/15)},Back:function(t){return t*t*(3*t-2)},Bounce:function(t){for(var e,i=4;((e=Math.pow(2,--i))-1)/11>t;);return 1/Math.pow(4,3-i)-7.5625*Math.pow((3*e-2)/22-t,2)}}),t.each(e,function(e,i){t.easing["easeIn"+e]=i,t.easing["easeOut"+e]=function(t){return 1-i(1-t)},t.easing["easeInOut"+e]=function(t){return.5>t?i(2*t)/2:1-i(-2*t+2)/2}})}()})(jQuery);
     1/*!
     2 * jQuery UI Effects 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/category/effects-core/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define( [ "jquery" ], factory );
     16    } else {
     17
     18        // Browser globals
     19        factory( jQuery );
     20    }
     21}(function( $ ) {
     22
     23var dataSpace = "ui-effects-",
     24
     25    // Create a local jQuery because jQuery Color relies on it and the
     26    // global may not exist with AMD and a custom build (#10199)
     27    jQuery = $;
     28
     29$.effects = {
     30    effect: {}
     31};
     32
     33/*!
     34 * jQuery Color Animations v2.1.2
     35 * https://github.com/jquery/jquery-color
     36 *
     37 * Copyright 2014 jQuery Foundation and other contributors
     38 * Released under the MIT license.
     39 * http://jquery.org/license
     40 *
     41 * Date: Wed Jan 16 08:47:09 2013 -0600
     42 */
     43(function( jQuery, undefined ) {
     44
     45    var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
     46
     47    // plusequals test for += 100 -= 100
     48    rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
     49    // a set of RE's that can match strings and generate color tuples.
     50    stringParsers = [ {
     51            re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
     52            parse: function( execResult ) {
     53                return [
     54                    execResult[ 1 ],
     55                    execResult[ 2 ],
     56                    execResult[ 3 ],
     57                    execResult[ 4 ]
     58                ];
     59            }
     60        }, {
     61            re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
     62            parse: function( execResult ) {
     63                return [
     64                    execResult[ 1 ] * 2.55,
     65                    execResult[ 2 ] * 2.55,
     66                    execResult[ 3 ] * 2.55,
     67                    execResult[ 4 ]
     68                ];
     69            }
     70        }, {
     71            // this regex ignores A-F because it's compared against an already lowercased string
     72            re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
     73            parse: function( execResult ) {
     74                return [
     75                    parseInt( execResult[ 1 ], 16 ),
     76                    parseInt( execResult[ 2 ], 16 ),
     77                    parseInt( execResult[ 3 ], 16 )
     78                ];
     79            }
     80        }, {
     81            // this regex ignores A-F because it's compared against an already lowercased string
     82            re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
     83            parse: function( execResult ) {
     84                return [
     85                    parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
     86                    parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
     87                    parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
     88                ];
     89            }
     90        }, {
     91            re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
     92            space: "hsla",
     93            parse: function( execResult ) {
     94                return [
     95                    execResult[ 1 ],
     96                    execResult[ 2 ] / 100,
     97                    execResult[ 3 ] / 100,
     98                    execResult[ 4 ]
     99                ];
     100            }
     101        } ],
     102
     103    // jQuery.Color( )
     104    color = jQuery.Color = function( color, green, blue, alpha ) {
     105        return new jQuery.Color.fn.parse( color, green, blue, alpha );
     106    },
     107    spaces = {
     108        rgba: {
     109            props: {
     110                red: {
     111                    idx: 0,
     112                    type: "byte"
     113                },
     114                green: {
     115                    idx: 1,
     116                    type: "byte"
     117                },
     118                blue: {
     119                    idx: 2,
     120                    type: "byte"
     121                }
     122            }
     123        },
     124
     125        hsla: {
     126            props: {
     127                hue: {
     128                    idx: 0,
     129                    type: "degrees"
     130                },
     131                saturation: {
     132                    idx: 1,
     133                    type: "percent"
     134                },
     135                lightness: {
     136                    idx: 2,
     137                    type: "percent"
     138                }
     139            }
     140        }
     141    },
     142    propTypes = {
     143        "byte": {
     144            floor: true,
     145            max: 255
     146        },
     147        "percent": {
     148            max: 1
     149        },
     150        "degrees": {
     151            mod: 360,
     152            floor: true
     153        }
     154    },
     155    support = color.support = {},
     156
     157    // element for support tests
     158    supportElem = jQuery( "<p>" )[ 0 ],
     159
     160    // colors = jQuery.Color.names
     161    colors,
     162
     163    // local aliases of functions called often
     164    each = jQuery.each;
     165
     166// determine rgba support immediately
     167supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
     168support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
     169
     170// define cache name and alpha properties
     171// for rgba and hsla spaces
     172each( spaces, function( spaceName, space ) {
     173    space.cache = "_" + spaceName;
     174    space.props.alpha = {
     175        idx: 3,
     176        type: "percent",
     177        def: 1
     178    };
     179});
     180
     181function clamp( value, prop, allowEmpty ) {
     182    var type = propTypes[ prop.type ] || {};
     183
     184    if ( value == null ) {
     185        return (allowEmpty || !prop.def) ? null : prop.def;
     186    }
     187
     188    // ~~ is an short way of doing floor for positive numbers
     189    value = type.floor ? ~~value : parseFloat( value );
     190
     191    // IE will pass in empty strings as value for alpha,
     192    // which will hit this case
     193    if ( isNaN( value ) ) {
     194        return prop.def;
     195    }
     196
     197    if ( type.mod ) {
     198        // we add mod before modding to make sure that negatives values
     199        // get converted properly: -10 -> 350
     200        return (value + type.mod) % type.mod;
     201    }
     202
     203    // for now all property types without mod have min and max
     204    return 0 > value ? 0 : type.max < value ? type.max : value;
     205}
     206
     207function stringParse( string ) {
     208    var inst = color(),
     209        rgba = inst._rgba = [];
     210
     211    string = string.toLowerCase();
     212
     213    each( stringParsers, function( i, parser ) {
     214        var parsed,
     215            match = parser.re.exec( string ),
     216            values = match && parser.parse( match ),
     217            spaceName = parser.space || "rgba";
     218
     219        if ( values ) {
     220            parsed = inst[ spaceName ]( values );
     221
     222            // if this was an rgba parse the assignment might happen twice
     223            // oh well....
     224            inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
     225            rgba = inst._rgba = parsed._rgba;
     226
     227            // exit each( stringParsers ) here because we matched
     228            return false;
     229        }
     230    });
     231
     232    // Found a stringParser that handled it
     233    if ( rgba.length ) {
     234
     235        // if this came from a parsed string, force "transparent" when alpha is 0
     236        // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
     237        if ( rgba.join() === "0,0,0,0" ) {
     238            jQuery.extend( rgba, colors.transparent );
     239        }
     240        return inst;
     241    }
     242
     243    // named colors
     244    return colors[ string ];
     245}
     246
     247color.fn = jQuery.extend( color.prototype, {
     248    parse: function( red, green, blue, alpha ) {
     249        if ( red === undefined ) {
     250            this._rgba = [ null, null, null, null ];
     251            return this;
     252        }
     253        if ( red.jquery || red.nodeType ) {
     254            red = jQuery( red ).css( green );
     255            green = undefined;
     256        }
     257
     258        var inst = this,
     259            type = jQuery.type( red ),
     260            rgba = this._rgba = [];
     261
     262        // more than 1 argument specified - assume ( red, green, blue, alpha )
     263        if ( green !== undefined ) {
     264            red = [ red, green, blue, alpha ];
     265            type = "array";
     266        }
     267
     268        if ( type === "string" ) {
     269            return this.parse( stringParse( red ) || colors._default );
     270        }
     271
     272        if ( type === "array" ) {
     273            each( spaces.rgba.props, function( key, prop ) {
     274                rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
     275            });
     276            return this;
     277        }
     278
     279        if ( type === "object" ) {
     280            if ( red instanceof color ) {
     281                each( spaces, function( spaceName, space ) {
     282                    if ( red[ space.cache ] ) {
     283                        inst[ space.cache ] = red[ space.cache ].slice();
     284                    }
     285                });
     286            } else {
     287                each( spaces, function( spaceName, space ) {
     288                    var cache = space.cache;
     289                    each( space.props, function( key, prop ) {
     290
     291                        // if the cache doesn't exist, and we know how to convert
     292                        if ( !inst[ cache ] && space.to ) {
     293
     294                            // if the value was null, we don't need to copy it
     295                            // if the key was alpha, we don't need to copy it either
     296                            if ( key === "alpha" || red[ key ] == null ) {
     297                                return;
     298                            }
     299                            inst[ cache ] = space.to( inst._rgba );
     300                        }
     301
     302                        // this is the only case where we allow nulls for ALL properties.
     303                        // call clamp with alwaysAllowEmpty
     304                        inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
     305                    });
     306
     307                    // everything defined but alpha?
     308                    if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
     309                        // use the default of 1
     310                        inst[ cache ][ 3 ] = 1;
     311                        if ( space.from ) {
     312                            inst._rgba = space.from( inst[ cache ] );
     313                        }
     314                    }
     315                });
     316            }
     317            return this;
     318        }
     319    },
     320    is: function( compare ) {
     321        var is = color( compare ),
     322            same = true,
     323            inst = this;
     324
     325        each( spaces, function( _, space ) {
     326            var localCache,
     327                isCache = is[ space.cache ];
     328            if (isCache) {
     329                localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
     330                each( space.props, function( _, prop ) {
     331                    if ( isCache[ prop.idx ] != null ) {
     332                        same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
     333                        return same;
     334                    }
     335                });
     336            }
     337            return same;
     338        });
     339        return same;
     340    },
     341    _space: function() {
     342        var used = [],
     343            inst = this;
     344        each( spaces, function( spaceName, space ) {
     345            if ( inst[ space.cache ] ) {
     346                used.push( spaceName );
     347            }
     348        });
     349        return used.pop();
     350    },
     351    transition: function( other, distance ) {
     352        var end = color( other ),
     353            spaceName = end._space(),
     354            space = spaces[ spaceName ],
     355            startColor = this.alpha() === 0 ? color( "transparent" ) : this,
     356            start = startColor[ space.cache ] || space.to( startColor._rgba ),
     357            result = start.slice();
     358
     359        end = end[ space.cache ];
     360        each( space.props, function( key, prop ) {
     361            var index = prop.idx,
     362                startValue = start[ index ],
     363                endValue = end[ index ],
     364                type = propTypes[ prop.type ] || {};
     365
     366            // if null, don't override start value
     367            if ( endValue === null ) {
     368                return;
     369            }
     370            // if null - use end
     371            if ( startValue === null ) {
     372                result[ index ] = endValue;
     373            } else {
     374                if ( type.mod ) {
     375                    if ( endValue - startValue > type.mod / 2 ) {
     376                        startValue += type.mod;
     377                    } else if ( startValue - endValue > type.mod / 2 ) {
     378                        startValue -= type.mod;
     379                    }
     380                }
     381                result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
     382            }
     383        });
     384        return this[ spaceName ]( result );
     385    },
     386    blend: function( opaque ) {
     387        // if we are already opaque - return ourself
     388        if ( this._rgba[ 3 ] === 1 ) {
     389            return this;
     390        }
     391
     392        var rgb = this._rgba.slice(),
     393            a = rgb.pop(),
     394            blend = color( opaque )._rgba;
     395
     396        return color( jQuery.map( rgb, function( v, i ) {
     397            return ( 1 - a ) * blend[ i ] + a * v;
     398        }));
     399    },
     400    toRgbaString: function() {
     401        var prefix = "rgba(",
     402            rgba = jQuery.map( this._rgba, function( v, i ) {
     403                return v == null ? ( i > 2 ? 1 : 0 ) : v;
     404            });
     405
     406        if ( rgba[ 3 ] === 1 ) {
     407            rgba.pop();
     408            prefix = "rgb(";
     409        }
     410
     411        return prefix + rgba.join() + ")";
     412    },
     413    toHslaString: function() {
     414        var prefix = "hsla(",
     415            hsla = jQuery.map( this.hsla(), function( v, i ) {
     416                if ( v == null ) {
     417                    v = i > 2 ? 1 : 0;
     418                }
     419
     420                // catch 1 and 2
     421                if ( i && i < 3 ) {
     422                    v = Math.round( v * 100 ) + "%";
     423                }
     424                return v;
     425            });
     426
     427        if ( hsla[ 3 ] === 1 ) {
     428            hsla.pop();
     429            prefix = "hsl(";
     430        }
     431        return prefix + hsla.join() + ")";
     432    },
     433    toHexString: function( includeAlpha ) {
     434        var rgba = this._rgba.slice(),
     435            alpha = rgba.pop();
     436
     437        if ( includeAlpha ) {
     438            rgba.push( ~~( alpha * 255 ) );
     439        }
     440
     441        return "#" + jQuery.map( rgba, function( v ) {
     442
     443            // default to 0 when nulls exist
     444            v = ( v || 0 ).toString( 16 );
     445            return v.length === 1 ? "0" + v : v;
     446        }).join("");
     447    },
     448    toString: function() {
     449        return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
     450    }
     451});
     452color.fn.parse.prototype = color.fn;
     453
     454// hsla conversions adapted from:
     455// https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
     456
     457function hue2rgb( p, q, h ) {
     458    h = ( h + 1 ) % 1;
     459    if ( h * 6 < 1 ) {
     460        return p + ( q - p ) * h * 6;
     461    }
     462    if ( h * 2 < 1) {
     463        return q;
     464    }
     465    if ( h * 3 < 2 ) {
     466        return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
     467    }
     468    return p;
     469}
     470
     471spaces.hsla.to = function( rgba ) {
     472    if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
     473        return [ null, null, null, rgba[ 3 ] ];
     474    }
     475    var r = rgba[ 0 ] / 255,
     476        g = rgba[ 1 ] / 255,
     477        b = rgba[ 2 ] / 255,
     478        a = rgba[ 3 ],
     479        max = Math.max( r, g, b ),
     480        min = Math.min( r, g, b ),
     481        diff = max - min,
     482        add = max + min,
     483        l = add * 0.5,
     484        h, s;
     485
     486    if ( min === max ) {
     487        h = 0;
     488    } else if ( r === max ) {
     489        h = ( 60 * ( g - b ) / diff ) + 360;
     490    } else if ( g === max ) {
     491        h = ( 60 * ( b - r ) / diff ) + 120;
     492    } else {
     493        h = ( 60 * ( r - g ) / diff ) + 240;
     494    }
     495
     496    // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
     497    // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
     498    if ( diff === 0 ) {
     499        s = 0;
     500    } else if ( l <= 0.5 ) {
     501        s = diff / add;
     502    } else {
     503        s = diff / ( 2 - add );
     504    }
     505    return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
     506};
     507
     508spaces.hsla.from = function( hsla ) {
     509    if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
     510        return [ null, null, null, hsla[ 3 ] ];
     511    }
     512    var h = hsla[ 0 ] / 360,
     513        s = hsla[ 1 ],
     514        l = hsla[ 2 ],
     515        a = hsla[ 3 ],
     516        q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
     517        p = 2 * l - q;
     518
     519    return [
     520        Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
     521        Math.round( hue2rgb( p, q, h ) * 255 ),
     522        Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
     523        a
     524    ];
     525};
     526
     527each( spaces, function( spaceName, space ) {
     528    var props = space.props,
     529        cache = space.cache,
     530        to = space.to,
     531        from = space.from;
     532
     533    // makes rgba() and hsla()
     534    color.fn[ spaceName ] = function( value ) {
     535
     536        // generate a cache for this space if it doesn't exist
     537        if ( to && !this[ cache ] ) {
     538            this[ cache ] = to( this._rgba );
     539        }
     540        if ( value === undefined ) {
     541            return this[ cache ].slice();
     542        }
     543
     544        var ret,
     545            type = jQuery.type( value ),
     546            arr = ( type === "array" || type === "object" ) ? value : arguments,
     547            local = this[ cache ].slice();
     548
     549        each( props, function( key, prop ) {
     550            var val = arr[ type === "object" ? key : prop.idx ];
     551            if ( val == null ) {
     552                val = local[ prop.idx ];
     553            }
     554            local[ prop.idx ] = clamp( val, prop );
     555        });
     556
     557        if ( from ) {
     558            ret = color( from( local ) );
     559            ret[ cache ] = local;
     560            return ret;
     561        } else {
     562            return color( local );
     563        }
     564    };
     565
     566    // makes red() green() blue() alpha() hue() saturation() lightness()
     567    each( props, function( key, prop ) {
     568        // alpha is included in more than one space
     569        if ( color.fn[ key ] ) {
     570            return;
     571        }
     572        color.fn[ key ] = function( value ) {
     573            var vtype = jQuery.type( value ),
     574                fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
     575                local = this[ fn ](),
     576                cur = local[ prop.idx ],
     577                match;
     578
     579            if ( vtype === "undefined" ) {
     580                return cur;
     581            }
     582
     583            if ( vtype === "function" ) {
     584                value = value.call( this, cur );
     585                vtype = jQuery.type( value );
     586            }
     587            if ( value == null && prop.empty ) {
     588                return this;
     589            }
     590            if ( vtype === "string" ) {
     591                match = rplusequals.exec( value );
     592                if ( match ) {
     593                    value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
     594                }
     595            }
     596            local[ prop.idx ] = value;
     597            return this[ fn ]( local );
     598        };
     599    });
     600});
     601
     602// add cssHook and .fx.step function for each named hook.
     603// accept a space separated string of properties
     604color.hook = function( hook ) {
     605    var hooks = hook.split( " " );
     606    each( hooks, function( i, hook ) {
     607        jQuery.cssHooks[ hook ] = {
     608            set: function( elem, value ) {
     609                var parsed, curElem,
     610                    backgroundColor = "";
     611
     612                if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
     613                    value = color( parsed || value );
     614                    if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
     615                        curElem = hook === "backgroundColor" ? elem.parentNode : elem;
     616                        while (
     617                            (backgroundColor === "" || backgroundColor === "transparent") &&
     618                            curElem && curElem.style
     619                        ) {
     620                            try {
     621                                backgroundColor = jQuery.css( curElem, "backgroundColor" );
     622                                curElem = curElem.parentNode;
     623                            } catch ( e ) {
     624                            }
     625                        }
     626
     627                        value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
     628                            backgroundColor :
     629                            "_default" );
     630                    }
     631
     632                    value = value.toRgbaString();
     633                }
     634                try {
     635                    elem.style[ hook ] = value;
     636                } catch( e ) {
     637                    // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
     638                }
     639            }
     640        };
     641        jQuery.fx.step[ hook ] = function( fx ) {
     642            if ( !fx.colorInit ) {
     643                fx.start = color( fx.elem, hook );
     644                fx.end = color( fx.end );
     645                fx.colorInit = true;
     646            }
     647            jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
     648        };
     649    });
     650
     651};
     652
     653color.hook( stepHooks );
     654
     655jQuery.cssHooks.borderColor = {
     656    expand: function( value ) {
     657        var expanded = {};
     658
     659        each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
     660            expanded[ "border" + part + "Color" ] = value;
     661        });
     662        return expanded;
     663    }
     664};
     665
     666// Basic color names only.
     667// Usage of any of the other color names requires adding yourself or including
     668// jquery.color.svg-names.js.
     669colors = jQuery.Color.names = {
     670    // 4.1. Basic color keywords
     671    aqua: "#00ffff",
     672    black: "#000000",
     673    blue: "#0000ff",
     674    fuchsia: "#ff00ff",
     675    gray: "#808080",
     676    green: "#008000",
     677    lime: "#00ff00",
     678    maroon: "#800000",
     679    navy: "#000080",
     680    olive: "#808000",
     681    purple: "#800080",
     682    red: "#ff0000",
     683    silver: "#c0c0c0",
     684    teal: "#008080",
     685    white: "#ffffff",
     686    yellow: "#ffff00",
     687
     688    // 4.2.3. "transparent" color keyword
     689    transparent: [ null, null, null, 0 ],
     690
     691    _default: "#ffffff"
     692};
     693
     694})( jQuery );
     695
     696/******************************************************************************/
     697/****************************** CLASS ANIMATIONS ******************************/
     698/******************************************************************************/
     699(function() {
     700
     701var classAnimationActions = [ "add", "remove", "toggle" ],
     702    shorthandStyles = {
     703        border: 1,
     704        borderBottom: 1,
     705        borderColor: 1,
     706        borderLeft: 1,
     707        borderRight: 1,
     708        borderTop: 1,
     709        borderWidth: 1,
     710        margin: 1,
     711        padding: 1
     712    };
     713
     714$.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
     715    $.fx.step[ prop ] = function( fx ) {
     716        if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
     717            jQuery.style( fx.elem, prop, fx.end );
     718            fx.setAttr = true;
     719        }
     720    };
     721});
     722
     723function getElementStyles( elem ) {
     724    var key, len,
     725        style = elem.ownerDocument.defaultView ?
     726            elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
     727            elem.currentStyle,
     728        styles = {};
     729
     730    if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
     731        len = style.length;
     732        while ( len-- ) {
     733            key = style[ len ];
     734            if ( typeof style[ key ] === "string" ) {
     735                styles[ $.camelCase( key ) ] = style[ key ];
     736            }
     737        }
     738    // support: Opera, IE <9
     739    } else {
     740        for ( key in style ) {
     741            if ( typeof style[ key ] === "string" ) {
     742                styles[ key ] = style[ key ];
     743            }
     744        }
     745    }
     746
     747    return styles;
     748}
     749
     750function styleDifference( oldStyle, newStyle ) {
     751    var diff = {},
     752        name, value;
     753
     754    for ( name in newStyle ) {
     755        value = newStyle[ name ];
     756        if ( oldStyle[ name ] !== value ) {
     757            if ( !shorthandStyles[ name ] ) {
     758                if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
     759                    diff[ name ] = value;
     760                }
     761            }
     762        }
     763    }
     764
     765    return diff;
     766}
     767
     768// support: jQuery <1.8
     769if ( !$.fn.addBack ) {
     770    $.fn.addBack = function( selector ) {
     771        return this.add( selector == null ?
     772            this.prevObject : this.prevObject.filter( selector )
     773        );
     774    };
     775}
     776
     777$.effects.animateClass = function( value, duration, easing, callback ) {
     778    var o = $.speed( duration, easing, callback );
     779
     780    return this.queue( function() {
     781        var animated = $( this ),
     782            baseClass = animated.attr( "class" ) || "",
     783            applyClassChange,
     784            allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
     785
     786        // map the animated objects to store the original styles.
     787        allAnimations = allAnimations.map(function() {
     788            var el = $( this );
     789            return {
     790                el: el,
     791                start: getElementStyles( this )
     792            };
     793        });
     794
     795        // apply class change
     796        applyClassChange = function() {
     797            $.each( classAnimationActions, function(i, action) {
     798                if ( value[ action ] ) {
     799                    animated[ action + "Class" ]( value[ action ] );
     800                }
     801            });
     802        };
     803        applyClassChange();
     804
     805        // map all animated objects again - calculate new styles and diff
     806        allAnimations = allAnimations.map(function() {
     807            this.end = getElementStyles( this.el[ 0 ] );
     808            this.diff = styleDifference( this.start, this.end );
     809            return this;
     810        });
     811
     812        // apply original class
     813        animated.attr( "class", baseClass );
     814
     815        // map all animated objects again - this time collecting a promise
     816        allAnimations = allAnimations.map(function() {
     817            var styleInfo = this,
     818                dfd = $.Deferred(),
     819                opts = $.extend({}, o, {
     820                    queue: false,
     821                    complete: function() {
     822                        dfd.resolve( styleInfo );
     823                    }
     824                });
     825
     826            this.el.animate( this.diff, opts );
     827            return dfd.promise();
     828        });
     829
     830        // once all animations have completed:
     831        $.when.apply( $, allAnimations.get() ).done(function() {
     832
     833            // set the final class
     834            applyClassChange();
     835
     836            // for each animated element,
     837            // clear all css properties that were animated
     838            $.each( arguments, function() {
     839                var el = this.el;
     840                $.each( this.diff, function(key) {
     841                    el.css( key, "" );
     842                });
     843            });
     844
     845            // this is guarnteed to be there if you use jQuery.speed()
     846            // it also handles dequeuing the next anim...
     847            o.complete.call( animated[ 0 ] );
     848        });
     849    });
     850};
     851
     852$.fn.extend({
     853    addClass: (function( orig ) {
     854        return function( classNames, speed, easing, callback ) {
     855            return speed ?
     856                $.effects.animateClass.call( this,
     857                    { add: classNames }, speed, easing, callback ) :
     858                orig.apply( this, arguments );
     859        };
     860    })( $.fn.addClass ),
     861
     862    removeClass: (function( orig ) {
     863        return function( classNames, speed, easing, callback ) {
     864            return arguments.length > 1 ?
     865                $.effects.animateClass.call( this,
     866                    { remove: classNames }, speed, easing, callback ) :
     867                orig.apply( this, arguments );
     868        };
     869    })( $.fn.removeClass ),
     870
     871    toggleClass: (function( orig ) {
     872        return function( classNames, force, speed, easing, callback ) {
     873            if ( typeof force === "boolean" || force === undefined ) {
     874                if ( !speed ) {
     875                    // without speed parameter
     876                    return orig.apply( this, arguments );
     877                } else {
     878                    return $.effects.animateClass.call( this,
     879                        (force ? { add: classNames } : { remove: classNames }),
     880                        speed, easing, callback );
     881                }
     882            } else {
     883                // without force parameter
     884                return $.effects.animateClass.call( this,
     885                    { toggle: classNames }, force, speed, easing );
     886            }
     887        };
     888    })( $.fn.toggleClass ),
     889
     890    switchClass: function( remove, add, speed, easing, callback) {
     891        return $.effects.animateClass.call( this, {
     892            add: add,
     893            remove: remove
     894        }, speed, easing, callback );
     895    }
     896});
     897
     898})();
     899
     900/******************************************************************************/
     901/*********************************** EFFECTS **********************************/
     902/******************************************************************************/
     903
     904(function() {
     905
     906$.extend( $.effects, {
     907    version: "1.11.1",
     908
     909    // Saves a set of properties in a data storage
     910    save: function( element, set ) {
     911        for ( var i = 0; i < set.length; i++ ) {
     912            if ( set[ i ] !== null ) {
     913                element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
     914            }
     915        }
     916    },
     917
     918    // Restores a set of previously saved properties from a data storage
     919    restore: function( element, set ) {
     920        var val, i;
     921        for ( i = 0; i < set.length; i++ ) {
     922            if ( set[ i ] !== null ) {
     923                val = element.data( dataSpace + set[ i ] );
     924                // support: jQuery 1.6.2
     925                // http://bugs.jquery.com/ticket/9917
     926                // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
     927                // We can't differentiate between "" and 0 here, so we just assume
     928                // empty string since it's likely to be a more common value...
     929                if ( val === undefined ) {
     930                    val = "";
     931                }
     932                element.css( set[ i ], val );
     933            }
     934        }
     935    },
     936
     937    setMode: function( el, mode ) {
     938        if (mode === "toggle") {
     939            mode = el.is( ":hidden" ) ? "show" : "hide";
     940        }
     941        return mode;
     942    },
     943
     944    // Translates a [top,left] array into a baseline value
     945    // this should be a little more flexible in the future to handle a string & hash
     946    getBaseline: function( origin, original ) {
     947        var y, x;
     948        switch ( origin[ 0 ] ) {
     949            case "top": y = 0; break;
     950            case "middle": y = 0.5; break;
     951            case "bottom": y = 1; break;
     952            default: y = origin[ 0 ] / original.height;
     953        }
     954        switch ( origin[ 1 ] ) {
     955            case "left": x = 0; break;
     956            case "center": x = 0.5; break;
     957            case "right": x = 1; break;
     958            default: x = origin[ 1 ] / original.width;
     959        }
     960        return {
     961            x: x,
     962            y: y
     963        };
     964    },
     965
     966    // Wraps the element around a wrapper that copies position properties
     967    createWrapper: function( element ) {
     968
     969        // if the element is already wrapped, return it
     970        if ( element.parent().is( ".ui-effects-wrapper" )) {
     971            return element.parent();
     972        }
     973
     974        // wrap the element
     975        var props = {
     976                width: element.outerWidth(true),
     977                height: element.outerHeight(true),
     978                "float": element.css( "float" )
     979            },
     980            wrapper = $( "<div></div>" )
     981                .addClass( "ui-effects-wrapper" )
     982                .css({
     983                    fontSize: "100%",
     984                    background: "transparent",
     985                    border: "none",
     986                    margin: 0,
     987                    padding: 0
     988                }),
     989            // Store the size in case width/height are defined in % - Fixes #5245
     990            size = {
     991                width: element.width(),
     992                height: element.height()
     993            },
     994            active = document.activeElement;
     995
     996        // support: Firefox
     997        // Firefox incorrectly exposes anonymous content
     998        // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
     999        try {
     1000            active.id;
     1001        } catch( e ) {
     1002            active = document.body;
     1003        }
     1004
     1005        element.wrap( wrapper );
     1006
     1007        // Fixes #7595 - Elements lose focus when wrapped.
     1008        if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
     1009            $( active ).focus();
     1010        }
     1011
     1012        wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
     1013
     1014        // transfer positioning properties to the wrapper
     1015        if ( element.css( "position" ) === "static" ) {
     1016            wrapper.css({ position: "relative" });
     1017            element.css({ position: "relative" });
     1018        } else {
     1019            $.extend( props, {
     1020                position: element.css( "position" ),
     1021                zIndex: element.css( "z-index" )
     1022            });
     1023            $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
     1024                props[ pos ] = element.css( pos );
     1025                if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
     1026                    props[ pos ] = "auto";
     1027                }
     1028            });
     1029            element.css({
     1030                position: "relative",
     1031                top: 0,
     1032                left: 0,
     1033                right: "auto",
     1034                bottom: "auto"
     1035            });
     1036        }
     1037        element.css(size);
     1038
     1039        return wrapper.css( props ).show();
     1040    },
     1041
     1042    removeWrapper: function( element ) {
     1043        var active = document.activeElement;
     1044
     1045        if ( element.parent().is( ".ui-effects-wrapper" ) ) {
     1046            element.parent().replaceWith( element );
     1047
     1048            // Fixes #7595 - Elements lose focus when wrapped.
     1049            if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
     1050                $( active ).focus();
     1051            }
     1052        }
     1053
     1054        return element;
     1055    },
     1056
     1057    setTransition: function( element, list, factor, value ) {
     1058        value = value || {};
     1059        $.each( list, function( i, x ) {
     1060            var unit = element.cssUnit( x );
     1061            if ( unit[ 0 ] > 0 ) {
     1062                value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
     1063            }
     1064        });
     1065        return value;
     1066    }
     1067});
     1068
     1069// return an effect options object for the given parameters:
     1070function _normalizeArguments( effect, options, speed, callback ) {
     1071
     1072    // allow passing all options as the first parameter
     1073    if ( $.isPlainObject( effect ) ) {
     1074        options = effect;
     1075        effect = effect.effect;
     1076    }
     1077
     1078    // convert to an object
     1079    effect = { effect: effect };
     1080
     1081    // catch (effect, null, ...)
     1082    if ( options == null ) {
     1083        options = {};
     1084    }
     1085
     1086    // catch (effect, callback)
     1087    if ( $.isFunction( options ) ) {
     1088        callback = options;
     1089        speed = null;
     1090        options = {};
     1091    }
     1092
     1093    // catch (effect, speed, ?)
     1094    if ( typeof options === "number" || $.fx.speeds[ options ] ) {
     1095        callback = speed;
     1096        speed = options;
     1097        options = {};
     1098    }
     1099
     1100    // catch (effect, options, callback)
     1101    if ( $.isFunction( speed ) ) {
     1102        callback = speed;
     1103        speed = null;
     1104    }
     1105
     1106    // add options to effect
     1107    if ( options ) {
     1108        $.extend( effect, options );
     1109    }
     1110
     1111    speed = speed || options.duration;
     1112    effect.duration = $.fx.off ? 0 :
     1113        typeof speed === "number" ? speed :
     1114        speed in $.fx.speeds ? $.fx.speeds[ speed ] :
     1115        $.fx.speeds._default;
     1116
     1117    effect.complete = callback || options.complete;
     1118
     1119    return effect;
     1120}
     1121
     1122function standardAnimationOption( option ) {
     1123    // Valid standard speeds (nothing, number, named speed)
     1124    if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
     1125        return true;
     1126    }
     1127
     1128    // Invalid strings - treat as "normal" speed
     1129    if ( typeof option === "string" && !$.effects.effect[ option ] ) {
     1130        return true;
     1131    }
     1132
     1133    // Complete callback
     1134    if ( $.isFunction( option ) ) {
     1135        return true;
     1136    }
     1137
     1138    // Options hash (but not naming an effect)
     1139    if ( typeof option === "object" && !option.effect ) {
     1140        return true;
     1141    }
     1142
     1143    // Didn't match any standard API
     1144    return false;
     1145}
     1146
     1147$.fn.extend({
     1148    effect: function( /* effect, options, speed, callback */ ) {
     1149        var args = _normalizeArguments.apply( this, arguments ),
     1150            mode = args.mode,
     1151            queue = args.queue,
     1152            effectMethod = $.effects.effect[ args.effect ];
     1153
     1154        if ( $.fx.off || !effectMethod ) {
     1155            // delegate to the original method (e.g., .show()) if possible
     1156            if ( mode ) {
     1157                return this[ mode ]( args.duration, args.complete );
     1158            } else {
     1159                return this.each( function() {
     1160                    if ( args.complete ) {
     1161                        args.complete.call( this );
     1162                    }
     1163                });
     1164            }
     1165        }
     1166
     1167        function run( next ) {
     1168            var elem = $( this ),
     1169                complete = args.complete,
     1170                mode = args.mode;
     1171
     1172            function done() {
     1173                if ( $.isFunction( complete ) ) {
     1174                    complete.call( elem[0] );
     1175                }
     1176                if ( $.isFunction( next ) ) {
     1177                    next();
     1178                }
     1179            }
     1180
     1181            // If the element already has the correct final state, delegate to
     1182            // the core methods so the internal tracking of "olddisplay" works.
     1183            if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
     1184                elem[ mode ]();
     1185                done();
     1186            } else {
     1187                effectMethod.call( elem[0], args, done );
     1188            }
     1189        }
     1190
     1191        return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
     1192    },
     1193
     1194    show: (function( orig ) {
     1195        return function( option ) {
     1196            if ( standardAnimationOption( option ) ) {
     1197                return orig.apply( this, arguments );
     1198            } else {
     1199                var args = _normalizeArguments.apply( this, arguments );
     1200                args.mode = "show";
     1201                return this.effect.call( this, args );
     1202            }
     1203        };
     1204    })( $.fn.show ),
     1205
     1206    hide: (function( orig ) {
     1207        return function( option ) {
     1208            if ( standardAnimationOption( option ) ) {
     1209                return orig.apply( this, arguments );
     1210            } else {
     1211                var args = _normalizeArguments.apply( this, arguments );
     1212                args.mode = "hide";
     1213                return this.effect.call( this, args );
     1214            }
     1215        };
     1216    })( $.fn.hide ),
     1217
     1218    toggle: (function( orig ) {
     1219        return function( option ) {
     1220            if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
     1221                return orig.apply( this, arguments );
     1222            } else {
     1223                var args = _normalizeArguments.apply( this, arguments );
     1224                args.mode = "toggle";
     1225                return this.effect.call( this, args );
     1226            }
     1227        };
     1228    })( $.fn.toggle ),
     1229
     1230    // helper functions
     1231    cssUnit: function(key) {
     1232        var style = this.css( key ),
     1233            val = [];
     1234
     1235        $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
     1236            if ( style.indexOf( unit ) > 0 ) {
     1237                val = [ parseFloat( style ), unit ];
     1238            }
     1239        });
     1240        return val;
     1241    }
     1242});
     1243
     1244})();
     1245
     1246/******************************************************************************/
     1247/*********************************** EASING ***********************************/
     1248/******************************************************************************/
     1249
     1250(function() {
     1251
     1252// based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
     1253
     1254var baseEasings = {};
     1255
     1256$.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
     1257    baseEasings[ name ] = function( p ) {
     1258        return Math.pow( p, i + 2 );
     1259    };
     1260});
     1261
     1262$.extend( baseEasings, {
     1263    Sine: function( p ) {
     1264        return 1 - Math.cos( p * Math.PI / 2 );
     1265    },
     1266    Circ: function( p ) {
     1267        return 1 - Math.sqrt( 1 - p * p );
     1268    },
     1269    Elastic: function( p ) {
     1270        return p === 0 || p === 1 ? p :
     1271            -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
     1272    },
     1273    Back: function( p ) {
     1274        return p * p * ( 3 * p - 2 );
     1275    },
     1276    Bounce: function( p ) {
     1277        var pow2,
     1278            bounce = 4;
     1279
     1280        while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
     1281        return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
     1282    }
     1283});
     1284
     1285$.each( baseEasings, function( name, easeIn ) {
     1286    $.easing[ "easeIn" + name ] = easeIn;
     1287    $.easing[ "easeOut" + name ] = function( p ) {
     1288        return 1 - easeIn( 1 - p );
     1289    };
     1290    $.easing[ "easeInOut" + name ] = function( p ) {
     1291        return p < 0.5 ?
     1292            easeIn( p * 2 ) / 2 :
     1293            1 - easeIn( p * -2 + 2 ) / 2;
     1294    };
     1295});
     1296
     1297})();
     1298
     1299return $.effects;
     1300
     1301}));
  • trunk/src/wp-includes/js/jquery/ui/menu.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){t.widget("ui.menu",{version:"1.10.4",defaultElement:"<ul>",delay:300,options:{icons:{submenu:"ui-icon-carat-1-e"},menus:"ul",position:{my:"left top",at:"right top"},role:"menu",blur:null,focus:null,select:null},_create:function(){this.activeMenu=this.element,this.mouseHandled=!1,this.element.uniqueId().addClass("ui-menu ui-widget ui-widget-content ui-corner-all").toggleClass("ui-menu-icons",!!this.element.find(".ui-icon").length).attr({role:this.options.role,tabIndex:0}).bind("click"+this.eventNamespace,t.proxy(function(t){this.options.disabled&&t.preventDefault()},this)),this.options.disabled&&this.element.addClass("ui-state-disabled").attr("aria-disabled","true"),this._on({"mousedown .ui-menu-item > a":function(t){t.preventDefault()},"click .ui-state-disabled > a":function(t){t.preventDefault()},"click .ui-menu-item:has(a)":function(e){var i=t(e.target).closest(".ui-menu-item");!this.mouseHandled&&i.not(".ui-state-disabled").length&&(this.select(e),e.isPropagationStopped()||(this.mouseHandled=!0),i.has(".ui-menu").length?this.expand(e):!this.element.is(":focus")&&t(this.document[0].activeElement).closest(".ui-menu").length&&(this.element.trigger("focus",[!0]),this.active&&1===this.active.parents(".ui-menu").length&&clearTimeout(this.timer)))},"mouseenter .ui-menu-item":function(e){var i=t(e.currentTarget);i.siblings().children(".ui-state-active").removeClass("ui-state-active"),this.focus(e,i)},mouseleave:"collapseAll","mouseleave .ui-menu":"collapseAll",focus:function(t,e){var i=this.active||this.element.children(".ui-menu-item").eq(0);e||this.focus(t,i)},blur:function(e){this._delay(function(){t.contains(this.element[0],this.document[0].activeElement)||this.collapseAll(e)})},keydown:"_keydown"}),this.refresh(),this._on(this.document,{click:function(e){t(e.target).closest(".ui-menu").length||this.collapseAll(e),this.mouseHandled=!1}})},_destroy:function(){this.element.removeAttr("aria-activedescendant").find(".ui-menu").addBack().removeClass("ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons").removeAttr("role").removeAttr("tabIndex").removeAttr("aria-labelledby").removeAttr("aria-expanded").removeAttr("aria-hidden").removeAttr("aria-disabled").removeUniqueId().show(),this.element.find(".ui-menu-item").removeClass("ui-menu-item").removeAttr("role").removeAttr("aria-disabled").children("a").removeUniqueId().removeClass("ui-corner-all ui-state-hover").removeAttr("tabIndex").removeAttr("role").removeAttr("aria-haspopup").children().each(function(){var e=t(this);e.data("ui-menu-submenu-carat")&&e.remove()}),this.element.find(".ui-menu-divider").removeClass("ui-menu-divider ui-widget-content")},_keydown:function(e){function i(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}var s,n,a,o,r,h=!0;switch(e.keyCode){case t.ui.keyCode.PAGE_UP:this.previousPage(e);break;case t.ui.keyCode.PAGE_DOWN:this.nextPage(e);break;case t.ui.keyCode.HOME:this._move("first","first",e);break;case t.ui.keyCode.END:this._move("last","last",e);break;case t.ui.keyCode.UP:this.previous(e);break;case t.ui.keyCode.DOWN:this.next(e);break;case t.ui.keyCode.LEFT:this.collapse(e);break;case t.ui.keyCode.RIGHT:this.active&&!this.active.is(".ui-state-disabled")&&this.expand(e);break;case t.ui.keyCode.ENTER:case t.ui.keyCode.SPACE:this._activate(e);break;case t.ui.keyCode.ESCAPE:this.collapse(e);break;default:h=!1,n=this.previousFilter||"",a=String.fromCharCode(e.keyCode),o=!1,clearTimeout(this.filterTimer),a===n?o=!0:a=n+a,r=RegExp("^"+i(a),"i"),s=this.activeMenu.children(".ui-menu-item").filter(function(){return r.test(t(this).children("a").text())}),s=o&&-1!==s.index(this.active.next())?this.active.nextAll(".ui-menu-item"):s,s.length||(a=String.fromCharCode(e.keyCode),r=RegExp("^"+i(a),"i"),s=this.activeMenu.children(".ui-menu-item").filter(function(){return r.test(t(this).children("a").text())})),s.length?(this.focus(e,s),s.length>1?(this.previousFilter=a,this.filterTimer=this._delay(function(){delete this.previousFilter},1e3)):delete this.previousFilter):delete this.previousFilter}h&&e.preventDefault()},_activate:function(t){this.active.is(".ui-state-disabled")||(this.active.children("a[aria-haspopup='true']").length?this.expand(t):this.select(t))},refresh:function(){var e,i=this.options.icons.submenu,s=this.element.find(this.options.menus);this.element.toggleClass("ui-menu-icons",!!this.element.find(".ui-icon").length),s.filter(":not(.ui-menu)").addClass("ui-menu ui-widget ui-widget-content ui-corner-all").hide().attr({role:this.options.role,"aria-hidden":"true","aria-expanded":"false"}).each(function(){var e=t(this),s=e.prev("a"),n=t("<span>").addClass("ui-menu-icon ui-icon "+i).data("ui-menu-submenu-carat",!0);s.attr("aria-haspopup","true").prepend(n),e.attr("aria-labelledby",s.attr("id"))}),e=s.add(this.element),e.children(":not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","presentation").children("a").uniqueId().addClass("ui-corner-all").attr({tabIndex:-1,role:this._itemRole()}),e.children(":not(.ui-menu-item)").each(function(){var e=t(this);/[^\-\u2014\u2013\s]/.test(e.text())||e.addClass("ui-widget-content ui-menu-divider")}),e.children(".ui-state-disabled").attr("aria-disabled","true"),this.active&&!t.contains(this.element[0],this.active[0])&&this.blur()},_itemRole:function(){return{menu:"menuitem",listbox:"option"}[this.options.role]},_setOption:function(t,e){"icons"===t&&this.element.find(".ui-menu-icon").removeClass(this.options.icons.submenu).addClass(e.submenu),this._super(t,e)},focus:function(t,e){var i,s;this.blur(t,t&&"focus"===t.type),this._scrollIntoView(e),this.active=e.first(),s=this.active.children("a").addClass("ui-state-focus"),this.options.role&&this.element.attr("aria-activedescendant",s.attr("id")),this.active.parent().closest(".ui-menu-item").children("a:first").addClass("ui-state-active"),t&&"keydown"===t.type?this._close():this.timer=this._delay(function(){this._close()},this.delay),i=e.children(".ui-menu"),i.length&&t&&/^mouse/.test(t.type)&&this._startOpening(i),this.activeMenu=e.parent(),this._trigger("focus",t,{item:e})},_scrollIntoView:function(e){var i,s,n,a,o,r;this._hasScroll()&&(i=parseFloat(t.css(this.activeMenu[0],"borderTopWidth"))||0,s=parseFloat(t.css(this.activeMenu[0],"paddingTop"))||0,n=e.offset().top-this.activeMenu.offset().top-i-s,a=this.activeMenu.scrollTop(),o=this.activeMenu.height(),r=e.height(),0>n?this.activeMenu.scrollTop(a+n):n+r>o&&this.activeMenu.scrollTop(a+n-o+r))},blur:function(t,e){e||clearTimeout(this.timer),this.active&&(this.active.children("a").removeClass("ui-state-focus"),this.active=null,this._trigger("blur",t,{item:this.active}))},_startOpening:function(t){clearTimeout(this.timer),"true"===t.attr("aria-hidden")&&(this.timer=this._delay(function(){this._close(),this._open(t)},this.delay))},_open:function(e){var i=t.extend({of:this.active},this.options.position);clearTimeout(this.timer),this.element.find(".ui-menu").not(e.parents(".ui-menu")).hide().attr("aria-hidden","true"),e.show().removeAttr("aria-hidden").attr("aria-expanded","true").position(i)},collapseAll:function(e,i){clearTimeout(this.timer),this.timer=this._delay(function(){var s=i?this.element:t(e&&e.target).closest(this.element.find(".ui-menu"));s.length||(s=this.element),this._close(s),this.blur(e),this.activeMenu=s},this.delay)},_close:function(t){t||(t=this.active?this.active.parent():this.element),t.find(".ui-menu").hide().attr("aria-hidden","true").attr("aria-expanded","false").end().find("a.ui-state-active").removeClass("ui-state-active")},collapse:function(t){var e=this.active&&this.active.parent().closest(".ui-menu-item",this.element);e&&e.length&&(this._close(),this.focus(t,e))},expand:function(t){var e=this.active&&this.active.children(".ui-menu ").children(".ui-menu-item").first();e&&e.length&&(this._open(e.parent()),this._delay(function(){this.focus(t,e)}))},next:function(t){this._move("next","first",t)},previous:function(t){this._move("prev","last",t)},isFirstItem:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},isLastItem:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},_move:function(t,e,i){var s;this.active&&(s="first"===t||"last"===t?this.active["first"===t?"prevAll":"nextAll"](".ui-menu-item").eq(-1):this.active[t+"All"](".ui-menu-item").eq(0)),s&&s.length&&this.active||(s=this.activeMenu.children(".ui-menu-item")[e]()),this.focus(i,s)},nextPage:function(e){var i,s,n;return this.active?(this.isLastItem()||(this._hasScroll()?(s=this.active.offset().top,n=this.element.height(),this.active.nextAll(".ui-menu-item").each(function(){return i=t(this),0>i.offset().top-s-n}),this.focus(e,i)):this.focus(e,this.activeMenu.children(".ui-menu-item")[this.active?"last":"first"]())),undefined):(this.next(e),undefined)},previousPage:function(e){var i,s,n;return this.active?(this.isFirstItem()||(this._hasScroll()?(s=this.active.offset().top,n=this.element.height(),this.active.prevAll(".ui-menu-item").each(function(){return i=t(this),i.offset().top-s+n>0}),this.focus(e,i)):this.focus(e,this.activeMenu.children(".ui-menu-item").first())),undefined):(this.next(e),undefined)},_hasScroll:function(){return this.element.outerHeight()<this.element.prop("scrollHeight")},select:function(e){this.active=this.active||t(e.target).closest(".ui-menu-item");var i={item:this.active};this.active.has(".ui-menu").length||this.collapseAll(e,!0),this._trigger("select",e,i)}})})(jQuery);
     1/*!
     2 * jQuery UI Menu 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/menu/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./core",
     18            "./widget",
     19            "./position"
     20        ], factory );
     21    } else {
     22
     23        // Browser globals
     24        factory( jQuery );
     25    }
     26}(function( $ ) {
     27
     28return $.widget( "ui.menu", {
     29    version: "1.11.1",
     30    defaultElement: "<ul>",
     31    delay: 300,
     32    options: {
     33        icons: {
     34            submenu: "ui-icon-carat-1-e"
     35        },
     36        items: "> *",
     37        menus: "ul",
     38        position: {
     39            my: "left-1 top",
     40            at: "right top"
     41        },
     42        role: "menu",
     43
     44        // callbacks
     45        blur: null,
     46        focus: null,
     47        select: null
     48    },
     49
     50    _create: function() {
     51        this.activeMenu = this.element;
     52
     53        // Flag used to prevent firing of the click handler
     54        // as the event bubbles up through nested menus
     55        this.mouseHandled = false;
     56        this.element
     57            .uniqueId()
     58            .addClass( "ui-menu ui-widget ui-widget-content" )
     59            .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
     60            .attr({
     61                role: this.options.role,
     62                tabIndex: 0
     63            });
     64
     65        if ( this.options.disabled ) {
     66            this.element
     67                .addClass( "ui-state-disabled" )
     68                .attr( "aria-disabled", "true" );
     69        }
     70
     71        this._on({
     72            // Prevent focus from sticking to links inside menu after clicking
     73            // them (focus should always stay on UL during navigation).
     74            "mousedown .ui-menu-item": function( event ) {
     75                event.preventDefault();
     76            },
     77            "click .ui-menu-item": function( event ) {
     78                var target = $( event.target );
     79                if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
     80                    this.select( event );
     81
     82                    // Only set the mouseHandled flag if the event will bubble, see #9469.
     83                    if ( !event.isPropagationStopped() ) {
     84                        this.mouseHandled = true;
     85                    }
     86
     87                    // Open submenu on click
     88                    if ( target.has( ".ui-menu" ).length ) {
     89                        this.expand( event );
     90                    } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
     91
     92                        // Redirect focus to the menu
     93                        this.element.trigger( "focus", [ true ] );
     94
     95                        // If the active item is on the top level, let it stay active.
     96                        // Otherwise, blur the active item since it is no longer visible.
     97                        if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
     98                            clearTimeout( this.timer );
     99                        }
     100                    }
     101                }
     102            },
     103            "mouseenter .ui-menu-item": function( event ) {
     104                var target = $( event.currentTarget );
     105                // Remove ui-state-active class from siblings of the newly focused menu item
     106                // to avoid a jump caused by adjacent elements both having a class with a border
     107                target.siblings( ".ui-state-active" ).removeClass( "ui-state-active" );
     108                this.focus( event, target );
     109            },
     110            mouseleave: "collapseAll",
     111            "mouseleave .ui-menu": "collapseAll",
     112            focus: function( event, keepActiveItem ) {
     113                // If there's already an active item, keep it active
     114                // If not, activate the first item
     115                var item = this.active || this.element.find( this.options.items ).eq( 0 );
     116
     117                if ( !keepActiveItem ) {
     118                    this.focus( event, item );
     119                }
     120            },
     121            blur: function( event ) {
     122                this._delay(function() {
     123                    if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
     124                        this.collapseAll( event );
     125                    }
     126                });
     127            },
     128            keydown: "_keydown"
     129        });
     130
     131        this.refresh();
     132
     133        // Clicks outside of a menu collapse any open menus
     134        this._on( this.document, {
     135            click: function( event ) {
     136                if ( this._closeOnDocumentClick( event ) ) {
     137                    this.collapseAll( event );
     138                }
     139
     140                // Reset the mouseHandled flag
     141                this.mouseHandled = false;
     142            }
     143        });
     144    },
     145
     146    _destroy: function() {
     147        // Destroy (sub)menus
     148        this.element
     149            .removeAttr( "aria-activedescendant" )
     150            .find( ".ui-menu" ).addBack()
     151                .removeClass( "ui-menu ui-widget ui-widget-content ui-menu-icons ui-front" )
     152                .removeAttr( "role" )
     153                .removeAttr( "tabIndex" )
     154                .removeAttr( "aria-labelledby" )
     155                .removeAttr( "aria-expanded" )
     156                .removeAttr( "aria-hidden" )
     157                .removeAttr( "aria-disabled" )
     158                .removeUniqueId()
     159                .show();
     160
     161        // Destroy menu items
     162        this.element.find( ".ui-menu-item" )
     163            .removeClass( "ui-menu-item" )
     164            .removeAttr( "role" )
     165            .removeAttr( "aria-disabled" )
     166            .removeUniqueId()
     167            .removeClass( "ui-state-hover" )
     168            .removeAttr( "tabIndex" )
     169            .removeAttr( "role" )
     170            .removeAttr( "aria-haspopup" )
     171            .children().each( function() {
     172                var elem = $( this );
     173                if ( elem.data( "ui-menu-submenu-carat" ) ) {
     174                    elem.remove();
     175                }
     176            });
     177
     178        // Destroy menu dividers
     179        this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
     180    },
     181
     182    _keydown: function( event ) {
     183        var match, prev, character, skip, regex,
     184            preventDefault = true;
     185
     186        function escape( value ) {
     187            return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
     188        }
     189
     190        switch ( event.keyCode ) {
     191        case $.ui.keyCode.PAGE_UP:
     192            this.previousPage( event );
     193            break;
     194        case $.ui.keyCode.PAGE_DOWN:
     195            this.nextPage( event );
     196            break;
     197        case $.ui.keyCode.HOME:
     198            this._move( "first", "first", event );
     199            break;
     200        case $.ui.keyCode.END:
     201            this._move( "last", "last", event );
     202            break;
     203        case $.ui.keyCode.UP:
     204            this.previous( event );
     205            break;
     206        case $.ui.keyCode.DOWN:
     207            this.next( event );
     208            break;
     209        case $.ui.keyCode.LEFT:
     210            this.collapse( event );
     211            break;
     212        case $.ui.keyCode.RIGHT:
     213            if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
     214                this.expand( event );
     215            }
     216            break;
     217        case $.ui.keyCode.ENTER:
     218        case $.ui.keyCode.SPACE:
     219            this._activate( event );
     220            break;
     221        case $.ui.keyCode.ESCAPE:
     222            this.collapse( event );
     223            break;
     224        default:
     225            preventDefault = false;
     226            prev = this.previousFilter || "";
     227            character = String.fromCharCode( event.keyCode );
     228            skip = false;
     229
     230            clearTimeout( this.filterTimer );
     231
     232            if ( character === prev ) {
     233                skip = true;
     234            } else {
     235                character = prev + character;
     236            }
     237
     238            regex = new RegExp( "^" + escape( character ), "i" );
     239            match = this.activeMenu.find( this.options.items ).filter(function() {
     240                return regex.test( $( this ).text() );
     241            });
     242            match = skip && match.index( this.active.next() ) !== -1 ?
     243                this.active.nextAll( ".ui-menu-item" ) :
     244                match;
     245
     246            // If no matches on the current filter, reset to the last character pressed
     247            // to move down the menu to the first item that starts with that character
     248            if ( !match.length ) {
     249                character = String.fromCharCode( event.keyCode );
     250                regex = new RegExp( "^" + escape( character ), "i" );
     251                match = this.activeMenu.find( this.options.items ).filter(function() {
     252                    return regex.test( $( this ).text() );
     253                });
     254            }
     255
     256            if ( match.length ) {
     257                this.focus( event, match );
     258                if ( match.length > 1 ) {
     259                    this.previousFilter = character;
     260                    this.filterTimer = this._delay(function() {
     261                        delete this.previousFilter;
     262                    }, 1000 );
     263                } else {
     264                    delete this.previousFilter;
     265                }
     266            } else {
     267                delete this.previousFilter;
     268            }
     269        }
     270
     271        if ( preventDefault ) {
     272            event.preventDefault();
     273        }
     274    },
     275
     276    _activate: function( event ) {
     277        if ( !this.active.is( ".ui-state-disabled" ) ) {
     278            if ( this.active.is( "[aria-haspopup='true']" ) ) {
     279                this.expand( event );
     280            } else {
     281                this.select( event );
     282            }
     283        }
     284    },
     285
     286    refresh: function() {
     287        var menus, items,
     288            that = this,
     289            icon = this.options.icons.submenu,
     290            submenus = this.element.find( this.options.menus );
     291
     292        this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
     293
     294        // Initialize nested menus
     295        submenus.filter( ":not(.ui-menu)" )
     296            .addClass( "ui-menu ui-widget ui-widget-content ui-front" )
     297            .hide()
     298            .attr({
     299                role: this.options.role,
     300                "aria-hidden": "true",
     301                "aria-expanded": "false"
     302            })
     303            .each(function() {
     304                var menu = $( this ),
     305                    item = menu.parent(),
     306                    submenuCarat = $( "<span>" )
     307                        .addClass( "ui-menu-icon ui-icon " + icon )
     308                        .data( "ui-menu-submenu-carat", true );
     309
     310                item
     311                    .attr( "aria-haspopup", "true" )
     312                    .prepend( submenuCarat );
     313                menu.attr( "aria-labelledby", item.attr( "id" ) );
     314            });
     315
     316        menus = submenus.add( this.element );
     317        items = menus.find( this.options.items );
     318
     319        // Initialize menu-items containing spaces and/or dashes only as dividers
     320        items.not( ".ui-menu-item" ).each(function() {
     321            var item = $( this );
     322            if ( that._isDivider( item ) ) {
     323                item.addClass( "ui-widget-content ui-menu-divider" );
     324            }
     325        });
     326
     327        // Don't refresh list items that are already adapted
     328        items.not( ".ui-menu-item, .ui-menu-divider" )
     329            .addClass( "ui-menu-item" )
     330            .uniqueId()
     331            .attr({
     332                tabIndex: -1,
     333                role: this._itemRole()
     334            });
     335
     336        // Add aria-disabled attribute to any disabled menu item
     337        items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
     338
     339        // If the active item has been removed, blur the menu
     340        if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
     341            this.blur();
     342        }
     343    },
     344
     345    _itemRole: function() {
     346        return {
     347            menu: "menuitem",
     348            listbox: "option"
     349        }[ this.options.role ];
     350    },
     351
     352    _setOption: function( key, value ) {
     353        if ( key === "icons" ) {
     354            this.element.find( ".ui-menu-icon" )
     355                .removeClass( this.options.icons.submenu )
     356                .addClass( value.submenu );
     357        }
     358        if ( key === "disabled" ) {
     359            this.element
     360                .toggleClass( "ui-state-disabled", !!value )
     361                .attr( "aria-disabled", value );
     362        }
     363        this._super( key, value );
     364    },
     365
     366    focus: function( event, item ) {
     367        var nested, focused;
     368        this.blur( event, event && event.type === "focus" );
     369
     370        this._scrollIntoView( item );
     371
     372        this.active = item.first();
     373        focused = this.active.addClass( "ui-state-focus" ).removeClass( "ui-state-active" );
     374        // Only update aria-activedescendant if there's a role
     375        // otherwise we assume focus is managed elsewhere
     376        if ( this.options.role ) {
     377            this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
     378        }
     379
     380        // Highlight active parent menu item, if any
     381        this.active
     382            .parent()
     383            .closest( ".ui-menu-item" )
     384            .addClass( "ui-state-active" );
     385
     386        if ( event && event.type === "keydown" ) {
     387            this._close();
     388        } else {
     389            this.timer = this._delay(function() {
     390                this._close();
     391            }, this.delay );
     392        }
     393
     394        nested = item.children( ".ui-menu" );
     395        if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
     396            this._startOpening(nested);
     397        }
     398        this.activeMenu = item.parent();
     399
     400        this._trigger( "focus", event, { item: item } );
     401    },
     402
     403    _scrollIntoView: function( item ) {
     404        var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
     405        if ( this._hasScroll() ) {
     406            borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
     407            paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
     408            offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
     409            scroll = this.activeMenu.scrollTop();
     410            elementHeight = this.activeMenu.height();
     411            itemHeight = item.outerHeight();
     412
     413            if ( offset < 0 ) {
     414                this.activeMenu.scrollTop( scroll + offset );
     415            } else if ( offset + itemHeight > elementHeight ) {
     416                this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
     417            }
     418        }
     419    },
     420
     421    blur: function( event, fromFocus ) {
     422        if ( !fromFocus ) {
     423            clearTimeout( this.timer );
     424        }
     425
     426        if ( !this.active ) {
     427            return;
     428        }
     429
     430        this.active.removeClass( "ui-state-focus" );
     431        this.active = null;
     432
     433        this._trigger( "blur", event, { item: this.active } );
     434    },
     435
     436    _startOpening: function( submenu ) {
     437        clearTimeout( this.timer );
     438
     439        // Don't open if already open fixes a Firefox bug that caused a .5 pixel
     440        // shift in the submenu position when mousing over the carat icon
     441        if ( submenu.attr( "aria-hidden" ) !== "true" ) {
     442            return;
     443        }
     444
     445        this.timer = this._delay(function() {
     446            this._close();
     447            this._open( submenu );
     448        }, this.delay );
     449    },
     450
     451    _open: function( submenu ) {
     452        var position = $.extend({
     453            of: this.active
     454        }, this.options.position );
     455
     456        clearTimeout( this.timer );
     457        this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
     458            .hide()
     459            .attr( "aria-hidden", "true" );
     460
     461        submenu
     462            .show()
     463            .removeAttr( "aria-hidden" )
     464            .attr( "aria-expanded", "true" )
     465            .position( position );
     466    },
     467
     468    collapseAll: function( event, all ) {
     469        clearTimeout( this.timer );
     470        this.timer = this._delay(function() {
     471            // If we were passed an event, look for the submenu that contains the event
     472            var currentMenu = all ? this.element :
     473                $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
     474
     475            // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
     476            if ( !currentMenu.length ) {
     477                currentMenu = this.element;
     478            }
     479
     480            this._close( currentMenu );
     481
     482            this.blur( event );
     483            this.activeMenu = currentMenu;
     484        }, this.delay );
     485    },
     486
     487    // With no arguments, closes the currently active menu - if nothing is active
     488    // it closes all menus.  If passed an argument, it will search for menus BELOW
     489    _close: function( startMenu ) {
     490        if ( !startMenu ) {
     491            startMenu = this.active ? this.active.parent() : this.element;
     492        }
     493
     494        startMenu
     495            .find( ".ui-menu" )
     496                .hide()
     497                .attr( "aria-hidden", "true" )
     498                .attr( "aria-expanded", "false" )
     499            .end()
     500            .find( ".ui-state-active" ).not( ".ui-state-focus" )
     501                .removeClass( "ui-state-active" );
     502    },
     503
     504    _closeOnDocumentClick: function( event ) {
     505        return !$( event.target ).closest( ".ui-menu" ).length;
     506    },
     507
     508    _isDivider: function( item ) {
     509
     510        // Match hyphen, em dash, en dash
     511        return !/[^\-\u2014\u2013\s]/.test( item.text() );
     512    },
     513
     514    collapse: function( event ) {
     515        var newItem = this.active &&
     516            this.active.parent().closest( ".ui-menu-item", this.element );
     517        if ( newItem && newItem.length ) {
     518            this._close();
     519            this.focus( event, newItem );
     520        }
     521    },
     522
     523    expand: function( event ) {
     524        var newItem = this.active &&
     525            this.active
     526                .children( ".ui-menu " )
     527                .find( this.options.items )
     528                .first();
     529
     530        if ( newItem && newItem.length ) {
     531            this._open( newItem.parent() );
     532
     533            // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
     534            this._delay(function() {
     535                this.focus( event, newItem );
     536            });
     537        }
     538    },
     539
     540    next: function( event ) {
     541        this._move( "next", "first", event );
     542    },
     543
     544    previous: function( event ) {
     545        this._move( "prev", "last", event );
     546    },
     547
     548    isFirstItem: function() {
     549        return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
     550    },
     551
     552    isLastItem: function() {
     553        return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
     554    },
     555
     556    _move: function( direction, filter, event ) {
     557        var next;
     558        if ( this.active ) {
     559            if ( direction === "first" || direction === "last" ) {
     560                next = this.active
     561                    [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
     562                    .eq( -1 );
     563            } else {
     564                next = this.active
     565                    [ direction + "All" ]( ".ui-menu-item" )
     566                    .eq( 0 );
     567            }
     568        }
     569        if ( !next || !next.length || !this.active ) {
     570            next = this.activeMenu.find( this.options.items )[ filter ]();
     571        }
     572
     573        this.focus( event, next );
     574    },
     575
     576    nextPage: function( event ) {
     577        var item, base, height;
     578
     579        if ( !this.active ) {
     580            this.next( event );
     581            return;
     582        }
     583        if ( this.isLastItem() ) {
     584            return;
     585        }
     586        if ( this._hasScroll() ) {
     587            base = this.active.offset().top;
     588            height = this.element.height();
     589            this.active.nextAll( ".ui-menu-item" ).each(function() {
     590                item = $( this );
     591                return item.offset().top - base - height < 0;
     592            });
     593
     594            this.focus( event, item );
     595        } else {
     596            this.focus( event, this.activeMenu.find( this.options.items )
     597                [ !this.active ? "first" : "last" ]() );
     598        }
     599    },
     600
     601    previousPage: function( event ) {
     602        var item, base, height;
     603        if ( !this.active ) {
     604            this.next( event );
     605            return;
     606        }
     607        if ( this.isFirstItem() ) {
     608            return;
     609        }
     610        if ( this._hasScroll() ) {
     611            base = this.active.offset().top;
     612            height = this.element.height();
     613            this.active.prevAll( ".ui-menu-item" ).each(function() {
     614                item = $( this );
     615                return item.offset().top - base + height > 0;
     616            });
     617
     618            this.focus( event, item );
     619        } else {
     620            this.focus( event, this.activeMenu.find( this.options.items ).first() );
     621        }
     622    },
     623
     624    _hasScroll: function() {
     625        return this.element.outerHeight() < this.element.prop( "scrollHeight" );
     626    },
     627
     628    select: function( event ) {
     629        // TODO: It should never be possible to not have an active item at this
     630        // point, but the tests don't trigger mouseenter before click.
     631        this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
     632        var ui = { item: this.active };
     633        if ( !this.active.has( ".ui-menu" ).length ) {
     634            this.collapseAll( event, true );
     635        }
     636        this._trigger( "select", event, ui );
     637    }
     638});
     639
     640}));
  • trunk/src/wp-includes/js/jquery/ui/mouse.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(e){var t=!1;e(document).mouseup(function(){t=!1}),e.widget("ui.mouse",{version:"1.10.4",options:{cancel:"input,textarea,button,select,option",distance:1,delay:0},_mouseInit:function(){var t=this;this.element.bind("mousedown."+this.widgetName,function(e){return t._mouseDown(e)}).bind("click."+this.widgetName,function(i){return!0===e.data(i.target,t.widgetName+".preventClickEvent")?(e.removeData(i.target,t.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):undefined}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&e(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(i){if(!t){this._mouseStarted&&this._mouseUp(i),this._mouseDownEvent=i;var s=this,n=1===i.which,a="string"==typeof this.options.cancel&&i.target.nodeName?e(i.target).closest(this.options.cancel).length:!1;return n&&!a&&this._mouseCapture(i)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){s.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(i)&&this._mouseDelayMet(i)&&(this._mouseStarted=this._mouseStart(i)!==!1,!this._mouseStarted)?(i.preventDefault(),!0):(!0===e.data(i.target,this.widgetName+".preventClickEvent")&&e.removeData(i.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(e){return s._mouseMove(e)},this._mouseUpDelegate=function(e){return s._mouseUp(e)},e(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),i.preventDefault(),t=!0,!0)):!0}},_mouseMove:function(t){return e.ui.ie&&(!document.documentMode||9>document.documentMode)&&!t.button?this._mouseUp(t):this._mouseStarted?(this._mouseDrag(t),t.preventDefault()):(this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,t)!==!1,this._mouseStarted?this._mouseDrag(t):this._mouseUp(t)),!this._mouseStarted)},_mouseUp:function(t){return e(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,t.target===this._mouseDownEvent.target&&e.data(t.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(t)),!1},_mouseDistanceMet:function(e){return Math.max(Math.abs(this._mouseDownEvent.pageX-e.pageX),Math.abs(this._mouseDownEvent.pageY-e.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}})})(jQuery);
     1/*!
     2 * jQuery UI Mouse 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/mouse/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./widget"
     18        ], factory );
     19    } else {
     20
     21        // Browser globals
     22        factory( jQuery );
     23    }
     24}(function( $ ) {
     25
     26var mouseHandled = false;
     27$( document ).mouseup( function() {
     28    mouseHandled = false;
     29});
     30
     31return $.widget("ui.mouse", {
     32    version: "1.11.1",
     33    options: {
     34        cancel: "input,textarea,button,select,option",
     35        distance: 1,
     36        delay: 0
     37    },
     38    _mouseInit: function() {
     39        var that = this;
     40
     41        this.element
     42            .bind("mousedown." + this.widgetName, function(event) {
     43                return that._mouseDown(event);
     44            })
     45            .bind("click." + this.widgetName, function(event) {
     46                if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
     47                    $.removeData(event.target, that.widgetName + ".preventClickEvent");
     48                    event.stopImmediatePropagation();
     49                    return false;
     50                }
     51            });
     52
     53        this.started = false;
     54    },
     55
     56    // TODO: make sure destroying one instance of mouse doesn't mess with
     57    // other instances of mouse
     58    _mouseDestroy: function() {
     59        this.element.unbind("." + this.widgetName);
     60        if ( this._mouseMoveDelegate ) {
     61            this.document
     62                .unbind("mousemove." + this.widgetName, this._mouseMoveDelegate)
     63                .unbind("mouseup." + this.widgetName, this._mouseUpDelegate);
     64        }
     65    },
     66
     67    _mouseDown: function(event) {
     68        // don't let more than one widget handle mouseStart
     69        if ( mouseHandled ) {
     70            return;
     71        }
     72
     73        // we may have missed mouseup (out of window)
     74        (this._mouseStarted && this._mouseUp(event));
     75
     76        this._mouseDownEvent = event;
     77
     78        var that = this,
     79            btnIsLeft = (event.which === 1),
     80            // event.target.nodeName works around a bug in IE 8 with
     81            // disabled inputs (#7620)
     82            elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
     83        if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
     84            return true;
     85        }
     86
     87        this.mouseDelayMet = !this.options.delay;
     88        if (!this.mouseDelayMet) {
     89            this._mouseDelayTimer = setTimeout(function() {
     90                that.mouseDelayMet = true;
     91            }, this.options.delay);
     92        }
     93
     94        if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
     95            this._mouseStarted = (this._mouseStart(event) !== false);
     96            if (!this._mouseStarted) {
     97                event.preventDefault();
     98                return true;
     99            }
     100        }
     101
     102        // Click event may never have fired (Gecko & Opera)
     103        if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
     104            $.removeData(event.target, this.widgetName + ".preventClickEvent");
     105        }
     106
     107        // these delegates are required to keep context
     108        this._mouseMoveDelegate = function(event) {
     109            return that._mouseMove(event);
     110        };
     111        this._mouseUpDelegate = function(event) {
     112            return that._mouseUp(event);
     113        };
     114
     115        this.document
     116            .bind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
     117            .bind( "mouseup." + this.widgetName, this._mouseUpDelegate );
     118
     119        event.preventDefault();
     120
     121        mouseHandled = true;
     122        return true;
     123    },
     124
     125    _mouseMove: function(event) {
     126        // IE mouseup check - mouseup happened when mouse was out of window
     127        if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
     128            return this._mouseUp(event);
     129
     130        // Iframe mouseup check - mouseup occurred in another document
     131        } else if ( !event.which ) {
     132            return this._mouseUp( event );
     133        }
     134
     135        if (this._mouseStarted) {
     136            this._mouseDrag(event);
     137            return event.preventDefault();
     138        }
     139
     140        if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
     141            this._mouseStarted =
     142                (this._mouseStart(this._mouseDownEvent, event) !== false);
     143            (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
     144        }
     145
     146        return !this._mouseStarted;
     147    },
     148
     149    _mouseUp: function(event) {
     150        this.document
     151            .unbind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
     152            .unbind( "mouseup." + this.widgetName, this._mouseUpDelegate );
     153
     154        if (this._mouseStarted) {
     155            this._mouseStarted = false;
     156
     157            if (event.target === this._mouseDownEvent.target) {
     158                $.data(event.target, this.widgetName + ".preventClickEvent", true);
     159            }
     160
     161            this._mouseStop(event);
     162        }
     163
     164        mouseHandled = false;
     165        return false;
     166    },
     167
     168    _mouseDistanceMet: function(event) {
     169        return (Math.max(
     170                Math.abs(this._mouseDownEvent.pageX - event.pageX),
     171                Math.abs(this._mouseDownEvent.pageY - event.pageY)
     172            ) >= this.options.distance
     173        );
     174    },
     175
     176    _mouseDelayMet: function(/* event */) {
     177        return this.mouseDelayMet;
     178    },
     179
     180    // These are placeholder methods, to be overriden by extending plugin
     181    _mouseStart: function(/* event */) {},
     182    _mouseDrag: function(/* event */) {},
     183    _mouseStop: function(/* event */) {},
     184    _mouseCapture: function(/* event */) { return true; }
     185});
     186
     187}));
  • trunk/src/wp-includes/js/jquery/ui/position.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t,e){function i(t,e,i){return[parseFloat(t[0])*(p.test(t[0])?e/100:1),parseFloat(t[1])*(p.test(t[1])?i/100:1)]}function s(e,i){return parseInt(t.css(e,i),10)||0}function n(e){var i=e[0];return 9===i.nodeType?{width:e.width(),height:e.height(),offset:{top:0,left:0}}:t.isWindow(i)?{width:e.width(),height:e.height(),offset:{top:e.scrollTop(),left:e.scrollLeft()}}:i.preventDefault?{width:0,height:0,offset:{top:i.pageY,left:i.pageX}}:{width:e.outerWidth(),height:e.outerHeight(),offset:e.offset()}}t.ui=t.ui||{};var a,o=Math.max,r=Math.abs,h=Math.round,l=/left|center|right/,c=/top|center|bottom/,u=/[\+\-]\d+(\.[\d]+)?%?/,d=/^\w+/,p=/%$/,f=t.fn.position;t.position={scrollbarWidth:function(){if(a!==e)return a;var i,s,n=t("<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>"),o=n.children()[0];return t("body").append(n),i=o.offsetWidth,n.css("overflow","scroll"),s=o.offsetWidth,i===s&&(s=n[0].clientWidth),n.remove(),a=i-s},getScrollInfo:function(e){var i=e.isWindow||e.isDocument?"":e.element.css("overflow-x"),s=e.isWindow||e.isDocument?"":e.element.css("overflow-y"),n="scroll"===i||"auto"===i&&e.width<e.element[0].scrollWidth,a="scroll"===s||"auto"===s&&e.height<e.element[0].scrollHeight;return{width:a?t.position.scrollbarWidth():0,height:n?t.position.scrollbarWidth():0}},getWithinInfo:function(e){var i=t(e||window),s=t.isWindow(i[0]),n=!!i[0]&&9===i[0].nodeType;return{element:i,isWindow:s,isDocument:n,offset:i.offset()||{left:0,top:0},scrollLeft:i.scrollLeft(),scrollTop:i.scrollTop(),width:s?i.width():i.outerWidth(),height:s?i.height():i.outerHeight()}}},t.fn.position=function(e){if(!e||!e.of)return f.apply(this,arguments);e=t.extend({},e);var a,p,m,g,v,b,_=t(e.of),y=t.position.getWithinInfo(e.within),w=t.position.getScrollInfo(y),x=(e.collision||"flip").split(" "),k={};return b=n(_),_[0].preventDefault&&(e.at="left top"),p=b.width,m=b.height,g=b.offset,v=t.extend({},g),t.each(["my","at"],function(){var t,i,s=(e[this]||"").split(" ");1===s.length&&(s=l.test(s[0])?s.concat(["center"]):c.test(s[0])?["center"].concat(s):["center","center"]),s[0]=l.test(s[0])?s[0]:"center",s[1]=c.test(s[1])?s[1]:"center",t=u.exec(s[0]),i=u.exec(s[1]),k[this]=[t?t[0]:0,i?i[0]:0],e[this]=[d.exec(s[0])[0],d.exec(s[1])[0]]}),1===x.length&&(x[1]=x[0]),"right"===e.at[0]?v.left+=p:"center"===e.at[0]&&(v.left+=p/2),"bottom"===e.at[1]?v.top+=m:"center"===e.at[1]&&(v.top+=m/2),a=i(k.at,p,m),v.left+=a[0],v.top+=a[1],this.each(function(){var n,l,c=t(this),u=c.outerWidth(),d=c.outerHeight(),f=s(this,"marginLeft"),b=s(this,"marginTop"),D=u+f+s(this,"marginRight")+w.width,T=d+b+s(this,"marginBottom")+w.height,C=t.extend({},v),M=i(k.my,c.outerWidth(),c.outerHeight());"right"===e.my[0]?C.left-=u:"center"===e.my[0]&&(C.left-=u/2),"bottom"===e.my[1]?C.top-=d:"center"===e.my[1]&&(C.top-=d/2),C.left+=M[0],C.top+=M[1],t.support.offsetFractions||(C.left=h(C.left),C.top=h(C.top)),n={marginLeft:f,marginTop:b},t.each(["left","top"],function(i,s){t.ui.position[x[i]]&&t.ui.position[x[i]][s](C,{targetWidth:p,targetHeight:m,elemWidth:u,elemHeight:d,collisionPosition:n,collisionWidth:D,collisionHeight:T,offset:[a[0]+M[0],a[1]+M[1]],my:e.my,at:e.at,within:y,elem:c})}),e.using&&(l=function(t){var i=g.left-C.left,s=i+p-u,n=g.top-C.top,a=n+m-d,h={target:{element:_,left:g.left,top:g.top,width:p,height:m},element:{element:c,left:C.left,top:C.top,width:u,height:d},horizontal:0>s?"left":i>0?"right":"center",vertical:0>a?"top":n>0?"bottom":"middle"};u>p&&p>r(i+s)&&(h.horizontal="center"),d>m&&m>r(n+a)&&(h.vertical="middle"),h.important=o(r(i),r(s))>o(r(n),r(a))?"horizontal":"vertical",e.using.call(this,t,h)}),c.offset(t.extend(C,{using:l}))})},t.ui.position={fit:{left:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollLeft:s.offset.left,a=s.width,r=t.left-e.collisionPosition.marginLeft,h=n-r,l=r+e.collisionWidth-a-n;e.collisionWidth>a?h>0&&0>=l?(i=t.left+h+e.collisionWidth-a-n,t.left+=h-i):t.left=l>0&&0>=h?n:h>l?n+a-e.collisionWidth:n:h>0?t.left+=h:l>0?t.left-=l:t.left=o(t.left-r,t.left)},top:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollTop:s.offset.top,a=e.within.height,r=t.top-e.collisionPosition.marginTop,h=n-r,l=r+e.collisionHeight-a-n;e.collisionHeight>a?h>0&&0>=l?(i=t.top+h+e.collisionHeight-a-n,t.top+=h-i):t.top=l>0&&0>=h?n:h>l?n+a-e.collisionHeight:n:h>0?t.top+=h:l>0?t.top-=l:t.top=o(t.top-r,t.top)}},flip:{left:function(t,e){var i,s,n=e.within,a=n.offset.left+n.scrollLeft,o=n.width,h=n.isWindow?n.scrollLeft:n.offset.left,l=t.left-e.collisionPosition.marginLeft,c=l-h,u=l+e.collisionWidth-o-h,d="left"===e.my[0]?-e.elemWidth:"right"===e.my[0]?e.elemWidth:0,p="left"===e.at[0]?e.targetWidth:"right"===e.at[0]?-e.targetWidth:0,f=-2*e.offset[0];0>c?(i=t.left+d+p+f+e.collisionWidth-o-a,(0>i||r(c)>i)&&(t.left+=d+p+f)):u>0&&(s=t.left-e.collisionPosition.marginLeft+d+p+f-h,(s>0||u>r(s))&&(t.left+=d+p+f))},top:function(t,e){var i,s,n=e.within,a=n.offset.top+n.scrollTop,o=n.height,h=n.isWindow?n.scrollTop:n.offset.top,l=t.top-e.collisionPosition.marginTop,c=l-h,u=l+e.collisionHeight-o-h,d="top"===e.my[1],p=d?-e.elemHeight:"bottom"===e.my[1]?e.elemHeight:0,f="top"===e.at[1]?e.targetHeight:"bottom"===e.at[1]?-e.targetHeight:0,m=-2*e.offset[1];0>c?(s=t.top+p+f+m+e.collisionHeight-o-a,t.top+p+f+m>c&&(0>s||r(c)>s)&&(t.top+=p+f+m)):u>0&&(i=t.top-e.collisionPosition.marginTop+p+f+m-h,t.top+p+f+m>u&&(i>0||u>r(i))&&(t.top+=p+f+m))}},flipfit:{left:function(){t.ui.position.flip.left.apply(this,arguments),t.ui.position.fit.left.apply(this,arguments)},top:function(){t.ui.position.flip.top.apply(this,arguments),t.ui.position.fit.top.apply(this,arguments)}}},function(){var e,i,s,n,a,o=document.getElementsByTagName("body")[0],r=document.createElement("div");e=document.createElement(o?"div":"body"),s={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},o&&t.extend(s,{position:"absolute",left:"-1000px",top:"-1000px"});for(a in s)e.style[a]=s[a];e.appendChild(r),i=o||document.documentElement,i.insertBefore(e,i.firstChild),r.style.cssText="position: absolute; left: 10.7432222px;",n=t(r).offset().left,t.support.offsetFractions=n>10&&11>n,e.innerHTML="",i.removeChild(e)}()})(jQuery);
     1/*!
     2 * jQuery UI Position 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/position/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define( [ "jquery" ], factory );
     16    } else {
     17
     18        // Browser globals
     19        factory( jQuery );
     20    }
     21}(function( $ ) {
     22(function() {
     23
     24$.ui = $.ui || {};
     25
     26var cachedScrollbarWidth, supportsOffsetFractions,
     27    max = Math.max,
     28    abs = Math.abs,
     29    round = Math.round,
     30    rhorizontal = /left|center|right/,
     31    rvertical = /top|center|bottom/,
     32    roffset = /[\+\-]\d+(\.[\d]+)?%?/,
     33    rposition = /^\w+/,
     34    rpercent = /%$/,
     35    _position = $.fn.position;
     36
     37function getOffsets( offsets, width, height ) {
     38    return [
     39        parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
     40        parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
     41    ];
     42}
     43
     44function parseCss( element, property ) {
     45    return parseInt( $.css( element, property ), 10 ) || 0;
     46}
     47
     48function getDimensions( elem ) {
     49    var raw = elem[0];
     50    if ( raw.nodeType === 9 ) {
     51        return {
     52            width: elem.width(),
     53            height: elem.height(),
     54            offset: { top: 0, left: 0 }
     55        };
     56    }
     57    if ( $.isWindow( raw ) ) {
     58        return {
     59            width: elem.width(),
     60            height: elem.height(),
     61            offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
     62        };
     63    }
     64    if ( raw.preventDefault ) {
     65        return {
     66            width: 0,
     67            height: 0,
     68            offset: { top: raw.pageY, left: raw.pageX }
     69        };
     70    }
     71    return {
     72        width: elem.outerWidth(),
     73        height: elem.outerHeight(),
     74        offset: elem.offset()
     75    };
     76}
     77
     78$.position = {
     79    scrollbarWidth: function() {
     80        if ( cachedScrollbarWidth !== undefined ) {
     81            return cachedScrollbarWidth;
     82        }
     83        var w1, w2,
     84            div = $( "<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
     85            innerDiv = div.children()[0];
     86
     87        $( "body" ).append( div );
     88        w1 = innerDiv.offsetWidth;
     89        div.css( "overflow", "scroll" );
     90
     91        w2 = innerDiv.offsetWidth;
     92
     93        if ( w1 === w2 ) {
     94            w2 = div[0].clientWidth;
     95        }
     96
     97        div.remove();
     98
     99        return (cachedScrollbarWidth = w1 - w2);
     100    },
     101    getScrollInfo: function( within ) {
     102        var overflowX = within.isWindow || within.isDocument ? "" :
     103                within.element.css( "overflow-x" ),
     104            overflowY = within.isWindow || within.isDocument ? "" :
     105                within.element.css( "overflow-y" ),
     106            hasOverflowX = overflowX === "scroll" ||
     107                ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
     108            hasOverflowY = overflowY === "scroll" ||
     109                ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
     110        return {
     111            width: hasOverflowY ? $.position.scrollbarWidth() : 0,
     112            height: hasOverflowX ? $.position.scrollbarWidth() : 0
     113        };
     114    },
     115    getWithinInfo: function( element ) {
     116        var withinElement = $( element || window ),
     117            isWindow = $.isWindow( withinElement[0] ),
     118            isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
     119        return {
     120            element: withinElement,
     121            isWindow: isWindow,
     122            isDocument: isDocument,
     123            offset: withinElement.offset() || { left: 0, top: 0 },
     124            scrollLeft: withinElement.scrollLeft(),
     125            scrollTop: withinElement.scrollTop(),
     126
     127            // support: jQuery 1.6.x
     128            // jQuery 1.6 doesn't support .outerWidth/Height() on documents or windows
     129            width: isWindow || isDocument ? withinElement.width() : withinElement.outerWidth(),
     130            height: isWindow || isDocument ? withinElement.height() : withinElement.outerHeight()
     131        };
     132    }
     133};
     134
     135$.fn.position = function( options ) {
     136    if ( !options || !options.of ) {
     137        return _position.apply( this, arguments );
     138    }
     139
     140    // make a copy, we don't want to modify arguments
     141    options = $.extend( {}, options );
     142
     143    var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
     144        target = $( options.of ),
     145        within = $.position.getWithinInfo( options.within ),
     146        scrollInfo = $.position.getScrollInfo( within ),
     147        collision = ( options.collision || "flip" ).split( " " ),
     148        offsets = {};
     149
     150    dimensions = getDimensions( target );
     151    if ( target[0].preventDefault ) {
     152        // force left top to allow flipping
     153        options.at = "left top";
     154    }
     155    targetWidth = dimensions.width;
     156    targetHeight = dimensions.height;
     157    targetOffset = dimensions.offset;
     158    // clone to reuse original targetOffset later
     159    basePosition = $.extend( {}, targetOffset );
     160
     161    // force my and at to have valid horizontal and vertical positions
     162    // if a value is missing or invalid, it will be converted to center
     163    $.each( [ "my", "at" ], function() {
     164        var pos = ( options[ this ] || "" ).split( " " ),
     165            horizontalOffset,
     166            verticalOffset;
     167
     168        if ( pos.length === 1) {
     169            pos = rhorizontal.test( pos[ 0 ] ) ?
     170                pos.concat( [ "center" ] ) :
     171                rvertical.test( pos[ 0 ] ) ?
     172                    [ "center" ].concat( pos ) :
     173                    [ "center", "center" ];
     174        }
     175        pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
     176        pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
     177
     178        // calculate offsets
     179        horizontalOffset = roffset.exec( pos[ 0 ] );
     180        verticalOffset = roffset.exec( pos[ 1 ] );
     181        offsets[ this ] = [
     182            horizontalOffset ? horizontalOffset[ 0 ] : 0,
     183            verticalOffset ? verticalOffset[ 0 ] : 0
     184        ];
     185
     186        // reduce to just the positions without the offsets
     187        options[ this ] = [
     188            rposition.exec( pos[ 0 ] )[ 0 ],
     189            rposition.exec( pos[ 1 ] )[ 0 ]
     190        ];
     191    });
     192
     193    // normalize collision option
     194    if ( collision.length === 1 ) {
     195        collision[ 1 ] = collision[ 0 ];
     196    }
     197
     198    if ( options.at[ 0 ] === "right" ) {
     199        basePosition.left += targetWidth;
     200    } else if ( options.at[ 0 ] === "center" ) {
     201        basePosition.left += targetWidth / 2;
     202    }
     203
     204    if ( options.at[ 1 ] === "bottom" ) {
     205        basePosition.top += targetHeight;
     206    } else if ( options.at[ 1 ] === "center" ) {
     207        basePosition.top += targetHeight / 2;
     208    }
     209
     210    atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
     211    basePosition.left += atOffset[ 0 ];
     212    basePosition.top += atOffset[ 1 ];
     213
     214    return this.each(function() {
     215        var collisionPosition, using,
     216            elem = $( this ),
     217            elemWidth = elem.outerWidth(),
     218            elemHeight = elem.outerHeight(),
     219            marginLeft = parseCss( this, "marginLeft" ),
     220            marginTop = parseCss( this, "marginTop" ),
     221            collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
     222            collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
     223            position = $.extend( {}, basePosition ),
     224            myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
     225
     226        if ( options.my[ 0 ] === "right" ) {
     227            position.left -= elemWidth;
     228        } else if ( options.my[ 0 ] === "center" ) {
     229            position.left -= elemWidth / 2;
     230        }
     231
     232        if ( options.my[ 1 ] === "bottom" ) {
     233            position.top -= elemHeight;
     234        } else if ( options.my[ 1 ] === "center" ) {
     235            position.top -= elemHeight / 2;
     236        }
     237
     238        position.left += myOffset[ 0 ];
     239        position.top += myOffset[ 1 ];
     240
     241        // if the browser doesn't support fractions, then round for consistent results
     242        if ( !supportsOffsetFractions ) {
     243            position.left = round( position.left );
     244            position.top = round( position.top );
     245        }
     246
     247        collisionPosition = {
     248            marginLeft: marginLeft,
     249            marginTop: marginTop
     250        };
     251
     252        $.each( [ "left", "top" ], function( i, dir ) {
     253            if ( $.ui.position[ collision[ i ] ] ) {
     254                $.ui.position[ collision[ i ] ][ dir ]( position, {
     255                    targetWidth: targetWidth,
     256                    targetHeight: targetHeight,
     257                    elemWidth: elemWidth,
     258                    elemHeight: elemHeight,
     259                    collisionPosition: collisionPosition,
     260                    collisionWidth: collisionWidth,
     261                    collisionHeight: collisionHeight,
     262                    offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
     263                    my: options.my,
     264                    at: options.at,
     265                    within: within,
     266                    elem: elem
     267                });
     268            }
     269        });
     270
     271        if ( options.using ) {
     272            // adds feedback as second argument to using callback, if present
     273            using = function( props ) {
     274                var left = targetOffset.left - position.left,
     275                    right = left + targetWidth - elemWidth,
     276                    top = targetOffset.top - position.top,
     277                    bottom = top + targetHeight - elemHeight,
     278                    feedback = {
     279                        target: {
     280                            element: target,
     281                            left: targetOffset.left,
     282                            top: targetOffset.top,
     283                            width: targetWidth,
     284                            height: targetHeight
     285                        },
     286                        element: {
     287                            element: elem,
     288                            left: position.left,
     289                            top: position.top,
     290                            width: elemWidth,
     291                            height: elemHeight
     292                        },
     293                        horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
     294                        vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
     295                    };
     296                if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
     297                    feedback.horizontal = "center";
     298                }
     299                if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
     300                    feedback.vertical = "middle";
     301                }
     302                if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
     303                    feedback.important = "horizontal";
     304                } else {
     305                    feedback.important = "vertical";
     306                }
     307                options.using.call( this, props, feedback );
     308            };
     309        }
     310
     311        elem.offset( $.extend( position, { using: using } ) );
     312    });
     313};
     314
     315$.ui.position = {
     316    fit: {
     317        left: function( position, data ) {
     318            var within = data.within,
     319                withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
     320                outerWidth = within.width,
     321                collisionPosLeft = position.left - data.collisionPosition.marginLeft,
     322                overLeft = withinOffset - collisionPosLeft,
     323                overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
     324                newOverRight;
     325
     326            // element is wider than within
     327            if ( data.collisionWidth > outerWidth ) {
     328                // element is initially over the left side of within
     329                if ( overLeft > 0 && overRight <= 0 ) {
     330                    newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
     331                    position.left += overLeft - newOverRight;
     332                // element is initially over right side of within
     333                } else if ( overRight > 0 && overLeft <= 0 ) {
     334                    position.left = withinOffset;
     335                // element is initially over both left and right sides of within
     336                } else {
     337                    if ( overLeft > overRight ) {
     338                        position.left = withinOffset + outerWidth - data.collisionWidth;
     339                    } else {
     340                        position.left = withinOffset;
     341                    }
     342                }
     343            // too far left -> align with left edge
     344            } else if ( overLeft > 0 ) {
     345                position.left += overLeft;
     346            // too far right -> align with right edge
     347            } else if ( overRight > 0 ) {
     348                position.left -= overRight;
     349            // adjust based on position and margin
     350            } else {
     351                position.left = max( position.left - collisionPosLeft, position.left );
     352            }
     353        },
     354        top: function( position, data ) {
     355            var within = data.within,
     356                withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
     357                outerHeight = data.within.height,
     358                collisionPosTop = position.top - data.collisionPosition.marginTop,
     359                overTop = withinOffset - collisionPosTop,
     360                overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
     361                newOverBottom;
     362
     363            // element is taller than within
     364            if ( data.collisionHeight > outerHeight ) {
     365                // element is initially over the top of within
     366                if ( overTop > 0 && overBottom <= 0 ) {
     367                    newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
     368                    position.top += overTop - newOverBottom;
     369                // element is initially over bottom of within
     370                } else if ( overBottom > 0 && overTop <= 0 ) {
     371                    position.top = withinOffset;
     372                // element is initially over both top and bottom of within
     373                } else {
     374                    if ( overTop > overBottom ) {
     375                        position.top = withinOffset + outerHeight - data.collisionHeight;
     376                    } else {
     377                        position.top = withinOffset;
     378                    }
     379                }
     380            // too far up -> align with top
     381            } else if ( overTop > 0 ) {
     382                position.top += overTop;
     383            // too far down -> align with bottom edge
     384            } else if ( overBottom > 0 ) {
     385                position.top -= overBottom;
     386            // adjust based on position and margin
     387            } else {
     388                position.top = max( position.top - collisionPosTop, position.top );
     389            }
     390        }
     391    },
     392    flip: {
     393        left: function( position, data ) {
     394            var within = data.within,
     395                withinOffset = within.offset.left + within.scrollLeft,
     396                outerWidth = within.width,
     397                offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
     398                collisionPosLeft = position.left - data.collisionPosition.marginLeft,
     399                overLeft = collisionPosLeft - offsetLeft,
     400                overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
     401                myOffset = data.my[ 0 ] === "left" ?
     402                    -data.elemWidth :
     403                    data.my[ 0 ] === "right" ?
     404                        data.elemWidth :
     405                        0,
     406                atOffset = data.at[ 0 ] === "left" ?
     407                    data.targetWidth :
     408                    data.at[ 0 ] === "right" ?
     409                        -data.targetWidth :
     410                        0,
     411                offset = -2 * data.offset[ 0 ],
     412                newOverRight,
     413                newOverLeft;
     414
     415            if ( overLeft < 0 ) {
     416                newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
     417                if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
     418                    position.left += myOffset + atOffset + offset;
     419                }
     420            } else if ( overRight > 0 ) {
     421                newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
     422                if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
     423                    position.left += myOffset + atOffset + offset;
     424                }
     425            }
     426        },
     427        top: function( position, data ) {
     428            var within = data.within,
     429                withinOffset = within.offset.top + within.scrollTop,
     430                outerHeight = within.height,
     431                offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
     432                collisionPosTop = position.top - data.collisionPosition.marginTop,
     433                overTop = collisionPosTop - offsetTop,
     434                overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
     435                top = data.my[ 1 ] === "top",
     436                myOffset = top ?
     437                    -data.elemHeight :
     438                    data.my[ 1 ] === "bottom" ?
     439                        data.elemHeight :
     440                        0,
     441                atOffset = data.at[ 1 ] === "top" ?
     442                    data.targetHeight :
     443                    data.at[ 1 ] === "bottom" ?
     444                        -data.targetHeight :
     445                        0,
     446                offset = -2 * data.offset[ 1 ],
     447                newOverTop,
     448                newOverBottom;
     449            if ( overTop < 0 ) {
     450                newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
     451                if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
     452                    position.top += myOffset + atOffset + offset;
     453                }
     454            } else if ( overBottom > 0 ) {
     455                newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
     456                if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
     457                    position.top += myOffset + atOffset + offset;
     458                }
     459            }
     460        }
     461    },
     462    flipfit: {
     463        left: function() {
     464            $.ui.position.flip.left.apply( this, arguments );
     465            $.ui.position.fit.left.apply( this, arguments );
     466        },
     467        top: function() {
     468            $.ui.position.flip.top.apply( this, arguments );
     469            $.ui.position.fit.top.apply( this, arguments );
     470        }
     471    }
     472};
     473
     474// fraction support test
     475(function() {
     476    var testElement, testElementParent, testElementStyle, offsetLeft, i,
     477        body = document.getElementsByTagName( "body" )[ 0 ],
     478        div = document.createElement( "div" );
     479
     480    //Create a "fake body" for testing based on method used in jQuery.support
     481    testElement = document.createElement( body ? "div" : "body" );
     482    testElementStyle = {
     483        visibility: "hidden",
     484        width: 0,
     485        height: 0,
     486        border: 0,
     487        margin: 0,
     488        background: "none"
     489    };
     490    if ( body ) {
     491        $.extend( testElementStyle, {
     492            position: "absolute",
     493            left: "-1000px",
     494            top: "-1000px"
     495        });
     496    }
     497    for ( i in testElementStyle ) {
     498        testElement.style[ i ] = testElementStyle[ i ];
     499    }
     500    testElement.appendChild( div );
     501    testElementParent = body || document.documentElement;
     502    testElementParent.insertBefore( testElement, testElementParent.firstChild );
     503
     504    div.style.cssText = "position: absolute; left: 10.7432222px;";
     505
     506    offsetLeft = $( div ).offset().left;
     507    supportsOffsetFractions = offsetLeft > 10 && offsetLeft < 11;
     508
     509    testElement.innerHTML = "";
     510    testElementParent.removeChild( testElement );
     511})();
     512
     513})();
     514
     515return $.ui.position;
     516
     517}));
  • trunk/src/wp-includes/js/jquery/ui/progressbar.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t,e){t.widget("ui.progressbar",{version:"1.10.4",options:{max:100,value:0,change:null,complete:null},min:0,_create:function(){this.oldValue=this.options.value=this._constrainedValue(),this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min}),this.valueDiv=t("<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>").appendTo(this.element),this._refreshValue()},_destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"),this.valueDiv.remove()},value:function(t){return t===e?this.options.value:(this.options.value=this._constrainedValue(t),this._refreshValue(),e)},_constrainedValue:function(t){return t===e&&(t=this.options.value),this.indeterminate=t===!1,"number"!=typeof t&&(t=0),this.indeterminate?!1:Math.min(this.options.max,Math.max(this.min,t))},_setOptions:function(t){var e=t.value;delete t.value,this._super(t),this.options.value=this._constrainedValue(e),this._refreshValue()},_setOption:function(t,e){"max"===t&&(e=Math.max(this.min,e)),this._super(t,e)},_percentage:function(){return this.indeterminate?100:100*(this.options.value-this.min)/(this.options.max-this.min)},_refreshValue:function(){var e=this.options.value,i=this._percentage();this.valueDiv.toggle(this.indeterminate||e>this.min).toggleClass("ui-corner-right",e===this.options.max).width(i.toFixed(0)+"%"),this.element.toggleClass("ui-progressbar-indeterminate",this.indeterminate),this.indeterminate?(this.element.removeAttr("aria-valuenow"),this.overlayDiv||(this.overlayDiv=t("<div class='ui-progressbar-overlay'></div>").appendTo(this.valueDiv))):(this.element.attr({"aria-valuemax":this.options.max,"aria-valuenow":e}),this.overlayDiv&&(this.overlayDiv.remove(),this.overlayDiv=null)),this.oldValue!==e&&(this.oldValue=e,this._trigger("change")),e===this.options.max&&this._trigger("complete")}})})(jQuery);
     1/*!
     2 * jQuery UI Progressbar 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/progressbar/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./core",
     18            "./widget"
     19        ], factory );
     20    } else {
     21
     22        // Browser globals
     23        factory( jQuery );
     24    }
     25}(function( $ ) {
     26
     27return $.widget( "ui.progressbar", {
     28    version: "1.11.1",
     29    options: {
     30        max: 100,
     31        value: 0,
     32
     33        change: null,
     34        complete: null
     35    },
     36
     37    min: 0,
     38
     39    _create: function() {
     40        // Constrain initial value
     41        this.oldValue = this.options.value = this._constrainedValue();
     42
     43        this.element
     44            .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
     45            .attr({
     46                // Only set static values, aria-valuenow and aria-valuemax are
     47                // set inside _refreshValue()
     48                role: "progressbar",
     49                "aria-valuemin": this.min
     50            });
     51
     52        this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
     53            .appendTo( this.element );
     54
     55        this._refreshValue();
     56    },
     57
     58    _destroy: function() {
     59        this.element
     60            .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
     61            .removeAttr( "role" )
     62            .removeAttr( "aria-valuemin" )
     63            .removeAttr( "aria-valuemax" )
     64            .removeAttr( "aria-valuenow" );
     65
     66        this.valueDiv.remove();
     67    },
     68
     69    value: function( newValue ) {
     70        if ( newValue === undefined ) {
     71            return this.options.value;
     72        }
     73
     74        this.options.value = this._constrainedValue( newValue );
     75        this._refreshValue();
     76    },
     77
     78    _constrainedValue: function( newValue ) {
     79        if ( newValue === undefined ) {
     80            newValue = this.options.value;
     81        }
     82
     83        this.indeterminate = newValue === false;
     84
     85        // sanitize value
     86        if ( typeof newValue !== "number" ) {
     87            newValue = 0;
     88        }
     89
     90        return this.indeterminate ? false :
     91            Math.min( this.options.max, Math.max( this.min, newValue ) );
     92    },
     93
     94    _setOptions: function( options ) {
     95        // Ensure "value" option is set after other values (like max)
     96        var value = options.value;
     97        delete options.value;
     98
     99        this._super( options );
     100
     101        this.options.value = this._constrainedValue( value );
     102        this._refreshValue();
     103    },
     104
     105    _setOption: function( key, value ) {
     106        if ( key === "max" ) {
     107            // Don't allow a max less than min
     108            value = Math.max( this.min, value );
     109        }
     110        if ( key === "disabled" ) {
     111            this.element
     112                .toggleClass( "ui-state-disabled", !!value )
     113                .attr( "aria-disabled", value );
     114        }
     115        this._super( key, value );
     116    },
     117
     118    _percentage: function() {
     119        return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
     120    },
     121
     122    _refreshValue: function() {
     123        var value = this.options.value,
     124            percentage = this._percentage();
     125
     126        this.valueDiv
     127            .toggle( this.indeterminate || value > this.min )
     128            .toggleClass( "ui-corner-right", value === this.options.max )
     129            .width( percentage.toFixed(0) + "%" );
     130
     131        this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
     132
     133        if ( this.indeterminate ) {
     134            this.element.removeAttr( "aria-valuenow" );
     135            if ( !this.overlayDiv ) {
     136                this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
     137            }
     138        } else {
     139            this.element.attr({
     140                "aria-valuemax": this.options.max,
     141                "aria-valuenow": value
     142            });
     143            if ( this.overlayDiv ) {
     144                this.overlayDiv.remove();
     145                this.overlayDiv = null;
     146            }
     147        }
     148
     149        if ( this.oldValue !== value ) {
     150            this.oldValue = value;
     151            this._trigger( "change" );
     152        }
     153        if ( value === this.options.max ) {
     154            this._trigger( "complete" );
     155        }
     156    }
     157});
     158
     159}));
  • trunk/src/wp-includes/js/jquery/ui/resizable.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(e){function t(e){return parseInt(e,10)||0}function i(e){return!isNaN(parseInt(e,10))}e.widget("ui.resizable",e.ui.mouse,{version:"1.10.4",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:90,resize:null,start:null,stop:null},_create:function(){var t,i,s,n,a,o=this,r=this.options;if(this.element.addClass("ui-resizable"),e.extend(this,{_aspectRatio:!!r.aspectRatio,aspectRatio:r.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:r.helper||r.ghost||r.animate?r.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)&&(this.element.wrap(e("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.data("ui-resizable")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize()),this.handles=r.handles||(e(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),t=this.handles.split(","),this.handles={},i=0;t.length>i;i++)s=e.trim(t[i]),a="ui-resizable-"+s,n=e("<div class='ui-resizable-handle "+a+"'></div>"),n.css({zIndex:r.zIndex}),"se"===s&&n.addClass("ui-icon ui-icon-gripsmall-diagonal-se"),this.handles[s]=".ui-resizable-"+s,this.element.append(n);this._renderAxis=function(t){var i,s,n,a;t=t||this.element;for(i in this.handles)this.handles[i].constructor===String&&(this.handles[i]=e(this.handles[i],this.element).show()),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)&&(s=e(this.handles[i],this.element),a=/sw|ne|nw|se|n|s/.test(i)?s.outerHeight():s.outerWidth(),n=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join(""),t.css(n,a),this._proportionallyResize()),e(this.handles[i]).length},this._renderAxis(this.element),this._handles=e(".ui-resizable-handle",this.element).disableSelection(),this._handles.mouseover(function(){o.resizing||(this.className&&(n=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),o.axis=n&&n[1]?n[1]:"se")}),r.autoHide&&(this._handles.hide(),e(this.element).addClass("ui-resizable-autohide").mouseenter(function(){r.disabled||(e(this).removeClass("ui-resizable-autohide"),o._handles.show())}).mouseleave(function(){r.disabled||o.resizing||(e(this).addClass("ui-resizable-autohide"),o._handles.hide())})),this._mouseInit()},_destroy:function(){this._mouseDestroy();var t,i=function(t){e(t).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};return this.elementIsWrapper&&(i(this.element),t=this.element,this.originalElement.css({position:t.css("position"),width:t.outerWidth(),height:t.outerHeight(),top:t.css("top"),left:t.css("left")}).insertAfter(t),t.remove()),this.originalElement.css("resize",this.originalResizeStyle),i(this.originalElement),this},_mouseCapture:function(t){var i,s,n=!1;for(i in this.handles)s=e(this.handles[i])[0],(s===t.target||e.contains(s,t.target))&&(n=!0);return!this.options.disabled&&n},_mouseStart:function(i){var s,n,a,o=this.options,r=this.element.position(),h=this.element;return this.resizing=!0,/absolute/.test(h.css("position"))?h.css({position:"absolute",top:h.css("top"),left:h.css("left")}):h.is(".ui-draggable")&&h.css({position:"absolute",top:r.top,left:r.left}),this._renderProxy(),s=t(this.helper.css("left")),n=t(this.helper.css("top")),o.containment&&(s+=e(o.containment).scrollLeft()||0,n+=e(o.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:s,top:n},this.size=this._helper?{width:this.helper.width(),height:this.helper.height()}:{width:h.width(),height:h.height()},this.originalSize=this._helper?{width:h.outerWidth(),height:h.outerHeight()}:{width:h.width(),height:h.height()},this.originalPosition={left:s,top:n},this.sizeDiff={width:h.outerWidth()-h.width(),height:h.outerHeight()-h.height()},this.originalMousePosition={left:i.pageX,top:i.pageY},this.aspectRatio="number"==typeof o.aspectRatio?o.aspectRatio:this.originalSize.width/this.originalSize.height||1,a=e(".ui-resizable-"+this.axis).css("cursor"),e("body").css("cursor","auto"===a?this.axis+"-resize":a),h.addClass("ui-resizable-resizing"),this._propagate("start",i),!0},_mouseDrag:function(t){var i,s=this.helper,n={},a=this.originalMousePosition,o=this.axis,r=this.position.top,h=this.position.left,l=this.size.width,u=this.size.height,c=t.pageX-a.left||0,d=t.pageY-a.top||0,p=this._change[o];return p?(i=p.apply(this,[t,c,d]),this._updateVirtualBoundaries(t.shiftKey),(this._aspectRatio||t.shiftKey)&&(i=this._updateRatio(i,t)),i=this._respectSize(i,t),this._updateCache(i),this._propagate("resize",t),this.position.top!==r&&(n.top=this.position.top+"px"),this.position.left!==h&&(n.left=this.position.left+"px"),this.size.width!==l&&(n.width=this.size.width+"px"),this.size.height!==u&&(n.height=this.size.height+"px"),s.css(n),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),e.isEmptyObject(n)||this._trigger("resize",t,this.ui()),!1):!1},_mouseStop:function(t){this.resizing=!1;var i,s,n,a,o,r,h,l=this.options,u=this;return this._helper&&(i=this._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),n=s&&e.ui.hasScroll(i[0],"left")?0:u.sizeDiff.height,a=s?0:u.sizeDiff.width,o={width:u.helper.width()-a,height:u.helper.height()-n},r=parseInt(u.element.css("left"),10)+(u.position.left-u.originalPosition.left)||null,h=parseInt(u.element.css("top"),10)+(u.position.top-u.originalPosition.top)||null,l.animate||this.element.css(e.extend(o,{top:h,left:r})),u.helper.height(u.size.height),u.helper.width(u.size.width),this._helper&&!l.animate&&this._proportionallyResize()),e("body").css("cursor","auto"),this.element.removeClass("ui-resizable-resizing"),this._propagate("stop",t),this._helper&&this.helper.remove(),!1},_updateVirtualBoundaries:function(e){var t,s,n,a,o,r=this.options;o={minWidth:i(r.minWidth)?r.minWidth:0,maxWidth:i(r.maxWidth)?r.maxWidth:1/0,minHeight:i(r.minHeight)?r.minHeight:0,maxHeight:i(r.maxHeight)?r.maxHeight:1/0},(this._aspectRatio||e)&&(t=o.minHeight*this.aspectRatio,n=o.minWidth/this.aspectRatio,s=o.maxHeight*this.aspectRatio,a=o.maxWidth/this.aspectRatio,t>o.minWidth&&(o.minWidth=t),n>o.minHeight&&(o.minHeight=n),o.maxWidth>s&&(o.maxWidth=s),o.maxHeight>a&&(o.maxHeight=a)),this._vBoundaries=o},_updateCache:function(e){this.offset=this.helper.offset(),i(e.left)&&(this.position.left=e.left),i(e.top)&&(this.position.top=e.top),i(e.height)&&(this.size.height=e.height),i(e.width)&&(this.size.width=e.width)},_updateRatio:function(e){var t=this.position,s=this.size,n=this.axis;return i(e.height)?e.width=e.height*this.aspectRatio:i(e.width)&&(e.height=e.width/this.aspectRatio),"sw"===n&&(e.left=t.left+(s.width-e.width),e.top=null),"nw"===n&&(e.top=t.top+(s.height-e.height),e.left=t.left+(s.width-e.width)),e},_respectSize:function(e){var t=this._vBoundaries,s=this.axis,n=i(e.width)&&t.maxWidth&&t.maxWidth<e.width,a=i(e.height)&&t.maxHeight&&t.maxHeight<e.height,o=i(e.width)&&t.minWidth&&t.minWidth>e.width,r=i(e.height)&&t.minHeight&&t.minHeight>e.height,h=this.originalPosition.left+this.originalSize.width,l=this.position.top+this.size.height,u=/sw|nw|w/.test(s),c=/nw|ne|n/.test(s);return o&&(e.width=t.minWidth),r&&(e.height=t.minHeight),n&&(e.width=t.maxWidth),a&&(e.height=t.maxHeight),o&&u&&(e.left=h-t.minWidth),n&&u&&(e.left=h-t.maxWidth),r&&c&&(e.top=l-t.minHeight),a&&c&&(e.top=l-t.maxHeight),e.width||e.height||e.left||!e.top?e.width||e.height||e.top||!e.left||(e.left=null):e.top=null,e},_proportionallyResize:function(){if(this._proportionallyResizeElements.length){var e,t,i,s,n,a=this.helper||this.element;for(e=0;this._proportionallyResizeElements.length>e;e++){if(n=this._proportionallyResizeElements[e],!this.borderDif)for(this.borderDif=[],i=[n.css("borderTopWidth"),n.css("borderRightWidth"),n.css("borderBottomWidth"),n.css("borderLeftWidth")],s=[n.css("paddingTop"),n.css("paddingRight"),n.css("paddingBottom"),n.css("paddingLeft")],t=0;i.length>t;t++)this.borderDif[t]=(parseInt(i[t],10)||0)+(parseInt(s[t],10)||0);n.css({height:a.height()-this.borderDif[0]-this.borderDif[2]||0,width:a.width()-this.borderDif[1]-this.borderDif[3]||0})}}},_renderProxy:function(){var t=this.element,i=this.options;this.elementOffset=t.offset(),this._helper?(this.helper=this.helper||e("<div style='overflow:hidden;'></div>"),this.helper.addClass(this._helper).css({width:this.element.outerWidth()-1,height:this.element.outerHeight()-1,position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++i.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element},_change:{e:function(e,t){return{width:this.originalSize.width+t}},w:function(e,t){var i=this.originalSize,s=this.originalPosition;return{left:s.left+t,width:i.width-t}},n:function(e,t,i){var s=this.originalSize,n=this.originalPosition;return{top:n.top+i,height:s.height-i}},s:function(e,t,i){return{height:this.originalSize.height+i}},se:function(t,i,s){return e.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[t,i,s]))},sw:function(t,i,s){return e.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[t,i,s]))},ne:function(t,i,s){return e.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[t,i,s]))},nw:function(t,i,s){return e.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[t,i,s]))}},_propagate:function(t,i){e.ui.plugin.call(this,t,[i,this.ui()]),"resize"!==t&&this._trigger(t,i,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),e.ui.plugin.add("resizable","animate",{stop:function(t){var i=e(this).data("ui-resizable"),s=i.options,n=i._proportionallyResizeElements,a=n.length&&/textarea/i.test(n[0].nodeName),o=a&&e.ui.hasScroll(n[0],"left")?0:i.sizeDiff.height,r=a?0:i.sizeDiff.width,h={width:i.size.width-r,height:i.size.height-o},l=parseInt(i.element.css("left"),10)+(i.position.left-i.originalPosition.left)||null,u=parseInt(i.element.css("top"),10)+(i.position.top-i.originalPosition.top)||null;i.element.animate(e.extend(h,u&&l?{top:u,left:l}:{}),{duration:s.animateDuration,easing:s.animateEasing,step:function(){var s={width:parseInt(i.element.css("width"),10),height:parseInt(i.element.css("height"),10),top:parseInt(i.element.css("top"),10),left:parseInt(i.element.css("left"),10)};n&&n.length&&e(n[0]).css({width:s.width,height:s.height}),i._updateCache(s),i._propagate("resize",t)}})}}),e.ui.plugin.add("resizable","containment",{start:function(){var i,s,n,a,o,r,h,l=e(this).data("ui-resizable"),u=l.options,c=l.element,d=u.containment,p=d instanceof e?d.get(0):/parent/.test(d)?c.parent().get(0):d;p&&(l.containerElement=e(p),/document/.test(d)||d===document?(l.containerOffset={left:0,top:0},l.containerPosition={left:0,top:0},l.parentData={element:e(document),left:0,top:0,width:e(document).width(),height:e(document).height()||document.body.parentNode.scrollHeight}):(i=e(p),s=[],e(["Top","Right","Left","Bottom"]).each(function(e,n){s[e]=t(i.css("padding"+n))}),l.containerOffset=i.offset(),l.containerPosition=i.position(),l.containerSize={height:i.innerHeight()-s[3],width:i.innerWidth()-s[1]},n=l.containerOffset,a=l.containerSize.height,o=l.containerSize.width,r=e.ui.hasScroll(p,"left")?p.scrollWidth:o,h=e.ui.hasScroll(p)?p.scrollHeight:a,l.parentData={element:p,left:n.left,top:n.top,width:r,height:h}))},resize:function(t){var i,s,n,a,o=e(this).data("ui-resizable"),r=o.options,h=o.containerOffset,l=o.position,u=o._aspectRatio||t.shiftKey,c={top:0,left:0},d=o.containerElement;d[0]!==document&&/static/.test(d.css("position"))&&(c=h),l.left<(o._helper?h.left:0)&&(o.size.width=o.size.width+(o._helper?o.position.left-h.left:o.position.left-c.left),u&&(o.size.height=o.size.width/o.aspectRatio),o.position.left=r.helper?h.left:0),l.top<(o._helper?h.top:0)&&(o.size.height=o.size.height+(o._helper?o.position.top-h.top:o.position.top),u&&(o.size.width=o.size.height*o.aspectRatio),o.position.top=o._helper?h.top:0),o.offset.left=o.parentData.left+o.position.left,o.offset.top=o.parentData.top+o.position.top,i=Math.abs((o._helper?o.offset.left-c.left:o.offset.left-c.left)+o.sizeDiff.width),s=Math.abs((o._helper?o.offset.top-c.top:o.offset.top-h.top)+o.sizeDiff.height),n=o.containerElement.get(0)===o.element.parent().get(0),a=/relative|absolute/.test(o.containerElement.css("position")),n&&a&&(i-=Math.abs(o.parentData.left)),i+o.size.width>=o.parentData.width&&(o.size.width=o.parentData.width-i,u&&(o.size.height=o.size.width/o.aspectRatio)),s+o.size.height>=o.parentData.height&&(o.size.height=o.parentData.height-s,u&&(o.size.width=o.size.height*o.aspectRatio))},stop:function(){var t=e(this).data("ui-resizable"),i=t.options,s=t.containerOffset,n=t.containerPosition,a=t.containerElement,o=e(t.helper),r=o.offset(),h=o.outerWidth()-t.sizeDiff.width,l=o.outerHeight()-t.sizeDiff.height;t._helper&&!i.animate&&/relative/.test(a.css("position"))&&e(this).css({left:r.left-n.left-s.left,width:h,height:l}),t._helper&&!i.animate&&/static/.test(a.css("position"))&&e(this).css({left:r.left-n.left-s.left,width:h,height:l})}}),e.ui.plugin.add("resizable","alsoResize",{start:function(){var t=e(this).data("ui-resizable"),i=t.options,s=function(t){e(t).each(function(){var t=e(this);t.data("ui-resizable-alsoresize",{width:parseInt(t.width(),10),height:parseInt(t.height(),10),left:parseInt(t.css("left"),10),top:parseInt(t.css("top"),10)})})};"object"!=typeof i.alsoResize||i.alsoResize.parentNode?s(i.alsoResize):i.alsoResize.length?(i.alsoResize=i.alsoResize[0],s(i.alsoResize)):e.each(i.alsoResize,function(e){s(e)})},resize:function(t,i){var s=e(this).data("ui-resizable"),n=s.options,a=s.originalSize,o=s.originalPosition,r={height:s.size.height-a.height||0,width:s.size.width-a.width||0,top:s.position.top-o.top||0,left:s.position.left-o.left||0},h=function(t,s){e(t).each(function(){var t=e(this),n=e(this).data("ui-resizable-alsoresize"),a={},o=s&&s.length?s:t.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];e.each(o,function(e,t){var i=(n[t]||0)+(r[t]||0);i&&i>=0&&(a[t]=i||null)}),t.css(a)})};"object"!=typeof n.alsoResize||n.alsoResize.nodeType?h(n.alsoResize):e.each(n.alsoResize,function(e,t){h(e,t)})},stop:function(){e(this).removeData("resizable-alsoresize")}}),e.ui.plugin.add("resizable","ghost",{start:function(){var t=e(this).data("ui-resizable"),i=t.options,s=t.size;t.ghost=t.originalElement.clone(),t.ghost.css({opacity:.25,display:"block",position:"relative",height:s.height,width:s.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass("string"==typeof i.ghost?i.ghost:""),t.ghost.appendTo(t.helper)},resize:function(){var t=e(this).data("ui-resizable");t.ghost&&t.ghost.css({position:"relative",height:t.size.height,width:t.size.width})},stop:function(){var t=e(this).data("ui-resizable");t.ghost&&t.helper&&t.helper.get(0).removeChild(t.ghost.get(0))}}),e.ui.plugin.add("resizable","grid",{resize:function(){var t=e(this).data("ui-resizable"),i=t.options,s=t.size,n=t.originalSize,a=t.originalPosition,o=t.axis,r="number"==typeof i.grid?[i.grid,i.grid]:i.grid,h=r[0]||1,l=r[1]||1,u=Math.round((s.width-n.width)/h)*h,c=Math.round((s.height-n.height)/l)*l,d=n.width+u,p=n.height+c,f=i.maxWidth&&d>i.maxWidth,m=i.maxHeight&&p>i.maxHeight,g=i.minWidth&&i.minWidth>d,v=i.minHeight&&i.minHeight>p;i.grid=r,g&&(d+=h),v&&(p+=l),f&&(d-=h),m&&(p-=l),/^(se|s|e)$/.test(o)?(t.size.width=d,t.size.height=p):/^(ne)$/.test(o)?(t.size.width=d,t.size.height=p,t.position.top=a.top-c):/^(sw)$/.test(o)?(t.size.width=d,t.size.height=p,t.position.left=a.left-u):(p-l>0?(t.size.height=p,t.position.top=a.top-c):(t.size.height=l,t.position.top=a.top+n.height-l),d-h>0?(t.size.width=d,t.position.left=a.left-u):(t.size.width=h,t.position.left=a.left+n.width-h))}})})(jQuery);
     1/*!
     2 * jQuery UI Resizable 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/resizable/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./core",
     18            "./mouse",
     19            "./widget"
     20        ], factory );
     21    } else {
     22
     23        // Browser globals
     24        factory( jQuery );
     25    }
     26}(function( $ ) {
     27
     28$.widget("ui.resizable", $.ui.mouse, {
     29    version: "1.11.1",
     30    widgetEventPrefix: "resize",
     31    options: {
     32        alsoResize: false,
     33        animate: false,
     34        animateDuration: "slow",
     35        animateEasing: "swing",
     36        aspectRatio: false,
     37        autoHide: false,
     38        containment: false,
     39        ghost: false,
     40        grid: false,
     41        handles: "e,s,se",
     42        helper: false,
     43        maxHeight: null,
     44        maxWidth: null,
     45        minHeight: 10,
     46        minWidth: 10,
     47        // See #7960
     48        zIndex: 90,
     49
     50        // callbacks
     51        resize: null,
     52        start: null,
     53        stop: null
     54    },
     55
     56    _num: function( value ) {
     57        return parseInt( value, 10 ) || 0;
     58    },
     59
     60    _isNumber: function( value ) {
     61        return !isNaN( parseInt( value, 10 ) );
     62    },
     63
     64    _hasScroll: function( el, a ) {
     65
     66        if ( $( el ).css( "overflow" ) === "hidden") {
     67            return false;
     68        }
     69
     70        var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
     71            has = false;
     72
     73        if ( el[ scroll ] > 0 ) {
     74            return true;
     75        }
     76
     77        // TODO: determine which cases actually cause this to happen
     78        // if the element doesn't have the scroll set, see if it's possible to
     79        // set the scroll
     80        el[ scroll ] = 1;
     81        has = ( el[ scroll ] > 0 );
     82        el[ scroll ] = 0;
     83        return has;
     84    },
     85
     86    _create: function() {
     87
     88        var n, i, handle, axis, hname,
     89            that = this,
     90            o = this.options;
     91        this.element.addClass("ui-resizable");
     92
     93        $.extend(this, {
     94            _aspectRatio: !!(o.aspectRatio),
     95            aspectRatio: o.aspectRatio,
     96            originalElement: this.element,
     97            _proportionallyResizeElements: [],
     98            _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
     99        });
     100
     101        // Wrap the element if it cannot hold child nodes
     102        if (this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
     103
     104            this.element.wrap(
     105                $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
     106                    position: this.element.css("position"),
     107                    width: this.element.outerWidth(),
     108                    height: this.element.outerHeight(),
     109                    top: this.element.css("top"),
     110                    left: this.element.css("left")
     111                })
     112            );
     113
     114            this.element = this.element.parent().data(
     115                "ui-resizable", this.element.resizable( "instance" )
     116            );
     117
     118            this.elementIsWrapper = true;
     119
     120            this.element.css({
     121                marginLeft: this.originalElement.css("marginLeft"),
     122                marginTop: this.originalElement.css("marginTop"),
     123                marginRight: this.originalElement.css("marginRight"),
     124                marginBottom: this.originalElement.css("marginBottom")
     125            });
     126            this.originalElement.css({
     127                marginLeft: 0,
     128                marginTop: 0,
     129                marginRight: 0,
     130                marginBottom: 0
     131            });
     132            // support: Safari
     133            // Prevent Safari textarea resize
     134            this.originalResizeStyle = this.originalElement.css("resize");
     135            this.originalElement.css("resize", "none");
     136
     137            this._proportionallyResizeElements.push( this.originalElement.css({
     138                position: "static",
     139                zoom: 1,
     140                display: "block"
     141            }) );
     142
     143            // support: IE9
     144            // avoid IE jump (hard set the margin)
     145            this.originalElement.css({ margin: this.originalElement.css("margin") });
     146
     147            this._proportionallyResize();
     148        }
     149
     150        this.handles = o.handles ||
     151            ( !$(".ui-resizable-handle", this.element).length ?
     152                "e,s,se" : {
     153                    n: ".ui-resizable-n",
     154                    e: ".ui-resizable-e",
     155                    s: ".ui-resizable-s",
     156                    w: ".ui-resizable-w",
     157                    se: ".ui-resizable-se",
     158                    sw: ".ui-resizable-sw",
     159                    ne: ".ui-resizable-ne",
     160                    nw: ".ui-resizable-nw"
     161                } );
     162
     163        if (this.handles.constructor === String) {
     164
     165            if ( this.handles === "all") {
     166                this.handles = "n,e,s,w,se,sw,ne,nw";
     167            }
     168
     169            n = this.handles.split(",");
     170            this.handles = {};
     171
     172            for (i = 0; i < n.length; i++) {
     173
     174                handle = $.trim(n[i]);
     175                hname = "ui-resizable-" + handle;
     176                axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
     177
     178                axis.css({ zIndex: o.zIndex });
     179
     180                // TODO : What's going on here?
     181                if ("se" === handle) {
     182                    axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
     183                }
     184
     185                this.handles[handle] = ".ui-resizable-" + handle;
     186                this.element.append(axis);
     187            }
     188
     189        }
     190
     191        this._renderAxis = function(target) {
     192
     193            var i, axis, padPos, padWrapper;
     194
     195            target = target || this.element;
     196
     197            for (i in this.handles) {
     198
     199                if (this.handles[i].constructor === String) {
     200                    this.handles[i] = this.element.children( this.handles[ i ] ).first().show();
     201                }
     202
     203                if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
     204
     205                    axis = $(this.handles[i], this.element);
     206
     207                    padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
     208
     209                    padPos = [ "padding",
     210                        /ne|nw|n/.test(i) ? "Top" :
     211                        /se|sw|s/.test(i) ? "Bottom" :
     212                        /^e$/.test(i) ? "Right" : "Left" ].join("");
     213
     214                    target.css(padPos, padWrapper);
     215
     216                    this._proportionallyResize();
     217
     218                }
     219
     220                // TODO: What's that good for? There's not anything to be executed left
     221                if (!$(this.handles[i]).length) {
     222                    continue;
     223                }
     224            }
     225        };
     226
     227        // TODO: make renderAxis a prototype function
     228        this._renderAxis(this.element);
     229
     230        this._handles = $(".ui-resizable-handle", this.element)
     231            .disableSelection();
     232
     233        this._handles.mouseover(function() {
     234            if (!that.resizing) {
     235                if (this.className) {
     236                    axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
     237                }
     238                that.axis = axis && axis[1] ? axis[1] : "se";
     239            }
     240        });
     241
     242        if (o.autoHide) {
     243            this._handles.hide();
     244            $(this.element)
     245                .addClass("ui-resizable-autohide")
     246                .mouseenter(function() {
     247                    if (o.disabled) {
     248                        return;
     249                    }
     250                    $(this).removeClass("ui-resizable-autohide");
     251                    that._handles.show();
     252                })
     253                .mouseleave(function() {
     254                    if (o.disabled) {
     255                        return;
     256                    }
     257                    if (!that.resizing) {
     258                        $(this).addClass("ui-resizable-autohide");
     259                        that._handles.hide();
     260                    }
     261                });
     262        }
     263
     264        this._mouseInit();
     265
     266    },
     267
     268    _destroy: function() {
     269
     270        this._mouseDestroy();
     271
     272        var wrapper,
     273            _destroy = function(exp) {
     274                $(exp)
     275                    .removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
     276                    .removeData("resizable")
     277                    .removeData("ui-resizable")
     278                    .unbind(".resizable")
     279                    .find(".ui-resizable-handle")
     280                        .remove();
     281            };
     282
     283        // TODO: Unwrap at same DOM position
     284        if (this.elementIsWrapper) {
     285            _destroy(this.element);
     286            wrapper = this.element;
     287            this.originalElement.css({
     288                position: wrapper.css("position"),
     289                width: wrapper.outerWidth(),
     290                height: wrapper.outerHeight(),
     291                top: wrapper.css("top"),
     292                left: wrapper.css("left")
     293            }).insertAfter( wrapper );
     294            wrapper.remove();
     295        }
     296
     297        this.originalElement.css("resize", this.originalResizeStyle);
     298        _destroy(this.originalElement);
     299
     300        return this;
     301    },
     302
     303    _mouseCapture: function(event) {
     304        var i, handle,
     305            capture = false;
     306
     307        for (i in this.handles) {
     308            handle = $(this.handles[i])[0];
     309            if (handle === event.target || $.contains(handle, event.target)) {
     310                capture = true;
     311            }
     312        }
     313
     314        return !this.options.disabled && capture;
     315    },
     316
     317    _mouseStart: function(event) {
     318
     319        var curleft, curtop, cursor,
     320            o = this.options,
     321            el = this.element;
     322
     323        this.resizing = true;
     324
     325        this._renderProxy();
     326
     327        curleft = this._num(this.helper.css("left"));
     328        curtop = this._num(this.helper.css("top"));
     329
     330        if (o.containment) {
     331            curleft += $(o.containment).scrollLeft() || 0;
     332            curtop += $(o.containment).scrollTop() || 0;
     333        }
     334
     335        this.offset = this.helper.offset();
     336        this.position = { left: curleft, top: curtop };
     337
     338        this.size = this._helper ? {
     339                width: this.helper.width(),
     340                height: this.helper.height()
     341            } : {
     342                width: el.width(),
     343                height: el.height()
     344            };
     345
     346        this.originalSize = this._helper ? {
     347                width: el.outerWidth(),
     348                height: el.outerHeight()
     349            } : {
     350                width: el.width(),
     351                height: el.height()
     352            };
     353
     354        this.sizeDiff = {
     355            width: el.outerWidth() - el.width(),
     356            height: el.outerHeight() - el.height()
     357        };
     358
     359        this.originalPosition = { left: curleft, top: curtop };
     360        this.originalMousePosition = { left: event.pageX, top: event.pageY };
     361
     362        this.aspectRatio = (typeof o.aspectRatio === "number") ?
     363            o.aspectRatio :
     364            ((this.originalSize.width / this.originalSize.height) || 1);
     365
     366        cursor = $(".ui-resizable-" + this.axis).css("cursor");
     367        $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
     368
     369        el.addClass("ui-resizable-resizing");
     370        this._propagate("start", event);
     371        return true;
     372    },
     373
     374    _mouseDrag: function(event) {
     375
     376        var data, props,
     377            smp = this.originalMousePosition,
     378            a = this.axis,
     379            dx = (event.pageX - smp.left) || 0,
     380            dy = (event.pageY - smp.top) || 0,
     381            trigger = this._change[a];
     382
     383        this._updatePrevProperties();
     384
     385        if (!trigger) {
     386            return false;
     387        }
     388
     389        data = trigger.apply(this, [ event, dx, dy ]);
     390
     391        this._updateVirtualBoundaries(event.shiftKey);
     392        if (this._aspectRatio || event.shiftKey) {
     393            data = this._updateRatio(data, event);
     394        }
     395
     396        data = this._respectSize(data, event);
     397
     398        this._updateCache(data);
     399
     400        this._propagate("resize", event);
     401
     402        props = this._applyChanges();
     403
     404        if ( !this._helper && this._proportionallyResizeElements.length ) {
     405            this._proportionallyResize();
     406        }
     407
     408        if ( !$.isEmptyObject( props ) ) {
     409            this._updatePrevProperties();
     410            this._trigger( "resize", event, this.ui() );
     411            this._applyChanges();
     412        }
     413
     414        return false;
     415    },
     416
     417    _mouseStop: function(event) {
     418
     419        this.resizing = false;
     420        var pr, ista, soffseth, soffsetw, s, left, top,
     421            o = this.options, that = this;
     422
     423        if (this._helper) {
     424
     425            pr = this._proportionallyResizeElements;
     426            ista = pr.length && (/textarea/i).test(pr[0].nodeName);
     427            soffseth = ista && this._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height;
     428            soffsetw = ista ? 0 : that.sizeDiff.width;
     429
     430            s = {
     431                width: (that.helper.width()  - soffsetw),
     432                height: (that.helper.height() - soffseth)
     433            };
     434            left = (parseInt(that.element.css("left"), 10) +
     435                (that.position.left - that.originalPosition.left)) || null;
     436            top = (parseInt(that.element.css("top"), 10) +
     437                (that.position.top - that.originalPosition.top)) || null;
     438
     439            if (!o.animate) {
     440                this.element.css($.extend(s, { top: top, left: left }));
     441            }
     442
     443            that.helper.height(that.size.height);
     444            that.helper.width(that.size.width);
     445
     446            if (this._helper && !o.animate) {
     447                this._proportionallyResize();
     448            }
     449        }
     450
     451        $("body").css("cursor", "auto");
     452
     453        this.element.removeClass("ui-resizable-resizing");
     454
     455        this._propagate("stop", event);
     456
     457        if (this._helper) {
     458            this.helper.remove();
     459        }
     460
     461        return false;
     462
     463    },
     464
     465    _updatePrevProperties: function() {
     466        this.prevPosition = {
     467            top: this.position.top,
     468            left: this.position.left
     469        };
     470        this.prevSize = {
     471            width: this.size.width,
     472            height: this.size.height
     473        };
     474    },
     475
     476    _applyChanges: function() {
     477        var props = {};
     478
     479        if ( this.position.top !== this.prevPosition.top ) {
     480            props.top = this.position.top + "px";
     481        }
     482        if ( this.position.left !== this.prevPosition.left ) {
     483            props.left = this.position.left + "px";
     484        }
     485        if ( this.size.width !== this.prevSize.width ) {
     486            props.width = this.size.width + "px";
     487        }
     488        if ( this.size.height !== this.prevSize.height ) {
     489            props.height = this.size.height + "px";
     490        }
     491
     492        this.helper.css( props );
     493
     494        return props;
     495    },
     496
     497    _updateVirtualBoundaries: function(forceAspectRatio) {
     498        var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
     499            o = this.options;
     500
     501        b = {
     502            minWidth: this._isNumber(o.minWidth) ? o.minWidth : 0,
     503            maxWidth: this._isNumber(o.maxWidth) ? o.maxWidth : Infinity,
     504            minHeight: this._isNumber(o.minHeight) ? o.minHeight : 0,
     505            maxHeight: this._isNumber(o.maxHeight) ? o.maxHeight : Infinity
     506        };
     507
     508        if (this._aspectRatio || forceAspectRatio) {
     509            pMinWidth = b.minHeight * this.aspectRatio;
     510            pMinHeight = b.minWidth / this.aspectRatio;
     511            pMaxWidth = b.maxHeight * this.aspectRatio;
     512            pMaxHeight = b.maxWidth / this.aspectRatio;
     513
     514            if (pMinWidth > b.minWidth) {
     515                b.minWidth = pMinWidth;
     516            }
     517            if (pMinHeight > b.minHeight) {
     518                b.minHeight = pMinHeight;
     519            }
     520            if (pMaxWidth < b.maxWidth) {
     521                b.maxWidth = pMaxWidth;
     522            }
     523            if (pMaxHeight < b.maxHeight) {
     524                b.maxHeight = pMaxHeight;
     525            }
     526        }
     527        this._vBoundaries = b;
     528    },
     529
     530    _updateCache: function(data) {
     531        this.offset = this.helper.offset();
     532        if (this._isNumber(data.left)) {
     533            this.position.left = data.left;
     534        }
     535        if (this._isNumber(data.top)) {
     536            this.position.top = data.top;
     537        }
     538        if (this._isNumber(data.height)) {
     539            this.size.height = data.height;
     540        }
     541        if (this._isNumber(data.width)) {
     542            this.size.width = data.width;
     543        }
     544    },
     545
     546    _updateRatio: function( data ) {
     547
     548        var cpos = this.position,
     549            csize = this.size,
     550            a = this.axis;
     551
     552        if (this._isNumber(data.height)) {
     553            data.width = (data.height * this.aspectRatio);
     554        } else if (this._isNumber(data.width)) {
     555            data.height = (data.width / this.aspectRatio);
     556        }
     557
     558        if (a === "sw") {
     559            data.left = cpos.left + (csize.width - data.width);
     560            data.top = null;
     561        }
     562        if (a === "nw") {
     563            data.top = cpos.top + (csize.height - data.height);
     564            data.left = cpos.left + (csize.width - data.width);
     565        }
     566
     567        return data;
     568    },
     569
     570    _respectSize: function( data ) {
     571
     572        var o = this._vBoundaries,
     573            a = this.axis,
     574            ismaxw = this._isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width),
     575            ismaxh = this._isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
     576            isminw = this._isNumber(data.width) && o.minWidth && (o.minWidth > data.width),
     577            isminh = this._isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
     578            dw = this.originalPosition.left + this.originalSize.width,
     579            dh = this.position.top + this.size.height,
     580            cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
     581        if (isminw) {
     582            data.width = o.minWidth;
     583        }
     584        if (isminh) {
     585            data.height = o.minHeight;
     586        }
     587        if (ismaxw) {
     588            data.width = o.maxWidth;
     589        }
     590        if (ismaxh) {
     591            data.height = o.maxHeight;
     592        }
     593
     594        if (isminw && cw) {
     595            data.left = dw - o.minWidth;
     596        }
     597        if (ismaxw && cw) {
     598            data.left = dw - o.maxWidth;
     599        }
     600        if (isminh && ch) {
     601            data.top = dh - o.minHeight;
     602        }
     603        if (ismaxh && ch) {
     604            data.top = dh - o.maxHeight;
     605        }
     606
     607        // Fixing jump error on top/left - bug #2330
     608        if (!data.width && !data.height && !data.left && data.top) {
     609            data.top = null;
     610        } else if (!data.width && !data.height && !data.top && data.left) {
     611            data.left = null;
     612        }
     613
     614        return data;
     615    },
     616
     617    _getPaddingPlusBorderDimensions: function( element ) {
     618        var i = 0,
     619            widths = [],
     620            borders = [
     621                element.css( "borderTopWidth" ),
     622                element.css( "borderRightWidth" ),
     623                element.css( "borderBottomWidth" ),
     624                element.css( "borderLeftWidth" )
     625            ],
     626            paddings = [
     627                element.css( "paddingTop" ),
     628                element.css( "paddingRight" ),
     629                element.css( "paddingBottom" ),
     630                element.css( "paddingLeft" )
     631            ];
     632
     633        for ( ; i < 4; i++ ) {
     634            widths[ i ] = ( parseInt( borders[ i ], 10 ) || 0 );
     635            widths[ i ] += ( parseInt( paddings[ i ], 10 ) || 0 );
     636        }
     637
     638        return {
     639            height: widths[ 0 ] + widths[ 2 ],
     640            width: widths[ 1 ] + widths[ 3 ]
     641        };
     642    },
     643
     644    _proportionallyResize: function() {
     645
     646        if (!this._proportionallyResizeElements.length) {
     647            return;
     648        }
     649
     650        var prel,
     651            i = 0,
     652            element = this.helper || this.element;
     653
     654        for ( ; i < this._proportionallyResizeElements.length; i++) {
     655
     656            prel = this._proportionallyResizeElements[i];
     657
     658            // TODO: Seems like a bug to cache this.outerDimensions
     659            // considering that we are in a loop.
     660            if (!this.outerDimensions) {
     661                this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
     662            }
     663
     664            prel.css({
     665                height: (element.height() - this.outerDimensions.height) || 0,
     666                width: (element.width() - this.outerDimensions.width) || 0
     667            });
     668
     669        }
     670
     671    },
     672
     673    _renderProxy: function() {
     674
     675        var el = this.element, o = this.options;
     676        this.elementOffset = el.offset();
     677
     678        if (this._helper) {
     679
     680            this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
     681
     682            this.helper.addClass(this._helper).css({
     683                width: this.element.outerWidth() - 1,
     684                height: this.element.outerHeight() - 1,
     685                position: "absolute",
     686                left: this.elementOffset.left + "px",
     687                top: this.elementOffset.top + "px",
     688                zIndex: ++o.zIndex //TODO: Don't modify option
     689            });
     690
     691            this.helper
     692                .appendTo("body")
     693                .disableSelection();
     694
     695        } else {
     696            this.helper = this.element;
     697        }
     698
     699    },
     700
     701    _change: {
     702        e: function(event, dx) {
     703            return { width: this.originalSize.width + dx };
     704        },
     705        w: function(event, dx) {
     706            var cs = this.originalSize, sp = this.originalPosition;
     707            return { left: sp.left + dx, width: cs.width - dx };
     708        },
     709        n: function(event, dx, dy) {
     710            var cs = this.originalSize, sp = this.originalPosition;
     711            return { top: sp.top + dy, height: cs.height - dy };
     712        },
     713        s: function(event, dx, dy) {
     714            return { height: this.originalSize.height + dy };
     715        },
     716        se: function(event, dx, dy) {
     717            return $.extend(this._change.s.apply(this, arguments),
     718                this._change.e.apply(this, [ event, dx, dy ]));
     719        },
     720        sw: function(event, dx, dy) {
     721            return $.extend(this._change.s.apply(this, arguments),
     722                this._change.w.apply(this, [ event, dx, dy ]));
     723        },
     724        ne: function(event, dx, dy) {
     725            return $.extend(this._change.n.apply(this, arguments),
     726                this._change.e.apply(this, [ event, dx, dy ]));
     727        },
     728        nw: function(event, dx, dy) {
     729            return $.extend(this._change.n.apply(this, arguments),
     730                this._change.w.apply(this, [ event, dx, dy ]));
     731        }
     732    },
     733
     734    _propagate: function(n, event) {
     735        $.ui.plugin.call(this, n, [ event, this.ui() ]);
     736        (n !== "resize" && this._trigger(n, event, this.ui()));
     737    },
     738
     739    plugins: {},
     740
     741    ui: function() {
     742        return {
     743            originalElement: this.originalElement,
     744            element: this.element,
     745            helper: this.helper,
     746            position: this.position,
     747            size: this.size,
     748            originalSize: this.originalSize,
     749            originalPosition: this.originalPosition
     750        };
     751    }
     752
     753});
     754
     755/*
     756 * Resizable Extensions
     757 */
     758
     759$.ui.plugin.add("resizable", "animate", {
     760
     761    stop: function( event ) {
     762        var that = $(this).resizable( "instance" ),
     763            o = that.options,
     764            pr = that._proportionallyResizeElements,
     765            ista = pr.length && (/textarea/i).test(pr[0].nodeName),
     766            soffseth = ista && that._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height,
     767            soffsetw = ista ? 0 : that.sizeDiff.width,
     768            style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
     769            left = (parseInt(that.element.css("left"), 10) +
     770                (that.position.left - that.originalPosition.left)) || null,
     771            top = (parseInt(that.element.css("top"), 10) +
     772                (that.position.top - that.originalPosition.top)) || null;
     773
     774        that.element.animate(
     775            $.extend(style, top && left ? { top: top, left: left } : {}), {
     776                duration: o.animateDuration,
     777                easing: o.animateEasing,
     778                step: function() {
     779
     780                    var data = {
     781                        width: parseInt(that.element.css("width"), 10),
     782                        height: parseInt(that.element.css("height"), 10),
     783                        top: parseInt(that.element.css("top"), 10),
     784                        left: parseInt(that.element.css("left"), 10)
     785                    };
     786
     787                    if (pr && pr.length) {
     788                        $(pr[0]).css({ width: data.width, height: data.height });
     789                    }
     790
     791                    // propagating resize, and updating values for each animation step
     792                    that._updateCache(data);
     793                    that._propagate("resize", event);
     794
     795                }
     796            }
     797        );
     798    }
     799
     800});
     801
     802$.ui.plugin.add( "resizable", "containment", {
     803
     804    start: function() {
     805        var element, p, co, ch, cw, width, height,
     806            that = $( this ).resizable( "instance" ),
     807            o = that.options,
     808            el = that.element,
     809            oc = o.containment,
     810            ce = ( oc instanceof $ ) ? oc.get( 0 ) : ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
     811
     812        if ( !ce ) {
     813            return;
     814        }
     815
     816        that.containerElement = $( ce );
     817
     818        if ( /document/.test( oc ) || oc === document ) {
     819            that.containerOffset = {
     820                left: 0,
     821                top: 0
     822            };
     823            that.containerPosition = {
     824                left: 0,
     825                top: 0
     826            };
     827
     828            that.parentData = {
     829                element: $( document ),
     830                left: 0,
     831                top: 0,
     832                width: $( document ).width(),
     833                height: $( document ).height() || document.body.parentNode.scrollHeight
     834            };
     835        } else {
     836            element = $( ce );
     837            p = [];
     838            $([ "Top", "Right", "Left", "Bottom" ]).each(function( i, name ) {
     839                p[ i ] = that._num( element.css( "padding" + name ) );
     840            });
     841
     842            that.containerOffset = element.offset();
     843            that.containerPosition = element.position();
     844            that.containerSize = {
     845                height: ( element.innerHeight() - p[ 3 ] ),
     846                width: ( element.innerWidth() - p[ 1 ] )
     847            };
     848
     849            co = that.containerOffset;
     850            ch = that.containerSize.height;
     851            cw = that.containerSize.width;
     852            width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
     853            height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
     854
     855            that.parentData = {
     856                element: ce,
     857                left: co.left,
     858                top: co.top,
     859                width: width,
     860                height: height
     861            };
     862        }
     863    },
     864
     865    resize: function( event ) {
     866        var woset, hoset, isParent, isOffsetRelative,
     867            that = $( this ).resizable( "instance" ),
     868            o = that.options,
     869            co = that.containerOffset,
     870            cp = that.position,
     871            pRatio = that._aspectRatio || event.shiftKey,
     872            cop = {
     873                top: 0,
     874                left: 0
     875            },
     876            ce = that.containerElement,
     877            continueResize = true;
     878
     879        if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
     880            cop = co;
     881        }
     882
     883        if ( cp.left < ( that._helper ? co.left : 0 ) ) {
     884            that.size.width = that.size.width +
     885                ( that._helper ?
     886                    ( that.position.left - co.left ) :
     887                    ( that.position.left - cop.left ) );
     888
     889            if ( pRatio ) {
     890                that.size.height = that.size.width / that.aspectRatio;
     891                continueResize = false;
     892            }
     893            that.position.left = o.helper ? co.left : 0;
     894        }
     895
     896        if ( cp.top < ( that._helper ? co.top : 0 ) ) {
     897            that.size.height = that.size.height +
     898                ( that._helper ?
     899                    ( that.position.top - co.top ) :
     900                    that.position.top );
     901
     902            if ( pRatio ) {
     903                that.size.width = that.size.height * that.aspectRatio;
     904                continueResize = false;
     905            }
     906            that.position.top = that._helper ? co.top : 0;
     907        }
     908
     909        isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
     910        isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
     911
     912        if ( isParent && isOffsetRelative ) {
     913            that.offset.left = that.parentData.left + that.position.left;
     914            that.offset.top = that.parentData.top + that.position.top;
     915        } else {
     916            that.offset.left = that.element.offset().left;
     917            that.offset.top = that.element.offset().top;
     918        }
     919
     920        woset = Math.abs( that.sizeDiff.width +
     921            (that._helper ?
     922                that.offset.left - cop.left :
     923                (that.offset.left - co.left)) );
     924
     925        hoset = Math.abs( that.sizeDiff.height +
     926            (that._helper ?
     927                that.offset.top - cop.top :
     928                (that.offset.top - co.top)) );
     929
     930        if ( woset + that.size.width >= that.parentData.width ) {
     931            that.size.width = that.parentData.width - woset;
     932            if ( pRatio ) {
     933                that.size.height = that.size.width / that.aspectRatio;
     934                continueResize = false;
     935            }
     936        }
     937
     938        if ( hoset + that.size.height >= that.parentData.height ) {
     939            that.size.height = that.parentData.height - hoset;
     940            if ( pRatio ) {
     941                that.size.width = that.size.height * that.aspectRatio;
     942                continueResize = false;
     943            }
     944        }
     945
     946        if ( !continueResize ){
     947            that.position.left = that.prevPosition.left;
     948            that.position.top = that.prevPosition.top;
     949            that.size.width = that.prevSize.width;
     950            that.size.height = that.prevSize.height;
     951        }
     952    },
     953
     954    stop: function() {
     955        var that = $( this ).resizable( "instance" ),
     956            o = that.options,
     957            co = that.containerOffset,
     958            cop = that.containerPosition,
     959            ce = that.containerElement,
     960            helper = $( that.helper ),
     961            ho = helper.offset(),
     962            w = helper.outerWidth() - that.sizeDiff.width,
     963            h = helper.outerHeight() - that.sizeDiff.height;
     964
     965        if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
     966            $( this ).css({
     967                left: ho.left - cop.left - co.left,
     968                width: w,
     969                height: h
     970            });
     971        }
     972
     973        if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
     974            $( this ).css({
     975                left: ho.left - cop.left - co.left,
     976                width: w,
     977                height: h
     978            });
     979        }
     980    }
     981});
     982
     983$.ui.plugin.add("resizable", "alsoResize", {
     984
     985    start: function() {
     986        var that = $(this).resizable( "instance" ),
     987            o = that.options,
     988            _store = function(exp) {
     989                $(exp).each(function() {
     990                    var el = $(this);
     991                    el.data("ui-resizable-alsoresize", {
     992                        width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
     993                        left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
     994                    });
     995                });
     996            };
     997
     998        if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
     999            if (o.alsoResize.length) {
     1000                o.alsoResize = o.alsoResize[0];
     1001                _store(o.alsoResize);
     1002            } else {
     1003                $.each(o.alsoResize, function(exp) {
     1004                    _store(exp);
     1005                });
     1006            }
     1007        } else {
     1008            _store(o.alsoResize);
     1009        }
     1010    },
     1011
     1012    resize: function(event, ui) {
     1013        var that = $(this).resizable( "instance" ),
     1014            o = that.options,
     1015            os = that.originalSize,
     1016            op = that.originalPosition,
     1017            delta = {
     1018                height: (that.size.height - os.height) || 0,
     1019                width: (that.size.width - os.width) || 0,
     1020                top: (that.position.top - op.top) || 0,
     1021                left: (that.position.left - op.left) || 0
     1022            },
     1023
     1024            _alsoResize = function(exp, c) {
     1025                $(exp).each(function() {
     1026                    var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
     1027                        css = c && c.length ?
     1028                            c :
     1029                            el.parents(ui.originalElement[0]).length ?
     1030                                [ "width", "height" ] :
     1031                                [ "width", "height", "top", "left" ];
     1032
     1033                    $.each(css, function(i, prop) {
     1034                        var sum = (start[prop] || 0) + (delta[prop] || 0);
     1035                        if (sum && sum >= 0) {
     1036                            style[prop] = sum || null;
     1037                        }
     1038                    });
     1039
     1040                    el.css(style);
     1041                });
     1042            };
     1043
     1044        if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
     1045            $.each(o.alsoResize, function(exp, c) {
     1046                _alsoResize(exp, c);
     1047            });
     1048        } else {
     1049            _alsoResize(o.alsoResize);
     1050        }
     1051    },
     1052
     1053    stop: function() {
     1054        $(this).removeData("resizable-alsoresize");
     1055    }
     1056});
     1057
     1058$.ui.plugin.add("resizable", "ghost", {
     1059
     1060    start: function() {
     1061
     1062        var that = $(this).resizable( "instance" ), o = that.options, cs = that.size;
     1063
     1064        that.ghost = that.originalElement.clone();
     1065        that.ghost
     1066            .css({
     1067                opacity: 0.25,
     1068                display: "block",
     1069                position: "relative",
     1070                height: cs.height,
     1071                width: cs.width,
     1072                margin: 0,
     1073                left: 0,
     1074                top: 0
     1075            })
     1076            .addClass("ui-resizable-ghost")
     1077            .addClass(typeof o.ghost === "string" ? o.ghost : "");
     1078
     1079        that.ghost.appendTo(that.helper);
     1080
     1081    },
     1082
     1083    resize: function() {
     1084        var that = $(this).resizable( "instance" );
     1085        if (that.ghost) {
     1086            that.ghost.css({
     1087                position: "relative",
     1088                height: that.size.height,
     1089                width: that.size.width
     1090            });
     1091        }
     1092    },
     1093
     1094    stop: function() {
     1095        var that = $(this).resizable( "instance" );
     1096        if (that.ghost && that.helper) {
     1097            that.helper.get(0).removeChild(that.ghost.get(0));
     1098        }
     1099    }
     1100
     1101});
     1102
     1103$.ui.plugin.add("resizable", "grid", {
     1104
     1105    resize: function() {
     1106        var outerDimensions,
     1107            that = $(this).resizable( "instance" ),
     1108            o = that.options,
     1109            cs = that.size,
     1110            os = that.originalSize,
     1111            op = that.originalPosition,
     1112            a = that.axis,
     1113            grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
     1114            gridX = (grid[0] || 1),
     1115            gridY = (grid[1] || 1),
     1116            ox = Math.round((cs.width - os.width) / gridX) * gridX,
     1117            oy = Math.round((cs.height - os.height) / gridY) * gridY,
     1118            newWidth = os.width + ox,
     1119            newHeight = os.height + oy,
     1120            isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
     1121            isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
     1122            isMinWidth = o.minWidth && (o.minWidth > newWidth),
     1123            isMinHeight = o.minHeight && (o.minHeight > newHeight);
     1124
     1125        o.grid = grid;
     1126
     1127        if (isMinWidth) {
     1128            newWidth += gridX;
     1129        }
     1130        if (isMinHeight) {
     1131            newHeight += gridY;
     1132        }
     1133        if (isMaxWidth) {
     1134            newWidth -= gridX;
     1135        }
     1136        if (isMaxHeight) {
     1137            newHeight -= gridY;
     1138        }
     1139
     1140        if (/^(se|s|e)$/.test(a)) {
     1141            that.size.width = newWidth;
     1142            that.size.height = newHeight;
     1143        } else if (/^(ne)$/.test(a)) {
     1144            that.size.width = newWidth;
     1145            that.size.height = newHeight;
     1146            that.position.top = op.top - oy;
     1147        } else if (/^(sw)$/.test(a)) {
     1148            that.size.width = newWidth;
     1149            that.size.height = newHeight;
     1150            that.position.left = op.left - ox;
     1151        } else {
     1152            if ( newHeight - gridY <= 0 || newWidth - gridX <= 0) {
     1153                outerDimensions = that._getPaddingPlusBorderDimensions( this );
     1154            }
     1155
     1156            if ( newHeight - gridY > 0 ) {
     1157                that.size.height = newHeight;
     1158                that.position.top = op.top - oy;
     1159            } else {
     1160                newHeight = gridY - outerDimensions.height;
     1161                that.size.height = newHeight;
     1162                that.position.top = op.top + os.height - newHeight;
     1163            }
     1164            if ( newWidth - gridX > 0 ) {
     1165                that.size.width = newWidth;
     1166                that.position.left = op.left - ox;
     1167            } else {
     1168                newWidth = gridY - outerDimensions.height;
     1169                that.size.width = newWidth;
     1170                that.position.left = op.left + os.width - newWidth;
     1171            }
     1172        }
     1173    }
     1174
     1175});
     1176
     1177return $.ui.resizable;
     1178
     1179}));
  • trunk/src/wp-includes/js/jquery/ui/selectable.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(e){e.widget("ui.selectable",e.ui.mouse,{version:"1.10.4",options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch",selected:null,selecting:null,start:null,stop:null,unselected:null,unselecting:null},_create:function(){var t,i=this;this.element.addClass("ui-selectable"),this.dragged=!1,this.refresh=function(){t=e(i.options.filter,i.element[0]),t.addClass("ui-selectee"),t.each(function(){var t=e(this),i=t.offset();e.data(this,"selectable-item",{element:this,$element:t,left:i.left,top:i.top,right:i.left+t.outerWidth(),bottom:i.top+t.outerHeight(),startselected:!1,selected:t.hasClass("ui-selected"),selecting:t.hasClass("ui-selecting"),unselecting:t.hasClass("ui-unselecting")})})},this.refresh(),this.selectees=t.addClass("ui-selectee"),this._mouseInit(),this.helper=e("<div class='ui-selectable-helper'></div>")},_destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item"),this.element.removeClass("ui-selectable ui-selectable-disabled"),this._mouseDestroy()},_mouseStart:function(t){var i=this,s=this.options;this.opos=[t.pageX,t.pageY],this.options.disabled||(this.selectees=e(s.filter,this.element[0]),this._trigger("start",t),e(s.appendTo).append(this.helper),this.helper.css({left:t.pageX,top:t.pageY,width:0,height:0}),s.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var s=e.data(this,"selectable-item");s.startselected=!0,t.metaKey||t.ctrlKey||(s.$element.removeClass("ui-selected"),s.selected=!1,s.$element.addClass("ui-unselecting"),s.unselecting=!0,i._trigger("unselecting",t,{unselecting:s.element}))}),e(t.target).parents().addBack().each(function(){var s,n=e.data(this,"selectable-item");return n?(s=!t.metaKey&&!t.ctrlKey||!n.$element.hasClass("ui-selected"),n.$element.removeClass(s?"ui-unselecting":"ui-selected").addClass(s?"ui-selecting":"ui-unselecting"),n.unselecting=!s,n.selecting=s,n.selected=s,s?i._trigger("selecting",t,{selecting:n.element}):i._trigger("unselecting",t,{unselecting:n.element}),!1):undefined}))},_mouseDrag:function(t){if(this.dragged=!0,!this.options.disabled){var i,s=this,n=this.options,a=this.opos[0],o=this.opos[1],r=t.pageX,h=t.pageY;return a>r&&(i=r,r=a,a=i),o>h&&(i=h,h=o,o=i),this.helper.css({left:a,top:o,width:r-a,height:h-o}),this.selectees.each(function(){var i=e.data(this,"selectable-item"),l=!1;i&&i.element!==s.element[0]&&("touch"===n.tolerance?l=!(i.left>r||a>i.right||i.top>h||o>i.bottom):"fit"===n.tolerance&&(l=i.left>a&&r>i.right&&i.top>o&&h>i.bottom),l?(i.selected&&(i.$element.removeClass("ui-selected"),i.selected=!1),i.unselecting&&(i.$element.removeClass("ui-unselecting"),i.unselecting=!1),i.selecting||(i.$element.addClass("ui-selecting"),i.selecting=!0,s._trigger("selecting",t,{selecting:i.element}))):(i.selecting&&((t.metaKey||t.ctrlKey)&&i.startselected?(i.$element.removeClass("ui-selecting"),i.selecting=!1,i.$element.addClass("ui-selected"),i.selected=!0):(i.$element.removeClass("ui-selecting"),i.selecting=!1,i.startselected&&(i.$element.addClass("ui-unselecting"),i.unselecting=!0),s._trigger("unselecting",t,{unselecting:i.element}))),i.selected&&(t.metaKey||t.ctrlKey||i.startselected||(i.$element.removeClass("ui-selected"),i.selected=!1,i.$element.addClass("ui-unselecting"),i.unselecting=!0,s._trigger("unselecting",t,{unselecting:i.element})))))}),!1}},_mouseStop:function(t){var i=this;return this.dragged=!1,e(".ui-unselecting",this.element[0]).each(function(){var s=e.data(this,"selectable-item");s.$element.removeClass("ui-unselecting"),s.unselecting=!1,s.startselected=!1,i._trigger("unselected",t,{unselected:s.element})}),e(".ui-selecting",this.element[0]).each(function(){var s=e.data(this,"selectable-item");s.$element.removeClass("ui-selecting").addClass("ui-selected"),s.selecting=!1,s.selected=!0,s.startselected=!0,i._trigger("selected",t,{selected:s.element})}),this._trigger("stop",t),this.helper.remove(),!1}})})(jQuery);
     1/*!
     2 * jQuery UI Selectable 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/selectable/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./core",
     18            "./mouse",
     19            "./widget"
     20        ], factory );
     21    } else {
     22
     23        // Browser globals
     24        factory( jQuery );
     25    }
     26}(function( $ ) {
     27
     28return $.widget("ui.selectable", $.ui.mouse, {
     29    version: "1.11.1",
     30    options: {
     31        appendTo: "body",
     32        autoRefresh: true,
     33        distance: 0,
     34        filter: "*",
     35        tolerance: "touch",
     36
     37        // callbacks
     38        selected: null,
     39        selecting: null,
     40        start: null,
     41        stop: null,
     42        unselected: null,
     43        unselecting: null
     44    },
     45    _create: function() {
     46        var selectees,
     47            that = this;
     48
     49        this.element.addClass("ui-selectable");
     50
     51        this.dragged = false;
     52
     53        // cache selectee children based on filter
     54        this.refresh = function() {
     55            selectees = $(that.options.filter, that.element[0]);
     56            selectees.addClass("ui-selectee");
     57            selectees.each(function() {
     58                var $this = $(this),
     59                    pos = $this.offset();
     60                $.data(this, "selectable-item", {
     61                    element: this,
     62                    $element: $this,
     63                    left: pos.left,
     64                    top: pos.top,
     65                    right: pos.left + $this.outerWidth(),
     66                    bottom: pos.top + $this.outerHeight(),
     67                    startselected: false,
     68                    selected: $this.hasClass("ui-selected"),
     69                    selecting: $this.hasClass("ui-selecting"),
     70                    unselecting: $this.hasClass("ui-unselecting")
     71                });
     72            });
     73        };
     74        this.refresh();
     75
     76        this.selectees = selectees.addClass("ui-selectee");
     77
     78        this._mouseInit();
     79
     80        this.helper = $("<div class='ui-selectable-helper'></div>");
     81    },
     82
     83    _destroy: function() {
     84        this.selectees
     85            .removeClass("ui-selectee")
     86            .removeData("selectable-item");
     87        this.element
     88            .removeClass("ui-selectable ui-selectable-disabled");
     89        this._mouseDestroy();
     90    },
     91
     92    _mouseStart: function(event) {
     93        var that = this,
     94            options = this.options;
     95
     96        this.opos = [ event.pageX, event.pageY ];
     97
     98        if (this.options.disabled) {
     99            return;
     100        }
     101
     102        this.selectees = $(options.filter, this.element[0]);
     103
     104        this._trigger("start", event);
     105
     106        $(options.appendTo).append(this.helper);
     107        // position helper (lasso)
     108        this.helper.css({
     109            "left": event.pageX,
     110            "top": event.pageY,
     111            "width": 0,
     112            "height": 0
     113        });
     114
     115        if (options.autoRefresh) {
     116            this.refresh();
     117        }
     118
     119        this.selectees.filter(".ui-selected").each(function() {
     120            var selectee = $.data(this, "selectable-item");
     121            selectee.startselected = true;
     122            if (!event.metaKey && !event.ctrlKey) {
     123                selectee.$element.removeClass("ui-selected");
     124                selectee.selected = false;
     125                selectee.$element.addClass("ui-unselecting");
     126                selectee.unselecting = true;
     127                // selectable UNSELECTING callback
     128                that._trigger("unselecting", event, {
     129                    unselecting: selectee.element
     130                });
     131            }
     132        });
     133
     134        $(event.target).parents().addBack().each(function() {
     135            var doSelect,
     136                selectee = $.data(this, "selectable-item");
     137            if (selectee) {
     138                doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
     139                selectee.$element
     140                    .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
     141                    .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
     142                selectee.unselecting = !doSelect;
     143                selectee.selecting = doSelect;
     144                selectee.selected = doSelect;
     145                // selectable (UN)SELECTING callback
     146                if (doSelect) {
     147                    that._trigger("selecting", event, {
     148                        selecting: selectee.element
     149                    });
     150                } else {
     151                    that._trigger("unselecting", event, {
     152                        unselecting: selectee.element
     153                    });
     154                }
     155                return false;
     156            }
     157        });
     158
     159    },
     160
     161    _mouseDrag: function(event) {
     162
     163        this.dragged = true;
     164
     165        if (this.options.disabled) {
     166            return;
     167        }
     168
     169        var tmp,
     170            that = this,
     171            options = this.options,
     172            x1 = this.opos[0],
     173            y1 = this.opos[1],
     174            x2 = event.pageX,
     175            y2 = event.pageY;
     176
     177        if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
     178        if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
     179        this.helper.css({ left: x1, top: y1, width: x2 - x1, height: y2 - y1 });
     180
     181        this.selectees.each(function() {
     182            var selectee = $.data(this, "selectable-item"),
     183                hit = false;
     184
     185            //prevent helper from being selected if appendTo: selectable
     186            if (!selectee || selectee.element === that.element[0]) {
     187                return;
     188            }
     189
     190            if (options.tolerance === "touch") {
     191                hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
     192            } else if (options.tolerance === "fit") {
     193                hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
     194            }
     195
     196            if (hit) {
     197                // SELECT
     198                if (selectee.selected) {
     199                    selectee.$element.removeClass("ui-selected");
     200                    selectee.selected = false;
     201                }
     202                if (selectee.unselecting) {
     203                    selectee.$element.removeClass("ui-unselecting");
     204                    selectee.unselecting = false;
     205                }
     206                if (!selectee.selecting) {
     207                    selectee.$element.addClass("ui-selecting");
     208                    selectee.selecting = true;
     209                    // selectable SELECTING callback
     210                    that._trigger("selecting", event, {
     211                        selecting: selectee.element
     212                    });
     213                }
     214            } else {
     215                // UNSELECT
     216                if (selectee.selecting) {
     217                    if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
     218                        selectee.$element.removeClass("ui-selecting");
     219                        selectee.selecting = false;
     220                        selectee.$element.addClass("ui-selected");
     221                        selectee.selected = true;
     222                    } else {
     223                        selectee.$element.removeClass("ui-selecting");
     224                        selectee.selecting = false;
     225                        if (selectee.startselected) {
     226                            selectee.$element.addClass("ui-unselecting");
     227                            selectee.unselecting = true;
     228                        }
     229                        // selectable UNSELECTING callback
     230                        that._trigger("unselecting", event, {
     231                            unselecting: selectee.element
     232                        });
     233                    }
     234                }
     235                if (selectee.selected) {
     236                    if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
     237                        selectee.$element.removeClass("ui-selected");
     238                        selectee.selected = false;
     239
     240                        selectee.$element.addClass("ui-unselecting");
     241                        selectee.unselecting = true;
     242                        // selectable UNSELECTING callback
     243                        that._trigger("unselecting", event, {
     244                            unselecting: selectee.element
     245                        });
     246                    }
     247                }
     248            }
     249        });
     250
     251        return false;
     252    },
     253
     254    _mouseStop: function(event) {
     255        var that = this;
     256
     257        this.dragged = false;
     258
     259        $(".ui-unselecting", this.element[0]).each(function() {
     260            var selectee = $.data(this, "selectable-item");
     261            selectee.$element.removeClass("ui-unselecting");
     262            selectee.unselecting = false;
     263            selectee.startselected = false;
     264            that._trigger("unselected", event, {
     265                unselected: selectee.element
     266            });
     267        });
     268        $(".ui-selecting", this.element[0]).each(function() {
     269            var selectee = $.data(this, "selectable-item");
     270            selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
     271            selectee.selecting = false;
     272            selectee.selected = true;
     273            selectee.startselected = true;
     274            that._trigger("selected", event, {
     275                selected: selectee.element
     276            });
     277        });
     278        this._trigger("stop", event);
     279
     280        this.helper.remove();
     281
     282        return false;
     283    }
     284
     285});
     286
     287}));
  • trunk/src/wp-includes/js/jquery/ui/slider.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){var e=5;t.widget("ui.slider",t.ui.mouse,{version:"1.10.4",widgetEventPrefix:"slide",options:{animate:!1,distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null,change:null,slide:null,start:null,stop:null},_create:function(){this._keySliding=!1,this._mouseSliding=!1,this._animateOff=!0,this._handleIndex=null,this._detectOrientation(),this._mouseInit(),this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget"+" ui-widget-content"+" ui-corner-all"),this._refresh(),this._setOption("disabled",this.options.disabled),this._animateOff=!1},_refresh:function(){this._createRange(),this._createHandles(),this._setupEvents(),this._refreshValue()},_createHandles:function(){var e,i,s=this.options,n=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),a="<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",o=[];for(i=s.values&&s.values.length||1,n.length>i&&(n.slice(i).remove(),n=n.slice(0,i)),e=n.length;i>e;e++)o.push(a);this.handles=n.add(t(o.join("")).appendTo(this.element)),this.handle=this.handles.eq(0),this.handles.each(function(e){t(this).data("ui-slider-handle-index",e)})},_createRange:function(){var e=this.options,i="";e.range?(e.range===!0&&(e.values?e.values.length&&2!==e.values.length?e.values=[e.values[0],e.values[0]]:t.isArray(e.values)&&(e.values=e.values.slice(0)):e.values=[this._valueMin(),this._valueMin()]),this.range&&this.range.length?this.range.removeClass("ui-slider-range-min ui-slider-range-max").css({left:"",bottom:""}):(this.range=t("<div></div>").appendTo(this.element),i="ui-slider-range ui-widget-header ui-corner-all"),this.range.addClass(i+("min"===e.range||"max"===e.range?" ui-slider-range-"+e.range:""))):(this.range&&this.range.remove(),this.range=null)},_setupEvents:function(){var t=this.handles.add(this.range).filter("a");this._off(t),this._on(t,this._handleEvents),this._hoverable(t),this._focusable(t)},_destroy:function(){this.handles.remove(),this.range&&this.range.remove(),this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-widget ui-widget-content ui-corner-all"),this._mouseDestroy()},_mouseCapture:function(e){var i,s,n,a,o,r,h,l,u=this,c=this.options;return c.disabled?!1:(this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()},this.elementOffset=this.element.offset(),i={x:e.pageX,y:e.pageY},s=this._normValueFromMouse(i),n=this._valueMax()-this._valueMin()+1,this.handles.each(function(e){var i=Math.abs(s-u.values(e));(n>i||n===i&&(e===u._lastChangedValue||u.values(e)===c.min))&&(n=i,a=t(this),o=e)}),r=this._start(e,o),r===!1?!1:(this._mouseSliding=!0,this._handleIndex=o,a.addClass("ui-state-active").focus(),h=a.offset(),l=!t(e.target).parents().addBack().is(".ui-slider-handle"),this._clickOffset=l?{left:0,top:0}:{left:e.pageX-h.left-a.width()/2,top:e.pageY-h.top-a.height()/2-(parseInt(a.css("borderTopWidth"),10)||0)-(parseInt(a.css("borderBottomWidth"),10)||0)+(parseInt(a.css("marginTop"),10)||0)},this.handles.hasClass("ui-state-hover")||this._slide(e,o,s),this._animateOff=!0,!0))},_mouseStart:function(){return!0},_mouseDrag:function(t){var e={x:t.pageX,y:t.pageY},i=this._normValueFromMouse(e);return this._slide(t,this._handleIndex,i),!1},_mouseStop:function(t){return this.handles.removeClass("ui-state-active"),this._mouseSliding=!1,this._stop(t,this._handleIndex),this._change(t,this._handleIndex),this._handleIndex=null,this._clickOffset=null,this._animateOff=!1,!1},_detectOrientation:function(){this.orientation="vertical"===this.options.orientation?"vertical":"horizontal"},_normValueFromMouse:function(t){var e,i,s,n,a;return"horizontal"===this.orientation?(e=this.elementSize.width,i=t.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(e=this.elementSize.height,i=t.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)),s=i/e,s>1&&(s=1),0>s&&(s=0),"vertical"===this.orientation&&(s=1-s),n=this._valueMax()-this._valueMin(),a=this._valueMin()+s*n,this._trimAlignValue(a)},_start:function(t,e){var i={handle:this.handles[e],value:this.value()};return this.options.values&&this.options.values.length&&(i.value=this.values(e),i.values=this.values()),this._trigger("start",t,i)},_slide:function(t,e,i){var s,n,a;this.options.values&&this.options.values.length?(s=this.values(e?0:1),2===this.options.values.length&&this.options.range===!0&&(0===e&&i>s||1===e&&s>i)&&(i=s),i!==this.values(e)&&(n=this.values(),n[e]=i,a=this._trigger("slide",t,{handle:this.handles[e],value:i,values:n}),s=this.values(e?0:1),a!==!1&&this.values(e,i))):i!==this.value()&&(a=this._trigger("slide",t,{handle:this.handles[e],value:i}),a!==!1&&this.value(i))},_stop:function(t,e){var i={handle:this.handles[e],value:this.value()};this.options.values&&this.options.values.length&&(i.value=this.values(e),i.values=this.values()),this._trigger("stop",t,i)},_change:function(t,e){if(!this._keySliding&&!this._mouseSliding){var i={handle:this.handles[e],value:this.value()};this.options.values&&this.options.values.length&&(i.value=this.values(e),i.values=this.values()),this._lastChangedValue=e,this._trigger("change",t,i)}},value:function(t){return arguments.length?(this.options.value=this._trimAlignValue(t),this._refreshValue(),this._change(null,0),undefined):this._value()},values:function(e,i){var s,n,a;if(arguments.length>1)return this.options.values[e]=this._trimAlignValue(i),this._refreshValue(),this._change(null,e),undefined;if(!arguments.length)return this._values();if(!t.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(e):this.value();for(s=this.options.values,n=arguments[0],a=0;s.length>a;a+=1)s[a]=this._trimAlignValue(n[a]),this._change(null,a);this._refreshValue()},_setOption:function(e,i){var s,n=0;switch("range"===e&&this.options.range===!0&&("min"===i?(this.options.value=this._values(0),this.options.values=null):"max"===i&&(this.options.value=this._values(this.options.values.length-1),this.options.values=null)),t.isArray(this.options.values)&&(n=this.options.values.length),t.Widget.prototype._setOption.apply(this,arguments),e){case"orientation":this._detectOrientation(),this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation),this._refreshValue();break;case"value":this._animateOff=!0,this._refreshValue(),this._change(null,0),this._animateOff=!1;break;case"values":for(this._animateOff=!0,this._refreshValue(),s=0;n>s;s+=1)this._change(null,s);this._animateOff=!1;break;case"min":case"max":this._animateOff=!0,this._refreshValue(),this._animateOff=!1;break;case"range":this._animateOff=!0,this._refresh(),this._animateOff=!1}},_value:function(){var t=this.options.value;return t=this._trimAlignValue(t)},_values:function(t){var e,i,s;if(arguments.length)return e=this.options.values[t],e=this._trimAlignValue(e);if(this.options.values&&this.options.values.length){for(i=this.options.values.slice(),s=0;i.length>s;s+=1)i[s]=this._trimAlignValue(i[s]);return i}return[]},_trimAlignValue:function(t){if(this._valueMin()>=t)return this._valueMin();if(t>=this._valueMax())return this._valueMax();var e=this.options.step>0?this.options.step:1,i=(t-this._valueMin())%e,s=t-i;return 2*Math.abs(i)>=e&&(s+=i>0?e:-e),parseFloat(s.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var e,i,s,n,a,o=this.options.range,r=this.options,h=this,l=this._animateOff?!1:r.animate,u={};this.options.values&&this.options.values.length?this.handles.each(function(s){i=100*((h.values(s)-h._valueMin())/(h._valueMax()-h._valueMin())),u["horizontal"===h.orientation?"left":"bottom"]=i+"%",t(this).stop(1,1)[l?"animate":"css"](u,r.animate),h.options.range===!0&&("horizontal"===h.orientation?(0===s&&h.range.stop(1,1)[l?"animate":"css"]({left:i+"%"},r.animate),1===s&&h.range[l?"animate":"css"]({width:i-e+"%"},{queue:!1,duration:r.animate})):(0===s&&h.range.stop(1,1)[l?"animate":"css"]({bottom:i+"%"},r.animate),1===s&&h.range[l?"animate":"css"]({height:i-e+"%"},{queue:!1,duration:r.animate}))),e=i}):(s=this.value(),n=this._valueMin(),a=this._valueMax(),i=a!==n?100*((s-n)/(a-n)):0,u["horizontal"===this.orientation?"left":"bottom"]=i+"%",this.handle.stop(1,1)[l?"animate":"css"](u,r.animate),"min"===o&&"horizontal"===this.orientation&&this.range.stop(1,1)[l?"animate":"css"]({width:i+"%"},r.animate),"max"===o&&"horizontal"===this.orientation&&this.range[l?"animate":"css"]({width:100-i+"%"},{queue:!1,duration:r.animate}),"min"===o&&"vertical"===this.orientation&&this.range.stop(1,1)[l?"animate":"css"]({height:i+"%"},r.animate),"max"===o&&"vertical"===this.orientation&&this.range[l?"animate":"css"]({height:100-i+"%"},{queue:!1,duration:r.animate}))},_handleEvents:{keydown:function(i){var s,n,a,o,r=t(i.target).data("ui-slider-handle-index");switch(i.keyCode){case t.ui.keyCode.HOME:case t.ui.keyCode.END:case t.ui.keyCode.PAGE_UP:case t.ui.keyCode.PAGE_DOWN:case t.ui.keyCode.UP:case t.ui.keyCode.RIGHT:case t.ui.keyCode.DOWN:case t.ui.keyCode.LEFT:if(i.preventDefault(),!this._keySliding&&(this._keySliding=!0,t(i.target).addClass("ui-state-active"),s=this._start(i,r),s===!1))return}switch(o=this.options.step,n=a=this.options.values&&this.options.values.length?this.values(r):this.value(),i.keyCode){case t.ui.keyCode.HOME:a=this._valueMin();break;case t.ui.keyCode.END:a=this._valueMax();break;case t.ui.keyCode.PAGE_UP:a=this._trimAlignValue(n+(this._valueMax()-this._valueMin())/e);break;case t.ui.keyCode.PAGE_DOWN:a=this._trimAlignValue(n-(this._valueMax()-this._valueMin())/e);break;case t.ui.keyCode.UP:case t.ui.keyCode.RIGHT:if(n===this._valueMax())return;a=this._trimAlignValue(n+o);break;case t.ui.keyCode.DOWN:case t.ui.keyCode.LEFT:if(n===this._valueMin())return;a=this._trimAlignValue(n-o)}this._slide(i,r,a)},click:function(t){t.preventDefault()},keyup:function(e){var i=t(e.target).data("ui-slider-handle-index");this._keySliding&&(this._keySliding=!1,this._stop(e,i),this._change(e,i),t(e.target).removeClass("ui-state-active"))}}})})(jQuery);
     1/*!
     2 * jQuery UI Slider 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/slider/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./core",
     18            "./mouse",
     19            "./widget"
     20        ], factory );
     21    } else {
     22
     23        // Browser globals
     24        factory( jQuery );
     25    }
     26}(function( $ ) {
     27
     28return $.widget( "ui.slider", $.ui.mouse, {
     29    version: "1.11.1",
     30    widgetEventPrefix: "slide",
     31
     32    options: {
     33        animate: false,
     34        distance: 0,
     35        max: 100,
     36        min: 0,
     37        orientation: "horizontal",
     38        range: false,
     39        step: 1,
     40        value: 0,
     41        values: null,
     42
     43        // callbacks
     44        change: null,
     45        slide: null,
     46        start: null,
     47        stop: null
     48    },
     49
     50    // number of pages in a slider
     51    // (how many times can you page up/down to go through the whole range)
     52    numPages: 5,
     53
     54    _create: function() {
     55        this._keySliding = false;
     56        this._mouseSliding = false;
     57        this._animateOff = true;
     58        this._handleIndex = null;
     59        this._detectOrientation();
     60        this._mouseInit();
     61
     62        this.element
     63            .addClass( "ui-slider" +
     64                " ui-slider-" + this.orientation +
     65                " ui-widget" +
     66                " ui-widget-content" +
     67                " ui-corner-all");
     68
     69        this._refresh();
     70        this._setOption( "disabled", this.options.disabled );
     71
     72        this._animateOff = false;
     73    },
     74
     75    _refresh: function() {
     76        this._createRange();
     77        this._createHandles();
     78        this._setupEvents();
     79        this._refreshValue();
     80    },
     81
     82    _createHandles: function() {
     83        var i, handleCount,
     84            options = this.options,
     85            existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
     86            handle = "<span class='ui-slider-handle ui-state-default ui-corner-all' tabindex='0'></span>",
     87            handles = [];
     88
     89        handleCount = ( options.values && options.values.length ) || 1;
     90
     91        if ( existingHandles.length > handleCount ) {
     92            existingHandles.slice( handleCount ).remove();
     93            existingHandles = existingHandles.slice( 0, handleCount );
     94        }
     95
     96        for ( i = existingHandles.length; i < handleCount; i++ ) {
     97            handles.push( handle );
     98        }
     99
     100        this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
     101
     102        this.handle = this.handles.eq( 0 );
     103
     104        this.handles.each(function( i ) {
     105            $( this ).data( "ui-slider-handle-index", i );
     106        });
     107    },
     108
     109    _createRange: function() {
     110        var options = this.options,
     111            classes = "";
     112
     113        if ( options.range ) {
     114            if ( options.range === true ) {
     115                if ( !options.values ) {
     116                    options.values = [ this._valueMin(), this._valueMin() ];
     117                } else if ( options.values.length && options.values.length !== 2 ) {
     118                    options.values = [ options.values[0], options.values[0] ];
     119                } else if ( $.isArray( options.values ) ) {
     120                    options.values = options.values.slice(0);
     121                }
     122            }
     123
     124            if ( !this.range || !this.range.length ) {
     125                this.range = $( "<div></div>" )
     126                    .appendTo( this.element );
     127
     128                classes = "ui-slider-range" +
     129                // note: this isn't the most fittingly semantic framework class for this element,
     130                // but worked best visually with a variety of themes
     131                " ui-widget-header ui-corner-all";
     132            } else {
     133                this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
     134                    // Handle range switching from true to min/max
     135                    .css({
     136                        "left": "",
     137                        "bottom": ""
     138                    });
     139            }
     140
     141            this.range.addClass( classes +
     142                ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
     143        } else {
     144            if ( this.range ) {
     145                this.range.remove();
     146            }
     147            this.range = null;
     148        }
     149    },
     150
     151    _setupEvents: function() {
     152        this._off( this.handles );
     153        this._on( this.handles, this._handleEvents );
     154        this._hoverable( this.handles );
     155        this._focusable( this.handles );
     156    },
     157
     158    _destroy: function() {
     159        this.handles.remove();
     160        if ( this.range ) {
     161            this.range.remove();
     162        }
     163
     164        this.element
     165            .removeClass( "ui-slider" +
     166                " ui-slider-horizontal" +
     167                " ui-slider-vertical" +
     168                " ui-widget" +
     169                " ui-widget-content" +
     170                " ui-corner-all" );
     171
     172        this._mouseDestroy();
     173    },
     174
     175    _mouseCapture: function( event ) {
     176        var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
     177            that = this,
     178            o = this.options;
     179
     180        if ( o.disabled ) {
     181            return false;
     182        }
     183
     184        this.elementSize = {
     185            width: this.element.outerWidth(),
     186            height: this.element.outerHeight()
     187        };
     188        this.elementOffset = this.element.offset();
     189
     190        position = { x: event.pageX, y: event.pageY };
     191        normValue = this._normValueFromMouse( position );
     192        distance = this._valueMax() - this._valueMin() + 1;
     193        this.handles.each(function( i ) {
     194            var thisDistance = Math.abs( normValue - that.values(i) );
     195            if (( distance > thisDistance ) ||
     196                ( distance === thisDistance &&
     197                    (i === that._lastChangedValue || that.values(i) === o.min ))) {
     198                distance = thisDistance;
     199                closestHandle = $( this );
     200                index = i;
     201            }
     202        });
     203
     204        allowed = this._start( event, index );
     205        if ( allowed === false ) {
     206            return false;
     207        }
     208        this._mouseSliding = true;
     209
     210        this._handleIndex = index;
     211
     212        closestHandle
     213            .addClass( "ui-state-active" )
     214            .focus();
     215
     216        offset = closestHandle.offset();
     217        mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
     218        this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
     219            left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
     220            top: event.pageY - offset.top -
     221                ( closestHandle.height() / 2 ) -
     222                ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
     223                ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
     224                ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
     225        };
     226
     227        if ( !this.handles.hasClass( "ui-state-hover" ) ) {
     228            this._slide( event, index, normValue );
     229        }
     230        this._animateOff = true;
     231        return true;
     232    },
     233
     234    _mouseStart: function() {
     235        return true;
     236    },
     237
     238    _mouseDrag: function( event ) {
     239        var position = { x: event.pageX, y: event.pageY },
     240            normValue = this._normValueFromMouse( position );
     241
     242        this._slide( event, this._handleIndex, normValue );
     243
     244        return false;
     245    },
     246
     247    _mouseStop: function( event ) {
     248        this.handles.removeClass( "ui-state-active" );
     249        this._mouseSliding = false;
     250
     251        this._stop( event, this._handleIndex );
     252        this._change( event, this._handleIndex );
     253
     254        this._handleIndex = null;
     255        this._clickOffset = null;
     256        this._animateOff = false;
     257
     258        return false;
     259    },
     260
     261    _detectOrientation: function() {
     262        this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
     263    },
     264
     265    _normValueFromMouse: function( position ) {
     266        var pixelTotal,
     267            pixelMouse,
     268            percentMouse,
     269            valueTotal,
     270            valueMouse;
     271
     272        if ( this.orientation === "horizontal" ) {
     273            pixelTotal = this.elementSize.width;
     274            pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
     275        } else {
     276            pixelTotal = this.elementSize.height;
     277            pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
     278        }
     279
     280        percentMouse = ( pixelMouse / pixelTotal );
     281        if ( percentMouse > 1 ) {
     282            percentMouse = 1;
     283        }
     284        if ( percentMouse < 0 ) {
     285            percentMouse = 0;
     286        }
     287        if ( this.orientation === "vertical" ) {
     288            percentMouse = 1 - percentMouse;
     289        }
     290
     291        valueTotal = this._valueMax() - this._valueMin();
     292        valueMouse = this._valueMin() + percentMouse * valueTotal;
     293
     294        return this._trimAlignValue( valueMouse );
     295    },
     296
     297    _start: function( event, index ) {
     298        var uiHash = {
     299            handle: this.handles[ index ],
     300            value: this.value()
     301        };
     302        if ( this.options.values && this.options.values.length ) {
     303            uiHash.value = this.values( index );
     304            uiHash.values = this.values();
     305        }
     306        return this._trigger( "start", event, uiHash );
     307    },
     308
     309    _slide: function( event, index, newVal ) {
     310        var otherVal,
     311            newValues,
     312            allowed;
     313
     314        if ( this.options.values && this.options.values.length ) {
     315            otherVal = this.values( index ? 0 : 1 );
     316
     317            if ( ( this.options.values.length === 2 && this.options.range === true ) &&
     318                    ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
     319                ) {
     320                newVal = otherVal;
     321            }
     322
     323            if ( newVal !== this.values( index ) ) {
     324                newValues = this.values();
     325                newValues[ index ] = newVal;
     326                // A slide can be canceled by returning false from the slide callback
     327                allowed = this._trigger( "slide", event, {
     328                    handle: this.handles[ index ],
     329                    value: newVal,
     330                    values: newValues
     331                } );
     332                otherVal = this.values( index ? 0 : 1 );
     333                if ( allowed !== false ) {
     334                    this.values( index, newVal );
     335                }
     336            }
     337        } else {
     338            if ( newVal !== this.value() ) {
     339                // A slide can be canceled by returning false from the slide callback
     340                allowed = this._trigger( "slide", event, {
     341                    handle: this.handles[ index ],
     342                    value: newVal
     343                } );
     344                if ( allowed !== false ) {
     345                    this.value( newVal );
     346                }
     347            }
     348        }
     349    },
     350
     351    _stop: function( event, index ) {
     352        var uiHash = {
     353            handle: this.handles[ index ],
     354            value: this.value()
     355        };
     356        if ( this.options.values && this.options.values.length ) {
     357            uiHash.value = this.values( index );
     358            uiHash.values = this.values();
     359        }
     360
     361        this._trigger( "stop", event, uiHash );
     362    },
     363
     364    _change: function( event, index ) {
     365        if ( !this._keySliding && !this._mouseSliding ) {
     366            var uiHash = {
     367                handle: this.handles[ index ],
     368                value: this.value()
     369            };
     370            if ( this.options.values && this.options.values.length ) {
     371                uiHash.value = this.values( index );
     372                uiHash.values = this.values();
     373            }
     374
     375            //store the last changed value index for reference when handles overlap
     376            this._lastChangedValue = index;
     377
     378            this._trigger( "change", event, uiHash );
     379        }
     380    },
     381
     382    value: function( newValue ) {
     383        if ( arguments.length ) {
     384            this.options.value = this._trimAlignValue( newValue );
     385            this._refreshValue();
     386            this._change( null, 0 );
     387            return;
     388        }
     389
     390        return this._value();
     391    },
     392
     393    values: function( index, newValue ) {
     394        var vals,
     395            newValues,
     396            i;
     397
     398        if ( arguments.length > 1 ) {
     399            this.options.values[ index ] = this._trimAlignValue( newValue );
     400            this._refreshValue();
     401            this._change( null, index );
     402            return;
     403        }
     404
     405        if ( arguments.length ) {
     406            if ( $.isArray( arguments[ 0 ] ) ) {
     407                vals = this.options.values;
     408                newValues = arguments[ 0 ];
     409                for ( i = 0; i < vals.length; i += 1 ) {
     410                    vals[ i ] = this._trimAlignValue( newValues[ i ] );
     411                    this._change( null, i );
     412                }
     413                this._refreshValue();
     414            } else {
     415                if ( this.options.values && this.options.values.length ) {
     416                    return this._values( index );
     417                } else {
     418                    return this.value();
     419                }
     420            }
     421        } else {
     422            return this._values();
     423        }
     424    },
     425
     426    _setOption: function( key, value ) {
     427        var i,
     428            valsLength = 0;
     429
     430        if ( key === "range" && this.options.range === true ) {
     431            if ( value === "min" ) {
     432                this.options.value = this._values( 0 );
     433                this.options.values = null;
     434            } else if ( value === "max" ) {
     435                this.options.value = this._values( this.options.values.length - 1 );
     436                this.options.values = null;
     437            }
     438        }
     439
     440        if ( $.isArray( this.options.values ) ) {
     441            valsLength = this.options.values.length;
     442        }
     443
     444        if ( key === "disabled" ) {
     445            this.element.toggleClass( "ui-state-disabled", !!value );
     446        }
     447
     448        this._super( key, value );
     449
     450        switch ( key ) {
     451            case "orientation":
     452                this._detectOrientation();
     453                this.element
     454                    .removeClass( "ui-slider-horizontal ui-slider-vertical" )
     455                    .addClass( "ui-slider-" + this.orientation );
     456                this._refreshValue();
     457
     458                // Reset positioning from previous orientation
     459                this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
     460                break;
     461            case "value":
     462                this._animateOff = true;
     463                this._refreshValue();
     464                this._change( null, 0 );
     465                this._animateOff = false;
     466                break;
     467            case "values":
     468                this._animateOff = true;
     469                this._refreshValue();
     470                for ( i = 0; i < valsLength; i += 1 ) {
     471                    this._change( null, i );
     472                }
     473                this._animateOff = false;
     474                break;
     475            case "min":
     476            case "max":
     477                this._animateOff = true;
     478                this._refreshValue();
     479                this._animateOff = false;
     480                break;
     481            case "range":
     482                this._animateOff = true;
     483                this._refresh();
     484                this._animateOff = false;
     485                break;
     486        }
     487    },
     488
     489    //internal value getter
     490    // _value() returns value trimmed by min and max, aligned by step
     491    _value: function() {
     492        var val = this.options.value;
     493        val = this._trimAlignValue( val );
     494
     495        return val;
     496    },
     497
     498    //internal values getter
     499    // _values() returns array of values trimmed by min and max, aligned by step
     500    // _values( index ) returns single value trimmed by min and max, aligned by step
     501    _values: function( index ) {
     502        var val,
     503            vals,
     504            i;
     505
     506        if ( arguments.length ) {
     507            val = this.options.values[ index ];
     508            val = this._trimAlignValue( val );
     509
     510            return val;
     511        } else if ( this.options.values && this.options.values.length ) {
     512            // .slice() creates a copy of the array
     513            // this copy gets trimmed by min and max and then returned
     514            vals = this.options.values.slice();
     515            for ( i = 0; i < vals.length; i+= 1) {
     516                vals[ i ] = this._trimAlignValue( vals[ i ] );
     517            }
     518
     519            return vals;
     520        } else {
     521            return [];
     522        }
     523    },
     524
     525    // returns the step-aligned value that val is closest to, between (inclusive) min and max
     526    _trimAlignValue: function( val ) {
     527        if ( val <= this._valueMin() ) {
     528            return this._valueMin();
     529        }
     530        if ( val >= this._valueMax() ) {
     531            return this._valueMax();
     532        }
     533        var step = ( this.options.step > 0 ) ? this.options.step : 1,
     534            valModStep = (val - this._valueMin()) % step,
     535            alignValue = val - valModStep;
     536
     537        if ( Math.abs(valModStep) * 2 >= step ) {
     538            alignValue += ( valModStep > 0 ) ? step : ( -step );
     539        }
     540
     541        // Since JavaScript has problems with large floats, round
     542        // the final value to 5 digits after the decimal point (see #4124)
     543        return parseFloat( alignValue.toFixed(5) );
     544    },
     545
     546    _valueMin: function() {
     547        return this.options.min;
     548    },
     549
     550    _valueMax: function() {
     551        return this.options.max;
     552    },
     553
     554    _refreshValue: function() {
     555        var lastValPercent, valPercent, value, valueMin, valueMax,
     556            oRange = this.options.range,
     557            o = this.options,
     558            that = this,
     559            animate = ( !this._animateOff ) ? o.animate : false,
     560            _set = {};
     561
     562        if ( this.options.values && this.options.values.length ) {
     563            this.handles.each(function( i ) {
     564                valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
     565                _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
     566                $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
     567                if ( that.options.range === true ) {
     568                    if ( that.orientation === "horizontal" ) {
     569                        if ( i === 0 ) {
     570                            that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
     571                        }
     572                        if ( i === 1 ) {
     573                            that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
     574                        }
     575                    } else {
     576                        if ( i === 0 ) {
     577                            that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
     578                        }
     579                        if ( i === 1 ) {
     580                            that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
     581                        }
     582                    }
     583                }
     584                lastValPercent = valPercent;
     585            });
     586        } else {
     587            value = this.value();
     588            valueMin = this._valueMin();
     589            valueMax = this._valueMax();
     590            valPercent = ( valueMax !== valueMin ) ?
     591                    ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
     592                    0;
     593            _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
     594            this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
     595
     596            if ( oRange === "min" && this.orientation === "horizontal" ) {
     597                this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
     598            }
     599            if ( oRange === "max" && this.orientation === "horizontal" ) {
     600                this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
     601            }
     602            if ( oRange === "min" && this.orientation === "vertical" ) {
     603                this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
     604            }
     605            if ( oRange === "max" && this.orientation === "vertical" ) {
     606                this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
     607            }
     608        }
     609    },
     610
     611    _handleEvents: {
     612        keydown: function( event ) {
     613            var allowed, curVal, newVal, step,
     614                index = $( event.target ).data( "ui-slider-handle-index" );
     615
     616            switch ( event.keyCode ) {
     617                case $.ui.keyCode.HOME:
     618                case $.ui.keyCode.END:
     619                case $.ui.keyCode.PAGE_UP:
     620                case $.ui.keyCode.PAGE_DOWN:
     621                case $.ui.keyCode.UP:
     622                case $.ui.keyCode.RIGHT:
     623                case $.ui.keyCode.DOWN:
     624                case $.ui.keyCode.LEFT:
     625                    event.preventDefault();
     626                    if ( !this._keySliding ) {
     627                        this._keySliding = true;
     628                        $( event.target ).addClass( "ui-state-active" );
     629                        allowed = this._start( event, index );
     630                        if ( allowed === false ) {
     631                            return;
     632                        }
     633                    }
     634                    break;
     635            }
     636
     637            step = this.options.step;
     638            if ( this.options.values && this.options.values.length ) {
     639                curVal = newVal = this.values( index );
     640            } else {
     641                curVal = newVal = this.value();
     642            }
     643
     644            switch ( event.keyCode ) {
     645                case $.ui.keyCode.HOME:
     646                    newVal = this._valueMin();
     647                    break;
     648                case $.ui.keyCode.END:
     649                    newVal = this._valueMax();
     650                    break;
     651                case $.ui.keyCode.PAGE_UP:
     652                    newVal = this._trimAlignValue(
     653                        curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
     654                    );
     655                    break;
     656                case $.ui.keyCode.PAGE_DOWN:
     657                    newVal = this._trimAlignValue(
     658                        curVal - ( (this._valueMax() - this._valueMin()) / this.numPages ) );
     659                    break;
     660                case $.ui.keyCode.UP:
     661                case $.ui.keyCode.RIGHT:
     662                    if ( curVal === this._valueMax() ) {
     663                        return;
     664                    }
     665                    newVal = this._trimAlignValue( curVal + step );
     666                    break;
     667                case $.ui.keyCode.DOWN:
     668                case $.ui.keyCode.LEFT:
     669                    if ( curVal === this._valueMin() ) {
     670                        return;
     671                    }
     672                    newVal = this._trimAlignValue( curVal - step );
     673                    break;
     674            }
     675
     676            this._slide( event, index, newVal );
     677        },
     678        keyup: function( event ) {
     679            var index = $( event.target ).data( "ui-slider-handle-index" );
     680
     681            if ( this._keySliding ) {
     682                this._keySliding = false;
     683                this._stop( event, index );
     684                this._change( event, index );
     685                $( event.target ).removeClass( "ui-state-active" );
     686            }
     687        }
     688    }
     689});
     690
     691}));
  • trunk/src/wp-includes/js/jquery/ui/sortable.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){function e(t,e,i){return t>e&&e+i>t}function i(t){return/left|right/.test(t.css("float"))||/inline|table-cell/.test(t.css("display"))}t.widget("ui.sortable",t.ui.mouse,{version:"1.10.4",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_create:function(){var t=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?"x"===t.axis||i(this.items[0].item):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var t=this.items.length-1;t>=0;t--)this.items[t].item.removeData(this.widgetName+"-item");return this},_setOption:function(e,i){"disabled"===e?(this.options[e]=i,this.widget().toggleClass("ui-sortable-disabled",!!i)):t.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(e,i){var s=null,n=!1,a=this;return this.reverting?!1:this.options.disabled||"static"===this.options.type?!1:(this._refreshItems(e),t(e.target).parents().each(function(){return t.data(this,a.widgetName+"-item")===a?(s=t(this),!1):undefined}),t.data(e.target,a.widgetName+"-item")===a&&(s=t(e.target)),s?!this.options.handle||i||(t(this.options.handle,s).find("*").addBack().each(function(){this===e.target&&(n=!0)}),n)?(this.currentItem=s,this._removeCurrentsFromItems(),!0):!1:!1)},_mouseStart:function(e,i,s){var n,a,o=this.options;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(e),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},t.extend(this.offset,{click:{left:e.pageX-this.offset.left,top:e.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(e),this.originalPageX=e.pageX,this.originalPageY=e.pageY,o.cursorAt&&this._adjustOffsetFromHelper(o.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!==this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),o.containment&&this._setContainment(),o.cursor&&"auto"!==o.cursor&&(a=this.document.find("body"),this.storedCursor=a.css("cursor"),a.css("cursor",o.cursor),this.storedStylesheet=t("<style>*{ cursor: "+o.cursor+" !important; }</style>").appendTo(a)),o.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",o.opacity)),o.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",o.zIndex)),this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",e,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!s)for(n=this.containers.length-1;n>=0;n--)this.containers[n]._trigger("activate",e,this._uiHash(this));return t.ui.ddmanager&&(t.ui.ddmanager.current=this),t.ui.ddmanager&&!o.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(e),!0},_mouseDrag:function(e){var i,s,n,a,o=this.options,r=!1;for(this.position=this._generatePosition(e),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll&&(this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-e.pageY<o.scrollSensitivity?this.scrollParent[0].scrollTop=r=this.scrollParent[0].scrollTop+o.scrollSpeed:e.pageY-this.overflowOffset.top<o.scrollSensitivity&&(this.scrollParent[0].scrollTop=r=this.scrollParent[0].scrollTop-o.scrollSpeed),this.overflowOffset.left+this.scrollParent[0].offsetWidth-e.pageX<o.scrollSensitivity?this.scrollParent[0].scrollLeft=r=this.scrollParent[0].scrollLeft+o.scrollSpeed:e.pageX-this.overflowOffset.left<o.scrollSensitivity&&(this.scrollParent[0].scrollLeft=r=this.scrollParent[0].scrollLeft-o.scrollSpeed)):(e.pageY-t(document).scrollTop()<o.scrollSensitivity?r=t(document).scrollTop(t(document).scrollTop()-o.scrollSpeed):t(window).height()-(e.pageY-t(document).scrollTop())<o.scrollSensitivity&&(r=t(document).scrollTop(t(document).scrollTop()+o.scrollSpeed)),e.pageX-t(document).scrollLeft()<o.scrollSensitivity?r=t(document).scrollLeft(t(document).scrollLeft()-o.scrollSpeed):t(window).width()-(e.pageX-t(document).scrollLeft())<o.scrollSensitivity&&(r=t(document).scrollLeft(t(document).scrollLeft()+o.scrollSpeed))),r!==!1&&t.ui.ddmanager&&!o.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e)),this.positionAbs=this._convertPositionTo("absolute"),this.options.axis&&"y"===this.options.axis||(this.helper[0].style.left=this.position.left+"px"),this.options.axis&&"x"===this.options.axis||(this.helper[0].style.top=this.position.top+"px"),i=this.items.length-1;i>=0;i--)if(s=this.items[i],n=s.item[0],a=this._intersectsWithPointer(s),a&&s.instance===this.currentContainer&&n!==this.currentItem[0]&&this.placeholder[1===a?"next":"prev"]()[0]!==n&&!t.contains(this.placeholder[0],n)&&("semi-dynamic"===this.options.type?!t.contains(this.element[0],n):!0)){if(this.direction=1===a?"down":"up","pointer"!==this.options.tolerance&&!this._intersectsWithSides(s))break;this._rearrange(e,s),this._trigger("change",e,this._uiHash());break}return this._contactContainers(e),t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),this._trigger("sort",e,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(e,i){if(e){if(t.ui.ddmanager&&!this.options.dropBehaviour&&t.ui.ddmanager.drop(this,e),this.options.revert){var s=this,n=this.placeholder.offset(),a=this.options.axis,o={};a&&"x"!==a||(o.left=n.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollLeft)),a&&"y"!==a||(o.top=n.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollTop)),this.reverting=!0,t(this.helper).animate(o,parseInt(this.options.revert,10)||500,function(){s._clear(e)})}else this._clear(e,i);return!1}},cancel:function(){if(this.dragging){this._mouseUp({target:null}),"original"===this.options.helper?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var e=this.containers.length-1;e>=0;e--)this.containers[e]._trigger("deactivate",null,this._uiHash(this)),this.containers[e].containerCache.over&&(this.containers[e]._trigger("out",null,this._uiHash(this)),this.containers[e].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!==this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),t.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?t(this.domPosition.prev).after(this.currentItem):t(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(e){var i=this._getItemsAsjQuery(e&&e.connected),s=[];return e=e||{},t(i).each(function(){var i=(t(e.item||this).attr(e.attribute||"id")||"").match(e.expression||/(.+)[\-=_](.+)/);i&&s.push((e.key||i[1]+"[]")+"="+(e.key&&e.expression?i[1]:i[2]))}),!s.length&&e.key&&s.push(e.key+"="),s.join("&")},toArray:function(e){var i=this._getItemsAsjQuery(e&&e.connected),s=[];return e=e||{},i.each(function(){s.push(t(e.item||this).attr(e.attribute||"id")||"")}),s},_intersectsWith:function(t){var e=this.positionAbs.left,i=e+this.helperProportions.width,s=this.positionAbs.top,n=s+this.helperProportions.height,a=t.left,o=a+t.width,r=t.top,h=r+t.height,l=this.offset.click.top,c=this.offset.click.left,u="x"===this.options.axis||s+l>r&&h>s+l,d="y"===this.options.axis||e+c>a&&o>e+c,p=u&&d;return"pointer"===this.options.tolerance||this.options.forcePointerForContainers||"pointer"!==this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>t[this.floating?"width":"height"]?p:e+this.helperProportions.width/2>a&&o>i-this.helperProportions.width/2&&s+this.helperProportions.height/2>r&&h>n-this.helperProportions.height/2},_intersectsWithPointer:function(t){var i="x"===this.options.axis||e(this.positionAbs.top+this.offset.click.top,t.top,t.height),s="y"===this.options.axis||e(this.positionAbs.left+this.offset.click.left,t.left,t.width),n=i&&s,a=this._getDragVerticalDirection(),o=this._getDragHorizontalDirection();return n?this.floating?o&&"right"===o||"down"===a?2:1:a&&("down"===a?2:1):!1},_intersectsWithSides:function(t){var i=e(this.positionAbs.top+this.offset.click.top,t.top+t.height/2,t.height),s=e(this.positionAbs.left+this.offset.click.left,t.left+t.width/2,t.width),n=this._getDragVerticalDirection(),a=this._getDragHorizontalDirection();return this.floating&&a?"right"===a&&s||"left"===a&&!s:n&&("down"===n&&i||"up"===n&&!i)},_getDragVerticalDirection:function(){var t=this.positionAbs.top-this.lastPositionAbs.top;return 0!==t&&(t>0?"down":"up")},_getDragHorizontalDirection:function(){var t=this.positionAbs.left-this.lastPositionAbs.left;return 0!==t&&(t>0?"right":"left")},refresh:function(t){return this._refreshItems(t),this.refreshPositions(),this},_connectWith:function(){var t=this.options;return t.connectWith.constructor===String?[t.connectWith]:t.connectWith},_getItemsAsjQuery:function(e){function i(){r.push(this)}var s,n,a,o,r=[],h=[],l=this._connectWith();if(l&&e)for(s=l.length-1;s>=0;s--)for(a=t(l[s]),n=a.length-1;n>=0;n--)o=t.data(a[n],this.widgetFullName),o&&o!==this&&!o.options.disabled&&h.push([t.isFunction(o.options.items)?o.options.items.call(o.element):t(o.options.items,o.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),o]);for(h.push([t.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):t(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]),s=h.length-1;s>=0;s--)h[s][0].each(i);return t(r)},_removeCurrentsFromItems:function(){var e=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=t.grep(this.items,function(t){for(var i=0;e.length>i;i++)if(e[i]===t.item[0])return!1;return!0})},_refreshItems:function(e){this.items=[],this.containers=[this];var i,s,n,a,o,r,h,l,c=this.items,u=[[t.isFunction(this.options.items)?this.options.items.call(this.element[0],e,{item:this.currentItem}):t(this.options.items,this.element),this]],d=this._connectWith();if(d&&this.ready)for(i=d.length-1;i>=0;i--)for(n=t(d[i]),s=n.length-1;s>=0;s--)a=t.data(n[s],this.widgetFullName),a&&a!==this&&!a.options.disabled&&(u.push([t.isFunction(a.options.items)?a.options.items.call(a.element[0],e,{item:this.currentItem}):t(a.options.items,a.element),a]),this.containers.push(a));for(i=u.length-1;i>=0;i--)for(o=u[i][1],r=u[i][0],s=0,l=r.length;l>s;s++)h=t(r[s]),h.data(this.widgetName+"-item",o),c.push({item:h,instance:o,width:0,height:0,left:0,top:0})},refreshPositions:function(e){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());var i,s,n,a;for(i=this.items.length-1;i>=0;i--)s=this.items[i],s.instance!==this.currentContainer&&this.currentContainer&&s.item[0]!==this.currentItem[0]||(n=this.options.toleranceElement?t(this.options.toleranceElement,s.item):s.item,e||(s.width=n.outerWidth(),s.height=n.outerHeight()),a=n.offset(),s.left=a.left,s.top=a.top);if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(i=this.containers.length-1;i>=0;i--)a=this.containers[i].element.offset(),this.containers[i].containerCache.left=a.left,this.containers[i].containerCache.top=a.top,this.containers[i].containerCache.width=this.containers[i].element.outerWidth(),this.containers[i].containerCache.height=this.containers[i].element.outerHeight();return this},_createPlaceholder:function(e){e=e||this;var i,s=e.options;s.placeholder&&s.placeholder.constructor!==String||(i=s.placeholder,s.placeholder={element:function(){var s=e.currentItem[0].nodeName.toLowerCase(),n=t("<"+s+">",e.document[0]).addClass(i||e.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper");return"tr"===s?e.currentItem.children().each(function(){t("<td>&#160;</td>",e.document[0]).attr("colspan",t(this).attr("colspan")||1).appendTo(n)}):"img"===s&&n.attr("src",e.currentItem.attr("src")),i||n.css("visibility","hidden"),n},update:function(t,n){(!i||s.forcePlaceholderSize)&&(n.height()||n.height(e.currentItem.innerHeight()-parseInt(e.currentItem.css("paddingTop")||0,10)-parseInt(e.currentItem.css("paddingBottom")||0,10)),n.width()||n.width(e.currentItem.innerWidth()-parseInt(e.currentItem.css("paddingLeft")||0,10)-parseInt(e.currentItem.css("paddingRight")||0,10)))}}),e.placeholder=t(s.placeholder.element.call(e.element,e.currentItem)),e.currentItem.after(e.placeholder),s.placeholder.update(e,e.placeholder)},_contactContainers:function(s){var n,a,o,r,h,l,c,u,d,p,f=null,m=null;for(n=this.containers.length-1;n>=0;n--)if(!t.contains(this.currentItem[0],this.containers[n].element[0]))if(this._intersectsWith(this.containers[n].containerCache)){if(f&&t.contains(this.containers[n].element[0],f.element[0]))continue;f=this.containers[n],m=n}else this.containers[n].containerCache.over&&(this.containers[n]._trigger("out",s,this._uiHash(this)),this.containers[n].containerCache.over=0);if(f)if(1===this.containers.length)this.containers[m].containerCache.over||(this.containers[m]._trigger("over",s,this._uiHash(this)),this.containers[m].containerCache.over=1);else{for(o=1e4,r=null,p=f.floating||i(this.currentItem),h=p?"left":"top",l=p?"width":"height",c=this.positionAbs[h]+this.offset.click[h],a=this.items.length-1;a>=0;a--)t.contains(this.containers[m].element[0],this.items[a].item[0])&&this.items[a].item[0]!==this.currentItem[0]&&(!p||e(this.positionAbs.top+this.offset.click.top,this.items[a].top,this.items[a].height))&&(u=this.items[a].item.offset()[h],d=!1,Math.abs(u-c)>Math.abs(u+this.items[a][l]-c)&&(d=!0,u+=this.items[a][l]),o>Math.abs(u-c)&&(o=Math.abs(u-c),r=this.items[a],this.direction=d?"up":"down"));if(!r&&!this.options.dropOnEmpty)return;if(this.currentContainer===this.containers[m])return;r?this._rearrange(s,r,null,!0):this._rearrange(s,null,this.containers[m].element,!0),this._trigger("change",s,this._uiHash()),this.containers[m]._trigger("change",s,this._uiHash(this)),this.currentContainer=this.containers[m],this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[m]._trigger("over",s,this._uiHash(this)),this.containers[m].containerCache.over=1}},_createHelper:function(e){var i=this.options,s=t.isFunction(i.helper)?t(i.helper.apply(this.element[0],[e,this.currentItem])):"clone"===i.helper?this.currentItem.clone():this.currentItem;return s.parents("body").length||t("parent"!==i.appendTo?i.appendTo:this.currentItem[0].parentNode)[0].appendChild(s[0]),s[0]===this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(!s[0].style.width||i.forceHelperSize)&&s.width(this.currentItem.width()),(!s[0].style.height||i.forceHelperSize)&&s.height(this.currentItem.height()),s},_adjustOffsetFromHelper:function(e){"string"==typeof e&&(e=e.split(" ")),t.isArray(e)&&(e={left:+e[0],top:+e[1]||0}),"left"in e&&(this.offset.click.left=e.left+this.margins.left),"right"in e&&(this.offset.click.left=this.helperProportions.width-e.right+this.margins.left),"top"in e&&(this.offset.click.top=e.top+this.margins.top),"bottom"in e&&(this.offset.click.top=this.helperProportions.height-e.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var e=this.offsetParent.offset();return"absolute"===this.cssPosition&&this.scrollParent[0]!==document&&t.contains(this.scrollParent[0],this.offsetParent[0])&&(e.left+=this.scrollParent.scrollLeft(),e.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]===document.body||this.offsetParent[0].tagName&&"html"===this.offsetParent[0].tagName.toLowerCase()&&t.ui.ie)&&(e={top:0,left:0}),{top:e.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:e.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"===this.cssPosition){var t=this.currentItem.position();return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:t.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e,i,s,n=this.options;"parent"===n.containment&&(n.containment=this.helper[0].parentNode),("document"===n.containment||"window"===n.containment)&&(this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,t("document"===n.containment?document:window).width()-this.helperProportions.width-this.margins.left,(t("document"===n.containment?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]),/^(document|window|parent)$/.test(n.containment)||(e=t(n.containment)[0],i=t(n.containment).offset(),s="hidden"!==t(e).css("overflow"),this.containment=[i.left+(parseInt(t(e).css("borderLeftWidth"),10)||0)+(parseInt(t(e).css("paddingLeft"),10)||0)-this.margins.left,i.top+(parseInt(t(e).css("borderTopWidth"),10)||0)+(parseInt(t(e).css("paddingTop"),10)||0)-this.margins.top,i.left+(s?Math.max(e.scrollWidth,e.offsetWidth):e.offsetWidth)-(parseInt(t(e).css("borderLeftWidth"),10)||0)-(parseInt(t(e).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,i.top+(s?Math.max(e.scrollHeight,e.offsetHeight):e.offsetHeight)-(parseInt(t(e).css("borderTopWidth"),10)||0)-(parseInt(t(e).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top])},_convertPositionTo:function(e,i){i||(i=this.position);var s="absolute"===e?1:-1,n="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,a=/(html|body)/i.test(n[0].tagName);return{top:i.top+this.offset.relative.top*s+this.offset.parent.top*s-("fixed"===this.cssPosition?-this.scrollParent.scrollTop():a?0:n.scrollTop())*s,left:i.left+this.offset.relative.left*s+this.offset.parent.left*s-("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():a?0:n.scrollLeft())*s}},_generatePosition:function(e){var i,s,n=this.options,a=e.pageX,o=e.pageY,r="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,h=/(html|body)/i.test(r[0].tagName);return"relative"!==this.cssPosition||this.scrollParent[0]!==document&&this.scrollParent[0]!==this.offsetParent[0]||(this.offset.relative=this._getRelativeOffset()),this.originalPosition&&(this.containment&&(e.pageX-this.offset.click.left<this.containment[0]&&(a=this.containment[0]+this.offset.click.left),e.pageY-this.offset.click.top<this.containment[1]&&(o=this.containment[1]+this.offset.click.top),e.pageX-this.offset.click.left>this.containment[2]&&(a=this.containment[2]+this.offset.click.left),e.pageY-this.offset.click.top>this.containment[3]&&(o=this.containment[3]+this.offset.click.top)),n.grid&&(i=this.originalPageY+Math.round((o-this.originalPageY)/n.grid[1])*n.grid[1],o=this.containment?i-this.offset.click.top>=this.containment[1]&&i-this.offset.click.top<=this.containment[3]?i:i-this.offset.click.top>=this.containment[1]?i-n.grid[1]:i+n.grid[1]:i,s=this.originalPageX+Math.round((a-this.originalPageX)/n.grid[0])*n.grid[0],a=this.containment?s-this.offset.click.left>=this.containment[0]&&s-this.offset.click.left<=this.containment[2]?s:s-this.offset.click.left>=this.containment[0]?s-n.grid[0]:s+n.grid[0]:s)),{top:o-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():h?0:r.scrollTop()),left:a-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():h?0:r.scrollLeft())}},_rearrange:function(t,e,i,s){i?i[0].appendChild(this.placeholder[0]):e.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?e.item[0]:e.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var n=this.counter;this._delay(function(){n===this.counter&&this.refreshPositions(!s)})},_clear:function(t,e){function i(t,e,i){return function(s){i._trigger(t,s,e._uiHash(e))}}this.reverting=!1;var s,n=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(s in this._storedCSS)("auto"===this._storedCSS[s]||"static"===this._storedCSS[s])&&(this._storedCSS[s]="");this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();for(this.fromOutside&&!e&&n.push(function(t){this._trigger("receive",t,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||e||n.push(function(t){this._trigger("update",t,this._uiHash())}),this!==this.currentContainer&&(e||(n.push(function(t){this._trigger("remove",t,this._uiHash())}),n.push(function(t){return function(e){t._trigger("receive",e,this._uiHash(this))}}.call(this,this.currentContainer)),n.push(function(t){return function(e){t._trigger("update",e,this._uiHash(this))}}.call(this,this.currentContainer)))),s=this.containers.length-1;s>=0;s--)e||n.push(i("deactivate",this,this.containers[s])),this.containers[s].containerCache.over&&(n.push(i("out",this,this.containers[s])),this.containers[s].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,this.cancelHelperRemoval){if(!e){for(this._trigger("beforeStop",t,this._uiHash()),s=0;n.length>s;s++)n[s].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!1}if(e||this._trigger("beforeStop",t,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null,!e){for(s=0;n.length>s;s++)n[s].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!0},_trigger:function(){t.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(e){var i=e||this;return{helper:i.helper,placeholder:i.placeholder||t([]),position:i.position,originalPosition:i.originalPosition,offset:i.positionAbs,item:i.currentItem,sender:e?e.element:null}}})})(jQuery);
     1/*!
     2 * jQuery UI Sortable 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/sortable/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./core",
     18            "./mouse",
     19            "./widget"
     20        ], factory );
     21    } else {
     22
     23        // Browser globals
     24        factory( jQuery );
     25    }
     26}(function( $ ) {
     27
     28return $.widget("ui.sortable", $.ui.mouse, {
     29    version: "1.11.1",
     30    widgetEventPrefix: "sort",
     31    ready: false,
     32    options: {
     33        appendTo: "parent",
     34        axis: false,
     35        connectWith: false,
     36        containment: false,
     37        cursor: "auto",
     38        cursorAt: false,
     39        dropOnEmpty: true,
     40        forcePlaceholderSize: false,
     41        forceHelperSize: false,
     42        grid: false,
     43        handle: false,
     44        helper: "original",
     45        items: "> *",
     46        opacity: false,
     47        placeholder: false,
     48        revert: false,
     49        scroll: true,
     50        scrollSensitivity: 20,
     51        scrollSpeed: 20,
     52        scope: "default",
     53        tolerance: "intersect",
     54        zIndex: 1000,
     55
     56        // callbacks
     57        activate: null,
     58        beforeStop: null,
     59        change: null,
     60        deactivate: null,
     61        out: null,
     62        over: null,
     63        receive: null,
     64        remove: null,
     65        sort: null,
     66        start: null,
     67        stop: null,
     68        update: null
     69    },
     70
     71    _isOverAxis: function( x, reference, size ) {
     72        return ( x >= reference ) && ( x < ( reference + size ) );
     73    },
     74
     75    _isFloating: function( item ) {
     76        return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
     77    },
     78
     79    _create: function() {
     80
     81        var o = this.options;
     82        this.containerCache = {};
     83        this.element.addClass("ui-sortable");
     84
     85        //Get the items
     86        this.refresh();
     87
     88        //Let's determine if the items are being displayed horizontally
     89        this.floating = this.items.length ? o.axis === "x" || this._isFloating(this.items[0].item) : false;
     90
     91        //Let's determine the parent's offset
     92        this.offset = this.element.offset();
     93
     94        //Initialize mouse events for interaction
     95        this._mouseInit();
     96
     97        this._setHandleClassName();
     98
     99        //We're ready to go
     100        this.ready = true;
     101
     102    },
     103
     104    _setOption: function( key, value ) {
     105        this._super( key, value );
     106
     107        if ( key === "handle" ) {
     108            this._setHandleClassName();
     109        }
     110    },
     111
     112    _setHandleClassName: function() {
     113        this.element.find( ".ui-sortable-handle" ).removeClass( "ui-sortable-handle" );
     114        $.each( this.items, function() {
     115            ( this.instance.options.handle ?
     116                this.item.find( this.instance.options.handle ) : this.item )
     117                .addClass( "ui-sortable-handle" );
     118        });
     119    },
     120
     121    _destroy: function() {
     122        this.element
     123            .removeClass( "ui-sortable ui-sortable-disabled" )
     124            .find( ".ui-sortable-handle" )
     125                .removeClass( "ui-sortable-handle" );
     126        this._mouseDestroy();
     127
     128        for ( var i = this.items.length - 1; i >= 0; i-- ) {
     129            this.items[i].item.removeData(this.widgetName + "-item");
     130        }
     131
     132        return this;
     133    },
     134
     135    _mouseCapture: function(event, overrideHandle) {
     136        var currentItem = null,
     137            validHandle = false,
     138            that = this;
     139
     140        if (this.reverting) {
     141            return false;
     142        }
     143
     144        if(this.options.disabled || this.options.type === "static") {
     145            return false;
     146        }
     147
     148        //We have to refresh the items data once first
     149        this._refreshItems(event);
     150
     151        //Find out if the clicked node (or one of its parents) is a actual item in this.items
     152        $(event.target).parents().each(function() {
     153            if($.data(this, that.widgetName + "-item") === that) {
     154                currentItem = $(this);
     155                return false;
     156            }
     157        });
     158        if($.data(event.target, that.widgetName + "-item") === that) {
     159            currentItem = $(event.target);
     160        }
     161
     162        if(!currentItem) {
     163            return false;
     164        }
     165        if(this.options.handle && !overrideHandle) {
     166            $(this.options.handle, currentItem).find("*").addBack().each(function() {
     167                if(this === event.target) {
     168                    validHandle = true;
     169                }
     170            });
     171            if(!validHandle) {
     172                return false;
     173            }
     174        }
     175
     176        this.currentItem = currentItem;
     177        this._removeCurrentsFromItems();
     178        return true;
     179
     180    },
     181
     182    _mouseStart: function(event, overrideHandle, noActivation) {
     183
     184        var i, body,
     185            o = this.options;
     186
     187        this.currentContainer = this;
     188
     189        //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
     190        this.refreshPositions();
     191
     192        //Create and append the visible helper
     193        this.helper = this._createHelper(event);
     194
     195        //Cache the helper size
     196        this._cacheHelperProportions();
     197
     198        /*
     199         * - Position generation -
     200         * This block generates everything position related - it's the core of draggables.
     201         */
     202
     203        //Cache the margins of the original element
     204        this._cacheMargins();
     205
     206        //Get the next scrolling parent
     207        this.scrollParent = this.helper.scrollParent();
     208
     209        //The element's absolute position on the page minus margins
     210        this.offset = this.currentItem.offset();
     211        this.offset = {
     212            top: this.offset.top - this.margins.top,
     213            left: this.offset.left - this.margins.left
     214        };
     215
     216        $.extend(this.offset, {
     217            click: { //Where the click happened, relative to the element
     218                left: event.pageX - this.offset.left,
     219                top: event.pageY - this.offset.top
     220            },
     221            parent: this._getParentOffset(),
     222            relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
     223        });
     224
     225        // Only after we got the offset, we can change the helper's position to absolute
     226        // TODO: Still need to figure out a way to make relative sorting possible
     227        this.helper.css("position", "absolute");
     228        this.cssPosition = this.helper.css("position");
     229
     230        //Generate the original position
     231        this.originalPosition = this._generatePosition(event);
     232        this.originalPageX = event.pageX;
     233        this.originalPageY = event.pageY;
     234
     235        //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
     236        (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
     237
     238        //Cache the former DOM position
     239        this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
     240
     241        //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way
     242        if(this.helper[0] !== this.currentItem[0]) {
     243            this.currentItem.hide();
     244        }
     245
     246        //Create the placeholder
     247        this._createPlaceholder();
     248
     249        //Set a containment if given in the options
     250        if(o.containment) {
     251            this._setContainment();
     252        }
     253
     254        if( o.cursor && o.cursor !== "auto" ) { // cursor option
     255            body = this.document.find( "body" );
     256
     257            // support: IE
     258            this.storedCursor = body.css( "cursor" );
     259            body.css( "cursor", o.cursor );
     260
     261            this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
     262        }
     263
     264        if(o.opacity) { // opacity option
     265            if (this.helper.css("opacity")) {
     266                this._storedOpacity = this.helper.css("opacity");
     267            }
     268            this.helper.css("opacity", o.opacity);
     269        }
     270
     271        if(o.zIndex) { // zIndex option
     272            if (this.helper.css("zIndex")) {
     273                this._storedZIndex = this.helper.css("zIndex");
     274            }
     275            this.helper.css("zIndex", o.zIndex);
     276        }
     277
     278        //Prepare scrolling
     279        if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
     280            this.overflowOffset = this.scrollParent.offset();
     281        }
     282
     283        //Call callbacks
     284        this._trigger("start", event, this._uiHash());
     285
     286        //Recache the helper size
     287        if(!this._preserveHelperProportions) {
     288            this._cacheHelperProportions();
     289        }
     290
     291
     292        //Post "activate" events to possible containers
     293        if( !noActivation ) {
     294            for ( i = this.containers.length - 1; i >= 0; i-- ) {
     295                this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
     296            }
     297        }
     298
     299        //Prepare possible droppables
     300        if($.ui.ddmanager) {
     301            $.ui.ddmanager.current = this;
     302        }
     303
     304        if ($.ui.ddmanager && !o.dropBehaviour) {
     305            $.ui.ddmanager.prepareOffsets(this, event);
     306        }
     307
     308        this.dragging = true;
     309
     310        this.helper.addClass("ui-sortable-helper");
     311        this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
     312        return true;
     313
     314    },
     315
     316    _mouseDrag: function(event) {
     317        var i, item, itemElement, intersection,
     318            o = this.options,
     319            scrolled = false;
     320
     321        //Compute the helpers position
     322        this.position = this._generatePosition(event);
     323        this.positionAbs = this._convertPositionTo("absolute");
     324
     325        if (!this.lastPositionAbs) {
     326            this.lastPositionAbs = this.positionAbs;
     327        }
     328
     329        //Do scrolling
     330        if(this.options.scroll) {
     331            if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
     332
     333                if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
     334                    this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
     335                } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
     336                    this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
     337                }
     338
     339                if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
     340                    this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
     341                } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
     342                    this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
     343                }
     344
     345            } else {
     346
     347                if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
     348                    scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
     349                } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
     350                    scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
     351                }
     352
     353                if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
     354                    scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
     355                } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
     356                    scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
     357                }
     358
     359            }
     360
     361            if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
     362                $.ui.ddmanager.prepareOffsets(this, event);
     363            }
     364        }
     365
     366        //Regenerate the absolute position used for position checks
     367        this.positionAbs = this._convertPositionTo("absolute");
     368
     369        //Set the helper position
     370        if(!this.options.axis || this.options.axis !== "y") {
     371            this.helper[0].style.left = this.position.left+"px";
     372        }
     373        if(!this.options.axis || this.options.axis !== "x") {
     374            this.helper[0].style.top = this.position.top+"px";
     375        }
     376
     377        //Rearrange
     378        for (i = this.items.length - 1; i >= 0; i--) {
     379
     380            //Cache variables and intersection, continue if no intersection
     381            item = this.items[i];
     382            itemElement = item.item[0];
     383            intersection = this._intersectsWithPointer(item);
     384            if (!intersection) {
     385                continue;
     386            }
     387
     388            // Only put the placeholder inside the current Container, skip all
     389            // items from other containers. This works because when moving
     390            // an item from one container to another the
     391            // currentContainer is switched before the placeholder is moved.
     392            //
     393            // Without this, moving items in "sub-sortables" can cause
     394            // the placeholder to jitter between the outer and inner container.
     395            if (item.instance !== this.currentContainer) {
     396                continue;
     397            }
     398
     399            // cannot intersect with itself
     400            // no useless actions that have been done before
     401            // no action if the item moved is the parent of the item checked
     402            if (itemElement !== this.currentItem[0] &&
     403                this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
     404                !$.contains(this.placeholder[0], itemElement) &&
     405                (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
     406            ) {
     407
     408                this.direction = intersection === 1 ? "down" : "up";
     409
     410                if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
     411                    this._rearrange(event, item);
     412                } else {
     413                    break;
     414                }
     415
     416                this._trigger("change", event, this._uiHash());
     417                break;
     418            }
     419        }
     420
     421        //Post events to containers
     422        this._contactContainers(event);
     423
     424        //Interconnect with droppables
     425        if($.ui.ddmanager) {
     426            $.ui.ddmanager.drag(this, event);
     427        }
     428
     429        //Call callbacks
     430        this._trigger("sort", event, this._uiHash());
     431
     432        this.lastPositionAbs = this.positionAbs;
     433        return false;
     434
     435    },
     436
     437    _mouseStop: function(event, noPropagation) {
     438
     439        if(!event) {
     440            return;
     441        }
     442
     443        //If we are using droppables, inform the manager about the drop
     444        if ($.ui.ddmanager && !this.options.dropBehaviour) {
     445            $.ui.ddmanager.drop(this, event);
     446        }
     447
     448        if(this.options.revert) {
     449            var that = this,
     450                cur = this.placeholder.offset(),
     451                axis = this.options.axis,
     452                animation = {};
     453
     454            if ( !axis || axis === "x" ) {
     455                animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
     456            }
     457            if ( !axis || axis === "y" ) {
     458                animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
     459            }
     460            this.reverting = true;
     461            $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
     462                that._clear(event);
     463            });
     464        } else {
     465            this._clear(event, noPropagation);
     466        }
     467
     468        return false;
     469
     470    },
     471
     472    cancel: function() {
     473
     474        if(this.dragging) {
     475
     476            this._mouseUp({ target: null });
     477
     478            if(this.options.helper === "original") {
     479                this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
     480            } else {
     481                this.currentItem.show();
     482            }
     483
     484            //Post deactivating events to containers
     485            for (var i = this.containers.length - 1; i >= 0; i--){
     486                this.containers[i]._trigger("deactivate", null, this._uiHash(this));
     487                if(this.containers[i].containerCache.over) {
     488                    this.containers[i]._trigger("out", null, this._uiHash(this));
     489                    this.containers[i].containerCache.over = 0;
     490                }
     491            }
     492
     493        }
     494
     495        if (this.placeholder) {
     496            //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
     497            if(this.placeholder[0].parentNode) {
     498                this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
     499            }
     500            if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
     501                this.helper.remove();
     502            }
     503
     504            $.extend(this, {
     505                helper: null,
     506                dragging: false,
     507                reverting: false,
     508                _noFinalSort: null
     509            });
     510
     511            if(this.domPosition.prev) {
     512                $(this.domPosition.prev).after(this.currentItem);
     513            } else {
     514                $(this.domPosition.parent).prepend(this.currentItem);
     515            }
     516        }
     517
     518        return this;
     519
     520    },
     521
     522    serialize: function(o) {
     523
     524        var items = this._getItemsAsjQuery(o && o.connected),
     525            str = [];
     526        o = o || {};
     527
     528        $(items).each(function() {
     529            var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
     530            if (res) {
     531                str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
     532            }
     533        });
     534
     535        if(!str.length && o.key) {
     536            str.push(o.key + "=");
     537        }
     538
     539        return str.join("&");
     540
     541    },
     542
     543    toArray: function(o) {
     544
     545        var items = this._getItemsAsjQuery(o && o.connected),
     546            ret = [];
     547
     548        o = o || {};
     549
     550        items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
     551        return ret;
     552
     553    },
     554
     555    /* Be careful with the following core functions */
     556    _intersectsWith: function(item) {
     557
     558        var x1 = this.positionAbs.left,
     559            x2 = x1 + this.helperProportions.width,
     560            y1 = this.positionAbs.top,
     561            y2 = y1 + this.helperProportions.height,
     562            l = item.left,
     563            r = l + item.width,
     564            t = item.top,
     565            b = t + item.height,
     566            dyClick = this.offset.click.top,
     567            dxClick = this.offset.click.left,
     568            isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
     569            isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
     570            isOverElement = isOverElementHeight && isOverElementWidth;
     571
     572        if ( this.options.tolerance === "pointer" ||
     573            this.options.forcePointerForContainers ||
     574            (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
     575        ) {
     576            return isOverElement;
     577        } else {
     578
     579            return (l < x1 + (this.helperProportions.width / 2) && // Right Half
     580                x2 - (this.helperProportions.width / 2) < r && // Left Half
     581                t < y1 + (this.helperProportions.height / 2) && // Bottom Half
     582                y2 - (this.helperProportions.height / 2) < b ); // Top Half
     583
     584        }
     585    },
     586
     587    _intersectsWithPointer: function(item) {
     588
     589        var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
     590            isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
     591            isOverElement = isOverElementHeight && isOverElementWidth,
     592            verticalDirection = this._getDragVerticalDirection(),
     593            horizontalDirection = this._getDragHorizontalDirection();
     594
     595        if (!isOverElement) {
     596            return false;
     597        }
     598
     599        return this.floating ?
     600            ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
     601            : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
     602
     603    },
     604
     605    _intersectsWithSides: function(item) {
     606
     607        var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
     608            isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
     609            verticalDirection = this._getDragVerticalDirection(),
     610            horizontalDirection = this._getDragHorizontalDirection();
     611
     612        if (this.floating && horizontalDirection) {
     613            return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
     614        } else {
     615            return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
     616        }
     617
     618    },
     619
     620    _getDragVerticalDirection: function() {
     621        var delta = this.positionAbs.top - this.lastPositionAbs.top;
     622        return delta !== 0 && (delta > 0 ? "down" : "up");
     623    },
     624
     625    _getDragHorizontalDirection: function() {
     626        var delta = this.positionAbs.left - this.lastPositionAbs.left;
     627        return delta !== 0 && (delta > 0 ? "right" : "left");
     628    },
     629
     630    refresh: function(event) {
     631        this._refreshItems(event);
     632        this._setHandleClassName();
     633        this.refreshPositions();
     634        return this;
     635    },
     636
     637    _connectWith: function() {
     638        var options = this.options;
     639        return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
     640    },
     641
     642    _getItemsAsjQuery: function(connected) {
     643
     644        var i, j, cur, inst,
     645            items = [],
     646            queries = [],
     647            connectWith = this._connectWith();
     648
     649        if(connectWith && connected) {
     650            for (i = connectWith.length - 1; i >= 0; i--){
     651                cur = $(connectWith[i]);
     652                for ( j = cur.length - 1; j >= 0; j--){
     653                    inst = $.data(cur[j], this.widgetFullName);
     654                    if(inst && inst !== this && !inst.options.disabled) {
     655                        queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), inst]);
     656                    }
     657                }
     658            }
     659        }
     660
     661        queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]);
     662
     663        function addItems() {
     664            items.push( this );
     665        }
     666        for (i = queries.length - 1; i >= 0; i--){
     667            queries[i][0].each( addItems );
     668        }
     669
     670        return $(items);
     671
     672    },
     673
     674    _removeCurrentsFromItems: function() {
     675
     676        var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
     677
     678        this.items = $.grep(this.items, function (item) {
     679            for (var j=0; j < list.length; j++) {
     680                if(list[j] === item.item[0]) {
     681                    return false;
     682                }
     683            }
     684            return true;
     685        });
     686
     687    },
     688
     689    _refreshItems: function(event) {
     690
     691        this.items = [];
     692        this.containers = [this];
     693
     694        var i, j, cur, inst, targetData, _queries, item, queriesLength,
     695            items = this.items,
     696            queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
     697            connectWith = this._connectWith();
     698
     699        if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
     700            for (i = connectWith.length - 1; i >= 0; i--){
     701                cur = $(connectWith[i]);
     702                for (j = cur.length - 1; j >= 0; j--){
     703                    inst = $.data(cur[j], this.widgetFullName);
     704                    if(inst && inst !== this && !inst.options.disabled) {
     705                        queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
     706                        this.containers.push(inst);
     707                    }
     708                }
     709            }
     710        }
     711
     712        for (i = queries.length - 1; i >= 0; i--) {
     713            targetData = queries[i][1];
     714            _queries = queries[i][0];
     715
     716            for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
     717                item = $(_queries[j]);
     718
     719                item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
     720
     721                items.push({
     722                    item: item,
     723                    instance: targetData,
     724                    width: 0, height: 0,
     725                    left: 0, top: 0
     726                });
     727            }
     728        }
     729
     730    },
     731
     732    refreshPositions: function(fast) {
     733
     734        //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
     735        if(this.offsetParent && this.helper) {
     736            this.offset.parent = this._getParentOffset();
     737        }
     738
     739        var i, item, t, p;
     740
     741        for (i = this.items.length - 1; i >= 0; i--){
     742            item = this.items[i];
     743
     744            //We ignore calculating positions of all connected containers when we're not over them
     745            if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
     746                continue;
     747            }
     748
     749            t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
     750
     751            if (!fast) {
     752                item.width = t.outerWidth();
     753                item.height = t.outerHeight();
     754            }
     755
     756            p = t.offset();
     757            item.left = p.left;
     758            item.top = p.top;
     759        }
     760
     761        if(this.options.custom && this.options.custom.refreshContainers) {
     762            this.options.custom.refreshContainers.call(this);
     763        } else {
     764            for (i = this.containers.length - 1; i >= 0; i--){
     765                p = this.containers[i].element.offset();
     766                this.containers[i].containerCache.left = p.left;
     767                this.containers[i].containerCache.top = p.top;
     768                this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
     769                this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
     770            }
     771        }
     772
     773        return this;
     774    },
     775
     776    _createPlaceholder: function(that) {
     777        that = that || this;
     778        var className,
     779            o = that.options;
     780
     781        if(!o.placeholder || o.placeholder.constructor === String) {
     782            className = o.placeholder;
     783            o.placeholder = {
     784                element: function() {
     785
     786                    var nodeName = that.currentItem[0].nodeName.toLowerCase(),
     787                        element = $( "<" + nodeName + ">", that.document[0] )
     788                            .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
     789                            .removeClass("ui-sortable-helper");
     790
     791                    if ( nodeName === "tr" ) {
     792                        that.currentItem.children().each(function() {
     793                            $( "<td>&#160;</td>", that.document[0] )
     794                                .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
     795                                .appendTo( element );
     796                        });
     797                    } else if ( nodeName === "img" ) {
     798                        element.attr( "src", that.currentItem.attr( "src" ) );
     799                    }
     800
     801                    if ( !className ) {
     802                        element.css( "visibility", "hidden" );
     803                    }
     804
     805                    return element;
     806                },
     807                update: function(container, p) {
     808
     809                    // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
     810                    // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
     811                    if(className && !o.forcePlaceholderSize) {
     812                        return;
     813                    }
     814
     815                    //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
     816                    if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
     817                    if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
     818                }
     819            };
     820        }
     821
     822        //Create the placeholder
     823        that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
     824
     825        //Append it after the actual current item
     826        that.currentItem.after(that.placeholder);
     827
     828        //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
     829        o.placeholder.update(that, that.placeholder);
     830
     831    },
     832
     833    _contactContainers: function(event) {
     834        var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis,
     835            innermostContainer = null,
     836            innermostIndex = null;
     837
     838        // get innermost container that intersects with item
     839        for (i = this.containers.length - 1; i >= 0; i--) {
     840
     841            // never consider a container that's located within the item itself
     842            if($.contains(this.currentItem[0], this.containers[i].element[0])) {
     843                continue;
     844            }
     845
     846            if(this._intersectsWith(this.containers[i].containerCache)) {
     847
     848                // if we've already found a container and it's more "inner" than this, then continue
     849                if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
     850                    continue;
     851                }
     852
     853                innermostContainer = this.containers[i];
     854                innermostIndex = i;
     855
     856            } else {
     857                // container doesn't intersect. trigger "out" event if necessary
     858                if(this.containers[i].containerCache.over) {
     859                    this.containers[i]._trigger("out", event, this._uiHash(this));
     860                    this.containers[i].containerCache.over = 0;
     861                }
     862            }
     863
     864        }
     865
     866        // if no intersecting containers found, return
     867        if(!innermostContainer) {
     868            return;
     869        }
     870
     871        // move the item into the container if it's not there already
     872        if(this.containers.length === 1) {
     873            if (!this.containers[innermostIndex].containerCache.over) {
     874                this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
     875                this.containers[innermostIndex].containerCache.over = 1;
     876            }
     877        } else {
     878
     879            //When entering a new container, we will find the item with the least distance and append our item near it
     880            dist = 10000;
     881            itemWithLeastDistance = null;
     882            floating = innermostContainer.floating || this._isFloating(this.currentItem);
     883            posProperty = floating ? "left" : "top";
     884            sizeProperty = floating ? "width" : "height";
     885            axis = floating ? "clientX" : "clientY";
     886
     887            for (j = this.items.length - 1; j >= 0; j--) {
     888                if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
     889                    continue;
     890                }
     891                if(this.items[j].item[0] === this.currentItem[0]) {
     892                    continue;
     893                }
     894
     895                cur = this.items[j].item.offset()[posProperty];
     896                nearBottom = false;
     897                if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
     898                    nearBottom = true;
     899                }
     900
     901                if ( Math.abs( event[ axis ] - cur ) < dist ) {
     902                    dist = Math.abs( event[ axis ] - cur );
     903                    itemWithLeastDistance = this.items[ j ];
     904                    this.direction = nearBottom ? "up": "down";
     905                }
     906            }
     907
     908            //Check if dropOnEmpty is enabled
     909            if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
     910                return;
     911            }
     912
     913            if(this.currentContainer === this.containers[innermostIndex]) {
     914                return;
     915            }
     916
     917            itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
     918            this._trigger("change", event, this._uiHash());
     919            this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
     920            this.currentContainer = this.containers[innermostIndex];
     921
     922            //Update the placeholder
     923            this.options.placeholder.update(this.currentContainer, this.placeholder);
     924
     925            this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
     926            this.containers[innermostIndex].containerCache.over = 1;
     927        }
     928
     929
     930    },
     931
     932    _createHelper: function(event) {
     933
     934        var o = this.options,
     935            helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
     936
     937        //Add the helper to the DOM if that didn't happen already
     938        if(!helper.parents("body").length) {
     939            $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
     940        }
     941
     942        if(helper[0] === this.currentItem[0]) {
     943            this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") };
     944        }
     945
     946        if(!helper[0].style.width || o.forceHelperSize) {
     947            helper.width(this.currentItem.width());
     948        }
     949        if(!helper[0].style.height || o.forceHelperSize) {
     950            helper.height(this.currentItem.height());
     951        }
     952
     953        return helper;
     954
     955    },
     956
     957    _adjustOffsetFromHelper: function(obj) {
     958        if (typeof obj === "string") {
     959            obj = obj.split(" ");
     960        }
     961        if ($.isArray(obj)) {
     962            obj = {left: +obj[0], top: +obj[1] || 0};
     963        }
     964        if ("left" in obj) {
     965            this.offset.click.left = obj.left + this.margins.left;
     966        }
     967        if ("right" in obj) {
     968            this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
     969        }
     970        if ("top" in obj) {
     971            this.offset.click.top = obj.top + this.margins.top;
     972        }
     973        if ("bottom" in obj) {
     974            this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
     975        }
     976    },
     977
     978    _getParentOffset: function() {
     979
     980
     981        //Get the offsetParent and cache its position
     982        this.offsetParent = this.helper.offsetParent();
     983        var po = this.offsetParent.offset();
     984
     985        // This is a special case where we need to modify a offset calculated on start, since the following happened:
     986        // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
     987        // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
     988        //    the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
     989        if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
     990            po.left += this.scrollParent.scrollLeft();
     991            po.top += this.scrollParent.scrollTop();
     992        }
     993
     994        // This needs to be actually done for all browsers, since pageX/pageY includes this information
     995        // with an ugly IE fix
     996        if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
     997            po = { top: 0, left: 0 };
     998        }
     999
     1000        return {
     1001            top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
     1002            left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
     1003        };
     1004
     1005    },
     1006
     1007    _getRelativeOffset: function() {
     1008
     1009        if(this.cssPosition === "relative") {
     1010            var p = this.currentItem.position();
     1011            return {
     1012                top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
     1013                left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
     1014            };
     1015        } else {
     1016            return { top: 0, left: 0 };
     1017        }
     1018
     1019    },
     1020
     1021    _cacheMargins: function() {
     1022        this.margins = {
     1023            left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
     1024            top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
     1025        };
     1026    },
     1027
     1028    _cacheHelperProportions: function() {
     1029        this.helperProportions = {
     1030            width: this.helper.outerWidth(),
     1031            height: this.helper.outerHeight()
     1032        };
     1033    },
     1034
     1035    _setContainment: function() {
     1036
     1037        var ce, co, over,
     1038            o = this.options;
     1039        if(o.containment === "parent") {
     1040            o.containment = this.helper[0].parentNode;
     1041        }
     1042        if(o.containment === "document" || o.containment === "window") {
     1043            this.containment = [
     1044                0 - this.offset.relative.left - this.offset.parent.left,
     1045                0 - this.offset.relative.top - this.offset.parent.top,
     1046                $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
     1047                ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
     1048            ];
     1049        }
     1050
     1051        if(!(/^(document|window|parent)$/).test(o.containment)) {
     1052            ce = $(o.containment)[0];
     1053            co = $(o.containment).offset();
     1054            over = ($(ce).css("overflow") !== "hidden");
     1055
     1056            this.containment = [
     1057                co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
     1058                co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
     1059                co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
     1060                co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
     1061            ];
     1062        }
     1063
     1064    },
     1065
     1066    _convertPositionTo: function(d, pos) {
     1067
     1068        if(!pos) {
     1069            pos = this.position;
     1070        }
     1071        var mod = d === "absolute" ? 1 : -1,
     1072            scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
     1073            scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
     1074
     1075        return {
     1076            top: (
     1077                pos.top +                                                               // The absolute mouse position
     1078                this.offset.relative.top * mod +                                        // Only for relative positioned nodes: Relative offset from element to offset parent
     1079                this.offset.parent.top * mod -                                          // The offsetParent's offset without borders (offset + border)
     1080                ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
     1081            ),
     1082            left: (
     1083                pos.left +                                                              // The absolute mouse position
     1084                this.offset.relative.left * mod +                                       // Only for relative positioned nodes: Relative offset from element to offset parent
     1085                this.offset.parent.left * mod   -                                       // The offsetParent's offset without borders (offset + border)
     1086                ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
     1087            )
     1088        };
     1089
     1090    },
     1091
     1092    _generatePosition: function(event) {
     1093
     1094        var top, left,
     1095            o = this.options,
     1096            pageX = event.pageX,
     1097            pageY = event.pageY,
     1098            scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
     1099
     1100        // This is another very weird special case that only happens for relative elements:
     1101        // 1. If the css position is relative
     1102        // 2. and the scroll parent is the document or similar to the offset parent
     1103        // we have to refresh the relative offset during the scroll so there are no jumps
     1104        if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
     1105            this.offset.relative = this._getRelativeOffset();
     1106        }
     1107
     1108        /*
     1109         * - Position constraining -
     1110         * Constrain the position to a mix of grid, containment.
     1111         */
     1112
     1113        if(this.originalPosition) { //If we are not dragging yet, we won't check for options
     1114
     1115            if(this.containment) {
     1116                if(event.pageX - this.offset.click.left < this.containment[0]) {
     1117                    pageX = this.containment[0] + this.offset.click.left;
     1118                }
     1119                if(event.pageY - this.offset.click.top < this.containment[1]) {
     1120                    pageY = this.containment[1] + this.offset.click.top;
     1121                }
     1122                if(event.pageX - this.offset.click.left > this.containment[2]) {
     1123                    pageX = this.containment[2] + this.offset.click.left;
     1124                }
     1125                if(event.pageY - this.offset.click.top > this.containment[3]) {
     1126                    pageY = this.containment[3] + this.offset.click.top;
     1127                }
     1128            }
     1129
     1130            if(o.grid) {
     1131                top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
     1132                pageY = this.containment ? ( (top - this.offset.click.top >= this.containment[1] && top - this.offset.click.top <= this.containment[3]) ? top : ((top - this.offset.click.top >= this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
     1133
     1134                left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
     1135                pageX = this.containment ? ( (left - this.offset.click.left >= this.containment[0] && left - this.offset.click.left <= this.containment[2]) ? left : ((left - this.offset.click.left >= this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
     1136            }
     1137
     1138        }
     1139
     1140        return {
     1141            top: (
     1142                pageY -                                                             // The absolute mouse position
     1143                this.offset.click.top -                                                 // Click offset (relative to the element)
     1144                this.offset.relative.top    -                                           // Only for relative positioned nodes: Relative offset from element to offset parent
     1145                this.offset.parent.top +                                                // The offsetParent's offset without borders (offset + border)
     1146                ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
     1147            ),
     1148            left: (
     1149                pageX -                                                             // The absolute mouse position
     1150                this.offset.click.left -                                                // Click offset (relative to the element)
     1151                this.offset.relative.left   -                                           // Only for relative positioned nodes: Relative offset from element to offset parent
     1152                this.offset.parent.left +                                               // The offsetParent's offset without borders (offset + border)
     1153                ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
     1154            )
     1155        };
     1156
     1157    },
     1158
     1159    _rearrange: function(event, i, a, hardRefresh) {
     1160
     1161        a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction === "down" ? i.item[0] : i.item[0].nextSibling));
     1162
     1163        //Various things done here to improve the performance:
     1164        // 1. we create a setTimeout, that calls refreshPositions
     1165        // 2. on the instance, we have a counter variable, that get's higher after every append
     1166        // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
     1167        // 4. this lets only the last addition to the timeout stack through
     1168        this.counter = this.counter ? ++this.counter : 1;
     1169        var counter = this.counter;
     1170
     1171        this._delay(function() {
     1172            if(counter === this.counter) {
     1173                this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
     1174            }
     1175        });
     1176
     1177    },
     1178
     1179    _clear: function(event, noPropagation) {
     1180
     1181        this.reverting = false;
     1182        // We delay all events that have to be triggered to after the point where the placeholder has been removed and
     1183        // everything else normalized again
     1184        var i,
     1185            delayedTriggers = [];
     1186
     1187        // We first have to update the dom position of the actual currentItem
     1188        // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
     1189        if(!this._noFinalSort && this.currentItem.parent().length) {
     1190            this.placeholder.before(this.currentItem);
     1191        }
     1192        this._noFinalSort = null;
     1193
     1194        if(this.helper[0] === this.currentItem[0]) {
     1195            for(i in this._storedCSS) {
     1196                if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
     1197                    this._storedCSS[i] = "";
     1198                }
     1199            }
     1200            this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
     1201        } else {
     1202            this.currentItem.show();
     1203        }
     1204
     1205        if(this.fromOutside && !noPropagation) {
     1206            delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
     1207        }
     1208        if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
     1209            delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
     1210        }
     1211
     1212        // Check if the items Container has Changed and trigger appropriate
     1213        // events.
     1214        if (this !== this.currentContainer) {
     1215            if(!noPropagation) {
     1216                delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
     1217                delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); };  }).call(this, this.currentContainer));
     1218                delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this));  }; }).call(this, this.currentContainer));
     1219            }
     1220        }
     1221
     1222
     1223        //Post events to containers
     1224        function delayEvent( type, instance, container ) {
     1225            return function( event ) {
     1226                container._trigger( type, event, instance._uiHash( instance ) );
     1227            };
     1228        }
     1229        for (i = this.containers.length - 1; i >= 0; i--){
     1230            if (!noPropagation) {
     1231                delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
     1232            }
     1233            if(this.containers[i].containerCache.over) {
     1234                delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
     1235                this.containers[i].containerCache.over = 0;
     1236            }
     1237        }
     1238
     1239        //Do what was originally in plugins
     1240        if ( this.storedCursor ) {
     1241            this.document.find( "body" ).css( "cursor", this.storedCursor );
     1242            this.storedStylesheet.remove();
     1243        }
     1244        if(this._storedOpacity) {
     1245            this.helper.css("opacity", this._storedOpacity);
     1246        }
     1247        if(this._storedZIndex) {
     1248            this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
     1249        }
     1250
     1251        this.dragging = false;
     1252        if(this.cancelHelperRemoval) {
     1253            if(!noPropagation) {
     1254                this._trigger("beforeStop", event, this._uiHash());
     1255                for (i=0; i < delayedTriggers.length; i++) {
     1256                    delayedTriggers[i].call(this, event);
     1257                } //Trigger all delayed events
     1258                this._trigger("stop", event, this._uiHash());
     1259            }
     1260
     1261            this.fromOutside = false;
     1262            return false;
     1263        }
     1264
     1265        if(!noPropagation) {
     1266            this._trigger("beforeStop", event, this._uiHash());
     1267        }
     1268
     1269        //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
     1270        this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
     1271
     1272        if(this.helper[0] !== this.currentItem[0]) {
     1273            this.helper.remove();
     1274        }
     1275        this.helper = null;
     1276
     1277        if(!noPropagation) {
     1278            for (i=0; i < delayedTriggers.length; i++) {
     1279                delayedTriggers[i].call(this, event);
     1280            } //Trigger all delayed events
     1281            this._trigger("stop", event, this._uiHash());
     1282        }
     1283
     1284        this.fromOutside = false;
     1285        return true;
     1286
     1287    },
     1288
     1289    _trigger: function() {
     1290        if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
     1291            this.cancel();
     1292        }
     1293    },
     1294
     1295    _uiHash: function(_inst) {
     1296        var inst = _inst || this;
     1297        return {
     1298            helper: inst.helper,
     1299            placeholder: inst.placeholder || $([]),
     1300            position: inst.position,
     1301            originalPosition: inst.originalPosition,
     1302            offset: inst.positionAbs,
     1303            item: inst.currentItem,
     1304            sender: _inst ? _inst.element : null
     1305        };
     1306    }
     1307
     1308});
     1309
     1310}));
  • trunk/src/wp-includes/js/jquery/ui/spinner.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){function e(t){return function(){var e=this.element.val();t.apply(this,arguments),this._refresh(),e!==this.element.val()&&this._trigger("change")}}t.widget("ui.spinner",{version:"1.10.4",defaultElement:"<input>",widgetEventPrefix:"spin",options:{culture:null,icons:{down:"ui-icon-triangle-1-s",up:"ui-icon-triangle-1-n"},incremental:!0,max:null,min:null,numberFormat:null,page:10,step:1,change:null,spin:null,start:null,stop:null},_create:function(){this._setOption("max",this.options.max),this._setOption("min",this.options.min),this._setOption("step",this.options.step),""!==this.value()&&this._value(this.element.val(),!0),this._draw(),this._on(this._events),this._refresh(),this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_getCreateOptions:function(){var e={},i=this.element;return t.each(["min","max","step"],function(t,s){var n=i.attr(s);void 0!==n&&n.length&&(e[s]=n)}),e},_events:{keydown:function(t){this._start(t)&&this._keydown(t)&&t.preventDefault()},keyup:"_stop",focus:function(){this.previous=this.element.val()},blur:function(t){return this.cancelBlur?(delete this.cancelBlur,void 0):(this._stop(),this._refresh(),this.previous!==this.element.val()&&this._trigger("change",t),void 0)},mousewheel:function(t,e){if(e){if(!this.spinning&&!this._start(t))return!1;this._spin((e>0?1:-1)*this.options.step,t),clearTimeout(this.mousewheelTimer),this.mousewheelTimer=this._delay(function(){this.spinning&&this._stop(t)},100),t.preventDefault()}},"mousedown .ui-spinner-button":function(e){function i(){var t=this.element[0]===this.document[0].activeElement;t||(this.element.focus(),this.previous=s,this._delay(function(){this.previous=s}))}var s;s=this.element[0]===this.document[0].activeElement?this.previous:this.element.val(),e.preventDefault(),i.call(this),this.cancelBlur=!0,this._delay(function(){delete this.cancelBlur,i.call(this)}),this._start(e)!==!1&&this._repeat(null,t(e.currentTarget).hasClass("ui-spinner-up")?1:-1,e)},"mouseup .ui-spinner-button":"_stop","mouseenter .ui-spinner-button":function(e){return t(e.currentTarget).hasClass("ui-state-active")?this._start(e)===!1?!1:(this._repeat(null,t(e.currentTarget).hasClass("ui-spinner-up")?1:-1,e),void 0):void 0},"mouseleave .ui-spinner-button":"_stop"},_draw:function(){var t=this.uiSpinner=this.element.addClass("ui-spinner-input").attr("autocomplete","off").wrap(this._uiSpinnerHtml()).parent().append(this._buttonHtml());this.element.attr("role","spinbutton"),this.buttons=t.find(".ui-spinner-button").attr("tabIndex",-1).button().removeClass("ui-corner-all"),this.buttons.height()>Math.ceil(.5*t.height())&&t.height()>0&&t.height(t.height()),this.options.disabled&&this.disable()},_keydown:function(e){var i=this.options,s=t.ui.keyCode;switch(e.keyCode){case s.UP:return this._repeat(null,1,e),!0;case s.DOWN:return this._repeat(null,-1,e),!0;case s.PAGE_UP:return this._repeat(null,i.page,e),!0;case s.PAGE_DOWN:return this._repeat(null,-i.page,e),!0}return!1},_uiSpinnerHtml:function(){return"<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>"},_buttonHtml:function(){return"<a class='ui-spinner-button ui-spinner-up ui-corner-tr'><span class='ui-icon "+this.options.icons.up+"'>&#9650;</span>"+"</a>"+"<a class='ui-spinner-button ui-spinner-down ui-corner-br'>"+"<span class='ui-icon "+this.options.icons.down+"'>&#9660;</span>"+"</a>"},_start:function(t){return this.spinning||this._trigger("start",t)!==!1?(this.counter||(this.counter=1),this.spinning=!0,!0):!1},_repeat:function(t,e,i){t=t||500,clearTimeout(this.timer),this.timer=this._delay(function(){this._repeat(40,e,i)},t),this._spin(e*this.options.step,i)},_spin:function(t,e){var i=this.value()||0;this.counter||(this.counter=1),i=this._adjustValue(i+t*this._increment(this.counter)),this.spinning&&this._trigger("spin",e,{value:i})===!1||(this._value(i),this.counter++)},_increment:function(e){var i=this.options.incremental;return i?t.isFunction(i)?i(e):Math.floor(e*e*e/5e4-e*e/500+17*e/200+1):1},_precision:function(){var t=this._precisionOf(this.options.step);return null!==this.options.min&&(t=Math.max(t,this._precisionOf(this.options.min))),t},_precisionOf:function(t){var e=""+t,i=e.indexOf(".");return-1===i?0:e.length-i-1},_adjustValue:function(t){var e,i,s=this.options;return e=null!==s.min?s.min:0,i=t-e,i=Math.round(i/s.step)*s.step,t=e+i,t=parseFloat(t.toFixed(this._precision())),null!==s.max&&t>s.max?s.max:null!==s.min&&s.min>t?s.min:t},_stop:function(t){this.spinning&&(clearTimeout(this.timer),clearTimeout(this.mousewheelTimer),this.counter=0,this.spinning=!1,this._trigger("stop",t))},_setOption:function(t,e){if("culture"===t||"numberFormat"===t){var i=this._parse(this.element.val());return this.options[t]=e,this.element.val(this._format(i)),void 0}("max"===t||"min"===t||"step"===t)&&"string"==typeof e&&(e=this._parse(e)),"icons"===t&&(this.buttons.first().find(".ui-icon").removeClass(this.options.icons.up).addClass(e.up),this.buttons.last().find(".ui-icon").removeClass(this.options.icons.down).addClass(e.down)),this._super(t,e),"disabled"===t&&(e?(this.element.prop("disabled",!0),this.buttons.button("disable")):(this.element.prop("disabled",!1),this.buttons.button("enable")))},_setOptions:e(function(t){this._super(t),this._value(this.element.val())}),_parse:function(t){return"string"==typeof t&&""!==t&&(t=window.Globalize&&this.options.numberFormat?Globalize.parseFloat(t,10,this.options.culture):+t),""===t||isNaN(t)?null:t},_format:function(t){return""===t?"":window.Globalize&&this.options.numberFormat?Globalize.format(t,this.options.numberFormat,this.options.culture):t},_refresh:function(){this.element.attr({"aria-valuemin":this.options.min,"aria-valuemax":this.options.max,"aria-valuenow":this._parse(this.element.val())})},_value:function(t,e){var i;""!==t&&(i=this._parse(t),null!==i&&(e||(i=this._adjustValue(i)),t=this._format(i))),this.element.val(t),this._refresh()},_destroy:function(){this.element.removeClass("ui-spinner-input").prop("disabled",!1).removeAttr("autocomplete").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"),this.uiSpinner.replaceWith(this.element)},stepUp:e(function(t){this._stepUp(t)}),_stepUp:function(t){this._start()&&(this._spin((t||1)*this.options.step),this._stop())},stepDown:e(function(t){this._stepDown(t)}),_stepDown:function(t){this._start()&&(this._spin((t||1)*-this.options.step),this._stop())},pageUp:e(function(t){this._stepUp((t||1)*this.options.page)}),pageDown:e(function(t){this._stepDown((t||1)*this.options.page)}),value:function(t){return arguments.length?(e(this._value).call(this,t),void 0):this._parse(this.element.val())},widget:function(){return this.uiSpinner}})})(jQuery);
     1/*!
     2 * jQuery UI Spinner 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/spinner/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./core",
     18            "./widget",
     19            "./button"
     20        ], factory );
     21    } else {
     22
     23        // Browser globals
     24        factory( jQuery );
     25    }
     26}(function( $ ) {
     27
     28function spinner_modifier( fn ) {
     29    return function() {
     30        var previous = this.element.val();
     31        fn.apply( this, arguments );
     32        this._refresh();
     33        if ( previous !== this.element.val() ) {
     34            this._trigger( "change" );
     35        }
     36    };
     37}
     38
     39return $.widget( "ui.spinner", {
     40    version: "1.11.1",
     41    defaultElement: "<input>",
     42    widgetEventPrefix: "spin",
     43    options: {
     44        culture: null,
     45        icons: {
     46            down: "ui-icon-triangle-1-s",
     47            up: "ui-icon-triangle-1-n"
     48        },
     49        incremental: true,
     50        max: null,
     51        min: null,
     52        numberFormat: null,
     53        page: 10,
     54        step: 1,
     55
     56        change: null,
     57        spin: null,
     58        start: null,
     59        stop: null
     60    },
     61
     62    _create: function() {
     63        // handle string values that need to be parsed
     64        this._setOption( "max", this.options.max );
     65        this._setOption( "min", this.options.min );
     66        this._setOption( "step", this.options.step );
     67
     68        // Only format if there is a value, prevents the field from being marked
     69        // as invalid in Firefox, see #9573.
     70        if ( this.value() !== "" ) {
     71            // Format the value, but don't constrain.
     72            this._value( this.element.val(), true );
     73        }
     74
     75        this._draw();
     76        this._on( this._events );
     77        this._refresh();
     78
     79        // turning off autocomplete prevents the browser from remembering the
     80        // value when navigating through history, so we re-enable autocomplete
     81        // if the page is unloaded before the widget is destroyed. #7790
     82        this._on( this.window, {
     83            beforeunload: function() {
     84                this.element.removeAttr( "autocomplete" );
     85            }
     86        });
     87    },
     88
     89    _getCreateOptions: function() {
     90        var options = {},
     91            element = this.element;
     92
     93        $.each( [ "min", "max", "step" ], function( i, option ) {
     94            var value = element.attr( option );
     95            if ( value !== undefined && value.length ) {
     96                options[ option ] = value;
     97            }
     98        });
     99
     100        return options;
     101    },
     102
     103    _events: {
     104        keydown: function( event ) {
     105            if ( this._start( event ) && this._keydown( event ) ) {
     106                event.preventDefault();
     107            }
     108        },
     109        keyup: "_stop",
     110        focus: function() {
     111            this.previous = this.element.val();
     112        },
     113        blur: function( event ) {
     114            if ( this.cancelBlur ) {
     115                delete this.cancelBlur;
     116                return;
     117            }
     118
     119            this._stop();
     120            this._refresh();
     121            if ( this.previous !== this.element.val() ) {
     122                this._trigger( "change", event );
     123            }
     124        },
     125        mousewheel: function( event, delta ) {
     126            if ( !delta ) {
     127                return;
     128            }
     129            if ( !this.spinning && !this._start( event ) ) {
     130                return false;
     131            }
     132
     133            this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
     134            clearTimeout( this.mousewheelTimer );
     135            this.mousewheelTimer = this._delay(function() {
     136                if ( this.spinning ) {
     137                    this._stop( event );
     138                }
     139            }, 100 );
     140            event.preventDefault();
     141        },
     142        "mousedown .ui-spinner-button": function( event ) {
     143            var previous;
     144
     145            // We never want the buttons to have focus; whenever the user is
     146            // interacting with the spinner, the focus should be on the input.
     147            // If the input is focused then this.previous is properly set from
     148            // when the input first received focus. If the input is not focused
     149            // then we need to set this.previous based on the value before spinning.
     150            previous = this.element[0] === this.document[0].activeElement ?
     151                this.previous : this.element.val();
     152            function checkFocus() {
     153                var isActive = this.element[0] === this.document[0].activeElement;
     154                if ( !isActive ) {
     155                    this.element.focus();
     156                    this.previous = previous;
     157                    // support: IE
     158                    // IE sets focus asynchronously, so we need to check if focus
     159                    // moved off of the input because the user clicked on the button.
     160                    this._delay(function() {
     161                        this.previous = previous;
     162                    });
     163                }
     164            }
     165
     166            // ensure focus is on (or stays on) the text field
     167            event.preventDefault();
     168            checkFocus.call( this );
     169
     170            // support: IE
     171            // IE doesn't prevent moving focus even with event.preventDefault()
     172            // so we set a flag to know when we should ignore the blur event
     173            // and check (again) if focus moved off of the input.
     174            this.cancelBlur = true;
     175            this._delay(function() {
     176                delete this.cancelBlur;
     177                checkFocus.call( this );
     178            });
     179
     180            if ( this._start( event ) === false ) {
     181                return;
     182            }
     183
     184            this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
     185        },
     186        "mouseup .ui-spinner-button": "_stop",
     187        "mouseenter .ui-spinner-button": function( event ) {
     188            // button will add ui-state-active if mouse was down while mouseleave and kept down
     189            if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
     190                return;
     191            }
     192
     193            if ( this._start( event ) === false ) {
     194                return false;
     195            }
     196            this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
     197        },
     198        // TODO: do we really want to consider this a stop?
     199        // shouldn't we just stop the repeater and wait until mouseup before
     200        // we trigger the stop event?
     201        "mouseleave .ui-spinner-button": "_stop"
     202    },
     203
     204    _draw: function() {
     205        var uiSpinner = this.uiSpinner = this.element
     206            .addClass( "ui-spinner-input" )
     207            .attr( "autocomplete", "off" )
     208            .wrap( this._uiSpinnerHtml() )
     209            .parent()
     210                // add buttons
     211                .append( this._buttonHtml() );
     212
     213        this.element.attr( "role", "spinbutton" );
     214
     215        // button bindings
     216        this.buttons = uiSpinner.find( ".ui-spinner-button" )
     217            .attr( "tabIndex", -1 )
     218            .button()
     219            .removeClass( "ui-corner-all" );
     220
     221        // IE 6 doesn't understand height: 50% for the buttons
     222        // unless the wrapper has an explicit height
     223        if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
     224                uiSpinner.height() > 0 ) {
     225            uiSpinner.height( uiSpinner.height() );
     226        }
     227
     228        // disable spinner if element was already disabled
     229        if ( this.options.disabled ) {
     230            this.disable();
     231        }
     232    },
     233
     234    _keydown: function( event ) {
     235        var options = this.options,
     236            keyCode = $.ui.keyCode;
     237
     238        switch ( event.keyCode ) {
     239        case keyCode.UP:
     240            this._repeat( null, 1, event );
     241            return true;
     242        case keyCode.DOWN:
     243            this._repeat( null, -1, event );
     244            return true;
     245        case keyCode.PAGE_UP:
     246            this._repeat( null, options.page, event );
     247            return true;
     248        case keyCode.PAGE_DOWN:
     249            this._repeat( null, -options.page, event );
     250            return true;
     251        }
     252
     253        return false;
     254    },
     255
     256    _uiSpinnerHtml: function() {
     257        return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
     258    },
     259
     260    _buttonHtml: function() {
     261        return "" +
     262            "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
     263                "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
     264            "</a>" +
     265            "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
     266                "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
     267            "</a>";
     268    },
     269
     270    _start: function( event ) {
     271        if ( !this.spinning && this._trigger( "start", event ) === false ) {
     272            return false;
     273        }
     274
     275        if ( !this.counter ) {
     276            this.counter = 1;
     277        }
     278        this.spinning = true;
     279        return true;
     280    },
     281
     282    _repeat: function( i, steps, event ) {
     283        i = i || 500;
     284
     285        clearTimeout( this.timer );
     286        this.timer = this._delay(function() {
     287            this._repeat( 40, steps, event );
     288        }, i );
     289
     290        this._spin( steps * this.options.step, event );
     291    },
     292
     293    _spin: function( step, event ) {
     294        var value = this.value() || 0;
     295
     296        if ( !this.counter ) {
     297            this.counter = 1;
     298        }
     299
     300        value = this._adjustValue( value + step * this._increment( this.counter ) );
     301
     302        if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
     303            this._value( value );
     304            this.counter++;
     305        }
     306    },
     307
     308    _increment: function( i ) {
     309        var incremental = this.options.incremental;
     310
     311        if ( incremental ) {
     312            return $.isFunction( incremental ) ?
     313                incremental( i ) :
     314                Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
     315        }
     316
     317        return 1;
     318    },
     319
     320    _precision: function() {
     321        var precision = this._precisionOf( this.options.step );
     322        if ( this.options.min !== null ) {
     323            precision = Math.max( precision, this._precisionOf( this.options.min ) );
     324        }
     325        return precision;
     326    },
     327
     328    _precisionOf: function( num ) {
     329        var str = num.toString(),
     330            decimal = str.indexOf( "." );
     331        return decimal === -1 ? 0 : str.length - decimal - 1;
     332    },
     333
     334    _adjustValue: function( value ) {
     335        var base, aboveMin,
     336            options = this.options;
     337
     338        // make sure we're at a valid step
     339        // - find out where we are relative to the base (min or 0)
     340        base = options.min !== null ? options.min : 0;
     341        aboveMin = value - base;
     342        // - round to the nearest step
     343        aboveMin = Math.round(aboveMin / options.step) * options.step;
     344        // - rounding is based on 0, so adjust back to our base
     345        value = base + aboveMin;
     346
     347        // fix precision from bad JS floating point math
     348        value = parseFloat( value.toFixed( this._precision() ) );
     349
     350        // clamp the value
     351        if ( options.max !== null && value > options.max) {
     352            return options.max;
     353        }
     354        if ( options.min !== null && value < options.min ) {
     355            return options.min;
     356        }
     357
     358        return value;
     359    },
     360
     361    _stop: function( event ) {
     362        if ( !this.spinning ) {
     363            return;
     364        }
     365
     366        clearTimeout( this.timer );
     367        clearTimeout( this.mousewheelTimer );
     368        this.counter = 0;
     369        this.spinning = false;
     370        this._trigger( "stop", event );
     371    },
     372
     373    _setOption: function( key, value ) {
     374        if ( key === "culture" || key === "numberFormat" ) {
     375            var prevValue = this._parse( this.element.val() );
     376            this.options[ key ] = value;
     377            this.element.val( this._format( prevValue ) );
     378            return;
     379        }
     380
     381        if ( key === "max" || key === "min" || key === "step" ) {
     382            if ( typeof value === "string" ) {
     383                value = this._parse( value );
     384            }
     385        }
     386        if ( key === "icons" ) {
     387            this.buttons.first().find( ".ui-icon" )
     388                .removeClass( this.options.icons.up )
     389                .addClass( value.up );
     390            this.buttons.last().find( ".ui-icon" )
     391                .removeClass( this.options.icons.down )
     392                .addClass( value.down );
     393        }
     394
     395        this._super( key, value );
     396
     397        if ( key === "disabled" ) {
     398            this.widget().toggleClass( "ui-state-disabled", !!value );
     399            this.element.prop( "disabled", !!value );
     400            this.buttons.button( value ? "disable" : "enable" );
     401        }
     402    },
     403
     404    _setOptions: spinner_modifier(function( options ) {
     405        this._super( options );
     406    }),
     407
     408    _parse: function( val ) {
     409        if ( typeof val === "string" && val !== "" ) {
     410            val = window.Globalize && this.options.numberFormat ?
     411                Globalize.parseFloat( val, 10, this.options.culture ) : +val;
     412        }
     413        return val === "" || isNaN( val ) ? null : val;
     414    },
     415
     416    _format: function( value ) {
     417        if ( value === "" ) {
     418            return "";
     419        }
     420        return window.Globalize && this.options.numberFormat ?
     421            Globalize.format( value, this.options.numberFormat, this.options.culture ) :
     422            value;
     423    },
     424
     425    _refresh: function() {
     426        this.element.attr({
     427            "aria-valuemin": this.options.min,
     428            "aria-valuemax": this.options.max,
     429            // TODO: what should we do with values that can't be parsed?
     430            "aria-valuenow": this._parse( this.element.val() )
     431        });
     432    },
     433
     434    isValid: function() {
     435        var value = this.value();
     436
     437        // null is invalid
     438        if ( value === null ) {
     439            return false;
     440        }
     441
     442        // if value gets adjusted, it's invalid
     443        return value === this._adjustValue( value );
     444    },
     445
     446    // update the value without triggering change
     447    _value: function( value, allowAny ) {
     448        var parsed;
     449        if ( value !== "" ) {
     450            parsed = this._parse( value );
     451            if ( parsed !== null ) {
     452                if ( !allowAny ) {
     453                    parsed = this._adjustValue( parsed );
     454                }
     455                value = this._format( parsed );
     456            }
     457        }
     458        this.element.val( value );
     459        this._refresh();
     460    },
     461
     462    _destroy: function() {
     463        this.element
     464            .removeClass( "ui-spinner-input" )
     465            .prop( "disabled", false )
     466            .removeAttr( "autocomplete" )
     467            .removeAttr( "role" )
     468            .removeAttr( "aria-valuemin" )
     469            .removeAttr( "aria-valuemax" )
     470            .removeAttr( "aria-valuenow" );
     471        this.uiSpinner.replaceWith( this.element );
     472    },
     473
     474    stepUp: spinner_modifier(function( steps ) {
     475        this._stepUp( steps );
     476    }),
     477    _stepUp: function( steps ) {
     478        if ( this._start() ) {
     479            this._spin( (steps || 1) * this.options.step );
     480            this._stop();
     481        }
     482    },
     483
     484    stepDown: spinner_modifier(function( steps ) {
     485        this._stepDown( steps );
     486    }),
     487    _stepDown: function( steps ) {
     488        if ( this._start() ) {
     489            this._spin( (steps || 1) * -this.options.step );
     490            this._stop();
     491        }
     492    },
     493
     494    pageUp: spinner_modifier(function( pages ) {
     495        this._stepUp( (pages || 1) * this.options.page );
     496    }),
     497
     498    pageDown: spinner_modifier(function( pages ) {
     499        this._stepDown( (pages || 1) * this.options.page );
     500    }),
     501
     502    value: function( newVal ) {
     503        if ( !arguments.length ) {
     504            return this._parse( this.element.val() );
     505        }
     506        spinner_modifier( this._value ).call( this, newVal );
     507    },
     508
     509    widget: function() {
     510        return this.uiSpinner;
     511    }
     512});
     513
     514}));
  • trunk/src/wp-includes/js/jquery/ui/tabs.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t,e){function i(){return++n}function s(t){return t=t.cloneNode(!1),t.hash.length>1&&decodeURIComponent(t.href.replace(a,""))===decodeURIComponent(location.href.replace(a,""))}var n=0,a=/#.*$/;t.widget("ui.tabs",{version:"1.10.4",delay:300,options:{active:null,collapsible:!1,event:"click",heightStyle:"content",hide:null,show:null,activate:null,beforeActivate:null,beforeLoad:null,load:null},_create:function(){var e=this,i=this.options;this.running=!1,this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all").toggleClass("ui-tabs-collapsible",i.collapsible).delegate(".ui-tabs-nav > li","mousedown"+this.eventNamespace,function(e){t(this).is(".ui-state-disabled")&&e.preventDefault()}).delegate(".ui-tabs-anchor","focus"+this.eventNamespace,function(){t(this).closest("li").is(".ui-state-disabled")&&this.blur()}),this._processTabs(),i.active=this._initialActive(),t.isArray(i.disabled)&&(i.disabled=t.unique(i.disabled.concat(t.map(this.tabs.filter(".ui-state-disabled"),function(t){return e.tabs.index(t)}))).sort()),this.active=this.options.active!==!1&&this.anchors.length?this._findActive(i.active):t(),this._refresh(),this.active.length&&this.load(i.active)},_initialActive:function(){var i=this.options.active,s=this.options.collapsible,n=location.hash.substring(1);return null===i&&(n&&this.tabs.each(function(s,a){return t(a).attr("aria-controls")===n?(i=s,!1):e}),null===i&&(i=this.tabs.index(this.tabs.filter(".ui-tabs-active"))),(null===i||-1===i)&&(i=this.tabs.length?0:!1)),i!==!1&&(i=this.tabs.index(this.tabs.eq(i)),-1===i&&(i=s?!1:0)),!s&&i===!1&&this.anchors.length&&(i=0),i},_getCreateEventData:function(){return{tab:this.active,panel:this.active.length?this._getPanelForTab(this.active):t()}},_tabKeydown:function(i){var s=t(this.document[0].activeElement).closest("li"),n=this.tabs.index(s),a=!0;if(!this._handlePageNav(i)){switch(i.keyCode){case t.ui.keyCode.RIGHT:case t.ui.keyCode.DOWN:n++;break;case t.ui.keyCode.UP:case t.ui.keyCode.LEFT:a=!1,n--;break;case t.ui.keyCode.END:n=this.anchors.length-1;break;case t.ui.keyCode.HOME:n=0;break;case t.ui.keyCode.SPACE:return i.preventDefault(),clearTimeout(this.activating),this._activate(n),e;case t.ui.keyCode.ENTER:return i.preventDefault(),clearTimeout(this.activating),this._activate(n===this.options.active?!1:n),e;default:return}i.preventDefault(),clearTimeout(this.activating),n=this._focusNextTab(n,a),i.ctrlKey||(s.attr("aria-selected","false"),this.tabs.eq(n).attr("aria-selected","true"),this.activating=this._delay(function(){this.option("active",n)},this.delay))}},_panelKeydown:function(e){this._handlePageNav(e)||e.ctrlKey&&e.keyCode===t.ui.keyCode.UP&&(e.preventDefault(),this.active.focus())},_handlePageNav:function(i){return i.altKey&&i.keyCode===t.ui.keyCode.PAGE_UP?(this._activate(this._focusNextTab(this.options.active-1,!1)),!0):i.altKey&&i.keyCode===t.ui.keyCode.PAGE_DOWN?(this._activate(this._focusNextTab(this.options.active+1,!0)),!0):e},_findNextTab:function(e,i){function s(){return e>n&&(e=0),0>e&&(e=n),e}for(var n=this.tabs.length-1;-1!==t.inArray(s(),this.options.disabled);)e=i?e+1:e-1;return e},_focusNextTab:function(t,e){return t=this._findNextTab(t,e),this.tabs.eq(t).focus(),t},_setOption:function(t,i){return"active"===t?(this._activate(i),e):"disabled"===t?(this._setupDisabled(i),e):(this._super(t,i),"collapsible"===t&&(this.element.toggleClass("ui-tabs-collapsible",i),i||this.options.active!==!1||this._activate(0)),"event"===t&&this._setupEvents(i),"heightStyle"===t&&this._setupHeightStyle(i),e)},_tabId:function(t){return t.attr("aria-controls")||"ui-tabs-"+i()},_sanitizeSelector:function(t){return t?t.replace(/[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g,"\\$&"):""},refresh:function(){var e=this.options,i=this.tablist.children(":has(a[href])");e.disabled=t.map(i.filter(".ui-state-disabled"),function(t){return i.index(t)}),this._processTabs(),e.active!==!1&&this.anchors.length?this.active.length&&!t.contains(this.tablist[0],this.active[0])?this.tabs.length===e.disabled.length?(e.active=!1,this.active=t()):this._activate(this._findNextTab(Math.max(0,e.active-1),!1)):e.active=this.tabs.index(this.active):(e.active=!1,this.active=t()),this._refresh()},_refresh:function(){this._setupDisabled(this.options.disabled),this._setupEvents(this.options.event),this._setupHeightStyle(this.options.heightStyle),this.tabs.not(this.active).attr({"aria-selected":"false",tabIndex:-1}),this.panels.not(this._getPanelForTab(this.active)).hide().attr({"aria-expanded":"false","aria-hidden":"true"}),this.active.length?(this.active.addClass("ui-tabs-active ui-state-active").attr({"aria-selected":"true",tabIndex:0}),this._getPanelForTab(this.active).show().attr({"aria-expanded":"true","aria-hidden":"false"})):this.tabs.eq(0).attr("tabIndex",0)},_processTabs:function(){var e=this;this.tablist=this._getList().addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").attr("role","tablist"),this.tabs=this.tablist.find("> li:has(a[href])").addClass("ui-state-default ui-corner-top").attr({role:"tab",tabIndex:-1}),this.anchors=this.tabs.map(function(){return t("a",this)[0]}).addClass("ui-tabs-anchor").attr({role:"presentation",tabIndex:-1}),this.panels=t(),this.anchors.each(function(i,n){var a,o,r,h=t(n).uniqueId().attr("id"),l=t(n).closest("li"),u=l.attr("aria-controls");s(n)?(a=n.hash,o=e.element.find(e._sanitizeSelector(a))):(r=e._tabId(l),a="#"+r,o=e.element.find(a),o.length||(o=e._createPanel(r),o.insertAfter(e.panels[i-1]||e.tablist)),o.attr("aria-live","polite")),o.length&&(e.panels=e.panels.add(o)),u&&l.data("ui-tabs-aria-controls",u),l.attr({"aria-controls":a.substring(1),"aria-labelledby":h}),o.attr("aria-labelledby",h)}),this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").attr("role","tabpanel")},_getList:function(){return this.tablist||this.element.find("ol,ul").eq(0)},_createPanel:function(e){return t("<div>").attr("id",e).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").data("ui-tabs-destroy",!0)},_setupDisabled:function(e){t.isArray(e)&&(e.length?e.length===this.anchors.length&&(e=!0):e=!1);for(var i,s=0;i=this.tabs[s];s++)e===!0||-1!==t.inArray(s,e)?t(i).addClass("ui-state-disabled").attr("aria-disabled","true"):t(i).removeClass("ui-state-disabled").removeAttr("aria-disabled");this.options.disabled=e},_setupEvents:function(e){var i={click:function(t){t.preventDefault()}};e&&t.each(e.split(" "),function(t,e){i[e]="_eventHandler"}),this._off(this.anchors.add(this.tabs).add(this.panels)),this._on(this.anchors,i),this._on(this.tabs,{keydown:"_tabKeydown"}),this._on(this.panels,{keydown:"_panelKeydown"}),this._focusable(this.tabs),this._hoverable(this.tabs)},_setupHeightStyle:function(e){var i,s=this.element.parent();"fill"===e?(i=s.height(),i-=this.element.outerHeight()-this.element.height(),this.element.siblings(":visible").each(function(){var e=t(this),s=e.css("position");"absolute"!==s&&"fixed"!==s&&(i-=e.outerHeight(!0))}),this.element.children().not(this.panels).each(function(){i-=t(this).outerHeight(!0)}),this.panels.each(function(){t(this).height(Math.max(0,i-t(this).innerHeight()+t(this).height()))}).css("overflow","auto")):"auto"===e&&(i=0,this.panels.each(function(){i=Math.max(i,t(this).height("").height())}).height(i))},_eventHandler:function(e){var i=this.options,s=this.active,n=t(e.currentTarget),a=n.closest("li"),o=a[0]===s[0],r=o&&i.collapsible,h=r?t():this._getPanelForTab(a),l=s.length?this._getPanelForTab(s):t(),u={oldTab:s,oldPanel:l,newTab:r?t():a,newPanel:h};e.preventDefault(),a.hasClass("ui-state-disabled")||a.hasClass("ui-tabs-loading")||this.running||o&&!i.collapsible||this._trigger("beforeActivate",e,u)===!1||(i.active=r?!1:this.tabs.index(a),this.active=o?t():a,this.xhr&&this.xhr.abort(),l.length||h.length||t.error("jQuery UI Tabs: Mismatching fragment identifier."),h.length&&this.load(this.tabs.index(a),e),this._toggle(e,u))},_toggle:function(e,i){function s(){a.running=!1,a._trigger("activate",e,i)}function n(){i.newTab.closest("li").addClass("ui-tabs-active ui-state-active"),o.length&&a.options.show?a._show(o,a.options.show,s):(o.show(),s())}var a=this,o=i.newPanel,r=i.oldPanel;this.running=!0,r.length&&this.options.hide?this._hide(r,this.options.hide,function(){i.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),n()}):(i.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),r.hide(),n()),r.attr({"aria-expanded":"false","aria-hidden":"true"}),i.oldTab.attr("aria-selected","false"),o.length&&r.length?i.oldTab.attr("tabIndex",-1):o.length&&this.tabs.filter(function(){return 0===t(this).attr("tabIndex")}).attr("tabIndex",-1),o.attr({"aria-expanded":"true","aria-hidden":"false"}),i.newTab.attr({"aria-selected":"true",tabIndex:0})},_activate:function(e){var i,s=this._findActive(e);s[0]!==this.active[0]&&(s.length||(s=this.active),i=s.find(".ui-tabs-anchor")[0],this._eventHandler({target:i,currentTarget:i,preventDefault:t.noop}))},_findActive:function(e){return e===!1?t():this.tabs.eq(e)},_getIndex:function(t){return"string"==typeof t&&(t=this.anchors.index(this.anchors.filter("[href$='"+t+"']"))),t},_destroy:function(){this.xhr&&this.xhr.abort(),this.element.removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible"),this.tablist.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").removeAttr("role"),this.anchors.removeClass("ui-tabs-anchor").removeAttr("role").removeAttr("tabIndex").removeUniqueId(),this.tabs.add(this.panels).each(function(){t.data(this,"ui-tabs-destroy")?t(this).remove():t(this).removeClass("ui-state-default ui-state-active ui-state-disabled ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel").removeAttr("tabIndex").removeAttr("aria-live").removeAttr("aria-busy").removeAttr("aria-selected").removeAttr("aria-labelledby").removeAttr("aria-hidden").removeAttr("aria-expanded").removeAttr("role")}),this.tabs.each(function(){var e=t(this),i=e.data("ui-tabs-aria-controls");i?e.attr("aria-controls",i).removeData("ui-tabs-aria-controls"):e.removeAttr("aria-controls")}),this.panels.show(),"content"!==this.options.heightStyle&&this.panels.css("height","")},enable:function(i){var s=this.options.disabled;s!==!1&&(i===e?s=!1:(i=this._getIndex(i),s=t.isArray(s)?t.map(s,function(t){return t!==i?t:null}):t.map(this.tabs,function(t,e){return e!==i?e:null})),this._setupDisabled(s))},disable:function(i){var s=this.options.disabled;if(s!==!0){if(i===e)s=!0;else{if(i=this._getIndex(i),-1!==t.inArray(i,s))return;s=t.isArray(s)?t.merge([i],s).sort():[i]}this._setupDisabled(s)}},load:function(e,i){e=this._getIndex(e);var n=this,a=this.tabs.eq(e),o=a.find(".ui-tabs-anchor"),r=this._getPanelForTab(a),h={tab:a,panel:r};s(o[0])||(this.xhr=t.ajax(this._ajaxSettings(o,i,h)),this.xhr&&"canceled"!==this.xhr.statusText&&(a.addClass("ui-tabs-loading"),r.attr("aria-busy","true"),this.xhr.success(function(t){setTimeout(function(){r.html(t),n._trigger("load",i,h)},1)}).complete(function(t,e){setTimeout(function(){"abort"===e&&n.panels.stop(!1,!0),a.removeClass("ui-tabs-loading"),r.removeAttr("aria-busy"),t===n.xhr&&delete n.xhr},1)})))},_ajaxSettings:function(e,i,s){var n=this;return{url:e.attr("href"),beforeSend:function(e,a){return n._trigger("beforeLoad",i,t.extend({jqXHR:e,ajaxSettings:a},s))}}},_getPanelForTab:function(e){var i=t(e).attr("aria-controls");return this.element.find(this._sanitizeSelector("#"+i))}})})(jQuery);
     1/*!
     2 * jQuery UI Tabs 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/tabs/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./core",
     18            "./widget"
     19        ], factory );
     20    } else {
     21
     22        // Browser globals
     23        factory( jQuery );
     24    }
     25}(function( $ ) {
     26
     27return $.widget( "ui.tabs", {
     28    version: "1.11.1",
     29    delay: 300,
     30    options: {
     31        active: null,
     32        collapsible: false,
     33        event: "click",
     34        heightStyle: "content",
     35        hide: null,
     36        show: null,
     37
     38        // callbacks
     39        activate: null,
     40        beforeActivate: null,
     41        beforeLoad: null,
     42        load: null
     43    },
     44
     45    _isLocal: (function() {
     46        var rhash = /#.*$/;
     47
     48        return function( anchor ) {
     49            var anchorUrl, locationUrl;
     50
     51            // support: IE7
     52            // IE7 doesn't normalize the href property when set via script (#9317)
     53            anchor = anchor.cloneNode( false );
     54
     55            anchorUrl = anchor.href.replace( rhash, "" );
     56            locationUrl = location.href.replace( rhash, "" );
     57
     58            // decoding may throw an error if the URL isn't UTF-8 (#9518)
     59            try {
     60                anchorUrl = decodeURIComponent( anchorUrl );
     61            } catch ( error ) {}
     62            try {
     63                locationUrl = decodeURIComponent( locationUrl );
     64            } catch ( error ) {}
     65
     66            return anchor.hash.length > 1 && anchorUrl === locationUrl;
     67        };
     68    })(),
     69
     70    _create: function() {
     71        var that = this,
     72            options = this.options;
     73
     74        this.running = false;
     75
     76        this.element
     77            .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
     78            .toggleClass( "ui-tabs-collapsible", options.collapsible );
     79
     80        this._processTabs();
     81        options.active = this._initialActive();
     82
     83        // Take disabling tabs via class attribute from HTML
     84        // into account and update option properly.
     85        if ( $.isArray( options.disabled ) ) {
     86            options.disabled = $.unique( options.disabled.concat(
     87                $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
     88                    return that.tabs.index( li );
     89                })
     90            ) ).sort();
     91        }
     92
     93        // check for length avoids error when initializing empty list
     94        if ( this.options.active !== false && this.anchors.length ) {
     95            this.active = this._findActive( options.active );
     96        } else {
     97            this.active = $();
     98        }
     99
     100        this._refresh();
     101
     102        if ( this.active.length ) {
     103            this.load( options.active );
     104        }
     105    },
     106
     107    _initialActive: function() {
     108        var active = this.options.active,
     109            collapsible = this.options.collapsible,
     110            locationHash = location.hash.substring( 1 );
     111
     112        if ( active === null ) {
     113            // check the fragment identifier in the URL
     114            if ( locationHash ) {
     115                this.tabs.each(function( i, tab ) {
     116                    if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
     117                        active = i;
     118                        return false;
     119                    }
     120                });
     121            }
     122
     123            // check for a tab marked active via a class
     124            if ( active === null ) {
     125                active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
     126            }
     127
     128            // no active tab, set to false
     129            if ( active === null || active === -1 ) {
     130                active = this.tabs.length ? 0 : false;
     131            }
     132        }
     133
     134        // handle numbers: negative, out of range
     135        if ( active !== false ) {
     136            active = this.tabs.index( this.tabs.eq( active ) );
     137            if ( active === -1 ) {
     138                active = collapsible ? false : 0;
     139            }
     140        }
     141
     142        // don't allow collapsible: false and active: false
     143        if ( !collapsible && active === false && this.anchors.length ) {
     144            active = 0;
     145        }
     146
     147        return active;
     148    },
     149
     150    _getCreateEventData: function() {
     151        return {
     152            tab: this.active,
     153            panel: !this.active.length ? $() : this._getPanelForTab( this.active )
     154        };
     155    },
     156
     157    _tabKeydown: function( event ) {
     158        var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
     159            selectedIndex = this.tabs.index( focusedTab ),
     160            goingForward = true;
     161
     162        if ( this._handlePageNav( event ) ) {
     163            return;
     164        }
     165
     166        switch ( event.keyCode ) {
     167            case $.ui.keyCode.RIGHT:
     168            case $.ui.keyCode.DOWN:
     169                selectedIndex++;
     170                break;
     171            case $.ui.keyCode.UP:
     172            case $.ui.keyCode.LEFT:
     173                goingForward = false;
     174                selectedIndex--;
     175                break;
     176            case $.ui.keyCode.END:
     177                selectedIndex = this.anchors.length - 1;
     178                break;
     179            case $.ui.keyCode.HOME:
     180                selectedIndex = 0;
     181                break;
     182            case $.ui.keyCode.SPACE:
     183                // Activate only, no collapsing
     184                event.preventDefault();
     185                clearTimeout( this.activating );
     186                this._activate( selectedIndex );
     187                return;
     188            case $.ui.keyCode.ENTER:
     189                // Toggle (cancel delayed activation, allow collapsing)
     190                event.preventDefault();
     191                clearTimeout( this.activating );
     192                // Determine if we should collapse or activate
     193                this._activate( selectedIndex === this.options.active ? false : selectedIndex );
     194                return;
     195            default:
     196                return;
     197        }
     198
     199        // Focus the appropriate tab, based on which key was pressed
     200        event.preventDefault();
     201        clearTimeout( this.activating );
     202        selectedIndex = this._focusNextTab( selectedIndex, goingForward );
     203
     204        // Navigating with control key will prevent automatic activation
     205        if ( !event.ctrlKey ) {
     206            // Update aria-selected immediately so that AT think the tab is already selected.
     207            // Otherwise AT may confuse the user by stating that they need to activate the tab,
     208            // but the tab will already be activated by the time the announcement finishes.
     209            focusedTab.attr( "aria-selected", "false" );
     210            this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
     211
     212            this.activating = this._delay(function() {
     213                this.option( "active", selectedIndex );
     214            }, this.delay );
     215        }
     216    },
     217
     218    _panelKeydown: function( event ) {
     219        if ( this._handlePageNav( event ) ) {
     220            return;
     221        }
     222
     223        // Ctrl+up moves focus to the current tab
     224        if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
     225            event.preventDefault();
     226            this.active.focus();
     227        }
     228    },
     229
     230    // Alt+page up/down moves focus to the previous/next tab (and activates)
     231    _handlePageNav: function( event ) {
     232        if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
     233            this._activate( this._focusNextTab( this.options.active - 1, false ) );
     234            return true;
     235        }
     236        if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
     237            this._activate( this._focusNextTab( this.options.active + 1, true ) );
     238            return true;
     239        }
     240    },
     241
     242    _findNextTab: function( index, goingForward ) {
     243        var lastTabIndex = this.tabs.length - 1;
     244
     245        function constrain() {
     246            if ( index > lastTabIndex ) {
     247                index = 0;
     248            }
     249            if ( index < 0 ) {
     250                index = lastTabIndex;
     251            }
     252            return index;
     253        }
     254
     255        while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
     256            index = goingForward ? index + 1 : index - 1;
     257        }
     258
     259        return index;
     260    },
     261
     262    _focusNextTab: function( index, goingForward ) {
     263        index = this._findNextTab( index, goingForward );
     264        this.tabs.eq( index ).focus();
     265        return index;
     266    },
     267
     268    _setOption: function( key, value ) {
     269        if ( key === "active" ) {
     270            // _activate() will handle invalid values and update this.options
     271            this._activate( value );
     272            return;
     273        }
     274
     275        if ( key === "disabled" ) {
     276            // don't use the widget factory's disabled handling
     277            this._setupDisabled( value );
     278            return;
     279        }
     280
     281        this._super( key, value);
     282
     283        if ( key === "collapsible" ) {
     284            this.element.toggleClass( "ui-tabs-collapsible", value );
     285            // Setting collapsible: false while collapsed; open first panel
     286            if ( !value && this.options.active === false ) {
     287                this._activate( 0 );
     288            }
     289        }
     290
     291        if ( key === "event" ) {
     292            this._setupEvents( value );
     293        }
     294
     295        if ( key === "heightStyle" ) {
     296            this._setupHeightStyle( value );
     297        }
     298    },
     299
     300    _sanitizeSelector: function( hash ) {
     301        return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
     302    },
     303
     304    refresh: function() {
     305        var options = this.options,
     306            lis = this.tablist.children( ":has(a[href])" );
     307
     308        // get disabled tabs from class attribute from HTML
     309        // this will get converted to a boolean if needed in _refresh()
     310        options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
     311            return lis.index( tab );
     312        });
     313
     314        this._processTabs();
     315
     316        // was collapsed or no tabs
     317        if ( options.active === false || !this.anchors.length ) {
     318            options.active = false;
     319            this.active = $();
     320        // was active, but active tab is gone
     321        } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
     322            // all remaining tabs are disabled
     323            if ( this.tabs.length === options.disabled.length ) {
     324                options.active = false;
     325                this.active = $();
     326            // activate previous tab
     327            } else {
     328                this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
     329            }
     330        // was active, active tab still exists
     331        } else {
     332            // make sure active index is correct
     333            options.active = this.tabs.index( this.active );
     334        }
     335
     336        this._refresh();
     337    },
     338
     339    _refresh: function() {
     340        this._setupDisabled( this.options.disabled );
     341        this._setupEvents( this.options.event );
     342        this._setupHeightStyle( this.options.heightStyle );
     343
     344        this.tabs.not( this.active ).attr({
     345            "aria-selected": "false",
     346            "aria-expanded": "false",
     347            tabIndex: -1
     348        });
     349        this.panels.not( this._getPanelForTab( this.active ) )
     350            .hide()
     351            .attr({
     352                "aria-hidden": "true"
     353            });
     354
     355        // Make sure one tab is in the tab order
     356        if ( !this.active.length ) {
     357            this.tabs.eq( 0 ).attr( "tabIndex", 0 );
     358        } else {
     359            this.active
     360                .addClass( "ui-tabs-active ui-state-active" )
     361                .attr({
     362                    "aria-selected": "true",
     363                    "aria-expanded": "true",
     364                    tabIndex: 0
     365                });
     366            this._getPanelForTab( this.active )
     367                .show()
     368                .attr({
     369                    "aria-hidden": "false"
     370                });
     371        }
     372    },
     373
     374    _processTabs: function() {
     375        var that = this;
     376
     377        this.tablist = this._getList()
     378            .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
     379            .attr( "role", "tablist" )
     380
     381            // Prevent users from focusing disabled tabs via click
     382            .delegate( "> li", "mousedown" + this.eventNamespace, function( event ) {
     383                if ( $( this ).is( ".ui-state-disabled" ) ) {
     384                    event.preventDefault();
     385                }
     386            })
     387
     388            // support: IE <9
     389            // Preventing the default action in mousedown doesn't prevent IE
     390            // from focusing the element, so if the anchor gets focused, blur.
     391            // We don't have to worry about focusing the previously focused
     392            // element since clicking on a non-focusable element should focus
     393            // the body anyway.
     394            .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
     395                if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
     396                    this.blur();
     397                }
     398            });
     399
     400        this.tabs = this.tablist.find( "> li:has(a[href])" )
     401            .addClass( "ui-state-default ui-corner-top" )
     402            .attr({
     403                role: "tab",
     404                tabIndex: -1
     405            });
     406
     407        this.anchors = this.tabs.map(function() {
     408                return $( "a", this )[ 0 ];
     409            })
     410            .addClass( "ui-tabs-anchor" )
     411            .attr({
     412                role: "presentation",
     413                tabIndex: -1
     414            });
     415
     416        this.panels = $();
     417
     418        this.anchors.each(function( i, anchor ) {
     419            var selector, panel, panelId,
     420                anchorId = $( anchor ).uniqueId().attr( "id" ),
     421                tab = $( anchor ).closest( "li" ),
     422                originalAriaControls = tab.attr( "aria-controls" );
     423
     424            // inline tab
     425            if ( that._isLocal( anchor ) ) {
     426                selector = anchor.hash;
     427                panelId = selector.substring( 1 );
     428                panel = that.element.find( that._sanitizeSelector( selector ) );
     429            // remote tab
     430            } else {
     431                // If the tab doesn't already have aria-controls,
     432                // generate an id by using a throw-away element
     433                panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
     434                selector = "#" + panelId;
     435                panel = that.element.find( selector );
     436                if ( !panel.length ) {
     437                    panel = that._createPanel( panelId );
     438                    panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
     439                }
     440                panel.attr( "aria-live", "polite" );
     441            }
     442
     443            if ( panel.length) {
     444                that.panels = that.panels.add( panel );
     445            }
     446            if ( originalAriaControls ) {
     447                tab.data( "ui-tabs-aria-controls", originalAriaControls );
     448            }
     449            tab.attr({
     450                "aria-controls": panelId,
     451                "aria-labelledby": anchorId
     452            });
     453            panel.attr( "aria-labelledby", anchorId );
     454        });
     455
     456        this.panels
     457            .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
     458            .attr( "role", "tabpanel" );
     459    },
     460
     461    // allow overriding how to find the list for rare usage scenarios (#7715)
     462    _getList: function() {
     463        return this.tablist || this.element.find( "ol,ul" ).eq( 0 );
     464    },
     465
     466    _createPanel: function( id ) {
     467        return $( "<div>" )
     468            .attr( "id", id )
     469            .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
     470            .data( "ui-tabs-destroy", true );
     471    },
     472
     473    _setupDisabled: function( disabled ) {
     474        if ( $.isArray( disabled ) ) {
     475            if ( !disabled.length ) {
     476                disabled = false;
     477            } else if ( disabled.length === this.anchors.length ) {
     478                disabled = true;
     479            }
     480        }
     481
     482        // disable tabs
     483        for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
     484            if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
     485                $( li )
     486                    .addClass( "ui-state-disabled" )
     487                    .attr( "aria-disabled", "true" );
     488            } else {
     489                $( li )
     490                    .removeClass( "ui-state-disabled" )
     491                    .removeAttr( "aria-disabled" );
     492            }
     493        }
     494
     495        this.options.disabled = disabled;
     496    },
     497
     498    _setupEvents: function( event ) {
     499        var events = {};
     500        if ( event ) {
     501            $.each( event.split(" "), function( index, eventName ) {
     502                events[ eventName ] = "_eventHandler";
     503            });
     504        }
     505
     506        this._off( this.anchors.add( this.tabs ).add( this.panels ) );
     507        // Always prevent the default action, even when disabled
     508        this._on( true, this.anchors, {
     509            click: function( event ) {
     510                event.preventDefault();
     511            }
     512        });
     513        this._on( this.anchors, events );
     514        this._on( this.tabs, { keydown: "_tabKeydown" } );
     515        this._on( this.panels, { keydown: "_panelKeydown" } );
     516
     517        this._focusable( this.tabs );
     518        this._hoverable( this.tabs );
     519    },
     520
     521    _setupHeightStyle: function( heightStyle ) {
     522        var maxHeight,
     523            parent = this.element.parent();
     524
     525        if ( heightStyle === "fill" ) {
     526            maxHeight = parent.height();
     527            maxHeight -= this.element.outerHeight() - this.element.height();
     528
     529            this.element.siblings( ":visible" ).each(function() {
     530                var elem = $( this ),
     531                    position = elem.css( "position" );
     532
     533                if ( position === "absolute" || position === "fixed" ) {
     534                    return;
     535                }
     536                maxHeight -= elem.outerHeight( true );
     537            });
     538
     539            this.element.children().not( this.panels ).each(function() {
     540                maxHeight -= $( this ).outerHeight( true );
     541            });
     542
     543            this.panels.each(function() {
     544                $( this ).height( Math.max( 0, maxHeight -
     545                    $( this ).innerHeight() + $( this ).height() ) );
     546            })
     547            .css( "overflow", "auto" );
     548        } else if ( heightStyle === "auto" ) {
     549            maxHeight = 0;
     550            this.panels.each(function() {
     551                maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
     552            }).height( maxHeight );
     553        }
     554    },
     555
     556    _eventHandler: function( event ) {
     557        var options = this.options,
     558            active = this.active,
     559            anchor = $( event.currentTarget ),
     560            tab = anchor.closest( "li" ),
     561            clickedIsActive = tab[ 0 ] === active[ 0 ],
     562            collapsing = clickedIsActive && options.collapsible,
     563            toShow = collapsing ? $() : this._getPanelForTab( tab ),
     564            toHide = !active.length ? $() : this._getPanelForTab( active ),
     565            eventData = {
     566                oldTab: active,
     567                oldPanel: toHide,
     568                newTab: collapsing ? $() : tab,
     569                newPanel: toShow
     570            };
     571
     572        event.preventDefault();
     573
     574        if ( tab.hasClass( "ui-state-disabled" ) ||
     575                // tab is already loading
     576                tab.hasClass( "ui-tabs-loading" ) ||
     577                // can't switch durning an animation
     578                this.running ||
     579                // click on active header, but not collapsible
     580                ( clickedIsActive && !options.collapsible ) ||
     581                // allow canceling activation
     582                ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
     583            return;
     584        }
     585
     586        options.active = collapsing ? false : this.tabs.index( tab );
     587
     588        this.active = clickedIsActive ? $() : tab;
     589        if ( this.xhr ) {
     590            this.xhr.abort();
     591        }
     592
     593        if ( !toHide.length && !toShow.length ) {
     594            $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
     595        }
     596
     597        if ( toShow.length ) {
     598            this.load( this.tabs.index( tab ), event );
     599        }
     600        this._toggle( event, eventData );
     601    },
     602
     603    // handles show/hide for selecting tabs
     604    _toggle: function( event, eventData ) {
     605        var that = this,
     606            toShow = eventData.newPanel,
     607            toHide = eventData.oldPanel;
     608
     609        this.running = true;
     610
     611        function complete() {
     612            that.running = false;
     613            that._trigger( "activate", event, eventData );
     614        }
     615
     616        function show() {
     617            eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
     618
     619            if ( toShow.length && that.options.show ) {
     620                that._show( toShow, that.options.show, complete );
     621            } else {
     622                toShow.show();
     623                complete();
     624            }
     625        }
     626
     627        // start out by hiding, then showing, then completing
     628        if ( toHide.length && this.options.hide ) {
     629            this._hide( toHide, this.options.hide, function() {
     630                eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
     631                show();
     632            });
     633        } else {
     634            eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
     635            toHide.hide();
     636            show();
     637        }
     638
     639        toHide.attr( "aria-hidden", "true" );
     640        eventData.oldTab.attr({
     641            "aria-selected": "false",
     642            "aria-expanded": "false"
     643        });
     644        // If we're switching tabs, remove the old tab from the tab order.
     645        // If we're opening from collapsed state, remove the previous tab from the tab order.
     646        // If we're collapsing, then keep the collapsing tab in the tab order.
     647        if ( toShow.length && toHide.length ) {
     648            eventData.oldTab.attr( "tabIndex", -1 );
     649        } else if ( toShow.length ) {
     650            this.tabs.filter(function() {
     651                return $( this ).attr( "tabIndex" ) === 0;
     652            })
     653            .attr( "tabIndex", -1 );
     654        }
     655
     656        toShow.attr( "aria-hidden", "false" );
     657        eventData.newTab.attr({
     658            "aria-selected": "true",
     659            "aria-expanded": "true",
     660            tabIndex: 0
     661        });
     662    },
     663
     664    _activate: function( index ) {
     665        var anchor,
     666            active = this._findActive( index );
     667
     668        // trying to activate the already active panel
     669        if ( active[ 0 ] === this.active[ 0 ] ) {
     670            return;
     671        }
     672
     673        // trying to collapse, simulate a click on the current active header
     674        if ( !active.length ) {
     675            active = this.active;
     676        }
     677
     678        anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
     679        this._eventHandler({
     680            target: anchor,
     681            currentTarget: anchor,
     682            preventDefault: $.noop
     683        });
     684    },
     685
     686    _findActive: function( index ) {
     687        return index === false ? $() : this.tabs.eq( index );
     688    },
     689
     690    _getIndex: function( index ) {
     691        // meta-function to give users option to provide a href string instead of a numerical index.
     692        if ( typeof index === "string" ) {
     693            index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
     694        }
     695
     696        return index;
     697    },
     698
     699    _destroy: function() {
     700        if ( this.xhr ) {
     701            this.xhr.abort();
     702        }
     703
     704        this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
     705
     706        this.tablist
     707            .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
     708            .removeAttr( "role" );
     709
     710        this.anchors
     711            .removeClass( "ui-tabs-anchor" )
     712            .removeAttr( "role" )
     713            .removeAttr( "tabIndex" )
     714            .removeUniqueId();
     715
     716        this.tablist.unbind( this.eventNamespace );
     717
     718        this.tabs.add( this.panels ).each(function() {
     719            if ( $.data( this, "ui-tabs-destroy" ) ) {
     720                $( this ).remove();
     721            } else {
     722                $( this )
     723                    .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
     724                        "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
     725                    .removeAttr( "tabIndex" )
     726                    .removeAttr( "aria-live" )
     727                    .removeAttr( "aria-busy" )
     728                    .removeAttr( "aria-selected" )
     729                    .removeAttr( "aria-labelledby" )
     730                    .removeAttr( "aria-hidden" )
     731                    .removeAttr( "aria-expanded" )
     732                    .removeAttr( "role" );
     733            }
     734        });
     735
     736        this.tabs.each(function() {
     737            var li = $( this ),
     738                prev = li.data( "ui-tabs-aria-controls" );
     739            if ( prev ) {
     740                li
     741                    .attr( "aria-controls", prev )
     742                    .removeData( "ui-tabs-aria-controls" );
     743            } else {
     744                li.removeAttr( "aria-controls" );
     745            }
     746        });
     747
     748        this.panels.show();
     749
     750        if ( this.options.heightStyle !== "content" ) {
     751            this.panels.css( "height", "" );
     752        }
     753    },
     754
     755    enable: function( index ) {
     756        var disabled = this.options.disabled;
     757        if ( disabled === false ) {
     758            return;
     759        }
     760
     761        if ( index === undefined ) {
     762            disabled = false;
     763        } else {
     764            index = this._getIndex( index );
     765            if ( $.isArray( disabled ) ) {
     766                disabled = $.map( disabled, function( num ) {
     767                    return num !== index ? num : null;
     768                });
     769            } else {
     770                disabled = $.map( this.tabs, function( li, num ) {
     771                    return num !== index ? num : null;
     772                });
     773            }
     774        }
     775        this._setupDisabled( disabled );
     776    },
     777
     778    disable: function( index ) {
     779        var disabled = this.options.disabled;
     780        if ( disabled === true ) {
     781            return;
     782        }
     783
     784        if ( index === undefined ) {
     785            disabled = true;
     786        } else {
     787            index = this._getIndex( index );
     788            if ( $.inArray( index, disabled ) !== -1 ) {
     789                return;
     790            }
     791            if ( $.isArray( disabled ) ) {
     792                disabled = $.merge( [ index ], disabled ).sort();
     793            } else {
     794                disabled = [ index ];
     795            }
     796        }
     797        this._setupDisabled( disabled );
     798    },
     799
     800    load: function( index, event ) {
     801        index = this._getIndex( index );
     802        var that = this,
     803            tab = this.tabs.eq( index ),
     804            anchor = tab.find( ".ui-tabs-anchor" ),
     805            panel = this._getPanelForTab( tab ),
     806            eventData = {
     807                tab: tab,
     808                panel: panel
     809            };
     810
     811        // not remote
     812        if ( this._isLocal( anchor[ 0 ] ) ) {
     813            return;
     814        }
     815
     816        this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
     817
     818        // support: jQuery <1.8
     819        // jQuery <1.8 returns false if the request is canceled in beforeSend,
     820        // but as of 1.8, $.ajax() always returns a jqXHR object.
     821        if ( this.xhr && this.xhr.statusText !== "canceled" ) {
     822            tab.addClass( "ui-tabs-loading" );
     823            panel.attr( "aria-busy", "true" );
     824
     825            this.xhr
     826                .success(function( response ) {
     827                    // support: jQuery <1.8
     828                    // http://bugs.jquery.com/ticket/11778
     829                    setTimeout(function() {
     830                        panel.html( response );
     831                        that._trigger( "load", event, eventData );
     832                    }, 1 );
     833                })
     834                .complete(function( jqXHR, status ) {
     835                    // support: jQuery <1.8
     836                    // http://bugs.jquery.com/ticket/11778
     837                    setTimeout(function() {
     838                        if ( status === "abort" ) {
     839                            that.panels.stop( false, true );
     840                        }
     841
     842                        tab.removeClass( "ui-tabs-loading" );
     843                        panel.removeAttr( "aria-busy" );
     844
     845                        if ( jqXHR === that.xhr ) {
     846                            delete that.xhr;
     847                        }
     848                    }, 1 );
     849                });
     850        }
     851    },
     852
     853    _ajaxSettings: function( anchor, event, eventData ) {
     854        var that = this;
     855        return {
     856            url: anchor.attr( "href" ),
     857            beforeSend: function( jqXHR, settings ) {
     858                return that._trigger( "beforeLoad", event,
     859                    $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
     860            }
     861        };
     862    },
     863
     864    _getPanelForTab: function( tab ) {
     865        var id = $( tab ).attr( "aria-controls" );
     866        return this.element.find( this._sanitizeSelector( "#" + id ) );
     867    }
     868});
     869
     870}));
  • trunk/src/wp-includes/js/jquery/ui/tooltip.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(t){function e(e,i){var s=(e.attr("aria-describedby")||"").split(/\s+/);s.push(i),e.data("ui-tooltip-id",i).attr("aria-describedby",t.trim(s.join(" ")))}function i(e){var i=e.data("ui-tooltip-id"),s=(e.attr("aria-describedby")||"").split(/\s+/),n=t.inArray(i,s);-1!==n&&s.splice(n,1),e.removeData("ui-tooltip-id"),s=t.trim(s.join(" ")),s?e.attr("aria-describedby",s):e.removeAttr("aria-describedby")}var s=0;t.widget("ui.tooltip",{version:"1.10.4",options:{content:function(){var e=t(this).attr("title")||"";return t("<a>").text(e).html()},hide:!0,items:"[title]:not([disabled])",position:{my:"left top+15",at:"left bottom",collision:"flipfit flip"},show:!0,tooltipClass:null,track:!1,close:null,open:null},_create:function(){this._on({mouseover:"open",focusin:"open"}),this.tooltips={},this.parents={},this.options.disabled&&this._disable()},_setOption:function(e,i){var s=this;return"disabled"===e?(this[i?"_disable":"_enable"](),this.options[e]=i,void 0):(this._super(e,i),"content"===e&&t.each(this.tooltips,function(t,e){s._updateContent(e)}),void 0)},_disable:function(){var e=this;t.each(this.tooltips,function(i,s){var n=t.Event("blur");n.target=n.currentTarget=s[0],e.close(n,!0)}),this.element.find(this.options.items).addBack().each(function(){var e=t(this);e.is("[title]")&&e.data("ui-tooltip-title",e.attr("title")).attr("title","")})},_enable:function(){this.element.find(this.options.items).addBack().each(function(){var e=t(this);e.data("ui-tooltip-title")&&e.attr("title",e.data("ui-tooltip-title"))})},open:function(e){var i=this,s=t(e?e.target:this.element).closest(this.options.items);s.length&&!s.data("ui-tooltip-id")&&(s.attr("title")&&s.data("ui-tooltip-title",s.attr("title")),s.data("ui-tooltip-open",!0),e&&"mouseover"===e.type&&s.parents().each(function(){var e,s=t(this);s.data("ui-tooltip-open")&&(e=t.Event("blur"),e.target=e.currentTarget=this,i.close(e,!0)),s.attr("title")&&(s.uniqueId(),i.parents[this.id]={element:this,title:s.attr("title")},s.attr("title",""))}),this._updateContent(s,e))},_updateContent:function(t,e){var i,s=this.options.content,n=this,a=e?e.type:null;return"string"==typeof s?this._open(e,t,s):(i=s.call(t[0],function(i){t.data("ui-tooltip-open")&&n._delay(function(){e&&(e.type=a),this._open(e,t,i)})}),i&&this._open(e,t,i),void 0)},_open:function(i,s,n){function a(t){l.of=t,o.is(":hidden")||o.position(l)}var o,r,h,l=t.extend({},this.options.position);if(n){if(o=this._find(s),o.length)return o.find(".ui-tooltip-content").html(n),void 0;s.is("[title]")&&(i&&"mouseover"===i.type?s.attr("title",""):s.removeAttr("title")),o=this._tooltip(s),e(s,o.attr("id")),o.find(".ui-tooltip-content").html(n),this.options.track&&i&&/^mouse/.test(i.type)?(this._on(this.document,{mousemove:a}),a(i)):o.position(t.extend({of:s},this.options.position)),o.hide(),this._show(o,this.options.show),this.options.show&&this.options.show.delay&&(h=this.delayedShow=setInterval(function(){o.is(":visible")&&(a(l.of),clearInterval(h))},t.fx.interval)),this._trigger("open",i,{tooltip:o}),r={keyup:function(e){if(e.keyCode===t.ui.keyCode.ESCAPE){var i=t.Event(e);i.currentTarget=s[0],this.close(i,!0)}},remove:function(){this._removeTooltip(o)}},i&&"mouseover"!==i.type||(r.mouseleave="close"),i&&"focusin"!==i.type||(r.focusout="close"),this._on(!0,s,r)}},close:function(e){var s=this,n=t(e?e.currentTarget:this.element),a=this._find(n);this.closing||(clearInterval(this.delayedShow),n.data("ui-tooltip-title")&&n.attr("title",n.data("ui-tooltip-title")),i(n),a.stop(!0),this._hide(a,this.options.hide,function(){s._removeTooltip(t(this))}),n.removeData("ui-tooltip-open"),this._off(n,"mouseleave focusout keyup"),n[0]!==this.element[0]&&this._off(n,"remove"),this._off(this.document,"mousemove"),e&&"mouseleave"===e.type&&t.each(this.parents,function(e,i){t(i.element).attr("title",i.title),delete s.parents[e]}),this.closing=!0,this._trigger("close",e,{tooltip:a}),this.closing=!1)},_tooltip:function(e){var i="ui-tooltip-"+s++,n=t("<div>").attr({id:i,role:"tooltip"}).addClass("ui-tooltip ui-widget ui-corner-all ui-widget-content "+(this.options.tooltipClass||""));return t("<div>").addClass("ui-tooltip-content").appendTo(n),n.appendTo(this.document[0].body),this.tooltips[i]=e,n},_find:function(e){var i=e.data("ui-tooltip-id");return i?t("#"+i):t()},_removeTooltip:function(t){t.remove(),delete this.tooltips[t.attr("id")]},_destroy:function(){var e=this;t.each(this.tooltips,function(i,s){var n=t.Event("blur");n.target=n.currentTarget=s[0],e.close(n,!0),t("#"+i).remove(),s.data("ui-tooltip-title")&&(s.attr("title",s.data("ui-tooltip-title")),s.removeData("ui-tooltip-title"))})}})})(jQuery);
     1/*!
     2 * jQuery UI Tooltip 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/tooltip/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define([
     16            "jquery",
     17            "./core",
     18            "./widget",
     19            "./position"
     20        ], factory );
     21    } else {
     22
     23        // Browser globals
     24        factory( jQuery );
     25    }
     26}(function( $ ) {
     27
     28return $.widget( "ui.tooltip", {
     29    version: "1.11.1",
     30    options: {
     31        content: function() {
     32            // support: IE<9, Opera in jQuery <1.7
     33            // .text() can't accept undefined, so coerce to a string
     34            var title = $( this ).attr( "title" ) || "";
     35            // Escape title, since we're going from an attribute to raw HTML
     36            return $( "<a>" ).text( title ).html();
     37        },
     38        hide: true,
     39        // Disabled elements have inconsistent behavior across browsers (#8661)
     40        items: "[title]:not([disabled])",
     41        position: {
     42            my: "left top+15",
     43            at: "left bottom",
     44            collision: "flipfit flip"
     45        },
     46        show: true,
     47        tooltipClass: null,
     48        track: false,
     49
     50        // callbacks
     51        close: null,
     52        open: null
     53    },
     54
     55    _addDescribedBy: function( elem, id ) {
     56        var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
     57        describedby.push( id );
     58        elem
     59            .data( "ui-tooltip-id", id )
     60            .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
     61    },
     62
     63    _removeDescribedBy: function( elem ) {
     64        var id = elem.data( "ui-tooltip-id" ),
     65            describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
     66            index = $.inArray( id, describedby );
     67
     68        if ( index !== -1 ) {
     69            describedby.splice( index, 1 );
     70        }
     71
     72        elem.removeData( "ui-tooltip-id" );
     73        describedby = $.trim( describedby.join( " " ) );
     74        if ( describedby ) {
     75            elem.attr( "aria-describedby", describedby );
     76        } else {
     77            elem.removeAttr( "aria-describedby" );
     78        }
     79    },
     80
     81    _create: function() {
     82        this._on({
     83            mouseover: "open",
     84            focusin: "open"
     85        });
     86
     87        // IDs of generated tooltips, needed for destroy
     88        this.tooltips = {};
     89        // IDs of parent tooltips where we removed the title attribute
     90        this.parents = {};
     91
     92        if ( this.options.disabled ) {
     93            this._disable();
     94        }
     95
     96        // Append the aria-live region so tooltips announce correctly
     97        this.liveRegion = $( "<div>" )
     98            .attr({
     99                role: "log",
     100                "aria-live": "assertive",
     101                "aria-relevant": "additions"
     102            })
     103            .addClass( "ui-helper-hidden-accessible" )
     104            .appendTo( this.document[ 0 ].body );
     105    },
     106
     107    _setOption: function( key, value ) {
     108        var that = this;
     109
     110        if ( key === "disabled" ) {
     111            this[ value ? "_disable" : "_enable" ]();
     112            this.options[ key ] = value;
     113            // disable element style changes
     114            return;
     115        }
     116
     117        this._super( key, value );
     118
     119        if ( key === "content" ) {
     120            $.each( this.tooltips, function( id, element ) {
     121                that._updateContent( element );
     122            });
     123        }
     124    },
     125
     126    _disable: function() {
     127        var that = this;
     128
     129        // close open tooltips
     130        $.each( this.tooltips, function( id, element ) {
     131            var event = $.Event( "blur" );
     132            event.target = event.currentTarget = element[0];
     133            that.close( event, true );
     134        });
     135
     136        // remove title attributes to prevent native tooltips
     137        this.element.find( this.options.items ).addBack().each(function() {
     138            var element = $( this );
     139            if ( element.is( "[title]" ) ) {
     140                element
     141                    .data( "ui-tooltip-title", element.attr( "title" ) )
     142                    .removeAttr( "title" );
     143            }
     144        });
     145    },
     146
     147    _enable: function() {
     148        // restore title attributes
     149        this.element.find( this.options.items ).addBack().each(function() {
     150            var element = $( this );
     151            if ( element.data( "ui-tooltip-title" ) ) {
     152                element.attr( "title", element.data( "ui-tooltip-title" ) );
     153            }
     154        });
     155    },
     156
     157    open: function( event ) {
     158        var that = this,
     159            target = $( event ? event.target : this.element )
     160                // we need closest here due to mouseover bubbling,
     161                // but always pointing at the same event target
     162                .closest( this.options.items );
     163
     164        // No element to show a tooltip for or the tooltip is already open
     165        if ( !target.length || target.data( "ui-tooltip-id" ) ) {
     166            return;
     167        }
     168
     169        if ( target.attr( "title" ) ) {
     170            target.data( "ui-tooltip-title", target.attr( "title" ) );
     171        }
     172
     173        target.data( "ui-tooltip-open", true );
     174
     175        // kill parent tooltips, custom or native, for hover
     176        if ( event && event.type === "mouseover" ) {
     177            target.parents().each(function() {
     178                var parent = $( this ),
     179                    blurEvent;
     180                if ( parent.data( "ui-tooltip-open" ) ) {
     181                    blurEvent = $.Event( "blur" );
     182                    blurEvent.target = blurEvent.currentTarget = this;
     183                    that.close( blurEvent, true );
     184                }
     185                if ( parent.attr( "title" ) ) {
     186                    parent.uniqueId();
     187                    that.parents[ this.id ] = {
     188                        element: this,
     189                        title: parent.attr( "title" )
     190                    };
     191                    parent.attr( "title", "" );
     192                }
     193            });
     194        }
     195
     196        this._updateContent( target, event );
     197    },
     198
     199    _updateContent: function( target, event ) {
     200        var content,
     201            contentOption = this.options.content,
     202            that = this,
     203            eventType = event ? event.type : null;
     204
     205        if ( typeof contentOption === "string" ) {
     206            return this._open( event, target, contentOption );
     207        }
     208
     209        content = contentOption.call( target[0], function( response ) {
     210            // ignore async response if tooltip was closed already
     211            if ( !target.data( "ui-tooltip-open" ) ) {
     212                return;
     213            }
     214            // IE may instantly serve a cached response for ajax requests
     215            // delay this call to _open so the other call to _open runs first
     216            that._delay(function() {
     217                // jQuery creates a special event for focusin when it doesn't
     218                // exist natively. To improve performance, the native event
     219                // object is reused and the type is changed. Therefore, we can't
     220                // rely on the type being correct after the event finished
     221                // bubbling, so we set it back to the previous value. (#8740)
     222                if ( event ) {
     223                    event.type = eventType;
     224                }
     225                this._open( event, target, response );
     226            });
     227        });
     228        if ( content ) {
     229            this._open( event, target, content );
     230        }
     231    },
     232
     233    _open: function( event, target, content ) {
     234        var tooltip, events, delayedShow, a11yContent,
     235            positionOption = $.extend( {}, this.options.position );
     236
     237        if ( !content ) {
     238            return;
     239        }
     240
     241        // Content can be updated multiple times. If the tooltip already
     242        // exists, then just update the content and bail.
     243        tooltip = this._find( target );
     244        if ( tooltip.length ) {
     245            tooltip.find( ".ui-tooltip-content" ).html( content );
     246            return;
     247        }
     248
     249        // if we have a title, clear it to prevent the native tooltip
     250        // we have to check first to avoid defining a title if none exists
     251        // (we don't want to cause an element to start matching [title])
     252        //
     253        // We use removeAttr only for key events, to allow IE to export the correct
     254        // accessible attributes. For mouse events, set to empty string to avoid
     255        // native tooltip showing up (happens only when removing inside mouseover).
     256        if ( target.is( "[title]" ) ) {
     257            if ( event && event.type === "mouseover" ) {
     258                target.attr( "title", "" );
     259            } else {
     260                target.removeAttr( "title" );
     261            }
     262        }
     263
     264        tooltip = this._tooltip( target );
     265        this._addDescribedBy( target, tooltip.attr( "id" ) );
     266        tooltip.find( ".ui-tooltip-content" ).html( content );
     267
     268        // Support: Voiceover on OS X, JAWS on IE <= 9
     269        // JAWS announces deletions even when aria-relevant="additions"
     270        // Voiceover will sometimes re-read the entire log region's contents from the beginning
     271        this.liveRegion.children().hide();
     272        if ( content.clone ) {
     273            a11yContent = content.clone();
     274            a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" );
     275        } else {
     276            a11yContent = content;
     277        }
     278        $( "<div>" ).html( a11yContent ).appendTo( this.liveRegion );
     279
     280        function position( event ) {
     281            positionOption.of = event;
     282            if ( tooltip.is( ":hidden" ) ) {
     283                return;
     284            }
     285            tooltip.position( positionOption );
     286        }
     287        if ( this.options.track && event && /^mouse/.test( event.type ) ) {
     288            this._on( this.document, {
     289                mousemove: position
     290            });
     291            // trigger once to override element-relative positioning
     292            position( event );
     293        } else {
     294            tooltip.position( $.extend({
     295                of: target
     296            }, this.options.position ) );
     297        }
     298
     299        this.hiding = false;
     300        this.closing = false;
     301        tooltip.hide();
     302
     303        this._show( tooltip, this.options.show );
     304        // Handle tracking tooltips that are shown with a delay (#8644). As soon
     305        // as the tooltip is visible, position the tooltip using the most recent
     306        // event.
     307        if ( this.options.show && this.options.show.delay ) {
     308            delayedShow = this.delayedShow = setInterval(function() {
     309                if ( tooltip.is( ":visible" ) ) {
     310                    position( positionOption.of );
     311                    clearInterval( delayedShow );
     312                }
     313            }, $.fx.interval );
     314        }
     315
     316        this._trigger( "open", event, { tooltip: tooltip } );
     317
     318        events = {
     319            keyup: function( event ) {
     320                if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
     321                    var fakeEvent = $.Event(event);
     322                    fakeEvent.currentTarget = target[0];
     323                    this.close( fakeEvent, true );
     324                }
     325            }
     326        };
     327
     328        // Only bind remove handler for delegated targets. Non-delegated
     329        // tooltips will handle this in destroy.
     330        if ( target[ 0 ] !== this.element[ 0 ] ) {
     331            events.remove = function() {
     332                this._removeTooltip( tooltip );
     333            };
     334        }
     335
     336        if ( !event || event.type === "mouseover" ) {
     337            events.mouseleave = "close";
     338        }
     339        if ( !event || event.type === "focusin" ) {
     340            events.focusout = "close";
     341        }
     342        this._on( true, target, events );
     343    },
     344
     345    close: function( event ) {
     346        var that = this,
     347            target = $( event ? event.currentTarget : this.element ),
     348            tooltip = this._find( target );
     349
     350        // disabling closes the tooltip, so we need to track when we're closing
     351        // to avoid an infinite loop in case the tooltip becomes disabled on close
     352        if ( this.closing ) {
     353            return;
     354        }
     355
     356        // Clear the interval for delayed tracking tooltips
     357        clearInterval( this.delayedShow );
     358
     359        // only set title if we had one before (see comment in _open())
     360        // If the title attribute has changed since open(), don't restore
     361        if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) {
     362            target.attr( "title", target.data( "ui-tooltip-title" ) );
     363        }
     364
     365        this._removeDescribedBy( target );
     366
     367        this.hiding = true;
     368        tooltip.stop( true );
     369        this._hide( tooltip, this.options.hide, function() {
     370            that._removeTooltip( $( this ) );
     371            this.hiding = false;
     372            this.closing = false;
     373        });
     374
     375        target.removeData( "ui-tooltip-open" );
     376        this._off( target, "mouseleave focusout keyup" );
     377
     378        // Remove 'remove' binding only on delegated targets
     379        if ( target[ 0 ] !== this.element[ 0 ] ) {
     380            this._off( target, "remove" );
     381        }
     382        this._off( this.document, "mousemove" );
     383
     384        if ( event && event.type === "mouseleave" ) {
     385            $.each( this.parents, function( id, parent ) {
     386                $( parent.element ).attr( "title", parent.title );
     387                delete that.parents[ id ];
     388            });
     389        }
     390
     391        this.closing = true;
     392        this._trigger( "close", event, { tooltip: tooltip } );
     393        if ( !this.hiding ) {
     394            this.closing = false;
     395        }
     396    },
     397
     398    _tooltip: function( element ) {
     399        var tooltip = $( "<div>" )
     400                .attr( "role", "tooltip" )
     401                .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
     402                    ( this.options.tooltipClass || "" ) ),
     403            id = tooltip.uniqueId().attr( "id" );
     404
     405        $( "<div>" )
     406            .addClass( "ui-tooltip-content" )
     407            .appendTo( tooltip );
     408
     409        tooltip.appendTo( this.document[0].body );
     410        this.tooltips[ id ] = element;
     411        return tooltip;
     412    },
     413
     414    _find: function( target ) {
     415        var id = target.data( "ui-tooltip-id" );
     416        return id ? $( "#" + id ) : $();
     417    },
     418
     419    _removeTooltip: function( tooltip ) {
     420        tooltip.remove();
     421        delete this.tooltips[ tooltip.attr( "id" ) ];
     422    },
     423
     424    _destroy: function() {
     425        var that = this;
     426
     427        // close open tooltips
     428        $.each( this.tooltips, function( id, element ) {
     429            // Delegate to close method to handle common cleanup
     430            var event = $.Event( "blur" );
     431            event.target = event.currentTarget = element[0];
     432            that.close( event, true );
     433
     434            // Remove immediately; destroying an open tooltip doesn't use the
     435            // hide animation
     436            $( "#" + id ).remove();
     437
     438            // Restore the title
     439            if ( element.data( "ui-tooltip-title" ) ) {
     440                // If the title attribute has changed since open(), don't restore
     441                if ( !element.attr( "title" ) ) {
     442                    element.attr( "title", element.data( "ui-tooltip-title" ) );
     443                }
     444                element.removeData( "ui-tooltip-title" );
     445            }
     446        });
     447        this.liveRegion.remove();
     448    }
     449});
     450
     451}));
  • trunk/src/wp-includes/js/jquery/ui/widget.js

    r29846 r29847  
    1 /*! jQuery UI - v1.10.4 - 2014-01-17
    2 * http://jqueryui.com
    3 * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
    4 (function(e,t){var i=0,s=Array.prototype.slice,n=e.cleanData;e.cleanData=function(t){for(var i,s=0;null!=(i=t[s]);s++)try{e(i).triggerHandler("remove")}catch(a){}n(t)},e.widget=function(i,s,n){var a,r,o,h,l={},u=i.split(".")[0];i=i.split(".")[1],a=u+"-"+i,n||(n=s,s=e.Widget),e.expr[":"][a.toLowerCase()]=function(t){return!!e.data(t,a)},e[u]=e[u]||{},r=e[u][i],o=e[u][i]=function(e,i){return this._createWidget?(arguments.length&&this._createWidget(e,i),t):new o(e,i)},e.extend(o,r,{version:n.version,_proto:e.extend({},n),_childConstructors:[]}),h=new s,h.options=e.widget.extend({},h.options),e.each(n,function(i,n){return e.isFunction(n)?(l[i]=function(){var e=function(){return s.prototype[i].apply(this,arguments)},t=function(e){return s.prototype[i].apply(this,e)};return function(){var i,s=this._super,a=this._superApply;return this._super=e,this._superApply=t,i=n.apply(this,arguments),this._super=s,this._superApply=a,i}}(),t):(l[i]=n,t)}),o.prototype=e.widget.extend(h,{widgetEventPrefix:r?h.widgetEventPrefix||i:i},l,{constructor:o,namespace:u,widgetName:i,widgetFullName:a}),r?(e.each(r._childConstructors,function(t,i){var s=i.prototype;e.widget(s.namespace+"."+s.widgetName,o,i._proto)}),delete r._childConstructors):s._childConstructors.push(o),e.widget.bridge(i,o)},e.widget.extend=function(i){for(var n,a,r=s.call(arguments,1),o=0,h=r.length;h>o;o++)for(n in r[o])a=r[o][n],r[o].hasOwnProperty(n)&&a!==t&&(i[n]=e.isPlainObject(a)?e.isPlainObject(i[n])?e.widget.extend({},i[n],a):e.widget.extend({},a):a);return i},e.widget.bridge=function(i,n){var a=n.prototype.widgetFullName||i;e.fn[i]=function(r){var o="string"==typeof r,h=s.call(arguments,1),l=this;return r=!o&&h.length?e.widget.extend.apply(null,[r].concat(h)):r,o?this.each(function(){var s,n=e.data(this,a);return n?e.isFunction(n[r])&&"_"!==r.charAt(0)?(s=n[r].apply(n,h),s!==n&&s!==t?(l=s&&s.jquery?l.pushStack(s.get()):s,!1):t):e.error("no such method '"+r+"' for "+i+" widget instance"):e.error("cannot call methods on "+i+" prior to initialization; "+"attempted to call method '"+r+"'")}):this.each(function(){var t=e.data(this,a);t?t.option(r||{})._init():e.data(this,a,new n(r,this))}),l}},e.Widget=function(){},e.Widget._childConstructors=[],e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(t,s){s=e(s||this.defaultElement||this)[0],this.element=e(s),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this.bindings=e(),this.hoverable=e(),this.focusable=e(),s!==this&&(e.data(s,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===s&&this.destroy()}}),this.document=e(s.style?s.ownerDocument:s.document||s),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(i,s){var n,a,r,o=i;if(0===arguments.length)return e.widget.extend({},this.options);if("string"==typeof i)if(o={},n=i.split("."),i=n.shift(),n.length){for(a=o[i]=e.widget.extend({},this.options[i]),r=0;n.length-1>r;r++)a[n[r]]=a[n[r]]||{},a=a[n[r]];if(i=n.pop(),1===arguments.length)return a[i]===t?null:a[i];a[i]=s}else{if(1===arguments.length)return this.options[i]===t?null:this.options[i];o[i]=s}return this._setOptions(o),this},_setOptions:function(e){var t;for(t in e)this._setOption(t,e[t]);return this},_setOption:function(e,t){return this.options[e]=t,"disabled"===e&&(this.widget().toggleClass(this.widgetFullName+"-disabled ui-state-disabled",!!t).attr("aria-disabled",t),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")),this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_on:function(i,s,n){var a,r=this;"boolean"!=typeof i&&(n=s,s=i,i=!1),n?(s=a=e(s),this.bindings=this.bindings.add(s)):(n=s,s=this.element,a=this.widget()),e.each(n,function(n,o){function h(){return i||r.options.disabled!==!0&&!e(this).hasClass("ui-state-disabled")?("string"==typeof o?r[o]:o).apply(r,arguments):t}"string"!=typeof o&&(h.guid=o.guid=o.guid||h.guid||e.guid++);var l=n.match(/^(\w+)\s*(.*)$/),u=l[1]+r.eventNamespace,c=l[2];c?a.delegate(c,u,h):s.bind(u,h)})},_off:function(e,t){t=(t||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.unbind(t).undelegate(t)},_delay:function(e,t){function i(){return("string"==typeof e?s[e]:e).apply(s,arguments)}var s=this;return setTimeout(i,t||0)},_hoverable:function(t){this.hoverable=this.hoverable.add(t),this._on(t,{mouseenter:function(t){e(t.currentTarget).addClass("ui-state-hover")},mouseleave:function(t){e(t.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(t){this.focusable=this.focusable.add(t),this._on(t,{focusin:function(t){e(t.currentTarget).addClass("ui-state-focus")},focusout:function(t){e(t.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(t,i,s){var n,a,r=this.options[t];if(s=s||{},i=e.Event(i),i.type=(t===this.widgetEventPrefix?t:this.widgetEventPrefix+t).toLowerCase(),i.target=this.element[0],a=i.originalEvent)for(n in a)n in i||(i[n]=a[n]);return this.element.trigger(i,s),!(e.isFunction(r)&&r.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},e.each({show:"fadeIn",hide:"fadeOut"},function(t,i){e.Widget.prototype["_"+t]=function(s,n,a){"string"==typeof n&&(n={effect:n});var r,o=n?n===!0||"number"==typeof n?i:n.effect||i:t;n=n||{},"number"==typeof n&&(n={duration:n}),r=!e.isEmptyObject(n),n.complete=a,n.delay&&s.delay(n.delay),r&&e.effects&&e.effects.effect[o]?s[t](n):o!==t&&s[o]?s[o](n.duration,n.easing,a):s.queue(function(i){e(this)[t](),a&&a.call(s[0]),i()})}})})(jQuery);
     1/*!
     2 * jQuery UI Widget 1.11.1
     3 * http://jqueryui.com
     4 *
     5 * Copyright 2014 jQuery Foundation and other contributors
     6 * Released under the MIT license.
     7 * http://jquery.org/license
     8 *
     9 * http://api.jqueryui.com/jQuery.widget/
     10 */
     11(function( factory ) {
     12    if ( typeof define === "function" && define.amd ) {
     13
     14        // AMD. Register as an anonymous module.
     15        define( [ "jquery" ], factory );
     16    } else {
     17
     18        // Browser globals
     19        factory( jQuery );
     20    }
     21}(function( $ ) {
     22
     23var widget_uuid = 0,
     24    widget_slice = Array.prototype.slice;
     25
     26$.cleanData = (function( orig ) {
     27    return function( elems ) {
     28        var events, elem, i;
     29        for ( i = 0; (elem = elems[i]) != null; i++ ) {
     30            try {
     31
     32                // Only trigger remove when necessary to save time
     33                events = $._data( elem, "events" );
     34                if ( events && events.remove ) {
     35                    $( elem ).triggerHandler( "remove" );
     36                }
     37
     38            // http://bugs.jquery.com/ticket/8235
     39            } catch( e ) {}
     40        }
     41        orig( elems );
     42    };
     43})( $.cleanData );
     44
     45$.widget = function( name, base, prototype ) {
     46    var fullName, existingConstructor, constructor, basePrototype,
     47        // proxiedPrototype allows the provided prototype to remain unmodified
     48        // so that it can be used as a mixin for multiple widgets (#8876)
     49        proxiedPrototype = {},
     50        namespace = name.split( "." )[ 0 ];
     51
     52    name = name.split( "." )[ 1 ];
     53    fullName = namespace + "-" + name;
     54
     55    if ( !prototype ) {
     56        prototype = base;
     57        base = $.Widget;
     58    }
     59
     60    // create selector for plugin
     61    $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
     62        return !!$.data( elem, fullName );
     63    };
     64
     65    $[ namespace ] = $[ namespace ] || {};
     66    existingConstructor = $[ namespace ][ name ];
     67    constructor = $[ namespace ][ name ] = function( options, element ) {
     68        // allow instantiation without "new" keyword
     69        if ( !this._createWidget ) {
     70            return new constructor( options, element );
     71        }
     72
     73        // allow instantiation without initializing for simple inheritance
     74        // must use "new" keyword (the code above always passes args)
     75        if ( arguments.length ) {
     76            this._createWidget( options, element );
     77        }
     78    };
     79    // extend with the existing constructor to carry over any static properties
     80    $.extend( constructor, existingConstructor, {
     81        version: prototype.version,
     82        // copy the object used to create the prototype in case we need to
     83        // redefine the widget later
     84        _proto: $.extend( {}, prototype ),
     85        // track widgets that inherit from this widget in case this widget is
     86        // redefined after a widget inherits from it
     87        _childConstructors: []
     88    });
     89
     90    basePrototype = new base();
     91    // we need to make the options hash a property directly on the new instance
     92    // otherwise we'll modify the options hash on the prototype that we're
     93    // inheriting from
     94    basePrototype.options = $.widget.extend( {}, basePrototype.options );
     95    $.each( prototype, function( prop, value ) {
     96        if ( !$.isFunction( value ) ) {
     97            proxiedPrototype[ prop ] = value;
     98            return;
     99        }
     100        proxiedPrototype[ prop ] = (function() {
     101            var _super = function() {
     102                    return base.prototype[ prop ].apply( this, arguments );
     103                },
     104                _superApply = function( args ) {
     105                    return base.prototype[ prop ].apply( this, args );
     106                };
     107            return function() {
     108                var __super = this._super,
     109                    __superApply = this._superApply,
     110                    returnValue;
     111
     112                this._super = _super;
     113                this._superApply = _superApply;
     114
     115                returnValue = value.apply( this, arguments );
     116
     117                this._super = __super;
     118                this._superApply = __superApply;
     119
     120                return returnValue;
     121            };
     122        })();
     123    });
     124    constructor.prototype = $.widget.extend( basePrototype, {
     125        // TODO: remove support for widgetEventPrefix
     126        // always use the name + a colon as the prefix, e.g., draggable:start
     127        // don't prefix for widgets that aren't DOM-based
     128        widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
     129    }, proxiedPrototype, {
     130        constructor: constructor,
     131        namespace: namespace,
     132        widgetName: name,
     133        widgetFullName: fullName
     134    });
     135
     136    // If this widget is being redefined then we need to find all widgets that
     137    // are inheriting from it and redefine all of them so that they inherit from
     138    // the new version of this widget. We're essentially trying to replace one
     139    // level in the prototype chain.
     140    if ( existingConstructor ) {
     141        $.each( existingConstructor._childConstructors, function( i, child ) {
     142            var childPrototype = child.prototype;
     143
     144            // redefine the child widget using the same prototype that was
     145            // originally used, but inherit from the new version of the base
     146            $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
     147        });
     148        // remove the list of existing child constructors from the old constructor
     149        // so the old child constructors can be garbage collected
     150        delete existingConstructor._childConstructors;
     151    } else {
     152        base._childConstructors.push( constructor );
     153    }
     154
     155    $.widget.bridge( name, constructor );
     156
     157    return constructor;
     158};
     159
     160$.widget.extend = function( target ) {
     161    var input = widget_slice.call( arguments, 1 ),
     162        inputIndex = 0,
     163        inputLength = input.length,
     164        key,
     165        value;
     166    for ( ; inputIndex < inputLength; inputIndex++ ) {
     167        for ( key in input[ inputIndex ] ) {
     168            value = input[ inputIndex ][ key ];
     169            if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
     170                // Clone objects
     171                if ( $.isPlainObject( value ) ) {
     172                    target[ key ] = $.isPlainObject( target[ key ] ) ?
     173                        $.widget.extend( {}, target[ key ], value ) :
     174                        // Don't extend strings, arrays, etc. with objects
     175                        $.widget.extend( {}, value );
     176                // Copy everything else by reference
     177                } else {
     178                    target[ key ] = value;
     179                }
     180            }
     181        }
     182    }
     183    return target;
     184};
     185
     186$.widget.bridge = function( name, object ) {
     187    var fullName = object.prototype.widgetFullName || name;
     188    $.fn[ name ] = function( options ) {
     189        var isMethodCall = typeof options === "string",
     190            args = widget_slice.call( arguments, 1 ),
     191            returnValue = this;
     192
     193        // allow multiple hashes to be passed on init
     194        options = !isMethodCall && args.length ?
     195            $.widget.extend.apply( null, [ options ].concat(args) ) :
     196            options;
     197
     198        if ( isMethodCall ) {
     199            this.each(function() {
     200                var methodValue,
     201                    instance = $.data( this, fullName );
     202                if ( options === "instance" ) {
     203                    returnValue = instance;
     204                    return false;
     205                }
     206                if ( !instance ) {
     207                    return $.error( "cannot call methods on " + name + " prior to initialization; " +
     208                        "attempted to call method '" + options + "'" );
     209                }
     210                if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
     211                    return $.error( "no such method '" + options + "' for " + name + " widget instance" );
     212                }
     213                methodValue = instance[ options ].apply( instance, args );
     214                if ( methodValue !== instance && methodValue !== undefined ) {
     215                    returnValue = methodValue && methodValue.jquery ?
     216                        returnValue.pushStack( methodValue.get() ) :
     217                        methodValue;
     218                    return false;
     219                }
     220            });
     221        } else {
     222            this.each(function() {
     223                var instance = $.data( this, fullName );
     224                if ( instance ) {
     225                    instance.option( options || {} );
     226                    if ( instance._init ) {
     227                        instance._init();
     228                    }
     229                } else {
     230                    $.data( this, fullName, new object( options, this ) );
     231                }
     232            });
     233        }
     234
     235        return returnValue;
     236    };
     237};
     238
     239$.Widget = function( /* options, element */ ) {};
     240$.Widget._childConstructors = [];
     241
     242$.Widget.prototype = {
     243    widgetName: "widget",
     244    widgetEventPrefix: "",
     245    defaultElement: "<div>",
     246    options: {
     247        disabled: false,
     248
     249        // callbacks
     250        create: null
     251    },
     252    _createWidget: function( options, element ) {
     253        element = $( element || this.defaultElement || this )[ 0 ];
     254        this.element = $( element );
     255        this.uuid = widget_uuid++;
     256        this.eventNamespace = "." + this.widgetName + this.uuid;
     257        this.options = $.widget.extend( {},
     258            this.options,
     259            this._getCreateOptions(),
     260            options );
     261
     262        this.bindings = $();
     263        this.hoverable = $();
     264        this.focusable = $();
     265
     266        if ( element !== this ) {
     267            $.data( element, this.widgetFullName, this );
     268            this._on( true, this.element, {
     269                remove: function( event ) {
     270                    if ( event.target === element ) {
     271                        this.destroy();
     272                    }
     273                }
     274            });
     275            this.document = $( element.style ?
     276                // element within the document
     277                element.ownerDocument :
     278                // element is window or document
     279                element.document || element );
     280            this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
     281        }
     282
     283        this._create();
     284        this._trigger( "create", null, this._getCreateEventData() );
     285        this._init();
     286    },
     287    _getCreateOptions: $.noop,
     288    _getCreateEventData: $.noop,
     289    _create: $.noop,
     290    _init: $.noop,
     291
     292    destroy: function() {
     293        this._destroy();
     294        // we can probably remove the unbind calls in 2.0
     295        // all event bindings should go through this._on()
     296        this.element
     297            .unbind( this.eventNamespace )
     298            .removeData( this.widgetFullName )
     299            // support: jquery <1.6.3
     300            // http://bugs.jquery.com/ticket/9413
     301            .removeData( $.camelCase( this.widgetFullName ) );
     302        this.widget()
     303            .unbind( this.eventNamespace )
     304            .removeAttr( "aria-disabled" )
     305            .removeClass(
     306                this.widgetFullName + "-disabled " +
     307                "ui-state-disabled" );
     308
     309        // clean up events and states
     310        this.bindings.unbind( this.eventNamespace );
     311        this.hoverable.removeClass( "ui-state-hover" );
     312        this.focusable.removeClass( "ui-state-focus" );
     313    },
     314    _destroy: $.noop,
     315
     316    widget: function() {
     317        return this.element;
     318    },
     319
     320    option: function( key, value ) {
     321        var options = key,
     322            parts,
     323            curOption,
     324            i;
     325
     326        if ( arguments.length === 0 ) {
     327            // don't return a reference to the internal hash
     328            return $.widget.extend( {}, this.options );
     329        }
     330
     331        if ( typeof key === "string" ) {
     332            // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
     333            options = {};
     334            parts = key.split( "." );
     335            key = parts.shift();
     336            if ( parts.length ) {
     337                curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
     338                for ( i = 0; i < parts.length - 1; i++ ) {
     339                    curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
     340                    curOption = curOption[ parts[ i ] ];
     341                }
     342                key = parts.pop();
     343                if ( arguments.length === 1 ) {
     344                    return curOption[ key ] === undefined ? null : curOption[ key ];
     345                }
     346                curOption[ key ] = value;
     347            } else {
     348                if ( arguments.length === 1 ) {
     349                    return this.options[ key ] === undefined ? null : this.options[ key ];
     350                }
     351                options[ key ] = value;
     352            }
     353        }
     354
     355        this._setOptions( options );
     356
     357        return this;
     358    },
     359    _setOptions: function( options ) {
     360        var key;
     361
     362        for ( key in options ) {
     363            this._setOption( key, options[ key ] );
     364        }
     365
     366        return this;
     367    },
     368    _setOption: function( key, value ) {
     369        this.options[ key ] = value;
     370
     371        if ( key === "disabled" ) {
     372            this.widget()
     373                .toggleClass( this.widgetFullName + "-disabled", !!value );
     374
     375            // If the widget is becoming disabled, then nothing is interactive
     376            if ( value ) {
     377                this.hoverable.removeClass( "ui-state-hover" );
     378                this.focusable.removeClass( "ui-state-focus" );
     379            }
     380        }
     381
     382        return this;
     383    },
     384
     385    enable: function() {
     386        return this._setOptions({ disabled: false });
     387    },
     388    disable: function() {
     389        return this._setOptions({ disabled: true });
     390    },
     391
     392    _on: function( suppressDisabledCheck, element, handlers ) {
     393        var delegateElement,
     394            instance = this;
     395
     396        // no suppressDisabledCheck flag, shuffle arguments
     397        if ( typeof suppressDisabledCheck !== "boolean" ) {
     398            handlers = element;
     399            element = suppressDisabledCheck;
     400            suppressDisabledCheck = false;
     401        }
     402
     403        // no element argument, shuffle and use this.element
     404        if ( !handlers ) {
     405            handlers = element;
     406            element = this.element;
     407            delegateElement = this.widget();
     408        } else {
     409            element = delegateElement = $( element );
     410            this.bindings = this.bindings.add( element );
     411        }
     412
     413        $.each( handlers, function( event, handler ) {
     414            function handlerProxy() {
     415                // allow widgets to customize the disabled handling
     416                // - disabled as an array instead of boolean
     417                // - disabled class as method for disabling individual parts
     418                if ( !suppressDisabledCheck &&
     419                        ( instance.options.disabled === true ||
     420                            $( this ).hasClass( "ui-state-disabled" ) ) ) {
     421                    return;
     422                }
     423                return ( typeof handler === "string" ? instance[ handler ] : handler )
     424                    .apply( instance, arguments );
     425            }
     426
     427            // copy the guid so direct unbinding works
     428            if ( typeof handler !== "string" ) {
     429                handlerProxy.guid = handler.guid =
     430                    handler.guid || handlerProxy.guid || $.guid++;
     431            }
     432
     433            var match = event.match( /^([\w:-]*)\s*(.*)$/ ),
     434                eventName = match[1] + instance.eventNamespace,
     435                selector = match[2];
     436            if ( selector ) {
     437                delegateElement.delegate( selector, eventName, handlerProxy );
     438            } else {
     439                element.bind( eventName, handlerProxy );
     440            }
     441        });
     442    },
     443
     444    _off: function( element, eventName ) {
     445        eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
     446        element.unbind( eventName ).undelegate( eventName );
     447    },
     448
     449    _delay: function( handler, delay ) {
     450        function handlerProxy() {
     451            return ( typeof handler === "string" ? instance[ handler ] : handler )
     452                .apply( instance, arguments );
     453        }
     454        var instance = this;
     455        return setTimeout( handlerProxy, delay || 0 );
     456    },
     457
     458    _hoverable: function( element ) {
     459        this.hoverable = this.hoverable.add( element );
     460        this._on( element, {
     461            mouseenter: function( event ) {
     462                $( event.currentTarget ).addClass( "ui-state-hover" );
     463            },
     464            mouseleave: function( event ) {
     465                $( event.currentTarget ).removeClass( "ui-state-hover" );
     466            }
     467        });
     468    },
     469
     470    _focusable: function( element ) {
     471        this.focusable = this.focusable.add( element );
     472        this._on( element, {
     473            focusin: function( event ) {
     474                $( event.currentTarget ).addClass( "ui-state-focus" );
     475            },
     476            focusout: function( event ) {
     477                $( event.currentTarget ).removeClass( "ui-state-focus" );
     478            }
     479        });
     480    },
     481
     482    _trigger: function( type, event, data ) {
     483        var prop, orig,
     484            callback = this.options[ type ];
     485
     486        data = data || {};
     487        event = $.Event( event );
     488        event.type = ( type === this.widgetEventPrefix ?
     489            type :
     490            this.widgetEventPrefix + type ).toLowerCase();
     491        // the original event may come from any element
     492        // so we need to reset the target on the new event
     493        event.target = this.element[ 0 ];
     494
     495        // copy original event properties over to the new event
     496        orig = event.originalEvent;
     497        if ( orig ) {
     498            for ( prop in orig ) {
     499                if ( !( prop in event ) ) {
     500                    event[ prop ] = orig[ prop ];
     501                }
     502            }
     503        }
     504
     505        this.element.trigger( event, data );
     506        return !( $.isFunction( callback ) &&
     507            callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
     508            event.isDefaultPrevented() );
     509    }
     510};
     511
     512$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
     513    $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
     514        if ( typeof options === "string" ) {
     515            options = { effect: options };
     516        }
     517        var hasOptions,
     518            effectName = !options ?
     519                method :
     520                options === true || typeof options === "number" ?
     521                    defaultEffect :
     522                    options.effect || defaultEffect;
     523        options = options || {};
     524        if ( typeof options === "number" ) {
     525            options = { duration: options };
     526        }
     527        hasOptions = !$.isEmptyObject( options );
     528        options.complete = callback;
     529        if ( options.delay ) {
     530            element.delay( options.delay );
     531        }
     532        if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
     533            element[ method ]( options );
     534        } else if ( effectName !== method && element[ effectName ] ) {
     535            element[ effectName ]( options.duration, options.easing, callback );
     536        } else {
     537            element.queue(function( next ) {
     538                $( this )[ method ]();
     539                if ( callback ) {
     540                    callback.call( element[ 0 ] );
     541                }
     542                next();
     543            });
     544        }
     545    };
     546});
     547
     548return $.widget;
     549
     550}));
  • trunk/src/wp-includes/script-loader.php

    r29769 r29847  
    166166
    167167    // full jQuery UI
    168     $scripts->add( 'jquery-ui-core', '/wp-includes/js/jquery/ui/jquery.ui.core.min.js', array('jquery'), '1.10.4', 1 );
    169     $scripts->add( 'jquery-effects-core', '/wp-includes/js/jquery/ui/jquery.ui.effect.min.js', array('jquery'), '1.10.4', 1 );
    170 
    171     $scripts->add( 'jquery-effects-blind', '/wp-includes/js/jquery/ui/jquery.ui.effect-blind.min.js', array('jquery-effects-core'), '1.10.4', 1 );
    172     $scripts->add( 'jquery-effects-bounce', '/wp-includes/js/jquery/ui/jquery.ui.effect-bounce.min.js', array('jquery-effects-core'), '1.10.4', 1 );
    173     $scripts->add( 'jquery-effects-clip', '/wp-includes/js/jquery/ui/jquery.ui.effect-clip.min.js', array('jquery-effects-core'), '1.10.4', 1 );
    174     $scripts->add( 'jquery-effects-drop', '/wp-includes/js/jquery/ui/jquery.ui.effect-drop.min.js', array('jquery-effects-core'), '1.10.4', 1 );
    175     $scripts->add( 'jquery-effects-explode', '/wp-includes/js/jquery/ui/jquery.ui.effect-explode.min.js', array('jquery-effects-core'), '1.10.4', 1 );
    176     $scripts->add( 'jquery-effects-fade', '/wp-includes/js/jquery/ui/jquery.ui.effect-fade.min.js', array('jquery-effects-core'), '1.10.4', 1 );
    177     $scripts->add( 'jquery-effects-fold', '/wp-includes/js/jquery/ui/jquery.ui.effect-fold.min.js', array('jquery-effects-core'), '1.10.4', 1 );
    178     $scripts->add( 'jquery-effects-highlight', '/wp-includes/js/jquery/ui/jquery.ui.effect-highlight.min.js', array('jquery-effects-core'), '1.10.4', 1 );
    179     $scripts->add( 'jquery-effects-pulsate', '/wp-includes/js/jquery/ui/jquery.ui.effect-pulsate.min.js', array('jquery-effects-core'), '1.10.4', 1 );
    180     $scripts->add( 'jquery-effects-scale', '/wp-includes/js/jquery/ui/jquery.ui.effect-scale.min.js', array('jquery-effects-core'), '1.10.4', 1 );
    181     $scripts->add( 'jquery-effects-shake', '/wp-includes/js/jquery/ui/jquery.ui.effect-shake.min.js', array('jquery-effects-core'), '1.10.4', 1 );
    182     $scripts->add( 'jquery-effects-slide', '/wp-includes/js/jquery/ui/jquery.ui.effect-slide.min.js', array('jquery-effects-core'), '1.10.4', 1 );
    183     $scripts->add( 'jquery-effects-transfer', '/wp-includes/js/jquery/ui/jquery.ui.effect-transfer.min.js', array('jquery-effects-core'), '1.10.4', 1 );
    184 
    185     $scripts->add( 'jquery-ui-accordion', '/wp-includes/js/jquery/ui/jquery.ui.accordion.min.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.10.4', 1 );
    186     $scripts->add( 'jquery-ui-autocomplete', '/wp-includes/js/jquery/ui/jquery.ui.autocomplete.min.js', array('jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position', 'jquery-ui-menu'), '1.10.4', 1 );
    187     $scripts->add( 'jquery-ui-button', '/wp-includes/js/jquery/ui/jquery.ui.button.min.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.10.4', 1 );
    188     $scripts->add( 'jquery-ui-datepicker', '/wp-includes/js/jquery/ui/jquery.ui.datepicker.min.js', array('jquery-ui-core'), '1.10.4', 1 );
    189     $scripts->add( 'jquery-ui-dialog', '/wp-includes/js/jquery/ui/jquery.ui.dialog.min.js', array('jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button', 'jquery-ui-position'), '1.10.4', 1 );
    190     $scripts->add( 'jquery-ui-draggable', '/wp-includes/js/jquery/ui/jquery.ui.draggable.min.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.10.4', 1 );
    191     $scripts->add( 'jquery-ui-droppable', '/wp-includes/js/jquery/ui/jquery.ui.droppable.min.js', array('jquery-ui-draggable'), '1.10.4', 1 );
    192     $scripts->add( 'jquery-ui-menu', '/wp-includes/js/jquery/ui/jquery.ui.menu.min.js', array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), '1.10.4', 1 );
    193     $scripts->add( 'jquery-ui-mouse', '/wp-includes/js/jquery/ui/jquery.ui.mouse.min.js', array('jquery-ui-widget'), '1.10.4', 1 );
    194     $scripts->add( 'jquery-ui-position', '/wp-includes/js/jquery/ui/jquery.ui.position.min.js', array('jquery'), '1.10.4', 1 );
    195     $scripts->add( 'jquery-ui-progressbar', '/wp-includes/js/jquery/ui/jquery.ui.progressbar.min.js', array('jquery-ui-widget'), '1.10.4', 1 );
    196     $scripts->add( 'jquery-ui-resizable', '/wp-includes/js/jquery/ui/jquery.ui.resizable.min.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.10.4', 1 );
    197     $scripts->add( 'jquery-ui-selectable', '/wp-includes/js/jquery/ui/jquery.ui.selectable.min.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.10.4', 1 );
    198     $scripts->add( 'jquery-ui-slider', '/wp-includes/js/jquery/ui/jquery.ui.slider.min.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.10.4', 1 );
    199     $scripts->add( 'jquery-ui-sortable', '/wp-includes/js/jquery/ui/jquery.ui.sortable.min.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.10.4', 1 );
    200     $scripts->add( 'jquery-ui-spinner', '/wp-includes/js/jquery/ui/jquery.ui.spinner.min.js', array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-button' ), '1.10.4', 1 );
    201     $scripts->add( 'jquery-ui-tabs', '/wp-includes/js/jquery/ui/jquery.ui.tabs.min.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.10.4', 1 );
    202     $scripts->add( 'jquery-ui-tooltip', '/wp-includes/js/jquery/ui/jquery.ui.tooltip.min.js', array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), '1.10.4', 1 );
    203     $scripts->add( 'jquery-ui-widget', '/wp-includes/js/jquery/ui/jquery.ui.widget.min.js', array('jquery'), '1.10.4', 1 );
     168    $scripts->add( 'jquery-ui-core', "/wp-includes/js/jquery/ui/core$dev_suffix.js", array('jquery'), '1.11.1', 1 );
     169    $scripts->add( 'jquery-effects-core', "/wp-includes/js/jquery/ui/effect$dev_suffix.js", array('jquery'), '1.11.1', 1 );
     170
     171    $scripts->add( 'jquery-effects-blind', "/wp-includes/js/jquery/ui/effect-blind$dev_suffix.js", array('jquery-effects-core'), '1.11.1', 1 );
     172    $scripts->add( 'jquery-effects-bounce', "/wp-includes/js/jquery/ui/effect-bounce$dev_suffix.js", array('jquery-effects-core'), '1.11.1', 1 );
     173    $scripts->add( 'jquery-effects-clip', "/wp-includes/js/jquery/ui/effect-clip$dev_suffix.js", array('jquery-effects-core'), '1.11.1', 1 );
     174    $scripts->add( 'jquery-effects-drop', "/wp-includes/js/jquery/ui/effect-drop$dev_suffix.js", array('jquery-effects-core'), '1.11.1', 1 );
     175    $scripts->add( 'jquery-effects-explode', "/wp-includes/js/jquery/ui/effect-explode$dev_suffix.js", array('jquery-effects-core'), '1.11.1', 1 );
     176    $scripts->add( 'jquery-effects-fade', "/wp-includes/js/jquery/ui/effect-fade$dev_suffix.js", array('jquery-effects-core'), '1.11.1', 1 );
     177    $scripts->add( 'jquery-effects-fold', "/wp-includes/js/jquery/ui/effect-fold$dev_suffix.js", array('jquery-effects-core'), '1.11.1', 1 );
     178    $scripts->add( 'jquery-effects-highlight', "/wp-includes/js/jquery/ui/effect-highlight$dev_suffix.js", array('jquery-effects-core'), '1.11.1', 1 );
     179    $scripts->add( 'jquery-effects-puff', "/wp-includes/js/jquery/ui/effect-puff$dev_suffix.js", array('jquery-effects-core'), '1.11.1', 1 );
     180    $scripts->add( 'jquery-effects-pulsate', "/wp-includes/js/jquery/ui/effect-pulsate$dev_suffix.js", array('jquery-effects-core'), '1.11.1', 1 );
     181    $scripts->add( 'jquery-effects-scale', "/wp-includes/js/jquery/ui/effect-scale$dev_suffix.js", array('jquery-effects-core'), '1.11.1', 1 );
     182    $scripts->add( 'jquery-effects-shake', "/wp-includes/js/jquery/ui/effect-shake$dev_suffix.js", array('jquery-effects-core'), '1.11.1', 1 );
     183    $scripts->add( 'jquery-effects-size', "/wp-includes/js/jquery/ui/effect-size$dev_suffix.js", array('jquery-effects-core'), '1.11.1', 1 );
     184    $scripts->add( 'jquery-effects-slide', "/wp-includes/js/jquery/ui/effect-slide$dev_suffix.js", array('jquery-effects-core'), '1.11.1', 1 );
     185    $scripts->add( 'jquery-effects-transfer', "/wp-includes/js/jquery/ui/effect-transfer$dev_suffix.js", array('jquery-effects-core'), '1.11.1', 1 );
     186
     187    $scripts->add( 'jquery-ui-accordion', "/wp-includes/js/jquery/ui/accordion$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.1', 1 );
     188    $scripts->add( 'jquery-ui-autocomplete', "/wp-includes/js/jquery/ui/autocomplete$dev_suffix.js", array('jquery-ui-menu'), '1.11.1', 1 );
     189    $scripts->add( 'jquery-ui-button', "/wp-includes/js/jquery/ui/button$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.1', 1 );
     190    $scripts->add( 'jquery-ui-datepicker', "/wp-includes/js/jquery/ui/datepicker$dev_suffix.js", array('jquery-ui-core'), '1.11.1', 1 );
     191    $scripts->add( 'jquery-ui-dialog', "/wp-includes/js/jquery/ui/dialog$dev_suffix.js", array('jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button', 'jquery-ui-position'), '1.11.1', 1 );
     192    $scripts->add( 'jquery-ui-draggable', "/wp-includes/js/jquery/ui/draggable$dev_suffix.js", array('jquery-ui-mouse'), '1.11.1', 1 );
     193    $scripts->add( 'jquery-ui-droppable', "/wp-includes/js/jquery/ui/droppable$dev_suffix.js", array('jquery-ui-draggable'), '1.11.1', 1 );
     194    $scripts->add( 'jquery-ui-menu', "/wp-includes/js/jquery/ui/menu$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), '1.11.1', 1 );
     195    $scripts->add( 'jquery-ui-mouse', "/wp-includes/js/jquery/ui/mouse$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget' ), '1.11.1', 1 );
     196    $scripts->add( 'jquery-ui-position', "/wp-includes/js/jquery/ui/position$dev_suffix.js", array('jquery'), '1.11.1', 1 );
     197    $scripts->add( 'jquery-ui-progressbar', "/wp-includes/js/jquery/ui/progressbar$dev_suffix.js", array('jquery-ui-widget'), '1.11.1', 1 );
     198    $scripts->add( 'jquery-ui-resizable', "/wp-includes/js/jquery/ui/resizable$dev_suffix.js", array('jquery-ui-mouse'), '1.11.1', 1 );
     199    $scripts->add( 'jquery-ui-selectable', "/wp-includes/js/jquery/ui/selectable$dev_suffix.js", array('jquery-ui-mouse'), '1.11.1', 1 );
     200    $scripts->add( 'jquery-ui-selectmenu', "/wp-includes/js/jquery/ui/selectmenu$dev_suffix.js", array('jquery-ui-menu'), '1.11.1', 1 );
     201    $scripts->add( 'jquery-ui-slider', "/wp-includes/js/jquery/ui/slider$dev_suffix.js", array('jquery-ui-mouse'), '1.11.1', 1 );
     202    $scripts->add( 'jquery-ui-sortable', "/wp-includes/js/jquery/ui/sortable$dev_suffix.js", array('jquery-ui-mouse'), '1.11.1', 1 );
     203    $scripts->add( 'jquery-ui-spinner', "/wp-includes/js/jquery/ui/spinner$dev_suffix.js", array( 'jquery-ui-button' ), '1.11.1', 1 );
     204    $scripts->add( 'jquery-ui-tabs', "/wp-includes/js/jquery/ui/tabs$dev_suffix.js", array('jquery-ui-core', 'jquery-ui-widget'), '1.11.1', 1 );
     205    $scripts->add( 'jquery-ui-tooltip', "/wp-includes/js/jquery/ui/tooltip$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), '1.11.1', 1 );
     206    $scripts->add( 'jquery-ui-widget', "/wp-includes/js/jquery/ui/widget$dev_suffix.js", array('jquery'), '1.11.1', 1 );
    204207
    205208    // deprecated, not used in core, most functionality is included in jQuery 1.3
Note: See TracChangeset for help on using the changeset viewer.