@@ -909,25 +909,55 @@ export namespace m$ {
909
909
* @param index A zero-based integer indicating which element to retrieve.
910
910
*/
911
911
public get ( index ?: number ) : HTMLElement [ ] | HTMLElement {
912
- if ( ! isSet ( index ) ) { return makeArray ( this ) ; }
913
- if ( index < 0 ) { index = this . length + index ; }
914
- return index >= 0 && index < this . length ? this [ index ] : void 0 ;
912
+ if ( ! isSet ( index ) ) { return makeArray ( this ) }
913
+ if ( index < 0 ) { index = this . length + index }
914
+ return index < this . length ? this [ index ] : void 0 ;
915
915
}
916
916
917
+ public width ( ) : number ;
917
918
public width ( value ?) : mQuery | number {
918
919
return size ( this , 'Width' , value ) ;
919
920
}
920
921
922
+ public height ( ) : number ;
921
923
public height ( value ?) : mQuery | number {
922
924
return size ( this , 'Height' , value ) ;
923
925
}
924
926
927
+
928
+ public load ( url : string ) : this;
929
+ public load ( url : string , complete : AJAXSuccess ) : this;
930
+ public load ( url : string , data : any , complete : AJAXSuccess ) : this;
931
+ public load ( url , dataOrComplete ?, complete ?) : this {
932
+ // If instance is empty, just return
933
+ if ( isEmpty ( this ) ) { return this }
934
+
935
+ // Get parameters
936
+ let data = dataOrComplete ;
937
+ if ( ! isSet ( complete ) ) {
938
+ complete = dataOrComplete ;
939
+ data = void 0 ;
940
+ }
941
+
942
+ // Get selector with the url (if exists)
943
+ let matches = url . trim ( ) . match ( / ^ ( [ ^ \s ] + ) \s ? ( .* ) $ / ) ,
944
+ selector = matches [ 2 ] ;
945
+ url = matches [ 1 ] ;
946
+
947
+ // Request url with data
948
+ m$ . get ( url , data , ( data ) => {
949
+ if ( selector ) { data = m$ ( data ) . filter ( selector ) }
950
+ this . empty ( ) . append ( data ) ;
951
+ } ) . allways ( complete ) ;
952
+ return this ;
953
+ }
954
+
925
955
/**
926
956
* Merge the contents of an object onto the mQuery prototype to provide new mQuery instance methods.
927
957
* @param obj An object to merge onto the jQuery prototype.
928
958
*/
929
959
public extend ( obj : Object ) : void {
930
- each ( obj , ( key , value ) => { fn [ key ] = value } ) ;
960
+ each ( obj , ( key , value ) => { fn [ key ] = value } ) ;
931
961
}
932
962
}
933
963
0 commit comments