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/wp-conte.../plugins/wp-file-.../lib/js/ui
File: toolbar.js
/**
[0] Fix | Delete
* @class elFinder toolbar
[1] Fix | Delete
*
[2] Fix | Delete
* @author Dmitry (dio) Levashov
[3] Fix | Delete
**/
[4] Fix | Delete
jQuery.fn.elfindertoolbar = function(fm, opts) {
[5] Fix | Delete
"use strict";
[6] Fix | Delete
this.not('.elfinder-toolbar').each(function() {
[7] Fix | Delete
var commands = fm._commands,
[8] Fix | Delete
self = jQuery(this).addClass('ui-helper-clearfix ui-widget-header elfinder-toolbar'),
[9] Fix | Delete
options = {
[10] Fix | Delete
// default options
[11] Fix | Delete
displayTextLabel: false,
[12] Fix | Delete
labelExcludeUA: ['Mobile'],
[13] Fix | Delete
autoHideUA: ['Mobile'],
[14] Fix | Delete
showPreferenceButton: 'none'
[15] Fix | Delete
},
[16] Fix | Delete
filter = function(opts) {
[17] Fix | Delete
return jQuery.grep(opts, function(v) {
[18] Fix | Delete
if (jQuery.isPlainObject(v)) {
[19] Fix | Delete
options = Object.assign(options, v);
[20] Fix | Delete
return false;
[21] Fix | Delete
}
[22] Fix | Delete
return true;
[23] Fix | Delete
});
[24] Fix | Delete
},
[25] Fix | Delete
render = function(disabled){
[26] Fix | Delete
var name,cmdPref;
[27] Fix | Delete
[28] Fix | Delete
jQuery.each(buttons, function(i, b) { b.detach(); });
[29] Fix | Delete
self.empty();
[30] Fix | Delete
l = panels.length;
[31] Fix | Delete
while (l--) {
[32] Fix | Delete
if (panels[l]) {
[33] Fix | Delete
panel = jQuery('<div class="ui-widget-content ui-corner-all elfinder-buttonset"></div>');
[34] Fix | Delete
i = panels[l].length;
[35] Fix | Delete
while (i--) {
[36] Fix | Delete
name = panels[l][i];
[37] Fix | Delete
if ((!disabled || !disabled[name]) && (cmd = commands[name])) {
[38] Fix | Delete
button = 'elfinder'+cmd.options.ui;
[39] Fix | Delete
if (! buttons[name] && jQuery.fn[button]) {
[40] Fix | Delete
buttons[name] = jQuery('<div></div>')[button](cmd);
[41] Fix | Delete
}
[42] Fix | Delete
if (buttons[name]) {
[43] Fix | Delete
buttons[name].children('.elfinder-button-text')[textLabel? 'show' : 'hide']();
[44] Fix | Delete
panel.prepend(buttons[name]);
[45] Fix | Delete
}
[46] Fix | Delete
}
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
panel.children().length && self.prepend(panel);
[50] Fix | Delete
panel.children(':gt(0)').before('<span class="ui-widget-content elfinder-toolbar-button-separator"></span>');
[51] Fix | Delete
[52] Fix | Delete
}
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
if (cmdPref = commands['preference']) {
[56] Fix | Delete
//cmdPref.state = !self.children().length? 0 : -1;
[57] Fix | Delete
if (options.showPreferenceButton === 'always' || (!self.children().length && options.showPreferenceButton === 'auto')) {
[58] Fix | Delete
//cmdPref.state = 0;
[59] Fix | Delete
panel = jQuery('<div class="ui-widget-content ui-corner-all elfinder-buttonset"></div>');
[60] Fix | Delete
name = 'preference';
[61] Fix | Delete
button = 'elfinder'+cmd.options.ui;
[62] Fix | Delete
buttons[name] = jQuery('<div></div>')[button](cmdPref);
[63] Fix | Delete
buttons[name].children('.elfinder-button-text')[textLabel? 'show' : 'hide']();
[64] Fix | Delete
panel.prepend(buttons[name]);
[65] Fix | Delete
self.append(panel);
[66] Fix | Delete
}
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
(! self.data('swipeClose') && self.children().length)? self.show() : self.hide();
[70] Fix | Delete
prevHeight = self[0].clientHeight;
[71] Fix | Delete
fm.trigger('toolbarload').trigger('uiresize');
[72] Fix | Delete
},
[73] Fix | Delete
buttons = {},
[74] Fix | Delete
panels = filter(opts || []),
[75] Fix | Delete
dispre = null,
[76] Fix | Delete
uiCmdMapPrev = '',
[77] Fix | Delete
prevHeight = 0,
[78] Fix | Delete
contextRaw = [],
[79] Fix | Delete
l, i, cmd, panel, button, swipeHandle, autoHide, textLabel, resizeTm;
[80] Fix | Delete
[81] Fix | Delete
// normalize options
[82] Fix | Delete
options.showPreferenceButton = options.showPreferenceButton.toLowerCase();
[83] Fix | Delete
[84] Fix | Delete
if (options.displayTextLabel !== 'none') {
[85] Fix | Delete
// correction of options.displayTextLabel
[86] Fix | Delete
textLabel = fm.storage('toolbarTextLabel');
[87] Fix | Delete
if (textLabel === null) {
[88] Fix | Delete
textLabel = (options.displayTextLabel && (! options.labelExcludeUA || ! options.labelExcludeUA.length || ! jQuery.grep(options.labelExcludeUA, function(v){ return fm.UA[v]? true : false; }).length));
[89] Fix | Delete
} else {
[90] Fix | Delete
textLabel = (textLabel == 1);
[91] Fix | Delete
}
[92] Fix | Delete
contextRaw.push({
[93] Fix | Delete
label : fm.i18n('textLabel'),
[94] Fix | Delete
icon : 'text',
[95] Fix | Delete
callback : function() {
[96] Fix | Delete
textLabel = ! textLabel;
[97] Fix | Delete
self.css('height', '').find('.elfinder-button-text')[textLabel? 'show':'hide']();
[98] Fix | Delete
fm.trigger('uiresize').storage('toolbarTextLabel', textLabel? '1' : '0');
[99] Fix | Delete
},
[100] Fix | Delete
});
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
if (options.preferenceInContextmenu && commands['preference']) {
[104] Fix | Delete
contextRaw.push({
[105] Fix | Delete
label : fm.i18n('toolbarPref'),
[106] Fix | Delete
icon : 'preference',
[107] Fix | Delete
callback : function() {
[108] Fix | Delete
fm.exec('preference', void(0), {tab: 'toolbar'});
[109] Fix | Delete
}
[110] Fix | Delete
});
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
// add contextmenu
[114] Fix | Delete
if (contextRaw.length) {
[115] Fix | Delete
self.on('contextmenu', function(e) {
[116] Fix | Delete
e.stopPropagation();
[117] Fix | Delete
e.preventDefault();
[118] Fix | Delete
fm.trigger('contextmenu', {
[119] Fix | Delete
raw: contextRaw,
[120] Fix | Delete
x: e.pageX,
[121] Fix | Delete
y: e.pageY
[122] Fix | Delete
});
[123] Fix | Delete
}).on('touchstart', function(e) {
[124] Fix | Delete
if (e.originalEvent.touches.length > 1) {
[125] Fix | Delete
return;
[126] Fix | Delete
}
[127] Fix | Delete
self.data('tmlongtap') && clearTimeout(self.data('tmlongtap'));
[128] Fix | Delete
self.removeData('longtap')
[129] Fix | Delete
.data('longtap', {x: e.originalEvent.touches[0].pageX, y: e.originalEvent.touches[0].pageY})
[130] Fix | Delete
.data('tmlongtap', setTimeout(function() {
[131] Fix | Delete
self.removeData('longtapTm')
[132] Fix | Delete
.trigger({
[133] Fix | Delete
type: 'contextmenu',
[134] Fix | Delete
pageX: self.data('longtap').x,
[135] Fix | Delete
pageY: self.data('longtap').y
[136] Fix | Delete
})
[137] Fix | Delete
.data('longtap', {longtap: true});
[138] Fix | Delete
}, 500));
[139] Fix | Delete
}).on('touchmove touchend', function(e) {
[140] Fix | Delete
if (self.data('tmlongtap')) {
[141] Fix | Delete
if (e.type === 'touchend' ||
[142] Fix | Delete
( Math.abs(self.data('longtap').x - e.originalEvent.touches[0].pageX)
[143] Fix | Delete
+ Math.abs(self.data('longtap').y - e.originalEvent.touches[0].pageY)) > 4)
[144] Fix | Delete
clearTimeout(self.data('tmlongtap'));
[145] Fix | Delete
self.removeData('longtapTm');
[146] Fix | Delete
}
[147] Fix | Delete
}).on('click', function(e) {
[148] Fix | Delete
if (self.data('longtap') && self.data('longtap').longtap) {
[149] Fix | Delete
e.stopImmediatePropagation();
[150] Fix | Delete
e.preventDefault();
[151] Fix | Delete
}
[152] Fix | Delete
}).on('touchend click', '.elfinder-button', function(e) {
[153] Fix | Delete
if (self.data('longtap') && self.data('longtap').longtap) {
[154] Fix | Delete
e.stopImmediatePropagation();
[155] Fix | Delete
e.preventDefault();
[156] Fix | Delete
}
[157] Fix | Delete
}
[158] Fix | Delete
);
[159] Fix | Delete
}
[160] Fix | Delete
[161] Fix | Delete
self.prev().length && self.parent().prepend(this);
[162] Fix | Delete
[163] Fix | Delete
render();
[164] Fix | Delete
[165] Fix | Delete
fm.bind('open sync select toolbarpref', function() {
[166] Fix | Delete
var disabled = Object.assign({}, fm.option('disabledFlip')),
[167] Fix | Delete
userHides = fm.storage('toolbarhides'),
[168] Fix | Delete
doRender, sel, disabledKeys;
[169] Fix | Delete
[170] Fix | Delete
if (! userHides && Array.isArray(options.defaultHides)) {
[171] Fix | Delete
userHides = {};
[172] Fix | Delete
jQuery.each(options.defaultHides, function() {
[173] Fix | Delete
userHides[this] = true;
[174] Fix | Delete
});
[175] Fix | Delete
fm.storage('toolbarhides', userHides);
[176] Fix | Delete
}
[177] Fix | Delete
if (this.type === 'select') {
[178] Fix | Delete
if (fm.searchStatus.state < 2) {
[179] Fix | Delete
return;
[180] Fix | Delete
}
[181] Fix | Delete
sel = fm.selected();
[182] Fix | Delete
if (sel.length) {
[183] Fix | Delete
disabled = fm.getDisabledCmds(sel, true);
[184] Fix | Delete
}
[185] Fix | Delete
}
[186] Fix | Delete
[187] Fix | Delete
jQuery.each(userHides, function(n) {
[188] Fix | Delete
if (!disabled[n]) {
[189] Fix | Delete
disabled[n] = true;
[190] Fix | Delete
}
[191] Fix | Delete
});
[192] Fix | Delete
[193] Fix | Delete
if (Object.keys(fm.commandMap).length) {
[194] Fix | Delete
jQuery.each(fm.commandMap, function(from, to){
[195] Fix | Delete
if (to === 'hidden') {
[196] Fix | Delete
disabled[from] = true;
[197] Fix | Delete
}
[198] Fix | Delete
});
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
disabledKeys = Object.keys(disabled);
[202] Fix | Delete
if (!dispre || dispre.toString() !== disabledKeys.sort().toString()) {
[203] Fix | Delete
render(disabledKeys.length? disabled : null);
[204] Fix | Delete
doRender = true;
[205] Fix | Delete
}
[206] Fix | Delete
dispre = disabledKeys.sort();
[207] Fix | Delete
[208] Fix | Delete
if (doRender || uiCmdMapPrev !== JSON.stringify(fm.commandMap)) {
[209] Fix | Delete
uiCmdMapPrev = JSON.stringify(fm.commandMap);
[210] Fix | Delete
if (! doRender) {
[211] Fix | Delete
// reset toolbar
[212] Fix | Delete
jQuery.each(jQuery('div.elfinder-button'), function(){
[213] Fix | Delete
var origin = jQuery(this).data('origin');
[214] Fix | Delete
if (origin) {
[215] Fix | Delete
jQuery(this).after(origin).detach();
[216] Fix | Delete
}
[217] Fix | Delete
});
[218] Fix | Delete
}
[219] Fix | Delete
if (Object.keys(fm.commandMap).length) {
[220] Fix | Delete
jQuery.each(fm.commandMap, function(from, to){
[221] Fix | Delete
var cmd = fm._commands[to],
[222] Fix | Delete
button = cmd? 'elfinder'+cmd.options.ui : null,
[223] Fix | Delete
btn;
[224] Fix | Delete
if (button && jQuery.fn[button]) {
[225] Fix | Delete
btn = buttons[from];
[226] Fix | Delete
if (btn) {
[227] Fix | Delete
if (! buttons[to] && jQuery.fn[button]) {
[228] Fix | Delete
buttons[to] = jQuery('<div></div>')[button](cmd);
[229] Fix | Delete
if (buttons[to]) {
[230] Fix | Delete
buttons[to].children('.elfinder-button-text')[textLabel? 'show' : 'hide']();
[231] Fix | Delete
if (cmd.extendsCmd) {
[232] Fix | Delete
buttons[to].children('span.elfinder-button-icon').addClass('elfinder-button-icon-' + cmd.extendsCmd);
[233] Fix | Delete
}
[234] Fix | Delete
}
[235] Fix | Delete
}
[236] Fix | Delete
if (buttons[to]) {
[237] Fix | Delete
btn.after(buttons[to]);
[238] Fix | Delete
buttons[to].data('origin', btn.detach());
[239] Fix | Delete
}
[240] Fix | Delete
}
[241] Fix | Delete
}
[242] Fix | Delete
});
[243] Fix | Delete
}
[244] Fix | Delete
}
[245] Fix | Delete
}).bind('resize', function(e) {
[246] Fix | Delete
resizeTm && cancelAnimationFrame(resizeTm);
[247] Fix | Delete
resizeTm = requestAnimationFrame(function() {
[248] Fix | Delete
var h = self[0].clientHeight;
[249] Fix | Delete
if (prevHeight !== h) {
[250] Fix | Delete
prevHeight = h;
[251] Fix | Delete
fm.trigger('uiresize');
[252] Fix | Delete
}
[253] Fix | Delete
});
[254] Fix | Delete
});
[255] Fix | Delete
[256] Fix | Delete
if (fm.UA.Touch) {
[257] Fix | Delete
autoHide = fm.storage('autoHide') || {};
[258] Fix | Delete
if (typeof autoHide.toolbar === 'undefined') {
[259] Fix | Delete
autoHide.toolbar = (options.autoHideUA && options.autoHideUA.length > 0 && jQuery.grep(options.autoHideUA, function(v){ return fm.UA[v]? true : false; }).length);
[260] Fix | Delete
fm.storage('autoHide', autoHide);
[261] Fix | Delete
}
[262] Fix | Delete
[263] Fix | Delete
if (autoHide.toolbar) {
[264] Fix | Delete
fm.one('init', function() {
[265] Fix | Delete
fm.uiAutoHide.push(function(){ self.stop(true, true).trigger('toggle', { duration: 500, init: true }); });
[266] Fix | Delete
});
[267] Fix | Delete
}
[268] Fix | Delete
[269] Fix | Delete
fm.bind('load', function() {
[270] Fix | Delete
swipeHandle = jQuery('<div class="elfinder-toolbar-swipe-handle"></div>').hide().appendTo(fm.getUI());
[271] Fix | Delete
if (swipeHandle.css('pointer-events') !== 'none') {
[272] Fix | Delete
swipeHandle.remove();
[273] Fix | Delete
swipeHandle = null;
[274] Fix | Delete
}
[275] Fix | Delete
});
[276] Fix | Delete
[277] Fix | Delete
self.on('toggle', function(e, data) {
[278] Fix | Delete
var wz = fm.getUI('workzone'),
[279] Fix | Delete
toshow= self.is(':hidden'),
[280] Fix | Delete
wzh = wz.height(),
[281] Fix | Delete
h = self.height(),
[282] Fix | Delete
tbh = self.outerHeight(true),
[283] Fix | Delete
delta = tbh - h,
[284] Fix | Delete
opt = Object.assign({
[285] Fix | Delete
step: function(now) {
[286] Fix | Delete
wz.height(wzh + (toshow? (now + delta) * -1 : h - now));
[287] Fix | Delete
fm.trigger('resize');
[288] Fix | Delete
},
[289] Fix | Delete
always: function() {
[290] Fix | Delete
requestAnimationFrame(function() {
[291] Fix | Delete
self.css('height', '');
[292] Fix | Delete
fm.trigger('uiresize');
[293] Fix | Delete
if (swipeHandle) {
[294] Fix | Delete
if (toshow) {
[295] Fix | Delete
swipeHandle.stop(true, true).hide();
[296] Fix | Delete
} else {
[297] Fix | Delete
swipeHandle.height(data.handleH? data.handleH : '');
[298] Fix | Delete
fm.resources.blink(swipeHandle, 'slowonce');
[299] Fix | Delete
}
[300] Fix | Delete
}
[301] Fix | Delete
toshow && self.scrollTop('0px');
[302] Fix | Delete
data.init && fm.trigger('uiautohide');
[303] Fix | Delete
});
[304] Fix | Delete
}
[305] Fix | Delete
}, data);
[306] Fix | Delete
self.data('swipeClose', ! toshow).stop(true, true).animate({height : 'toggle'}, opt);
[307] Fix | Delete
autoHide.toolbar = !toshow;
[308] Fix | Delete
fm.storage('autoHide', Object.assign(fm.storage('autoHide'), {toolbar: autoHide.toolbar}));
[309] Fix | Delete
}).on('touchstart', function(e) {
[310] Fix | Delete
if (self.scrollBottom() > 5) {
[311] Fix | Delete
e.originalEvent._preventSwipeY = true;
[312] Fix | Delete
}
[313] Fix | Delete
});
[314] Fix | Delete
}
[315] Fix | Delete
});
[316] Fix | Delete
[317] Fix | Delete
return this;
[318] Fix | Delete
};
[319] Fix | Delete
[320] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function