diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-08-06 16:15:40 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-08-06 16:15:40 -0700 |
commit | 3850587519b6f281531651e6790803c3eaa41244 (patch) | |
tree | d3e2329246f0e883637a2e60602c9df3da28ccb0 | |
parent | 7ea05eacd7b8bd18d817996c5240b33b2a79fd18 (diff) | |
parent | 794a7a5abf38ed828329cb0023df938479e90901 (diff) |
Merge branch 'master' of git@github.com:talmdal/gallery3 into talmdal_branch
-rw-r--r-- | modules/organize/helpers/organize_event.php | 2 | ||||
-rw-r--r-- | modules/organize/helpers/organize_theme.php | 7 | ||||
-rw-r--r-- | modules/organize/js/organize.js | 131 | ||||
-rw-r--r-- | modules/organize/views/organize_dialog.html.php | 10 |
4 files changed, 61 insertions, 89 deletions
diff --git a/modules/organize/helpers/organize_event.php b/modules/organize/helpers/organize_event.php index 99a28673..887d9c2d 100644 --- a/modules/organize/helpers/organize_event.php +++ b/modules/organize/helpers/organize_event.php @@ -23,7 +23,7 @@ class organize_event_Core { if ($item && access::can("edit", $item) && $item->is_album()) { $menu->get("options_menu") - ->append(Menu::factory("link") + ->append(Menu::factory("dialog") ->id("organize") ->label(t("Organize Album")) ->css_id("gOrganizeLink") diff --git a/modules/organize/helpers/organize_theme.php b/modules/organize/helpers/organize_theme.php index f01ab88b..0fd117c3 100644 --- a/modules/organize/helpers/organize_theme.php +++ b/modules/organize/helpers/organize_theme.php @@ -19,8 +19,9 @@ */ class organize_theme { static function head($theme) { - //$theme->script("organize_init.js"); - $theme->script("organize.js"); - $theme->css("organize.css"); + if (access::can("view", $theme->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 3e58f3f3..e4d4a9a2 100644 --- a/modules/organize/js/organize.js +++ b/modules/organize/js/organize.js @@ -1,91 +1,52 @@ (function($) { - $.fn.organize = function() { - var size = $.getViewportSize(); - var height = size.height() - 100; // Leave 50 pixels on the top and bottom of the dialog - var width = size.width() - 100; // Leave 50 pixels on the left and right of the dialog - return this.each(function() { - $(this).click(function(event) { - var href = event.target.href; - - $("body").append('<div id="gOrganizeDialog"></div>'); - - $("#gOrganizeDialog").dialog({ - autoOpen: false, - modal: true, - resizable: false, - width: width, - height: height, - position: "center", - close: function () { - $("#gOrganizeDialog").dialog("destroy").remove(); - document.location.reload(); - }, - zIndex: 75 - }); - $.get(href, _init); - return false; + $.organize = { + /** + * Dynamically initialize the organize dialog when it is displayed + */ + init: function(data) { + // Deal with ui.jquery bug: http://dev.jqueryui.com/ticket/4475 (target 1.8?) + $(".sf-menu li.sfHover ul").css("z-index", 70); + + var height = $("#gOrganizeDetail").innerHeight(); + $("#gMicroThumbPanel").height(height - $("#gOrganizeEditDrawerHandle").outerHeight()); + + $("#gDialog #gMicroThumbDone").click(function(event) { + $("#gDialog").dialog("close"); + window.location.reload(); }); - }); - }; - - /** - * Dynamically initialize the organize dialog when it is displayed - */ - function _init(data) { - // Deal with ui.jquery bug: http://dev.jqueryui.com/ticket/4475 (target 1.8?) - $(".sf-menu li.sfHover ul").css("z-index", 70); - $("#gOrganizeDialog").html(data); - $("#gOrganizeDialog").dialog("open"); - - var height = $("#gOrganizeDetail").innerHeight(); - $("#gMicroThumbPanel").height(height - $("#gOrganizeEditDrawerHandle").outerHeight()); - - if ($("#gOrganizeDialog h1").length) { - $("#gOrganizeDialog").dialog('option', 'title', $("#gOrganizeDialog h1:eq(0)").html()); - } else if ($("#gOrganizeDialog fieldset legend").length) { - $("#gOrganizeDialog").dialog('option', 'title', $("#gOrganizeDialog fieldset legend:eq(0)").html()); + $(".gBranchText span").click($.organize.collapse_or_expand_tree); + $(".gBranchText").click($.organize.setContents); + }, + + /** + * Open or close a branch. If the children is a div placeholder, replace with <ul> + */ + collapse_or_expand_tree: function (event) { + event.stopPropagation(); + if ($(event.currentTarget).hasClass("ui-icon-minus")) { + $(event.currentTarget).removeClass("ui-icon-minus").addClass("ui-icon-plus"); + } else { + $(event.currentTarget).removeClass("ui-icon-plus").addClass("ui-icon-minus"); + } + $("#gOrganizeChildren-" + $(event.currentTarget).attr("ref")).toggle(); + }, + + /** + * When the text of a selection is clicked, then show that albums contents + */ + setContents: function(event) { + event.preventDefault(); + if ($(event.currentTarget).hasClass("gBranchSelected")) { + return; + } + var id = $(event.currentTarget).attr("ref"); + $(".gBranchSelected").removeClass("gBranchSelected"); + $("#gOrganizeBranch-" + id).addClass("gBranchSelected"); + var url = $("#gMicroThumbPanel").attr("ref").replace("__ITEM_ID__", id).replace("__OFFSET__", 0); + $.get(url, function(data) { + $("#gMicroThumbGrid").html(data); + }); } - - $("#gOrganizeDialog #gMicroThumbDone").click(function(event) { - $("#gOrganizeDialog").dialog("close"); - }); - - $(".gBranchText span").click(_collapse_or_expanded_tree); - $(".gBranchText").click(_setContents); }; - - /** - * Open or close a branch. If the children is a div placeholder, replace with <ul> - */ - function _collapse_or_expanded_tree(event) { - event.stopPropagation(); - if ($(event.currentTarget).hasClass("ui-icon-minus")) { - $(event.currentTarget).removeClass("ui-icon-minus").addClass("ui-icon-plus"); - } else { - $(event.currentTarget).removeClass("ui-icon-plus").addClass("ui-icon-minus"); - } - $("#gOrganizeChildren-" + $(event.currentTarget).attr("ref")).toggle(); - } - - /** - * When the text of a selection is clicked, then show that albums contents - */ - function _setContents(event) { - event.preventDefault(); - if ($(event.currentTarget).hasClass("gBranchSelected")) { - return; - } - var id = $(event.currentTarget).attr("ref"); - $(".gBranchSelected").removeClass("gBranchSelected"); - $("#gOrganizeBranch-" + id).addClass("gBranchSelected"); - var url = $("#gMicroThumbPanel").attr("ref").replace("__ITEM_ID__", id).replace("__OFFSET__", 0); - $.get(url, function(data) { - $("#gMicroThumbGrid").html(data); - }); - } })(jQuery); - -$("document").ready(function() { - $("#gOrganizeLink").organize(); -}); diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index 4f10297e..11ce0a37 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -38,3 +38,13 @@ </div> </div> +<script type="text/javascript"> + setTimeout(function() { + // 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"); + $.organize.init(); + }, 0); +</script>
\ No newline at end of file |