├── outro.js ├── .gitignore ├── selector.js ├── var ├── arr.js ├── rnotwhite.js ├── push.js ├── class2type.js ├── concat.js ├── indexOf.js ├── slice.js ├── pnum.js ├── toString.js ├── hasOwn.js └── support.js ├── ajax ├── var │ ├── rquery.js │ └── nonce.js ├── parseJSON.js ├── parseXML.js ├── script.js ├── load.js ├── jsonp.js └── xhr.js ├── css ├── var │ ├── rmargin.js │ ├── cssExpand.js │ ├── rnumnonpx.js │ ├── isHidden.js │ └── getStyles.js ├── hiddenVisibleSelectors.js ├── addGetHookIf.js ├── swap.js ├── curCSS.js ├── defaultDisplay.js └── support.js ├── README.md ├── data ├── var │ ├── dataPriv.js │ └── dataUser.js ├── accepts.js └── Data.js ├── manipulation ├── var │ └── rcheckableType.js ├── _evalUrl.js └── support.js ├── traversing ├── var │ └── rneedsContext.js └── findFilter.js ├── core ├── var │ └── rsingleTag.js ├── parseHTML.js ├── access.js ├── ready.js └── init.js ├── event ├── support.js ├── ajax.js └── alias.js ├── attributes.js ├── effects ├── animatedSelector.js └── Tween.js ├── deprecated.js ├── selector-sizzle.js ├── .jshintrc ├── queue └── delay.js ├── exports ├── global.js └── amd.js ├── jquery.js ├── attributes ├── support.js ├── prop.js ├── attr.js ├── val.js └── classes.js ├── LICENSE ├── intro.js ├── wrap.js ├── dimensions.js ├── queue.js ├── serialize.js ├── traversing.js ├── selector-native.js ├── offset.js ├── deferred.js ├── data.js ├── callbacks.js ├── css.js ├── effects.js ├── manipulation.js └── core.js /outro.js: -------------------------------------------------------------------------------- 1 | })); 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # 只忽略dbg目录,不忽略dbg文件 2 | 3 | .idea/ -------------------------------------------------------------------------------- /selector.js: -------------------------------------------------------------------------------- 1 | define([ "./selector-sizzle" ]); 2 | -------------------------------------------------------------------------------- /var/arr.js: -------------------------------------------------------------------------------- 1 | define(function() { 2 | return []; 3 | }); 4 | -------------------------------------------------------------------------------- /ajax/var/rquery.js: -------------------------------------------------------------------------------- 1 | define(function() { 2 | return (/\?/); 3 | }); 4 | -------------------------------------------------------------------------------- /css/var/rmargin.js: -------------------------------------------------------------------------------- 1 | define(function() { 2 | return (/^margin/); 3 | }); 4 | -------------------------------------------------------------------------------- /var/rnotwhite.js: -------------------------------------------------------------------------------- 1 | define(function() { 2 | // 匹配空白字符 3 | return (/\S+/g); 4 | }); 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | jQuery_analysis_Chinese 2 | ======================= 3 | 4 | jQuery 2.1.1 源码分析 5 | -------------------------------------------------------------------------------- /var/push.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "./arr" 3 | ], function( arr ) { 4 | return arr.push; 5 | }); 6 | -------------------------------------------------------------------------------- /var/class2type.js: -------------------------------------------------------------------------------- 1 | define(function() { 2 | // [[Class]] -> type pairs 3 | return {}; 4 | }); 5 | -------------------------------------------------------------------------------- /var/concat.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "./arr" 3 | ], function( arr ) { 4 | return arr.concat; 5 | }); 6 | -------------------------------------------------------------------------------- /var/indexOf.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "./arr" 3 | ], function( arr ) { 4 | return arr.indexOf; 5 | }); 6 | -------------------------------------------------------------------------------- /var/slice.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "./arr" 3 | ], function( arr ) { 4 | return arr.slice; 5 | }); 6 | -------------------------------------------------------------------------------- /css/var/cssExpand.js: -------------------------------------------------------------------------------- 1 | define(function() { 2 | return [ "Top", "Right", "Bottom", "Left" ]; 3 | }); 4 | -------------------------------------------------------------------------------- /var/pnum.js: -------------------------------------------------------------------------------- 1 | define(function() { 2 | return (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source; 3 | }); 4 | -------------------------------------------------------------------------------- /data/var/dataPriv.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../Data" 3 | ], function( Data ) { 4 | return new Data(); 5 | }); 6 | -------------------------------------------------------------------------------- /data/var/dataUser.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../Data" 3 | ], function( Data ) { 4 | return new Data(); 5 | }); 6 | -------------------------------------------------------------------------------- /manipulation/var/rcheckableType.js: -------------------------------------------------------------------------------- 1 | define(function() { 2 | return (/^(?:checkbox|radio)$/i); 3 | }); 4 | -------------------------------------------------------------------------------- /ajax/var/nonce.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../../core" 3 | ], function( jQuery ) { 4 | return jQuery.now(); 5 | }); 6 | -------------------------------------------------------------------------------- /var/toString.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "./class2type" 3 | ], function( class2type ) { 4 | return class2type.toString; 5 | }); 6 | -------------------------------------------------------------------------------- /var/hasOwn.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "./class2type" 3 | ], function( class2type ) { 4 | return class2type.hasOwnProperty; 5 | }); 6 | -------------------------------------------------------------------------------- /var/support.js: -------------------------------------------------------------------------------- 1 | define(function() { 2 | // All support tests are defined in their respective modules. 3 | return {}; 4 | }); 5 | -------------------------------------------------------------------------------- /css/var/rnumnonpx.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../../var/pnum" 3 | ], function( pnum ) { 4 | return new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); 5 | }); 6 | -------------------------------------------------------------------------------- /traversing/var/rneedsContext.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../../core", 3 | "../../selector" 4 | ], function( jQuery ) { 5 | return jQuery.expr.match.needsContext; 6 | }); 7 | -------------------------------------------------------------------------------- /core/var/rsingleTag.js: -------------------------------------------------------------------------------- 1 | define(function() { 2 | // Match a standalone tag 3 | // 匹配独立的标签 4 | // 类似
或者
5 | return (/^<(\w+)\s*\/?>(?:<\/\1>|)$/); 6 | }); 7 | -------------------------------------------------------------------------------- /event/support.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../var/support" 3 | ], function( support ) { 4 | 5 | support.focusinBubbles = "onfocusin" in window; 6 | 7 | return support; 8 | 9 | }); 10 | -------------------------------------------------------------------------------- /attributes.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "./core", 3 | "./attributes/attr", 4 | "./attributes/prop", 5 | "./attributes/classes", 6 | "./attributes/val" 7 | ], function( jQuery ) { 8 | 9 | // Return jQuery for attributes-only inclusion 10 | return jQuery; 11 | }); 12 | -------------------------------------------------------------------------------- /ajax/parseJSON.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core" 3 | ], function( jQuery ) { 4 | 5 | // Support: Android 2.3 6 | // Workaround failure to string-cast null input 7 | jQuery.parseJSON = function( data ) { 8 | return JSON.parse( data + "" ); 9 | }; 10 | 11 | return jQuery.parseJSON; 12 | 13 | }); 14 | -------------------------------------------------------------------------------- /effects/animatedSelector.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "../selector", 4 | "../effects" 5 | ], function( jQuery ) { 6 | 7 | jQuery.expr.filters.animated = function( elem ) { 8 | return jQuery.grep(jQuery.timers, function( fn ) { 9 | return elem === fn.elem; 10 | }).length; 11 | }; 12 | 13 | }); 14 | -------------------------------------------------------------------------------- /deprecated.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "./core", 3 | "./traversing" 4 | ], function( jQuery ) { 5 | 6 | // The number of elements contained in the matched element set 7 | // 匹配的元素集合中包含的元素数量 8 | jQuery.fn.size = function() { 9 | return this.length; 10 | }; 11 | 12 | jQuery.fn.andSelf = jQuery.fn.addBack; 13 | 14 | }); 15 | -------------------------------------------------------------------------------- /manipulation/_evalUrl.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../ajax" 3 | ], function( jQuery ) { 4 | 5 | jQuery._evalUrl = function( url ) { 6 | return jQuery.ajax({ 7 | url: url, 8 | type: "GET", 9 | dataType: "script", 10 | async: false, 11 | global: false, 12 | "throws": true 13 | }); 14 | }; 15 | 16 | return jQuery._evalUrl; 17 | 18 | }); 19 | -------------------------------------------------------------------------------- /selector-sizzle.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "./core", 3 | "sizzle" 4 | ], function( jQuery, Sizzle ) { 5 | 6 | jQuery.find = Sizzle; 7 | jQuery.expr = Sizzle.selectors; 8 | jQuery.expr[":"] = jQuery.expr.pseudos; 9 | jQuery.unique = Sizzle.uniqueSort; 10 | jQuery.text = Sizzle.getText; 11 | jQuery.isXMLDoc = Sizzle.isXML; 12 | jQuery.contains = Sizzle.contains; 13 | 14 | }); 15 | -------------------------------------------------------------------------------- /event/ajax.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "../event" 4 | ], function( jQuery ) { 5 | 6 | // Attach a bunch of functions for handling common AJAX events 7 | jQuery.each([ 8 | "ajaxStart", 9 | "ajaxStop", 10 | "ajaxComplete", 11 | "ajaxError", 12 | "ajaxSuccess", 13 | "ajaxSend" 14 | ], function( i, type ) { 15 | jQuery.fn[ type ] = function( fn ) { 16 | return this.on( type, fn ); 17 | }; 18 | }); 19 | 20 | }); 21 | -------------------------------------------------------------------------------- /css/var/isHidden.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../../core", 3 | "../../selector" 4 | // css is assumed 5 | ], function( jQuery ) { 6 | 7 | return function( elem, el ) { 8 | // isHidden might be called from jQuery#filter function; 9 | // in that case, element will be second argument 10 | elem = el || elem; 11 | return jQuery.css( elem, "display" ) === "none" || 12 | !jQuery.contains( elem.ownerDocument, elem ); 13 | }; 14 | }); 15 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "boss": true, 3 | "curly": true, 4 | "eqeqeq": true, 5 | "eqnull": true, 6 | "expr": true, 7 | "immed": true, 8 | "noarg": true, 9 | "onevar": true, 10 | "quotmark": "double", 11 | "smarttabs": true, 12 | "trailing": true, 13 | "undef": true, 14 | "unused": true, 15 | 16 | "sub": true, 17 | 18 | "browser": true, 19 | 20 | "globals": { 21 | "jQuery": true, 22 | "define": true, 23 | "module": true, 24 | "noGlobal": true 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /css/var/getStyles.js: -------------------------------------------------------------------------------- 1 | define(function() { 2 | return function( elem ) { 3 | // Support: IE<=11+, Firefox<=30+ (#15098, #14150) 4 | // IE throws on elements created in popups 5 | // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" 6 | if ( elem.ownerDocument.defaultView.opener ) { 7 | return elem.ownerDocument.defaultView.getComputedStyle( elem, null ); 8 | } 9 | 10 | return window.getComputedStyle( elem, null ); 11 | }; 12 | }); 13 | -------------------------------------------------------------------------------- /data/accepts.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core" 3 | ], function( jQuery ) { 4 | 5 | /** 6 | * Determines whether an object can have data 7 | * 确定一个对象是否可以添加数据缓存 8 | */ 9 | jQuery.acceptData = function( owner ) { 10 | // Accepts only: 11 | // - Node 12 | // - Node.ELEMENT_NODE 13 | // - Node.DOCUMENT_NODE 14 | // - Object 15 | // - Any 16 | /* jshint -W018 */ 17 | 18 | // 仅接受 元素对象,文档对象以及js对象 19 | return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); 20 | }; 21 | 22 | return jQuery.acceptData; 23 | }); 24 | -------------------------------------------------------------------------------- /css/hiddenVisibleSelectors.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "../selector" 4 | ], function( jQuery ) { 5 | 6 | jQuery.expr.filters.hidden = function( elem ) { 7 | // Support: Opera <= 12.12 8 | // Opera reports offsetWidths and offsetHeights less than zero on some elements 9 | // Use OR instead of AND as the element is not visible if either is true 10 | // See tickets #10406 and #13132 11 | return elem.offsetWidth <= 0 || elem.offsetHeight <= 0; 12 | }; 13 | jQuery.expr.filters.visible = function( elem ) { 14 | return !jQuery.expr.filters.hidden( elem ); 15 | }; 16 | 17 | }); 18 | -------------------------------------------------------------------------------- /ajax/parseXML.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core" 3 | ], function( jQuery ) { 4 | 5 | // Cross-browser xml parsing 6 | jQuery.parseXML = function( data ) { 7 | var xml, tmp; 8 | if ( !data || typeof data !== "string" ) { 9 | return null; 10 | } 11 | 12 | // Support: IE9 13 | try { 14 | tmp = new DOMParser(); 15 | xml = tmp.parseFromString( data, "text/xml" ); 16 | } catch ( e ) { 17 | xml = undefined; 18 | } 19 | 20 | if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) { 21 | jQuery.error( "Invalid XML: " + data ); 22 | } 23 | return xml; 24 | }; 25 | 26 | return jQuery.parseXML; 27 | 28 | }); 29 | -------------------------------------------------------------------------------- /css/addGetHookIf.js: -------------------------------------------------------------------------------- 1 | define(function() { 2 | 3 | function addGetHookIf( conditionFn, hookFn ) { 4 | // Define the hook, we'll check on the first run if it's really needed. 5 | return { 6 | get: function() { 7 | if ( conditionFn() ) { 8 | // Hook not needed (or it's not possible to use it due 9 | // to missing dependency), remove it. 10 | delete this.get; 11 | return; 12 | } 13 | 14 | // Hook needed; redefine it so that the support test is not executed again. 15 | return (this.get = hookFn).apply( this, arguments ); 16 | } 17 | }; 18 | } 19 | 20 | return addGetHookIf; 21 | 22 | }); 23 | -------------------------------------------------------------------------------- /queue/delay.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "../queue", 4 | "../effects" // Delay is optional because of this dependency 5 | ], function( jQuery ) { 6 | 7 | // Based off of the plugin by Clint Helfers, with permission. 8 | // http://blindsignals.com/index.php/2009/07/jquery-delay/ 9 | jQuery.fn.delay = function( time, type ) { 10 | time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; 11 | type = type || "fx"; 12 | 13 | return this.queue( type, function( next, hooks ) { 14 | var timeout = setTimeout( next, time ); 15 | hooks.stop = function() { 16 | clearTimeout( timeout ); 17 | }; 18 | }); 19 | }; 20 | 21 | return jQuery.fn.delay; 22 | }); 23 | -------------------------------------------------------------------------------- /css/swap.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core" 3 | ], function( jQuery ) { 4 | 5 | // A method for quickly swapping in/out CSS properties to get correct calculations. 6 | jQuery.swap = function( elem, options, callback, args ) { 7 | var ret, name, 8 | old = {}; 9 | 10 | // Remember the old values, and insert the new ones 11 | for ( name in options ) { 12 | old[ name ] = elem.style[ name ]; 13 | elem.style[ name ] = options[ name ]; 14 | } 15 | 16 | ret = callback.apply( elem, args || [] ); 17 | 18 | // Revert the old values 19 | for ( name in options ) { 20 | elem.style[ name ] = old[ name ]; 21 | } 22 | 23 | return ret; 24 | }; 25 | 26 | return jQuery.swap; 27 | 28 | }); 29 | -------------------------------------------------------------------------------- /exports/global.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core" 3 | ], function( jQuery ) { 4 | 5 | var 6 | // Map over jQuery in case of overwrite 7 | _jQuery = window.jQuery, 8 | 9 | // Map over the $ in case of overwrite 10 | _$ = window.$; 11 | 12 | jQuery.noConflict = function( deep ) { 13 | if ( window.$ === jQuery ) { 14 | window.$ = _$; 15 | } 16 | 17 | if ( deep && window.jQuery === jQuery ) { 18 | window.jQuery = _jQuery; 19 | } 20 | 21 | return jQuery; 22 | }; 23 | 24 | // Expose jQuery and $ identifiers, even in AMD 25 | // (#7102#comment:10, https://github.com/jquery/jquery/pull/557) 26 | // and CommonJS for browser emulators (#13566) 27 | if ( !noGlobal ) { 28 | window.jQuery = window.$ = jQuery; 29 | } 30 | 31 | }); 32 | -------------------------------------------------------------------------------- /jquery.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "./core", 3 | "./selector", 4 | "./traversing", 5 | "./callbacks", 6 | "./deferred", 7 | "./core/ready", 8 | "./data", 9 | "./queue", 10 | "./queue/delay", 11 | "./attributes", 12 | "./event", 13 | "./event/alias", 14 | "./manipulation", 15 | "./manipulation/_evalUrl", 16 | "./wrap", 17 | "./css", 18 | "./css/hiddenVisibleSelectors", 19 | "./serialize", 20 | "./ajax", 21 | "./ajax/xhr", 22 | "./ajax/script", 23 | "./ajax/jsonp", 24 | "./ajax/load", 25 | "./event/ajax", 26 | "./effects", 27 | "./effects/animatedSelector", 28 | "./offset", 29 | "./dimensions", 30 | "./deprecated", 31 | "./exports/amd", 32 | "./exports/global" 33 | ], function( jQuery ) { 34 | 35 | return jQuery; 36 | 37 | }); 38 | -------------------------------------------------------------------------------- /attributes/support.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../var/support" 3 | ], function( support ) { 4 | 5 | (function() { 6 | var input = document.createElement( "input" ), 7 | select = document.createElement( "select" ), 8 | opt = select.appendChild( document.createElement( "option" ) ); 9 | 10 | input.type = "checkbox"; 11 | 12 | // Support: iOS<=5.1, Android<=4.2+ 13 | // Default value for a checkbox should be "on" 14 | support.checkOn = input.value !== ""; 15 | 16 | // Support: IE<=11+ 17 | // Must access selectedIndex to make default options select 18 | support.optSelected = opt.selected; 19 | 20 | // Support: Android<=2.3 21 | // Options inside disabled selects are incorrectly marked as disabled 22 | select.disabled = true; 23 | support.optDisabled = !opt.disabled; 24 | 25 | // Support: IE<=11+ 26 | // An input loses its value after becoming a radio 27 | input = document.createElement( "input" ); 28 | input.value = "t"; 29 | input.type = "radio"; 30 | support.radioValue = input.value === "t"; 31 | })(); 32 | 33 | return support; 34 | 35 | }); 36 | -------------------------------------------------------------------------------- /exports/amd.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core" 3 | ], function( jQuery ) { 4 | 5 | // Register as a named AMD module, since jQuery can be concatenated with other 6 | // files that may use define, but not via a proper concatenation script that 7 | // understands anonymous AMD modules. A named AMD is safest and most robust 8 | // way to register. Lowercase jquery is used because AMD module names are 9 | // derived from file names, and jQuery is normally delivered in a lowercase 10 | // file name. Do this after creating the global so that if an AMD module wants 11 | // to call noConflict to hide this version of jQuery, it will work. 12 | 13 | // Note that for maximum portability, libraries that are not jQuery should 14 | // declare themselves as anonymous modules, and avoid setting a global if an 15 | // AMD loader is present. jQuery is a special case. For more information, see 16 | // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon 17 | 18 | if ( typeof define === "function" && define.amd ) { 19 | define( "jquery", [], function() { 20 | return jQuery; 21 | }); 22 | } 23 | 24 | }); 25 | -------------------------------------------------------------------------------- /manipulation/support.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../var/support" 3 | ], function( support ) { 4 | 5 | (function() { 6 | var fragment = document.createDocumentFragment(), 7 | div = fragment.appendChild( document.createElement( "div" ) ), 8 | input = document.createElement( "input" ); 9 | 10 | // Support: Safari<=5.1 11 | // Check state lost if the name is set (#11217) 12 | // Support: Windows Web Apps (WWA) 13 | // `name` and `type` must use .setAttribute for WWA (#14901) 14 | input.setAttribute( "type", "radio" ); 15 | input.setAttribute( "checked", "checked" ); 16 | input.setAttribute( "name", "t" ); 17 | 18 | div.appendChild( input ); 19 | 20 | // Support: Safari<=5.1, Android<4.2 21 | // Older WebKit doesn't clone checked state correctly in fragments 22 | support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; 23 | 24 | // Support: IE<=11+ 25 | // Make sure textarea (and checkbox) defaultValue is properly cloned 26 | div.innerHTML = ""; 27 | support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; 28 | })(); 29 | 30 | return support; 31 | 32 | }); 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 bailnl 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /event/alias.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "../event" 4 | ], function( jQuery ) { 5 | 6 | jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + 7 | "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + 8 | "change select submit keydown keypress keyup error contextmenu").split(" "), 9 | function( i, name ) { 10 | 11 | // Handle event binding 12 | jQuery.fn[ name ] = function( data, fn ) { 13 | return arguments.length > 0 ? 14 | this.on( name, null, data, fn ) : 15 | this.trigger( name ); 16 | }; 17 | }); 18 | 19 | jQuery.fn.extend({ 20 | hover: function( fnOver, fnOut ) { 21 | return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); 22 | }, 23 | 24 | bind: function( types, data, fn ) { 25 | return this.on( types, null, data, fn ); 26 | }, 27 | unbind: function( types, fn ) { 28 | return this.off( types, null, fn ); 29 | }, 30 | 31 | delegate: function( selector, types, data, fn ) { 32 | return this.on( types, selector, data, fn ); 33 | }, 34 | undelegate: function( selector, types, fn ) { 35 | // ( namespace ) or ( selector, types [, fn] ) 36 | return arguments.length === 1 ? 37 | this.off( selector, "**" ) : 38 | this.off( types, selector || "**", fn ); 39 | } 40 | }); 41 | 42 | }); 43 | -------------------------------------------------------------------------------- /ajax/script.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "../ajax" 4 | ], function( jQuery ) { 5 | 6 | // Install script dataType 7 | jQuery.ajaxSetup({ 8 | accepts: { 9 | script: "text/javascript, application/javascript, " + 10 | "application/ecmascript, application/x-ecmascript" 11 | }, 12 | contents: { 13 | script: /(?:java|ecma)script/ 14 | }, 15 | converters: { 16 | "text script": function( text ) { 17 | jQuery.globalEval( text ); 18 | return text; 19 | } 20 | } 21 | }); 22 | 23 | // Handle cache's special case and crossDomain 24 | jQuery.ajaxPrefilter( "script", function( s ) { 25 | if ( s.cache === undefined ) { 26 | s.cache = false; 27 | } 28 | if ( s.crossDomain ) { 29 | s.type = "GET"; 30 | } 31 | }); 32 | 33 | // Bind script tag hack transport 34 | jQuery.ajaxTransport( "script", function( s ) { 35 | // This transport only deals with cross domain requests 36 | if ( s.crossDomain ) { 37 | var script, callback; 38 | return { 39 | send: function( _, complete ) { 40 | script = jQuery("