diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-08-29 16:33:22 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-08-29 16:33:22 -0700 |
commit | 483d8df91b443a20a614eb5864cabb2a66ac72d2 (patch) | |
tree | 385851fc3bfc080199e2e201b8aa2f56fd17f6b1 /modules | |
parent | 0aceba6f48e5542d3edfbb1f195af50187adbac4 (diff) |
Change the organize tree to expand/collapse. It doesn't properly open
up to the album that you're viewing, and if you move a photo to a
different album it'll reload the entire album tree.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/organize/controllers/organize.php | 18 | ||||
-rw-r--r-- | modules/organize/js/organize.js | 26 | ||||
-rw-r--r-- | modules/organize/views/organize_dialog.html.php | 1 | ||||
-rw-r--r-- | modules/organize/views/organize_tree.html.php | 46 |
4 files changed, 47 insertions, 44 deletions
diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index 2b966657..3cbcfb28 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -25,7 +25,7 @@ class Organize_Controller extends Controller { $v = new View("organize_dialog.html"); $v->album = $album; - $v->album_tree = self::_tree($album); + $v->album_tree = self::_tree(ORM::factory("item", 1)); $v->micro_thumb_grid = self::_get_micro_thumb_grid($album, 0); print $v; } @@ -50,7 +50,7 @@ class Organize_Controller extends Controller { } print json_encode( - array("tree" => self::_tree($album)->__toString(), + array("tree" => self::_tree(ORM::factory("item", 1))->__toString(), "grid" => self::_get_micro_thumb_grid($album, 0)->__toString())); } @@ -132,17 +132,15 @@ class Organize_Controller extends Controller { return $v; } + public function tree($album_id) { + $album = ORM::factory("item", $album_id); + access::required("view", $album); + print self::_tree($album); + } + private static function _tree($album) { $v = new View("organize_tree.html"); - $v->parents = $album->parents(); $v->album = $album; - - if ($album->id == 1) { - $v->peers = array($album); - } else { - $v->peers = $album->parent()->children(null, 0, array("type" => "album")); - } - return $v; } } diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js index 04e14a2f..3dbd0c89 100644 --- a/modules/organize/js/organize.js +++ b/modules/organize/js/organize.js @@ -159,8 +159,34 @@ $(".gMicroThumbGridCell").mousemove($.organize.mouse_move_handler); $(".gOrganizeAlbum").droppable($.organize.branch_droppable); $(".gAlbumText").click($.organize.show_album); + $("#gOrganizeAlbumTree .ui-icon-plus,#gOrganizeAlbumTree .ui-icon-minus").click($.organize.toggle_branch); }, + toggle_branch: function(event) { + event.preventDefault(); + var target = $(event.currentTarget); + var branch = $(target).parent(); + var id = $(event.currentTarget).parent().attr("ref"); + + if ($(target).hasClass("ui-icon-plus")) { + // Expanding + if (!branch.find("ul").length) { + $.get(tree_url.replace("__ALBUM_ID__", id), { }, + function(data) { + branch.replaceWith(data); + $.organize.set_handlers(); + } + ); + } else { + branch.find("ul:eq(0)").slideDown(); + } + } else { + // Contracting + branch.find("ul:eq(0)").slideUp(); + } + $(target).toggleClass("ui-icon-plus"); + $(target).toggleClass("ui-icon-minus"); + }, /** * When the text of a selection is clicked, then show that albums contents diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index b03c066c..d4196460 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -3,6 +3,7 @@ var move_url = "<?= url::site("organize/move_to/__ALBUM_ID__?csrf=$csrf") ?>"; var rearrange_url = "<?= url::site("organize/rearrange/__TARGET_ID__/__BEFORE__?csrf=$csrf") ?>"; var sort_order_url = "<?= url::site("organize/sort_order/__ALBUM_ID__/__COL__/__DIR__?csrf=$csrf") ?>"; + var tree_url = "<?= url::site("organize/tree/__ALBUM_ID__") ?>"; </script> <div id="gOrganize" class="gDialogPanel"> <h1 style="display:none"><?= t("Organize %name", array("name" => p::purify($album->title))) ?></h1> diff --git a/modules/organize/views/organize_tree.html.php b/modules/organize/views/organize_tree.html.php index 36f900ac..4677234c 100644 --- a/modules/organize/views/organize_tree.html.php +++ b/modules/organize/views/organize_tree.html.php @@ -1,44 +1,22 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> -<? foreach ($parents as $parent): ?> -<li class="gOrganizeAlbum ui-icon-left <?= access::can("edit", $parent) ? "" : "gViewOnly" ?>" - ref="<?= $parent->id ?>"> +<li class="gOrganizeAlbum ui-icon-left <?= access::can("edit", $album) ? "" : "gViewOnly" ?>" + ref="<?= $album->id ?>"> <span class="ui-icon ui-icon-minus"> </span> - <span class="gAlbumText" ref="<?= $parent->id ?>"> - <?= p::clean($parent->title) ?> + <span class="gAlbumText" ref="<?= $album->id ?>"> + <?= p::clean($album->title) ?> </span> - <ul class="ui-icon-plus"> - <? endforeach ?> - - <? foreach ($peers as $peer): ?> - <li class="gOrganizeAlbum ui-icon-left <?= access::can("edit", $peer) ? "" : "gViewOnly" ?>" - ref="<?= $peer->id ?>"> - <span class="ui-icon <?= $peer->id == $album->id ? "ui-icon-minus" : "ui-icon-plus" ?>"> + <ul> + <? foreach ($album->children(null, 0, array("type" => "album")) as $child): ?> + <li class="gOrganizeAlbum ui-icon-left <?= access::can("edit", $child) ? "" : "gViewOnly" ?>" + ref="<?= $child->id ?>"> + <span class="ui-icon ui-icon-plus"> </span> - <span class="gAlbumText <?= $peer->id == $album->id ? "selected" : "" ?>" - ref="<?= $peer->id ?>"> - <?= p::clean($peer->title) ?> + <span class="gAlbumText" ref="<?= $child->id ?>"> + <?= p::clean($child->title) ?> </span> - - <? if ($peer->id == $album->id): ?> - <ul class="ui-icon-plus"> - <? foreach ($album->children(null, 0, array("type" => "album")) as $child): ?> - <li class="gOrganizeAlbum ui-icon-left <?= access::can("edit", $child) ? "" : "gViewOnly" ?>" - ref="<?= $child->id ?>"> - <span class="ui-icon ui-icon-plus"> - </span> - <span class="gAlbumText" - ref="<?= $child->id ?>"> - <?= p::clean($child->title) ?> - </span> - </li> - <? endforeach ?> - </ul> - <? endif ?> </li> <? endforeach ?> - - <? foreach ($parents as $parent): ?> </ul> </li> -<? endforeach ?> + |