From a245c57400398d2b4b1c2aea94f590a9c0a7d8a8 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 6 Aug 2009 21:36:17 -0700 Subject: Further streamline the code. Organize_Controller: * Remove unnecessary constants * Rename index() to dialog() * Simplify _get_micro_thumb_grid organize.js: * Move sizing code in here from organize_dialog.html.php organize_dialog.html.php: * Move CSS and JS links in here so that we only load them when we need them. * Move sizing code into organize.js organize_thumb_grid.html.php: * Move pagination logic in here, since it's view centric * Collapse the css class determination code and inline it --- modules/organize/controllers/organize.php | 22 +++++---------- modules/organize/helpers/organize_event.php | 2 +- modules/organize/helpers/organize_theme.php | 27 ------------------- modules/organize/js/organize.js | 6 +++++ modules/organize/views/organize_dialog.html.php | 9 +++---- .../organize/views/organize_thumb_grid.html.php | 31 +++++++++++----------- modules/organize/views/organize_tree.html.php | 2 -- 7 files changed, 33 insertions(+), 66 deletions(-) delete mode 100644 modules/organize/helpers/organize_theme.php (limited to 'modules') diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index 95d71e9c..3a81ef4f 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -18,10 +18,7 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Organize_Controller extends Controller { - private static $_MICRO_THUMB_SIZE = 90; - private static $_MICRO_THUMB_PADDING = 10; - - function index($item_id) { + function dialog($item_id) { $item = ORM::factory("item", $item_id); $root = $item->id == 1 ? $item : ORM::factory("item", 1); access::required("view", $item); @@ -36,26 +33,21 @@ class Organize_Controller extends Controller { $parents[$item->id] = 1; $v->album_tree = $this->_tree($root, $parents); - $v->micro_thumb_grid = $this->_get_micro_thumb_grid($item); + $v->micro_thumb_grid = $this->_get_micro_thumb_grid($item, 0); print $v; } - function content($item_id, $offset=0) { + function content($item_id, $offset) { $item = ORM::factory("item", $item_id); access::required("view", $item); access::required("edit", $item); - - $v = $this->_get_micro_thumb_grid($item, $offset); - print $v->__toString(); + print $this->_get_micro_thumb_grid($item, $offset); } - private function _get_micro_thumb_grid($item, $offset=0) { + private function _get_micro_thumb_grid($item, $offset) { $v = new View("organize_thumb_grid.html"); - $v->item_id = $item->id; - $v->children = $item->children(25, $offset); - $v->thumbsize = self::$_MICRO_THUMB_SIZE; - $v->offset = $offset + 25; - + $v->item = $item; + $v->offset = $offset; return $v; } diff --git a/modules/organize/helpers/organize_event.php b/modules/organize/helpers/organize_event.php index 887d9c2d..7d6b3e24 100644 --- a/modules/organize/helpers/organize_event.php +++ b/modules/organize/helpers/organize_event.php @@ -27,7 +27,7 @@ class organize_event_Core { ->id("organize") ->label(t("Organize Album")) ->css_id("gOrganizeLink") - ->url(url::site("organize/index/{$item->id}"))); + ->url(url::site("organize/dialog/{$item->id}"))); } } } diff --git a/modules/organize/helpers/organize_theme.php b/modules/organize/helpers/organize_theme.php deleted file mode 100644 index 0fd117c3..00000000 --- a/modules/organize/helpers/organize_theme.php +++ /dev/null @@ -1,27 +0,0 @@ -item()) && access::can("edit", $theme->item())) { - $theme->script("organize.js"); - $theme->css("organize.css"); - } - } -} diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js index d2006c27..6b4a5934 100644 --- a/modules/organize/js/organize.js +++ b/modules/organize/js/organize.js @@ -4,6 +4,12 @@ * Dynamically initialize the organize dialog when it is displayed */ init: function(data) { + // Resize with 50 pixels padding all around + var size = $.getViewportSize(); + $("#gDialog").dialog("option", "height", size.height() - 100) + .dialog("option", "width", size.width() - 100) + .dialog("option", "position", "center"); + // Deal with ui.jquery bug: http://dev.jqueryui.com/ticket/4475 (target 1.8?) $(".sf-menu li.sfHover ul").css("z-index", 70); diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index 11ce0a37..6001e038 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -1,4 +1,5 @@ +" />

p::purify($title))) ?>

@@ -38,13 +39,9 @@
+ \ No newline at end of file + diff --git a/modules/organize/views/organize_thumb_grid.html.php b/modules/organize/views/organize_thumb_grid.html.php index e6b7aec0..0d54c5c8 100644 --- a/modules/organize/views/organize_thumb_grid.html.php +++ b/modules/organize/views/organize_thumb_grid.html.php @@ -1,19 +1,20 @@ - $child): ?> - - is_album()): ?> - - -
  • - thumb_img(array("class" => "gThumbnail"), $thumbsize, true) ?> -
  • +children(25, $offset) as $child): ?> +
  • " + ref="id ?>"> + thumb_img(array("class" => "gThumbnail"), 90, true) ?> +
  • -= 25): ?> + +children_count() > $offset): ?> - \ No newline at end of file + diff --git a/modules/organize/views/organize_tree.html.php b/modules/organize/views/organize_tree.html.php index 280bdc5f..99b0dc1a 100644 --- a/modules/organize/views/organize_tree.html.php +++ b/modules/organize/views/organize_tree.html.php @@ -1,6 +1,5 @@
  • -
    gBranchText">
  • - -- cgit v1.2.3