From eec915b8874eb5f18ca823c5fbd76025a8914cae Mon Sep 17 00:00:00 2001 From: 3nids Date: Mon, 26 Oct 2009 09:04:17 +0100 Subject: [PATCH] Context menu of videos and photos inside the Lightbox theme! --- themes/3nids_theme/3nids/css/3nids.css | 1 + .../3nids_theme/3nids/js/jquery.fancybox.js | 32 ++++++++++++---- themes/3nids_theme/3nids/js/ui.init.js | 6 +++ .../3nids/views/movie_3nids.html.php | 3 +- .../3nids/views/photo_3nids.html.php | 38 +++++++++++++++++++ themes/3nids_theme/last_commit.txt | 2 +- .../theme_3nids/controllers/movie_3nids.php | 5 +-- .../theme_3nids/controllers/photo_3nids.php | 37 ++++++++++++++++++ .../theme_3nids/helpers/theme_3nids.php | 7 +--- 9 files changed, 114 insertions(+), 17 deletions(-) create mode 100755 themes/3nids_theme/3nids/views/photo_3nids.html.php create mode 100755 themes/3nids_theme/modules/theme_3nids/controllers/photo_3nids.php diff --git a/themes/3nids_theme/3nids/css/3nids.css b/themes/3nids_theme/3nids/css/3nids.css index cfd940be..68d8b627 100755 --- a/themes/3nids_theme/3nids/css/3nids.css +++ b/themes/3nids_theme/3nids/css/3nids.css @@ -19,6 +19,7 @@ .g-fancy-iframe-body{ background-color: #333333; + height: auto; } #mod_frame{ diff --git a/themes/3nids_theme/3nids/js/jquery.fancybox.js b/themes/3nids_theme/3nids/js/jquery.fancybox.js index 194d65fd..cf2a4582 100755 --- a/themes/3nids_theme/3nids/js/jquery.fancybox.js +++ b/themes/3nids_theme/3nids/js/jquery.fancybox.js @@ -128,14 +128,14 @@ }); } } else if (href.match("iframe") || opts.itemArray[opts.itemCurrent].fancyclass.indexOf("iframe") >= 0) { - if (href.match('width=') && href.match('height=')){ - var ifrWidth = parseInt(href.substring(href.indexOf('width=')+6,href.indexOf('endwidth')))+20; - var ifrHeight = parseInt(href.substring(href.indexOf('height=')+7,href.indexOf('endheight')))+50; + if (href.match('w=') && href.match('h=')){ + var ifrWidth = parseInt(href.substring(href.indexOf('w=')+2,href.indexOf('xewx'))); + var ifrHeight = parseInt(href.substring(href.indexOf('h=')+2,href.indexOf('xehx'))); }else{ var ifrWidth= opts.frameWidth; var ifrHeight= opts.frameHeight; } - + $("#fancy_content").empty(); _set_content('', ifrWidth, ifrHeight); } else { @@ -181,7 +181,14 @@ }; function _set_content(value, width, height) { + busy = true; + + + var w = $.fn.fancybox.getViewport(); + var r = Math.min(Math.min(w[0]-36, width) / width, Math.min(w[1]-50, height )/ height); + var width = Math.round(r * width); + var height = Math.round(r * height); var pad = opts.padding; @@ -214,7 +221,7 @@ 'right' : 0, 'bottom' : 0, 'left' : 0, - 'width' : '100%', + 'width' : '100%', 'height' : '100%' }); } @@ -228,8 +235,7 @@ return; } - - var w = $.fn.fancybox.getViewport(); + var itemLeft = (width + 36) > w[0] ? w[2] : (w[2] + Math.round((w[0] - width - 36) / 2)); var itemTop = (height + 50) > w[1] ? w[3] : (w[3] + Math.round((w[1] - height - 50) / 2)); @@ -420,6 +426,17 @@ $.fn.fancybox.showIframe = function() { $(".fancy_loading").hide(); $("#fancy_frame").show(); + var w = $.fn.fancybox.getViewport(); + var img = $("#fancy_frame").contents().find("#g-item-img"); + if (img.length){ + var width = img.width(); + var height = img.height(); + var ir = Math.min(Math.min(w[0]-36, width) / width, Math.min(w[1]-50, height) / height); + var width = Math.round(ir * width); + var height = Math.round(ir * height); + $("#fancy_frame").contents().find("#g-item-img").width(width); + $("#fancy_frame").contents().find("#g-item-img").height(height); + } }; $.fn.fancybox.getViewport = function() { @@ -460,6 +477,7 @@ } $("#fancy_close, .fancy_loading, #fancy_left, #fancy_right, #fancy_title, #fancy_modules").hide(); + $("#fancy_content").empty(); if (opts.centerOnScroll) { $(window).unbind("resize scroll"); diff --git a/themes/3nids_theme/3nids/js/ui.init.js b/themes/3nids_theme/3nids/js/ui.init.js index 14dc5f2a..88139e22 100755 --- a/themes/3nids_theme/3nids/js/ui.init.js +++ b/themes/3nids_theme/3nids/js/ui.init.js @@ -91,6 +91,12 @@ $(document).ready(function() { } ); } + + // Photo/Item item view lightbox + if ($("#g-item-box").length) { + $(this).gallery_context_menu(); + } + // Photo/Item item view if ($("#g-item").length) { diff --git a/themes/3nids_theme/3nids/views/movie_3nids.html.php b/themes/3nids_theme/3nids/views/movie_3nids.html.php index 13c7593c..d3a18cdd 100755 --- a/themes/3nids_theme/3nids/views/movie_3nids.html.php +++ b/themes/3nids_theme/3nids/views/movie_3nids.html.php @@ -31,7 +31,7 @@
-
+
file_url(true), "", $attrs) ?> + context_menu($item, "#g-movie-id-{$item->id}") ?>

title) ?>

diff --git a/themes/3nids_theme/3nids/views/photo_3nids.html.php b/themes/3nids_theme/3nids/views/photo_3nids.html.php new file mode 100755 index 00000000..bd612405 --- /dev/null +++ b/themes/3nids_theme/3nids/views/photo_3nids.html.php @@ -0,0 +1,38 @@ + + + + + + css("yui/reset-fonts-grids.css") ?> + css("superfish/css/superfish.css") ?> + css("themeroller/ui.base.css") ?> + css("gallery.common.css") ?> + css("jquery.fancybox.css") ?> + css("screen.css") ?> + css("3nids.css") ?> + script("jquery.js") ?> + script("jquery.form.js") ?> + script("jquery-ui.js") ?> + script("gallery.common.js") ?> + + + script("gallery.ajax.js") ?> + script("gallery.dialog.js") ?> + script("superfish/js/superfish.js") ?> + script("jquery.localscroll.js") ?> + script("jquery.easing.js") ?> + script("jquery.fancybox.js") ?> + script("ui.init.js") ?> +head() ?> + + +
+ +context_menu($item, "#g-item-id-{$item->id}") ?> + +
+ + diff --git a/themes/3nids_theme/last_commit.txt b/themes/3nids_theme/last_commit.txt index f7da686d..5ee23da2 100755 --- a/themes/3nids_theme/last_commit.txt +++ b/themes/3nids_theme/last_commit.txt @@ -1 +1 @@ -updated README \ No newline at end of file +Context menu of videos and photos inside the Lightbox theme! \ No newline at end of file diff --git a/themes/3nids_theme/modules/theme_3nids/controllers/movie_3nids.php b/themes/3nids_theme/modules/theme_3nids/controllers/movie_3nids.php index f72489a6..f9a2b75d 100755 --- a/themes/3nids_theme/modules/theme_3nids/controllers/movie_3nids.php +++ b/themes/3nids_theme/modules/theme_3nids/controllers/movie_3nids.php @@ -25,9 +25,8 @@ class Movie_3nids_Controller extends REST_Controller { * Display comments based on criteria. * @see REST_Controller::_index() */ - public function _index() { - $item_id = $this->input->get('item_id'); - $item = ORM::factory("item", $item_id); + public function show($item_id) { + $item = ORM::factory("item", $item_id); access::required("view", $item); $view = new Theme_View("movie_3nids.html", "page"); diff --git a/themes/3nids_theme/modules/theme_3nids/controllers/photo_3nids.php b/themes/3nids_theme/modules/theme_3nids/controllers/photo_3nids.php new file mode 100755 index 00000000..ca54e416 --- /dev/null +++ b/themes/3nids_theme/modules/theme_3nids/controllers/photo_3nids.php @@ -0,0 +1,37 @@ +item = $item; + print $view; + break; + } +} \ No newline at end of file diff --git a/themes/3nids_theme/modules/theme_3nids/helpers/theme_3nids.php b/themes/3nids_theme/modules/theme_3nids/helpers/theme_3nids.php index 7bdfb4f9..c8e921dd 100755 --- a/themes/3nids_theme/modules/theme_3nids/helpers/theme_3nids.php +++ b/themes/3nids_theme/modules/theme_3nids/helpers/theme_3nids.php @@ -39,9 +39,9 @@ class theme_3nids_Core { if (module::is_active("comment") && module::is_active("theme_3nids")){ $fancymodule .= "comment::" . url::site("comments_3nids?item_id={$item->id}") . ";;comment_count::" . comment_3nids::count($item) . ";;" ;} if ($item->is_photo()){ - $link .= "file_url() ."\" rel=\"fancygroup\" class=\"fancyclass\" title=\"" . $item->parent()->title .", " . $item->parent()->description ."\" name=\"" . $fancymodule . " \">"; + $link .= "id}") ."/?w=" . $item->width . "xewx&h=" . $item->height . "xehx\" rel=\"fancygroup\" class=\"fancyclass iframe\" title=\"" . $item->parent()->title .", " . $item->parent()->description ."\" name=\"" . $fancymodule . " \">"; }else{ - $link .= "id}") . "&width=" . $item->width . "endwidth&height=" . $item->height . "endheight\" rel=\"fancygroup\" class=\"fancyclass iframe\" title=\"" . $item->parent()->title .", " . $item->parent()->description ."\" name=\"" . $fancymodule . " \">"; + $link .= "id}") . "/?w=" . strval(20+($item->width)) . "xewx&h=" . strval(50+($item->height)) . "xehx\" rel=\"fancygroup\" class=\"fancyclass iframe\" title=\"" . $item->parent()->title .", " . $item->parent()->description ."\" name=\"" . $fancymodule . " \">"; } } elseif( $item->is_album() && $viewtype != "header"){ $link .= "url() . "\">"; @@ -54,9 +54,6 @@ class theme_3nids_Core { } elseif ( !($item->is_album()) && $viewtype == "dynamic") { $link .= "parent()->url() . "?show=" . $item->id . "\">

" . html::clean($item->parent()->title) . "

"; } - if ( !($item->is_album()) && $user->admin) { - $link .= "url() ."\">edit"; - } if (($item->is_photo() || $item->is_movie()) && module::is_active("comment") && module::is_active("theme_3nids")) { $link .= "";