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/popup-ma.../trunk/assets/js
File: admin-bar.js
/**
[0] Fix | Delete
* CssSelectorGenerator
[1] Fix | Delete
*/
[2] Fix | Delete
(function () {
[3] Fix | Delete
var CssSelectorGenerator, root,
[4] Fix | Delete
indexOf = [].indexOf || function (item) {
[5] Fix | Delete
for (var i = 0, l = this.length; i < l; i++) {
[6] Fix | Delete
if (i in this && this[i] === item) return i;
[7] Fix | Delete
}
[8] Fix | Delete
return -1;
[9] Fix | Delete
};
[10] Fix | Delete
[11] Fix | Delete
CssSelectorGenerator = (function () {
[12] Fix | Delete
CssSelectorGenerator.prototype.default_options = {
[13] Fix | Delete
selectors: ['id', 'class', 'tag', 'nthchild']
[14] Fix | Delete
};
[15] Fix | Delete
[16] Fix | Delete
function CssSelectorGenerator(options) {
[17] Fix | Delete
if (options == null) {
[18] Fix | Delete
options = {};
[19] Fix | Delete
}
[20] Fix | Delete
this.options = {};
[21] Fix | Delete
this.setOptions(this.default_options);
[22] Fix | Delete
this.setOptions(options);
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
CssSelectorGenerator.prototype.setOptions = function (options) {
[26] Fix | Delete
var key, results, val;
[27] Fix | Delete
if (options == null) {
[28] Fix | Delete
options = {};
[29] Fix | Delete
}
[30] Fix | Delete
results = [];
[31] Fix | Delete
for (key in options) {
[32] Fix | Delete
val = options[key];
[33] Fix | Delete
if (this.default_options.hasOwnProperty(key)) {
[34] Fix | Delete
results.push(this.options[key] = val);
[35] Fix | Delete
} else {
[36] Fix | Delete
results.push(void 0);
[37] Fix | Delete
}
[38] Fix | Delete
}
[39] Fix | Delete
return results;
[40] Fix | Delete
};
[41] Fix | Delete
[42] Fix | Delete
CssSelectorGenerator.prototype.isElement = function (element) {
[43] Fix | Delete
return !!((element != null ? element.nodeType : void 0) === 1);
[44] Fix | Delete
};
[45] Fix | Delete
[46] Fix | Delete
CssSelectorGenerator.prototype.getParents = function (element) {
[47] Fix | Delete
var current_element, result;
[48] Fix | Delete
result = [];
[49] Fix | Delete
if (this.isElement(element)) {
[50] Fix | Delete
current_element = element;
[51] Fix | Delete
while (this.isElement(current_element)) {
[52] Fix | Delete
result.push(current_element);
[53] Fix | Delete
current_element = current_element.parentNode;
[54] Fix | Delete
}
[55] Fix | Delete
}
[56] Fix | Delete
return result;
[57] Fix | Delete
};
[58] Fix | Delete
[59] Fix | Delete
CssSelectorGenerator.prototype.getTagSelector = function (element) {
[60] Fix | Delete
return this.sanitizeItem(element.tagName.toLowerCase());
[61] Fix | Delete
};
[62] Fix | Delete
[63] Fix | Delete
CssSelectorGenerator.prototype.sanitizeItem = function (item) {
[64] Fix | Delete
var characters;
[65] Fix | Delete
characters = (item.split('')).map(function (character) {
[66] Fix | Delete
if (character === ':') {
[67] Fix | Delete
return "\\" + (':'.charCodeAt(0).toString(16).toUpperCase()) + " ";
[68] Fix | Delete
} else if (/[ !"#$%&'()*+,.\/;<=>?@\[\\\]^`{|}~]/.test(character)) {
[69] Fix | Delete
return "\\" + character;
[70] Fix | Delete
} else {
[71] Fix | Delete
return escape(character).replace(/\%/g, '\\');
[72] Fix | Delete
}
[73] Fix | Delete
});
[74] Fix | Delete
return characters.join('');
[75] Fix | Delete
};
[76] Fix | Delete
[77] Fix | Delete
CssSelectorGenerator.prototype.getIdSelector = function (element) {
[78] Fix | Delete
var id, sanitized_id;
[79] Fix | Delete
id = element.getAttribute('id');
[80] Fix | Delete
if ((id != null) && (id !== '') && !(/\s/.exec(id)) && !(/^\d/.exec(id))) {
[81] Fix | Delete
sanitized_id = "#" + (this.sanitizeItem(id));
[82] Fix | Delete
if (element.ownerDocument.querySelectorAll(sanitized_id).length === 1) {
[83] Fix | Delete
return sanitized_id;
[84] Fix | Delete
}
[85] Fix | Delete
}
[86] Fix | Delete
return null;
[87] Fix | Delete
};
[88] Fix | Delete
[89] Fix | Delete
CssSelectorGenerator.prototype.getClassSelectors = function (element) {
[90] Fix | Delete
var class_string, item, result;
[91] Fix | Delete
result = [];
[92] Fix | Delete
class_string = element.getAttribute('class');
[93] Fix | Delete
if (class_string != null) {
[94] Fix | Delete
class_string = class_string.replace(/\s+/g, ' ');
[95] Fix | Delete
class_string = class_string.replace(/^\s|\s$/g, '');
[96] Fix | Delete
if (class_string !== '') {
[97] Fix | Delete
result = (function () {
[98] Fix | Delete
var k, len, ref, results;
[99] Fix | Delete
ref = class_string.split(/\s+/);
[100] Fix | Delete
results = [];
[101] Fix | Delete
for (k = 0, len = ref.length; k < len; k++) {
[102] Fix | Delete
item = ref[k];
[103] Fix | Delete
results.push("." + (this.sanitizeItem(item)));
[104] Fix | Delete
}
[105] Fix | Delete
return results;
[106] Fix | Delete
}).call(this);
[107] Fix | Delete
}
[108] Fix | Delete
}
[109] Fix | Delete
return result;
[110] Fix | Delete
};
[111] Fix | Delete
[112] Fix | Delete
CssSelectorGenerator.prototype.getAttributeSelectors = function (element) {
[113] Fix | Delete
var attribute, blacklist, k, len, ref, ref1, result;
[114] Fix | Delete
result = [];
[115] Fix | Delete
blacklist = ['id', 'class'];
[116] Fix | Delete
ref = element.attributes;
[117] Fix | Delete
for (k = 0, len = ref.length; k < len; k++) {
[118] Fix | Delete
attribute = ref[k];
[119] Fix | Delete
if (ref1 = attribute.nodeName, indexOf.call(blacklist, ref1) < 0) {
[120] Fix | Delete
result.push("[" + attribute.nodeName + "=" + attribute.nodeValue + "]");
[121] Fix | Delete
}
[122] Fix | Delete
}
[123] Fix | Delete
return result;
[124] Fix | Delete
};
[125] Fix | Delete
[126] Fix | Delete
CssSelectorGenerator.prototype.getNthChildSelector = function (element) {
[127] Fix | Delete
var counter, k, len, parent_element, sibling, siblings;
[128] Fix | Delete
parent_element = element.parentNode;
[129] Fix | Delete
if (parent_element != null) {
[130] Fix | Delete
counter = 0;
[131] Fix | Delete
siblings = parent_element.childNodes;
[132] Fix | Delete
for (k = 0, len = siblings.length; k < len; k++) {
[133] Fix | Delete
sibling = siblings[k];
[134] Fix | Delete
if (this.isElement(sibling)) {
[135] Fix | Delete
counter++;
[136] Fix | Delete
if (sibling === element) {
[137] Fix | Delete
return ":nth-child(" + counter + ")";
[138] Fix | Delete
}
[139] Fix | Delete
}
[140] Fix | Delete
}
[141] Fix | Delete
}
[142] Fix | Delete
return null;
[143] Fix | Delete
};
[144] Fix | Delete
[145] Fix | Delete
CssSelectorGenerator.prototype.testSelector = function (element, selector) {
[146] Fix | Delete
var is_unique, result;
[147] Fix | Delete
is_unique = false;
[148] Fix | Delete
if ((selector != null) && selector !== '') {
[149] Fix | Delete
result = element.ownerDocument.querySelectorAll(selector);
[150] Fix | Delete
if (result.length === 1 && result[0] === element) {
[151] Fix | Delete
is_unique = true;
[152] Fix | Delete
}
[153] Fix | Delete
}
[154] Fix | Delete
return is_unique;
[155] Fix | Delete
};
[156] Fix | Delete
[157] Fix | Delete
CssSelectorGenerator.prototype.getAllSelectors = function (element) {
[158] Fix | Delete
var result;
[159] Fix | Delete
result = {
[160] Fix | Delete
t: null,
[161] Fix | Delete
i: null,
[162] Fix | Delete
c: null,
[163] Fix | Delete
a: null,
[164] Fix | Delete
n: null
[165] Fix | Delete
};
[166] Fix | Delete
if (indexOf.call(this.options.selectors, 'tag') >= 0) {
[167] Fix | Delete
result.t = this.getTagSelector(element);
[168] Fix | Delete
}
[169] Fix | Delete
if (indexOf.call(this.options.selectors, 'id') >= 0) {
[170] Fix | Delete
result.i = this.getIdSelector(element);
[171] Fix | Delete
}
[172] Fix | Delete
if (indexOf.call(this.options.selectors, 'class') >= 0) {
[173] Fix | Delete
result.c = this.getClassSelectors(element);
[174] Fix | Delete
}
[175] Fix | Delete
if (indexOf.call(this.options.selectors, 'attribute') >= 0) {
[176] Fix | Delete
result.a = this.getAttributeSelectors(element);
[177] Fix | Delete
}
[178] Fix | Delete
if (indexOf.call(this.options.selectors, 'nthchild') >= 0) {
[179] Fix | Delete
result.n = this.getNthChildSelector(element);
[180] Fix | Delete
}
[181] Fix | Delete
return result;
[182] Fix | Delete
};
[183] Fix | Delete
[184] Fix | Delete
CssSelectorGenerator.prototype.testUniqueness = function (element, selector) {
[185] Fix | Delete
var found_elements, parent;
[186] Fix | Delete
parent = element.parentNode;
[187] Fix | Delete
found_elements = parent.querySelectorAll(selector);
[188] Fix | Delete
return found_elements.length === 1 && found_elements[0] === element;
[189] Fix | Delete
};
[190] Fix | Delete
[191] Fix | Delete
CssSelectorGenerator.prototype.testCombinations = function (element, items, tag) {
[192] Fix | Delete
var item, k, l, len, len1, ref, ref1;
[193] Fix | Delete
ref = this.getCombinations(items);
[194] Fix | Delete
for (k = 0, len = ref.length; k < len; k++) {
[195] Fix | Delete
item = ref[k];
[196] Fix | Delete
if (this.testUniqueness(element, item)) {
[197] Fix | Delete
return item;
[198] Fix | Delete
}
[199] Fix | Delete
}
[200] Fix | Delete
if (tag != null) {
[201] Fix | Delete
ref1 = items.map(function (item) {
[202] Fix | Delete
return tag + item;
[203] Fix | Delete
});
[204] Fix | Delete
for (l = 0, len1 = ref1.length; l < len1; l++) {
[205] Fix | Delete
item = ref1[l];
[206] Fix | Delete
if (this.testUniqueness(element, item)) {
[207] Fix | Delete
return item;
[208] Fix | Delete
}
[209] Fix | Delete
}
[210] Fix | Delete
}
[211] Fix | Delete
return null;
[212] Fix | Delete
};
[213] Fix | Delete
[214] Fix | Delete
CssSelectorGenerator.prototype.getUniqueSelector = function (element) {
[215] Fix | Delete
var found_selector, k, len, ref, selector_type, selectors;
[216] Fix | Delete
selectors = this.getAllSelectors(element);
[217] Fix | Delete
ref = this.options.selectors;
[218] Fix | Delete
for (k = 0, len = ref.length; k < len; k++) {
[219] Fix | Delete
selector_type = ref[k];
[220] Fix | Delete
switch (selector_type) {
[221] Fix | Delete
case 'id':
[222] Fix | Delete
if (selectors.i != null) {
[223] Fix | Delete
return selectors.i;
[224] Fix | Delete
}
[225] Fix | Delete
break;
[226] Fix | Delete
case 'tag':
[227] Fix | Delete
if (selectors.t != null) {
[228] Fix | Delete
if (this.testUniqueness(element, selectors.t)) {
[229] Fix | Delete
return selectors.t;
[230] Fix | Delete
}
[231] Fix | Delete
}
[232] Fix | Delete
break;
[233] Fix | Delete
case 'class':
[234] Fix | Delete
if ((selectors.c != null) && selectors.c.length !== 0) {
[235] Fix | Delete
found_selector = this.testCombinations(element, selectors.c, selectors.t);
[236] Fix | Delete
if (found_selector) {
[237] Fix | Delete
return found_selector;
[238] Fix | Delete
}
[239] Fix | Delete
}
[240] Fix | Delete
break;
[241] Fix | Delete
case 'attribute':
[242] Fix | Delete
if ((selectors.a != null) && selectors.a.length !== 0) {
[243] Fix | Delete
found_selector = this.testCombinations(element, selectors.a, selectors.t);
[244] Fix | Delete
if (found_selector) {
[245] Fix | Delete
return found_selector;
[246] Fix | Delete
}
[247] Fix | Delete
}
[248] Fix | Delete
break;
[249] Fix | Delete
case 'nthchild':
[250] Fix | Delete
if (selectors.n != null) {
[251] Fix | Delete
return selectors.n;
[252] Fix | Delete
}
[253] Fix | Delete
}
[254] Fix | Delete
}
[255] Fix | Delete
return '*';
[256] Fix | Delete
};
[257] Fix | Delete
[258] Fix | Delete
CssSelectorGenerator.prototype.getSelector = function (element) {
[259] Fix | Delete
var all_selectors, item, k, l, len, len1, parents, result, selector, selectors;
[260] Fix | Delete
all_selectors = [];
[261] Fix | Delete
parents = this.getParents(element);
[262] Fix | Delete
for (k = 0, len = parents.length; k < len; k++) {
[263] Fix | Delete
item = parents[k];
[264] Fix | Delete
selector = this.getUniqueSelector(item);
[265] Fix | Delete
if (selector != null) {
[266] Fix | Delete
all_selectors.push(selector);
[267] Fix | Delete
}
[268] Fix | Delete
}
[269] Fix | Delete
selectors = [];
[270] Fix | Delete
for (l = 0, len1 = all_selectors.length; l < len1; l++) {
[271] Fix | Delete
item = all_selectors[l];
[272] Fix | Delete
selectors.unshift(item);
[273] Fix | Delete
result = selectors.join(' > ');
[274] Fix | Delete
if (this.testSelector(element, result)) {
[275] Fix | Delete
return result;
[276] Fix | Delete
}
[277] Fix | Delete
}
[278] Fix | Delete
return null;
[279] Fix | Delete
};
[280] Fix | Delete
[281] Fix | Delete
CssSelectorGenerator.prototype.getCombinations = function (items) {
[282] Fix | Delete
var i, j, k, l, ref, ref1, result;
[283] Fix | Delete
if (items == null) {
[284] Fix | Delete
items = [];
[285] Fix | Delete
}
[286] Fix | Delete
result = [[]];
[287] Fix | Delete
for (i = k = 0, ref = items.length - 1; 0 <= ref ? k <= ref : k >= ref; i = 0 <= ref ? ++k : --k) {
[288] Fix | Delete
for (j = l = 0, ref1 = result.length - 1; 0 <= ref1 ? l <= ref1 : l >= ref1; j = 0 <= ref1 ? ++l : --l) {
[289] Fix | Delete
result.push(result[j].concat(items[i]));
[290] Fix | Delete
}
[291] Fix | Delete
}
[292] Fix | Delete
result.shift();
[293] Fix | Delete
result = result.sort(function (a, b) {
[294] Fix | Delete
return a.length - b.length;
[295] Fix | Delete
});
[296] Fix | Delete
result = result.map(function (item) {
[297] Fix | Delete
return item.join('');
[298] Fix | Delete
});
[299] Fix | Delete
return result;
[300] Fix | Delete
};
[301] Fix | Delete
[302] Fix | Delete
return CssSelectorGenerator;
[303] Fix | Delete
[304] Fix | Delete
})();
[305] Fix | Delete
[306] Fix | Delete
if (typeof define !== "undefined" && define !== null ? define.amd : void 0) {
[307] Fix | Delete
define([], function () {
[308] Fix | Delete
return CssSelectorGenerator;
[309] Fix | Delete
});
[310] Fix | Delete
} else {
[311] Fix | Delete
root = typeof exports !== "undefined" && exports !== null ? exports : this;
[312] Fix | Delete
root.CssSelectorGenerator = CssSelectorGenerator;
[313] Fix | Delete
}
[314] Fix | Delete
[315] Fix | Delete
}).call(this);
[316] Fix | Delete
[317] Fix | Delete
(function ($) {
[318] Fix | Delete
var selector_generator = new CssSelectorGenerator;
[319] Fix | Delete
var pumAdminBarText = pumAdminBarText || {
[320] Fix | Delete
instructions: 'After clicking ok, click the element you want a selector for.',
[321] Fix | Delete
results: 'Selector'
[322] Fix | Delete
};
[323] Fix | Delete
[324] Fix | Delete
$(document).on('click', '#wp-admin-bar-pum-get-selector', function (event) {
[325] Fix | Delete
[326] Fix | Delete
alert(pumAdminBarText.instructions);
[327] Fix | Delete
[328] Fix | Delete
event.preventDefault();
[329] Fix | Delete
event.stopPropagation();
[330] Fix | Delete
[331] Fix | Delete
$(document).one('click', function (event) {
[332] Fix | Delete
// get reference to the element user clicked on
[333] Fix | Delete
var element = event.target,
[334] Fix | Delete
// get unique CSS selector for that element
[335] Fix | Delete
selector = selector_generator.getSelector(element);
[336] Fix | Delete
[337] Fix | Delete
alert( pumAdminBarText.results + ": " + selector);
[338] Fix | Delete
[339] Fix | Delete
event.preventDefault();
[340] Fix | Delete
event.stopPropagation();
[341] Fix | Delete
});
[342] Fix | Delete
});
[343] Fix | Delete
}(jQuery));
[344] Fix | Delete
[345] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function