scratch – Diff between revs 58 and 125

Subversion Repositories:
Rev:
Show entire fileRegard whitespace
Rev 58 Rev 125
Line 1... Line 1...
1 define( [ 1 define([
2 "../core", 2 "../core",
3 "../core/stripAndCollapse", -  
4 "../core/parseHTML", 3 "../core/parseHTML",
5 "../ajax", 4 "../ajax",
6 "../traversing", 5 "../traversing",
7 "../manipulation", 6 "../manipulation",
8 "../selector" 7 "../selector",
-   8 // Optional event/alias dependency
-   9 "../event/alias"
9 ], function( jQuery, stripAndCollapse ) { 10 ], function( jQuery ) {
Line -... Line 11...
-   11  
10   12 // Keep a copy of the old load method
Line 11... Line 13...
11 "use strict"; 13 var _load = jQuery.fn.load;
12   14  
13 /** 15 /**
14 * Load a url into a page 16 * Load a url into a page
-   17 */
-   18 jQuery.fn.load = function( url, params, callback ) {
-   19 if ( typeof url !== "string" && _load ) {
-   20 return _load.apply( this, arguments );
15 */ 21 }
16 jQuery.fn.load = function( url, params, callback ) { 22  
17 var selector, type, response, 23 var selector, type, response,
Line 18... Line 24...
18 self = this, 24 self = this,
19 off = url.indexOf( " " ); 25 off = url.indexOf(" ");
20   26  
21 if ( off > -1 ) { 27 if ( off >= 0 ) {
Line 22... Line 28...
22 selector = stripAndCollapse( url.slice( off ) ); 28 selector = jQuery.trim( url.slice( off ) );
23 url = url.slice( 0, off ); 29 url = url.slice( 0, off );
Line 38... Line 44...
38 // If we have elements to modify, make the request 44 // If we have elements to modify, make the request
39 if ( self.length > 0 ) { 45 if ( self.length > 0 ) {
40 jQuery.ajax( { 46 jQuery.ajax({
41 url: url, 47 url: url,
Line 42... Line 48...
42   48  
43 // If "type" variable is undefined, then "GET" method will be used. -  
44 // Make value of this field explicit since -  
45 // user can override it through ajaxSetup method 49 // if "type" variable is undefined, then "GET" method will be used
46 type: type || "GET", 50 type: type,
47 dataType: "html", 51 dataType: "html",
48 data: params 52 data: params
Line 49... Line 53...
49 } ).done( function( responseText ) { 53 }).done(function( responseText ) {
Line 58... Line 62...
58 jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) : 62 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
Line 59... Line 63...
59   63  
60 // Otherwise use the full result 64 // Otherwise use the full result
Line 61... Line -...
61 responseText ); -  
62   -  
63 // If the request succeeds, this function gets "data", "status", "jqXHR" -  
64 // but they are ignored because response was set above. 65 responseText );
65 // If it fails, this function gets "jqXHR", "status", "error" -  
66 } ).always( callback && function( jqXHR, status ) { 66  
67 self.each( function() { -  
68 callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] ); 67 }).complete( callback && function( jqXHR, status ) {
69 } ); 68 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
Line 70... Line 69...
70 } ); 69 });
71 } 70 }