Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

New module: carousel not on GIT before

  • Loading branch information...
commit db073dd3b0aecb062a3ef2217d4cb501a143cd74 1 parent 41135b6
@floridave floridave authored
View
183 3.0/modules/carousel/controllers/admin_carousel.php
@@ -0,0 +1,183 @@
+<?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 Admin_Carousel_Controller extends Admin_Controller {
+ public function index() {
+ print $this->_get_view();
+ }
+
+ public function handler() {
+ access::verify_csrf();
+
+ $form = $this->_get_form();
+ if ($form->validate()) {
+ module::set_var(
+ "carousel", "circular", $form->carousel->circular->value);
+ module::set_var(
+ "carousel", "autoscroll", $form->carousel->autoscroll->value);
+ module::set_var(
+ "carousel", "autostart", $form->carousel->autostart->value);
+ module::set_var(
+ "carousel", "speed", $form->carousel->speed->value);
+ module::set_var(
+ "carousel", "mousewheel", $form->carousel->mousewheel->value);
+
+ module::set_var(
+ "carousel", "title2", $form->recent->title2->value);
+ module::set_var(
+ "carousel", "thumbsize2", $form->recent->thumbsize2->value);
+ module::set_var(
+ "carousel", "visible2", $form->recent->visible2->value);
+ module::set_var(
+ "carousel", "quantity2", $form->recent->quantity2->value);
+ module::set_var(
+ "carousel", "onphoto2", $form->recent->onphoto2->value);
+ module::set_var(
+ "carousel", "onalbum2", $form->recent->onalbum2->value);
+
+ module::set_var(
+ "carousel", "title3", $form->popular->title3->value);
+ module::set_var(
+ "carousel", "thumbsize3", $form->popular->thumbsize3->value);
+ module::set_var(
+ "carousel", "visible3", $form->popular->visible3->value);
+ module::set_var(
+ "carousel", "quantity3", $form->popular->quantity3->value);
+ module::set_var(
+ "carousel", "onphoto3", $form->popular->onphoto3->value);
+ module::set_var(
+ "carousel", "onalbum3", $form->popular->onalbum3->value);
+
+ module::set_var(
+ "carousel", "title", $form->random->title->value);
+ module::set_var(
+ "carousel", "thumbsize", $form->random->thumbsize->value);
+ module::set_var(
+ "carousel", "visible", $form->random->visible->value);
+ module::set_var(
+ "carousel", "quantity", $form->random->quantity->value);
+ module::set_var(
+ "carousel", "onphoto", $form->random->onphoto->value);
+ module::set_var(
+ "carousel", "onalbum", $form->random->onalbum->value);
+
+ message::success(t("Your settings have been saved."));
+ url::redirect("admin/carousel");
+ }
+ print $this->_get_view($form);
+ }
+
+ private function _get_view($form=null) {
+ $v = new Admin_View("admin.html");
+ $v->content = new View("admin_carousel.html");
+ $v->content->form = empty($form) ? $this->_get_form() : $form;
+ return $v;
+ }
+
+ private function _get_form() {
+ for ($i = 5; $i <= 50; $i+=5) {
+ $range[$i] = "$i";
+ }
+ $shortrange = array();
+ for ($i = 1; $i < 21; $i++) {
+ $key=((float)$i / 2);
+ $shortrange["$key"] = sprintf("%.1f", (float)$i / 2);
+ }
+ if (module::get_var("carousel", "autoscroll") == true) {
+ $disableme == "false";
+ } else {
+ $disableme == "true";
+ }
+ $form = new Forge("admin/carousel/handler", "", "post", array("id" => "g-admin-form"));
+
+ $group = $form->group("carousel")->label(t("General carousel settings"));
+ $group->checkbox("circular")->label(t('Enable the carousel to be circular so it starts over again from the beggining.'))
+ ->checked(module::get_var("carousel", "circular", "0"));
+ $group->checkbox("autoscroll")->label(t('Carousel should auto scroll. Toggle value to change settings below.'))
+ ->onClick("toggle()")
+ ->id("autoscroll")
+ ->checked(module::get_var("carousel", "autoscroll", "0"));
+ $group->input("autostart")->label(t("Enter the value of the auto start. (800)"))
+ ->value(module::get_var("carousel", "autostart", "800"))
+ ->id("auto")
+ ->disabled("false")
+ ->rules("valid_numeric|length[1,5]");
+ $group->input("speed")->label(t('Enter the scrolling speed of the carousel. (1000)'))
+ ->value(module::get_var("carousel", "speed", "1000"))
+ ->id("speed")
+ ->disabled($disableme)
+ ->rules("valid_numeric|length[1,5]");
+ $group->checkbox("mousewheel")->label(t('Enable mouse wheel. Allows for mouse wheel to scroll items.'))
+ ->checked(module::get_var("carousel", "mousewheel", "0"));
+
+ $group = $form->group("recent")->label(t("Recent carousel block"));
+ $group->input("title2")->label(t('Enter the title of the recent block.'))
+ ->value(module::get_var("carousel", "title2", "Recent items"));
+ $group->input("thumbsize2")->label(t('Enter the size of the thumbs. (pixels)'))
+ ->value(module::get_var("carousel", "thumbsize2", "200"))
+ ->rules("valid_numeric|length[2,3]");
+ $group->dropdown("visible2")->label(t('Enter number of thumbs to show. (height of carousel)'))
+ ->options($shortrange)
+ ->selected(module::get_var("carousel", "visible2", "1"));
+ $group->dropdown("quantity2")->label(t("Choose the toal quantity of thumbs in recent carousel."))
+ ->options($range)
+ ->selected(module::get_var("carousel", "quantity2", "25"));
+ $group->checkbox("onalbum2")->label(t("Show on album & collection pages"))
+ ->checked(module::get_var("carousel", "onalbum2", "0"));
+ $group->checkbox("onphoto2")->label(t("Show on photo pages"))
+ ->checked(module::get_var("carousel", "onphoto2", "0"));
+
+ $group = $form->group("popular")->label(t("Popular carousel block"));
+ $group->input("title3")->label(t('Enter the title of the popular block.'))
+ ->value(module::get_var("carousel", "title3", "Popular items"));
+ $group->input("thumbsize3")->label(t('Enter the thumb size. (pixels)'))
+ ->value(module::get_var("carousel", "thumbsize3", "200"))
+ ->rules("valid_numeric|length[2,3]");
+ $group->dropdown("visible3")->label(t('Enter number of thumbs to show. (height of carousel)'))
+ ->options($shortrange)
+ ->selected(module::get_var("carousel", "visible3", "1"));
+ $group->dropdown("quantity3")->label(t("Choose the toal quantity of thumbs in popular carousel."))
+ ->options($range)
+ ->selected(module::get_var("carousel", "quantity3", "25"));
+ $group->checkbox("onalbum3")->label(t("Show on album & collection pages"))
+ ->checked(module::get_var("carousel", "onalbum3", "0"));
+ $group->checkbox("onphoto3")->label(t("Show on photo pages"))
+ ->checked(module::get_var("carousel", "onphoto3", "0"));
+
+ $group = $form->group("random")->label(t("Random carousel block. Some issues with smaller galleries."));
+ $group->input("title")->label(t('Enter the title of the random block.'))
+ ->value(module::get_var("carousel", "title", "Random items"));
+ $group->input("thumbsize")->label(t('Enter the thumb size. (pixels)'))
+ ->value(module::get_var("carousel", "thumbsize", "200"))
+ ->rules("valid_numeric|length[2,3]");
+ $group->dropdown("visible")->label(t('Enter number of thumbs to show. (height of carousel)'))
+ ->options($shortrange)
+ ->selected(module::get_var("carousel", "visible", "1"));
+ $group->dropdown("quantity")->label(t("Choose the toal quantity of thumbs in random carousel."))
+ ->options($range)
+ ->selected(module::get_var("carousel", "quantity", "25"));
+ $group->checkbox("onalbum")->label(t("Show on album & collection pages"))
+ ->checked(module::get_var("carousel", "onalbum", "0"));
+ $group->checkbox("onphoto")->label(t("Show on photo pages"))
+ ->checked(module::get_var("carousel", "onphoto", "0"));
+
+ $form->submit("submit")->value(t("Save"));
+ return $form;
+ }
+}
View
30 3.0/modules/carousel/css/carousel.css
@@ -0,0 +1,30 @@
+.jcarousel-container {
+ -moz-border-radius: 10px;
+ background: #F0F6F9;
+ border: 1px solid #346F97;
+}
+
+.jcarousel-container-vertical {
+ width: 75px;
+ height: 245px;
+ padding: 40px 20px;
+}
+
+.jcarousel-clip-vertical {
+ width: 75px;
+ height: 245px;
+}
+
+.jcarousel-item {
+ width: 75px;
+ height: 75px;
+}
+
+.jcarousel-item-vertical {
+ margin-bottom: 10px;
+}
+
+.jcarousel-item-placeholder {
+ background: #fff;
+ color: #000;
+}
View
61 3.0/modules/carousel/helpers/carousel_block.php
@@ -0,0 +1,61 @@
+<?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 carousel_block_Core {
+ static function get_site_list() {
+ return array(
+ "carousel_recent" => t("Recent items carousel"),
+ "carousel_popular" => t("Popular items carousel"),
+ "carousel_random" => t("Random items carousel"));
+ }
+
+ static function get($block_id, $theme) {
+ $block = "";
+ switch ($block_id) {
+ case "carousel_recent":
+ if (module::get_var("carousel", "onalbum2") && $theme->page_type == "collection" ||
+ module::get_var("carousel", "onphoto2") && $theme->page_type == "item") {
+ $block = new Block();
+ $block->css_id = "g-carousel-rec";
+ $block->title = module::get_var("carousel", "title2", "Recent items");
+ $block->content = new View("carousel_recent.html");
+ }
+ break;
+ case "carousel_popular":
+ if (module::get_var("carousel", "onalbum3") && $theme->page_type == "collection" ||
+ module::get_var("carousel", "onphoto3") && $theme->page_type == "item") {
+ $block = new Block();
+ $block->css_id = "g-carousel-pop";
+ $block->title = module::get_var("carousel", "title3", "Popular items");
+ $block->content = new View("carousel_popular.html");
+ }
+ break;
+ case "carousel_random":
+ if (module::get_var("carousel", "onalbum") && $theme->page_type == "collection" ||
+ module::get_var("carousel", "onphoto") && $theme->page_type == "item") {
+ $block = new Block();
+ $block->css_id = "g-carousel-ran";
+ $block->title = module::get_var("carousel", "title", "Random items");
+ $block->content = new View("carousel_random.html");
+ }
+ break;
+ }
+ return $block;
+ }
+}
View
28 3.0/modules/carousel/helpers/carousel_event.php
@@ -0,0 +1,28 @@
+<?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 carousel_event_Core {
+ static function admin_menu($menu, $theme) {
+ $menu->get("settings_menu")
+ ->append(Menu::factory("link")
+ ->id("carousel_menu")
+ ->label(t("Carousel"))
+ ->url(url::site("admin/carousel")));
+ }
+}
View
24 3.0/modules/carousel/helpers/carousel_theme.php
@@ -0,0 +1,24 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2010 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 carousel_theme_Core {
+ static function head($theme) {
+ return $theme->script("jcarousellite.min.js");
+ }
+}
View
1  3.0/modules/carousel/js/jcarousellite.min.js
@@ -0,0 +1 @@
+(function($){$.fn.jCarouselLite=function(o){o=$.extend({btnPrev:null,btnNext:null,btnGo:null,mouseWheel:false,auto:null,speed:200,easing:null,vertical:false,circular:true,visible:3,start:0,scroll:1,beforeStart:null,afterEnd:null},o||{});return this.each(function(){var b=false,animCss=o.vertical?"top":"left",sizeCss=o.vertical?"height":"width";var c=$(this),ul=$("ul",c),tLi=$("li",ul),tl=tLi.size(),v=o.visible;if(o.circular){ul.prepend(tLi.slice(tl-v-1+1).clone()).append(tLi.slice(0,v).clone());o.start+=v}var f=$("li",ul),itemLength=f.size(),curr=o.start;c.css("visibility","visible");f.css({overflow:"hidden",float:o.vertical?"none":"left"});ul.css({margin:"0",padding:"0",position:"relative","list-style-type":"none","z-index":"1"});c.css({overflow:"hidden",position:"relative","z-index":"2",left:"0px"});var g=o.vertical?height(f):width(f);var h=g*itemLength;var j=g*v;f.css({width:f.width(),height:f.height()});ul.css(sizeCss,h+"px").css(animCss,-(curr*g));c.css(sizeCss,j+"px");if(o.btnPrev)$(o.btnPrev).click(function(){return go(curr-o.scroll)});if(o.btnNext)$(o.btnNext).click(function(){return go(curr+o.scroll)});if(o.btnGo)$.each(o.btnGo,function(i,a){$(a).click(function(){return go(o.circular?o.visible+i:i)})});if(o.mouseWheel&&c.mousewheel)c.mousewheel(function(e,d){return d>0?go(curr-o.scroll):go(curr+o.scroll)});if(o.auto)setInterval(function(){go(curr+o.scroll)},o.auto+o.speed);function vis(){return f.slice(curr).slice(0,v)};function go(a){if(!b){if(o.beforeStart)o.beforeStart.call(this,vis());if(o.circular){if(a<=o.start-v-1){ul.css(animCss,-((itemLength-(v*2))*g)+"px");curr=a==o.start-v-1?itemLength-(v*2)-1:itemLength-(v*2)-o.scroll}else if(a>=itemLength-v+1){ul.css(animCss,-((v)*g)+"px");curr=a==itemLength-v+1?v+1:v+o.scroll}else curr=a}else{if(a<0||a>itemLength-v)return;else curr=a}b=true;ul.animate(animCss=="left"?{left:-(curr*g)}:{top:-(curr*g)},o.speed,o.easing,function(){if(o.afterEnd)o.afterEnd.call(this,vis());b=false});if(!o.circular){$(o.btnPrev+","+o.btnNext).removeClass("disabled");$((curr-o.scroll<0&&o.btnPrev)||(curr+o.scroll>itemLength-v&&o.btnNext)||[]).addClass("disabled")}}return false}})};function css(a,b){return parseInt($.css(a[0],b))||0};function width(a){return a[0].offsetWidth+css(a,'marginLeft')+css(a,'marginRight')};function height(a){return a[0].offsetHeight+css(a,'marginTop')+css(a,'marginBottom')}})(jQuery);
View
364 3.0/modules/carousel/js/jcarousellite_orig.js
@@ -0,0 +1,364 @@
+/**
+ * jCarouselLite - jQuery plugin to navigate images/any content in a carousel style widget.
+ * @requires jQuery v1.2 or above
+ *
+ * http://gmarwaha.com/jquery/jcarousellite/
+ *
+ * Copyright (c) 2007 Ganeshji Marwaha (gmarwaha.com)
+ * Dual licensed under the MIT and GPL licenses:
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * Version: 1.0.1
+ * Note: Requires jquery 1.2 or above from version 1.0.1
+ */
+
+/**
+ * Creates a carousel-style navigation widget for images/any-content from a simple HTML markup.
+ *
+ * The HTML markup that is used to build the carousel can be as simple as...
+ *
+ * <div class="carousel">
+ * <ul>
+ * <li><img src="image/1.jpg" alt="1"></li>
+ * <li><img src="image/2.jpg" alt="2"></li>
+ * <li><img src="image/3.jpg" alt="3"></li>
+ * </ul>
+ * </div>
+ *
+ * As you can see, this snippet is nothing but a simple div containing an unordered list of images.
+ * You don't need any special "class" attribute, or a special "css" file for this plugin.
+ * I am using a class attribute just for the sake of explanation here.
+ *
+ * To navigate the elements of the carousel, you need some kind of navigation buttons.
+ * For example, you will need a "previous" button to go backward, and a "next" button to go forward.
+ * This need not be part of the carousel "div" itself. It can be any element in your page.
+ * Lets assume that the following elements in your document can be used as next, and prev buttons...
+ *
+ * <button class="prev">&lt;&lt;</button>
+ * <button class="next">&gt;&gt;</button>
+ *
+ * Now, all you need to do is call the carousel component on the div element that represents it, and pass in the
+ * navigation buttons as options.
+ *
+ * $(".carousel").jCarouselLite({
+ * btnNext: ".next",
+ * btnPrev: ".prev"
+ * });
+ *
+ * That's it, you would have now converted your raw div, into a magnificient carousel.
+ *
+ * There are quite a few other options that you can use to customize it though.
+ * Each will be explained with an example below.
+ *
+ * @param an options object - You can specify all the options shown below as an options object param.
+ *
+ * @option btnPrev, btnNext : string - no defaults
+ * @example
+ * $(".carousel").jCarouselLite({
+ * btnNext: ".next",
+ * btnPrev: ".prev"
+ * });
+ * @desc Creates a basic carousel. Clicking "btnPrev" navigates backwards and "btnNext" navigates forward.
+ *
+ * @option btnGo - array - no defaults
+ * @example
+ * $(".carousel").jCarouselLite({
+ * btnNext: ".next",
+ * btnPrev: ".prev",
+ * btnGo: [".0", ".1", ".2"]
+ * });
+ * @desc If you don't want next and previous buttons for navigation, instead you prefer custom navigation based on
+ * the item number within the carousel, you can use this option. Just supply an array of selectors for each element
+ * in the carousel. The index of the array represents the index of the element. What i mean is, if the
+ * first element in the array is ".0", it means that when the element represented by ".0" is clicked, the carousel
+ * will slide to the first element and so on and so forth. This feature is very powerful. For example, i made a tabbed
+ * interface out of it by making my navigation elements styled like tabs in css. As the carousel is capable of holding
+ * any content, not just images, you can have a very simple tabbed navigation in minutes without using any other plugin.
+ * The best part is that, the tab will "slide" based on the provided effect. :-)
+ *
+ * @option mouseWheel : boolean - default is false
+ * @example
+ * $(".carousel").jCarouselLite({
+ * mouseWheel: true
+ * });
+ * @desc The carousel can also be navigated using the mouse wheel interface of a scroll mouse instead of using buttons.
+ * To get this feature working, you have to do 2 things. First, you have to include the mouse-wheel plugin from brandon.
+ * Second, you will have to set the option "mouseWheel" to true. That's it, now you will be able to navigate your carousel
+ * using the mouse wheel. Using buttons and mouseWheel or not mutually exclusive. You can still have buttons for navigation
+ * as well. They complement each other. To use both together, just supply the options required for both as shown below.
+ * @example
+ * $(".carousel").jCarouselLite({
+ * btnNext: ".next",
+ * btnPrev: ".prev",
+ * mouseWheel: true
+ * });
+ *
+ * @option auto : number - default is null, meaning autoscroll is disabled by default
+ * @example
+ * $(".carousel").jCarouselLite({
+ * auto: 800,
+ * speed: 500
+ * });
+ * @desc You can make your carousel auto-navigate itself by specfying a millisecond value in this option.
+ * The value you specify is the amount of time between 2 slides. The default is null, and that disables auto scrolling.
+ * Specify this value and magically your carousel will start auto scrolling.
+ *
+ * @option speed : number - 200 is default
+ * @example
+ * $(".carousel").jCarouselLite({
+ * btnNext: ".next",
+ * btnPrev: ".prev",
+ * speed: 800
+ * });
+ * @desc Specifying a speed will slow-down or speed-up the sliding speed of your carousel. Try it out with
+ * different speeds like 800, 600, 1500 etc. Providing 0, will remove the slide effect.
+ *
+ * @option easing : string - no easing effects by default.
+ * @example
+ * $(".carousel").jCarouselLite({
+ * btnNext: ".next",
+ * btnPrev: ".prev",
+ * easing: "bounceout"
+ * });
+ * @desc You can specify any easing effect. Note: You need easing plugin for that. Once specified,
+ * the carousel will slide based on the provided easing effect.
+ *
+ * @option vertical : boolean - default is false
+ * @example
+ * $(".carousel").jCarouselLite({
+ * btnNext: ".next",
+ * btnPrev: ".prev",
+ * vertical: true
+ * });
+ * @desc Determines the direction of the carousel. true, means the carousel will display vertically. The next and
+ * prev buttons will slide the items vertically as well. The default is false, which means that the carousel will
+ * display horizontally. The next and prev items will slide the items from left-right in this case.
+ *
+ * @option circular : boolean - default is true
+ * @example
+ * $(".carousel").jCarouselLite({
+ * btnNext: ".next",
+ * btnPrev: ".prev",
+ * circular: false
+ * });
+ * @desc Setting it to true enables circular navigation. This means, if you click "next" after you reach the last
+ * element, you will automatically slide to the first element and vice versa. If you set circular to false, then
+ * if you click on the "next" button after you reach the last element, you will stay in the last element itself
+ * and similarly for "previous" button and first element.
+ *
+ * @option visible : number - default is 3
+ * @example
+ * $(".carousel").jCarouselLite({
+ * btnNext: ".next",
+ * btnPrev: ".prev",
+ * visible: 4
+ * });
+ * @desc This specifies the number of items visible at all times within the carousel. The default is 3.
+ * You are even free to experiment with real numbers. Eg: "3.5" will have 3 items fully visible and the
+ * last item half visible. This gives you the effect of showing the user that there are more images to the right.
+ *
+ * @option start : number - default is 0
+ * @example
+ * $(".carousel").jCarouselLite({
+ * btnNext: ".next",
+ * btnPrev: ".prev",
+ * start: 2
+ * });
+ * @desc You can specify from which item the carousel should start. Remember, the first item in the carousel
+ * has a start of 0, and so on.
+ *
+ * @option scrool : number - default is 1
+ * @example
+ * $(".carousel").jCarouselLite({
+ * btnNext: ".next",
+ * btnPrev: ".prev",
+ * scroll: 2
+ * });
+ * @desc The number of items that should scroll/slide when you click the next/prev navigation buttons. By
+ * default, only one item is scrolled, but you may set it to any number. Eg: setting it to "2" will scroll
+ * 2 items when you click the next or previous buttons.
+ *
+ * @option beforeStart, afterEnd : function - callbacks
+ * @example
+ * $(".carousel").jCarouselLite({
+ * btnNext: ".next",
+ * btnPrev: ".prev",
+ * beforeStart: function(a) {
+ * alert("Before animation starts:" + a);
+ * },
+ * afterEnd: function(a) {
+ * alert("After animation ends:" + a);
+ * }
+ * });
+ * @desc If you wanted to do some logic in your page before the slide starts and after the slide ends, you can
+ * register these 2 callbacks. The functions will be passed an argument that represents an array of elements that
+ * are visible at the time of callback.
+ *
+ *
+ * @cat Plugins/Image Gallery
+ * @author Ganeshji Marwaha/ganeshread@gmail.com
+ */
+
+(function($) { // Compliant with jquery.noConflict()
+$.fn.jCarouselLite = function(o) {
+ o = $.extend({
+ btnPrev: null,
+ btnNext: null,
+ btnGo: null,
+ mouseWheel: false,
+ auto: null,
+ hoverPause: false,
+
+ speed: 200,
+ easing: null,
+
+ vertical: false,
+ circular: true,
+ visible: 3,
+ start: 0,
+ scroll: 1,
+
+ beforeStart: null,
+ afterEnd: null
+ }, o || {});
+
+ return this.each(function() { // Returns the element collection. Chainable.
+
+ var running = false, animCss=o.vertical?"top":"left", sizeCss=o.vertical?"height":"width";
+ var div = $(this), ul = $("ul", div), tLi = $("li", ul), tl = tLi.size(), v = o.visible;
+
+ if(o.circular) {
+ ul.prepend(tLi.slice(tl-v+1).clone())
+ .append(tLi.slice(0,o.scroll).clone());
+ o.start += v-1;
+ }
+
+ var li = $("li", ul), itemLength = li.size(), curr = o.start;
+ div.css("visibility", "visible");
+
+ li.css({overflow: "hidden", float: o.vertical ? "none" : "left"});
+ ul.css({margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1"});
+ div.css({overflow: "hidden", position: "relative", "z-index": "2", left: "0px"});
+
+ var liSize = o.vertical ? height(li) : width(li); // Full li size(incl margin)-Used for animation
+ var ulSize = liSize * itemLength; // size of full ul(total length, not just for the visible items)
+ var divSize = liSize * v; // size of entire div(total length for just the visible items)
+
+ li.css({width: li.width(), height: li.height()});
+ ul.css(sizeCss, ulSize+"px").css(animCss, -(curr*liSize));
+
+ div.css(sizeCss, divSize+"px"); // Width of the DIV. length of visible images
+
+ if(o.btnPrev) {
+ $(o.btnPrev).click(function() {
+ return go(curr-o.scroll);
+ });
+ if(o.hoverPause) {
+ $(o.btnPrev).hover(function(){stopAuto();}, function(){startAuto();});
+ }
+ }
+
+
+ if(o.btnNext) {
+ $(o.btnNext).click(function() {
+ return go(curr+o.scroll);
+ });
+ if(o.hoverPause) {
+ $(o.btnNext).hover(function(){stopAuto();}, function(){startAuto();});
+ }
+ }
+
+ if(o.btnGo)
+ $.each(o.btnGo, function(i, val) {
+ $(val).click(function() {
+ return go(o.circular ? o.visible+i : i);
+ });
+ });
+
+ if(o.mouseWheel && div.mousewheel)
+ div.mousewheel(function(e, d) {
+ return d>0 ? go(curr-o.scroll) : go(curr+o.scroll);
+ });
+
+ var autoInterval;
+
+ function startAuto() {
+ stopAuto();
+ autoInterval = setInterval(function() {
+ go(curr+o.scroll);
+ }, o.auto+o.speed);
+ };
+
+ function stopAuto() {
+ clearInterval(autoInterval);
+ };
+
+ if(o.auto) {
+ if(o.hoverPause) {
+ div.hover(function(){stopAuto();}, function(){startAuto();});
+ }
+ startAuto();
+ };
+
+ function vis() {
+ return li.slice(curr).slice(0,v);
+ };
+
+ function go(to) {
+ if(!running) {
+
+ if(o.beforeStart)
+ o.beforeStart.call(this, vis());
+
+ if(o.circular) { // If circular we are in first or last, then goto the other end
+ if(to<0) { // If before range, then go around
+ ul.css(animCss, -( (curr + tl) * liSize)+"px");
+ curr = to + tl;
+ } else if(to>itemLength-v) { // If beyond range, then come around
+ ul.css(animCss, -( (curr - tl) * liSize ) + "px" );
+ curr = to - tl;
+ } else curr = to;
+ } else { // If non-circular and to points to first or last, we just return.
+ if(to<0 || to>itemLength-v) return;
+ else curr = to;
+ } // If neither overrides it, the curr will still be "to" and we can proceed.
+
+ running = true;
+
+ ul.animate(
+ animCss == "left" ? { left: -(curr*liSize) } : { top: -(curr*liSize) } , o.speed, o.easing,
+ function() {
+ if(o.afterEnd)
+ o.afterEnd.call(this, vis());
+ running = false;
+ }
+ );
+ // Disable buttons when the carousel reaches the last/first, and enable when not
+ if(!o.circular) {
+ $(o.btnPrev + "," + o.btnNext).removeClass("disabled");
+ $( (curr-o.scroll<0 && o.btnPrev)
+ ||
+ (curr+o.scroll > itemLength-v && o.btnNext)
+ ||
+ []
+ ).addClass("disabled");
+ }
+
+ }
+ return false;
+ };
+ });
+};
+
+function css(el, prop) {
+ return parseInt($.css(el[0], prop)) || 0;
+};
+function width(el) {
+ return el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');
+};
+function height(el) {
+ return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');
+};
+
+})(jQuery);
View
11 3.0/modules/carousel/js/jquery.mousewheel.min.js
@@ -0,0 +1,11 @@
+/* Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net)
+ * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
+ * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
+ * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
+ * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
+ *
+ * Version: 3.0.2
+ *
+ * Requires: 1.2.2+
+ */
+(function(c){var a=["DOMMouseScroll","mousewheel"];c.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var d=a.length;d;){this.addEventListener(a[--d],b,false)}}else{this.onmousewheel=b}},teardown:function(){if(this.removeEventListener){for(var d=a.length;d;){this.removeEventListener(a[--d],b,false)}}else{this.onmousewheel=null}}};c.fn.extend({mousewheel:function(d){return d?this.bind("mousewheel",d):this.trigger("mousewheel")},unmousewheel:function(d){return this.unbind("mousewheel",d)}});function b(f){var d=[].slice.call(arguments,1),g=0,e=true;f=c.event.fix(f||window.event);f.type="mousewheel";if(f.wheelDelta){g=f.wheelDelta/120}if(f.detail){g=-f.detail/3}d.unshift(f,g);return c.event.handle.apply(this,d)}})(jQuery);
View
7 3.0/modules/carousel/module.info
@@ -0,0 +1,7 @@
+name = "Carousel"
+description = "Add a vertical carousel for recent & popular items in the sidebar."
+version = 1.0
+author_name = "floridave"
+author_url = "http://codex.gallery2.org/User:Floridave"
+info_url = "http://codex.gallery2.org/Gallery3:Modules:carousel"
+discuss_url = "http://gallery.menalto.com/forum_module_all_carousel"
View
23 3.0/modules/carousel/views/admin_carousel.html.php
@@ -0,0 +1,23 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<script type="text/javascript">
+ function toggle() {
+ var checkbox = document.getElementById('autoscroll');
+ var toggle = document.getElementById('auto');
+ var toggle1 = document.getElementById('speed');
+ updateToggle = checkbox.checked ? toggle.disabled=false : toggle.disabled=true;
+ updateToggle1 = checkbox.checked ? toggle1.disabled=false : toggle1.disabled=true;
+ }
+window.onload=toggle;
+</script>
+<div id="g-admin-carousel">
+ <h2><?= t("Carousel Administration") ?></h2>
+ <p><?= t("Change settings below for the different parameters.") ?></p>
+ <?= $form ?>
+
+ <div class="g-block">
+ <hr />
+ <h3><?= t("Notes:") ?></h3>
+ <p><?= t("Navigation buttons are hard to style and clutter the user interface.<br />
+ Use mouse wheel to scroll thought the images.") ?></p>
+ </div>
+</div>
View
47 3.0/modules/carousel/views/carousel_popular.html.php
@@ -0,0 +1,47 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<?php
+ $circular = module::get_var("carousel", "circular", "false");
+ $autoscroll = module::get_var("carousel", "autoscroll", "false");
+ $auto = module::get_var("carousel", "autostart", "800");
+ $speed = module::get_var("carousel", "speed", "1000");
+ $quantity = module::get_var("carousel", "quantity3", "1");
+ $visible = module::get_var("carousel", "visible3", "1");
+ $thumbsize = module::get_var("carousel", "thumbsize3");
+ $photos = ORM::factory("item")->viewable()
+ ->where("type", "!=", "album")
+ ->order_by("view_count", "DESC")
+ ->find_all($quantity);
+?>
+<? if (module::get_var("carousel", "mousewheel") == true) : ?>
+<script type="text/javascript" src="<?= url::file("modules/carousel/js/jquery.mousewheel.min.js") ?>"></script>
+<? endif ?>
+<script type="text/javascript">
+$(function() {
+ $(".carouselpop").jCarouselLite({
+ circular: <?= $circular ?>,
+ mouseWheel: true,
+ visible: <?= $visible ?>,
+ vertical: true,
+<? if (module::get_var("carousel", "autoscroll") == true) : ?>
+ hoverPause: true,
+ auto: <?= $auto ?>,
+ speed: <?= $speed ?>
+<? endif ?>
+ });
+});
+</script>
+<div class="carouselpop" id="pop">
+ <ul>
+<? foreach ($photos as $photo):
+ if (module::get_var("carousel", "mousewheel") == true) {
+ $ctitle = "Use mouse wheel to scroll!";
+ } else {
+ $ctitle = $photo->title;
+ }
+ ?>
+ <li><a href="<?= $photo->abs_url() ?>">
+ <?= $photo->thumb_img(array("class" => "g-thumbnail", "title" => $ctitle), $thumbsize) ?></a>
+ </li>
+<? endforeach ?>
+ </ul>
+</div>
View
49 3.0/modules/carousel/views/carousel_random.html.php
@@ -0,0 +1,49 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<?php
+ $circular = module::get_var("carousel", "circular", "false");
+ $autoscroll = module::get_var("carousel", "autoscroll", "false");
+ $auto = module::get_var("carousel", "autostart", "800");
+ $speed = module::get_var("carousel", "speed", "1000");
+ $quantity = module::get_var("carousel", "quantity", "1");
+ $visible = module::get_var("carousel", "visible", "1");
+ $thumbsize = module::get_var("carousel", "thumbsize");
+ $photos = ORM::factory("item")->viewable()
+ ->where("rand_key", "<", ((float)mt_rand()) / (float)mt_getrandmax())
+ ->merge_where(NULL)
+ ->order_by("rand_key", "DESC")
+ ->find_all($quantity);
+?>
+<? if (module::get_var("carousel", "mousewheel") == true) : ?>
+<script type="text/javascript" src="<?= url::file("modules/carousel/js/jquery.mousewheel.min.js") ?>"></script>
+<? endif ?>
+<script type="text/javascript">
+$(function() {
+ $(".carouselran").jCarouselLite({
+ circular: <?= $circular ?>,
+ mouseWheel: true,
+ visible: <?= $visible ?>,
+ vertical: true,
+<? if (module::get_var("carousel", "autoscroll") == true) : ?>
+ hoverPause: true,
+ auto: <?= $auto ?>,
+ speed: <?= $speed ?>
+<? endif ?>
+ });
+});
+</script>
+<div class="carouselran" id="rand">
+ <ul>
+<? foreach ($photos as $photo):
+ if (module::get_var("carousel", "mousewheel") == true) {
+ $ctitle = "Use mouse wheel to scroll!";
+ } else {
+ $ctitle = $photo->title;
+ }
+ ?>
+ <li><a href="<?= $photo->abs_url() ?>">
+ <?= $photo->thumb_img(array("class" => "g-thumbnail", "title" => $ctitle), $thumbsize) ?>
+ </a>
+ </li>
+ <? endforeach ?>
+ </ul>
+</div>
View
48 3.0/modules/carousel/views/carousel_recent.html.php
@@ -0,0 +1,48 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<?php
+ $circular = module::get_var("carousel", "circular", "false");
+ $autoscroll = module::get_var("carousel", "autoscroll", "false");
+ $auto = module::get_var("carousel", "autostart", "800");
+ $speed = module::get_var("carousel", "speed", "1000");
+ $quantity = module::get_var("carousel", "quantity2", "1");
+ $visible = module::get_var("carousel", "visible2", "1");
+ $thumbsize = module::get_var("carousel", "thumbsize2");
+ $photos = ORM::factory("item")->viewable()
+ ->where("type", "!=", "album")
+ ->order_by("created", "DESC")
+ ->find_all($quantity);
+?>
+<? if (module::get_var("carousel", "mousewheel") == true) : ?>
+<script type="text/javascript" src="<?= url::file("modules/carousel/js/jquery.mousewheel.min.js") ?>"></script>
+<? endif ?>
+<script type="text/javascript">
+$(function() {
+ $(".carouselr").jCarouselLite({
+ circular: <?= $circular ?>,
+ mouseWheel: true,
+ visible: <?= $visible ?>,
+ vertical: true,
+<? if (module::get_var("carousel", "autoscroll") == true) : ?>
+ hoverPause: true,
+ auto: <?= $auto ?>,
+ speed: <?= $speed ?>
+<? endif ?>
+ });
+});
+</script>
+<div class="carouselr" id="dyna">
+ <ul>
+ <? foreach ($photos as $photo):
+ if (module::get_var("carousel", "mousewheel") == true) {
+ $ctitle = t("Use mouse wheel to scroll!");
+ } else {
+ $ctitle = $photo->title;
+ }
+ ?>
+ <li><a href="<?= $photo->abs_url() ?>">
+ <?= $photo->thumb_img(array("class" => "g-thumbnail", "title" => $ctitle), $thumbsize) ?>
+ </a>
+ </li>
+ <? endforeach ?>
+ </ul>
+</div>
Please sign in to comment.
Something went wrong with that request. Please try again.