diff options
Diffstat (limited to 'modules/slideshow')
-rw-r--r-- | modules/slideshow/controllers/slideshow.php | 64 | ||||
-rw-r--r-- | modules/slideshow/css/buttons.png | bin | 0 -> 3579 bytes | |||
-rw-r--r-- | modules/slideshow/css/slideshow.css | 101 | ||||
-rw-r--r-- | modules/slideshow/helpers/slideshow_event.php | 51 | ||||
-rw-r--r-- | modules/slideshow/helpers/slideshow_installer.php | 8 | ||||
-rw-r--r-- | modules/slideshow/helpers/slideshow_theme.php | 5 | ||||
-rw-r--r-- | modules/slideshow/js/slideshow.js | 145 | ||||
-rw-r--r-- | modules/slideshow/module.info | 2 |
8 files changed, 336 insertions, 40 deletions
diff --git a/modules/slideshow/controllers/slideshow.php b/modules/slideshow/controllers/slideshow.php new file mode 100644 index 00000000..8c4d1f46 --- /dev/null +++ b/modules/slideshow/controllers/slideshow.php @@ -0,0 +1,64 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2009 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ +class Slideshow_Controller extends Controller { + function album($item_id) { + $item = ORM::factory("item", $item_id); + access::required("view", $item); + + print json_encode(array_values($this->_build_image_list($item->children()))); + } + + function photo($item_id) { + $item = ORM::factory("item", $item_id); + access::required("view", $item); + + $images = $this->_build_image_list($item->parent()->children()); + $this_photo = array_search($item_id, array_keys($images)); + $images = array_merge(array_slice($images, $this_photo), array_slice($images, 0, $this_photo)); + + print json_encode($images); + } + + function tag($tag_id) { + $tag = ORM::factory("tag", $tag_id); + print json_encode(array_values($this->_build_image_list($tag->items()))); + } + + private function _build_image_list($children) { + $resizes = array(); + foreach ($children as $child) { + switch($child->type) { + case "album": + if (!empty($child->album_cover_item_id)) { + $cover = ORM::factory("item", $child->album_cover_item_id); + $resizes[$child->id] = array("url" => $cover->resize_url(), + "width" => $cover->resize_width, "height" => $cover->resize_height); + } + break; + case "photo": + $resizes[$child->id] = array("url" => $child->resize_url(), + "width" => $child->resize_width, "height" => $child->resize_height); + break; + } + } + + return $resizes; + } +} diff --git a/modules/slideshow/css/buttons.png b/modules/slideshow/css/buttons.png Binary files differnew file mode 100644 index 00000000..6fe50e1b --- /dev/null +++ b/modules/slideshow/css/buttons.png diff --git a/modules/slideshow/css/slideshow.css b/modules/slideshow/css/slideshow.css new file mode 100644 index 00000000..f635c244 --- /dev/null +++ b/modules/slideshow/css/slideshow.css @@ -0,0 +1,101 @@ +#gSlideshowOverlay { + border: none; + margin: 0; + padding: 0; + background-color: #000; + position: absolute; + top: 0px; + left: 0px; + width: 100%; + height: 100%; + opacity: 0.7; + filter: alpha(opacity=70); + -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; + -moz-background-inline-policy: -moz-initial; + z-index: 2001; +} + +#gSlideShowImages { + z-index: 2002; +} + +#gSlideShowImages img { + display: none; + float: left; + z-index: 2002; +} + +#gSlideshowButtonPanel { + bottom: .5em; + position: absolute; + width: 100%; + z-index: 2004; +} + +#gSlideshowButtonPanel div { + background-color: #000; + color: #fff; + filter: alpha(opacity=70); + height: 55px; + margin: 0 auto; + opacity: 0.7; + width: 232px; + z-index: 2004; +} + +#gSlideshowPrevious, +#gSlideshowPause, +#gSlideshowResume, +#gSlideshowResume, +#gSlideshowClose, +#gSlideshowNext { + background-image: url(buttons.png); + background-repeat: no-repeat; + display: block; + float: left; + height: 55px; + overflow: hidden; + text-indent: -99999px; + width: 58px; +} + +#gSlideshowPrevious { + background-position: 0 0; +} + +#gSlideshowPrevious:hover { + background-position: -58px 0; +} + +#gSlideshowPause { + background-position: -174px 0; +} + +#gSlideshowPause:hover { + background-position: -116px 0; +} + +#gSlideshowResume { + background-position: -290px 0; + display: none; +} + +#gSlideshowResume:hover { + background-position: -232px 0; +} + +#gSlideshowNext { + background-position: -406px 0; +} + +#gSlideshowNext:hover { + background-position: -348px 0; +} + +#gSlideshowClose { + background-position: -464px 0; +} + +#gSlideshowClose:hover { + background-position: -522px 0; +} diff --git a/modules/slideshow/helpers/slideshow_event.php b/modules/slideshow/helpers/slideshow_event.php index cf79f71a..926b4da1 100644 --- a/modules/slideshow/helpers/slideshow_event.php +++ b/modules/slideshow/helpers/slideshow_event.php @@ -18,45 +18,30 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class slideshow_event_Core { - static function module_change($changes) { - if (!module::is_active("rss") || in_array("rss", $changes->deactivate)) { - site_status::warning( - t("The Slideshow module requires the RSS module. " . - "<a href=\"%url\">Activate the RSS module now</a>", - array("url" => url::site("admin/modules"))), - "slideshow_needs_rss"); - } else { - site_status::clear("slideshow_needs_rss"); - } - } - static function album_menu($menu, $theme) { - $menu - ->append(Menu::factory("link") - ->id("slideshow") - ->label(t("View slideshow")) - ->url("javascript:PicLensLite.start(" . - "{maxScale:0,feedUrl:PicLensLite.indexFeeds()[0].url})") - ->css_id("gSlideshowLink")); + $item = $theme->item(); + $menu->append(Menu::factory("link") + ->id("slideshow") + ->label(t("View slideshow")) + ->url(url::site("slideshow/album/{$item->id}")) + ->css_id("gSlideshowLink")); } static function photo_menu($menu, $theme) { - $menu - ->append(Menu::factory("link") - ->id("slideshow") - ->label(t("View slideshow")) - ->url("javascript:PicLensLite.start(" . - "{maxScale:0,feedUrl:PicLensLite.indexFeeds()[0].url})") - ->css_id("gSlideshowLink")); + $item = $theme->item(); + $menu->append(Menu::factory("link") + ->id("slideshow") + ->label(t("View slideshow")) + ->url(url::site("slideshow/photo/{$item->id}")) + ->css_id("gSlideshowLink")); } static function tag_menu($menu, $theme) { - $menu - ->append(Menu::factory("link") - ->id("slideshow") - ->label(t("View slideshow")) - ->url("javascript:PicLensLite.start(" . - "{maxScale:0,feedUrl:PicLensLite.indexFeeds()[0].url})") - ->css_id("gSlideshowLink")); + $tag = $theme->tag(); + $menu->append(Menu::factory("link") + ->id("slideshow") + ->label(t("View slideshow")) + ->url(url::site("slideshow/tag/{$tag->id}")) + ->css_id("gSlideshowLink")); } } diff --git a/modules/slideshow/helpers/slideshow_installer.php b/modules/slideshow/helpers/slideshow_installer.php index cd1c6e05..a71ea183 100644 --- a/modules/slideshow/helpers/slideshow_installer.php +++ b/modules/slideshow/helpers/slideshow_installer.php @@ -19,10 +19,12 @@ */ class slideshow_installer { static function install() { - module::set_version("slideshow", 1); + module::set_version("slideshow", 2); } - static function deactivate() { - site_status::clear("slideshow_needs_rss"); + static function upgrade($version) { + if ($version == 1) { + module::set_version("slideshow", 2); + } } } diff --git a/modules/slideshow/helpers/slideshow_theme.php b/modules/slideshow/helpers/slideshow_theme.php index 269a93ce..fdce22f3 100644 --- a/modules/slideshow/helpers/slideshow_theme.php +++ b/modules/slideshow/helpers/slideshow_theme.php @@ -19,8 +19,7 @@ */ class slideshow_theme_Core { static function head($theme) { - $proto = (empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] === "off") ? "http" : "https"; - return "<script src=\"$proto://lite.piclens.com/current/piclens_optimized.js\" " . - "type=\"text/javascript\"></script>"; + $theme->script("slideshow.js"); + $theme->css("slideshow.css"); } } diff --git a/modules/slideshow/js/slideshow.js b/modules/slideshow/js/slideshow.js new file mode 100644 index 00000000..1dffbf5a --- /dev/null +++ b/modules/slideshow/js/slideshow.js @@ -0,0 +1,145 @@ +(function($) { + $.gallery_slideshow = { + interval: 4000, + timer: null, + images: [], + current: -1, + init: function(data) { + var self = this; + var size = $.gallery_get_viewport_size(); + $("body").append( + '<div id="gSlideshowOverlay" class="ui-dialog-overlay"></div>' + + '<div class="gLoadingLarge" style="z-index; 2005; width:100%; height:100%"> </div>' + + '<div id="gSlideshowButtonPanel"><div class="ui-corner-all">' + + '<a id="gSlideshowPrevious" href="javascript: $.gallery_slideshow.previous()" />' + + '<a id="gSlideshowPause" href="javascript: $.gallery_slideshow.pause()" />' + + '<a id="gSlideshowResume" href="javascript: $.gallery_slideshow.resume()" />' + + '<a id="gSlideshowNext" href="javascript: $.gallery_slideshow.next()" />' + + '<a id="gSlideshowClose" href="javascript: $.gallery_slideshow.close()" />' + + '</div></div>' + + '<div id="gSlideShowImages"></div>'); + $().bind("mousemove", $.gallery_slideshow._mouse_over); + + // array of {url: xxx, width: nnn, height: nnn} + for (var i=0; i < data.length; i++) { + $("#gSlideShowImages").append( + '<img id="img_' + i + '" src="' + data[i].url + '" width="' + data[i].width + 'px" ' + + 'height="' + data[i].height + 'px" />'); + $("#gSlideShowImages #img_" + i).load(function() { + $.gallery_slideshow.images.push("#" +$(this).attr("id")); + if ($.gallery_slideshow.images.length == 1) { + $.gallery_slideshow._show_image(null); + setTimeout(function() {$("#gSlideshowButtonPanel").hide();}, + $.gallery_slideshow.interval); + } + }); + }; + $(window).resize(function() { + var size = $.gallery_get_viewport_size(); + $("#gSlideshowOverlay").width(size.width()).height(size.height()); + var current = $(".gSlideCurrent"); + var position = $.gallery_auto_fit_window(current.width(), current.height()); + $($.gallery_slideshow.images[$.gallery_slideshow.current].replace("img", "clone")) + .height(position.height).width(position.width).css({ + top: position.top, + left: position.left + }); + }); + }, + + close: function(event) { + $.gallery_slideshow.pause(); + $($.gallery_slideshow.images[$.gallery_slideshow.current].replace("img", "clone")).remove(); + $("#gSlideshowOverlay").remove(); + $("#gSlideShowImages").remove(); + $("#gSlideshowButtonPanel").remove(); + $().unbind("mousemove", $.gallery_slideshow._mouse_over); + }, + + previous: function() { + $.gallery_slideshow.pause(); + $.gallery_slideshow.current--; + + $.gallery_slideshow.current = --$.gallery_slideshow.current < 0 ? + $.gallery_slideshow.images.length - 1 : $.gallery_slideshow.current; + var next_image = $($.gallery_slideshow.images[$.gallery_slideshow.current]); + $.gallery_slideshow._show_image(next_image); + }, + + next: function() { + $.gallery_slideshow.pause(); + $.gallery_slideshow.current = ++$.gallery_slideshow.current % $.gallery_slideshow.images.length; + var next_image = $($.gallery_slideshow.images[$.gallery_slideshow.current]); + $.gallery_slideshow._show_image(next_image); + }, + + pause: function() { + if ($.gallery_slideshow.timer) { + $("#gSlideshowPause").toggle(); + $("#gSlideshowResume").toggle(); + clearTimeout($.gallery_slideshow.timer); + $.gallery_slideshow.timer = null; + } + }, + + resume: function() { + $("#gSlideshowPause").toggle(); + $("#gSlideshowResume").toggle(); + $.gallery_slideshow._show_image(null); + }, + + _mouse_over: function(event) { + var size = $.gallery_get_viewport_size(); + if (event.pageY < size.height() && size.height() - 100 <= event.pageY) { + $("#gSlideshowButtonPanel").show(); + } else { + $("#gSlideshowButtonPanel").hide(); + } + }, + + // If next_image is not null, then this a call from prev or next + _show_image: function(next_image) { + var reset_timer = false; + var previous = $.gallery_slideshow.current; + if (next_image == null) { + $.gallery_slideshow.current = ++$.gallery_slideshow.current % $.gallery_slideshow.images.length; + next_image = $($.gallery_slideshow.images[$.gallery_slideshow.current]); + reset_timer = true; + } + var zIndex = parseInt(next_image.css("zIndex")); + var position = $.gallery_auto_fit_window(next_image.width(), next_image.height()); + var clone = next_image.clone(); + + clone.attr("id", next_image.attr("id").replace("img", "clone")); + clone.height(position.height).width(position.width).css({ + marginTop: 0, marginLeft: 0, marginBottom: 0, marginRight: 0, + display: "none", + position: "absolute", + zIndex: zIndex + 1, + top: position.top + "px", + left: position.left + "px" + }); + + $("body").append(clone); + clone.fadeIn("slow", function() { + if (previous >= 0) { + $($.gallery_slideshow.images[previous].replace("img", "clone")).remove(); + } + clone.css("zIndex", zIndex); + if (reset_timer) { + $.gallery_slideshow.timer = + setTimeout(function() {$.gallery_slideshow._show_image(null);}, + $.gallery_slideshow.interval); + } + }); + } + }; +})(jQuery); + +$(document).ready(function() { + $("#gSlideshowLink").click(function(event) { + event.preventDefault(); + $.get($(event.currentTarget).attr("href"), {}, $.gallery_slideshow.init, "json"); + return false; + }); +}); diff --git a/modules/slideshow/module.info b/modules/slideshow/module.info index 6841199a..b56eac81 100644 --- a/modules/slideshow/module.info +++ b/modules/slideshow/module.info @@ -1,3 +1,3 @@ name = "Slideshow" description = "Allows users to view a slideshow of photos" -version = 1 +version = 2 |