diff --git a/app/controllers/public/content_viewer_controller.rb b/app/controllers/public/content_viewer_controller.rb index 608e682..5bf74ed 100644 --- a/app/controllers/public/content_viewer_controller.rb +++ b/app/controllers/public/content_viewer_controller.rb @@ -87,6 +87,9 @@ class ContentViewerController < ApplicationController end @comments = @page.comments(true) + if params[:slideshow] + render :action => 'slideshow', :layout => 'slideshow' + end end protected diff --git a/app/views/content_viewer/image_gallery.rhtml b/app/views/content_viewer/image_gallery.rhtml index ec431ba..d14ad53 100644 --- a/app/views/content_viewer/image_gallery.rhtml +++ b/app/views/content_viewer/image_gallery.rhtml @@ -1,26 +1,5 @@ diff --git a/app/views/content_viewer/slideshow.rhtml b/app/views/content_viewer/slideshow.rhtml new file mode 100644 index 0000000..e1a5c2b --- /dev/null +++ b/app/views/content_viewer/slideshow.rhtml @@ -0,0 +1,8 @@ +

<%= button('', _('Back to gallery'), @page.url)%>

+ diff --git a/app/views/layouts/slideshow.rhtml b/app/views/layouts/slideshow.rhtml new file mode 100644 index 0000000..9751275 --- /dev/null +++ b/app/views/layouts/slideshow.rhtml @@ -0,0 +1,32 @@ + + + + <%= + (@page ? @page.name + ' - ' : '') + + (@profile ? @profile.name + ' - ' : '') + + @environment.name + + (@category ? "→ #{@category.full_name}" : '') + %> + + <%= stylesheet_import "slideshow" %> + <%= javascript_include_tag 'jquery-latest', 'sliderjs', 'pikachoose' %> + + + + <%= yield %> + + diff --git a/public/designs/icons/default/slideshow.gif b/public/designs/icons/default/slideshow.gif new file mode 100644 index 0000000..cf2d4e2 Binary files /dev/null and b/public/designs/icons/default/slideshow.gif differ diff --git a/public/designs/icons/default/style.css b/public/designs/icons/default/style.css index 530f2e7..65f0d41 100644 --- a/public/designs/icons/default/style.css +++ b/public/designs/icons/default/style.css @@ -55,3 +55,4 @@ .icon-menu-people { background-image: url(album-HC.gif) } .icon-menu-mail { background-image: url(mail-HC.gif) } .icon-upload-file { background-image: url(go-up-HC.gif) } +.icon-slideshow { background-image: url(slideshow.gif) } diff --git a/public/javascripts/jquery.aslideshow.js b/public/javascripts/jquery.aslideshow.js deleted file mode 100644 index 8e64f6b..0000000 --- a/public/javascripts/jquery.aslideshow.js +++ /dev/null @@ -1,645 +0,0 @@ -/** - * jQuery (a)Slideshow plugin - * - * Copyright (c) 2008 Trent Foley - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. - * - * @author Anton Shevchuk AntonShevchuk@gmail.com - * @version 0.5.5 - */ -;(function($) { - defaults = { - width:320, // width in px - height:240, // height in px - index:0, // start from frame number N - time:3000, // time out beetwen slides - title:true, // show title - titleshow:false,// always show title - panel:true, // show controls panel - play:false, // play slideshow - loop:true, - effect:'fade', // aviable fade, scrollUp/Down/Left/Right, zoom, zoomFade, growX, growY - effecttime:1000,// aviable fast,slow,normal and any valid fx speed value - filter:true, // remove
, empty
,

and other stuff - nextclick:false, // bind content click next slide - playclick:false, // bind content click play/stop - playhover:false, // bind content hover play/stop - playhoverr:false, // bind content hover stop/play (reverse of playhover) - playframe:true, // show frame "Play Now!" - fullscreen:false, // in full window size - imgresize:false, // resize image to slideshow window - imgcenter:true, // set image to center // TODO - imgajax:true, // load images from links - linkajax:false, // load html from links - help:'Plugin homepage: (a)Slideshow
'+ - 'Author homepage: Anton Shevchuk', - - controls :{ // show/hide controls elements - 'hide':true, // show controls bar on mouse hover - 'first':true, // goto first frame - 'prev':true, // goto previouse frame (if it first go to last) - 'play':true, // play slideshow - 'next':true, // goto next frame (if it last go to first) - 'last':true, // goto last frame - 'help':true, // show help message - 'counter':true // show slide counter - } - }; - /** - * Create a new instance of slideshow. - * - * @classDescription This class creates a new slideshow and manipulate it - * - * @return {Object} Returns a new slideshow object. - * @constructor - */ - $.fn.slideshow = function(settings) { - - var _slideshow = this; - - /* - * Construct - */ - this.each(function(){ - - var ext = $(this); - - this.playFlag = false; - this.playId = null; - this.length = 0; - this.inited = new Array(); - - /** - * Build Html - * @method - */ - this.build = function () { - var _self = this; - - ext.wrapInner('

'); - ext = ext.find('.slideshow'); - - // filter content - if (this.options.filter) { - ext.find('.slideshow-content > br').remove(); - ext.find('.slideshow-content > p:empty').remove(); - ext.find('.slideshow-content > div:empty').remove(); - } - - - // fullscreen - if (this.options.fullscreen) { - $('body').css({overflow:'hidden', padding:0}); - - this.options.width = $(window).width(); - this.options.height = ($(window).height()>$(document).height())?$(window).height():$(document).height(); - -// this.options.width = this.options.width; -// this.options.height = this.options.height; - - ext.addClass('slideshow-fullscreen'); - } - - this.length = ext.find('.slideshow-content > *').length; - - // build title - if (this.options.title) { - ext.prepend('
'); - - if (!this.options.titleshow) { - ext.find('.slideshow-label-place').hover(function(){ - $(this).find('.slideshow-label').fadeIn(); - }, function() { - $(this).find('.slideshow-label').fadeOut(); - }); - ext.find('.slideshow-label').hide(); - } - - - ext.find('.slideshow-label-place').css('width', this.options.width); - } - - // build panel - if (this.options.panel) { - ext.append('
'); - panel = ext.find('.slideshow-panel'); - if (this.options.controls.first) - panel.append('First'); - - if (this.options.controls.prev) - panel.append(''); - - if (this.options.controls.play) - panel.append('Play'); - - if (this.options.controls.next) - panel.append(''); - - if (this.options.controls.last) - panel.append('Last'); - - if (this.options.controls.help) { - panel.append('Help'); - panel.prepend('
'+this.options.help+'
'); - -// panel.find('.slideshow-help').css('width', this.options.width - 4 + 'px'); - } - - - if (this.options.controls.counter) { - panel.append(''+(this.options.index+1)+' / '+this.length+''); - } - - if (this.options.controls.hide) { - ext.find('.slideshow-panel-place').hover(function(){ - $(this).find('.slideshow-panel').fadeIn(); - }, function() { - $(this).find('.slideshow-panel').fadeOut(); - }); - panel.hide(); - } - - - ext.find('.slideshow-panel-place').css('width', this.options.width); - } - - /** - * Set Size Options - */ - ext.css('width', this.options.width + 'px'); -// ext.css('height', this.options.height + 'px'); - - ext.find('.slideshow-content').css('width', this.options.width); - ext.find('.slideshow-content').css('height', this.options.height); - - /** - * Change children styles - */ - ext.find('.slideshow-content > *').each(function(){ - _self._build($(this)); - }); - - // init slide (replace by ajax etc) - this.init(this.options.index); - - // hide all slides - ext.find('.slideshow-content > *:not(:eq('+this.options.index+'))').hide(); - - // show label - this.label(); - - // add playframe - if (this.options.playframe) { - ext.find('.slideshow-content').append('
'); - } - - // bind all events - this.events(); - - return true; - }; - - /** - * Change CSS for every entity - */ - this._build = function(el){ - el.css({margin :0, - position: 'absolute', - left: (this.options.width/2 - el.attr('width')/2), - top : (this.options.height/2 - el.attr('height')/2), - overflow:'hidden' - }); - - if (el.is('img') && this.options.imgresize || el.is(':not(img)')){ - el.css({width:'100%',height:'100%'}); - } - }; - - /** - * Bind Events - */ - this.events = function() { - - var _self = this; - - /** - * Go to next slide on content click (optional) - */ - if (_self.options.nextclick) - ext.find('.slideshow-content').click(function(){ - _self.stop(); - _self.next(); - return false; - }); - - /** - * Goto first slide button - */ - if (this.options.controls.first) - ext.find('a.first').click(function(){ - _self.stop(); - _self.goSlide(0); - return false; - }); - - /** - * Goto previouse slide button - */ - if (this.options.controls.prev) - ext.find('a.prev').click(function(){ - _self.stop(); - _self.prev(); - return false; - }); - - /** - * Play slideshow button - */ - if (this.options.controls.play) - ext.find('a.play').click(function(){ - if (_self.playFlag) { - _self.stop(); - } else { - _self.play(); - } - return false; - }); - - /** - * Goto next slide button - */ - if (this.options.controls.next) - ext.find('a.next').click(function(){ - _self.stop(); - _self.next(); - return false; - }); - - /** - * Goto last slide button - */ - if (this.options.controls.last) - ext.find('a.last').click(function(){ - _self.stop(); - _self.goSlide(_self.length-1); - return false; - }); - - /** - * Show help message - */ - if (this.options.controls.help) - ext.find('a.help').click(function(){ - _self.stop(); - ext.find('.slideshow-help').slideToggle(); - return false; - }); - - /** - * Show playframe - */ - if (this.options.playframe) - ext.find('.slideshow-frame').click(function(){ - ext.find('.slideshow-frame').remove(); - ext.find('.slideshow-shadow').remove(); - - if (_self.options.playclick) - setTimeout(function(ms){ _self.play() }, _self.options.time); - return false; - }); - - /** - * Play/stop on slideshow hover - */ - if (this.options.playhover) - ext.hover(function(){ - if (!_self.playFlag) { - _self.play(); - } - }, function(){ - if (_self.playFlag) { - _self.stop(); - } - }); - - - /** - * Stop/Play on slideshow hover - */ - if (this.options.playhoverr) - ext.hover(function(){ - if (_self.playFlag) { - _self.stop(); - } - }, function(){ - if (!_self.playFlag) { - _self.play(); - } - }); - }; - - /** - * Find and show label of slide - * @method - */ - this.label = function () { - if (!this.options.title) return false; - - label = ''; - - current = ext.find('.slideshow-content > *:eq('+this.options.index +')'); - - if (current.attr('alt')) { - label = current.attr('alt'); - } else if (current.attr('title')) { - label = current.attr('title'); - }else if (current.find('label:first').length>0) { - current.find('label:first').hide(); - label = current.find('label:first').html(); - } - - ext.find('.slideshow-label').html(label); - }; - - /** - * Goto previous slide - * @method - */ - this.prev = function () { - if (this.options.index == 0) { - i = (this.length-1); - } else { - i = this.options.index - 1; - } - - this.goSlide(i); - }; - - - /** - * Play Slideshow - * @method - */ - this.play = function () { - var _self = this; - this.playFlag = true; - this.playId = setTimeout(function(ms){ _self._play() }, this.options.time); - ext.find('a.play').addClass('stop'); - }; - - /** - * Play Slideshow - * @method - */ - this._play = function () { - var _self = this; - this.next(); - if (this.playFlag) { - if (this.options.index == (this.length-1) && !this.options.loop) { this.stop();return false; } - this.playId = setTimeout(function(ms){ _self._play() }, this.options.time); - } - }; - - /** - * Stop Slideshow - * @method - */ - this.stop = function () { - ext.find('a.play').removeClass('stop'); - this.playFlag = false; - clearTimeout(this.playId); - }; - - /** - * Goto next slide - * @method - */ - this.next = function () { - if (this.options.index == (this.length-1)) { - i = 0; - } else { - i = this.options.index + 1; - } - this.goSlide(i); - }; - - /** - * Init N-slide - * @method - * @param {Integer} n - */ - this.init = function (index) { - // initialize only ones - for (var i = 0, loopCnt = this.inited.length; i < loopCnt; i++) { - if (this.inited[i] === index) { - return true; - } - } - - // index to inited stack - this.inited.push(index); - - // current slide - slide = ext.find('.slideshow-content > *:eq('+index+')'); - - var _self = this; - /** - * Replace A to content from HREF - */ - if (slide.get(0).tagName == 'A') { - var href = slide.attr('href'); - - var title = slide.attr('title'); - title = title.replace(/\"/i,'\''); // if you use single quotes for tag attribs - - var domain = document.domain; - domain = domain.replace(/\./i,"\."); // for strong check domain name - - var reimage = new RegExp("\.(png|gif|jpg|jpeg|svg)$", "i"); - var relocal = new RegExp("^((https?:\/\/"+domain+")|(?!http:\/\/))", "i"); - - - if (this.options.imgajax && reimage.test(href)) { - slide.replaceWith(''+title+''); - } else if (this.options.linkajax && relocal.test(href)) { - $.get(href, function(data){ - slide.replaceWith('
'+data+'
'); - }); - } else { // nothing else -// slide.wrap('

'); - } - - slide = ext.find('.slideshow-content > *:eq('+index+')'); - - // reset css - this._build(slide); - } - - /** - * Play/stop on content click (like image and other) - */ - if (this.options.playclick) - $(slide).click(function(){ - if (_self.playFlag) { - _self.stop(); - } else { - _self.play(); - } - return false; - }); - }; - - /** - * Goto N-slide - * @method - * @param {Integer} n - */ - this.goSlide = function (n) { - - if (this.options.index == n) return; - - this.init(n); - - var next = ext.find('.slideshow-content > *:eq('+n+')'); - var prev = ext.find('.slideshow-content > *:eq('+this.options.index+')'); - - // restore next slide after all effects, set z-index = 0 for prev slide - prev.css({zIndex:0}); - if (this.options.imgresize) { - next.css({zIndex:1, top: 0, left: 0, opacity: 1, width: this.options.width, height: this.options.height}); - } else { - next.css({zIndex:1, top: (this.options.height/2 - next.attr('height')/2), left: (this.options.width/2 - next.attr('width')/2), opacity: 1}); - } - - this.options.index = n; - - if (this.options.effect == 'random' ) { - var r = Math.random(); - r = Math.floor(r*12); - } else { - r = -1; - } - // effect between slides - switch (true) { - case (this.options.effect == 'scrollUp' || r == 0): - prev.css({width:'100%'}); - next.css({top:0, height:0}); - - prevAni = {height: 0, top:this.options.height}; - break; - case (this.options.effect == 'scrollDown' || r == 1): - prev.css({width:'100%'}); - next.css({top:this.options.height,height:0}); - - prevAni = {height: 0, top:0}; - break; - case (this.options.effect == 'scrollRight' || r == 2): - prev.css({right:0,left:'',height:'100%'}); - next.css({right:'',left:0,height:'100%',width:'0%'}); - - prevAni = {width: 0}; - break; - case (this.options.effect == 'scrollLeft' || r == 3): - prev.css({right:'',left:0,height:'100%'}); - next.css({right:0,left:'',height:'100%',width:'0%'}); - - prevAni = {width: 0}; - break; - case (this.options.effect == 'growX' || r == 4): - next.css({zIndex:2,opacity: 1,left: this.options.width/2, width: '0%', height:'100%'}); - - prevAni = {opacity: 0.8}; - break; - - case (this.options.effect == 'growY' || r == 5): - next.css({opacity: 1,top: this.options.height/2, width:'100%', height: '0%'}); - - prevAni = {opacity: 0.8}; - break; - - case (this.options.effect == 'zoom' || r == 6): - next.css({width: 0, height: 0, top: this.options.height/2, left: this.options.width/2}); - - prevAni = {width: 0, height: 0, top: this.options.height/2, left: this.options.width/2}; - break; - - case (this.options.effect == 'zoomFade' || r == 7): - next.css({zIndex:1, opacity: 0,width: 0, height: 0, top: this.options.height/2, left: this.options.width/2}); - - prevAni = {opacity: 0, width: 0, height: 0, top: this.options.height/2, left: this.options.width/2}; - break; - - case (this.options.effect == 'zoomTL' || r == 8): - next.css({zIndex:1, opacity: 0,width: this.options.width/2, height: this.options.height/2, top:0, left: 0}); - - prevAni = {opacity: 0, width: 0, height: 0, top: this.options.height, left: this.options.width}; - break; - case (this.options.effect == 'zoomBR' || r == 9): - next.css({zIndex:1, opacity: 0,width: this.options.width/2, height: this.options.height/2, top: this.options.height/2, left: this.options.width/2}); - - prevAni = {opacity: 0, width: 0, height: 0, top: 0, left: 0}; - break; - case (this.options.effect == 'fade' || r == 10): - default: - prev.css({zIndex:0, opacity: 1}); - next.css({zIndex:1, opacity: 0}); - - prevAni = {opacity: 0}; - break; - } - - var _self = this; - - prev.animate(prevAni,this.options.effecttime); - - // play next slide animation, hide prev slide, update label, update counter - next.show().animate({opacity: 1}, this.options.effecttime, function () { prev.hide(); _self.label(); _self.counter(); }); - }; - - /** - * Update counter data - * @method - */ - this.counter = function () { - if (this.options.controls.counter) - ext.find('.slideshow-panel span.counter').html((this.options.index+1) + ' / ' + this.length); - - }; - - // Now initialize the slideshow - this.options = $.extend({}, defaults, settings); - - if (typeof(settings) != 'undefined') { - if (typeof(settings.controls) != 'undefined') - this.options.controls = $.extend({}, defaults.controls, settings.controls); - } - - this.build(); - - /** - * Show slideshow - */ - ext.show(); - - /** - * Check play option - */ - if (this.options.play) { - this.play(); - } - - return ext; - }); - - /** - * external functions - append to $ - */ - _slideshow.playSlide = function(){ _slideshow.each(function () { this.play(); }) }; - _slideshow.stopSlide = function(){ _slideshow.each(function () { this.stop(); }) }; - _slideshow.nextSlide = function(){ _slideshow.each(function () { this.next(); }) }; - _slideshow.prevSlide = function(){ _slideshow.each(function () { this.prev(); }) }; - - return this; - } -})(jQuery); diff --git a/public/javascripts/jquery.aslideshow/simple/images/big-play.png b/public/javascripts/jquery.aslideshow/simple/images/big-play.png deleted file mode 100644 index f729acb..0000000 Binary files a/public/javascripts/jquery.aslideshow/simple/images/big-play.png and /dev/null differ diff --git a/public/javascripts/jquery.aslideshow/simple/images/buttons.png b/public/javascripts/jquery.aslideshow/simple/images/buttons.png deleted file mode 100644 index e8ef1ca..0000000 Binary files a/public/javascripts/jquery.aslideshow/simple/images/buttons.png and /dev/null differ diff --git a/public/javascripts/jquery.aslideshow/simple/styles.css b/public/javascripts/jquery.aslideshow/simple/styles.css deleted file mode 100644 index 7137ac4..0000000 --- a/public/javascripts/jquery.aslideshow/simple/styles.css +++ /dev/null @@ -1,180 +0,0 @@ -.slideshow, .slideshow-label, .slideshow-content, .slideshow-panel { - font:12px Verdana, Tahoma, sans-serif; -} - -.slideshow { - padding:0; - border:0; - position:relative; - display:none; /* Set to "none" for not preview slideshow content */ -} - -.slideshow-fullscreen { - position:absolute; - top:0; - left:0; - padding:0; - border:0; - overflow:hidden; -} - -.slideshow-label-place { - padding:0; - position:absolute; - top:0px; - left:0px; - z-index:100; - height:30px; -} - .slideshow-label { - z-index:101; - color:#fff; - width:100%; - height:100%; - line-height:30px; - text-indent:8px; - font-weight:bold - } - -.slideshow-panel-place { - padding:0; - position:absolute; - bottom:-29px; - left:0px; - z-index:100; - height:28px; -} - - - .slideshow-panel { - z-index:101; - width:100%; - height:100%; - } - - .slideshow-panel a.slideshowbutton { - display: block; - width:26px; - height:26px; - float:left; - text-indent:-99999%; - overflow:hidden; - outline: 0; /* @ Firefox, prevent dotted border after click */ - background-image:url(images/buttons.png); - background-repeat:no-repeat; - border:1px solid transparent - } - - .slideshow-panel a.slideshowbutton:hover { - border:1px solid #777; - } - - - .slideshow-panel a.first { - background-position: 0 0 - } - - .slideshow-panel a.prev { - background-position: -24px 0 - } - - .slideshow-panel a.play { - background-position: -48px 0 - } - - .slideshow-panel a.stop { - background-position: -72px 0 - } - - .slideshow-panel a.next { - background-position: -96px 0 - } - - .slideshow-panel a.last { - background-position: -120px 0 - } - - .slideshow-panel a.help { - position:relative; - background-position: -144px 0 - } - - .slideshow-panel span.counter { - float:right; - display: block; - /*width:26px;*/ - height:26px; - line-height:26px; - padding:0 4px; - color: white; - } - - -.slideshow-help { - position:absolute; - bottom:28px; - left:0px; - z-index:101; - background-color:#ff9; - display:none; - opacity: 0.9; - width:100%; -} - -.slideshow-content { - padding:0; - background-color:#fff; - color:#333; - overflow:hidden; - position:relative; - width:100%; - height:100%; -} - - /* Some Content Changes */ - .slideshow-content p { - padding:0; - overflow:auto; - } - -.slideshow-frame { - position:absolute; - top:0px; - left:0px; - background:url(images/big-play.png) 50% 50% no-repeat; - z-index:201; - cursor:pointer; - width:100%; - height:100%; -} - -.slideshow-shadow{ - position:absolute; - top:0px; - left:0px; - z-index:200; - width:100%; - height:100%; -} - -.slideshow-opacity{ - background-color: black; -} - *:first-child+html .slideshow-opacity, * html .slideshow-opacity { - zoom:1; - background:#000; - filter:alpha(opacity=50); - } - * html .slideshow-opacity { - zoom:1; - background:#000; - filter:alpha(opacity=50); - } - - *:first-child+html .slideshow-opacity *{ - position:relative; - } - - * html .slideshow-opacity *{ - position:relative; - } diff --git a/public/javascripts/pikachoose.js b/public/javascripts/pikachoose.js new file mode 100644 index 0000000..94d9114 --- /dev/null +++ b/public/javascripts/pikachoose.js @@ -0,0 +1,275 @@ +/* 1/13/2009 + PikaChoose + Jquery plugin for photo galleries + Copyright (C) 2009 Jeremy Fry + + 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 3 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, see . +*/ + + +jQuery.iPikaChoose = { + build : function(user_options) + { + var user_options; + var defaults = { + show_captions: true, + slide_enabled: true, + auto_play: true, + show_prev_next: true, + slide_speed: 5000, + thumb_width: 50, + thumb_height: 42 + }; + + return $(this).each( + function() { + //bring in options + var options = $.extend(defaults, user_options); + // grab our images + var $images = $(this).children('li').children('img'); + //hide the images so the user doesn't see crap + $images.fadeOut(1); + + //save our list for future ref + var $ulist = $(this); + $images.each(LoadImages); + //start building structure + $(this).before("
"); + // houses eveything about the UL + var $main_div = $(this).prev(".pika_main"); + + //add in slideshow elements when appropriate + if(options.slide_enabled){ + $main_div.append("
"); + var $play_div = $(this).prev(".pika_main").children(".pika_play"); + $play_div.html("PlayStop"); + $play_div.fadeOut(1); + var $play_anchor = $play_div.children('a:first'); + var $stop_anchor = $play_div.children('a:last'); + } + //this div is used to make image and caption fade together + $main_div.append("
"); + var $sub_div = $main_div.children(".pika_subdiv"); + + //the main image we'll be using to load + $sub_div.append(""); + var $main_img = $sub_div.children("img"); + + //create the caption div when appropriate + if(options.show_captions){ + $sub_div.append("
"); + var $caption_div = $sub_div.children(".pika_caption"); + } + + //navigation div ALWAYS gets created, its refrenced a lot + $(this).after("
"); + var $navigation_div = $(this).next(".pika_navigation"); + //fill in sub elements + $navigation_div.prepend("Previous :: Next"); + var $previous_image_anchor = $navigation_div.children('a:first'); + var $next_image_anchor = $navigation_div.children('a:last'); + + //hide the navigation if the user doesn't want it + if(!options.show_prev_next){ + $navigation_div.css("display","none"); + } + + //$playing triggers the loop for the slideshow + var $playing = options.auto_play; + + $main_img.wrap(""); + var $main_link = $main_img.parent("a"); + + function LoadImages(){ + $(this).bind("load", function(){ + //had to make a seperate function so that the thumbnails wouldn't have problems + //from beings resized before loaded, thus not h/w + + var $w = $(this).width(); + var $h = $(this).height(); + if($w===0){$w = $(this).attr("width");} + if($h===0){$h = $(this).attr("height");} + //grab a ratio for image to user defined settings + var $rw = options.thumb_width/$w; + var $rh = options.thumb_height/$h; + + //determine which has the smallest ratio (thus needing + //to be the side we use to scale so our whole thumb is filled) + if($rw<$rh){ + //we'll use ratio later to scale and not distort + var $ratio = $rh; + var $left = (($w*$ratio-options.thumb_width)/2)*-1; + $left = Math.round($left); + //set images left offset to match + $(this).css({left:$left}); + }else{ + var $ratio = $rw; + //you can uncoment this lines to have the vertical picture centered + //but usually tall photos have the focal point at the top... + //var $top = (($h*$ratio-options.thumb_height)/2)*-1; + //var $top = Math.round($top); + $top = 0; + $(this).css({top:$top}); + } + //use those ratios to calculate scale + var $width = Math.round($w*$ratio); + var $height = Math.round($h*$ratio); + $(this).css("position","relative"); + $(this).width($width).height($height); + var imgcss={ + width: $width, + height: $height + }; + $(this).css(imgcss); + + $(this).fadeTo(250,0.4); + if($(this).hasClass('pika_first')){ + $(this).trigger("click",["auto"]); + } + }); + + //clone so the on loads will fire correctly + $(this).clone(true).insertAfter(this); + + $(this).remove(); + //reset images to the clones + $images = $ulist.children('li').children('img'); + } + function activate(){ + //sets the intial phase for everything + + //image_click is controls the fading + $images.bind("click",image_click); + //hiding refrence to slide elements if slide is disabled + if(options.slide_enabled){ + if(options.auto_play){ + $playing = true; + $play_anchor.hide(); + $stop_anchor.show(); + }else{ + $play_anchor.show(); + $stop_anchor.hide(); + } + } + + //resizes and centers thumbs + prep_thumbs(); + //previous link to go back an image + $previous_image_anchor.bind("click",previous_image); + //ditto for forward, also the item that gets auto clicked for slideshow + $next_image_anchor.bind("click",next_image); + }//end activate function + + + function prep_thumbs(){ + //now we know the first and last images + $images.filter(":last").addClass("pika_last"); + $images.filter(":first").addClass("pika_first"); + //parse images + $images.each(function(){ + var licss = { + width: options.thumb_width+"px", + height: options.thumb_height+"px", + "list-style": "none", + overflow: "hidden" + }; + $(this).parent('li').css(licss); + $(this).hover( + function(){$(this).fadeTo(250,1);}, + function(){if(!$(this).hasClass("pika_selected")){$(this).fadeTo(250,0.4);}} + ); + }); + + }//end fix thumbs functions + function image_click(event, how){ + //catch when user clicks on an image Then cancel current slideshow + if(how!="auto"){ + if(options.slide_enabled){ + $stop_anchor.hide(); + $play_anchor.show(); + $playing=false; + } + $sub_div.stop(); + $sub_div.dequeue(); + } + //all our image variables + var $image_source = $(this).attr("src"); + var $image_link = $(this).attr("ref"); + var $image_caption = $(this).attr("title"); + + //fade out the old thumb + $images.filter(".pika_selected").fadeTo(250,0.4); + $images.filter(".pika_selected").removeClass("pika_selected"); + //fade in the new thumb + $(this).fadeTo(250,1); + $(this).addClass("pika_selected"); + //fade the old image out and the new one in + $sub_div.fadeTo(500,0.05,function(){ + $main_img.attr("src",$image_source); + $main_link.attr("href", $image_link); + if(options.show_captions){$caption_div.html($image_caption);} + }); + $sub_div.fadeTo(800,1,function(){ + if($playing){ + $(this).animate({top:0},options.slide_speed, function(){ + //redudency needed here to catch the user clicking on an image during a change. + if($playing){$next_image_anchor.trigger("click",["auto"]);} + }); + } + }); + }//end image_click function + + function next_image(event, how){ + if($images.filter(".pika_selected").hasClass("pika_last")){ + $images.filter(":first").trigger("click",how); + }else{ + $images.filter(".pika_selected").parent('li').next('li').children('img').trigger("click",how); + } + }//end next image function + + function previous_image(event, how){ + if($images.filter(".pika_selected").hasClass("pika_first")){ + $images.filter(":last").trigger("click",how); + }else{ + $images.filter(".pika_selected").parent('li').prev('li').children('img').trigger("click",how); + } + }//end previous image function + + function play_button(){ + $main_div.hover( + function(){$play_div.fadeIn(400);}, + function(){$play_div.fadeOut(400);} + ); + $play_anchor.bind("click", function(){ + $playing = true; + $next_image_anchor.trigger("click",["auto"]); + $(this).hide(); + $stop_anchor.show(); + }); + $stop_anchor.bind("click", function(){ + $playing = false; + $(this).hide(); + $play_anchor.show(); + }); + } + if(options.slide_enabled){play_button();} + activate(); + + });//end return this.each + }//end build function + + //activate applies the appropriate actions to all the different parts of the structure. + //and loads the sets the first image +};//end jquery.ipikachoose +jQuery.fn.PikaChoose = jQuery.iPikaChoose.build; diff --git a/public/javascripts/sliderjs.js b/public/javascripts/sliderjs.js new file mode 100644 index 0000000..ecfded8 --- /dev/null +++ b/public/javascripts/sliderjs.js @@ -0,0 +1,213 @@ +/*The easing code was provided by George Smith. Please check out his site +as without him this would look really horrible! +http://gsgd.co.uk/sandbox/jquery/easing/ +*/ + +jQuery.easing.jswing = jQuery.swing; +jQuery.extend( jQuery.easing, +{ + def: 'easeOutCubic', + swing: function (x, t, b, c, d) { + return jQuery.easing[jQuery.easing.def](x, t, b, c, d); + }, + easeOutCubic: function (x, t, b, c, d) { + return c*((t=t/d-1)*t*t + 1) + b; + } +}); + +/* + 12/20/08 + SliderJS + Jquery plugin for smooth and pretty sliding divs + Copyright (C) 2008 Jeremy Fry + + 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 3 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, see . +*/ + + +jQuery.iSliderJS = { + build : function(user_options) + { + var defaults = { + direction:"horizontal", + list_width: 6740, + window_width: 500, + window_height: 350, + pikachoose: false + }; + return $(this).each(function(){ + //declare variables. God knows I've missed half of them I'll use + var options = $.extend(defaults, user_options); + var acceleration = 0; + var initx = 0; //intial + var inity = 0; + var movex = []; + var downtime = 0; + + //wrap the list in a sliderjs div. + $(this).wrap("
"); + var $sliderul = $(this); + var $sliderjs = $(this).parent("
"); + var divcss = { + width: options.window_width+"px", + height: options.window_height+"px", + overflow:"hidden", + position:"relative" + }; + var ulcss = { + position: "relative", + width: options.list_width+"px" + }; + $sliderjs.css(divcss); + $sliderul.css(ulcss); + //TODO:add a scroll bar and buttons maybe. + if($.browser.msie){ + //$sliderjs.children().mousedown(function(){ return true;}); + $sliderul.children().mousedown(function(){ + return false;}); + $sliderul.children().children().mousedown(function(){ + return false;}); + } + + //mouse fucntions for tosses + $sliderjs.bind('selectstart', function() { + return false; + }); + $sliderjs.bind("mousedown", function(e){ + $sliderul.stop(); + $sliderul.dequeue(); + movex.splice(0); + initx = e.pageX; + var date = new Date(); + downtime = date.getTime(); + var xlen = 0; + var ulinitx = $sliderul.position().left; + $().bind("mousemove", function(e){ + //track the mouse movements + //duplicates cause some issues. Though moving only one direction would + //cause this. it tends to be unintentional + if(movex[xlen-1]!=e.pageX){ + xlen = movex.push(e.pageX); + } + + //keep trimming our array + if(xlen>10){ + movex.splice(0,6); + xlen = movex.push(e.pageX); + } + + //track direction of last three movements. if directions changes reset time + if(movex.length>3){ + if((movex[xlen-3]>=movex[xlen-2]) &&(movex[xlen-2]>=movex[xlen-1])){ + }else if((movex[xlen-3]<=movex[xlen-2]) &&(movex[xlen-2]<=movex[xlen-1])){ + }else{ + //if we made it here the user has changed direction so now we need to reset the time + //downtime = date.getTime(); + } + } + + //move the list around well the mouse is pressed + var newleft = parseInt(ulinitx, 10)+parseInt((e.pageX-initx)/1.5, 10); + if(newleft<((options.list_width*-1)+parseInt(options.window_width, 10)-50)){ + newleft=((options.list_width*-1)+parseInt(options.window_width, 10)-50); + } + if(newleft>50){newleft=50;} + //$('.pika_navigation').html(newleft); + $sliderul.css("left",newleft+"px"); + }); + $().bind("mouseup", MeatAndPatatos); + return false; + }); + + function Animate(xvalue){ + $sliderul.stop(); + $sliderul.dequeue(); + $sliderul.animate({ + left:xvalue+"px" + },1500,"easeOutCubic"); + } + + //TODO: find a better name for this func... nevermind I like it + function MeatAndPatatos(e){ + $().unbind("mousemove"); + $().unbind("mouseup", MeatAndPatatos); + var date = new Date(); + var uptime = date.getTime(); + + //calculate velocity... did math class just pay off? + var velocity = (movex[movex.length-1]*100-movex[movex.length-2]*100)/(uptime-downtime); + var distance = movex[movex.length-1]-movex[movex.length-2]; + var negative = 1; + //they're both negative when they get multiplied together we're going to end up with a positive + if(distance<0){ + negative = -1; + } + var ulinitx = $sliderul.position().left; + var animateleft = parseInt(ulinitx, 10)+(velocity * distance * negative)/2; + if(animateleft<(options.list_width*-1)+parseInt(options.window_width, 10)){ + animateleft=(options.list_width*-1)+parseInt(options.window_width, 10); + } + //alert(animateleft); + if(animateleft>0){animateleft=0;} + //now that we have velocity figure out the distance to go and the time + if(isNaN(animateleft)){}else{ + Animate(animateleft); + } + + } + + + + function MoveToLi(){ + var pos = $(this).parent('li').position(); + var width = $(this).css("width").slice(0,-2); + var lileft = pos.left; + var liright = parseInt(pos.left, 10)+parseInt(width, 10); + var ulleft = $sliderul.position().left; + //find out if the li is inside the viewable area + //first find range of viewable values + var low = ulleft*-1; + var high = low+options.window_width; + //is my li in that? + if((lileft>=low)&&(liright<=high)){ + //viewable we're gravy + return; + }else{ + //uh oh! not viewable lets slide + //find how far outside view we are + var slide =0; + if(lileft 'gallery', :profile => profile) + get :view_page, :profile => profile.identifier, :page => f.explode_path, :slideshow => true + + assert_template 'slideshow' + end + end -- libgit2 0.21.2