Вход Регистрация
Файл: src/public/plugins/pickadate/picker.js
Строк: 1195
<?php
/*!
 * pickadate.js v3.5.6, 2015/04/20
 * By Amsul, http://amsul.ca
 * Hosted on http://amsul.github.io/pickadate.js
 * Licensed under MIT
 */

(function ( factory ) {

    
// AMD.
    
if ( typeof define == 'function' && define.amd )
        
define'picker', ['jquery'], factory )

    
// Node.js/browserify.
    
else if ( typeof exports == 'object' )
        
module.exports factory( require('jquery') )

    
// Browser globals.
    
else this.Picker factoryjQuery )

}(function( $ ) {

var 
$window = $( window )
var 
$document = $( document )
var 
$html = $( document.documentElement )
var 
supportsTransitions document.documentElement.style.transition != null


/**
 * The picker constructor that creates a blank picker.
 */
function PickerConstructorELEMENTNAMECOMPONENTOPTIONS ) {

    
// If there’s no element, return the picker constructor.
    
if ( !ELEMENT ) return PickerConstructor


    
var
        
IS_DEFAULT_THEME false,


        
// The state of the picker.
        
STATE = {
            
idELEMENT.id || 'P' Math.abs( ~~(Math.random() * new Date()) )
        },


        
// Merge the defaults and options passed.
        
SETTINGS COMPONENT ? $.extendtrue, {}, COMPONENT.defaultsOPTIONS ) : OPTIONS || {},


        
// Merge the default classes with the settings classes.
        
CLASSES = $.extend( {}, PickerConstructor.klasses(), SETTINGS.klass ),


        
// The element node wrapper into a jQuery object.
        
$ELEMENT = $( ELEMENT ),


        
// Pseudo picker constructor.
        
PickerInstance = function() {
            return 
this.start()
        },


        
// The picker prototype.
        
PickerInstance.prototype = {

            
constructorPickerInstance,

            
$node$ELEMENT,


            
/**
             * Initialize everything
             */
            
start: function() {

                
// If it’s already started, do nothing.
                
if ( STATE && STATE.start ) return P


                
// Update the picker states.
                
STATE.methods = {}
                
STATE.start true
                STATE
.open false
                STATE
.type ELEMENT.type


                
// Confirm focus state, convert into text input to remove UA stylings,
                // and set as readonly to prevent keyboard popup.
                
ELEMENT.autofocus ELEMENT == getActiveElement()
                
ELEMENT.readOnly = !SETTINGS.editable
                ELEMENT
.id ELEMENT.id || STATE.id
                
if ( ELEMENT.type != 'text' ) {
                    
ELEMENT.type 'text'
                
}


                
// Create a new picker component with the settings.
                
P.component = new COMPONENT(PSETTINGS)


                
// Create the picker root and then prepare it.
                
P.$root = $( '<div class="' CLASSES.picker '" id="' ELEMENT.id '_root" />' )
                
prepareElementRoot()


                
// Create the picker holder and then prepare it.
                
P.$holder = $( createWrappedComponent() ).appendToP.$root )
                
prepareElementHolder()


                
// If there’s a format for the hidden input element, create the element.
                
if ( SETTINGS.formatSubmit ) {
                    
prepareElementHidden()
                }


                
// Prepare the input element.
                
prepareElement()


                
// Insert the hidden input as specified in the settings.
                
if ( SETTINGS.containerHidden ) $( SETTINGS.containerHidden ).appendP._hidden )
                else 
$ELEMENT.afterP._hidden )


                
// Insert the root as specified in the settings.
                
if ( SETTINGS.container ) $( SETTINGS.container ).appendP.$root )
                else 
$ELEMENT.afterP.$root )


                
// Bind the default component and settings events.
                
P.on({
                    
startP.component.onStart,
                    
renderP.component.onRender,
                    
stopP.component.onStop,
                    
openP.component.onOpen,
                    
closeP.component.onClose,
                    
setP.component.onSet
                
}).on({
                    
startSETTINGS.onStart,
                    
renderSETTINGS.onRender,
                    
stopSETTINGS.onStop,
                    
openSETTINGS.onOpen,
                    
closeSETTINGS.onClose,
                    
setSETTINGS.onSet
                
})


                
// Once we’re all set, check the theme in use.
                
IS_DEFAULT_THEME isUsingDefaultThemeP.$holder[0] )


                
// If the element has autofocus, open the picker.
                
if ( ELEMENT.autofocus ) {
                    
P.open()
                }


                
// Trigger queued the “start” and “render” events.
                
return P.trigger'start' ).trigger'render' )
            }, 
//start


            /**
             * Render a new picker
             */
            
render: function( entireComponent ) {

                
// Insert a new component holder in the root or box.
                
if ( entireComponent ) {
                    
P.$holder = $( createWrappedComponent() )
                    
prepareElementHolder()
                    
P.$root.htmlP.$holder )
                }
                else 
P.$root.find'.' CLASSES.box ).htmlP.component.nodesSTATE.open ) )

                
// Trigger the queued “render” events.
                
return P.trigger'render' )
            }, 
//render


            /**
             * Destroy everything
             */
            
stop: function() {

                
// If it’s already stopped, do nothing.
                
if ( !STATE.start ) return P

                
// Then close the picker.
                
P.close()

                
// Remove the hidden field.
                
if ( P._hidden ) {
                    
P._hidden.parentNode.removeChildP._hidden )
                }

                
// Remove the root.
                
P.$root.remove()

                
// Remove the input class, remove the stored data, and unbind
                // the events (after a tick for IE - see `P.close`).
                
$ELEMENT.removeClassCLASSES.input ).removeDataNAME )
                
setTimeout( function() {
                    
$ELEMENT.off'.' STATE.id )
                }, 
0)

                
// Restore the element state
                
ELEMENT.type STATE.type
                ELEMENT
.readOnly false

                
// Trigger the queued “stop” events.
                
P.trigger'stop' )

                
// Reset the picker states.
                
STATE.methods = {}
                
STATE.start false

                
return P
            
}, //stop


            /**
             * Open up the picker
             */
            
open: function( dontGiveFocus ) {

                
// If it’s already open, do nothing.
                
if ( STATE.open ) return P

                
// Add the “active” class.
                
$ELEMENT.addClassCLASSES.active )
                
ariaELEMENT'expanded'true )

                
// * A Firefox bug, when `html` has `overflow:hidden`, results in
                //   killing transitions :(. So add the “opened” state on the next tick.
                //   Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289
                
setTimeout( function() {

                    
// Add the “opened” class to the picker root.
                    
P.$root.addClassCLASSES.opened )
                    
ariaP.$root[0], 'hidden'false )

                }, 
)

                
// If we have to give focus, bind the element and doc events.
                
if ( dontGiveFocus !== false ) {

                    
// Set it as open.
                    
STATE.open true

                    
// Prevent the page from scrolling.
                    
if ( IS_DEFAULT_THEME ) {
                        
$html.
                            
css'overflow''hidden' ).
                            
css'padding-right''+=' getScrollbarWidth() )
                    }

                    
// Pass focus to the root element’s jQuery object.
                    
focusPickerOnceOpened()

                    
// Bind the document events.
                    
$document.on'click.' STATE.id ' focusin.' STATE.id, function( event ) {

                        var 
target event.target

                        
// If the target of the event is not the element, close the picker picker.
                        // * Don’t worry about clicks or focusins on the root because those don’t bubble up.
                        //   Also, for Firefox, a click on an `option` element bubbles up directly
                        //   to the doc. So make sure the target wasn't the doc.
                        // * In Firefox stopPropagation() doesn’t prevent right-click events from bubbling,
                        //   which causes the picker to unexpectedly close when right-clicking it. So make
                        //   sure the event wasn’t a right-click.
                        
if ( target != ELEMENT && target != document && event.which != ) {

                            
// If the target was the holder that covers the screen,
                            // keep the element focused to maintain tabindex.
                            
P.closetarget === P.$holder[0] )
                        }

                    }).
on'keydown.' STATE.id, function( event ) {

                        var
                            
// Get the keycode.
                            
keycode event.keyCode,

                            
// Translate that to a selection change.
                            
keycodeToMove P.component.keykeycode ],

                            
// Grab the target.
                            
target event.target


                        
// On escape, close the picker and give focus.
                        
if ( keycode == 27 ) {
                            
P.closetrue )
                        }


                        
// Check if there is a key movement or “enter” keypress on the element.
                        
else if ( target == P.$holder[0] && ( keycodeToMove || keycode == 13 ) ) {

                            
// Prevent the default action to stop page movement.
                            
event.preventDefault()

                            
// Trigger the key movement action.
                            
if ( keycodeToMove ) {
                                
PickerConstructor._.triggerP.component.key.goP, [ PickerConstructor._.triggerkeycodeToMove ) ] )
                            }

                            
// On “enter”, if the highlighted item isn’t disabled, set the value and close.
                            
else if ( !P.$root.find'.' CLASSES.highlighted ).hasClassCLASSES.disabled ) ) {
                                
P.set'select'P.component.item.highlight )
                                if ( 
SETTINGS.closeOnSelect ) {
                                    
P.closetrue )
                                }
                            }
                        }


                        
// If the target is within the root and “enter” is pressed,
                        // prevent the default action and trigger a click on the target instead.
                        
else if ( $.containsP.$root[0], target ) && keycode == 13 ) {
                            
event.preventDefault()
                            
target.click()
                        }
                    })
                }

                
// Trigger the queued “open” events.
                
return P.trigger'open' )
            }, 
//open


            /**
             * Close the picker
             */
            
close: function( giveFocus ) {

                
// If we need to give focus, do it before changing states.
                
if ( giveFocus ) {
                    if ( 
SETTINGS.editable ) {
                        
ELEMENT.focus()
                    }
                    else {
                        
// ....ah yes! It would’ve been incomplete without a crazy workaround for IE :|
                        // The focus is triggered *after* the close has completed - causing it
                        // to open again. So unbind and rebind the event at the next tick.
                        
P.$holder.off'focus.toOpen' ).focus()
                        
setTimeout( function() {
                            
P.$holder.on'focus.toOpen'handleFocusToOpenEvent )
                        }, 
)
                    }
                }

                
// Remove the “active” class.
                
$ELEMENT.removeClassCLASSES.active )
                
ariaELEMENT'expanded'false )

                
// * A Firefox bug, when `html` has `overflow:hidden`, results in
                //   killing transitions :(. So remove the “opened” state on the next tick.
                //   Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289
                
setTimeout( function() {

                    
// Remove the “opened” and “focused” class from the picker root.
                    
P.$root.removeClassCLASSES.opened ' ' CLASSES.focused )
                    
ariaP.$root[0], 'hidden'true )

                }, 
)

                
// If it’s already closed, do nothing more.
                
if ( !STATE.open ) return P

                
// Set it as closed.
                
STATE.open false

                
// Allow the page to scroll.
                
if ( IS_DEFAULT_THEME ) {
                    
$html.
                        
css'overflow''' ).
                        
css'padding-right''-=' getScrollbarWidth() )
                }

                
// Unbind the document events.
                
$document.off'.' STATE.id )

                
// Trigger the queued “close” events.
                
return P.trigger'close' )
            }, 
//close


            /**
             * Clear the values
             */
            
clear: function( options ) {
                return 
P.set'clear'nulloptions )
            }, 
//clear


            /**
             * Set something
             */
            
set: function( thingvalueoptions ) {

                var 
thingItemthingValue,
                    
thingIsObject = $.isPlainObjectthing ),
                    
thingObject thingIsObject thing : {}

                
// Make sure we have usable options.
                
options thingIsObject && $.isPlainObjectvalue ) ? value options || {}

                if ( 
thing ) {

                    
// If the thing isn’t an object, make it one.
                    
if ( !thingIsObject ) {
                        
thingObjectthing ] = value
                    
}

                    
// Go through the things of items to set.
                    
for ( thingItem in thingObject ) {

                        
// Grab the value of the thing.
                        
thingValue thingObjectthingItem ]

                        
// First, if the item exists and there’s a value, set it.
                        
if ( thingItem in P.component.item ) {
                            if ( 
thingValue === undefined thingValue null
                            P
.component.setthingItemthingValueoptions )
                        }

                        
// Then, check to update the element value and broadcast a change.
                        
if ( thingItem == 'select' || thingItem == 'clear' ) {
                            
$ELEMENT.
                                
valthingItem == 'clear' '' P.getthingItemSETTINGS.format ) ).
                                
trigger'change' )
                        }
                    }

                    
// Render a new picker.
                    
P.render()
                }

                
// When the method isn’t muted, trigger queued “set” events and pass the `thingObject`.
                
return options.muted P.trigger'set'thingObject )
            }, 
//set


            /**
             * Get something
             */
            
get: function( thingformat ) {

                
// Make sure there’s something to get.
                
thing thing || 'value'

                
// If a picker state exists, return that.
                
if ( STATEthing ] != null ) {
                    return 
STATEthing ]
                }

                
// Return the submission value, if that.
                
if ( thing == 'valueSubmit' ) {
                    if ( 
P._hidden ) {
                        return 
P._hidden.value
                    
}
                    
thing 'value'
                
}

                
// Return the value, if that.
                
if ( thing == 'value' ) {
                    return 
ELEMENT.value
                
}

                
// Check if a component item exists, return that.
                
if ( thing in P.component.item ) {
                    if ( 
typeof format == 'string' ) {
                        var 
thingValue P.component.getthing )
                        return 
thingValue ?
                            
PickerConstructor._.trigger(
                                
P.component.formats.toString,
                                
P.component,
                                [ 
formatthingValue ]
                            ) : 
''
                    
}
                    return 
P.component.getthing )
                }
            }, 
//get



            /**
             * Bind events on the things.
             */
            
on: function( thingmethodinternal ) {

                var 
thingNamethingMethod,
                    
thingIsObject = $.isPlainObjectthing ),
                    
thingObject thingIsObject thing : {}

                if ( 
thing ) {

                    
// If the thing isn’t an object, make it one.
                    
if ( !thingIsObject ) {
                        
thingObjectthing ] = method
                    
}

                    
// Go through the things to bind to.
                    
for ( thingName in thingObject ) {

                        
// Grab the method of the thing.
                        
thingMethod thingObjectthingName ]

                        
// If it was an internal binding, prefix it.
                        
if ( internal ) {
                            
thingName '_' thingName
                        
}

                        
// Make sure the thing methods collection exists.
                        
STATE.methodsthingName ] = STATE.methodsthingName ] || []

                        
// Add the method to the relative method collection.
                        
STATE.methodsthingName ].pushthingMethod )
                    }
                }

                return 
P
            
}, //on



            /**
             * Unbind events on the things.
             */
            
off: function() {
                var 
ithingName,
                    
names arguments;
                for ( 
0namesCount names.lengthnamesCount+= ) {
                    
thingName names[i]
                    if ( 
thingName in STATE.methods ) {
                        
delete STATE.methods[thingName]
                    }
                }
                return 
P
            
},


            
/**
             * Fire off method events.
             */
            
trigger: function( namedata ) {
                var 
_trigger = function( name ) {
                    var 
methodList STATE.methodsname ]
                    if ( 
methodList ) {
                        
methodList.map( function( method ) {
                            
PickerConstructor._.triggermethodP, [ data ] )
                        })
                    }
                }
                
_trigger'_' name )
                
_triggername )
                return 
P
            
//trigger
        
//PickerInstance.prototype


    /**
     * Wrap the picker holder components together.
     */
    
function createWrappedComponent() {

        
// Create a picker wrapper holder
        
return PickerConstructor._.node'div',

            
// Create a picker wrapper node
            
PickerConstructor._.node'div',

                
// Create a picker frame
                
PickerConstructor._.node'div',

                    
// Create a picker box node
                    
PickerConstructor._.node'div',

                        
// Create the components nodes.
                        
P.component.nodesSTATE.open ),

                        
// The picker box class
                        
CLASSES.box
                    
),

                    
// Picker wrap class
                    
CLASSES.wrap
                
),

                
// Picker frame class
                
CLASSES.frame
            
),

            
// Picker holder class
            
CLASSES.holder,

            
'tabindex="-1"'
        
//endreturn
    
//createWrappedComponent



    /**
     * Prepare the input element with all bindings.
     */
    
function prepareElement() {

        
$ELEMENT.

            
// Store the picker data by component name.
            
data(NAMEP).

            
// Add the “input” class name.
            
addClass(CLASSES.input).

            
// If there’s a `data-value`, update the value of the element.
            
val$ELEMENT.data('value') ?
                
P.get('select'SETTINGS.format) :
                
ELEMENT.value
            
)


        
// Only bind keydown events if the element isn’t editable.
        
if ( !SETTINGS.editable ) {

            
$ELEMENT.

                
// On focus/click, open the picker.
                
on'focus.' STATE.id ' click.' STATE.id, function(event) {
                    
event.preventDefault()
                    
P.open()
                }).

                
// Handle keyboard event based on the picker being opened or not.
                
on'keydown.' STATE.idhandleKeydownEvent )
        }


        
// Update the aria attributes.
        
aria(ELEMENT, {
            
haspopuptrue,
            
expandedfalse,
            
readonlyfalse,
            
ownsELEMENT.id '_root'
        
})
    }


    
/**
     * Prepare the root picker element with all bindings.
     */
    
function prepareElementRoot() {
        
ariaP.$root[0], 'hidden'true )
    }


     
/**
      * Prepare the holder picker element with all bindings.
      */
    
function prepareElementHolder() {

        
P.$holder.

            
on({

                
// For iOS8.
                
keydownhandleKeydownEvent,

                
'focus.toOpen'handleFocusToOpenEvent,

                
blur: function() {
                    
// Remove the “target” class.
                    
$ELEMENT.removeClassCLASSES.target )
                },

                
// When something within the holder is focused, stop from bubbling
                // to the doc and remove the “focused” state from the root.
                
focusin: function( event ) {
                    
P.$root.removeClassCLASSES.focused )
                    
event.stopPropagation()
                },

                
// When something within the holder is clicked, stop it
                // from bubbling to the doc.
                
'mousedown click': function( event ) {

                    var 
target event.target

                    
// Make sure the target isn’t the root holder so it can bubble up.
                    
if ( target != P.$holder[0] ) {

                        
event.stopPropagation()

                        
// * For mousedown events, cancel the default action in order to
                        //   prevent cases where focus is shifted onto external elements
                        //   when using things like jQuery mobile or MagnificPopup (ref: #249 & #120).
                        //   Also, for Firefox, don’t prevent action on the `option` element.
                        
if ( event.type == 'mousedown' && !$( target ).is'input, select, textarea, button, option' )) {

                            
event.preventDefault()

                            
// Re-focus onto the holder so that users can click away
                            // from elements focused within the picker.
                            
P.$holder[0].focus()
                        }
                    }
                }

            }).

            
// If there’s a click on an actionable element, carry out the actions.
            
on'click''[data-pick], [data-nav], [data-clear], [data-close]', function() {

                var 
$target = $( this ),
                    
targetData $target.data(),
                    
targetDisabled $target.hasClassCLASSES.navDisabled ) || $target.hasClassCLASSES.disabled ),

                    
// * For IE, non-focusable elements can be active elements as well
                    //   (http://stackoverflow.com/a/2684561).
                    
activeElement getActiveElement()
                    
activeElement activeElement && ( activeElement.type || activeElement.href )

                
// If it’s disabled or nothing inside is actively focused, re-focus the element.
                
if ( targetDisabled || activeElement && !$.containsP.$root[0], activeElement ) ) {
                    
P.$holder[0].focus()
                }

                
// If something is superficially changed, update the `highlight` based on the `nav`.
                
if ( !targetDisabled && targetData.nav ) {
                    
P.set'highlight'P.component.item.highlight, { navtargetData.nav } )
                }

                
// If something is picked, set `select` then close with focus.
                
else if ( !targetDisabled && 'pick' in targetData ) {
                    
P.set'select'targetData.pick )
                    if ( 
SETTINGS.closeOnSelect ) {
                        
P.closetrue )
                    }
                }

                
// If a “clear” button is pressed, empty the values and close with focus.
                
else if ( targetData.clear ) {
                    
P.clear()
                    if ( 
SETTINGS.closeOnClear ) {
                        
P.closetrue )
                    }
                }

                else if ( 
targetData.close ) {
                    
P.closetrue )
                }

            }) 
//P.$holder

    
}


     
/**
      * Prepare the hidden input element along with all bindings.
      */
    
function prepareElementHidden() {

        var 
name

        
if ( SETTINGS.hiddenName === true ) {
            
name ELEMENT.name
            ELEMENT
.name ''
        
}
        else {
            
name = [
                
typeof SETTINGS.hiddenPrefix == 'string' SETTINGS.hiddenPrefix '',
                
typeof SETTINGS.hiddenSuffix == 'string' SETTINGS.hiddenSuffix '_submit'
            
]
            
name name[0] + ELEMENT.name name[1]
        }

        
P._hidden = $(
            
'<input ' +
            
'type=hidden ' +

            
// Create the name using the original input’s with a prefix and suffix.
            
'name="' name '"' +

            
// If the element has a value, set the hidden value as well.
            
(
                
$ELEMENT.data('value') || ELEMENT.value ?
                    
' value="' P.get('select'SETTINGS.formatSubmit) + '"' :
                    
''
            
) +
            
'>'
        
)[0]

        
$ELEMENT.

            
// If the value changes, update the hidden input with the correct format.
            
on('change.' STATE.id, function() {
                
P._hidden.value ELEMENT.value ?
                    
P.get('select'SETTINGS.formatSubmit) :
                    
''
            
})
    }


    
// Wait for transitions to end before focusing the holder. Otherwise, while
    // using the `container` option, the view jumps to the container.
    
function focusPickerOnceOpened() {

        if (
IS_DEFAULT_THEME && supportsTransitions) {
            
P.$holder.find('.' CLASSES.frame).one('transitionend', function() {
                
P.$holder[0].focus()
            })
        }
        else {
            
P.$holder[0].focus()
        }
    }


    function 
handleFocusToOpenEvent(event) {

        
// Stop the event from propagating to the doc.
        
event.stopPropagation()

        
// Add the “target” class.
        
$ELEMENT.addClassCLASSES.target )

        
// Add the “focused” class to the root.
        
P.$root.addClassCLASSES.focused )

        
// And then finally open the picker.
        
P.open()
    }


    
// For iOS8.
    
function handleKeydownEventevent ) {

        var 
keycode event.keyCode,

            
// Check if one of the delete keys was pressed.
            
isKeycodeDelete = /^(8|46)$/.test(keycode)

        
// For some reason IE clears the input value on “escape”.
        
if ( keycode == 27 ) {
            
P.closetrue )
            return 
false
        
}

        
// Check if `space` or `delete` was pressed or the picker is closed with a key movement.
        
if ( keycode == 32 || isKeycodeDelete || !STATE.open && P.component.key[keycode] ) {

            
// Prevent it from moving the page and bubbling to doc.
            
event.preventDefault()
            
event.stopPropagation()

            
// If `delete` was pressed, clear the values and close the picker.
            // Otherwise open the picker.
            
if ( isKeycodeDelete ) { P.clear().close() }
            else { 
P.open() }
        }
    }


    
// Return a new picker instance.
    
return new PickerInstance()
//PickerConstructor



/**
 * The default classes and prefix to use for the HTML classes.
 */
PickerConstructor.klasses = function( prefix ) {
    
prefix prefix || 'picker'
    
return {

        
pickerprefix,
        
openedprefix '--opened',
        
focusedprefix '--focused',

        
inputprefix '__input',
        
activeprefix '__input--active',
        
targetprefix '__input--target',

        
holderprefix '__holder',

        
frameprefix '__frame',
        
wrapprefix '__wrap',

        
boxprefix '__box'
    
}
//PickerConstructor.klasses



/**
 * Check if the default theme is being used.
 */
function isUsingDefaultThemeelement ) {

    var 
theme,
        
prop 'position'

    
// For IE.
    
if ( element.currentStyle ) {
        
theme element.currentStyle[prop]
    }

    
// For normal browsers.
    
else if ( window.getComputedStyle ) {
        
theme getComputedStyleelement )[prop]
    }

    return 
theme == 'fixed'
}



/**
 * Get the width of the browser’s scrollbar.
 * Taken from: https://github.com/VodkaBears/Remodal/blob/master/src/jquery.remodal.js
 */
function getScrollbarWidth() {

    if ( 
$html.height() <= $window.height() ) {
        return 
0
    
}

    var 
$outer = $( '<div style="visibility:hidden;width:100px" />' ).
        
appendTo'body' )

    
// Get the width without scrollbars.
    
var widthWithoutScroll $outer[0].offsetWidth

    
// Force adding scrollbars.
    
$outer.css'overflow''scroll' )

    
// Add the inner div.
    
var $inner = $( '<div style="width:100%" />' ).appendTo$outer )

    
// Get the width with scrollbars.
    
var widthWithScroll $inner[0].offsetWidth

    
// Remove the divs.
    
$outer.remove()

    
// Return the difference between the widths.
    
return widthWithoutScroll widthWithScroll
}



/**
 * PickerConstructor helper methods.
 */
PickerConstructor.= {

    
/**
     * Create a group of nodes. Expects:
     * `
        {
            min:    {Integer},
            max:    {Integer},
            i:      {Integer},
            node:   {String},
            item:   {Function}
        }
     * `
     */
    
group: function( groupObject ) {

        var
            
// Scope for the looped object
            
loopObjectScope,

            
// Create the nodes list
            
nodesList '',

            
// The counter starts from the `min`
            
counter PickerConstructor._.triggergroupObject.mingroupObject )


        
// Loop from the `min` to `max`, incrementing by `i`
        
for ( ; counter <= PickerConstructor._.triggergroupObject.maxgroupObject, [ counter ] ); counter += groupObject.) {

            
// Trigger the `item` function within scope of the object
            
loopObjectScope PickerConstructor._.triggergroupObject.itemgroupObject, [ counter ] )

            
// Splice the subgroup and create nodes out of the sub nodes
            
nodesList += PickerConstructor._.node(
                
groupObject.node,
                
loopObjectScope],   // the node
                
loopObjectScope],   // the classes
                
loopObjectScope]    // the attributes
            
)
        }

        
// Return the list of nodes
        
return nodesList
    
}, //group


    /**
     * Create a dom node string
     */
    
node: function( wrapperitemklassattribute ) {

        
// If the item is false-y, just return an empty string
        
if ( !item ) return ''

        
// If the item is an array, do a join
        
item = $.isArrayitem ) ? item.join'' ) : item

        
// Check for the class
        
klass klass ' class="' klass '"' ''

        
// Check for any attributes
        
attribute attribute ' ' attribute ''

        
// Return the wrapped item
        
return '<' wrapper klass attribute '>' item '</' wrapper '>'
    
}, //node


    /**
     * Lead numbers below 10 with a zero.
     */
    
lead: function( number ) {
        return ( 
number 10 '0''' ) + number
    
},


    
/**
     * Trigger a function otherwise return the value.
     */
    
trigger: function( callbackscopeargs ) {
        return 
typeof callback == 'function' callback.applyscopeargs || [] ) : callback
    
},


    
/**
     * If the second character is a digit, length is 2 otherwise 1.
     */
    
digits: function( string ) {
        return ( /
d/ ).teststring] ) ? 1
    
},


    
/**
     * Tell if something is a date object.
     */
    
isDate: function( value ) {
        return {}.
toString.callvalue ).indexOf'Date' ) > -&& this.isIntegervalue.getDate() )
    },


    
/**
     * Tell if something is an integer.
     */
    
isInteger: function( value ) {
        return {}.
toString.callvalue ).indexOf'Number' ) > -&& value === 0
    
},


    
/**
     * Create ARIA attribute strings.
     */
    
ariaAttrariaAttr
//PickerConstructor._



/**
 * Extend the picker with a component and defaults.
 */
PickerConstructor.extend = function( nameComponent ) {

    
// Extend jQuery.
    
$.fnname ] = function( optionsaction ) {

        
// Grab the component data.
        
var componentData this.dataname )

        
// If the picker is requested, return the data object.
        
if ( options == 'picker' ) {
            return 
componentData
        
}

        
// If the component data exists and `options` is a string, carry out the action.
        
if ( componentData && typeof options == 'string' ) {
            return 
PickerConstructor._.triggercomponentDataoptions ], componentData, [ action ] )
        }

        
// Otherwise go through each matched element and if the component
        // doesn’t exist, create a new picker using `this` element
        // and merging the defaults and options with a deep copy.
        
return this.each( function() {
            var 
$this = $( this )
            if ( !
$this.dataname ) ) {
                new 
PickerConstructorthisnameComponentoptions )
            }
        })
    }

    
// Set the defaults.
    
$.fnname ].defaults Component.defaults
//PickerConstructor.extend



function aria(elementattributevalue) {
    if ( $.
isPlainObject(attribute) ) {
        for ( var 
key in attribute ) {
            
ariaSet(elementkeyattribute[key])
        }
    }
    else {
        
ariaSet(elementattributevalue)
    }
}
function 
ariaSet(elementattributevalue) {
    
element.setAttribute(
        (
attribute == 'role' '' 'aria-') + attribute,
        
value
    
)
}
function 
ariaAttr(attributedata) {
    if ( !$.
isPlainObject(attribute) ) {
        
attribute = { attributedata }
    }
    
data ''
    
for ( var key in attribute ) {
        var 
attr = (key == 'role' '' 'aria-') + key,
            
attrVal attribute[key]
        
data += attrVal == null '' attr '="' attribute[key] + '"'
    
}
    return 
data
}

// IE8 bug throws an error for activeElements within iframes.
function getActiveElement() {
    try {
        return 
document.activeElement
    
} catch ( err ) { }
}



// Expose the picker constructor.
return PickerConstructor


}));
?>
Онлайн: 2
Реклама