1
0

Create a widget ui.gallery_tag_cloud to initialize and run the tag cloud block

This commit is contained in:
Tim Almdal 2009-10-01 13:10:30 -07:00
parent 3019abefea
commit 79a7bd1aec
3 changed files with 109 additions and 51 deletions

View File

@ -0,0 +1,25 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class tag_cloud_theme_Core {
static function head($theme) {
$theme->script("tag_cloud.js");
// return html::script("modules/tag_cloud/js/tag_cloud.js");
}
}

View File

@ -0,0 +1,81 @@
(function($) {
$.widget("ui.gallery_tag_cloud", {
_init: function() {
var self = this;
self._set_tag_cloud();
this._ajax_form();
this._autocomplete();
},
_autocomplete: function() {
var url = $("#gTagCloud3D").attr("title") + "/autocomplete";
$("#gAddTagForm input:text").autocomplete(
url, {
max: 30,
multiple: true,
multipleSeparator: ',',
cacheLength: 1}
);
},
_ajax_form: function() {
var self = this;
var form = $("#gAddTagForm");
form.ajaxForm({
dataType: "json",
success: function(data) {
if (data.result == "success") {
$.get($("#gTagCloud3D").attr("title"), function(data, textStatus) {
$("#gTagCloud3D").html(data);
self._set_tag_cloud();
});
}
form.resetForm();
}
});
},
_set_tag_cloud: function() {
var self = this;
var width = $("#gTagCloud3D").width();
var tags = document.createElement("tags");
$("#gTagCloud3D a").each(function(i) {
var addr = $(this).clone();
$(addr).attr("style", "font-size:" + $(this).css("fontSize") + ";");
$(tags).append(addr);
});
var object = document.createElement("object");
$(object).attr({
type: "application/x-shockwave-flash",
data: self.options.movie,
width: width,
height: .75 * width
});
var value = "tcolor=" + self.options.tcolor + "&tcolor2=" + self.options.tcolor2 +
"&hicolor=" + self.options.hicolor + "&tspeed=" + self.options.tspeed +
"&distr=" + self.options.distr + "&mode=" + self.options.mode +
"&tagcloud=" + escape("<tags>" + $(tags).html() + "</tags>");
$(object).append("<param name=\"movie\" value=\"" + self.options.movie +"\" />")
.append("<param name=\"wmode\" value=\"" + self.options.transparent + "\" />")
.append("<param name=\"bgcolor\" value=\"" + self.options.bgColor + "\" />")
.append("<param name=\"allowScriptAccess\"value=\"" + self.options.scriptAccess + "\" />")
.append("<param name=\"flashvars\" value=\"" + value + "\" />");
$("#gTagCloud3D").html(object);
}
});
$.extend($.ui.gallery_tag_cloud, {
defaults: {
bgColor: false,
wmode: "transparent",
scriptAccess: "always",
tcolor: "0x333333",
tcolor2: "0x009900",
hicolor: "0x000000",
tspeed: 100,
distr: "true",
mode: "tag"
}
});
})(jQuery);

View File

@ -1,58 +1,10 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<script>
function ajaxify_tag3d_form() {
$("#gTag3D form").ajaxForm({
dataType: "json",
success: function(data) {
if (data.result == "success") {
$.get($("#gTagCloud3D").attr("title"), function(data, textStatus) {
$("#gTagCloud3D").html(data);
set_tag_cloud();
});
}
$("#gTag3D form").resetForm();
}
});
}
$("document").ready(function() {
ajaxify_tag3d_form();
set_tag_cloud();
$("#gTag3D").gallery_tag_cloud({
movie: "<?= url::file("modules/tag_cloud/lib/tagcloud.swf") ?>",
});
});
$("#gAddTagForm").ready(function() {
var url = $("#gTagCloud").attr("title") + "/autocomplete";
$("#gAddTagForm input:text").autocomplete(
url, {
max: 30,
multiple: true,
multipleSeparator: ',',
cacheLength: 1}
);
});
function set_tag_cloud() {
var width = $("#gTagCloud3D").width();
var tags = document.createElement("tags");
$("#gTagCloud3D a").each(function(i) {
var addr = $(this).clone();
$(addr).attr("style", "font-size:" + $(this).css("fontSize")) + ";";
$(tags).append(addr);
});
var object = document.createElement("object");
$(object).attr({
type: "application/x-shockwave-flash",
data: "<?= url::file("modules/tag_cloud/lib/tagcloud.swf") ?>",
width: width,
height: .75 * width
});
$(object).append("<param name=\"movie\" value=\"<?= url::file("modules/tag_cloud/lib/tagcloud.swf") ?>\" />");
$(object).append("<param name=\"bgcolor\" value=\"#ffffff\" />");
$(object).append("<param name=\"allowScriptAccess\" value=\"always\" />");
var value = 'tcolor=0x333333&tcolor2=0x009900&hicolor=0x000000&tspeed=100&distr=true&mode=tags&tagcloud=' + escape("<tags>" + $(tags).html() + "</tags>");
$(object).append("<param name=\"flashvars\" value=\"" + value + "\" />");
console.log($(object).html());
$("#gTagCloud3D").html(object);
}
</script>
<div id="gTagCloud3D" title="<?= url::site("tags") ?>">
<?= $cloud ?>