Change variables back to the original plugin variables.

This commit is contained in:
dlandon
2024-05-01 04:58:17 -05:00
parent 0c32fe5d4d
commit efe372d1d9

View File

@@ -1,121 +1,120 @@
/* jQuery File Tree. Authors - Cory S.N. LaViska & Dave Rogers. Copyright 2008 A Beautiful Site, LLC. - Adapted by Bergware for use in Unraid */
jQuery && function(e) {
e.extend(e.fn, {
fileTree: function(i, t, l) {
// Initialize pickexclude with an empty string if not provided
void 0 === i.root && (i.root = "/mnt/"),
void 0 === i.top && (i.top = "/mnt/"),
void 0 === i.filter && (i.filter = ""),
void 0 === i.match && (i.match = ".*"),
void 0 === i.script && (i.script = "/webGui/include/FileTree.php"),
void 0 === i.folderEvent && (i.folderEvent = "click"),
void 0 === i.expandSpeed && (i.expandSpeed = 300),
void 0 === i.collapseSpeed && (i.collapseSpeed = 300),
void 0 === i.expandEasing && (i.expandEasing = null),
void 0 === i.collapseEasing && (i.collapseEasing = null),
void 0 === i.multiFolder && (i.multiFolder = !1),
void 0 === i.loadMessage && (i.loadMessage = "Loading..."),
void 0 === i.multiSelect && (i.multiSelect = !1),
void 0 === i.allowBrowsing && (i.allowBrowsing = !1),
void 0 === i.pickexclude && (i.pickexclude = "");
e(this).each(function() {
function s(r, n, o) {
e(r).addClass("wait"),
e(".jqueryFileTree.start").remove(),
/* Modify the post data to include pickexclude. */
e.post(i.script, {
dir: n,
root: i.top,
multiSelect: i.multiSelect,
filter: i.filter,
match: i.match,
show_parent: o,
/* Add pickexclude parameter. */
pickexclude: i.pickexclude
}).done(function(o) {
var d;
e(r).find(".start").html(""),
e(r).removeClass("wait").append(o),
i.root == n ? e(r).find("UL:hidden").show() : e(r).find("UL:hidden").slideDown({
duration: i.expandSpeed,
easing: i.expandEasing
}),
e(d = r).find("LI A").on(i.folderEvent, function(r) {
r.preventDefault();
var n = {};
return n.li = e(this).closest("li"),
n.type = n.li.hasClass("directory") ? "directory" : "file",
n.value = e(this).text(),
n.rel = e(this).prop("rel"),
".." == e(this).text() ? (i.root = n.rel, l && l(e(this).attr("rel")), a(e(this), "filetreefolderclicked", n), root = e(this).closest("ul.jqueryFileTree"), root.html('<ul class="jqueryFileTree start"><li class="wait">' + i.loadMessage + "<li></ul>"), s(e(root), i.root, i.allowBrowsing)) : e(this).parent().hasClass("directory") ? (e(this).parent().hasClass("collapsed") ? (a(e(this), "filetreeexpand", n), i.multiFolder || (e(this).parent().parent().find("UL").slideUp({
duration: i.collapseSpeed,
easing: i.collapseEasing
}), e(this).parent().parent().find("LI.directory").removeClass("expanded").addClass("collapsed")), e(this).parent().removeClass("collapsed").addClass("expanded"), e(this).parent().find("UL").remove(), s(e(this).parent(), e(this).attr("rel").match(/.*\//)[0], !1)) : (a(e(this), "filetreecollapse", n), e(this).parent().find("UL").slideUp({
duration: i.collapseSpeed,
easing: i.collapseEasing
}), e(this).parent().removeClass("expanded").addClass("collapsed"), a(e(this), "filetreecollapsed", n)), l && l(e(this).attr("rel")), a(e(this), "filetreefolderclicked", n)) : (t && t(e(this).attr("rel")), a(e(this), "filetreeclicked", n)), !1
}),
"click" != i.folderEvent.toLowerCase && e(d).find("LI A").on("click", function(e) {
return e.preventDefault(), !1
}),
a(e(this), "filetreeexpanded", o)
}).fail(function() {
e(r).find(".start").html(""),
e(r).removeClass("wait").append("<li>Unable to get file tree information</li>")
})
}
function a(e, i, t) {
t.trigger = i,
e.trigger(i, t)
}
e(this).html('<ul class="jqueryFileTree start"><li class="wait">' + i.loadMessage + "<li></ul>"),
s(e(this), i.root, i.allowBrowsing),
e(this).on("change", "input:checkbox", function() {
var i = {};
i.li = e(this).closest("li"),
i.type = i.li.hasClass("directory") ? "directory" : "file",
i.value = i.li.children("a").text(),
i.rel = i.li.children("a").prop("rel"),
i.li.find("input:checkbox").prop("checked", e(this).prop("checked")),
e(this).prop("checked") ? a(e(this), "filetreechecked", i) : a(e(this), "filetreeunchecked", i)
jQuery && function($) {
$.extend($.fn, {
fileTree: function(options, callback, onCancel) {
void 0 === options.root && (options.root = "/mnt/"),
void 0 === options.top && (options.top = "/mnt/"),
void 0 === options.filter && (options.filter = ""),
void 0 === options.match && (options.match = ".*"),
void 0 === options.script && (options.script = "/webGui/include/FileTree.php"),
void 0 === options.folderEvent && (options.folderEvent = "click"),
void 0 === options.expandSpeed && (options.expandSpeed = 300),
void 0 === options.collapseSpeed && (options.collapseSpeed = 300),
void 0 === options.expandEasing && (options.expandEasing = null),
void 0 === options.collapseEasing && (options.collapseEasing = null),
void 0 === options.multiFolder && (options.multiFolder = !1),
void 0 === options.loadMessage && (options.loadMessage = "Loading..."),
void 0 === options.multiSelect && (options.multiSelect = !1),
void 0 === options.allowBrowsing && (options.allowBrowsing = !1),
void 0 === options.pickexclude && (options.pickexclude = "");
$(this).each(function() {
function showTree($this, dir, showParent) {
$this.addClass("wait"),
$(".jqueryFileTree.start").remove(),
/* Modify the post data to include pickexclude. */
$.post(options.script, {
dir: dir,
root: options.top,
multiSelect: options.multiSelect,
filter: options.filter,
match: options.match,
show_parent: showParent,
/* Add pickexclude parameter. */
pickexclude: options.pickexclude
}).done(function(data) {
var $parent;
$this.find(".start").html(""),
$this.removeClass("wait").append(data),
options.root == dir ? $this.find("UL:hidden").show() : $this.find("UL:hidden").slideDown({
duration: options.expandSpeed,
easing: options.expandEasing
}),
$($parent = $this).find("LI A").on(options.folderEvent, function(event) {
event.preventDefault();
var node = {};
return node.li = $(this).closest("li"),
node.type = node.li.hasClass("directory") ? "directory" : "file",
node.value = $(this).text(),
node.rel = $(this).prop("rel"),
".." == $(this).text() ? (options.root = node.rel, callback && callback($(this).attr("rel")), triggerEvent($(this), "filetreefolderclicked", node), root = $(this).closest("ul.jqueryFileTree"), root.html('<ul class="jqueryFileTree start"><li class="wait">' + options.loadMessage + "<li></ul>"), showTree($(root), options.root, options.allowBrowsing)) : $(this).parent().hasClass("directory") ? ($(this).parent().hasClass("collapsed") ? (triggerEvent($(this), "filetreeexpand", node), options.multiFolder || ($(this).parent().parent().find("UL").slideUp({
duration: options.collapseSpeed,
easing: options.collapseEasing
}), $(this).parent().parent().find("LI.directory").removeClass("expanded").addClass("collapsed")), $(this).parent().removeClass("collapsed").addClass("expanded"), $(this).parent().find("UL").remove(), showTree($(this).parent(), $(this).attr("rel").match(/.*\//)[0], !1)) : (triggerEvent($(this), "filetreecollapse", node), $(this).parent().find("UL").slideUp({
duration: options.collapseSpeed,
easing: options.collapseEasing
}), $(this).parent().removeClass("expanded").addClass("collapsed"), triggerEvent($(this), "filetreecollapsed", node)), callback && callback($(this).attr("rel")), triggerEvent($(this), "filetreefolderclicked", node)) : (onCancel && onCancel($(this).attr("rel")), triggerEvent($(this), "filetreeclicked", node)), !1
}),
"click" != options.folderEvent.toLowerCase && $parent.find("LI A").on("click", function(event) {
return event.preventDefault(), !1
}),
triggerEvent($(this), "filetreeexpanded", data)
}).fail(function() {
$this.find(".start").html(""),
$this.removeClass("wait").append("<li>Unable to get file tree information</li>")
})
})
}
function triggerEvent($elem, event, data) {
data.trigger = event,
$elem.trigger(event, data)
}
$(this).html('<ul class="jqueryFileTree start"><li class="wait">' + options.loadMessage + "<li></ul>"),
showTree($(this), options.root, options.allowBrowsing),
$(this).on("change", "input:checkbox", function() {
var node = {};
node.li = $(this).closest("li"),
node.type = node.li.hasClass("directory") ? "directory" : "file",
node.value = node.li.children("a").text(),
node.rel = node.li.children("a").prop("rel"),
node.li.find("input:checkbox").prop("checked", $(this).prop("checked")),
$(this).prop("checked") ? triggerEvent($(this), "filetreechecked", node) : triggerEvent($(this), "filetreeunchecked", node)
})
})
},
fileTreeAttach: function(i, t, l) {
var s = {};
e.isFunction(i) ? (e.isFunction(t) && (l = t), t = i) : i && e.extend(s, i),
e(this).each(function() {
var i = e(this),
a = e.extend({}, s, i.data()),
r = i.next(".fileTree");
0 === r.length && (e(document).mousedown(function(i) {
var t = e(".fileTree");
t.is(i.target) || 0 !== t.has(i.target).length || t.slideUp("fast")
fileTreeAttach: function(options, callback, onCancel) {
var settings = {};
$.isFunction(options) ? ($.isFunction(callback) && (onCancel = callback), callback = options) : options && $.extend(settings, options),
$(this).each(function() {
var $this = $(this),
config = $.extend({}, settings, $this.data()),
$fileTree = $this.next(".fileTree");
0 === $fileTree.length && ($(document).mousedown(function(event) {
var $fileTree = $(".fileTree");
$fileTree.is(event.target) || 0 !== $fileTree.has(event.target).length || $fileTree.slideUp("fast")
}),
r = e("<div>", {
$fileTree = $("<div>", {
class: "textarea fileTree"
}),
i.after(r)),
i.click(function() {
r.is(":visible") ? r.slideUp("fast") : ("" === r.html() && (r.html('<span style="padding-left: 20px"><img src="/webGui/images/spinner.gif"> Loading...</span>'),
r.fileTree({
root: a.pickroot,
top: a.picktop,
filter: (a.pickfilter || "").split(","),
match: a.pickmatch || ".*",
$this.after($fileTree)),
$this.click(function() {
$fileTree.is(":visible") ? $fileTree.slideUp("fast") : ("" === $fileTree.html() && ($fileTree.html('<span style="padding-left: 20px"><img src="/webGui/images/spinner.gif"> Loading...</span>'),
$fileTree.fileTree({
root: config.pickroot,
top: config.picktop,
filter: (config.pickfilter || "").split(","),
match: config.pickmatch || ".*",
/* Include pickexclude parameter in fileTreeAttach. */
pickexclude: a.pickexclude
}, e.isFunction(t) ? t : function(e) {
i.val(e).change(),
a.hasOwnProperty("pickcloseonfile") && r.slideUp("fast")
}, e.isFunction(l) ? l : function(e) {
a.hasOwnProperty("pickfolders") && i.val(e).change()
pickexclude: config.pickexclude
}, $.isFunction(callback) ? callback : function(data) {
$this.val(data).change(),
config.hasOwnProperty("pickcloseonfile") && $fileTree.slideUp("fast")
}, $.isFunction(onCancel) ? onCancel : function(data) {
config.hasOwnProperty("pickfolders") && $this.val(data).change()
})),
r.offset({
left: i.position().left
$fileTree.offset({
left: $this.position().left
}),
r.slideDown("fast"))
$fileTree.slideDown("fast"))
})
})
}