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. --- 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, 66 insertions(+), 44 deletions(-) create mode 100644 lib/gallery.reload.js diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index 74c2f20e..0efcf120 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) { - window.location = data.location; + $.gallery_location(data.location); } else { - window.location.reload(); + $.gallery_reload(); } } } diff --git a/lib/gallery.panel.js b/lib/gallery.panel.js index 022e4878..26be11ad 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) { - window.location = data.location; + $.gallery_location(data.location); } else { - window.location.reload(); + $.gallery_reload(); } } } diff --git a/lib/gallery.reload.js b/lib/gallery.reload.js new file mode 100644 index 00000000..2c8752a0 --- /dev/null +++ b/lib/gallery.reload.js @@ -0,0 +1,16 @@ +/** + * 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 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 @@
diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js index f10cbcc9..12d8a5b5 100644 --- a/modules/organize/js/organize.js +++ b/modules/organize/js/organize.js @@ -374,7 +374,7 @@ function organize_dialog_init() { } $("#gDialog").bind("organize_close", function(target) { - document.location.reload(); + $.gallery_reload(); }); heightMicroThumbPanel -= 2 * parseFloat($("#gDialog").css("padding-top")); 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..8dfd2c38 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 765c2a35..564de393 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); - window.location.reload(); + $.gallery_reload(); } } }); diff --git a/themes/admin_default/views/admin.html.php b/themes/admin_default/views/admin.html.php index d27f9260..63fc45b5 100644 --- a/themes/admin_default/views/admin.html.php +++ b/themes/admin_default/views/admin.html.php @@ -21,6 +21,8 @@ script("jquery.form.js") ?> script("jquery-ui.js") ?> script("gallery.common.js") ?> + + script("gallery.reload.js") ?> -
- p::purify($item->title))) ?> -
-
-
-
-
-

-
-
-
-
-
-
-
- -
-
"> -
    -
    -
    -
    -
    -
      -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    diff --git a/modules/organize/views/organize_album.html.php b/modules/organize/views/organize_album.html.php deleted file mode 100644 index ae2d5d51..00000000 --- a/modules/organize/views/organize_album.html.php +++ /dev/null @@ -1,17 +0,0 @@ - - diff --git a/modules/organize/views/organize_button_pane.html.php b/modules/organize/views/organize_button_pane.html.php index c5839a44..8eced107 100644 --- a/modules/organize/views/organize_button_pane.html.php +++ b/modules/organize/views/organize_button_pane.html.php @@ -1,50 +1,5 @@ - -
    - - - +
    diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php new file mode 100644 index 00000000..cf3fd478 --- /dev/null +++ b/modules/organize/views/organize_dialog.html.php @@ -0,0 +1,37 @@ + +
    +

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

    +
    +
    +
    +

    +
    +
    +
    +
    +
    +
    +
    +
      + +
    +
    +
    +
    "> +
      + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + diff --git a/modules/organize/views/organize_edit.html.php b/modules/organize/views/organize_edit.html.php deleted file mode 100644 index 1adf290f..00000000 --- a/modules/organize/views/organize_edit.html.php +++ /dev/null @@ -1,14 +0,0 @@ - - - - 0): ?> - $pane): ?> -
    - - -
    - \ 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 c80696ad..e6b7aec0 100644 --- a/modules/organize/views/organize_thumb_grid.html.php +++ b/modules/organize/views/organize_thumb_grid.html.php @@ -1,12 +1,19 @@ $child): ?> - -is_album()): ?> - - -
  • -
    + + is_album()): ?> + + +
  • thumb_img(array("class" => "gThumbnail"), $thumbsize, true) ?> -
  • - + += 25): ?> + + \ 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 d2cdd957..28b45be0 100644 --- a/modules/organize/views/organize_tree.html.php +++ b/modules/organize/views/organize_tree.html.php @@ -1,4 +1,20 @@ - $child): ?> - +
  • + "> + + +
    gBranchText"> + title) ?> +
    + +
    + + + +
  • -- cgit v1.2.3 From 63f3efef37839ffba8cd75b9098d56cd03b06376 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 5 Aug 2009 10:26:49 -0700 Subject: Revert "Revert "Enable the expand/collapse of branches by clicking on the plus/minus"" This reverts commit e37526f94df74a52a9cf36f0a5a5e641958ebbb3. --- modules/organize/controllers/organize.php | 59 ++++++++++++++++--------- modules/organize/css/organize.css | 8 ++++ modules/organize/js/organize.js | 28 +++++++++++- modules/organize/views/organize_dialog.html.php | 2 +- modules/organize/views/organize_tree.html.php | 10 +++-- 5 files changed, 80 insertions(+), 27 deletions(-) diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index d7854c53..e10e33b5 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -50,6 +50,27 @@ class Organize_Controller extends Controller { print $v->__toString(); } + function children($item_id) { + $item = ORM::factory("item", $item_id); + access::required("view", $item); + access::required("edit", $item); + + $albums = $item->children(null, 0, "album", array("title" => "ASC")); + + $children = ""; + foreach ($albums as $album) { + $v = new View("organize_tree.html"); + $v->album = $album; + $v->selected = false; + $v->children = array(); + $v->album_icon = $album->children_count("album") ? "ui-icon-plus" : "gBranchEmpty"; + + $children .= $v->__toString(); + } + + print $children; + } + private function _get_micro_thumb_grid($item, $offset=0) { $v = new View("organize_thumb_grid.html"); $v->item_id = $item->id; @@ -60,34 +81,30 @@ class Organize_Controller extends Controller { return $v; } - private function _tree($item, $parent, $selected=false) { - access::required("view", $item); - access::required("edit", $item); - - $albums = ORM::factory("item") - ->where(array("parent_id" => $parent->id, "type" => "album")) - ->orderby(array("title" => "ASC")) - ->find_all(); + private function _tree($item, $parent, $depth=0) { + $albums = $parent->children(null, 0, "album", array("title" => "ASC")); $v = new View("organize_tree.html"); $v->album = $parent; - $v->selected = false; - $v->children = ""; - $v->album_icon = "ui-icon-plus"; - if (!$selected) { - $v->selected = $parent->id == $item->id; + if ($parent->id == $item->id) { + $v->selected = true; + $depth = 1; + } else { + $v->selected = false; + } + $v->children = array(); + $v->album_icon = "gBranchEmpty"; + if ($albums->count()) { + $v->album_icon = "ui-icon-plus"; - if ($albums->count() && ($parent->id == 1 || $v->selected) ) { + if ($depth <= 1) { $v->album_icon = "ui-icon-minus"; - } - - foreach ($albums as $album) { - $v->children .= $this->_tree($item, $album, $v->selected); + foreach ($albums as $album) { + $v->children[] = $this->_tree($item, $album, ++$depth); + } } } - return $v->__toString(); + return $v; } - - } diff --git a/modules/organize/css/organize.css b/modules/organize/css/organize.css index 4568a707..7c2d9c5b 100644 --- a/modules/organize/css/organize.css +++ b/modules/organize/css/organize.css @@ -41,6 +41,14 @@ padding-left: 1.2em; } +.gBranchText:hover { + border: 1px dashed #999; +} + +.gBranchEmpty { + visibility: hidden; +} + .gBranchSelected { background-color: #cfdeff !important; border-bottom: 1px solid #999 !important; diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js index e84afd03..74b02569 100644 --- a/modules/organize/js/organize.js +++ b/modules/organize/js/organize.js @@ -37,7 +37,6 @@ * Dynamically initialize the organize dialog when it is displayed */ function _init(data) { - // Deal with ui.jquery bug: http://dev.jqueryui.com/ticket/4475 $(".sf-menu li.sfHover ul").css("z-index", 70); @@ -64,6 +63,8 @@ $.gallery_reload(); }); + $(".gBranchText span").click(_collapse_or_expanded_tree); + //$(".gOrganizeBranch .ui-icon").click(organizeToggleChildren); //$(".gBranchText").droppable(treeDroppable); //$(".gBranchText").click(organizeOpenFolder); @@ -109,6 +110,31 @@ $("#gOrganizeDialog").dialog("close"); }; + /** + * Open or close a branch. If the children is a div placeholder, replace with -