fix jquery library vulnary
This commit is contained in:
parent
18322b883e
commit
a43eaf4215
|
@ -46,7 +46,11 @@ all_template.each do |folder|
|
||||||
filename = folder+'partial/_head.html.erb'
|
filename = folder+'partial/_head.html.erb'
|
||||||
texts = File.read(filename).force_encoding('UTF-8')
|
texts = File.read(filename).force_encoding('UTF-8')
|
||||||
new_texts = texts.gsub(/<.*javascript_include_tag.*bootstrap.*>/,"<%= javascript_include_tag \"bootstrap.min\"%>")
|
new_texts = texts.gsub(/<.*javascript_include_tag.*bootstrap.*>/,"<%= javascript_include_tag \"bootstrap.min\"%>")
|
||||||
|
if new_texts.scan('jquery_prefix').length>0
|
||||||
new_texts = new_texts.gsub(/<.*javascript_include_tag.*\/jquery\.min.*>|<.*javascript_include_tag.*\/jquery-1\.11\.0\.min.*>/,"<%= javascript_include_tag \"jquery.min\"%>")
|
new_texts = new_texts.gsub(/<.*javascript_include_tag.*\/jquery\.min.*>|<.*javascript_include_tag.*\/jquery-1\.11\.0\.min.*>/,"<%= javascript_include_tag \"jquery.min\"%>")
|
||||||
|
else
|
||||||
|
new_texts = new_texts.gsub(/<.*javascript_include_tag.*\/jquery\.min.*>|<.*javascript_include_tag.*\/jquery-1\.11\.0\.min.*>/,"<%= javascript_include_tag \"jquery.min\"%><%= javascript_include_tag \"jquery_prefix\"%>")
|
||||||
|
end
|
||||||
if texts != new_texts
|
if texts != new_texts
|
||||||
File.open(filename,'w') do |f|
|
File.open(filename,'w') do |f|
|
||||||
f.write new_texts
|
f.write new_texts
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,94 @@
|
||||||
|
$.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;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue