Skip to content

Commit

Permalink
Fix-ups for d98b85f
Browse files Browse the repository at this point in the history
- Pass the CSS selector of the active image in as an arg to site_menu
  so that quick operations know what they're operating on.
- Change the ids from g-{photo,movie}-id to the generic g-item-id
- Initialize ajax handlers for site menu on the photo and movie page
- Drop the movie context menu, it's now in the site menu
  • Loading branch information
bharat committed May 14, 2010
1 parent dc4fdca commit 1240878
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 10 deletions.
9 changes: 6 additions & 3 deletions modules/gallery/helpers/gallery_event.php
Expand Up @@ -167,7 +167,7 @@ static function user_menu($menu, $theme) {
}
}

static function site_menu($menu, $theme) {
static function site_menu($menu, $theme, $item_css_selector) {
if ($theme->page_subtype != "login") {
$menu->append(Menu::factory("link")
->id("home")
Expand Down Expand Up @@ -239,6 +239,9 @@ static function site_menu($menu, $theme) {
}
}

$csrf = access::csrf_token();
$theme_item = $theme->item();
$page_type = $theme->page_type();
if ($item->is_photo() && graphics::can("rotate")) {
$options_menu
->append(
Expand All @@ -247,15 +250,15 @@ static function site_menu($menu, $theme) {
->label(t("Rotate 90° counter clockwise"))
->css_class("ui-icon-rotate-ccw")
->ajax_handler("function(data) { " .
"\$.gallery_replace_image(data, \$('$thumb_css_selector')) }")
"\$.gallery_replace_image(data, \$('$item_css_selector')) }")
->url(url::site("quick/rotate/$item->id/ccw?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type")))
->append(
Menu::factory("ajax_link")
->id("rotate_cw")
->label(t("Rotate 90° clockwise"))
->css_class("ui-icon-rotate-cw")
->ajax_handler("function(data) { " .
"\$.gallery_replace_image(data, \$('$thumb_css_selector')) }")
"\$.gallery_replace_image(data, \$('$item_css_selector')) }")
->url(url::site("quick/rotate/$item->id/cw?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type")));
}

Expand Down
4 changes: 2 additions & 2 deletions modules/gallery/libraries/Theme_View.php
Expand Up @@ -86,9 +86,9 @@ public function user_menu() {
return $menu->render();
}

public function site_menu() {
public function site_menu($item_css_selector) {
$menu = Menu::factory("root");
module::event("site_menu", $menu, $this);
module::event("site_menu", $menu, $this, $item_css_selector);
return $menu->render();
}

Expand Down
2 changes: 1 addition & 1 deletion modules/gallery/models/item.php
Expand Up @@ -674,7 +674,7 @@ public function movie_img($extra_attrs) {
$v->attrs = array_merge($extra_attrs,
array("style" => "display:block;width:{$this->width}px;height:{$this->height}px"));
if (empty($v->attrs["id"])) {
$v->attrs["id"] = "g-movie-id-{$this->id}";
$v->attrs["id"] = "g-item-id-{$this->id}";
}
return $v;
}
Expand Down
3 changes: 3 additions & 0 deletions themes/wind/js/ui.init.js
Expand Up @@ -108,6 +108,9 @@ $(document).ready(function() {
duration: 1000,
hash: true
});

$(this).find(".g-dialog-link").gallery_dialog();
$(this).find(".g-ajax-link").gallery_ajax();
}

// Initialize button hover effect
Expand Down
3 changes: 1 addition & 2 deletions themes/wind/views/movie.html.php
Expand Up @@ -5,8 +5,7 @@
<?= $theme->paginator() ?>

<div id="g-movie" class="ui-helper-clearfix">
<?= $item->movie_img(array("class" => "g-movie", "id" => "g-movie-id-{$item->id}")) ?>
<?= $theme->context_menu($item, "#g-movie-id-{$item->id}") ?>
<?= $item->movie_img(array("class" => "g-movie", "id" => "g-item-id-{$item->id}")) ?>
</div>

<div id="g-info">
Expand Down
2 changes: 1 addition & 1 deletion themes/wind/views/page.html.php
Expand Up @@ -89,7 +89,7 @@

<!-- hide the menu and make it visible after the page has loaded, to minimize menu flicker -->
<div id="g-site-menu" style="visibility: hidden">
<?= $theme->site_menu() ?>
<?= $theme->site_menu($theme->item() ? "#g-item-id-{$theme->item()->id}" : "") ?>
</div>
<script type="text/javascript"> $(document).ready(function() { $("#g-site-menu").css("visibility", "visible"); }) </script>

Expand Down
2 changes: 1 addition & 1 deletion themes/wind/views/photo.html.php
Expand Up @@ -22,7 +22,7 @@
<? if (access::can("view_full", $item)): ?>
<a href="<?= $item->file_url() ?>" class="g-fullsize-link" title="<?= t("View full size")->for_html_attr() ?>">
<? endif ?>
<?= $item->resize_img(array("id" => "g-photo-id-{$item->id}", "class" => "g-resize")) ?>
<?= $item->resize_img(array("id" => "g-item-id-{$item->id}", "class" => "g-resize")) ?>
<? if (access::can("view_full", $item)): ?>
</a>
<? endif ?>
Expand Down

0 comments on commit 1240878

Please sign in to comment.