Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/advanced.../public/assets/js
File: frontend-picker.js
// Highlight elements in frontend, if local storage variable is set.
[0] Fix | Delete
jQuery( document ).ready( function () {
[1] Fix | Delete
[2] Fix | Delete
function is_enabled() {
[3] Fix | Delete
if ( ! advads.supports_localstorage() || ! localStorage.getItem( 'advads_frontend_picker' ) ) {
[4] Fix | Delete
return false;
[5] Fix | Delete
}
[6] Fix | Delete
[7] Fix | Delete
// Check if the frontend picker was started on the current blog.
[8] Fix | Delete
if ( window.advads_options.blog_id
[9] Fix | Delete
&& localStorage.getItem( 'advads_frontend_blog_id' )
[10] Fix | Delete
&& window.advads_options.blog_id !== localStorage.getItem( 'advads_frontend_blog_id' ) ) {
[11] Fix | Delete
return false;
[12] Fix | Delete
}
[13] Fix | Delete
[14] Fix | Delete
// Deactivate the frontend picker if it was started more than 45 minutes ago.
[15] Fix | Delete
if ( localStorage.getItem( 'advads_frontend_starttime' )
[16] Fix | Delete
&& parseInt( localStorage.getItem( 'advads_frontend_starttime' ), 10 ) < (
[17] Fix | Delete
new Date().getTime()
[18] Fix | Delete
) - 45 * 60 * 1000 ) {
[19] Fix | Delete
localStorage.removeItem( 'advads_frontend_action' );
[20] Fix | Delete
localStorage.removeItem( 'advads_frontend_element' );
[21] Fix | Delete
localStorage.removeItem( 'advads_frontend_picker' );
[22] Fix | Delete
localStorage.removeItem( 'advads_prev_url' );
[23] Fix | Delete
localStorage.removeItem( 'advads_frontend_pathtype' );
[24] Fix | Delete
localStorage.removeItem( 'advads_frontend_boundary' );
[25] Fix | Delete
localStorage.removeItem( 'advads_frontend_blog_id' );
[26] Fix | Delete
localStorage.removeItem( 'advads_frontend_starttime' );
[27] Fix | Delete
advads.set_cookie( 'advads_frontend_picker', '', - 1 );
[28] Fix | Delete
return false;
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
return true;
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
// only trigger if local storage is available
[35] Fix | Delete
if ( is_enabled() ) {
[36] Fix | Delete
var advads_picker_cur, advads_picker_overlay = jQuery( "<div id='advads-picker-overlay'>" ),
[37] Fix | Delete
advads_picker_no = [document.body, document.documentElement, document];
[38] Fix | Delete
advads_picker_overlay.css( {
[39] Fix | Delete
position: 'absolute', border: 'solid 2px #428bca',
[40] Fix | Delete
backgroundColor: 'rgba(66,139,202,0.5)', boxSizing: 'border-box',
[41] Fix | Delete
zIndex: 1000000, pointerEvents: 'none'
[42] Fix | Delete
} ).prependTo( 'body' );
[43] Fix | Delete
[44] Fix | Delete
if ( 'true' === localStorage.getItem( 'advads_frontend_boundary' ) ) {
[45] Fix | Delete
jQuery( 'body' ).css( 'cursor', 'not-allowed' );
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
/**
[49] Fix | Delete
* Check if we can traverse up the dom tree.
[50] Fix | Delete
*
[51] Fix | Delete
* We cannot use event delegation because:
[52] Fix | Delete
* - the content can be loaded via AJAX dynamically
[53] Fix | Delete
* - we cannot wrap the content in a `div` that represents post boundary
[54] Fix | Delete
* because that may prevent css rules from working
[55] Fix | Delete
*
[56] Fix | Delete
* @param HTMLElement The current element.
[57] Fix | Delete
* return bool
[58] Fix | Delete
*/
[59] Fix | Delete
window.advads.is_boundary_reached = function ( advads_picker_cur ) {
[60] Fix | Delete
if ( 'true' !== localStorage.getItem( 'advads_frontend_boundary' ) ) {
[61] Fix | Delete
return false;
[62] Fix | Delete
}
[63] Fix | Delete
$advads_picker_cur = jQuery( advads_picker_cur );
[64] Fix | Delete
// A boundary helper is the `ins` element inside of the post content
[65] Fix | Delete
// that is used to determine the post boundary (where the content starts and ends).
[66] Fix | Delete
var $boundary_helpers = jQuery( '.advads-frontend-picker-boundary-helper' );
[67] Fix | Delete
[68] Fix | Delete
$boundaries = $boundary_helpers.parent();
[69] Fix | Delete
$boundaries.css( 'cursor', 'pointer' );
[70] Fix | Delete
return $advads_picker_cur.is( $boundaries ) || ! $advads_picker_cur.closest( $boundaries ).length;
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
if ( 'xpath' === localStorage.getItem( 'advads_frontend_pathtype' ) ) {
[74] Fix | Delete
var fn = 'getXPath';
[75] Fix | Delete
} else {
[76] Fix | Delete
var fn = 'getPath';
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
jQuery( document ).mousemove( function ( e ) {
[80] Fix | Delete
if ( e.target === advads_picker_cur ) {
[81] Fix | Delete
return;
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
if ( ~ advads_picker_no.indexOf( e.target ) ) {
[85] Fix | Delete
advads_picker_cur = null;
[86] Fix | Delete
advads_picker_overlay.hide();
[87] Fix | Delete
return;
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
var target = jQuery( e.target ),
[91] Fix | Delete
offset = target.offset(),
[92] Fix | Delete
width = target.outerWidth(),
[93] Fix | Delete
height = target.outerHeight();
[94] Fix | Delete
[95] Fix | Delete
advads_picker_cur = e.target;
[96] Fix | Delete
[97] Fix | Delete
var path = jQuery( advads_picker_cur )[fn]();
[98] Fix | Delete
if ( ! path ) {
[99] Fix | Delete
// A click outside of the boundary.
[100] Fix | Delete
// @see `is_boundary_reached`.
[101] Fix | Delete
return;
[102] Fix | Delete
}
[103] Fix | Delete
// log path
[104] Fix | Delete
console.log( path );
[105] Fix | Delete
[106] Fix | Delete
advads_picker_overlay.css( {
[107] Fix | Delete
top: offset.top,
[108] Fix | Delete
left: offset.left,
[109] Fix | Delete
width: width,
[110] Fix | Delete
height: height
[111] Fix | Delete
} ).show();
[112] Fix | Delete
[113] Fix | Delete
} );
[114] Fix | Delete
// save on click
[115] Fix | Delete
jQuery( document ).click( function ( e ) {
[116] Fix | Delete
var path = jQuery( advads_picker_cur )[fn]();
[117] Fix | Delete
[118] Fix | Delete
if ( advads.is_boundary_reached( advads_picker_cur ) ) {
[119] Fix | Delete
return;
[120] Fix | Delete
}
[121] Fix | Delete
[122] Fix | Delete
localStorage.setItem( 'advads_frontend_element', path );
[123] Fix | Delete
window.location = localStorage.getItem( 'advads_prev_url' );
[124] Fix | Delete
} );
[125] Fix | Delete
};
[126] Fix | Delete
} );
[127] Fix | Delete
[128] Fix | Delete
/*
[129] Fix | Delete
Derrived from jQuery-GetPath v0.01, by Dave Cardwell. (2007-04-27)
[130] Fix | Delete
http://davecardwell.co.uk/javascript/jquery/plugins/jquery-getpath/
[131] Fix | Delete
Usage:
[132] Fix | Delete
var path = $('#foo').getPath();
[133] Fix | Delete
*/
[134] Fix | Delete
jQuery.fn.extend( {
[135] Fix | Delete
getPath: function ( path, depth ) {
[136] Fix | Delete
// The first time this function is called, path won't be defined.
[137] Fix | Delete
if ( typeof path === 'undefined' ) {
[138] Fix | Delete
path = '';
[139] Fix | Delete
}
[140] Fix | Delete
if ( typeof depth === 'undefined' ) {
[141] Fix | Delete
depth = 0;
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
// If this element is <html> we've reached the end of the path.
[145] Fix | Delete
// also end after 2 elements
[146] Fix | Delete
if ( this.is( 'html' ) ) {
[147] Fix | Delete
return 'html > ' + path;
[148] Fix | Delete
} else if ( 3 === depth ) {
[149] Fix | Delete
return path;
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
// Add the element name.
[153] Fix | Delete
var cur = this.get( 0 ).nodeName.toLowerCase();
[154] Fix | Delete
[155] Fix | Delete
// Determine the IDs and path.
[156] Fix | Delete
var el_id = this.attr( 'id' ),
[157] Fix | Delete
el_class = this.attr( 'class' );
[158] Fix | Delete
[159] Fix | Delete
depth = depth + 1;
[160] Fix | Delete
[161] Fix | Delete
// Add the #id if there is one. Ignore ID with number.
[162] Fix | Delete
if ( typeof el_id !== 'undefined' && ! /\d/.test( el_id ) ) {
[163] Fix | Delete
cur += '#' + el_id;
[164] Fix | Delete
} else if ( typeof el_class !== 'undefined' ) {
[165] Fix | Delete
// Add classes if there is no id.
[166] Fix | Delete
el_class = el_class.split( /[\s\n]+/ );
[167] Fix | Delete
// Skip classes with numbers.
[168] Fix | Delete
el_class = jQuery.grep( el_class, function ( element, index ) {
[169] Fix | Delete
return ! /\d/.test( element )
[170] Fix | Delete
} );
[171] Fix | Delete
// Add 2 classes.
[172] Fix | Delete
if ( el_class.length ) {
[173] Fix | Delete
cur += '.' + el_class.slice( 0, 2 ).join( '.' );
[174] Fix | Delete
}
[175] Fix | Delete
}
[176] Fix | Delete
[177] Fix | Delete
// add index if this element is not unique among its siblings
[178] Fix | Delete
if ( this.siblings( cur ).length ) {
[179] Fix | Delete
cur += ":eq(" + this.siblings( cur ).addBack().not( '#advads-picker-overlay' ).index( this ) + ")";
[180] Fix | Delete
}
[181] Fix | Delete
[182] Fix | Delete
// Recurse up the DOM.
[183] Fix | Delete
if ( path === '' ) {
[184] Fix | Delete
return this.parent().getPath( cur, depth );
[185] Fix | Delete
} else {
[186] Fix | Delete
return this.parent().getPath( cur + ' > ' + path, depth );
[187] Fix | Delete
}
[188] Fix | Delete
},
[189] Fix | Delete
[190] Fix | Delete
/**
[191] Fix | Delete
* Get XPath.
[192] Fix | Delete
*/
[193] Fix | Delete
getXPath: function ( path, depth ) {
[194] Fix | Delete
// The first time this function is called, path won't be defined.
[195] Fix | Delete
if ( typeof path === 'undefined' ) {
[196] Fix | Delete
path = '';
[197] Fix | Delete
}
[198] Fix | Delete
if ( typeof depth === 'undefined' ) {
[199] Fix | Delete
depth = 0;
[200] Fix | Delete
}
[201] Fix | Delete
[202] Fix | Delete
// If this element is <html> we've reached the end of the path.
[203] Fix | Delete
// also end after 2 elements
[204] Fix | Delete
if ( this.is( 'body' ) || 3 === depth ) {
[205] Fix | Delete
return path;
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
if ( advads.is_boundary_reached( this ) ) {
[209] Fix | Delete
return path;
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
// Add the element name.
[213] Fix | Delete
var tag = this.get( 0 ).nodeName.toLowerCase();
[214] Fix | Delete
var cur = tag;
[215] Fix | Delete
[216] Fix | Delete
// Determine the IDs and path.
[217] Fix | Delete
var el_id = this.attr( 'id' ),
[218] Fix | Delete
el_class = this.attr( 'class' );
[219] Fix | Delete
var classes = [];
[220] Fix | Delete
[221] Fix | Delete
// Add the #id if there is one. Ignore ID with number.
[222] Fix | Delete
if ( typeof el_id !== 'undefined' && ! /\d/.test( el_id ) ) {
[223] Fix | Delete
return cur + '[@id and id="' + el_id + '"]/' + path;
[224] Fix | Delete
} else if ( typeof el_class !== 'undefined' ) {
[225] Fix | Delete
// Add classes if there is no id.
[226] Fix | Delete
el_class = el_class.split( /[\s\n]+/ );
[227] Fix | Delete
// Skip classes with numbers.
[228] Fix | Delete
el_class = jQuery.grep( el_class, function ( element, index ) {
[229] Fix | Delete
return ! /\d/.test( element )
[230] Fix | Delete
} );
[231] Fix | Delete
// Add 2 classes.
[232] Fix | Delete
if ( el_class.length ) {
[233] Fix | Delete
depth = depth + 1;
[234] Fix | Delete
var classes = el_class.slice( 0, 2 );
[235] Fix | Delete
[236] Fix | Delete
var xpath_classes = [];
[237] Fix | Delete
for ( var i = 0, l = classes.length; i < l; i ++ ) {
[238] Fix | Delete
xpath_classes.push( '(@class and contains(concat(" ", normalize-space(@class), " "), " ' + classes[i] + ' "))' );
[239] Fix | Delete
}
[240] Fix | Delete
cur += '[' + xpath_classes.join( ' and ' ) + ']';
[241] Fix | Delete
}
[242] Fix | Delete
}
[243] Fix | Delete
[244] Fix | Delete
// Add index if this element is not unique among its siblings.
[245] Fix | Delete
if ( classes.length ) {
[246] Fix | Delete
var $siblings = this.siblings( tag + '.' + classes.join( '.' ) );
[247] Fix | Delete
} else {
[248] Fix | Delete
var $siblings = this.siblings( tag );
[249] Fix | Delete
}
[250] Fix | Delete
[251] Fix | Delete
if ( $siblings.length ) {
[252] Fix | Delete
var index = $siblings.addBack().not( '#advads-picker-overlay' ).index( this );
[253] Fix | Delete
cur += '[' + index + ']';
[254] Fix | Delete
}
[255] Fix | Delete
[256] Fix | Delete
// Recurse up the DOM.
[257] Fix | Delete
if ( path === '' ) {
[258] Fix | Delete
return this.parent().getXPath( cur, depth );
[259] Fix | Delete
} else {
[260] Fix | Delete
return this.parent().getXPath( cur + '/' + path, depth );
[261] Fix | Delete
}
[262] Fix | Delete
}
[263] Fix | Delete
} );
[264] Fix | Delete
[265] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function