mirror of
https://github.com/github/semantic.git
synced 2024-11-28 10:15:55 +03:00
Merge pull request #1387 from github/a-tidy-repo-is-a-happy-repo
A tidy repo is a happy repo
This commit is contained in:
commit
cf6f8f4e13
3
HLint.hs
3
HLint.hs
@ -14,9 +14,6 @@ error "Avoid return" =
|
||||
return ==> pure
|
||||
where note = "return is obsolete as of GHC 7.10"
|
||||
|
||||
error "use pure" = free . Pure ==> pure
|
||||
error "use wrap" = free . Free ==> wrap
|
||||
|
||||
error "use extract" = termAnnotation . unTerm ==> extract
|
||||
error "use unwrap" = termOut . unTerm ==> unwrap
|
||||
|
||||
|
@ -55,13 +55,11 @@ library
|
||||
, Language.Go.Syntax
|
||||
, Language.JSON.Grammar
|
||||
, Language.JSON.Syntax
|
||||
, Language.Ruby
|
||||
, Language.Ruby.Grammar
|
||||
, Language.Ruby.Syntax
|
||||
, Language.TypeScript
|
||||
, Language.TypeScript.Grammar
|
||||
, Language.TypeScript.Syntax
|
||||
, Language.Python
|
||||
, Language.Python.Grammar
|
||||
, Language.Python.Syntax
|
||||
, Parser
|
||||
|
@ -1 +0,0 @@
|
||||
module Language.Python where
|
@ -1,177 +0,0 @@
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
module Language.Ruby where
|
||||
|
||||
import Data.Foldable (toList)
|
||||
import Data.List (partition)
|
||||
import Data.Record
|
||||
import Data.Semigroup
|
||||
import Data.Source
|
||||
import Data.Term
|
||||
import Data.Text (Text)
|
||||
import Info
|
||||
import Language
|
||||
import qualified Syntax as S
|
||||
|
||||
termAssignment
|
||||
:: Source -- ^ The source of the term.
|
||||
-> Category -- ^ The category for the term.
|
||||
-> [ Term S.Syntax (Record DefaultFields) ] -- ^ The child nodes of the term.
|
||||
-> Maybe (S.Syntax (Term S.Syntax (Record DefaultFields))) -- ^ The resulting term, in Maybe.
|
||||
termAssignment _ category children
|
||||
= case (category, children) of
|
||||
(ArgumentPair, [ k, v ] ) -> Just $ S.Pair k v
|
||||
(KeywordParameter, [ k, v ] ) -> Just $ S.Pair k v
|
||||
-- NB: ("keyword_parameter", k) is a required keyword parameter, e.g.:
|
||||
-- def foo(name:); end
|
||||
-- Let it fall through to generate an Indexed syntax.
|
||||
(OptionalParameter, [ k, v ] ) -> Just $ S.Pair k v
|
||||
(AnonymousFunction, first : rest)
|
||||
| null rest -> Just $ S.AnonymousFunction [] [first]
|
||||
| otherwise -> Just $ S.AnonymousFunction (toList (unwrap first)) rest
|
||||
(ArrayLiteral, _ ) -> Just $ S.Array Nothing children
|
||||
(Assignment, [ identifier, value ]) -> Just $ S.Assignment identifier value
|
||||
(Begin, _ ) -> Just $ case partition (\x -> Info.category (extract x) == Rescue) children of
|
||||
(rescues, rest) -> case partition (\x -> Info.category (extract x) == Ensure || Info.category (extract x) == Else) rest of
|
||||
(ensureElse, body) -> case ensureElse of
|
||||
[ elseBlock, ensure ]
|
||||
| Else <- Info.category (extract elseBlock)
|
||||
, Ensure <- Info.category (extract ensure) -> S.Try body rescues (Just elseBlock) (Just ensure)
|
||||
[ ensure, elseBlock ]
|
||||
| Ensure <- Info.category (extract ensure)
|
||||
, Else <- Info.category (extract elseBlock) -> S.Try body rescues (Just elseBlock) (Just ensure)
|
||||
[ elseBlock ] | Else <- Info.category (extract elseBlock) -> S.Try body rescues (Just elseBlock) Nothing
|
||||
[ ensure ] | Ensure <- Info.category (extract ensure) -> S.Try body rescues Nothing (Just ensure)
|
||||
_ -> S.Try body rescues Nothing Nothing
|
||||
(Class, constant : superclass : body)
|
||||
| Superclass <- Info.category (extract superclass)
|
||||
-> Just $ S.Class constant [superclass] body
|
||||
(Class, constant : rest) -> Just $ S.Class constant [] rest
|
||||
(SingletonClass, identifier : rest) -> Just $ S.Class identifier [] rest
|
||||
(Case, _) -> Just $ uncurry S.Switch (break ((== When) . Info.category . extract) children)
|
||||
(When, expr : body) -> Just $ S.Case expr body
|
||||
(Ternary, condition : cases) -> Just $ S.Ternary condition cases
|
||||
(MethodCall, fn : args)
|
||||
| MemberAccess <- Info.category (extract fn)
|
||||
, [target, method] <- toList (unwrap fn)
|
||||
-> Just $ S.MethodCall target method [] (toList . unwrap =<< args)
|
||||
| otherwise
|
||||
-> Just $ S.FunctionCall fn [] (toList . unwrap =<< args)
|
||||
(Object, _ ) -> Just . S.Object Nothing $ foldMap toTuple children
|
||||
(Modifier If, [ lhs, condition ]) -> Just $ S.If condition [lhs]
|
||||
(Modifier Unless, [lhs, rhs]) -> Just $ S.If (termIn (setCategory (extract rhs) Negate) (S.Negate rhs)) [lhs]
|
||||
(Unless, expr : rest) -> Just $ S.If (termIn (setCategory (extract expr) Negate) (S.Negate expr)) rest
|
||||
(Modifier Until, [ lhs, rhs ]) -> Just $ S.While (termIn (setCategory (extract rhs) Negate) (S.Negate rhs)) [lhs]
|
||||
(Until, expr : rest) -> Just $ S.While (termIn (setCategory (extract expr) Negate) (S.Negate expr)) rest
|
||||
(Elsif, condition : body ) -> Just $ S.If condition body
|
||||
(SubscriptAccess, [ base, element ]) -> Just $ S.SubscriptAccess base element
|
||||
(For, lhs : expr : rest ) -> Just $ S.For [lhs, expr] rest
|
||||
(OperatorAssignment, [ identifier, value ]) -> Just $ S.OperatorAssignment identifier value
|
||||
(MemberAccess, [ base, property ]) -> Just $ S.MemberAccess base property
|
||||
(SingletonMethod, expr : methodName : rest)
|
||||
| params : body <- rest
|
||||
, Params <- Info.category (extract params)
|
||||
-> Just $ S.Method [] methodName (Just expr) [params] body
|
||||
| Identifier <- Info.category (extract methodName)
|
||||
-> Just $ S.Method [] methodName (Just expr) [] rest
|
||||
(Method, identifier : rest)
|
||||
| params : body <- rest
|
||||
, Params <- Info.category (extract params)
|
||||
-> Just $ S.Method [] identifier Nothing [params] body
|
||||
| otherwise
|
||||
-> Just $ S.Method [] identifier Nothing [] rest
|
||||
(Module, constant : body ) -> Just $ S.Module constant body
|
||||
(Modifier Rescue, [lhs, rhs] ) -> Just $ S.Rescue [lhs] [rhs]
|
||||
(Rescue, exceptions : exceptionVar : rest)
|
||||
| RescueArgs <- Info.category (extract exceptions)
|
||||
, RescuedException <- Info.category (extract exceptionVar)
|
||||
-> Just $ S.Rescue (toList (unwrap exceptions) <> [exceptionVar]) rest
|
||||
(Rescue, exceptionVar : rest)
|
||||
| RescuedException <- Info.category (extract exceptionVar)
|
||||
-> Just $ S.Rescue [exceptionVar] rest
|
||||
(Rescue, exceptions : body)
|
||||
| RescueArgs <- Info.category (extract exceptions)
|
||||
-> Just $ S.Rescue (toList (unwrap exceptions)) body
|
||||
(Rescue, body) -> Just $ S.Rescue [] body
|
||||
(Modifier While, [ lhs, condition ]) -> Just $ S.While condition [lhs]
|
||||
_ | category `elem` [ BeginBlock, EndBlock ] -> Just $ S.BlockStatement children
|
||||
_ -> Nothing
|
||||
|
||||
categoryForRubyName :: Text -> Category
|
||||
categoryForRubyName name = case name of
|
||||
"argument_list_with_parens" -> Args
|
||||
"argument_list" -> Args
|
||||
"argument_pair" -> ArgumentPair
|
||||
"array" -> ArrayLiteral
|
||||
"assignment" -> Assignment
|
||||
"begin_block" -> BeginBlock
|
||||
"begin" -> Begin
|
||||
"binary" -> Binary
|
||||
"block" -> ExpressionStatements
|
||||
"block_parameter" -> BlockParameter
|
||||
"block_parameters" -> Params
|
||||
"boolean" -> Boolean
|
||||
"call" -> MemberAccess
|
||||
"case" -> Case
|
||||
"class" -> Class
|
||||
"comment" -> Comment
|
||||
"conditional" -> Ternary
|
||||
"constant" -> Constant
|
||||
"element_reference" -> SubscriptAccess
|
||||
"else" -> Else
|
||||
"elsif" -> Elsif
|
||||
"empty_statement" -> Empty
|
||||
"end_block" -> EndBlock
|
||||
"ensure" -> Ensure
|
||||
"exception_variable" -> RescuedException
|
||||
"exceptions" -> RescueArgs
|
||||
"false" -> Boolean
|
||||
"float" -> NumberLiteral
|
||||
"for" -> For
|
||||
"hash_splat_parameter" -> HashSplatParameter
|
||||
"hash" -> Object
|
||||
"identifier" -> Identifier
|
||||
"if_modifier" -> Modifier If
|
||||
"if" -> If
|
||||
"instance_variable" -> Identifier
|
||||
"integer" -> IntegerLiteral
|
||||
"interpolation" -> Interpolation
|
||||
"keyword_parameter" -> KeywordParameter
|
||||
"lambda_parameters" -> Params
|
||||
"lambda" -> AnonymousFunction
|
||||
"left_assignment_list" -> Args
|
||||
"method_call" -> MethodCall
|
||||
"method_parameters" -> Params
|
||||
"method" -> Method
|
||||
"module" -> Module
|
||||
"nil" -> Identifier
|
||||
"operator_assignment" -> OperatorAssignment
|
||||
"optional_parameter" -> OptionalParameter
|
||||
"pair" -> Pair
|
||||
"pattern" -> Args
|
||||
"program" -> Program
|
||||
"range" -> RangeExpression
|
||||
"regex" -> Regex
|
||||
"rescue_modifier" -> Modifier Rescue
|
||||
"rescue" -> Rescue
|
||||
"rest_assignment" -> SplatParameter
|
||||
"return" -> Return
|
||||
"scope_resolution" -> ScopeOperator
|
||||
"self" -> Identifier
|
||||
"singleton_class" -> SingletonClass
|
||||
"singleton_method" -> SingletonMethod
|
||||
"splat_parameter" -> SplatParameter
|
||||
"string" -> StringLiteral
|
||||
"subshell" -> Subshell
|
||||
"superclass" -> Superclass
|
||||
"symbol" -> SymbolLiteral
|
||||
"true" -> Boolean
|
||||
"unary" -> Unary
|
||||
"unless_modifier" -> Modifier Unless
|
||||
"unless" -> Unless
|
||||
"until_modifier" -> Modifier Until
|
||||
"until" -> Until
|
||||
"when" -> When
|
||||
"while_modifier" -> Modifier While
|
||||
"while" -> While
|
||||
"yield" -> Yield
|
||||
s -> Other s
|
@ -20,8 +20,7 @@ import Data.Term
|
||||
import Data.Text (Text, pack)
|
||||
import Language
|
||||
import qualified Language.Go as Go
|
||||
import qualified Language.Ruby as Ruby
|
||||
import qualified Language.Ruby as TypeScript
|
||||
import qualified Language.TypeScript as TypeScript
|
||||
import Foreign
|
||||
import Foreign.C.String (peekCString)
|
||||
import Foreign.Marshal.Array (allocaArray)
|
||||
@ -30,7 +29,6 @@ import qualified TreeSitter.Document as TS
|
||||
import qualified TreeSitter.Node as TS
|
||||
import qualified TreeSitter.Language as TS
|
||||
import qualified TreeSitter.Go as TS
|
||||
import qualified TreeSitter.Ruby as TS
|
||||
import qualified TreeSitter.TypeScript as TS
|
||||
import Info
|
||||
|
||||
@ -114,7 +112,6 @@ assignTerm language source annotation children allChildren =
|
||||
where assignTermByLanguage :: Source -> Category -> [ Term S.Syntax (Record DefaultFields) ] -> Maybe (S.Syntax (Term S.Syntax (Record DefaultFields)))
|
||||
assignTermByLanguage = case languageForTSLanguage language of
|
||||
Just Language.Go -> Go.termAssignment
|
||||
Just Ruby -> Ruby.termAssignment
|
||||
Just TypeScript -> TypeScript.termAssignment
|
||||
_ -> \ _ _ _ -> Nothing
|
||||
|
||||
@ -192,14 +189,13 @@ categoryForLanguageProductionName = withDefaults . byLanguage
|
||||
s -> productionMap s
|
||||
|
||||
byLanguage language = case languageForTSLanguage language of
|
||||
Just Ruby -> Ruby.categoryForRubyName
|
||||
Just Language.Go -> Go.categoryForGoName
|
||||
Just Language.TypeScript -> TypeScript.categoryForTypeScriptName
|
||||
_ -> Other
|
||||
|
||||
|
||||
languageForTSLanguage :: Ptr TS.Language -> Maybe Language
|
||||
languageForTSLanguage = flip lookup
|
||||
[ (TS.tree_sitter_go, Language.Go)
|
||||
, (TS.tree_sitter_ruby, Ruby)
|
||||
, (TS.tree_sitter_typescript, TypeScript)
|
||||
]
|
||||
|
@ -65,6 +65,3 @@ diffFixtures =
|
||||
jsonOutput = "{\"diff\":{\"merge\":{\"after\":{\"sourceRange\":[0,21],\"sourceSpan\":{\"start\":[1,1],\"end\":[4,1]}},\"children\":[{\"merge\":{\"after\":{\"sourceRange\":[0,20],\"sourceSpan\":{\"start\":[1,1],\"end\":[3,4]}},\"children\":[{\"merge\":{\"after\":{\"sourceRange\":[0,3],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,4]}},\"children\":[],\"before\":{\"sourceRange\":[0,3],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,4]}}}},{\"patch\":{\"replace\":[{\"children\":[],\"sourceRange\":[4,7],\"sourceSpan\":{\"start\":[1,5],\"end\":[1,8]}},{\"children\":[],\"sourceRange\":[4,7],\"sourceSpan\":{\"start\":[1,5],\"end\":[1,8]}}]}},{\"patch\":{\"insert\":{\"children\":[],\"sourceRange\":[8,9],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,10]}}}},{\"merge\":{\"after\":{\"sourceRange\":[13,16],\"sourceSpan\":{\"start\":[2,3],\"end\":[2,6]}},\"children\":[{\"patch\":{\"insert\":{\"children\":[],\"sourceRange\":[13,16],\"sourceSpan\":{\"start\":[2,3],\"end\":[2,6]}}}}],\"before\":{\"sourceRange\":[8,11],\"sourceSpan\":{\"start\":[2,1],\"end\":[2,4]}}}}],\"before\":{\"sourceRange\":[0,11],\"sourceSpan\":{\"start\":[1,1],\"end\":[2,4]}}}}],\"before\":{\"sourceRange\":[0,12],\"sourceSpan\":{\"start\":[1,1],\"end\":[3,1]}}}},\"oids\":[\"0000000000000000000000000000000000000000\",\"0000000000000000000000000000000000000000\"],\"paths\":[\"test/fixtures/ruby/method-declaration.A.rb\",\"test/fixtures/ruby/method-declaration.B.rb\"]}\n"
|
||||
sExpressionOutput = "(Program\n (Method\n (Empty)\n { (Identifier)\n ->(Identifier) }\n {+(Identifier)+}\n (\n {+(Identifier)+})))\n"
|
||||
tocOutput = "{\"changes\":{\"test/fixtures/ruby/method-declaration.A.rb -> test/fixtures/ruby/method-declaration.B.rb\":[{\"span\":{\"start\":[1,1],\"end\":[3,4]},\"category\":\"Method\",\"term\":\"bar\",\"changeType\":\"modified\"}]},\"errors\":{}}\n"
|
||||
|
||||
repo :: FilePath
|
||||
repo = "test/fixtures/git/examples/all-languages.git"
|
||||
|
@ -1,875 +0,0 @@
|
||||
var jQuery = (function() {
|
||||
|
||||
// Define a local copy of jQuery
|
||||
var jQuery = function( selector, context ) {
|
||||
// The jQuery object is actually just the init constructor 'enhanced'
|
||||
return new jQuery.fn.init( selector, context );
|
||||
},
|
||||
|
||||
// Map over jQuery in case of overwrite
|
||||
_jQuery = window.jQuery,
|
||||
|
||||
// Map over the $ in case of overwrite
|
||||
_$ = window.$,
|
||||
|
||||
// A central reference to the root jQuery(document)
|
||||
rootjQuery,
|
||||
|
||||
// A simple way to check for HTML strings or ID strings
|
||||
// (both of which we optimize for)
|
||||
quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,
|
||||
|
||||
// Is it a simple selector
|
||||
isSimple = /^.[^:#\[\.,]*$/,
|
||||
|
||||
// Check if a string has a non-whitespace character in it
|
||||
rnotwhite = /\S/,
|
||||
rwhite = /\s/,
|
||||
|
||||
// Used for trimming whitespace
|
||||
trimLeft = /^\s+/,
|
||||
trimRight = /\s+$/,
|
||||
|
||||
// Check for non-word characters
|
||||
rnonword = /\W/,
|
||||
|
||||
// Match a standalone tag
|
||||
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
|
||||
|
||||
// JSON RegExp
|
||||
rvalidchars = /^[\],:{}\s]*$/,
|
||||
rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
|
||||
rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
|
||||
rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
|
||||
|
||||
// Useragent RegExp
|
||||
rwebkit = /(webkit)[ \/]([\w.]+)/,
|
||||
ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
|
||||
rmsie = /(msie) ([\w.]+)/,
|
||||
rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
|
||||
|
||||
// Keep a UserAgent string for use with jQuery.browser
|
||||
userAgent = navigator.userAgent,
|
||||
|
||||
// For matching the engine and version of the browser
|
||||
browserMatch,
|
||||
|
||||
// Has the ready events already been bound?
|
||||
readyBound = false,
|
||||
|
||||
// The functions to execute on DOM ready
|
||||
readyList = [],
|
||||
|
||||
// The ready event handler
|
||||
DOMContentLoaded,
|
||||
|
||||
// Save a reference to some core methods
|
||||
toString = Object.prototype.toString,
|
||||
hasOwn = Object.prototype.hasOwnProperty,
|
||||
push = Array.prototype.push,
|
||||
slice = Array.prototype.slice,
|
||||
trim = String.prototype.trim,
|
||||
indexOf = Array.prototype.indexOf,
|
||||
|
||||
// [[Class]] -> type pairs
|
||||
class2type = {};
|
||||
|
||||
jQuery.fn = jQuery.prototype = {
|
||||
init: function( selector, context ) {
|
||||
var match, elem, ret, doc;
|
||||
|
||||
// Handle $(""), $(null), or $(undefined)
|
||||
if ( !selector ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
// Handle $(DOMElement)
|
||||
if ( selector.nodeType ) {
|
||||
this.context = this[0] = selector;
|
||||
this.length = 1;
|
||||
return this;
|
||||
}
|
||||
|
||||
// The body element only exists once, optimize finding it
|
||||
if ( selector === "body" && !context ) {
|
||||
this.context = document;
|
||||
this[0] = document.body;
|
||||
this.selector = "body";
|
||||
this.length = 1;
|
||||
return this;
|
||||
}
|
||||
|
||||
// Handle HTML strings
|
||||
if ( typeof selector === "string" ) {
|
||||
// Are we dealing with HTML string or an ID?
|
||||
match = quickExpr.exec( selector );
|
||||
|
||||
// Verify a match, and that no context was specified for #id
|
||||
if ( match && (match[1] || !context) ) {
|
||||
|
||||
// HANDLE: $(html) -> $(array)
|
||||
if ( match[1] ) {
|
||||
doc = (context ? context.ownerDocument || context : document);
|
||||
|
||||
// If a single string is passed in and it's a single tag
|
||||
// just do a createElement and skip the rest
|
||||
ret = rsingleTag.exec( selector );
|
||||
|
||||
if ( ret ) {
|
||||
if ( jQuery.isPlainObject( context ) ) {
|
||||
selector = [ document.createElement( ret[1] ) ];
|
||||
jQuery.fn.attr.call( selector, context, true );
|
||||
|
||||
} else {
|
||||
selector = [ doc.createElement( ret[1] ) ];
|
||||
}
|
||||
|
||||
} else {
|
||||
ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
|
||||
selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
|
||||
}
|
||||
|
||||
return jQuery.merge( this, selector );
|
||||
|
||||
// HANDLE: $("#id")
|
||||
} else {
|
||||
elem = document.getElementById( match[2] );
|
||||
|
||||
// Check parentNode to catch when Blackberry 4.6 returns
|
||||
// nodes that are no longer in the document #6963
|
||||
if ( elem && elem.parentNode ) {
|
||||
// Handle the case where IE and Opera return items
|
||||
// by name instead of ID
|
||||
if ( elem.id !== match[2] ) {
|
||||
return rootjQuery.find( selector );
|
||||
}
|
||||
|
||||
// Otherwise, we inject the element directly into the jQuery object
|
||||
this.length = 1;
|
||||
this[0] = elem;
|
||||
}
|
||||
|
||||
this.context = document;
|
||||
this.selector = selector;
|
||||
return this;
|
||||
}
|
||||
|
||||
// HANDLE: $("TAG")
|
||||
} else if ( !context && !rnonword.test( selector ) ) {
|
||||
this.selector = selector;
|
||||
this.context = document;
|
||||
selector = document.getElementsByTagName( selector );
|
||||
return jQuery.merge( this, selector );
|
||||
|
||||
// HANDLE: $(expr, $(...))
|
||||
} else if ( !context || context.jquery ) {
|
||||
return (context || rootjQuery).find( selector );
|
||||
|
||||
// HANDLE: $(expr, context)
|
||||
// (which is just equivalent to: $(context).find(expr)
|
||||
} else {
|
||||
return jQuery( context ).find( selector );
|
||||
}
|
||||
|
||||
// HANDLE: $(function)
|
||||
// Shortcut for document ready
|
||||
} else if ( jQuery.isFunction( selector ) ) {
|
||||
return rootjQuery.ready( selector );
|
||||
}
|
||||
|
||||
if (selector.selector !== undefined) {
|
||||
this.selector = selector.selector;
|
||||
this.context = selector.context;
|
||||
}
|
||||
|
||||
return jQuery.makeArray( selector, this );
|
||||
},
|
||||
|
||||
// Start with an empty selector
|
||||
selector: "",
|
||||
|
||||
// The current version of jQuery being used
|
||||
jquery: "@VERSION",
|
||||
|
||||
// The default length of a jQuery object is 0
|
||||
length: 0,
|
||||
|
||||
// The number of elements contained in the matched element set
|
||||
size: function() {
|
||||
return this.length;
|
||||
},
|
||||
|
||||
toArray: function() {
|
||||
return slice.call( this, 0 );
|
||||
},
|
||||
|
||||
// Get the Nth element in the matched element set OR
|
||||
// Get the whole matched element set as a clean array
|
||||
get: function( num ) {
|
||||
return num == null ?
|
||||
|
||||
// Return a 'clean' array
|
||||
this.toArray() :
|
||||
|
||||
// Return just the object
|
||||
( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
|
||||
},
|
||||
|
||||
// Take an array of elements and push it onto the stack
|
||||
// (returning the new matched element set)
|
||||
pushStack: function( elems, name, selector ) {
|
||||
// Build a new jQuery matched element set
|
||||
var ret = jQuery();
|
||||
|
||||
if ( jQuery.isArray( elems ) ) {
|
||||
push.apply( ret, elems );
|
||||
|
||||
} else {
|
||||
jQuery.merge( ret, elems );
|
||||
}
|
||||
|
||||
// Add the old object onto the stack (as a reference)
|
||||
ret.prevObject = this;
|
||||
|
||||
ret.context = this.context;
|
||||
|
||||
if ( name === "find" ) {
|
||||
ret.selector = this.selector + (this.selector ? " " : "") + selector;
|
||||
} else if ( name ) {
|
||||
ret.selector = this.selector + "." + name + "(" + selector + ")";
|
||||
}
|
||||
|
||||
// Return the newly-formed element set
|
||||
return ret;
|
||||
},
|
||||
|
||||
// Execute a callback for every element in the matched set.
|
||||
// (You can seed the arguments with an array of args, but this is
|
||||
// only used internally.)
|
||||
each: function( callback, args ) {
|
||||
return jQuery.each( this, callback, args );
|
||||
},
|
||||
|
||||
ready: function( fn ) {
|
||||
// Attach the listeners
|
||||
jQuery.bindReady();
|
||||
|
||||
// If the DOM is already ready
|
||||
if ( jQuery.isReady ) {
|
||||
// Execute the function immediately
|
||||
fn.call( document, jQuery );
|
||||
|
||||
// Otherwise, remember the function for later
|
||||
} else if ( readyList ) {
|
||||
// Add the function to the wait list
|
||||
readyList.push( fn );
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
eq: function( i ) {
|
||||
return i === -1 ?
|
||||
this.slice( i ) :
|
||||
this.slice( i, +i + 1 );
|
||||
},
|
||||
|
||||
first: function() {
|
||||
return this.eq( 0 );
|
||||
},
|
||||
|
||||
last: function() {
|
||||
return this.eq( -1 );
|
||||
},
|
||||
|
||||
slice: function() {
|
||||
return this.pushStack( slice.apply( this, arguments ),
|
||||
"slice", slice.call(arguments).join(",") );
|
||||
},
|
||||
|
||||
map: function( callback ) {
|
||||
return this.pushStack( jQuery.map(this, function( elem, i ) {
|
||||
return callback.call( elem, i, elem );
|
||||
}));
|
||||
},
|
||||
|
||||
end: function() {
|
||||
return this.prevObject || jQuery(null);
|
||||
},
|
||||
|
||||
// For internal use only.
|
||||
// Behaves like an Array's method, not like a jQuery method.
|
||||
push: push,
|
||||
sort: [].sort,
|
||||
splice: [].splice
|
||||
};
|
||||
|
||||
// Give the init function the jQuery prototype for later instantiation
|
||||
jQuery.fn.init.prototype = jQuery.fn;
|
||||
|
||||
jQuery.extend = jQuery.fn.extend = function() {
|
||||
// copy reference to target object
|
||||
var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy, copyIsArray;
|
||||
|
||||
// Handle a deep copy situation
|
||||
if ( typeof target === "boolean" ) {
|
||||
deep = target;
|
||||
target = arguments[1] || {};
|
||||
// skip the boolean and the target
|
||||
i = 2;
|
||||
}
|
||||
|
||||
// Handle case when target is a string or something (possible in deep copy)
|
||||
if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
|
||||
target = {};
|
||||
}
|
||||
|
||||
// extend jQuery itself if only one argument is passed
|
||||
if ( length === i ) {
|
||||
target = this;
|
||||
--i;
|
||||
}
|
||||
|
||||
for ( ; i < length; i++ ) {
|
||||
// Only deal with non-null/undefined values
|
||||
if ( (options = arguments[ i ]) != null ) {
|
||||
// Extend the base object
|
||||
for ( name in options ) {
|
||||
src = target[ name ];
|
||||
copy = options[ name ];
|
||||
|
||||
// Prevent never-ending loop
|
||||
if ( target === copy ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Recurse if we're merging plain objects or arrays
|
||||
if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
|
||||
if ( copyIsArray ) {
|
||||
copyIsArray = false;
|
||||
clone = src && jQuery.isArray(src) ? src : [];
|
||||
} else {
|
||||
clone = src && jQuery.isPlainObject(src) ? src : {};
|
||||
}
|
||||
|
||||
// Never move original objects, clone them
|
||||
target[ name ] = jQuery.extend( deep, clone, copy );
|
||||
|
||||
// Don't bring in undefined values
|
||||
} else if ( copy !== undefined ) {
|
||||
target[ name ] = copy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return the modified object
|
||||
return target;
|
||||
};
|
||||
|
||||
jQuery.extend({
|
||||
noConflict: function( deep ) {
|
||||
window.$ = _$;
|
||||
|
||||
if ( deep ) {
|
||||
window.jQuery = _jQuery;
|
||||
}
|
||||
|
||||
return jQuery;
|
||||
},
|
||||
|
||||
// Is the DOM ready to be used? Set to true once it occurs.
|
||||
isReady: false,
|
||||
|
||||
// A counter to track how many items to wait for before
|
||||
// the ready event fires. See #6781
|
||||
readyWait: 1,
|
||||
|
||||
// Handle when the DOM is ready
|
||||
ready: function( wait ) {
|
||||
// A third-party is pushing the ready event forwards
|
||||
if ( wait === true ) {
|
||||
jQuery.readyWait--;
|
||||
}
|
||||
|
||||
// Make sure that the DOM is not already loaded
|
||||
if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) {
|
||||
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
|
||||
if ( !document.body ) {
|
||||
return setTimeout( jQuery.ready, 13 );
|
||||
}
|
||||
|
||||
// Remember that the DOM is ready
|
||||
jQuery.isReady = true;
|
||||
|
||||
// If a normal DOM Ready event fired, decrement, and wait if need be
|
||||
if ( wait !== true && --jQuery.readyWait > 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If there are functions bound, to execute
|
||||
if ( readyList ) {
|
||||
// Execute all of them
|
||||
var fn, i = 0;
|
||||
while ( (fn = readyList[ i++ ]) ) {
|
||||
fn.call( document, jQuery );
|
||||
}
|
||||
|
||||
// Reset the list of functions
|
||||
readyList = null;
|
||||
}
|
||||
|
||||
// Trigger any bound ready events
|
||||
if ( jQuery.fn.triggerHandler ) {
|
||||
jQuery( document ).triggerHandler( "ready" );
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
bindReady: function() {
|
||||
if ( readyBound ) {
|
||||
return;
|
||||
}
|
||||
|
||||
readyBound = true;
|
||||
|
||||
// Catch cases where $(document).ready() is called after the
|
||||
// browser event has already occurred.
|
||||
if ( document.readyState === "complete" ) {
|
||||
return jQuery.ready();
|
||||
}
|
||||
|
||||
// Mozilla, Opera and webkit nightlies currently support this event
|
||||
if ( document.addEventListener ) {
|
||||
// Use the handy event callback
|
||||
document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
|
||||
|
||||
// A fallback to window.onload, that will always work
|
||||
window.addEventListener( "load", jQuery.ready, false );
|
||||
|
||||
// If IE event model is used
|
||||
} else if ( document.attachEvent ) {
|
||||
// ensure firing before onload,
|
||||
// maybe late but safe also for iframes
|
||||
document.attachEvent("onreadystatechange", DOMContentLoaded);
|
||||
|
||||
// A fallback to window.onload, that will always work
|
||||
window.attachEvent( "onload", jQuery.ready );
|
||||
|
||||
// If IE and not a frame
|
||||
// continually check to see if the document is ready
|
||||
var toplevel = false;
|
||||
|
||||
try {
|
||||
toplevel = window.frameElement == null;
|
||||
} catch(e) {}
|
||||
|
||||
if ( document.documentElement.doScroll && toplevel ) {
|
||||
doScrollCheck();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// See test/unit/core.js for details concerning isFunction.
|
||||
// Since version 1.3, DOM methods and functions like alert
|
||||
// aren't supported. They return false on IE (#2968).
|
||||
isFunction: function( obj ) {
|
||||
return jQuery.type(obj) === "function";
|
||||
},
|
||||
|
||||
isArray: Array.isArray || function( obj ) {
|
||||
return jQuery.type(obj) === "array";
|
||||
},
|
||||
|
||||
// A crude way of determining if an object is a window
|
||||
isWindow: function( obj ) {
|
||||
return obj && typeof obj === "object" && "setInterval" in obj;
|
||||
},
|
||||
|
||||
type: function( obj ) {
|
||||
return obj == null ?
|
||||
String( obj ) :
|
||||
class2type[ toString.call(obj) ] || "object";
|
||||
},
|
||||
|
||||
isPlainObject: function( obj ) {
|
||||
// Must be an Object.
|
||||
// Because of IE, we also have to check the presence of the constructor property.
|
||||
// Make sure that DOM nodes and window objects don't pass through, as well
|
||||
if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Not own constructor property must be Object
|
||||
if ( obj.constructor &&
|
||||
!hasOwn.call(obj, "constructor") &&
|
||||
!hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Own properties are enumerated firstly, so to speed up,
|
||||
// if last one is own, then all properties are own.
|
||||
|
||||
var key;
|
||||
for ( key in obj ) {}
|
||||
|
||||
return key === undefined || hasOwn.call( obj, key );
|
||||
},
|
||||
|
||||
isEmptyObject: function( obj ) {
|
||||
for ( var name in obj ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
error: function( msg ) {
|
||||
throw msg;
|
||||
},
|
||||
|
||||
parseJSON: function( data ) {
|
||||
if ( typeof data !== "string" || !data ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Make sure leading/trailing whitespace is removed (IE can't handle it)
|
||||
data = jQuery.trim( data );
|
||||
|
||||
// Make sure the incoming data is actual JSON
|
||||
// Logic borrowed from http://json.org/json2.js
|
||||
if ( rvalidchars.test(data.replace(rvalidescape, "@")
|
||||
.replace(rvalidtokens, "]")
|
||||
.replace(rvalidbraces, "")) ) {
|
||||
|
||||
// Try to use the native JSON parser first
|
||||
return window.JSON && window.JSON.parse ?
|
||||
window.JSON.parse( data ) :
|
||||
(new Function("return " + data))();
|
||||
|
||||
} else {
|
||||
jQuery.error( "Invalid JSON: " + data );
|
||||
}
|
||||
},
|
||||
|
||||
noop: function() {},
|
||||
|
||||
// Evalulates a script in a global context
|
||||
globalEval: function( data ) {
|
||||
if ( data && rnotwhite.test(data) ) {
|
||||
// Inspired by code by Andrea Giammarchi
|
||||
// http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
|
||||
var head = document.getElementsByTagName("head")[0] || document.documentElement,
|
||||
script = document.createElement("script");
|
||||
|
||||
script.type = "text/javascript";
|
||||
|
||||
if ( jQuery.support.scriptEval ) {
|
||||
script.appendChild( document.createTextNode( data ) );
|
||||
} else {
|
||||
script.text = data;
|
||||
}
|
||||
|
||||
// Use insertBefore instead of appendChild to circumvent an IE6 bug.
|
||||
// This arises when a base node is used (#2709).
|
||||
head.insertBefore( script, head.firstChild );
|
||||
head.removeChild( script );
|
||||
}
|
||||
},
|
||||
|
||||
nodeName: function( elem, name ) {
|
||||
return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
|
||||
},
|
||||
|
||||
// args is for internal usage only
|
||||
each: function( object, callback, args ) {
|
||||
var name, i = 0,
|
||||
length = object.length,
|
||||
isObj = length === undefined || jQuery.isFunction(object);
|
||||
|
||||
if ( args ) {
|
||||
if ( isObj ) {
|
||||
for ( name in object ) {
|
||||
if ( callback.apply( object[ name ], args ) === false ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for ( ; i < length; ) {
|
||||
if ( callback.apply( object[ i++ ], args ) === false ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A special, fast, case for the most common use of each
|
||||
} else {
|
||||
if ( isObj ) {
|
||||
for ( name in object ) {
|
||||
if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for ( var value = object[0];
|
||||
i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
|
||||
}
|
||||
}
|
||||
|
||||
return object;
|
||||
},
|
||||
|
||||
// Use native String.trim function wherever possible
|
||||
trim: trim ?
|
||||
function( text ) {
|
||||
return text == null ?
|
||||
"" :
|
||||
trim.call( text );
|
||||
} :
|
||||
|
||||
// Otherwise use our own trimming functionality
|
||||
function( text ) {
|
||||
return text == null ?
|
||||
"" :
|
||||
text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
|
||||
},
|
||||
|
||||
// results is for internal usage only
|
||||
makeArray: function( array, results ) {
|
||||
var ret = results || [];
|
||||
|
||||
if ( array != null ) {
|
||||
// The window, strings (and functions) also have 'length'
|
||||
// The extra typeof function check is to prevent crashes
|
||||
// in Safari 2 (See: #3039)
|
||||
// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
|
||||
var type = jQuery.type(array);
|
||||
|
||||
if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
|
||||
push.call( ret, array );
|
||||
} else {
|
||||
jQuery.merge( ret, array );
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
},
|
||||
|
||||
inArray: function( elem, array ) {
|
||||
if ( array.indexOf ) {
|
||||
return array.indexOf( elem );
|
||||
}
|
||||
|
||||
for ( var i = 0, length = array.length; i < length; i++ ) {
|
||||
if ( array[ i ] === elem ) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
},
|
||||
|
||||
merge: function( first, second ) {
|
||||
var i = first.length, j = 0;
|
||||
|
||||
if ( typeof second.length === "number" ) {
|
||||
for ( var l = second.length; j < l; j++ ) {
|
||||
first[ i++ ] = second[ j ];
|
||||
}
|
||||
|
||||
} else {
|
||||
while ( second[j] !== undefined ) {
|
||||
first[ i++ ] = second[ j++ ];
|
||||
}
|
||||
}
|
||||
|
||||
first.length = i;
|
||||
|
||||
return first;
|
||||
},
|
||||
|
||||
grep: function( elems, callback, inv ) {
|
||||
var ret = [], retVal;
|
||||
inv = !!inv;
|
||||
|
||||
// Go through the array, only saving the items
|
||||
// that pass the validator function
|
||||
for ( var i = 0, length = elems.length; i < length; i++ ) {
|
||||
retVal = !!callback( elems[ i ], i );
|
||||
if ( inv !== retVal ) {
|
||||
ret.push( elems[ i ] );
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
},
|
||||
|
||||
// arg is for internal usage only
|
||||
map: function( elems, callback, arg ) {
|
||||
var ret = [], value;
|
||||
|
||||
// Go through the array, translating each of the items to their
|
||||
// new value (or values).
|
||||
for ( var i = 0, length = elems.length; i < length; i++ ) {
|
||||
value = callback( elems[ i ], i, arg );
|
||||
|
||||
if ( value != null ) {
|
||||
ret[ ret.length ] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return ret.concat.apply( [], ret );
|
||||
},
|
||||
|
||||
// A global GUID counter for objects
|
||||
guid: 1,
|
||||
|
||||
proxy: function( fn, proxy, thisObject ) {
|
||||
if ( arguments.length === 2 ) {
|
||||
if ( typeof proxy === "string" ) {
|
||||
thisObject = fn;
|
||||
fn = thisObject[ proxy ];
|
||||
proxy = undefined;
|
||||
|
||||
} else if ( proxy && !jQuery.isFunction( proxy ) ) {
|
||||
thisObject = proxy;
|
||||
proxy = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !proxy && fn ) {
|
||||
proxy = function() {
|
||||
return fn.apply( thisObject || this, arguments );
|
||||
};
|
||||
}
|
||||
|
||||
// Set the guid of unique handler to the same of original handler, so it can be removed
|
||||
if ( fn ) {
|
||||
proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
|
||||
}
|
||||
|
||||
// So proxy can be declared as an argument
|
||||
return proxy;
|
||||
},
|
||||
|
||||
// Mutifunctional method to get and set values to a collection
|
||||
// The value/s can be optionally by executed if its a function
|
||||
access: function( elems, key, value, exec, fn, pass ) {
|
||||
var length = elems.length;
|
||||
|
||||
// Setting many attributes
|
||||
if ( typeof key === "object" ) {
|
||||
for ( var k in key ) {
|
||||
jQuery.access( elems, k, key[k], exec, fn, value );
|
||||
}
|
||||
return elems;
|
||||
}
|
||||
|
||||
// Setting one attribute
|
||||
if ( value !== undefined ) {
|
||||
// Optionally, function values get executed if exec is true
|
||||
exec = !pass && exec && jQuery.isFunction(value);
|
||||
|
||||
for ( var i = 0; i < length; i++ ) {
|
||||
fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
|
||||
}
|
||||
|
||||
return elems;
|
||||
}
|
||||
|
||||
// Getting an attribute
|
||||
return length ? fn( elems[0], key ) : undefined;
|
||||
},
|
||||
|
||||
now: function() {
|
||||
return (new Date()).getTime();
|
||||
},
|
||||
|
||||
// Use of jQuery.browser is frowned upon.
|
||||
// More details: http://docs.jquery.com/Utilities/jQuery.browser
|
||||
uaMatch: function( ua ) {
|
||||
ua = ua.toLowerCase();
|
||||
|
||||
var match = rwebkit.exec( ua ) ||
|
||||
ropera.exec( ua ) ||
|
||||
rmsie.exec( ua ) ||
|
||||
ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
|
||||
[];
|
||||
|
||||
return { browser: match[1] || "", version: match[2] || "0" };
|
||||
},
|
||||
|
||||
browser: {}
|
||||
});
|
||||
|
||||
// Populate the class2type map
|
||||
jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
|
||||
class2type[ "[object " + name + "]" ] = name.toLowerCase();
|
||||
});
|
||||
|
||||
browserMatch = jQuery.uaMatch( userAgent );
|
||||
if ( browserMatch.browser ) {
|
||||
jQuery.browser[ browserMatch.browser ] = true;
|
||||
jQuery.browser.version = browserMatch.version;
|
||||
}
|
||||
|
||||
// Deprecated, use jQuery.browser.webkit instead
|
||||
if ( jQuery.browser.webkit ) {
|
||||
jQuery.browser.safari = true;
|
||||
}
|
||||
|
||||
if ( indexOf ) {
|
||||
jQuery.inArray = function( elem, array ) {
|
||||
return indexOf.call( array, elem );
|
||||
};
|
||||
}
|
||||
|
||||
// Verify that \s matches non-breaking spaces
|
||||
// (IE fails on this test)
|
||||
if ( !rwhite.test( "\xA0" ) ) {
|
||||
trimLeft = /^[\s\xA0]+/;
|
||||
trimRight = /[\s\xA0]+$/;
|
||||
}
|
||||
|
||||
// All jQuery objects should point back to these
|
||||
rootjQuery = jQuery(document);
|
||||
|
||||
// Cleanup functions for the document ready method
|
||||
if ( document.addEventListener ) {
|
||||
DOMContentLoaded = function() {
|
||||
document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
|
||||
jQuery.ready();
|
||||
};
|
||||
|
||||
} else if ( document.attachEvent ) {
|
||||
DOMContentLoaded = function() {
|
||||
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
|
||||
if ( document.readyState === "complete" ) {
|
||||
document.detachEvent( "onreadystatechange", DOMContentLoaded );
|
||||
jQuery.ready();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// The DOM ready check for Internet Explorer
|
||||
function doScrollCheck() {
|
||||
if ( jQuery.isReady ) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// If IE is used, use the trick by Diego Perini
|
||||
// http://javascript.nwbox.com/IEContentLoaded/
|
||||
document.documentElement.doScroll("left");
|
||||
} catch(e) {
|
||||
setTimeout( doScrollCheck, 1 );
|
||||
return;
|
||||
}
|
||||
|
||||
// and execute any waiting functions
|
||||
jQuery.ready();
|
||||
}
|
||||
|
||||
// Expose jQuery to the global object
|
||||
return (window.jQuery = window.$ = jQuery);
|
||||
|
||||
})();
|
@ -1,863 +0,0 @@
|
||||
var jQuery = (function() {
|
||||
|
||||
// Define a local copy of jQuery
|
||||
var jQuery = function( selector, context ) {
|
||||
// The jQuery object is actually just the init constructor 'enhanced'
|
||||
return new jQuery.fn.init( selector, context );
|
||||
},
|
||||
|
||||
// Map over jQuery in case of overwrite
|
||||
_jQuery = window.jQuery,
|
||||
|
||||
// Map over the $ in case of overwrite
|
||||
_$ = window.$,
|
||||
|
||||
// A central reference to the root jQuery(document)
|
||||
rootjQuery,
|
||||
|
||||
// A simple way to check for HTML strings or ID strings
|
||||
// (both of which we optimize for)
|
||||
quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,
|
||||
|
||||
// Is it a simple selector
|
||||
isSimple = /^.[^:#\[\.,]*$/,
|
||||
|
||||
// Check if a string has a non-whitespace character in it
|
||||
rnotwhite = /\S/,
|
||||
rwhite = /\s/,
|
||||
|
||||
// Used for trimming whitespace
|
||||
trimLeft = /^\s+/,
|
||||
trimRight = /\s+$/,
|
||||
|
||||
// Check for non-word characters
|
||||
rnonword = /\W/,
|
||||
|
||||
// Match a standalone tag
|
||||
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
|
||||
|
||||
// JSON RegExp
|
||||
rvalidchars = /^[\],:{}\s]*$/,
|
||||
rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
|
||||
rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
|
||||
rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
|
||||
|
||||
// Useragent RegExp
|
||||
rwebkit = /(webkit)[ \/]([\w.]+)/,
|
||||
ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
|
||||
rmsie = /(msie) ([\w.]+)/,
|
||||
rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
|
||||
|
||||
// Keep a UserAgent string for use with jQuery.browser
|
||||
userAgent = navigator.userAgent,
|
||||
|
||||
// For matching the engine and version of the browser
|
||||
browserMatch,
|
||||
|
||||
// Has the ready events already been bound?
|
||||
readyBound = false,
|
||||
|
||||
// The functions to execute on DOM ready
|
||||
readyList = [],
|
||||
|
||||
// The ready event handler
|
||||
DOMContentLoaded,
|
||||
|
||||
// Save a reference to some core methods
|
||||
toString = Object.prototype.toString,
|
||||
hasOwn = Object.prototype.hasOwnProperty,
|
||||
push = Array.prototype.push,
|
||||
slice = Array.prototype.slice,
|
||||
trim = String.prototype.trim,
|
||||
indexOf = Array.prototype.indexOf;
|
||||
|
||||
jQuery.fn = jQuery.prototype = {
|
||||
init: function( selector, context ) {
|
||||
var match, elem, ret, doc;
|
||||
|
||||
// Handle $(""), $(null), or $(undefined)
|
||||
if ( !selector ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
// Handle $(DOMElement)
|
||||
if ( selector.nodeType ) {
|
||||
this.context = this[0] = selector;
|
||||
this.length = 1;
|
||||
return this;
|
||||
}
|
||||
|
||||
// The body element only exists once, optimize finding it
|
||||
if ( selector === "body" && !context ) {
|
||||
this.context = document;
|
||||
this[0] = document.body;
|
||||
this.selector = "body";
|
||||
this.length = 1;
|
||||
return this;
|
||||
}
|
||||
|
||||
// Handle HTML strings
|
||||
if ( typeof selector === "string" ) {
|
||||
// Are we dealing with HTML string or an ID?
|
||||
match = quickExpr.exec( selector );
|
||||
|
||||
// Verify a match, and that no context was specified for #id
|
||||
if ( match && (match[1] || !context) ) {
|
||||
|
||||
// HANDLE: $(html) -> $(array)
|
||||
if ( match[1] ) {
|
||||
doc = (context ? context.ownerDocument || context : document);
|
||||
|
||||
// If a single string is passed in and it's a single tag
|
||||
// just do a createElement and skip the rest
|
||||
ret = rsingleTag.exec( selector );
|
||||
|
||||
if ( ret ) {
|
||||
if ( jQuery.isPlainObject( context ) ) {
|
||||
selector = [ document.createElement( ret[1] ) ];
|
||||
jQuery.fn.attr.call( selector, context, true );
|
||||
|
||||
} else {
|
||||
selector = [ doc.createElement( ret[1] ) ];
|
||||
}
|
||||
|
||||
} else {
|
||||
ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
|
||||
selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
|
||||
}
|
||||
|
||||
return jQuery.merge( this, selector );
|
||||
|
||||
// HANDLE: $("#id")
|
||||
} else {
|
||||
elem = document.getElementById( match[2] );
|
||||
|
||||
// Check parentNode to catch when Blackberry 4.6 returns
|
||||
// nodes that are no longer in the document #6963
|
||||
if ( elem && elem.parentNode ) {
|
||||
// Handle the case where IE and Opera return items
|
||||
// by name instead of ID
|
||||
if ( elem.id !== match[2] ) {
|
||||
return rootjQuery.find( selector );
|
||||
}
|
||||
|
||||
// Otherwise, we inject the element directly into the jQuery object
|
||||
this.length = 1;
|
||||
this[0] = elem;
|
||||
}
|
||||
|
||||
this.context = document;
|
||||
this.selector = selector;
|
||||
return this;
|
||||
}
|
||||
|
||||
// HANDLE: $("TAG")
|
||||
} else if ( !context && !rnonword.test( selector ) ) {
|
||||
this.selector = selector;
|
||||
this.context = document;
|
||||
selector = document.getElementsByTagName( selector );
|
||||
return jQuery.merge( this, selector );
|
||||
|
||||
// HANDLE: $(expr, $(...))
|
||||
} else if ( !context || context.jquery ) {
|
||||
return (context || rootjQuery).find( selector );
|
||||
|
||||
// HANDLE: $(expr, context)
|
||||
// (which is just equivalent to: $(context).find(expr)
|
||||
} else {
|
||||
return jQuery( context ).find( selector );
|
||||
}
|
||||
|
||||
// HANDLE: $(function)
|
||||
// Shortcut for document ready
|
||||
} else if ( jQuery.isFunction( selector ) ) {
|
||||
return rootjQuery.ready( selector );
|
||||
}
|
||||
|
||||
if (selector.selector !== undefined) {
|
||||
this.selector = selector.selector;
|
||||
this.context = selector.context;
|
||||
}
|
||||
|
||||
return jQuery.makeArray( selector, this );
|
||||
},
|
||||
|
||||
// Start with an empty selector
|
||||
selector: "",
|
||||
|
||||
// The current version of jQuery being used
|
||||
jquery: "@VERSION",
|
||||
|
||||
// The default length of a jQuery object is 0
|
||||
length: 0,
|
||||
|
||||
// The number of elements contained in the matched element set
|
||||
size: function() {
|
||||
return this.length;
|
||||
},
|
||||
|
||||
toArray: function() {
|
||||
return slice.call( this, 0 );
|
||||
},
|
||||
|
||||
// Get the Nth element in the matched element set OR
|
||||
// Get the whole matched element set as a clean array
|
||||
get: function( num ) {
|
||||
return num == null ?
|
||||
|
||||
// Return a 'clean' array
|
||||
this.toArray() :
|
||||
|
||||
// Return just the object
|
||||
( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
|
||||
},
|
||||
|
||||
// Take an array of elements and push it onto the stack
|
||||
// (returning the new matched element set)
|
||||
pushStack: function( elems, name, selector ) {
|
||||
// Build a new jQuery matched element set
|
||||
var ret = jQuery();
|
||||
|
||||
if ( jQuery.isArray( elems ) ) {
|
||||
push.apply( ret, elems );
|
||||
|
||||
} else {
|
||||
jQuery.merge( ret, elems );
|
||||
}
|
||||
|
||||
// Add the old object onto the stack (as a reference)
|
||||
ret.prevObject = this;
|
||||
|
||||
ret.context = this.context;
|
||||
|
||||
if ( name === "find" ) {
|
||||
ret.selector = this.selector + (this.selector ? " " : "") + selector;
|
||||
} else if ( name ) {
|
||||
ret.selector = this.selector + "." + name + "(" + selector + ")";
|
||||
}
|
||||
|
||||
// Return the newly-formed element set
|
||||
return ret;
|
||||
},
|
||||
|
||||
// Execute a callback for every element in the matched set.
|
||||
// (You can seed the arguments with an array of args, but this is
|
||||
// only used internally.)
|
||||
each: function( callback, args ) {
|
||||
return jQuery.each( this, callback, args );
|
||||
},
|
||||
|
||||
ready: function( fn ) {
|
||||
// Attach the listeners
|
||||
jQuery.bindReady();
|
||||
|
||||
// If the DOM is already ready
|
||||
if ( jQuery.isReady ) {
|
||||
// Execute the function immediately
|
||||
fn.call( document, jQuery );
|
||||
|
||||
// Otherwise, remember the function for later
|
||||
} else if ( readyList ) {
|
||||
// Add the function to the wait list
|
||||
readyList.push( fn );
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
eq: function( i ) {
|
||||
return i === -1 ?
|
||||
this.slice( i ) :
|
||||
this.slice( i, +i + 1 );
|
||||
},
|
||||
|
||||
first: function() {
|
||||
return this.eq( 0 );
|
||||
},
|
||||
|
||||
last: function() {
|
||||
return this.eq( -1 );
|
||||
},
|
||||
|
||||
slice: function() {
|
||||
return this.pushStack( slice.apply( this, arguments ),
|
||||
"slice", slice.call(arguments).join(",") );
|
||||
},
|
||||
|
||||
map: function( callback ) {
|
||||
return this.pushStack( jQuery.map(this, function( elem, i ) {
|
||||
return callback.call( elem, i, elem );
|
||||
}));
|
||||
},
|
||||
|
||||
end: function() {
|
||||
return this.prevObject || jQuery(null);
|
||||
},
|
||||
|
||||
// For internal use only.
|
||||
// Behaves like an Array's method, not like a jQuery method.
|
||||
push: push,
|
||||
sort: [].sort,
|
||||
splice: [].splice
|
||||
};
|
||||
|
||||
// Give the init function the jQuery prototype for later instantiation
|
||||
jQuery.fn.init.prototype = jQuery.fn;
|
||||
|
||||
jQuery.extend = jQuery.fn.extend = function() {
|
||||
// copy reference to target object
|
||||
var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy;
|
||||
|
||||
// Handle a deep copy situation
|
||||
if ( typeof target === "boolean" ) {
|
||||
deep = target;
|
||||
target = arguments[1] || {};
|
||||
// skip the boolean and the target
|
||||
i = 2;
|
||||
}
|
||||
|
||||
// Handle case when target is a string or something (possible in deep copy)
|
||||
if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
|
||||
target = {};
|
||||
}
|
||||
|
||||
// extend jQuery itself if only one argument is passed
|
||||
if ( length === i ) {
|
||||
target = this;
|
||||
--i;
|
||||
}
|
||||
|
||||
for ( ; i < length; i++ ) {
|
||||
// Only deal with non-null/undefined values
|
||||
if ( (options = arguments[ i ]) != null ) {
|
||||
// Extend the base object
|
||||
for ( name in options ) {
|
||||
src = target[ name ];
|
||||
copy = options[ name ];
|
||||
|
||||
// Prevent never-ending loop
|
||||
if ( target === copy ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Recurse if we're merging object literal values or arrays
|
||||
if ( deep && copy && ( jQuery.isPlainObject(copy) || jQuery.isArray(copy) ) ) {
|
||||
var clone = src && ( jQuery.isPlainObject(src) || jQuery.isArray(src) ) ? src
|
||||
: jQuery.isArray(copy) ? [] : {};
|
||||
|
||||
// Never move original objects, clone them
|
||||
target[ name ] = jQuery.extend( deep, clone, copy );
|
||||
|
||||
// Don't bring in undefined values
|
||||
} else if ( copy !== undefined ) {
|
||||
target[ name ] = copy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return the modified object
|
||||
return target;
|
||||
};
|
||||
|
||||
jQuery.extend({
|
||||
noConflict: function( deep ) {
|
||||
window.$ = _$;
|
||||
|
||||
if ( deep ) {
|
||||
window.jQuery = _jQuery;
|
||||
}
|
||||
|
||||
return jQuery;
|
||||
},
|
||||
|
||||
// Is the DOM ready to be used? Set to true once it occurs.
|
||||
isReady: false,
|
||||
|
||||
// A counter to track how many items to wait for before
|
||||
// the ready event fires. See #6781
|
||||
readyWait: 1,
|
||||
|
||||
// Handle when the DOM is ready
|
||||
ready: function( wait ) {
|
||||
// A third-party is pushing the ready event forwards
|
||||
if ( wait === true ) {
|
||||
jQuery.readyWait--;
|
||||
}
|
||||
|
||||
// Make sure that the DOM is not already loaded
|
||||
if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) {
|
||||
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
|
||||
if ( !document.body ) {
|
||||
return setTimeout( jQuery.ready, 13 );
|
||||
}
|
||||
|
||||
// Remember that the DOM is ready
|
||||
jQuery.isReady = true;
|
||||
|
||||
// If a normal DOM Ready event fired, decrement, and wait if need be
|
||||
if ( wait !== true && --jQuery.readyWait > 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If there are functions bound, to execute
|
||||
if ( readyList ) {
|
||||
// Execute all of them
|
||||
var fn, i = 0;
|
||||
while ( (fn = readyList[ i++ ]) ) {
|
||||
fn.call( document, jQuery );
|
||||
}
|
||||
|
||||
// Reset the list of functions
|
||||
readyList = null;
|
||||
}
|
||||
|
||||
// Trigger any bound ready events
|
||||
if ( jQuery.fn.triggerHandler ) {
|
||||
jQuery( document ).triggerHandler( "ready" );
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
bindReady: function() {
|
||||
if ( readyBound ) {
|
||||
return;
|
||||
}
|
||||
|
||||
readyBound = true;
|
||||
|
||||
// Catch cases where $(document).ready() is called after the
|
||||
// browser event has already occurred.
|
||||
if ( document.readyState === "complete" ) {
|
||||
return jQuery.ready();
|
||||
}
|
||||
|
||||
// Mozilla, Opera and webkit nightlies currently support this event
|
||||
if ( document.addEventListener ) {
|
||||
// Use the handy event callback
|
||||
document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
|
||||
|
||||
// A fallback to window.onload, that will always work
|
||||
window.addEventListener( "load", jQuery.ready, false );
|
||||
|
||||
// If IE event model is used
|
||||
} else if ( document.attachEvent ) {
|
||||
// ensure firing before onload,
|
||||
// maybe late but safe also for iframes
|
||||
document.attachEvent("onreadystatechange", DOMContentLoaded);
|
||||
|
||||
// A fallback to window.onload, that will always work
|
||||
window.attachEvent( "onload", jQuery.ready );
|
||||
|
||||
// If IE and not a frame
|
||||
// continually check to see if the document is ready
|
||||
var toplevel = false;
|
||||
|
||||
try {
|
||||
toplevel = window.frameElement == null;
|
||||
} catch(e) {}
|
||||
|
||||
if ( document.documentElement.doScroll && toplevel ) {
|
||||
doScrollCheck();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// See test/unit/core.js for details concerning isFunction.
|
||||
// Since version 1.3, DOM methods and functions like alert
|
||||
// aren't supported. They return false on IE (#2968).
|
||||
isFunction: function( obj ) {
|
||||
return jQuery.type(obj) === "function";
|
||||
},
|
||||
|
||||
isArray: Array.isArray || function( obj ) {
|
||||
return jQuery.type(obj) === "array";
|
||||
},
|
||||
|
||||
// A crude way of determining if an object is a window
|
||||
isWindow: function( obj ) {
|
||||
return obj && typeof obj === "object" && "setInterval" in obj;
|
||||
},
|
||||
|
||||
type: function( obj ) {
|
||||
return obj == null ?
|
||||
String( obj ) :
|
||||
toString.call(obj).slice(8, -1).toLowerCase();
|
||||
},
|
||||
|
||||
isPlainObject: function( obj ) {
|
||||
// Must be an Object.
|
||||
// Because of IE, we also have to check the presence of the constructor property.
|
||||
// Make sure that DOM nodes and window objects don't pass through, as well
|
||||
if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Not own constructor property must be Object
|
||||
if ( obj.constructor &&
|
||||
!hasOwn.call(obj, "constructor") &&
|
||||
!hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Own properties are enumerated firstly, so to speed up,
|
||||
// if last one is own, then all properties are own.
|
||||
|
||||
var key;
|
||||
for ( key in obj ) {}
|
||||
|
||||
return key === undefined || hasOwn.call( obj, key );
|
||||
},
|
||||
|
||||
isEmptyObject: function( obj ) {
|
||||
for ( var name in obj ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
error: function( msg ) {
|
||||
throw msg;
|
||||
},
|
||||
|
||||
parseJSON: function( data ) {
|
||||
if ( typeof data !== "string" || !data ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Make sure leading/trailing whitespace is removed (IE can't handle it)
|
||||
data = jQuery.trim( data );
|
||||
|
||||
// Make sure the incoming data is actual JSON
|
||||
// Logic borrowed from http://json.org/json2.js
|
||||
if ( rvalidchars.test(data.replace(rvalidescape, "@")
|
||||
.replace(rvalidtokens, "]")
|
||||
.replace(rvalidbraces, "")) ) {
|
||||
|
||||
// Try to use the native JSON parser first
|
||||
return window.JSON && window.JSON.parse ?
|
||||
window.JSON.parse( data ) :
|
||||
(new Function("return " + data))();
|
||||
|
||||
} else {
|
||||
jQuery.error( "Invalid JSON: " + data );
|
||||
}
|
||||
},
|
||||
|
||||
noop: function() {},
|
||||
|
||||
// Evalulates a script in a global context
|
||||
globalEval: function( data ) {
|
||||
if ( data && rnotwhite.test(data) ) {
|
||||
// Inspired by code by Andrea Giammarchi
|
||||
// http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
|
||||
var head = document.getElementsByTagName("head")[0] || document.documentElement,
|
||||
script = document.createElement("script");
|
||||
|
||||
script.type = "text/javascript";
|
||||
|
||||
if ( jQuery.support.scriptEval ) {
|
||||
script.appendChild( document.createTextNode( data ) );
|
||||
} else {
|
||||
script.text = data;
|
||||
}
|
||||
|
||||
// Use insertBefore instead of appendChild to circumvent an IE6 bug.
|
||||
// This arises when a base node is used (#2709).
|
||||
head.insertBefore( script, head.firstChild );
|
||||
head.removeChild( script );
|
||||
}
|
||||
},
|
||||
|
||||
nodeName: function( elem, name ) {
|
||||
return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
|
||||
},
|
||||
|
||||
// args is for internal usage only
|
||||
each: function( object, callback, args ) {
|
||||
var name, i = 0,
|
||||
length = object.length,
|
||||
isObj = length === undefined || jQuery.isFunction(object);
|
||||
|
||||
if ( args ) {
|
||||
if ( isObj ) {
|
||||
for ( name in object ) {
|
||||
if ( callback.apply( object[ name ], args ) === false ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for ( ; i < length; ) {
|
||||
if ( callback.apply( object[ i++ ], args ) === false ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A special, fast, case for the most common use of each
|
||||
} else {
|
||||
if ( isObj ) {
|
||||
for ( name in object ) {
|
||||
if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for ( var value = object[0];
|
||||
i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
|
||||
}
|
||||
}
|
||||
|
||||
return object;
|
||||
},
|
||||
|
||||
// Use native String.trim function wherever possible
|
||||
trim: trim ?
|
||||
function( text ) {
|
||||
return text == null ?
|
||||
"" :
|
||||
trim.call( text );
|
||||
} :
|
||||
|
||||
// Otherwise use our own trimming functionality
|
||||
function( text ) {
|
||||
return text == null ?
|
||||
"" :
|
||||
text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
|
||||
},
|
||||
|
||||
// results is for internal usage only
|
||||
makeArray: function( array, results ) {
|
||||
var ret = results || [];
|
||||
|
||||
if ( array != null ) {
|
||||
// The window, strings (and functions) also have 'length'
|
||||
// The extra typeof function check is to prevent crashes
|
||||
// in Safari 2 (See: #3039)
|
||||
// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
|
||||
var type = jQuery.type(array);
|
||||
|
||||
if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
|
||||
push.call( ret, array );
|
||||
} else {
|
||||
jQuery.merge( ret, array );
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
},
|
||||
|
||||
inArray: function( elem, array ) {
|
||||
if ( array.indexOf ) {
|
||||
return array.indexOf( elem );
|
||||
}
|
||||
|
||||
for ( var i = 0, length = array.length; i < length; i++ ) {
|
||||
if ( array[ i ] === elem ) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
},
|
||||
|
||||
merge: function( first, second ) {
|
||||
var i = first.length, j = 0;
|
||||
|
||||
if ( typeof second.length === "number" ) {
|
||||
for ( var l = second.length; j < l; j++ ) {
|
||||
first[ i++ ] = second[ j ];
|
||||
}
|
||||
|
||||
} else {
|
||||
while ( second[j] !== undefined ) {
|
||||
first[ i++ ] = second[ j++ ];
|
||||
}
|
||||
}
|
||||
|
||||
first.length = i;
|
||||
|
||||
return first;
|
||||
},
|
||||
|
||||
grep: function( elems, callback, inv ) {
|
||||
var ret = [], retVal;
|
||||
inv = !!inv;
|
||||
|
||||
// Go through the array, only saving the items
|
||||
// that pass the validator function
|
||||
for ( var i = 0, length = elems.length; i < length; i++ ) {
|
||||
retVal = !!callback( elems[ i ], i );
|
||||
if ( inv !== retVal ) {
|
||||
ret.push( elems[ i ] );
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
},
|
||||
|
||||
// arg is for internal usage only
|
||||
map: function( elems, callback, arg ) {
|
||||
var ret = [], value;
|
||||
|
||||
// Go through the array, translating each of the items to their
|
||||
// new value (or values).
|
||||
for ( var i = 0, length = elems.length; i < length; i++ ) {
|
||||
value = callback( elems[ i ], i, arg );
|
||||
|
||||
if ( value != null ) {
|
||||
ret[ ret.length ] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return ret.concat.apply( [], ret );
|
||||
},
|
||||
|
||||
// A global GUID counter for objects
|
||||
guid: 1,
|
||||
|
||||
proxy: function( fn, proxy, thisObject ) {
|
||||
if ( arguments.length === 2 ) {
|
||||
if ( typeof proxy === "string" ) {
|
||||
thisObject = fn;
|
||||
fn = thisObject[ proxy ];
|
||||
proxy = undefined;
|
||||
|
||||
} else if ( proxy && !jQuery.isFunction( proxy ) ) {
|
||||
thisObject = proxy;
|
||||
proxy = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !proxy && fn ) {
|
||||
proxy = function() {
|
||||
return fn.apply( thisObject || this, arguments );
|
||||
};
|
||||
}
|
||||
|
||||
// Set the guid of unique handler to the same of original handler, so it can be removed
|
||||
if ( fn ) {
|
||||
proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
|
||||
}
|
||||
|
||||
// So proxy can be declared as an argument
|
||||
return proxy;
|
||||
},
|
||||
|
||||
// Mutifunctional method to get and set values to a collection
|
||||
// The value/s can be optionally by executed if its a function
|
||||
access: function( elems, key, value, exec, fn, pass ) {
|
||||
var length = elems.length;
|
||||
|
||||
// Setting many attributes
|
||||
if ( typeof key === "object" ) {
|
||||
for ( var k in key ) {
|
||||
jQuery.access( elems, k, key[k], exec, fn, value );
|
||||
}
|
||||
return elems;
|
||||
}
|
||||
|
||||
// Setting one attribute
|
||||
if ( value !== undefined ) {
|
||||
// Optionally, function values get executed if exec is true
|
||||
exec = !pass && exec && jQuery.isFunction(value);
|
||||
|
||||
for ( var i = 0; i < length; i++ ) {
|
||||
fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
|
||||
}
|
||||
|
||||
return elems;
|
||||
}
|
||||
|
||||
// Getting an attribute
|
||||
return length ? fn( elems[0], key ) : undefined;
|
||||
},
|
||||
|
||||
now: function() {
|
||||
return (new Date()).getTime();
|
||||
},
|
||||
|
||||
// Use of jQuery.browser is frowned upon.
|
||||
// More details: http://docs.jquery.com/Utilities/jQuery.browser
|
||||
uaMatch: function( ua ) {
|
||||
ua = ua.toLowerCase();
|
||||
|
||||
var match = rwebkit.exec( ua ) ||
|
||||
ropera.exec( ua ) ||
|
||||
rmsie.exec( ua ) ||
|
||||
ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
|
||||
[];
|
||||
|
||||
return { browser: match[1] || "", version: match[2] || "0" };
|
||||
},
|
||||
|
||||
browser: {}
|
||||
});
|
||||
|
||||
browserMatch = jQuery.uaMatch( userAgent );
|
||||
if ( browserMatch.browser ) {
|
||||
jQuery.browser[ browserMatch.browser ] = true;
|
||||
jQuery.browser.version = browserMatch.version;
|
||||
}
|
||||
|
||||
// Deprecated, use jQuery.browser.webkit instead
|
||||
if ( jQuery.browser.webkit ) {
|
||||
jQuery.browser.safari = true;
|
||||
}
|
||||
|
||||
if ( indexOf ) {
|
||||
jQuery.inArray = function( elem, array ) {
|
||||
return indexOf.call( array, elem );
|
||||
};
|
||||
}
|
||||
|
||||
// Verify that \s matches non-breaking spaces
|
||||
// (IE fails on this test)
|
||||
if ( !rwhite.test( "\xA0" ) ) {
|
||||
trimLeft = /^[\s\xA0]+/;
|
||||
trimRight = /[\s\xA0]+$/;
|
||||
}
|
||||
|
||||
// All jQuery objects should point back to these
|
||||
rootjQuery = jQuery(document);
|
||||
|
||||
// Cleanup functions for the document ready method
|
||||
if ( document.addEventListener ) {
|
||||
DOMContentLoaded = function() {
|
||||
document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
|
||||
jQuery.ready();
|
||||
};
|
||||
|
||||
} else if ( document.attachEvent ) {
|
||||
DOMContentLoaded = function() {
|
||||
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
|
||||
if ( document.readyState === "complete" ) {
|
||||
document.detachEvent( "onreadystatechange", DOMContentLoaded );
|
||||
jQuery.ready();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// The DOM ready check for Internet Explorer
|
||||
function doScrollCheck() {
|
||||
if ( jQuery.isReady ) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// If IE is used, use the trick by Diego Perini
|
||||
// http://javascript.nwbox.com/IEContentLoaded/
|
||||
document.documentElement.doScroll("left");
|
||||
} catch(e) {
|
||||
setTimeout( doScrollCheck, 1 );
|
||||
return;
|
||||
}
|
||||
|
||||
// and execute any waiting functions
|
||||
jQuery.ready();
|
||||
}
|
||||
|
||||
// Expose jQuery to the global object
|
||||
return (window.jQuery = window.$ = jQuery);
|
||||
|
||||
})();
|
@ -1,177 +0,0 @@
|
||||
define( [
|
||||
"../core",
|
||||
"../var/rnotwhite",
|
||||
"../data/var/dataPriv",
|
||||
"../core/init"
|
||||
], function( jQuery, rnotwhite, dataPriv ) {
|
||||
|
||||
var rclass = /[\t\r\n\f]/g;
|
||||
|
||||
function getClass( elem ) {
|
||||
return elem.getAttribute && elem.getAttribute( "class" ) || "";
|
||||
}
|
||||
|
||||
jQuery.fn.extend( {
|
||||
addClass: function( value ) {
|
||||
var classes, elem, cur, curValue, clazz, j, finalValue,
|
||||
i = 0;
|
||||
|
||||
if ( jQuery.isFunction( value ) ) {
|
||||
return this.each( function( j ) {
|
||||
jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
|
||||
} );
|
||||
}
|
||||
|
||||
if ( typeof value === "string" && value ) {
|
||||
classes = value.match( rnotwhite ) || [];
|
||||
|
||||
while ( ( elem = this[ i++ ] ) ) {
|
||||
curValue = getClass( elem );
|
||||
cur = elem.nodeType === 1 &&
|
||||
( " " + curValue + " " ).replace( rclass, " " );
|
||||
|
||||
if ( cur ) {
|
||||
j = 0;
|
||||
while ( ( clazz = classes[ j++ ] ) ) {
|
||||
if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
|
||||
cur += clazz + " ";
|
||||
}
|
||||
}
|
||||
|
||||
// Only assign if different to avoid unneeded rendering.
|
||||
finalValue = jQuery.trim( cur );
|
||||
if ( curValue !== finalValue ) {
|
||||
elem.setAttribute( "class", finalValue );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
removeClass: function( value ) {
|
||||
var classes, elem, cur, curValue, clazz, j, finalValue,
|
||||
i = 0;
|
||||
|
||||
if ( jQuery.isFunction( value ) ) {
|
||||
return this.each( function( j ) {
|
||||
jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
|
||||
} );
|
||||
}
|
||||
|
||||
if ( !arguments.length ) {
|
||||
return this.attr( "class", "" );
|
||||
}
|
||||
|
||||
if ( typeof value === "string" && value ) {
|
||||
classes = value.match( rnotwhite ) || [];
|
||||
|
||||
while ( ( elem = this[ i++ ] ) ) {
|
||||
curValue = getClass( elem );
|
||||
|
||||
// This expression is here for better compressibility (see addClass)
|
||||
cur = elem.nodeType === 1 &&
|
||||
( " " + curValue + " " ).replace( rclass, " " );
|
||||
|
||||
if ( cur ) {
|
||||
j = 0;
|
||||
while ( ( clazz = classes[ j++ ] ) ) {
|
||||
|
||||
// Remove *all* instances
|
||||
while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
|
||||
cur = cur.replace( " " + clazz + " ", " " );
|
||||
}
|
||||
}
|
||||
|
||||
// Only assign if different to avoid unneeded rendering.
|
||||
finalValue = jQuery.trim( cur );
|
||||
if ( curValue !== finalValue ) {
|
||||
elem.setAttribute( "class", finalValue );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
toggleClass: function( value, stateVal ) {
|
||||
var type = typeof value;
|
||||
|
||||
if ( typeof stateVal === "boolean" && type === "string" ) {
|
||||
return stateVal ? this.addClass( value ) : this.removeClass( value );
|
||||
}
|
||||
|
||||
if ( jQuery.isFunction( value ) ) {
|
||||
return this.each( function( i ) {
|
||||
jQuery( this ).toggleClass(
|
||||
value.call( this, i, getClass( this ), stateVal ),
|
||||
stateVal
|
||||
);
|
||||
} );
|
||||
}
|
||||
|
||||
return this.each( function() {
|
||||
var className, i, self, classNames;
|
||||
|
||||
if ( type === "string" ) {
|
||||
|
||||
// Toggle individual class names
|
||||
i = 0;
|
||||
self = jQuery( this );
|
||||
classNames = value.match( rnotwhite ) || [];
|
||||
|
||||
while ( ( className = classNames[ i++ ] ) ) {
|
||||
|
||||
// Check each className given, space separated list
|
||||
if ( self.hasClass( className ) ) {
|
||||
self.removeClass( className );
|
||||
} else {
|
||||
self.addClass( className );
|
||||
}
|
||||
}
|
||||
|
||||
// Toggle whole class name
|
||||
} else if ( value === undefined || type === "boolean" ) {
|
||||
className = getClass( this );
|
||||
if ( className ) {
|
||||
|
||||
// Store className if set
|
||||
dataPriv.set( this, "__className__", className );
|
||||
}
|
||||
|
||||
// If the element has a class name or if we're passed `false`,
|
||||
// then remove the whole classname (if there was one, the above saved it).
|
||||
// Otherwise bring back whatever was previously saved (if anything),
|
||||
// falling back to the empty string if nothing was stored.
|
||||
if ( this.setAttribute ) {
|
||||
this.setAttribute( "class",
|
||||
className || value === false ?
|
||||
"" :
|
||||
dataPriv.get( this, "__className__" ) || ""
|
||||
);
|
||||
}
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
hasClass: function( selector ) {
|
||||
var className, elem,
|
||||
i = 0;
|
||||
|
||||
className = " " + selector + " ";
|
||||
while ( ( elem = this[ i++ ] ) ) {
|
||||
if ( elem.nodeType === 1 &&
|
||||
( " " + getClass( elem ) + " " ).replace( rclass, " " )
|
||||
.indexOf( className ) > -1
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
|
||||
} );
|
@ -1,174 +0,0 @@
|
||||
define( [
|
||||
"../core",
|
||||
"../core/stripAndCollapse",
|
||||
"../var/rnothtmlwhite",
|
||||
"../data/var/dataPriv",
|
||||
"../core/init"
|
||||
], function( jQuery, stripAndCollapse, rnothtmlwhite, dataPriv ) {
|
||||
|
||||
"use strict";
|
||||
|
||||
function getClass( elem ) {
|
||||
return elem.getAttribute && elem.getAttribute( "class" ) || "";
|
||||
}
|
||||
|
||||
jQuery.fn.extend( {
|
||||
addClass: function( value ) {
|
||||
var classes, elem, cur, curValue, clazz, j, finalValue,
|
||||
i = 0;
|
||||
|
||||
if ( jQuery.isFunction( value ) ) {
|
||||
return this.each( function( j ) {
|
||||
jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
|
||||
} );
|
||||
}
|
||||
|
||||
if ( typeof value === "string" && value ) {
|
||||
classes = value.match( rnothtmlwhite ) || [];
|
||||
|
||||
while ( ( elem = this[ i++ ] ) ) {
|
||||
curValue = getClass( elem );
|
||||
cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
|
||||
|
||||
if ( cur ) {
|
||||
j = 0;
|
||||
while ( ( clazz = classes[ j++ ] ) ) {
|
||||
if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
|
||||
cur += clazz + " ";
|
||||
}
|
||||
}
|
||||
|
||||
// Only assign if different to avoid unneeded rendering.
|
||||
finalValue = stripAndCollapse( cur );
|
||||
if ( curValue !== finalValue ) {
|
||||
elem.setAttribute( "class", finalValue );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
removeClass: function( value ) {
|
||||
var classes, elem, cur, curValue, clazz, j, finalValue,
|
||||
i = 0;
|
||||
|
||||
if ( jQuery.isFunction( value ) ) {
|
||||
return this.each( function( j ) {
|
||||
jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
|
||||
} );
|
||||
}
|
||||
|
||||
if ( !arguments.length ) {
|
||||
return this.attr( "class", "" );
|
||||
}
|
||||
|
||||
if ( typeof value === "string" && value ) {
|
||||
classes = value.match( rnothtmlwhite ) || [];
|
||||
|
||||
while ( ( elem = this[ i++ ] ) ) {
|
||||
curValue = getClass( elem );
|
||||
|
||||
// This expression is here for better compressibility (see addClass)
|
||||
cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
|
||||
|
||||
if ( cur ) {
|
||||
j = 0;
|
||||
while ( ( clazz = classes[ j++ ] ) ) {
|
||||
|
||||
// Remove *all* instances
|
||||
while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
|
||||
cur = cur.replace( " " + clazz + " ", " " );
|
||||
}
|
||||
}
|
||||
|
||||
// Only assign if different to avoid unneeded rendering.
|
||||
finalValue = stripAndCollapse( cur );
|
||||
if ( curValue !== finalValue ) {
|
||||
elem.setAttribute( "class", finalValue );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
toggleClass: function( value, stateVal ) {
|
||||
var type = typeof value;
|
||||
|
||||
if ( typeof stateVal === "boolean" && type === "string" ) {
|
||||
return stateVal ? this.addClass( value ) : this.removeClass( value );
|
||||
}
|
||||
|
||||
if ( jQuery.isFunction( value ) ) {
|
||||
return this.each( function( i ) {
|
||||
jQuery( this ).toggleClass(
|
||||
value.call( this, i, getClass( this ), stateVal ),
|
||||
stateVal
|
||||
);
|
||||
} );
|
||||
}
|
||||
|
||||
return this.each( function() {
|
||||
var className, i, self, classNames;
|
||||
|
||||
if ( type === "string" ) {
|
||||
|
||||
// Toggle individual class names
|
||||
i = 0;
|
||||
self = jQuery( this );
|
||||
classNames = value.match( rnothtmlwhite ) || [];
|
||||
|
||||
while ( ( className = classNames[ i++ ] ) ) {
|
||||
|
||||
// Check each className given, space separated list
|
||||
if ( self.hasClass( className ) ) {
|
||||
self.removeClass( className );
|
||||
} else {
|
||||
self.addClass( className );
|
||||
}
|
||||
}
|
||||
|
||||
// Toggle whole class name
|
||||
} else if ( value === undefined || type === "boolean" ) {
|
||||
className = getClass( this );
|
||||
if ( className ) {
|
||||
|
||||
// Store className if set
|
||||
dataPriv.set( this, "__className__", className );
|
||||
}
|
||||
|
||||
// If the element has a class name or if we're passed `false`,
|
||||
// then remove the whole classname (if there was one, the above saved it).
|
||||
// Otherwise bring back whatever was previously saved (if anything),
|
||||
// falling back to the empty string if nothing was stored.
|
||||
if ( this.setAttribute ) {
|
||||
this.setAttribute( "class",
|
||||
className || value === false ?
|
||||
"" :
|
||||
dataPriv.get( this, "__className__" ) || ""
|
||||
);
|
||||
}
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
hasClass: function( selector ) {
|
||||
var className, elem,
|
||||
i = 0;
|
||||
|
||||
className = " " + selector + " ";
|
||||
while ( ( elem = this[ i++ ] ) ) {
|
||||
if ( elem.nodeType === 1 &&
|
||||
( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
|
||||
} );
|
@ -1,56 +0,0 @@
|
||||
// Use the right jQuery source on the test page (and iframes)
|
||||
( function() {
|
||||
/* global loadTests: false */
|
||||
|
||||
var path = window.location.pathname.split( "test" )[ 0 ],
|
||||
QUnit = window.QUnit || parent.QUnit,
|
||||
require = window.require || parent.require,
|
||||
|
||||
// Default to unminified jQuery for directly-opened iframes
|
||||
urlParams = QUnit ?
|
||||
QUnit.urlParams :
|
||||
{ dev: true },
|
||||
src = urlParams.dev ?
|
||||
"dist/jquery.js" :
|
||||
"dist/jquery.min.js";
|
||||
|
||||
// Define configuration parameters controlling how jQuery is loaded
|
||||
if ( QUnit ) {
|
||||
QUnit.config.urlConfig.push( {
|
||||
id: "amd",
|
||||
label: "Load with AMD",
|
||||
tooltip: "Load the AMD jQuery file (and its dependencies)"
|
||||
} );
|
||||
QUnit.config.urlConfig.push( {
|
||||
id: "dev",
|
||||
label: "Load unminified",
|
||||
tooltip: "Load the development (unminified) jQuery file"
|
||||
} );
|
||||
}
|
||||
|
||||
// Honor AMD loading on the main window (detected by seeing QUnit on it).
|
||||
// This doesn't apply to iframes because they synchronously expect jQuery to be there.
|
||||
if ( urlParams.amd && window.QUnit ) {
|
||||
require.config( {
|
||||
baseUrl: path
|
||||
} );
|
||||
src = "src/jquery";
|
||||
|
||||
// Include tests if specified
|
||||
if ( typeof loadTests !== "undefined" ) {
|
||||
require( [ src ], loadTests );
|
||||
} else {
|
||||
require( [ src ] );
|
||||
}
|
||||
|
||||
// Otherwise, load synchronously
|
||||
} else {
|
||||
document.write( "<script id='jquery-js' src='" + path + src + "'><\x2Fscript>" );
|
||||
|
||||
// Synchronous-only tests (other tests are loaded from the test page)
|
||||
if ( typeof loadTests !== "undefined" ) {
|
||||
document.write( "<script src='" + path + "test/unit/ready.js'><\x2Fscript>" );
|
||||
}
|
||||
}
|
||||
|
||||
} )();
|
@ -1,55 +0,0 @@
|
||||
// Use the right jQuery source on the test page (and iframes)
|
||||
( function() {
|
||||
/* global loadTests: false */
|
||||
|
||||
var src,
|
||||
path = window.location.pathname.split( "test" )[ 0 ],
|
||||
QUnit = window.QUnit || parent.QUnit,
|
||||
require = window.require || parent.require;
|
||||
|
||||
// iFrames won't load AMD (the iframe tests synchronously expect jQuery to be there)
|
||||
QUnit.config.urlConfig.push( {
|
||||
id: "amd",
|
||||
label: "Load with AMD",
|
||||
tooltip: "Load the AMD jQuery file (and its dependencies)"
|
||||
} );
|
||||
|
||||
// If QUnit is on window, this is the main window
|
||||
// This detection allows AMD tests to be run in an iframe
|
||||
if ( QUnit.urlParams.amd && window.QUnit ) {
|
||||
require.config( {
|
||||
baseUrl: path
|
||||
} );
|
||||
src = "src/jquery";
|
||||
|
||||
// Include tests if specified
|
||||
if ( typeof loadTests !== "undefined" ) {
|
||||
require( [ src ], loadTests );
|
||||
} else {
|
||||
require( [ src ] );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Config parameter to use minified jQuery
|
||||
QUnit.config.urlConfig.push( {
|
||||
id: "dev",
|
||||
label: "Load unminified",
|
||||
tooltip: "Load the development (unminified) jQuery file"
|
||||
} );
|
||||
if ( QUnit.urlParams.dev ) {
|
||||
src = "dist/jquery.js";
|
||||
} else {
|
||||
src = "dist/jquery.min.js";
|
||||
}
|
||||
|
||||
// Load jQuery
|
||||
document.write( "<script id='jquery-js' src='" + path + src + "'><\x2Fscript>" );
|
||||
|
||||
// Synchronous-only tests
|
||||
// Other tests are loaded from the test page
|
||||
if ( typeof loadTests !== "undefined" ) {
|
||||
document.write( "<script src='" + path + "test/unit/ready.js'><\x2Fscript>" );
|
||||
}
|
||||
|
||||
} )();
|
Loading…
Reference in New Issue
Block a user