summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-05-21 01:31:29 +0000
committerTim Almdal <tnalmdal@shaw.ca>2009-05-21 01:31:29 +0000
commita9e3692027dc767b340242ed18fe7184cbfd883d (patch)
tree125e9d3cdb28c5acdd34e1bc15fe80df030bf8e7 /modules
parentf24c8f66ea9673d812c882dd7db6fbe49bd01dfb (diff)
1) This provides the editting functionality for albums and photos in the
organize feature. 2) Remove the tag functionality at this point 3) Added a callback to handle validating conflicting names (only used by organize at this point. 4) Closes #231
Diffstat (limited to 'modules')
-rw-r--r--modules/organize/css/organize.css6
-rw-r--r--modules/organize/js/organize.js141
-rw-r--r--modules/organize/views/organize.html.php25
-rw-r--r--modules/organize/views/organize_button_pane.html.php75
-rw-r--r--modules/organize/views/organize_edit.html.php10
-rw-r--r--modules/tag/helpers/tag_event.php34
-rw-r--r--modules/tag/views/tag_organize.html.php25
7 files changed, 166 insertions, 150 deletions
diff --git a/modules/organize/css/organize.css b/modules/organize/css/organize.css
index cef25f1c..0fdf5aef 100644
--- a/modules/organize/css/organize.css
+++ b/modules/organize/css/organize.css
@@ -170,12 +170,18 @@
width: 15px;
}
+#gOrganizeEditHandleButtonsMiddle,
#gOrganizeEditHandleButtonsLeft {
float: left;
height: 20px;
padding: 2px 10px;
}
+#gOrganizeEditHandleButtonsMiddle {
+ margin-left: 20px;
+}
+
+#gOrganizeEditHandleButtonsMiddle a,
#gOrganizeEditHandleButtonsLeft a {
float: left;
margin: 0 2.5px;
diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js
index 538e366d..30b3f8b6 100644
--- a/modules/organize/js/organize.js
+++ b/modules/organize/js/organize.js
@@ -150,9 +150,7 @@ var selectable = {
setDrawerButtonState();
},
stop: function(event, ui) {
- if ($("#gMicroThumbGrid li.ui-selected").length > 0) {
- getEditForm();
- }
+ getEditForm();
}
};
@@ -197,11 +195,21 @@ function drawerHandleButtonsClick(event) {
var operation = $(this).attr("ref");
switch (operation) {
case "edit":
+ case "close":
$("#gOrganizeEditDrawerPanel").animate(
{"height": "toggle", "display": "block"},
{duration: "fast",
complete: function() {
setSelectedThumbs();
+ if (operation == "close") {
+ $("#gOrganizeEditHandleButtonsLeft a[ref='edit']").css("display", "inline-block");
+ $("#gOrganizeEditHandleButtonsLeft a[ref='close']").css("display", "none");
+ $("#gOrganizeEditHandleButtonsMiddle a").css("display", "none");
+ } else {
+ $("#gOrganizeEditHandleButtonsLeft a[ref='edit']").css("display", "none");
+ $("#gOrganizeEditHandleButtonsLeft a[ref='close']").css("display", "inline-block");
+ $("#gOrganizeEditHandleButtonsMiddle a").css("display", "inline-block");
+ }
},
step: function() {
$("#gMicroThumbPanel").height(heightMicroThumbPanel - $(this).height());
@@ -209,22 +217,59 @@ function drawerHandleButtonsClick(event) {
});
break;
case "select-all":
- $(".gMicroThumbContainer").addClass("ui-selected");
+ $("#gMicroThumbGrid li").addClass("ui-selected");
$("#gMicroThumbSelectAll").hide();
$("#gMicroThumbUnselectAll").show();
+ setDrawerButtonState();
+ getEditForm();
break;
case "unselect-all":
- $(".gMicroThumbContainer").removeClass("ui-selected");
+ $("#gMicroThumbGrid li").removeClass("ui-selected");
$("#gMicroThumbSelectAll").show();
$("#gMicroThumbUnselectAll").hide();
+ setDrawerButtonState();
break;
- case "close":
+ case "done":
$("#gDialog").dialog("close");
break;
+ case "submit":
+ var currentTab = $("#gOrganizeEditForm").tabs("option", "selected");
+ var form = $("#pane-"+currentTab+" form");
+ var url = $(form).attr("action")
+ .replace("__FUNCTION__", $(form).attr("ref"));
+ $.ajax({
+ data: $(form).serialize(),
+ dataType: "json",
+ success: function (data, textStatus) {
+ if (data.task) {
+ // @todo if task is sent then create a progress bar and run the task
+ } else {
+ $("#pane-"+currentTab).children("form").replaceWith(data.form);
+ if (data.message) {
+ $("#pane-"+currentTab + " form").before("<div class=\"gSuccess\">" + data.message +"</div>");
+ }
+ }
+ },
+ type: "POST",
+ url: url
+ });
+ break;
+ case "reset":
+ currentTab = $("#gOrganizeEditForm").tabs("option", "selected");
+ form = $("#pane-"+currentTab+" form");
+ $.ajax({
+ data: serializeItemIds("#gMicroThumbPanel li.ui-selected"),
+ dataType: "html",
+ success: function (data, textStatus) {
+ $("#pane-"+currentTab + " form").replaceWith(data);
+ },
+ type: "GET",
+ url: $(form).attr("action").replace("__FUNCTION__", "reset_" + $(form).attr("ref"))
+ });
+ break;
default:
- var postData = serializeItemIds("#gMicroThumbPanel li.ui-selected");
$.ajax({
- data: postData,
+ data: serializeItemIds("#gMicroThumbPanel li.ui-selected"),
dataType: "json",
success: operationCallback,
type: "POST",
@@ -408,25 +453,22 @@ function get_url(uri, parms) {
function setDrawerButtonState() {
$("#gOrganizeFormThumbStack").empty();
$("#gOrganizeEditForm").empty();
- switch ($("#gMicroThumbGrid li.ui-selected").length) {
- case 0:
+ var selectedCount = $("#gMicroThumbGrid li.ui-selected").length;
+ if (selectedCount) {
+ $("#gOrganizeEditHandleButtonsLeft a").removeAttr("disabled");
+ $("#gOrganizeEditHandleButtonsLeft a").removeClass("ui-state-disabled");
+
+ if (selectedCount > 1) {
+ $("#gOrganizeEditHandleButtonsLeft a[ref='albumCover']").attr("disabled", true);
+ $("#gOrganizeEditHandleButtonsLeft a[ref='albumCover']").addClass("ui-state-disabled");
+ }
+ setSelectedThumbs();
+ } else {
if ($("#gOrganizeEditDrawerPanel::visible").length) {
- $("#gOrganizeEditHandleButtonsLeft a[ref='edit']").trigger("click");
+ $("#gOrganizeEditHandleButtonsLeft a[ref='close']").trigger("click");
}
$("#gOrganizeEditHandleButtonsLeft a").attr("disabled", true);
$("#gOrganizeEditHandleButtonsLeft a").addClass("ui-state-disabled");
- break;
- case 1:
- $("#gOrganizeEditHandleButtonsLeft a").removeAttr("disabled");
- $("#gOrganizeEditHandleButtonsLeft a").removeClass("ui-state-disabled");
- setSelectedThumbs();
-// getEditForm();
- break;
- default:
- $("#gOrganizeEditHandleButtonsLeft a[ref='albumCover']").attr("disabled", true);
- $("#gOrganizeEditHandleButtonsLeft a[ref='albumCover']").addClass("ui-state-disabled");
- setSelectedThumbs();
-// getEditForm();
}
}
@@ -456,17 +498,25 @@ function setSelectedThumbs() {
}
function getEditForm() {
- var postData = "";
- $("li.ui-selected").each(function(i) {
- postData += "&item[]=" + $(this).attr("ref");
- });
- var url_data = get_url("organize/editForm", {}) + postData;
- $.get(url_data, function(data, textStatus) {
+ if ($("#gMicroThumbGrid li.ui-selected").length > 0) {
+ var postData = serializeItemIds("li.ui-selected");
+ var url_data = get_url("organize/editForm", {}) + postData;
+ $.get(url_data, function(data, textStatus) {
+ $("#gOrganizeEditForm").tabs("destroy");
+ $("#gOrganizeEditForm").html(data);
+ if ($("#gOrganizeEditForm ul li").length) {
+ $("#gOrganizeEditForm").tabs();
+ $("#gOrganizeEditHandleButtonsMiddle a").removeAttr("disabled");
+ $("#gOrganizeEditHandleButtonsMiddle a").removeClass("ui-state-disabled");
+ } else {
+ $("#gOrganizeEditHandleButtonsMiddle a").attr("disabled", true);
+ $("#gOrganizeEditHandleButtonsMiddle a").addClass("ui-state-disabled");
+ }
+ });
+ } else {
$("#gOrganizeEditForm").tabs("destroy");
- //$("#gOrganizeEditForm").empty();
- $("#gOrganizeEditForm").html(data);
- $("#gOrganizeEditForm").tabs();
- });
+ $("#gOrganizeEditForm").empty();
+ }
}
function serializeItemIds(selector) {
@@ -478,6 +528,16 @@ function serializeItemIds(selector) {
return postData;
}
+function submitCurrentForm(event) {
+ console.log("submitCurrentForm");
+ return false;
+}
+
+function resetCurrentForm(event) {
+ console.log("resetCurrentForm");
+ return false;
+}
+
function createProgressDialog(title) {
$("body").append("<div id='gOrganizeProgressDialog'>" +
"<div class='gProgressBar'></div>" +
@@ -548,12 +608,13 @@ function getViewportSize() {
function displayAjaxError(error) {
$("body").append("<div id=\"gAjaxError\" title=\"" + FATAL_ERROR + "\">" + error + "</div>");
+
$("#gAjaxError").dialog({
- autoOpen: true,
- autoResize: false,
- modal: true,
- resizable: true,
- width: 610,
- height: $("#gDialog").height()
- });
+ autoOpen: true,
+ autoResize: false,
+ modal: true,
+ resizable: true,
+ width: 610,
+ height: $("#gDialog").height()
+ });
}
diff --git a/modules/organize/views/organize.html.php b/modules/organize/views/organize.html.php
index 60c4a524..b1f062a1 100644
--- a/modules/organize/views/organize.html.php
+++ b/modules/organize/views/organize.html.php
@@ -36,25 +36,18 @@
ref="<?= url::site("organize/content/__ITEM_ID__?width=__WIDTH__&height=__HEIGHT__&offset=__OFFSET__") ?>">
<ul id="gMicroThumbGrid"></ul>
</div>
- <div id="gOrganizeEditDrawer" class="yui-u">
- <div id="gOrganizeEditDrawerPanel" class="yui-gf">
- <div id="gOrganizeFormThumbs" class="yui-u first">
- <ul id="gOrganizeFormThumbStack" />
- </div>
- <div id="gOrganizeEditForm">
- </div>
+ <div id="gOrganizeEditDrawer" class="yui-u">
+ <div id="gOrganizeEditDrawerPanel" class="yui-gf">
+ <div id="gOrganizeFormThumbs" class="yui-u first">
+ <ul id="gOrganizeFormThumbStack" />
</div>
- <div id="gOrganizeEditDrawerHandle">
- <div id="gOrganizeEditHandleButtonsLeft">
- <?= $button_pane ?>
- </div>
- <div id="gOrganizeEditHandleButtonsRight">
- <a id="gMicroThumbSelectAll" href="#" ref="select-all" class="gButtonLink ui-corner-all ui-state-default"><?= t("Select all") ?></a>
- <a id="gMicroThumbUnselectAll" href="#" ref="unselect-all" style="display: none" class="gButtonLink ui-corner-all ui-state-default"><?= t("Deselect all") ?></a>
- <a id="gMicroThumbDone" href="#" ref="close" class="gButtonLink ui-corner-all ui-state-default"><?= t("Done") ?></a>
- </div>
+ <div id="gOrganizeEditForm">
</div>
</div>
+ <div id="gOrganizeEditDrawerHandle">
+ <?= $button_pane ?>
+ </div>
+ </div>
</div>
</div>
</div>
diff --git a/modules/organize/views/organize_button_pane.html.php b/modules/organize/views/organize_button_pane.html.php
index 9902eafb..cd780d5e 100644
--- a/modules/organize/views/organize_button_pane.html.php
+++ b/modules/organize/views/organize_button_pane.html.php
@@ -1,39 +1,50 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
+<div id="gOrganizeEditHandleButtonsLeft">
+ <a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="edit"
+ disabled="1" title="<?= t("Open Drawer") ?>">
+ <span class="ui-icon ui-icon-arrowthickstop-1-n"><?= t("Open Drawer") ?></span>
+ </a>
-<a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="edit"
- disabled="1" title="<?= t("Edit Selection") ?>">
- <span class="ui-icon ui-icon-pencil">
- <?= t("Edit Selection") ?>
- </span>
-</a>
+ <a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="close"
+ disabled="1" title="<?= t("Close Drawer") ?>" style="display: none">
+ <span class="ui-icon ui-icon-arrowthickstop-1-s"><?= t("Close Drawer") ?></span>
+ </a>
-<? if (graphics::can("rotate")): ?>
-<a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="rotateCcw"
- disabled="1" title="<?= t("Rotate 90 degrees counter clockwise") ?>">
- <span class="ui-icon ui-icon-rotate-ccw">
- <?= t("Rotate 90 degrees counter clockwise") ?>
- </span>
-</a>
+ <? if (graphics::can("rotate")): ?>
+ <a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="rotateCcw"
+ disabled="1" title="<?= t("Rotate 90 degrees counter clockwise") ?>">
+ <span class="ui-icon ui-icon-rotate-ccw"><?= t("Rotate 90 degrees counter clockwise") ?></span>
+ </a>
-<a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="rotateCw"
- disabled="1" title="<?= t("Rotate 90 degrees clockwise") ?>">
- <span class="ui-icon ui-icon-rotate-cw">
- <?= t("Rotate 90 degrees clockwise") ?>
- </span>
-</a>
-<? endif ?>
+ <a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="rotateCw"
+ disabled="1" title="<?= t("Rotate 90 degrees clockwise") ?>">
+ <span class="ui-icon ui-icon-rotate-cw"> <?= t("Rotate 90 degrees clockwise") ?></span>
+ </a>
+ <? endif ?>
-<a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="albumCover"
- disabled="1" title="<?= t("Choose this photo as the album cover") ?>">
- <span class="ui-icon ui-icon-star">
- <?= t("Choose this photo as the album cover") ?>
- </span>
-</a>
+ <a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="albumCover"
+ disabled="1" title="<?= t("Choose this photo as the album cover") ?>">
+ <span class="ui-icon ui-icon-star"><?= t("Choose this photo as the album cover") ?></span>
+ </a>
-<a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="delete"
- disabled="1" title="<?= t("Delete selection") ?>">
- <span class="ui-icon ui-icon-trash">
- <?= t("Delete selection") ?>
- </span>
-</a>
+ <a class="gButtonLink ui-corner-all ui-state-default ui-state-disabled" href="#" ref="delete"
+ disabled="1" title="<?= t("Delete selection") ?>">
+ <span class="ui-icon ui-icon-trash"><?= t("Delete selection") ?></span>
+ </a>
+</div>
+<div id="gOrganizeEditHandleButtonsMiddle">
+ <a class="gButtonLink ui-corner-all ui-state-default" href="#" ref="submit"
+ title="<?= t("Apply Changes") ?>" style="display: none" >
+ <span class="ui-icon ui-icon-check"><?= t("Apply Changes") ?></span>
+ </a>
+ <a class="gButtonLink ui-corner-all ui-state-default" href="#" ref="reset"
+ title="<?= t("Reset Form") ?>" style="display: none" >
+ <span class="ui-icon ui-icon-closethick"><?= t("Reset Form") ?></span>
+ </a>
+</div>
+<div id="gOrganizeEditHandleButtonsRight">
+ <a id="gMicroThumbSelectAll" href="#" ref="select-all" class="gButtonLink ui-corner-all ui-state-default"><?= t("Select all") ?></a>
+ <a id="gMicroThumbUnselectAll" href="#" ref="unselect-all" style="display: none" class="gButtonLink ui-corner-all ui-state-default"><?= t("Deselect all") ?></a>
+ <a id="gMicroThumbDone" href="#" ref="done" class="gButtonLink ui-corner-all ui-state-default"><?= t("Done") ?></a>
+</div>
diff --git a/modules/organize/views/organize_edit.html.php b/modules/organize/views/organize_edit.html.php
index c0fc43e5..1adf290f 100644
--- a/modules/organize/views/organize_edit.html.php
+++ b/modules/organize/views/organize_edit.html.php
@@ -5,6 +5,10 @@
<? endforeach?>
</ul>
-<? foreach ($panes as $idx => $pane): ?>
- <div id="pane-<?= $idx ?>" class="gOrganizeEditPane"><?= $pane["content"] ?></div>
-<? endforeach?>
+<? if (count($panes) > 0): ?>
+ <? foreach ($panes as $idx => $pane): ?>
+ <div id="pane-<?= $idx ?>" class="gOrganizeEditPane ui-tabs-hide"><?= $pane["content"] ?></div>
+ <? endforeach?>
+<? else: ?>
+<div class="gWarning"><?= t("No Edit pages apply to the selected items") ?></div>
+<? endif ?> \ No newline at end of file
diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php
index a13ae99c..735422b5 100644
--- a/modules/tag/helpers/tag_event.php
+++ b/modules/tag/helpers/tag_event.php
@@ -59,38 +59,4 @@ class tag_event_Core {
"SELECT `tag_id` from {items_tags} WHERE `item_id` = $item->id)");
$db->delete("items_tags", array("item_id" => "$item->id"));
}
-
- static function organize_form_creation($event_parms) {
- $v = new View("tag_organize.html");
- $v->tags = array();
-
- $ids = implode(", ", $event_parms->itemids);
- $db = Database::instance();
- $tags = $db->query("SELECT it.tag_id, t.name,
- COUNT(DISTINCT it.item_id) as item_count,
- UPPER(SUBSTR(t.name, 1, 1)) as first_letter
- FROM {items_tags} it, {tags} t
- WHERE it.tag_id = t.id
- AND it.item_id in($ids)
- GROUP BY it.tag_id
- ORDER BY first_letter ASC, t.name ASC");
- foreach ($tags as $tag) {
- $v->tags[$tag->first_letter]["taglist"][] =
- array("id" => $tag->tag_id, "tag" => $tag->name, "count" => $tag->item_count);
- }
- $v->tag_count = $tags->count();
-
- $letters = $db->query("SELECT COUNT(DISTINCT it.item_id) as letter_count,
- UPPER(SUBSTR(t.name, 1, 1)) as first_letter
- FROM {items_tags} it, {tags} t
- WHERE it.tag_id = t.id
- AND it.item_id in($ids)
- GROUP BY first_letter
- ORDER BY first_letter ASC");
- foreach ($letters as $letter) {
- $v->tags[$letter->first_letter]["count"] = $letter->letter_count;
- }
-
- $event_parms->panes[] = array("label" => t("Manage Tags"), "content" => $v);
- }
}
diff --git a/modules/tag/views/tag_organize.html.php b/modules/tag/views/tag_organize.html.php
deleted file mode 100644
index bb46b861..00000000
--- a/modules/tag/views/tag_organize.html.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.") ?>
-<span id="gTagCount"><?= t2("There is one tag", "There are %count tags", $tag_count) ?></span>
-<span id="gAddTag">
- <a id="gAddTagButton" href="#" class="gButtonLink"><?= t("Click to Add Tag") ?></a>
-</span>
-<? foreach ($tags as $firstLetter => $tagGroup): ?>
-<div class="gTagGroup">
- <strong><?= $firstLetter ?></strong><span class="understate">&nbsp;(<?= $tagGroup["count"] ?>)</span>
- <ul>
- <? foreach ($tagGroup["taglist"] as $taglist): ?>
- <li>
- <span id="gTag-<?= $taglist['id'] ?>" class="gEditable tag-name"><?= $taglist["tag"] ?></span>
- <span class="understate">(<?= $taglist["count"] ?>)</span>
-
- <!-- a href="<?= url::site("admin/tags/form_delete/{$taglist['id']}") ?>"
- class="gDialogLink delete-link gButtonLink" -->
- <a href="#"
- class="gDialogLink delete-link gButtonLink">
- <span class="ui-icon ui-icon-trash"><?= t("Delete tag") ?></span>
- </a>
- </li>
- <? endforeach ?>
- </ul>
-</div>
-<? endforeach ?> \ No newline at end of file