mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-08-22 23:05:18 -04:00
Merge branch 'master' of git@github.com:bharat/gallery3
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
(function($) {
|
||||
$.widget("ui.gallery_ajax", {
|
||||
_init: function() {
|
||||
this.element.click(function(event) {
|
||||
eval("var ajax_handler = " + $(event.currentTarget).attr("ajax_handler"));
|
||||
$.get($(event.currentTarget).attr("href"), function(data) {
|
||||
eval("var data = " + data);
|
||||
ajax_handler(data);
|
||||
});
|
||||
event.preventDefault();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
||||
@@ -80,7 +80,7 @@
|
||||
return this.id.match(/gPhotoId-\d+/);
|
||||
});
|
||||
return photo;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the sum of an element's height, margin-top, and margin-bottom
|
||||
@@ -104,7 +104,11 @@
|
||||
$(this).removeClass("ui-state-hover");
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// Ajax handler for replacing an image, used in Ajax thumbnail rotation
|
||||
$.gallery_replace_image = function(data, thumb) {
|
||||
$(thumb).attr({src: data.src, width: data.width, height: data.height});
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
|
||||
@@ -197,108 +197,117 @@ class gallery_Core {
|
||||
return $menu;
|
||||
}
|
||||
|
||||
static function context_menu($menu, $theme, $item) {
|
||||
$page_type = $theme->page_type();
|
||||
switch ($item->type) {
|
||||
case "movie":
|
||||
$edit_title = t("Edit this movie");
|
||||
$delete_title = t("Delete this movie");
|
||||
break;
|
||||
|
||||
case "album":
|
||||
$edit_title = t("Edit this album");
|
||||
$delete_title = t("Delete this album");
|
||||
break;
|
||||
|
||||
default:
|
||||
$edit_title = t("Edit this photo");
|
||||
$delete_title = t("Delete this photo");
|
||||
break;
|
||||
}
|
||||
$cover_title = t("Choose as the album cover");
|
||||
$move_title = t("Move to another album");
|
||||
|
||||
$csrf = access::csrf_token();
|
||||
|
||||
static function context_menu($menu, $theme, $item, $thumb_css_selector) {
|
||||
$menu->append($options_menu = Menu::factory("submenu")
|
||||
->id("options_menu")
|
||||
->label(t("Options"))
|
||||
->css_class("ui-icon-carat-1-n"));
|
||||
|
||||
$options_menu->append(Menu::factory("dialog")
|
||||
->id("edit")
|
||||
->label($edit_title)
|
||||
->css_class("ui-icon-pencil")
|
||||
->url(url::site("quick/form_edit/$item->id?page_type=$page_type")));
|
||||
if (access::can("edit", $item)) {
|
||||
$page_type = $theme->page_type();
|
||||
switch ($item->type) {
|
||||
case "movie":
|
||||
$edit_title = t("Edit this movie");
|
||||
$delete_title = t("Delete this movie");
|
||||
break;
|
||||
|
||||
case "album":
|
||||
$edit_title = t("Edit this album");
|
||||
$delete_title = t("Delete this album");
|
||||
break;
|
||||
|
||||
if ($item->is_photo() && graphics::can("rotate")) {
|
||||
$options_menu
|
||||
->append(Menu::factory("link")
|
||||
->id("rotate_ccw")
|
||||
->label(t("Rotate 90° counter clockwise"))
|
||||
->css_class("ui-icon-rotate-ccw")
|
||||
->url(url::site("quick/rotate/$item->id/ccw?csrf=$csrf&page_type=$page_type")))
|
||||
->append(Menu::factory("link")
|
||||
->id("rotate_cw")
|
||||
->label(t("Rotate 90° clockwise"))
|
||||
->css_class("ui-icon-rotate-cw")
|
||||
->url(url::site("quick/rotate/$item->id/cw?csrf=$csrf&page_type=$page_type")));
|
||||
}
|
||||
|
||||
// Don't move photos from the photo page; we don't yet have a good way of redirecting after move
|
||||
if ($page_type == "album") {
|
||||
$options_menu
|
||||
->append(Menu::factory("dialog")
|
||||
->id("move")
|
||||
->label($move_title)
|
||||
->css_class("ui-icon-folder-open")
|
||||
->url(url::site("move/browse/$item->id")));
|
||||
}
|
||||
|
||||
$parent = $item->parent();
|
||||
if (access::can("edit", $parent)) {
|
||||
// We can't make this item the highlight if it's an album with no album cover, or if it's
|
||||
// already the album cover.
|
||||
if (($item->type == "album" && empty($item->album_cover_item_id)) ||
|
||||
($item->type == "album" && $parent->album_cover_item_id == $item->album_cover_item_id) ||
|
||||
$parent->album_cover_item_id == $item->id) {
|
||||
$disabledState = " ui-state-disabled";
|
||||
} else {
|
||||
$disabledState = " ";
|
||||
default:
|
||||
$edit_title = t("Edit this photo");
|
||||
$delete_title = t("Delete this photo");
|
||||
break;
|
||||
}
|
||||
$options_menu
|
||||
->append(Menu::factory("link")
|
||||
->id("make_album_cover")
|
||||
->label($cover_title)
|
||||
->css_class("ui-icon-star")
|
||||
->url(
|
||||
url::site("quick/make_album_cover/$item->id?csrf=$csrf&page_type=$page_type")))
|
||||
->append(Menu::factory("dialog")
|
||||
->id("delete")
|
||||
->label($delete_title)
|
||||
->css_class("ui-icon-trash")
|
||||
->css_id("gQuickDelete")
|
||||
->url(url::site("quick/form_delete/$item->id?csrf=$csrf&page_type=$page_type")));
|
||||
}
|
||||
$cover_title = t("Choose as the album cover");
|
||||
$move_title = t("Move to another album");
|
||||
|
||||
if ($item->is_album()) {
|
||||
$options_menu
|
||||
->append(Menu::factory("dialog")
|
||||
->id("add_item")
|
||||
->label(t("Add a photo"))
|
||||
->css_class("add_item")
|
||||
->url(url::site("simple_uploader/app/$item->id")))
|
||||
->append(Menu::factory("dialog")
|
||||
->id("add_album")
|
||||
->label(t("Add an album"))
|
||||
->css_class("add_album")
|
||||
->url(url::site("form/add/albums/$item->id?type=album")))
|
||||
->append(Menu::factory("dialog")
|
||||
->id("edit_permissions")
|
||||
->label(t("Edit permissions"))
|
||||
->css_class("permissions")
|
||||
->url(url::site("permissions/browse/$item->id")));
|
||||
$csrf = access::csrf_token();
|
||||
|
||||
$options_menu->append(Menu::factory("dialog")
|
||||
->id("edit")
|
||||
->label($edit_title)
|
||||
->css_class("ui-icon-pencil")
|
||||
->url(url::site("quick/form_edit/$item->id?page_type=$page_type")));
|
||||
|
||||
|
||||
if ($item->is_photo() && graphics::can("rotate")) {
|
||||
$options_menu
|
||||
->append(
|
||||
Menu::factory("ajax_link")
|
||||
->id("rotate_ccw")
|
||||
->label(t("Rotate 90° counter clockwise"))
|
||||
->css_class("ui-icon-rotate-ccw")
|
||||
->ajax_handler("function(data) { " .
|
||||
"\$.gallery_replace_image(data, \$('$thumb_css_selector')) }")
|
||||
->url(url::site("quick/rotate/$item->id/ccw?csrf=$csrf&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')) }")
|
||||
->url(url::site("quick/rotate/$item->id/cw?csrf=$csrf&page_type=$page_type")));
|
||||
}
|
||||
|
||||
// Don't move photos from the photo page; we don't yet have a good way of redirecting after
|
||||
// move
|
||||
if ($page_type == "album") {
|
||||
$options_menu
|
||||
->append(Menu::factory("dialog")
|
||||
->id("move")
|
||||
->label($move_title)
|
||||
->css_class("ui-icon-folder-open")
|
||||
->url(url::site("move/browse/$item->id")));
|
||||
}
|
||||
|
||||
$parent = $item->parent();
|
||||
if (access::can("edit", $parent)) {
|
||||
// We can't make this item the highlight if it's an album with no album cover, or if it's
|
||||
// already the album cover.
|
||||
if (($item->type == "album" && empty($item->album_cover_item_id)) ||
|
||||
($item->type == "album" && $parent->album_cover_item_id == $item->album_cover_item_id) ||
|
||||
$parent->album_cover_item_id == $item->id) {
|
||||
$disabledState = " ui-state-disabled";
|
||||
} else {
|
||||
$disabledState = " ";
|
||||
}
|
||||
$options_menu
|
||||
->append(Menu::factory("ajax_link")
|
||||
->id("make_album_cover")
|
||||
->label($cover_title)
|
||||
->css_class("ui-icon-star")
|
||||
->ajax_handler("function(data) { window.location.reload() }")
|
||||
->url(url::site("quick/make_album_cover/$item->id?csrf=$csrf")))
|
||||
->append(Menu::factory("dialog")
|
||||
->id("delete")
|
||||
->label($delete_title)
|
||||
->css_class("ui-icon-trash")
|
||||
->css_id("gQuickDelete")
|
||||
->url(url::site("quick/form_delete/$item->id?csrf=$csrf&page_type=$page_type")));
|
||||
}
|
||||
|
||||
if ($item->is_album()) {
|
||||
$options_menu
|
||||
->append(Menu::factory("dialog")
|
||||
->id("add_item")
|
||||
->label(t("Add a photo"))
|
||||
->css_class("add_item")
|
||||
->url(url::site("simple_uploader/app/$item->id")))
|
||||
->append(Menu::factory("dialog")
|
||||
->id("add_album")
|
||||
->label(t("Add an album"))
|
||||
->css_class("add_album")
|
||||
->url(url::site("form/add/albums/$item->id?type=album")))
|
||||
->append(Menu::factory("dialog")
|
||||
->id("edit_permissions")
|
||||
->label(t("Edit permissions"))
|
||||
->css_class("permissions")
|
||||
->url(url::site("permissions/browse/$item->id")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,6 +96,37 @@ class Menu_Element_Link extends Menu_Element {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu element that provides an AJAX link.
|
||||
*/
|
||||
class Menu_Element_Ajax_Link extends Menu_Element {
|
||||
public $ajax_handler;
|
||||
|
||||
/**
|
||||
* Set the AJAX handler
|
||||
* @chainable
|
||||
*/
|
||||
public function ajax_handler($ajax_handler) {
|
||||
$this->ajax_handler = $ajax_handler;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
if (isset($this->css_id) && !empty($this->css_id)) {
|
||||
$css_id = " id=\"$this->css_id\"";
|
||||
} else {
|
||||
$css_id = "";
|
||||
}
|
||||
if (isset($this->css_class) && !empty($this->css_class)) {
|
||||
$css_class = " $this->css_class";
|
||||
} else {
|
||||
$css_class = "";
|
||||
}
|
||||
return "<li><a$css_id class=\"gAjaxLink $css_class\" href=\"$this->url\" " .
|
||||
"title=\"$this->label\" ajax_handler=\"$this->ajax_handler\">$this->label</a></li>";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu element that provides a pop-up dialog
|
||||
*/
|
||||
@@ -132,6 +163,9 @@ class Menu_Core extends Menu_Element {
|
||||
case "link":
|
||||
return new Menu_Element_Link($type);
|
||||
|
||||
case "ajax_link":
|
||||
return new Menu_Element_Ajax_Link($type);
|
||||
|
||||
case "dialog":
|
||||
return new Menu_Element_Dialog($type);
|
||||
|
||||
|
||||
@@ -111,15 +111,15 @@ class Theme_View_Core extends Gallery_View {
|
||||
return $menu->compact();
|
||||
}
|
||||
|
||||
public function context_menu($item) {
|
||||
public function context_menu($item, $thumbnail_css_selector) {
|
||||
$menu = Menu::factory("root")
|
||||
->append(Menu::factory("submenu")
|
||||
->id("context_menu")
|
||||
->label(t("Options")))
|
||||
->css_class("gContextMenu");
|
||||
|
||||
gallery::context_menu($menu, $this, $item);
|
||||
module::event("context_menu", $menu, $this, $item);
|
||||
gallery::context_menu($menu, $this, $item, $thumbnail_css_selector);
|
||||
module::event("context_menu", $menu, $this, $item, $thumbnail_css_selector);
|
||||
return $menu->compact();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@ $(document).ready(function(){
|
||||
// Initialize modal dialogs
|
||||
$(".gDialogLink").gallery_dialog();
|
||||
|
||||
// Initialize ajax links
|
||||
$(".gDialogLink").gallery_ajax();
|
||||
|
||||
// Initialize panels
|
||||
$(".gPanelLink").gallery_panel();
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
<script type="text/javascript">
|
||||
var MSG_CANCEL = "<?= t('Cancel') ?>";
|
||||
</script>
|
||||
<?= $theme->script("gallery.ajax.js") ?>
|
||||
<?= $theme->script("gallery.dialog.js") ?>
|
||||
<?= $theme->script("superfish/js/superfish.js") ?>
|
||||
<?= $theme->script("jquery.dropshadow.js") ?>
|
||||
|
||||
@@ -34,6 +34,7 @@ $(document).ready(function() {
|
||||
// Initialize dialogs
|
||||
$("#gLoginLink").addClass("gDialogLink");
|
||||
$(".gDialogLink").gallery_dialog();
|
||||
$(".gAjaxLink").gallery_ajax();
|
||||
|
||||
// Initialize view menu
|
||||
if ($("#gViewMenu").length) {
|
||||
@@ -100,8 +101,8 @@ $(document).ready(function() {
|
||||
$(".gContextMenu").hover(
|
||||
function() {
|
||||
$(this).find("ul").slideDown("fast");
|
||||
var dialogLinks = $(this).find(".gDialogLink");
|
||||
$(dialogLinks).gallery_dialog();
|
||||
$(this).find(".gDialogLink").gallery_dialog();
|
||||
$(this).find(".gAjaxLink").gallery_ajax();
|
||||
},
|
||||
function() {
|
||||
$(this).find("ul").slideUp("slow");
|
||||
@@ -128,8 +129,8 @@ $(document).ready(function() {
|
||||
$(".gContextMenu").hover(
|
||||
function() {
|
||||
$(this).find("ul").slideDown("fast");
|
||||
var dialogLinks = $(this).find(".gDialogLink");
|
||||
$(dialogLinks).gallery_dialog();
|
||||
$(this).find(".gDialogLink").gallery_dialog();
|
||||
$(this).find(".gAjaxLink").gallery_ajax();
|
||||
},
|
||||
function() {
|
||||
$(this).find("ul").slideUp("slow");
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<?= $child->thumb_img(array("class" => "gThumbnail")) ?>
|
||||
</a>
|
||||
<?= $theme->thumb_bottom($child) ?>
|
||||
<?= $theme->context_menu($child) ?>
|
||||
<?= $theme->context_menu($child, "#gItemId-{$child->id} .gThumbnail") ?>
|
||||
<h2><span></span><a href="<?= $child->url() ?>"><?= p::clean($child->title) ?></a></h2>
|
||||
<ul class="gMetadata">
|
||||
<?= $theme->thumb_info($child) ?>
|
||||
|
||||
@@ -36,5 +36,5 @@
|
||||
var ADD_A_COMMENT = "<?= t("Add a comment") ?>";
|
||||
</script>
|
||||
<?= $theme->photo_bottom() ?>
|
||||
<?= $theme->context_menu($item) ?>
|
||||
<?= $theme->context_menu($item, "#gMovieId-{$item->id}") ?>
|
||||
</div>
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
<script type="text/javascript">
|
||||
var MSG_CANCEL = "<?= t('Cancel') ?>";
|
||||
</script>
|
||||
<?= $theme->script("gallery.ajax.js") ?>
|
||||
<?= $theme->script("gallery.dialog.js") ?>
|
||||
<?= $theme->script("gallery.form.js") ?>
|
||||
<?= $theme->script("superfish/js/superfish.js") ?>
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
</a>
|
||||
<? endif ?>
|
||||
<?= $theme->resize_bottom($item) ?>
|
||||
<?= $theme->context_menu($item) ?>
|
||||
<?= $theme->context_menu($item, "#gPhotoId-{$item->id}") ?>
|
||||
</div>
|
||||
|
||||
<div id="gInfo">
|
||||
|
||||
Reference in New Issue
Block a user