From 7b1cca168cb9b29fcccdcdce9e32efb190e4575e Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 5 Aug 2009 10:25:23 -0700 Subject: Revert "Revert "Allow a theme to override the page refresh mechanism. Create a new"" This reverts commit 9f396178cedc96abb282e72ff0e843e255c8225a. --- modules/gallery/js/quick.js | 4 +- modules/gallery/tests/xss_data.txt | 68 +++++++++++----------- .../views/admin_maintenance_show_log.html.php | 2 +- .../gallery/views/admin_maintenance_task.html.php | 2 +- 4 files changed, 39 insertions(+), 37 deletions(-) (limited to 'modules/gallery') diff --git a/modules/gallery/js/quick.js b/modules/gallery/js/quick.js index fda6470f..4753808e 100644 --- a/modules/gallery/js/quick.js +++ b/modules/gallery/js/quick.js @@ -67,9 +67,9 @@ var quick_do = function(cont, pane, img) { img.css("margin-top", 0); } } else if (data.location) { - window.location = data.location; + $.gallery_location(data.location); } else if (data.reload) { - window.location.reload(); + $.gallery_reload(); } } }); diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index 0e118ce7..29d223b7 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -496,24 +496,25 @@ themes/admin_default/views/admin.html.php 20 DIRTY $theme->s themes/admin_default/views/admin.html.php 21 DIRTY $theme->script("jquery.form.js") themes/admin_default/views/admin.html.php 22 DIRTY $theme->script("jquery-ui.js") themes/admin_default/views/admin.html.php 23 DIRTY $theme->script("gallery.common.js") -themes/admin_default/views/admin.html.php 28 DIRTY $theme->script("gallery.dialog.js") -themes/admin_default/views/admin.html.php 29 DIRTY $theme->script("superfish/js/superfish.js") -themes/admin_default/views/admin.html.php 30 DIRTY $theme->script("jquery.dropshadow.js") -themes/admin_default/views/admin.html.php 31 DIRTY $theme->script("ui.init.js") -themes/admin_default/views/admin.html.php 33 DIRTY $theme->admin_head() -themes/admin_default/views/admin.html.php 36 DIRTY $theme->body_attributes() -themes/admin_default/views/admin.html.php 37 DIRTY $theme->admin_page_top() -themes/admin_default/views/admin.html.php 43 DIRTY $theme->site_status() -themes/admin_default/views/admin.html.php 45 DIRTY $theme->admin_header_top() -themes/admin_default/views/admin.html.php 48 DIRTY $csrf -themes/admin_default/views/admin.html.php 54 DIRTY $theme->admin_menu() -themes/admin_default/views/admin.html.php 56 DIRTY $theme->admin_header_bottom() -themes/admin_default/views/admin.html.php 62 DIRTY $theme->messages() -themes/admin_default/views/admin.html.php 63 DIRTY $content -themes/admin_default/views/admin.html.php 69 DIRTY $sidebar -themes/admin_default/views/admin.html.php 74 DIRTY $theme->admin_footer() -themes/admin_default/views/admin.html.php 76 DIRTY $theme->admin_credits() -themes/admin_default/views/admin.html.php 80 DIRTY $theme->admin_page_bottom() +themes/admin_default/views/admin.html.php 25 DIRTY $theme->script("gallery.reload.js") +themes/admin_default/views/admin.html.php 30 DIRTY $theme->script("gallery.dialog.js") +themes/admin_default/views/admin.html.php 31 DIRTY $theme->script("superfish/js/superfish.js") +themes/admin_default/views/admin.html.php 32 DIRTY $theme->script("jquery.dropshadow.js") +themes/admin_default/views/admin.html.php 33 DIRTY $theme->script("ui.init.js") +themes/admin_default/views/admin.html.php 35 DIRTY $theme->admin_head() +themes/admin_default/views/admin.html.php 38 DIRTY $theme->body_attributes() +themes/admin_default/views/admin.html.php 39 DIRTY $theme->admin_page_top() +themes/admin_default/views/admin.html.php 45 DIRTY $theme->site_status() +themes/admin_default/views/admin.html.php 47 DIRTY $theme->admin_header_top() +themes/admin_default/views/admin.html.php 50 DIRTY $csrf +themes/admin_default/views/admin.html.php 56 DIRTY $theme->admin_menu() +themes/admin_default/views/admin.html.php 58 DIRTY $theme->admin_header_bottom() +themes/admin_default/views/admin.html.php 64 DIRTY $theme->messages() +themes/admin_default/views/admin.html.php 65 DIRTY $content +themes/admin_default/views/admin.html.php 71 DIRTY $sidebar +themes/admin_default/views/admin.html.php 76 DIRTY $theme->admin_footer() +themes/admin_default/views/admin.html.php 78 DIRTY $theme->admin_credits() +themes/admin_default/views/admin.html.php 82 DIRTY $theme->admin_page_bottom() themes/admin_default/views/block.html.php 2 DIRTY $id themes/admin_default/views/block.html.php 2 DIRTY $css_id themes/admin_default/views/block.html.php 5 DIRTY $id @@ -601,21 +602,22 @@ themes/default/views/page.html.php 48 DIRTY $theme->s themes/default/views/page.html.php 49 DIRTY $theme->script("jquery.form.js") themes/default/views/page.html.php 50 DIRTY $theme->script("jquery-ui.js") themes/default/views/page.html.php 51 DIRTY $theme->script("gallery.common.js") -themes/default/views/page.html.php 56 DIRTY $theme->script("gallery.dialog.js") -themes/default/views/page.html.php 57 DIRTY $theme->script("gallery.form.js") -themes/default/views/page.html.php 58 DIRTY $theme->script("superfish/js/superfish.js") -themes/default/views/page.html.php 59 DIRTY $theme->script("jquery.localscroll.js") -themes/default/views/page.html.php 60 DIRTY $theme->script("ui.init.js") -themes/default/views/page.html.php 64 DIRTY $theme->script("jquery.scrollTo.js") -themes/default/views/page.html.php 65 DIRTY $theme->script("gallery.show_full_size.js") -themes/default/views/page.html.php 67 DIRTY $theme->script("flowplayer.js") -themes/default/views/page.html.php 70 DIRTY $theme->head() -themes/default/views/page.html.php 73 DIRTY $theme->body_attributes() -themes/default/views/page.html.php 74 DIRTY $theme->page_top() -themes/default/views/page.html.php 76 DIRTY $theme->site_status() -themes/default/views/page.html.php 84 DIRTY $theme->messages() -themes/default/views/page.html.php 85 DIRTY $content -themes/default/views/page.html.php 99 DIRTY $theme->page_bottom() +themes/default/views/page.html.php 53 DIRTY $theme->script("gallery.reload.js") +themes/default/views/page.html.php 58 DIRTY $theme->script("gallery.dialog.js") +themes/default/views/page.html.php 59 DIRTY $theme->script("gallery.form.js") +themes/default/views/page.html.php 60 DIRTY $theme->script("superfish/js/superfish.js") +themes/default/views/page.html.php 61 DIRTY $theme->script("jquery.localscroll.js") +themes/default/views/page.html.php 62 DIRTY $theme->script("ui.init.js") +themes/default/views/page.html.php 66 DIRTY $theme->script("jquery.scrollTo.js") +themes/default/views/page.html.php 67 DIRTY $theme->script("gallery.show_full_size.js") +themes/default/views/page.html.php 69 DIRTY $theme->script("flowplayer.js") +themes/default/views/page.html.php 72 DIRTY $theme->head() +themes/default/views/page.html.php 75 DIRTY $theme->body_attributes() +themes/default/views/page.html.php 76 DIRTY $theme->page_top() +themes/default/views/page.html.php 78 DIRTY $theme->site_status() +themes/default/views/page.html.php 86 DIRTY $theme->messages() +themes/default/views/page.html.php 87 DIRTY $content +themes/default/views/page.html.php 101 DIRTY $theme->page_bottom() themes/default/views/pager.html.php 13 DIRTY $url themes/default/views/pager.html.php 20 DIRTY $previous_page themes/default/views/pager.html.php 20 DIRTY $url diff --git a/modules/gallery/views/admin_maintenance_show_log.html.php b/modules/gallery/views/admin_maintenance_show_log.html.php index 9d850986..ac593de7 100644 --- a/modules/gallery/views/admin_maintenance_show_log.html.php +++ b/modules/gallery/views/admin_maintenance_show_log.html.php @@ -1,7 +1,7 @@
-- cgit v1.2.3 From 7bdf382e813515ce7ab6e14f0b8e3e0b7b6bd867 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 6 Aug 2009 07:02:41 -0700 Subject: Revert "Revert "Revert "Allow a theme to override the page refresh mechanism. Create a new""" This reverts commit 7b1cca168cb9b29fcccdcdce9e32efb190e4575e. Basically remove it and Bharat and I will fight it out in SF for a resolution :-) --- lib/gallery.dialog.js | 4 +- lib/gallery.panel.js | 4 +- lib/gallery.reload.js | 16 ----- modules/gallery/js/quick.js | 4 +- modules/gallery/tests/xss_data.txt | 68 +++++++++++----------- .../views/admin_maintenance_show_log.html.php | 2 +- .../gallery/views/admin_maintenance_task.html.php | 2 +- modules/organize/js/organize.js | 2 +- .../views/server_add_tree_dialog.html.php | 2 +- modules/tag/js/tag.js | 2 +- themes/admin_default/views/admin.html.php | 2 - themes/default/views/page.html.php | 2 - 12 files changed, 44 insertions(+), 66 deletions(-) delete mode 100644 lib/gallery.reload.js (limited to 'modules/gallery') diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index 0efcf120..74c2f20e 100644 --- a/lib/gallery.dialog.js +++ b/lib/gallery.dialog.js @@ -25,9 +25,9 @@ function ajaxify_dialog() { } if (data.result == "success") { if (data.location) { - $.gallery_location(data.location); + window.location = data.location; } else { - $.gallery_reload(); + window.location.reload(); } } } diff --git a/lib/gallery.panel.js b/lib/gallery.panel.js index 26be11ad..022e4878 100644 --- a/lib/gallery.panel.js +++ b/lib/gallery.panel.js @@ -40,9 +40,9 @@ function togglePanel(element, on_success) { if (on_success) { on_success(); } else if (data.location) { - $.gallery_location(data.location); + window.location = data.location; } else { - $.gallery_reload(); + window.location.reload(); } } } diff --git a/lib/gallery.reload.js b/lib/gallery.reload.js deleted file mode 100644 index 2c8752a0..00000000 --- a/lib/gallery.reload.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -(function ($) { - $.gallery_reload = function() { - window.location.reload(); - }; -})(jQuery); - -// Vertically align a block element's content -(function ($) { - $.gallery_location = function(location) { - window.location = location; - }; -})(jQuery); diff --git a/modules/gallery/js/quick.js b/modules/gallery/js/quick.js index 4753808e..fda6470f 100644 --- a/modules/gallery/js/quick.js +++ b/modules/gallery/js/quick.js @@ -67,9 +67,9 @@ var quick_do = function(cont, pane, img) { img.css("margin-top", 0); } } else if (data.location) { - $.gallery_location(data.location); + window.location = data.location; } else if (data.reload) { - $.gallery_reload(); + window.location.reload(); } } }); diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index 29d223b7..0e118ce7 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -496,25 +496,24 @@ themes/admin_default/views/admin.html.php 20 DIRTY $theme->s themes/admin_default/views/admin.html.php 21 DIRTY $theme->script("jquery.form.js") themes/admin_default/views/admin.html.php 22 DIRTY $theme->script("jquery-ui.js") themes/admin_default/views/admin.html.php 23 DIRTY $theme->script("gallery.common.js") -themes/admin_default/views/admin.html.php 25 DIRTY $theme->script("gallery.reload.js") -themes/admin_default/views/admin.html.php 30 DIRTY $theme->script("gallery.dialog.js") -themes/admin_default/views/admin.html.php 31 DIRTY $theme->script("superfish/js/superfish.js") -themes/admin_default/views/admin.html.php 32 DIRTY $theme->script("jquery.dropshadow.js") -themes/admin_default/views/admin.html.php 33 DIRTY $theme->script("ui.init.js") -themes/admin_default/views/admin.html.php 35 DIRTY $theme->admin_head() -themes/admin_default/views/admin.html.php 38 DIRTY $theme->body_attributes() -themes/admin_default/views/admin.html.php 39 DIRTY $theme->admin_page_top() -themes/admin_default/views/admin.html.php 45 DIRTY $theme->site_status() -themes/admin_default/views/admin.html.php 47 DIRTY $theme->admin_header_top() -themes/admin_default/views/admin.html.php 50 DIRTY $csrf -themes/admin_default/views/admin.html.php 56 DIRTY $theme->admin_menu() -themes/admin_default/views/admin.html.php 58 DIRTY $theme->admin_header_bottom() -themes/admin_default/views/admin.html.php 64 DIRTY $theme->messages() -themes/admin_default/views/admin.html.php 65 DIRTY $content -themes/admin_default/views/admin.html.php 71 DIRTY $sidebar -themes/admin_default/views/admin.html.php 76 DIRTY $theme->admin_footer() -themes/admin_default/views/admin.html.php 78 DIRTY $theme->admin_credits() -themes/admin_default/views/admin.html.php 82 DIRTY $theme->admin_page_bottom() +themes/admin_default/views/admin.html.php 28 DIRTY $theme->script("gallery.dialog.js") +themes/admin_default/views/admin.html.php 29 DIRTY $theme->script("superfish/js/superfish.js") +themes/admin_default/views/admin.html.php 30 DIRTY $theme->script("jquery.dropshadow.js") +themes/admin_default/views/admin.html.php 31 DIRTY $theme->script("ui.init.js") +themes/admin_default/views/admin.html.php 33 DIRTY $theme->admin_head() +themes/admin_default/views/admin.html.php 36 DIRTY $theme->body_attributes() +themes/admin_default/views/admin.html.php 37 DIRTY $theme->admin_page_top() +themes/admin_default/views/admin.html.php 43 DIRTY $theme->site_status() +themes/admin_default/views/admin.html.php 45 DIRTY $theme->admin_header_top() +themes/admin_default/views/admin.html.php 48 DIRTY $csrf +themes/admin_default/views/admin.html.php 54 DIRTY $theme->admin_menu() +themes/admin_default/views/admin.html.php 56 DIRTY $theme->admin_header_bottom() +themes/admin_default/views/admin.html.php 62 DIRTY $theme->messages() +themes/admin_default/views/admin.html.php 63 DIRTY $content +themes/admin_default/views/admin.html.php 69 DIRTY $sidebar +themes/admin_default/views/admin.html.php 74 DIRTY $theme->admin_footer() +themes/admin_default/views/admin.html.php 76 DIRTY $theme->admin_credits() +themes/admin_default/views/admin.html.php 80 DIRTY $theme->admin_page_bottom() themes/admin_default/views/block.html.php 2 DIRTY $id themes/admin_default/views/block.html.php 2 DIRTY $css_id themes/admin_default/views/block.html.php 5 DIRTY $id @@ -602,22 +601,21 @@ themes/default/views/page.html.php 48 DIRTY $theme->s themes/default/views/page.html.php 49 DIRTY $theme->script("jquery.form.js") themes/default/views/page.html.php 50 DIRTY $theme->script("jquery-ui.js") themes/default/views/page.html.php 51 DIRTY $theme->script("gallery.common.js") -themes/default/views/page.html.php 53 DIRTY $theme->script("gallery.reload.js") -themes/default/views/page.html.php 58 DIRTY $theme->script("gallery.dialog.js") -themes/default/views/page.html.php 59 DIRTY $theme->script("gallery.form.js") -themes/default/views/page.html.php 60 DIRTY $theme->script("superfish/js/superfish.js") -themes/default/views/page.html.php 61 DIRTY $theme->script("jquery.localscroll.js") -themes/default/views/page.html.php 62 DIRTY $theme->script("ui.init.js") -themes/default/views/page.html.php 66 DIRTY $theme->script("jquery.scrollTo.js") -themes/default/views/page.html.php 67 DIRTY $theme->script("gallery.show_full_size.js") -themes/default/views/page.html.php 69 DIRTY $theme->script("flowplayer.js") -themes/default/views/page.html.php 72 DIRTY $theme->head() -themes/default/views/page.html.php 75 DIRTY $theme->body_attributes() -themes/default/views/page.html.php 76 DIRTY $theme->page_top() -themes/default/views/page.html.php 78 DIRTY $theme->site_status() -themes/default/views/page.html.php 86 DIRTY $theme->messages() -themes/default/views/page.html.php 87 DIRTY $content -themes/default/views/page.html.php 101 DIRTY $theme->page_bottom() +themes/default/views/page.html.php 56 DIRTY $theme->script("gallery.dialog.js") +themes/default/views/page.html.php 57 DIRTY $theme->script("gallery.form.js") +themes/default/views/page.html.php 58 DIRTY $theme->script("superfish/js/superfish.js") +themes/default/views/page.html.php 59 DIRTY $theme->script("jquery.localscroll.js") +themes/default/views/page.html.php 60 DIRTY $theme->script("ui.init.js") +themes/default/views/page.html.php 64 DIRTY $theme->script("jquery.scrollTo.js") +themes/default/views/page.html.php 65 DIRTY $theme->script("gallery.show_full_size.js") +themes/default/views/page.html.php 67 DIRTY $theme->script("flowplayer.js") +themes/default/views/page.html.php 70 DIRTY $theme->head() +themes/default/views/page.html.php 73 DIRTY $theme->body_attributes() +themes/default/views/page.html.php 74 DIRTY $theme->page_top() +themes/default/views/page.html.php 76 DIRTY $theme->site_status() +themes/default/views/page.html.php 84 DIRTY $theme->messages() +themes/default/views/page.html.php 85 DIRTY $content +themes/default/views/page.html.php 99 DIRTY $theme->page_bottom() themes/default/views/pager.html.php 13 DIRTY $url themes/default/views/pager.html.php 20 DIRTY $previous_page themes/default/views/pager.html.php 20 DIRTY $url diff --git a/modules/gallery/views/admin_maintenance_show_log.html.php b/modules/gallery/views/admin_maintenance_show_log.html.php index ac593de7..9d850986 100644 --- a/modules/gallery/views/admin_maintenance_show_log.html.php +++ b/modules/gallery/views/admin_maintenance_show_log.html.php @@ -1,7 +1,7 @@
diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js index 0a7576b0..89549954 100644 --- a/modules/organize/js/organize.js +++ b/modules/organize/js/organize.js @@ -58,7 +58,7 @@ $("#gOrganizeDialog #gMicroThumbDone").click(_dialog_close); $("#gOrganizeDialog").bind("organize_close", function(target) { - $.gallery_reload(); + document.location.reload(); }); $(".gBranchText span").click(_collapse_or_expanded_tree); diff --git a/modules/server_add/views/server_add_tree_dialog.html.php b/modules/server_add/views/server_add_tree_dialog.html.php index 8dfd2c38..21952849 100644 --- a/modules/server_add/views/server_add_tree_dialog.html.php +++ b/modules/server_add/views/server_add_tree_dialog.html.php @@ -34,7 +34,7 @@ - diff --git a/modules/tag/js/tag.js b/modules/tag/js/tag.js index 564de393..765c2a35 100644 --- a/modules/tag/js/tag.js +++ b/modules/tag/js/tag.js @@ -59,7 +59,7 @@ function editInPlace(element) { closeEditInPlaceForms(); // close form $("#gTag-" + data.tag_id).text(data.new_tagname); // update tagname console.log(data); - $.gallery_reload(); + window.location.reload(); } } }); diff --git a/themes/admin_default/views/admin.html.php b/themes/admin_default/views/admin.html.php index 63fc45b5..d27f9260 100644 --- a/themes/admin_default/views/admin.html.php +++ b/themes/admin_default/views/admin.html.php @@ -21,8 +21,6 @@ script("jquery.form.js") ?> script("jquery-ui.js") ?> script("gallery.common.js") ?> - - script("gallery.reload.js") ?>

diff --git a/modules/server_add/views/server_add_tree_dialog.html.php b/modules/server_add/views/server_add_tree_dialog.html.php index 21952849..5c5dfd0f 100644 --- a/modules/server_add/views/server_add_tree_dialog.html.php +++ b/modules/server_add/views/server_add_tree_dialog.html.php @@ -34,7 +34,7 @@ - @@ -48,6 +48,9 @@ progressbar("value", 0); $("#gProgress").slideDown("fast", function() { start_add() }); }); + $("#gServerCloseButton").click(function(event) { + $("#gDialog").dialog("close"); + }); }); diff --git a/modules/tag/js/tag.js b/modules/tag/js/tag.js index 765c2a35..535582c5 100644 --- a/modules/tag/js/tag.js +++ b/modules/tag/js/tag.js @@ -23,7 +23,7 @@ function closeEditInPlaceForms() { $("#gRenameTagForm").parent().html($("#gRenameTagForm").parent().data("revert")); li.height(""); $(".gEditable", li).bind("click", editInPlace); - $(".gDialogLink", li).bind("click", handleDialogEvent); + $(".gDialogLink", li).galleryDialog(); } } diff --git a/modules/user/views/admin_users.html.php b/modules/user/views/admin_users.html.php index 542b8b8b..a487d565 100644 --- a/modules/user/views/admin_users.html.php +++ b/modules/user/views/admin_users.html.php @@ -28,7 +28,7 @@ {}, function(data) { $("#group-" + group_id).html(data); - $("#group-" + group_id + " .gDialogLink").bind("click", handleDialogEvent); + $("#group-" + group_id + " .gDialogLink").galleryDialog()); }); } diff --git a/themes/admin_default/js/ui.init.js b/themes/admin_default/js/ui.init.js index 63b74300..eea3cab2 100644 --- a/themes/admin_default/js/ui.init.js +++ b/themes/admin_default/js/ui.init.js @@ -17,7 +17,7 @@ $(document).ready(function(){ $("#gMessage li").showMessage(); // Initialize modal dialogs - $(".gDialogLink").bind("click", handleDialogEvent); + $(".gDialogLink").galleryDialog(); // Initialize panels $(".gPanelLink").galleryPanel(); diff --git a/themes/default/js/ui.init.js b/themes/default/js/ui.init.js index ff76c79c..33d04328 100644 --- a/themes/default/js/ui.init.js +++ b/themes/default/js/ui.init.js @@ -34,7 +34,7 @@ $(document).ready(function() { // Initialize dialogs $(".gMenuLink").addClass("gDialogLink"); $("#gLoginLink").addClass("gDialogLink"); - $(".gDialogLink").bind("click", handleDialogEvent); + $(".gDialogLink").galleryDialog(); // Initialize view menu if ($("#gViewMenu").length) { -- cgit v1.2.3 From 49d46e4010e428b9df97a6e7c5e55708d1c674a8 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 7 Aug 2009 10:47:56 -0700 Subject: Change galleryPanel and galleryDialog widgets to gallery_panel and gallery_dialog respectively --- lib/gallery.dialog.js | 8 ++++---- lib/gallery.panel.js | 2 +- modules/gallery/views/after_install.html.php | 2 +- modules/tag/js/tag.js | 2 +- modules/user/views/admin_users.html.php | 2 +- themes/admin_default/js/ui.init.js | 4 ++-- themes/default/js/ui.init.js | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) (limited to 'modules/gallery') diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index 7e0ba1b4..04ab44de 100644 --- a/lib/gallery.dialog.js +++ b/lib/gallery.dialog.js @@ -1,5 +1,5 @@ (function($) { - $.widget("ui.galleryDialog", { + $.widget("ui.gallery_dialog", { _init: function() { var self = this; this.element.click(function(event){ @@ -12,7 +12,7 @@ $("body").append(eDialog); if (!self.options.close) { - self.options.close = self.closeDialog; + self.options.close = self.close_dialog; } $("#gDialog").dialog(self.options); @@ -91,7 +91,7 @@ ); }, - closeDialog: function (event, ui) { + close_dialog: function (event, ui) { var self = $("#gDialog").dialog("option", "self"); self.destroy(); }, @@ -124,7 +124,7 @@ dialog_closing: function(event, ui) {} }); - $.extend($.ui.galleryDialog, { + $.extend($.ui.gallery_dialog, { defaults: { autoOpen: false, autoResize: true, diff --git a/lib/gallery.panel.js b/lib/gallery.panel.js index 98d78d2a..e0bf4259 100644 --- a/lib/gallery.panel.js +++ b/lib/gallery.panel.js @@ -1,5 +1,5 @@ (function($) { - $.widget("ui.galleryPanel", { + $.widget("ui.gallery_panel", { _init: function() { var self = this; this.element.click(function(event) { diff --git a/modules/gallery/views/after_install.html.php b/modules/gallery/views/after_install.html.php index feb2d281..bfce46f0 100644 --- a/modules/gallery/views/after_install.html.php +++ b/modules/gallery/views/after_install.html.php @@ -16,7 +16,7 @@ title="" id="gAfterInstallChangePasswordLink" class="gButtonLink ui-state-default ui-corners-all">

diff --git a/modules/tag/js/tag.js b/modules/tag/js/tag.js index 535582c5..61ac73f4 100644 --- a/modules/tag/js/tag.js +++ b/modules/tag/js/tag.js @@ -23,7 +23,7 @@ function closeEditInPlaceForms() { $("#gRenameTagForm").parent().html($("#gRenameTagForm").parent().data("revert")); li.height(""); $(".gEditable", li).bind("click", editInPlace); - $(".gDialogLink", li).galleryDialog(); + $(".gDialogLink", li).gallery_dialog(); } } diff --git a/modules/user/views/admin_users.html.php b/modules/user/views/admin_users.html.php index a487d565..9bd4c068 100644 --- a/modules/user/views/admin_users.html.php +++ b/modules/user/views/admin_users.html.php @@ -28,7 +28,7 @@ {}, function(data) { $("#group-" + group_id).html(data); - $("#group-" + group_id + " .gDialogLink").galleryDialog()); + $("#group-" + group_id + " .gDialogLink").gallery_dialog(); }); } diff --git a/themes/admin_default/js/ui.init.js b/themes/admin_default/js/ui.init.js index eea3cab2..89dd5b47 100644 --- a/themes/admin_default/js/ui.init.js +++ b/themes/admin_default/js/ui.init.js @@ -17,10 +17,10 @@ $(document).ready(function(){ $("#gMessage li").showMessage(); // Initialize modal dialogs - $(".gDialogLink").galleryDialog(); + $(".gDialogLink").gallery_dialog(); // Initialize panels - $(".gPanelLink").galleryPanel(); + $(".gPanelLink").gallery_panel(); if ($("#gPhotoStream").length) { // Vertically align thumbs in photostream diff --git a/themes/default/js/ui.init.js b/themes/default/js/ui.init.js index 33d04328..4b876c66 100644 --- a/themes/default/js/ui.init.js +++ b/themes/default/js/ui.init.js @@ -34,7 +34,7 @@ $(document).ready(function() { // Initialize dialogs $(".gMenuLink").addClass("gDialogLink"); $("#gLoginLink").addClass("gDialogLink"); - $(".gDialogLink").galleryDialog(); + $(".gDialogLink").gallery_dialog(); // Initialize view menu if ($("#gViewMenu").length) { -- cgit v1.2.3 From 76f320ab3d6b1f67055dd913eb5811d0d113682a Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 16 Aug 2009 12:36:14 -0700 Subject: In this patch, drag now works to the album tree, but the progress bar is not showing. As well fixed a problem where selectable single clink no longer worked when the album was reloaded. --- modules/gallery/controllers/combined.php | 9 +- modules/organize/controllers/organize.php | 121 +++++++++++++++++++-- modules/organize/js/organize.js | 138 ++++++++++++++---------- modules/organize/views/organize_dialog.html.php | 7 +- 4 files changed, 208 insertions(+), 67 deletions(-) (limited to 'modules/gallery') diff --git a/modules/gallery/controllers/combined.php b/modules/gallery/controllers/combined.php index 9a790fdf..c1f42bfe 100644 --- a/modules/gallery/controllers/combined.php +++ b/modules/gallery/controllers/combined.php @@ -42,22 +42,23 @@ class Combined_Controller extends Controller { private function _emit($type, $key) { $input = Input::instance(); + // We don't need to save the session for this request + Session::abort_save(); + // Our data is immutable, so if they already have a copy then it needs no updating. if ($input->server("HTTP_IF_MODIFIED_SINCE")) { header('HTTP/1.0 304 Not Modified'); header("Expires: Tue, 19 Jan 2038 00:00:00 GMT"); header("Cache-Control: max-age=2678400"); header('Pragma: public'); - return; + Kohana::close_buffers(false); + return ""; } if (empty($key)) { Kohana::show_404(); } - // We don't need to save the session for this request - Session::abort_save(); - $cache = Cache::instance(); $use_gzip = function_exists("gzencode") && stripos($input->server("HTTP_ACCEPT_ENCODING"), "gzip") !== false && diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index 6f83f940..1c4a3a69 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -32,8 +32,8 @@ 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, 0); + $v->album_tree = self::_tree($root, $parents); + $v->micro_thumb_grid = self::_get_micro_thumb_grid($item, 0); print $v; } @@ -41,17 +41,77 @@ class Organize_Controller extends Controller { $item = ORM::factory("item", $item_id); access::required("view", $item); access::required("edit", $item); - print $this->_get_micro_thumb_grid($item, $offset); + print self::_get_micro_thumb_grid($item, $offset); } - private function _get_micro_thumb_grid($item, $offset) { + function move($target_id) { + access::verify_csrf(); + + $task_def = Task_Definition::factory() + ->callback("Organize_Controller::move_task_handler") + ->description(t("Move images")) + ->name(t("Move Images")); + $task = task::create($task_def, array("target_id" => $target_id, + "source_ids" => $this->input->post("source_ids"))); + + print json_encode( + array("result" => "started", + "status" => $task->status, + "url" => url::site("organize/run/$task->id?csrf=" . access::csrf_token()))); + } + + function rearrange($target_id, $before) { + access::verify_csrf(); + $target = ORM::factory("item", $target_id); + $parent = $target->parent(); + access::required("view", $parent); + access::required("edit", $parent); + + $task_def = Task_Definition::factory() + ->callback("Organize_Controller::rearrange_task_handler") + ->description(t("Rearrange Image")) + ->name(t("Rearrange Images")); + $task = task::create($task_def, array("target_id" => $target_id, "before" => $before, + "current" => 0, + "source_ids" => $this->input->post("source_ids"))); + + print json_encode( + array("result" => "started", + "status" => $task->status, + "url" => url::site("organize/run/$task->id?csrf=" . access::csrf_token()))); + } + + private static function _get_micro_thumb_grid($item, $offset) { $v = new View("organize_thumb_grid.html"); $v->item = $item; $v->offset = $offset; return $v; } - private function _tree($item, $parents) { + /** + * Run the task + */ + function run($task_id) { + access::verify_csrf(); + + $task = ORM::factory("task", $task_id); + if (!$task->loaded || $task->owner_id != user::active()->id) { + access::forbidden(); + } + + $task = task::run($task_id); + $results = array("done" => $task->done, "status" => $task->status, + "percent_complete" => $task->percent_complete); + foreach (array("tree", "content") as $data) { + $value = $task->get($data, false); + if ($value !== false) { + $results[$data] = $value; + } + } + print json_encode($results); + } + + private static function _tree($item, $parents) { $v = new View("organize_tree.html"); $v->album = $item; $keys = array_keys($parents); @@ -62,7 +122,7 @@ class Organize_Controller extends Controller { $albums = $item->children(null, 0, array("type" => "album"), array("title" => "ASC")); foreach ($albums as $album) { if (access::can("view", $album)) { - $v->children[] = $this->_tree($album, $parents); + $v->children[] = self::_tree($album, $parents); } } if (count($v->children)) { @@ -70,4 +130,53 @@ class Organize_Controller extends Controller { } return $v; } + + static function move_task_handler($task) { + $start = microtime(true); + if ($task->percent_complete == 0) { + batch::start(); + } + + $target = ORM::factory("item", $task->get("target_id")); + $source_ids = $task->get("source_ids", array()); + $idx = $task->get("current", 0); + $count = 0; + for (; $idx < count($source_ids) && microtime(true) - $start < 0.5; $idx++) { + item::move(ORM::factory("item", $source_ids[$idx]), $target); + $count++; + } + $task->set("current", $idx); + $task->percent_complete = ceil($idx / count($source_ids) * 100); + $task->status = t2("Moved one file", "Moved %count files", $count); + if ($task->percent_complete == 100) { + batch::stop(); + $task->done = true; + $task->state = "success"; + $parents = array(); + foreach ($target->parents() as $parent) { + $parents[$parent->id] = 1; + } + $parents[$target->id] = 1; + // @TODO do we want to set a flag and then generate them in the run method so we don't + // potentially store large data items in the task? + $task->set("tree", self::_tree(ORM::factory("item", 1), $parents)->__toString()); + $task->set("content", self::_get_micro_thumb_grid($target, 0)->__toString()); + } + } + + static function rearrange_task_handler($task) { + // @todo need to + // 1) reset the weights based on the current sort order + // 2) when they are all copied, change the sort order of the parent to "weight" + $task->percent_complete = 100; + //$start = microtime(true); + //$mode = $task->get("mode", "init"); + //$start = microtime(true); + // if (microtime(true) - $start > 0.5) { + // break; + $task->done = true; + $task->state = "success"; + $target = ORM::factory("item", $task->get("target_id")); + $task->set("content", self::_get_micro_thumb_grid($target, 0)->__toString()); + } } diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js index 07c07286..2d7c99fc 100644 --- a/modules/organize/js/organize.js +++ b/modules/organize/js/organize.js @@ -1,32 +1,37 @@ (function($) { $.organize = { micro_thumb_draggable: { + handle: ".ui-state-selected", distance: 10, cursorAt: { left: -10, top: -10}, appendTo: "#gMicroThumbPanel", helper: function(event, ui) { - var selected = $(".ui-draggable.ui-state-selected img"), - set = $('
').css({zIndex: 2000, width: 80, height: Math.ceil(selected.length / 5) * 16 }), - offset = $(this).offset(), - click = { left: event.pageX - offset.left, top: event.pageY - offset.top }; - - selected.each(function(i) { - var row = parseInt(i / 5); - var j = i - (row * 5); - - var o = $(this).offset(); - - var copy = $(this).clone() - .css({ - width: $(this).width(), height: $(this).height(), display: "block", - margin: 0, position: 'absolute', outline: '5px solid #fff', - left: o.left - event.pageX, top: o.top - event.pageY - }) - .appendTo(set) - .animate({width: 10, height: 10, outlineWidth: 1, margin: 1, left: (20 * j), top: (row * 20)}, 500); - }); - return set; + var selected = $(".ui-draggable.ui-state-selected img"); + if (selected.length) { + var set = $('
').css({zIndex: 2000, width: 80, height: Math.ceil(selected.length / 5) * 16 }), + offset = $(this).offset(), + click = { left: event.pageX - offset.left, top: event.pageY - offset.top }; + + selected.each(function(i) { + var row = parseInt(i / 5); + var j = i - (row * 5); + + var o = $(this).offset(); + + var copy = $(this).clone() + .css({ + width: $(this).width(), height: $(this).height(), display: "block", + margin: 0, position: 'absolute', outline: '5px solid #fff', + left: o.left - event.pageX, top: o.top - event.pageY + }) + .appendTo(set) + .animate({width: 10, height: 10, outlineWidth: 1, margin: 1, left: (20 * j), top: (row * 20)}, 500); + }); + return set; + } + return null; }, + start: function(event, ui) { $("#gMicroThumbPanel .ui-state-selected").hide(); }, @@ -52,9 +57,8 @@ greedy: true, drop: function(event, ui) { $.organize.do_drop({ - parent_id: $(".gBranchSelected").attr("ref"), - target_id: $(".currentDropTarget").attr("ref"), - position: $(".currentDropTarget").css("borderLeftStyle") == "solid" ? "before" : "after", + url: rearrange_url.replace("__TARGET_ID__", $(".currentDropTarget").attr("ref")) + .replace("__BEFORE__", $(".currentDropTarget").css("borderLeftStyle") == "solid"), source: $(ui.helper).children("img") }); } @@ -66,40 +70,61 @@ greedy: true, drop: function(event, ui) { $.organize.do_drop({ - parent_id: $(event.target).attr("ref"), - target_id: -1, - position: "after", + url: move_url.replace("__TARGET_ID__", $(event.target).attr("ref")), source: $(ui.helper).children("img") }); } }, - do_drop:function(drop_parms) { - var source_ids = ""; - $(drop_parms.source).each(function(i) { - source_ids += (source_ids.length ? "&" : "") + "source_id[" + i + "]=" + $(this).attr("ref"); + do_drop:function(options) { + var source_ids = []; + $(options.source).each(function(i) { + source_ids.push($(this).attr("ref")); }); - var url = drop_url.replace("__PARENT_ID__", drop_parms.parent_id) - .replace("__POSITION__", drop_parms.position) - .replace("__TARGET_ID__", drop_parms.target_id); - - console.group("do_drop"); - console.log("Generated url: " + url); - console.log("Post data(ids to move): " + source_ids); - console.groupEnd(); - // @todo do a ajax call to send the rearrange request to the server - // organize/move/parent_id/before|after/-1|target_id - // post parameters - // source=[id1, id2, ...] - // before or after not supplied then append to end - // return: json { - // result: success | msg, - // tree: null | new tree, - // content: new thumbgrid - // } - // do forget to reset all the stuff in init when updating the content + + if (source_ids.length) { + $("#gOrganize .gProgressBar").progressbar().progressbar("value", 0); + $("#gOrganizeProgress").slideDown("fast", function() { + $.ajax({ + url: options.url, + type: "POST", + async: false, + data: { "source_ids[]": source_ids }, + dataType: "json", + success: function(data, textStatus) { + $("#gStatus").html(data.status); + $("#gOrganize .gProgressBar").progressbar("value", data.percent_complete); + setTimeout(function() { $.organize._run_task(data.url); }, 0); + } + }); + }); + } }, + _run_task: function(url) { + $.ajax({ + url: url, + async: false, + dataType: "json", + success: function(data, textStatus) { + $("#gStatus").html(data.status); + $("#gOrganize .gProgressBar").progressbar("value", data.percent_complete); + if (data.done) { + $("#gProgress").slideUp(); + // Don't forget to refresh the content pane and tree + if (data.tree) { + $("#gOrganizeAlbumTree").html(data.tree); + } + if (data.content) { + $("#gMicroThumbGrid").html(data.content); + } + $.organize.set_handlers(); + } else { + setTimeout(function() { $.organize._run_task(url); }, 0); + } + } + }); + }, mouse_move_handler: function(event) { if ($(".gDragHelper").length) { $(".gMicroThumbGridCell").css("borderStyle", "hidden"); @@ -121,8 +146,8 @@ $("#gDialog").dialog("option", "zIndex", 70); $("#gDialog").bind("dialogopen", function(event, ui) { $("#gOrganize").height($("#gDialog").innerHeight() - 20); - $("#gMicroThumbPanel").height($("#gDialog").innerHeight() - 90); - $("#gOrganizeAlbumTree").height($("#gDialog").innerHeight() - 59); + $("#gMicroThumbPanel").height($("#gDialog").innerHeight() - 120); + $("#gOrganizeAlbumTree").height($("#gDialog").innerHeight() - 89); }); $("#gDialog").bind("dialogclose", function(event, ui) { @@ -133,18 +158,18 @@ $("#gDialog").dialog("close"); }); - $("#gMicroThumbPanel").selectable({filter: ".gMicroThumbGridCell"}); - $("#gMicroThumbPanel").droppable($.organize.content_droppable); - $.organize.set_handlers(); }, set_handlers: function() { + $("#gMicroThumbPanel").selectable({filter: ".gMicroThumbGridCell"}); + $("#gMicroThumbPanel").droppable($.organize.content_droppable); + $(".gMicroThumbGridCell").draggable($.organize.micro_thumb_draggable); $(".gMicroThumbGridCell").mousemove($.organize.mouse_move_handler); $(".gOrganizeBranch").droppable($.organize.branch_droppable); - $(".gBranchText span").click($.organize.collapse_or_expand_tree); $(".gBranchText").click($.organize.show_album); + $(".gOrganizeBranch .ui-icon").click($.organize.collapse_or_expand_tree); }, /** @@ -164,6 +189,7 @@ if ($(event.currentTarget).hasClass("gBranchSelected")) { return; } + $("#gMicroThumbPanel").selectable("destroy"); var id = $(event.currentTarget).attr("ref"); $(".gBranchSelected").removeClass("gBranchSelected"); $("#gOrganizeBranch-" + id).addClass("gBranchSelected"); diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php index 982eba9e..46f9ad9b 100644 --- a/modules/organize/views/organize_dialog.html.php +++ b/modules/organize/views/organize_dialog.html.php @@ -1,6 +1,7 @@

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

@@ -39,6 +40,10 @@
+