Revert to minimized version.

This commit is contained in:
dlandon
2024-05-02 08:06:46 -05:00
parent a90d083cb0
commit 4f82b16fdd

View File

@@ -1,122 +1,2 @@
/* 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($) {
$.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(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")
}),
$fileTree = $("<div>", {
class: "textarea fileTree"
}),
$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: 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()
})),
$fileTree.offset({
left: $this.position().left
}),
$fileTree.slideDown("fast"))
})
})
}
})
}(jQuery);
jQuery&&function(e){e.extend(e.fn,{fileTree:function(i,t,l){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),e(this).each(function(){function s(r,n,o){e(r).addClass("wait"),e(".jqueryFileTree.start").remove(),e.post(i.script,{dir:n,root:i.top,multiSelect:i.multiSelect,filter:i.filter,match:i.match,show_parent:o}).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)})})},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")}),r=e("<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||".*"},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()})),r.offset({left:i.position().left}),r.slideDown("fast"))})})}})}(jQuery);