patch_file/updatefiles/javascripts/jquery_prefix.js

99 lines
2.8 KiB
JavaScript

$.fn.size= function(){
return this.length;
}
$.fn.andSelf= function() {
return this.addBack.apply(this, arguments);
}
$.fn.find= function( selector ) {
var i, ret,
len = this.length,
self = this;
if ( typeof selector !== "string" ) {
return this.pushStack( jQuery( selector ).filter( function() {
for ( i = 0; i < len; i++ ) {
if ( jQuery.contains( self[ i ], this ) ) {
return true;
}
}
} ) );
}
ret = this.pushStack( [] );
if (selector != '\#'){
for ( i = 0; i < len; i++ ) {
jQuery.find( selector, self[ i ], ret );
}
}
else{
jQuery.find( document, self[ i ], ret );
}
return len > 1 ? jQuery.uniqueSort( ret ) : ret;
}
$.event.props = ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " +
"metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " )
$.fn.load= function( url, params, callback ){
if (typeof url != 'string'){
callback = url;
return this.on( 'load',null, this, callback);
}
else{
var selector, type, response,
self = this,
off = url.indexOf( " " );
if ( off > -1 ) {
selector = jQuery.trim( url.slice( off, url.length ) );
url = url.slice( 0, off );
}
if ( jQuery.isFunction( params ) ) {
callback = params;
params = undefined;
} else if ( params && typeof params === "object" ) {
type = "POST";
}
jQuery.ajax( {
url: url,
type: type || "GET",
dataType: "html",
data: params
} ).done( function( responseText ) {
response = arguments;
self.html( selector ? jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) : responseText );
} ).always( callback && function( jqXHR, status ) {
self.each( function() {
callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
} );
} );
}
}
function migrateWarnFunc( obj, prop, newFunc, msg ) {
obj[ prop ] = function() {
return newFunc.apply( this, arguments );
};
}
if ( jQuery.ajax ) {
var oldAjax = jQuery.ajax;
jQuery.ajax = function( ) {
var jQXHR = oldAjax.apply( this, arguments );
// Be sure we got a jQXHR (e.g., not sync)
if ( jQXHR.promise ) {
migrateWarnFunc( jQXHR, "success", jQXHR.done,
"jQXHR.success is deprecated and removed" );
migrateWarnFunc( jQXHR, "error", jQXHR.fail,
"jQXHR.error is deprecated and removed" );
migrateWarnFunc( jQXHR, "complete", jQXHR.always,
"jQXHR.complete is deprecated and removed" );
}
return jQXHR;
};
}
$(function(){
$('input[type!="checkbox"],textarea').not('[type="submit"],[type=radio]').on('focus', function() {
$([document.documentElement, document.body]).animate({
scrollTop: $(this).offset().top -200
}, 100);
});
$.each($('input[type="text"][placeholder]'),function(i,v){
if (!$(this).attr('title')){
$(this).attr('title',$(this).attr('placeholder'))
}
})
})