diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-08-28 14:27:37 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-08-28 14:27:37 -0700 |
commit | cb2171d0825251d619b53f6f80d217326fb6bab5 (patch) | |
tree | 3f4ebee66cdbe06a1aa2c61c9d4527e30d2c83b5 | |
parent | 6dcfdb6432d556f43736d60de8f310f247868bfa (diff) |
Display the sort order in the Organize dialog, and allow users to
change the sort order on the fly.
-rw-r--r-- | modules/gallery/helpers/album.php | 21 | ||||
-rw-r--r-- | modules/organize/controllers/organize.php | 21 | ||||
-rw-r--r-- | modules/organize/css/organize.css | 59 | ||||
-rw-r--r-- | modules/organize/js/organize.js | 22 | ||||
-rw-r--r-- | modules/organize/views/organize_dialog.html.php | 20 |
5 files changed, 71 insertions, 72 deletions
diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php index 1b6b875d..d46f21ac 100644 --- a/modules/gallery/helpers/album.php +++ b/modules/gallery/helpers/album.php @@ -116,13 +116,7 @@ class album_Core { $sort_order->dropdown("column", array("id" => "gAlbumSortColumn")) ->label(t("Sort by")) - ->options(array("weight" => t("Manual"), - "captured" => t("Date captured"), - "created" => t("Date uploaded"), - "title" => t("Title"), - "updated" => t("Date modified"), - "view_count" => t("Number of views"), - "rand_key" => t("Random"))) + ->options(album::get_sort_order_options()) ->selected($parent->sort_column); $sort_order->dropdown("direction", array("id" => "gAlbumSortDirection")) ->label(t("Order")) @@ -137,4 +131,17 @@ class album_Core { $form->add_rules_from(ORM::factory("item")); return $form; } + + /** + * Return a structured set of all the possible sort orders. + */ + static function get_sort_order_options() { + return array("weight" => t("Manual"), + "captured" => t("Date captured"), + "created" => t("Date uploaded"), + "title" => t("Title"), + "updated" => t("Date modified"), + "view_count" => t("Number of views"), + "rand_key" => t("Random")); + } } diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index f56ad006..10b109f6 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -25,7 +25,7 @@ class Organize_Controller extends Controller { access::required("edit", $item); $v = new View("organize_dialog.html"); - $v->title = $item->title; + $v->album = $item; $parents = array(); foreach ($item->parents() as $parent) { $parents[$parent->id] = 1; @@ -84,6 +84,25 @@ class Organize_Controller extends Controller { "url" => url::site("organize/run/$task->id?csrf=" . access::csrf_token()))); } + function resort($target_id, $col, $dir) { + access::verify_csrf(); + + $album = ORM::factory("item", $target_id); + access::required("view", $album); + access::required("edit", $album); + + $options = album::get_sort_order_options(); + if (!isset($options[$col])) { + return; + } + + $album->sort_column = $col; + $album->sort_order = $dir; + $album->save(); + + print self::_get_micro_thumb_grid($album, 0); + } + private static function _get_micro_thumb_grid($item, $offset) { $v = new View("organize_thumb_grid.html"); $v->item = $item; diff --git a/modules/organize/css/organize.css b/modules/organize/css/organize.css index d717bcae..52de87fc 100644 --- a/modules/organize/css/organize.css +++ b/modules/organize/css/organize.css @@ -134,63 +134,20 @@ } /**************************************************************** - * Organize Edit Drawer styling + * Organize Controls styling */ -#gOrganizeEditDrawer { +#gOrganizeControls { + padding-left: 8px; background-color: #13A; + color: #ccc; width: 100% !important; } -#gOrganizeEditDrawerPanel { - background-color: #fff; - border: 1px solid #13A; - display: none; - height: 195px; -} - -#gOrganizeEditDrawerHandle { - height: 30px; -} - -#gOrganizeEditHandleLeft { - background-color: #FFF; - float: left; - height: 30px; - 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; -} - -#gOrganizeEditHandleButtonsRight { - float: right; - height: 20px; - padding: 2px 10px; -} - -#gOrganizeEditHandleButtonsRight a { - float: left; - margin: 0 2.5px; +#gOrganizeControls select { + display: inline; } -#gOrganizeEditHandleRight { - background-color: #FFF; - background-position: -15px 0; +#gOrganizeClose { float: right; - height: 30px; - width: 15px; + margin-right: 12px; } diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js index ec6bd924..96309787 100644 --- a/modules/organize/js/organize.js +++ b/modules/organize/js/organize.js @@ -125,9 +125,8 @@ $("#gOrganize .gProgressBar").progressbar("value", data.percent_complete); if (data.done) { var height = $("#gOrganizeProgress").height(); - $("#gOrganizeProgress").toggle(); + $("#gOrganizeProgress").slideUp(); $("#gMicroThumbPanel").height($("#gDialog").innerHeight() - 90); - //$("#gMicroThumbPanel").height($("#gMicroThumbPanel").height() + height); if (data.tree) { $("#gOrganizeAlbumTree").html(data.tree); } @@ -171,10 +170,14 @@ window.location.reload(); }); - $("#gDialog #gMicroThumbDone").click(function(event) { + $("#gDialog #gOrganizeClose").click(function(event) { $("#gDialog").dialog("close"); }); + $("#gOrganizeSortColumn,#gOrganizeSortDir").change(function(event) { + $.organize.resort($("#gOrganizeSortColumn").attr("value"), $("#gOrganizeSortDir").attr("value")); + }); + $.organize.set_handlers(); }, @@ -219,6 +222,19 @@ $("#gMicroThumbGrid").html(data); $.organize.set_handlers(); }); + }, + + /** + * Change the sort order. + */ + resort: function(column, dir) { + var url = sort_order_url + .replace("__COL__", column) + .replace("__DIR__", dir); + $.get(url, function(data) { + $("#gMicroThumbGrid").html(data); + $.organize.set_handlers(); + }); } }; })(jQuery); diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index 7c09266f..a3aae05b 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -2,9 +2,10 @@ <script type="text/javascript"> var move_url = "<?= url::site("organize/move/__TARGET_ID__?csrf=$csrf") ?>"; var rearrange_url = "<?= url::site("organize/rearrange/__TARGET_ID__/__BEFORE__?csrf=$csrf") ?>"; + var sort_order_url = "<?= url::site("organize/resort/$album->id/__COL__/__DIR__?csrf=$csrf") ?>"; </script> <div id="gOrganize" class="gDialogPanel"> - <h1 style="display:none"><?= t("Organize %name", array("name" => p::purify($title))) ?></h1> + <h1 style="display:none"><?= t("Organize %name", array("name" => p::purify($album->title))) ?></h1> <div id="bd"> <div class="yui-gf"> <div class="yui-u first"> @@ -27,15 +28,14 @@ <?= $micro_thumb_grid ?> </ul> </div> - <div id="gOrganizeEditDrawer" class="yui-u"> - <div id="gOrganizeEditDrawerPanel" class="yui-gf"> - </div> - <div id="gOrganizeEditDrawerHandle"> - <div id="gOrganizeEditHandleButtonsRight"> - <a id="gMicroThumbDone" href="#" ref="done" - class="gButtonLink ui-corner-all ui-state-default"><?= t("Close") ?></a> - </div> - </div> + <div id="gOrganizeControls"> + <a id="gOrganizeClose" href="#" ref="done" + class="gButtonLink ui-corner-all ui-state-default"><?= t("Close") ?></a> + <form> + <?= t("Sort order") ?> + <?= form::dropdown(array("id" => "gOrganizeSortColumn"), album::get_sort_order_options(), $album->sort_column) ?> + <?= form::dropdown(array("id" => "gOrganizeSortDir"), array("ASC" => "Ascending", "DESC" => "Descending"), $album->sort_order) ?> + </form> </div> <div id="gOrganizeProgress" style="display: none"> <div class="gProgressBar"></div> |