Skip to content

Commit

Permalink
Item15325: upgrade jQuery treeview to version 1.4.2
Browse files Browse the repository at this point in the history
... and add a custom foswiki theme
  • Loading branch information
MichaelDaum committed May 21, 2024
1 parent 2848dbb commit 5cdfdb3
Show file tree
Hide file tree
Showing 10 changed files with 270 additions and 232 deletions.
10 changes: 6 additions & 4 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ pub/System/JQueryPlugin/plugins/tooltip/tooltip-bubble-bottom.png 0644
pub/System/JQueryPlugin/plugins/tooltip/tooltip-bubble.png 0644
pub/System/JQueryPlugin/plugins/tooltip/tooltip-bubble-reverse-bottom.png 0644
pub/System/JQueryPlugin/plugins/tooltip/tooltip-bubble-reverse.png 0644
pub/System/JQueryPlugin/plugins/treeview/foswiki.uncompressed.css 0644
pub/System/JQueryPlugin/plugins/treeview/images/file.gif 0644
pub/System/JQueryPlugin/plugins/treeview/images/folder-closed.gif 0644
pub/System/JQueryPlugin/plugins/treeview/images/folder.gif 0644
Expand All @@ -639,16 +640,16 @@ pub/System/JQueryPlugin/plugins/treeview/images/treeview-red-line.gif 0644
pub/System/JQueryPlugin/plugins/treeview/jquery.treeview.async.js 0644
pub/System/JQueryPlugin/plugins/treeview/jquery.treeview.async.js.gz 0644
pub/System/JQueryPlugin/plugins/treeview/jquery.treeview.async.uncompressed.js 0644
pub/System/JQueryPlugin/plugins/treeview/jquery.treeview.css 0644
pub/System/JQueryPlugin/plugins/treeview/jquery.treeview.css.gz 0644
pub/System/JQueryPlugin/plugins/treeview/jquery.treeview.init.js 0644
pub/System/JQueryPlugin/plugins/treeview/jquery.treeview.init.js.gz 0644
pub/System/JQueryPlugin/plugins/treeview/jquery.treeview.init.uncompressed.js 0644
pub/System/JQueryPlugin/plugins/treeview/jquery.treeview.js 0644
pub/System/JQueryPlugin/plugins/treeview/jquery.treeview.js.gz 0644
pub/System/JQueryPlugin/plugins/treeview/jquery.treeview.uncompressed.css 0644
pub/System/JQueryPlugin/plugins/treeview/jquery.treeview.uncompressed.js 0644
pub/System/JQueryPlugin/plugins/treeview/Makefile 0644
pub/System/JQueryPlugin/plugins/treeview/treeview.css 0644
pub/System/JQueryPlugin/plugins/treeview/treeview.css.gz 0644
pub/System/JQueryPlugin/plugins/treeview/treeview.js 0644
pub/System/JQueryPlugin/plugins/treeview/treeview.js.gz 0644
pub/System/JQueryPlugin/plugins/ui/i18n/datepicker-af.js 0644
pub/System/JQueryPlugin/plugins/ui/i18n/datepicker-ar-DZ.js 0644
pub/System/JQueryPlugin/plugins/ui/i18n/datepicker-ar.js 0644
Expand Down Expand Up @@ -1245,6 +1246,7 @@ pub/System/JQueryPlugin/plugins/validate/localization/messages_fr.js 0644
pub/System/JQueryPlugin/plugins/validate/localization/messages_ge.js 0644
pub/System/JQueryPlugin/plugins/validate/localization/messages_gl.js 0644
pub/System/JQueryPlugin/plugins/validate/localization/messages_he.js 0644
pub/System/JQueryPlugin/plugins/validate/localization/messages_hi.js 0644
pub/System/JQueryPlugin/plugins/validate/localization/messages_hr.js 0644
pub/System/JQueryPlugin/plugins/validate/localization/messages_hu.js 0644
pub/System/JQueryPlugin/plugins/validate/localization/messages_hy_AM.js 0644
Expand Down
13 changes: 5 additions & 8 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/TREEVIEW.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,13 @@ sub new {
my $this = bless(
$class->SUPER::new(
name => 'Treeview',
version => '1.4',
version => '1.4.2',
author => 'Joern Zaefferer',
homepage =>
'http://bassistance.de/jquery-plugins/jquery-plugin-treeview',
css => ['jquery.treeview.css'],
javascript => [
'jquery.treeview.js', 'jquery.treeview.async.js',
'jquery.treeview.init.js'
],
dependencies => ['metadata'],
css => ['treeview.css'],
javascript => ['treeview.js'],
dependencies => ['foswiki']
),
$class
);
Expand All @@ -47,7 +44,7 @@ sub new {
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2010-2020 Foswiki Contributors. Foswiki Contributors
Copyright (C) 2010-2024 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
Expand Down
18 changes: 12 additions & 6 deletions JQueryPlugin/pub/System/JQueryPlugin/plugins/treeview/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
TARGET=\
jquery.treeview.js \
jquery.treeview.async.js \
jquery.treeview.init.js \
jquery.treeview.css \
$(JQUERYPLUGIN_LIB)/TREEVIEW.pm
TARGET=treeview.js treeview.css jquery.treeview.async.js

-include ../../Makefile.include

clean:
rm -f $(TARGET) *.gz

treeview.css: jquery.treeview.uncompressed.css foswiki.uncompressed.css
@echo "generating $@"
@cat $^ | $(CSSMIN) $(CSSMIN_ARGS)> $@

treeview.js: jquery.treeview.js jquery.treeview.async.js jquery.treeview.init.js
@echo "generating $@"
@$(JSMIN) $^ > $@
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* foswiki customizations */
.jqTreeview {
display:none; /* activated using js */
}
.jqTreeview.red li { background-image: url(images/treeview-red-line.gif) !important; }
.jqTreeview.red .hitarea,
.jqTreeview.red li.lastCollapsable,
.jqTreeview.red li.lastExpandable { background-image: url(images/treeview-red.gif) !important; }

.jqTreeview.black li { background-image: url(images/treeview-black-line.gif) !important; }
.jqTreeview.black .hitarea,
.jqTreeview.black li.lastCollapsable,
.jqTreeview.black li.lastExpandable { background-image: url(images/treeview-black.gif) !important; }

.jqTreeview.gray li { background-image: url(images/treeview-gray-line.gif) !important; }
.jqTreeview.gray .hitarea,
.jqTreeview.gray li.lastCollapsable,
.jqTreeview.gray li.lastExpandable { background-image: url(images/treeview-gray.gif) !important; }

.jqTreeview.famfamfam li { background-image: url(images/treeview-famfamfam-line.gif) !important; }
.jqTreeview.famfamfam .hitarea,
.jqTreeview.famfamfam li.lastCollapsable,
.jqTreeview.famfamfam li.lastExpandable { background-image: url(images/treeview-famfamfam.gif) !important; }

.jqTreeview.orangearrows li { background-image: url(images/treeview-famfamfam-line.gif) !important; }
.jqTreeview.orangearrows .hitarea,
.jqTreeview.orangearrows li.lastCollapsable,
.jqTreeview.orangearrows li.lastExpandable { background-image: url(images/treeview-orangearrows.gif) !important; }

.jqTreeview.grayarrows li { background-image: url(images/treeview-famfamfam-line.gif) !important; }
.jqTreeview.grayarrows .hitarea,
.jqTreeview.grayarrows li.lastCollapsable,
.jqTreeview.grayarrows li.lastExpandable { background-image: url(images/treeview-orangearrows.gif) !important; }

.jqAjaxLoader,
.treeview .placeholder {
background: url(../../images/spinner.gif) 0 0 no-repeat;
height: 16px;
width: 16px;
display: block;
}
.treeview .open .placeholder {
display:none;
}
.treeview .open .closed .placeholder {
display:block;
}
@media print {
.jqTreeview {
display:block;
}
}

Original file line number Diff line number Diff line change
@@ -1,90 +1,108 @@
/*
* Async Treeview 0.1 - Lazy-loading extension for Treeview
*
* http://bassistance.de/jquery-plugins/jquery-plugin-treeview/
*
* Copyright (c) 2007 Jörn Zaefferer
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Revision: $Id$
*
*/

;(function($) {

function load(settings, root, child, container) {
function responseHandler(response) {
function createNode(parent) {
var current = $("<li/>").attr("id", this.id || "").html("<span>" + this.text + "</span>").appendTo(parent);
if (this.classes) {
current.children("span").addClass(this.classes);
}
if (this.expanded) {
current.addClass("open");
} else {
current.addClass("closed");
}
if (this.hasChildren || this.children && this.children.length) {
var branch = $("<ul/>").appendTo(current);
if (this.hasChildren) {
current.addClass("hasChildren");
createNode.call({
classes: "placeholder",
text: "&nbsp;",
children:[]
}, branch);
}
if (this.children && this.children.length) {
$.each(this.children, createNode, [branch])
}
}
}
child.empty();
$.each(response, createNode, [child]);
$(container).treeview({add: child});
}

if (settings.data === undefined) {
$.getJSON(settings.url, {root: root}, responseHandler);
} else {
var postData = $.extend({
root: root
}, settings.data);
$.ajax({
url:settings.url,
dataType: 'json',
type: 'POST',
data: postData,
success: responseHandler
});
}
}

var proxied = $.fn.treeview;
$.fn.treeview = function(settings) {
if (!settings.url) {
return proxied.apply(this, arguments);
}
var container = this;
if (!container.children().size())
load(settings, settings.root ||"source", this, container);
var userToggle = settings.toggle;
return proxied.call(this, $.extend({}, settings, {
collapsed: true,
toggle: function() {
var $this = $(this);
if ($this.hasClass("hasChildren")) {
var childList = $this.removeClass("hasChildren").find("ul");
load(settings, this.id, childList, container);
}
if (userToggle) {
userToggle.apply(this, arguments);
}
}
}));
};

})(jQuery);
/*
* Async Treeview 0.1 - Lazy-loading extension for Treeview
*
* http://bassistance.de/jquery-plugins/jquery-plugin-treeview/
*
* Copyright Jörn Zaefferer
* Released under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*/

;(function($) {

function load(settings, root, child, container) {
function createNode(parent) {
var current = $("<li/>").attr("id", this.id || "").html("<span>" + this.text + "</span>").appendTo(parent);
if (this.classes) {
current.children("span").addClass(this.classes);
}
if (this.expanded) {
current.addClass("open");
}
if (this.hasChildren || this.children && this.children.length) {
var branch = $("<ul/>").appendTo(current);
if (this.hasChildren) {
current.addClass("hasChildren");
createNode.call({
classes: "placeholder",
text: "&nbsp;",
children:[]
}, branch);
}
if (this.children && this.children.length) {
$.each(this.children, createNode, [branch])
}
}
}
$.ajax($.extend(true, {
url: settings.url,
dataType: "json",
data: {
root: root
},
success: function(response) {
child.empty();
$.each(response, createNode, [child]);
$(container).treeview({add: child});
}
}, settings.ajax));
/*
$.getJSON(settings.url, {root: root}, function(response) {
function createNode(parent) {
var current = $("<li/>").attr("id", this.id || "").html("<span>" + this.text + "</span>").appendTo(parent);
if (this.classes) {
current.children("span").addClass(this.classes);
}
if (this.expanded) {
current.addClass("open");
}
if (this.hasChildren || this.children && this.children.length) {
var branch = $("<ul/>").appendTo(current);
if (this.hasChildren) {
current.addClass("hasChildren");
createNode.call({
classes: "placeholder",
text: "&nbsp;",
children:[]
}, branch);
}
if (this.children && this.children.length) {
$.each(this.children, createNode, [branch])
}
}
}
child.empty();
$.each(response, createNode, [child]);
$(container).treeview({add: child});
});
*/
}

var proxied = $.fn.treeview;
$.fn.treeview = function(settings) {
if (!settings.url) {
return proxied.apply(this, arguments);
}
if (!settings.root) {
settings.root = "source";
}
var container = this;
if (!container.children().size())
load(settings, settings.root, this, container);
var userToggle = settings.toggle;
return proxied.call(this, $.extend({}, settings, {
collapsed: true,
toggle: function() {
var $this = $(this);
if ($this.hasClass("hasChildren")) {
var childList = $this.removeClass("hasChildren").find("ul");
load(settings, this.id, childList, container);
}
if (userToggle) {
userToggle.apply(this, arguments);
}
}
}));
};

})(jQuery);
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
"use strict";

jQuery(function($){
$(".jqTreeview:not(.jqInitedTreeview)").livequery(function() {
$(".jqTreeview:not(.inited)").livequery(function() {
var $this = $(this),
$ul = $this.find("ul:first"),
thisClass = $this.attr('class'),
opts = $.extend({}, $this.data(), $this.metadata());
opts = $.extend({}, $this.data());

if (typeof(opts.open) !== 'undefined') {
var maxDepth = parseInt(opts.open);
$this.find("li").addClass("closed");
if (maxDepth) {
$this.find("li").filter(function(i, elem) {
var depth = $(elem).parentsUntil($ul).length;
return depth <= maxDepth;
}).addClass("open").removeClass("closed");
}
}

if (thisClass.match(/\bopen\b/)) {
opts.collapsed = false;
Expand All @@ -27,8 +40,15 @@ jQuery(function($){
}
}

$this.addClass("jqInitedTreeview");
$this.find("ul:first").treeview(opts);
$this.addClass("inited");
$ul.treeview(opts);

// SMELL: fix classes
$this.find(".open.expandable").removeClass("expandable").addClass("collapsable");
$this.find(".open.lastExpandable").removeClass("lastExpandable").addClass("lastCollapsable");
$this.find(".open-hitarea.expandable-hitarea").removeClass("expandable-hitarea").addClass("collapsable-hitarea");
$this.find(".open-hitarea.lastExpandable-hitarea").removeClass("lastExpandable-hitarea").addClass("lastCollapsable-hitarea");

$this.css('display', 'block');
});
});
Loading

0 comments on commit 5cdfdb3

Please sign in to comment.