swipebox 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +32 -0
- data/lib/swipebox.rb +4 -0
- data/lib/swipebox/version.rb +3 -0
- data/lib/tasks/swipebox_tasks.rake +4 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +14 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +56 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +56 -0
- data/test/dummy/log/test.log +24 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/f9c6a267bff4dbc4c014a32d65f455fee642ff7f/swipebox.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2417663820f12194df84f901aeddf205 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/299e5c3e6fe902ee2248d4f551e2a736 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/39a4691fbee5b5d7a15a61d39e8298c9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/52844af88f25171d8b2bd9b3841fc531 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/58b5fb0ecf84f52f0afa100b0b4c8cba +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7cad4e0f6c155aee86ff849175d87485 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/9540837ee939a819ff3def6208986d2b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ad7154cc55f39a227d2bc6415f58932d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f8832e909e8abc5a5f26e98546d2f7ca +0 -0
- data/test/integration/swipebox_integration_test.rb +13 -0
- data/test/test_helper.rb +14 -0
- data/vendor/assets/images/icons.png +0 -0
- data/vendor/assets/images/icons.svg +1 -0
- data/vendor/assets/images/loader.gif +0 -0
- data/vendor/assets/javascripts/swipebox.js +595 -0
- data/vendor/assets/stylesheets/swipebox.css.scss +265 -0
- metadata +244 -0
    
        data/test/test_helper.rb
    ADDED
    
    | @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            # Configure Rails Environment
         | 
| 2 | 
            +
            ENV["RAILS_ENV"] = "test"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            require File.expand_path("../dummy/config/environment.rb",  __FILE__)
         | 
| 5 | 
            +
            require "rails/test_help"
         | 
| 6 | 
            +
            require 'minitest/autorun'
         | 
| 7 | 
            +
            require "capybara/rails"
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            Rails.backtrace_cleaner.remove_silencers!
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            class IntegrationTest < MiniTest::Spec
         | 
| 12 | 
            +
              include Capybara::DSL
         | 
| 13 | 
            +
              register_spec_type(/integration$/, self)
         | 
| 14 | 
            +
            end
         | 
| Binary file | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            <?xml version="1.0" encoding="utf-8"?> <!-- Generator: IcoMoon.io --> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="120" height="24" viewBox="0 0 120 24" fill="#ffffff" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M 17.384,17.705q0.00,0.536 -0.375,0.911l-1.821,1.821q-0.375,0.375 -0.911,0.375t-0.911-0.375l-3.938-3.938l-3.938,3.938q-0.375,0.375 -0.911,0.375t-0.911-0.375l-1.821-1.821q-0.375-0.375 -0.375-0.911t 0.375-0.911l 3.938-3.938l-3.938-3.938q-0.375-0.375 -0.375-0.911t 0.375-0.911l 1.821-1.821q 0.375-0.375 0.911-0.375t 0.911,0.375l 3.938,3.938l 3.938-3.938q 0.375-0.375 0.911-0.375t 0.911,0.375l 1.821,1.821q 0.375,0.375 0.375,0.911 t-0.375,0.911l-3.938,3.938l 3.938,3.938q 0.375,0.375 0.375,0.911zM 57.938,21.067l-8.732-8.719q-0.496-0.496 -0.496-1.212t 0.496-1.212l 8.732-8.719q 0.496-0.496 1.212-0.496t 1.212,0.496l 1.004,1.004q 0.496,0.496 0.496,1.212t-0.496,1.212l-6.509,6.509l 6.509,6.496q 0.496,0.509 0.496,1.219t-0.496,1.205l-1.004,1.004q-0.496,0.496 -1.212,0.496t-1.212-0.496zM 110.719,11.143q0.00,0.696 -0.496,1.219l-8.732,8.719q-0.496,0.496 -1.205,0.496t-1.205-0.496l-1.018-1.004q-0.496-0.522 -0.496-1.219q0.00-0.71 0.496-1.205l 6.509-6.509l-6.509-6.496q-0.496-0.522 -0.496-1.219q0.00-0.71 0.496-1.205l 1.018-1.004q 0.482-0.509 1.205-0.509t 1.205,0.509l 8.732,8.719q 0.496,0.496 0.496,1.205z"></path></svg>
         | 
| Binary file | 
| @@ -0,0 +1,595 @@ | |
| 1 | 
            +
            /*---------------------------------------------------------------------------------------------
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            @author       Constantin Saguin - @brutaldesign
         | 
| 4 | 
            +
            @link            http://csag.co
         | 
| 5 | 
            +
            @github        http://github.com/brutaldesign/swipebox
         | 
| 6 | 
            +
            @version     1.2.1*
         | 
| 7 | 
            +
            @license      MIT License
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            *svg class mod
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            ----------------------------------------------------------------------------------------------*/
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            ;(function (window, document, $, undefined) {
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            	$.swipebox = function(elem, options) {
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            		var defaults = {
         | 
| 18 | 
            +
            			useCSS : true,
         | 
| 19 | 
            +
            			initialIndexOnArray : 0,
         | 
| 20 | 
            +
            			hideBarsDelay : 3000,
         | 
| 21 | 
            +
            			videoMaxWidth : 1140,
         | 
| 22 | 
            +
            			vimeoColor : 'CCCCCC',
         | 
| 23 | 
            +
            			beforeOpen: null,
         | 
| 24 | 
            +
            		      	afterClose: null
         | 
| 25 | 
            +
            		},
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            		plugin = this,
         | 
| 28 | 
            +
            		elements = [], // slides array [{href:'...', title:'...'}, ...],
         | 
| 29 | 
            +
            		elem = elem,
         | 
| 30 | 
            +
            		selector = elem.selector,
         | 
| 31 | 
            +
            		$selector = $(selector),
         | 
| 32 | 
            +
            		isTouch = document.createTouch !== undefined || ('ontouchstart' in window) || ('onmsgesturechange' in window) || navigator.msMaxTouchPoints,
         | 
| 33 | 
            +
            		supportSVG = !!(window.SVGSVGElement),
         | 
| 34 | 
            +
            		winWidth = window.innerWidth ? window.innerWidth : $(window).width(),
         | 
| 35 | 
            +
            		winHeight = window.innerHeight ? window.innerHeight : $(window).height(),
         | 
| 36 | 
            +
            		html = '<div id="swipebox-overlay">\
         | 
| 37 | 
            +
            				<div id="swipebox-slider"></div>\
         | 
| 38 | 
            +
            				<div id="swipebox-caption"></div>\
         | 
| 39 | 
            +
            				<div id="swipebox-action">\
         | 
| 40 | 
            +
            					<a id="swipebox-close"></a>\
         | 
| 41 | 
            +
            					<div id="swipebox-count"></div>\
         | 
| 42 | 
            +
            					<a id="swipebox-prev"></a>\
         | 
| 43 | 
            +
            					<a id="swipebox-next"></a>\
         | 
| 44 | 
            +
            				</div>\
         | 
| 45 | 
            +
            		</div>';
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            		plugin.settings = {}
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            		plugin.init = function(){
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            			plugin.settings = $.extend({}, defaults, options);
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            			if ($.isArray(elem)) {
         | 
| 54 | 
            +
             | 
| 55 | 
            +
            				elements = elem;
         | 
| 56 | 
            +
            				ui.target = $(window);
         | 
| 57 | 
            +
            				ui.init(plugin.settings.initialIndexOnArray);
         | 
| 58 | 
            +
             | 
| 59 | 
            +
            			}else{
         | 
| 60 | 
            +
             | 
| 61 | 
            +
            				$selector.click(function(e){
         | 
| 62 | 
            +
            					elements = [];
         | 
| 63 | 
            +
            					var index , relType, relVal;
         | 
| 64 | 
            +
             | 
| 65 | 
            +
            					if (!relVal) {
         | 
| 66 | 
            +
            						relType = 'rel';
         | 
| 67 | 
            +
            						relVal  = $(this).attr(relType);
         | 
| 68 | 
            +
            					}
         | 
| 69 | 
            +
             | 
| 70 | 
            +
            					if (relVal && relVal !== '' && relVal !== 'nofollow') {
         | 
| 71 | 
            +
            						$elem = $selector.filter('[' + relType + '="' + relVal + '"]');
         | 
| 72 | 
            +
            					}else{
         | 
| 73 | 
            +
            						$elem = $(selector);
         | 
| 74 | 
            +
            					}
         | 
| 75 | 
            +
             | 
| 76 | 
            +
            					$elem.each(function(){
         | 
| 77 | 
            +
             | 
| 78 | 
            +
            						var title = null, href = null;
         | 
| 79 | 
            +
             | 
| 80 | 
            +
            						if( $(this).attr('title') )
         | 
| 81 | 
            +
            							title = $(this).attr('title');
         | 
| 82 | 
            +
             | 
| 83 | 
            +
            						if( $(this).attr('href') )
         | 
| 84 | 
            +
            							href = $(this).attr('href');
         | 
| 85 | 
            +
             | 
| 86 | 
            +
            						elements.push({
         | 
| 87 | 
            +
            							href: href,
         | 
| 88 | 
            +
            							title: title
         | 
| 89 | 
            +
            						});
         | 
| 90 | 
            +
            					});
         | 
| 91 | 
            +
             | 
| 92 | 
            +
            					index = $elem.index($(this));
         | 
| 93 | 
            +
            					e.preventDefault();
         | 
| 94 | 
            +
            					e.stopPropagation();
         | 
| 95 | 
            +
            					ui.target = $(e.target);
         | 
| 96 | 
            +
            					ui.init(index);
         | 
| 97 | 
            +
            				});
         | 
| 98 | 
            +
            			}
         | 
| 99 | 
            +
            		}
         | 
| 100 | 
            +
             | 
| 101 | 
            +
            		plugin.refresh = function() {
         | 
| 102 | 
            +
            			if (!$.isArray(elem)) {
         | 
| 103 | 
            +
            				ui.destroy();
         | 
| 104 | 
            +
            				$elem = $(selector);
         | 
| 105 | 
            +
            				ui.actions();
         | 
| 106 | 
            +
            			}
         | 
| 107 | 
            +
            		}
         | 
| 108 | 
            +
             | 
| 109 | 
            +
            		var ui = {
         | 
| 110 | 
            +
             | 
| 111 | 
            +
            			init : function(index){
         | 
| 112 | 
            +
            				if (plugin.settings.beforeOpen)
         | 
| 113 | 
            +
            					plugin.settings.beforeOpen();
         | 
| 114 | 
            +
            				this.target.trigger('swipebox-start');
         | 
| 115 | 
            +
            				$.swipebox.isOpen = true;
         | 
| 116 | 
            +
            				this.build();
         | 
| 117 | 
            +
            				this.openSlide(index);
         | 
| 118 | 
            +
            				this.openMedia(index);
         | 
| 119 | 
            +
            				this.preloadMedia(index+1);
         | 
| 120 | 
            +
            				this.preloadMedia(index-1);
         | 
| 121 | 
            +
            			},
         | 
| 122 | 
            +
             | 
| 123 | 
            +
            			build : function(){
         | 
| 124 | 
            +
            				var $this = this;
         | 
| 125 | 
            +
             | 
| 126 | 
            +
            				$('body').append(html);
         | 
| 127 | 
            +
             | 
| 128 | 
            +
            				if($this.doCssTrans()){
         | 
| 129 | 
            +
            					$('#swipebox-slider').css({
         | 
| 130 | 
            +
            						'-webkit-transition' : 'left 0.4s ease',
         | 
| 131 | 
            +
            						'-moz-transition' : 'left 0.4s ease',
         | 
| 132 | 
            +
            						'-o-transition' : 'left 0.4s ease',
         | 
| 133 | 
            +
            						'-khtml-transition' : 'left 0.4s ease',
         | 
| 134 | 
            +
            						'transition' : 'left 0.4s ease'
         | 
| 135 | 
            +
            					});
         | 
| 136 | 
            +
            					$('#swipebox-overlay').css({
         | 
| 137 | 
            +
            						'-webkit-transition' : 'opacity 1s ease',
         | 
| 138 | 
            +
            						'-moz-transition' : 'opacity 1s ease',
         | 
| 139 | 
            +
            						'-o-transition' : 'opacity 1s ease',
         | 
| 140 | 
            +
            						'-khtml-transition' : 'opacity 1s ease',
         | 
| 141 | 
            +
            						'transition' : 'opacity 1s ease'
         | 
| 142 | 
            +
            					});
         | 
| 143 | 
            +
            					$('#swipebox-action, #swipebox-caption').css({
         | 
| 144 | 
            +
            						'-webkit-transition' : '0.5s',
         | 
| 145 | 
            +
            						'-moz-transition' : '0.5s',
         | 
| 146 | 
            +
            						'-o-transition' : '0.5s',
         | 
| 147 | 
            +
            						'-khtml-transition' : '0.5s',
         | 
| 148 | 
            +
            						'transition' : '0.5s'
         | 
| 149 | 
            +
            					});
         | 
| 150 | 
            +
            				}
         | 
| 151 | 
            +
             | 
| 152 | 
            +
             | 
| 153 | 
            +
            				if(supportSVG){
         | 
| 154 | 
            +
            					$('#swipebox-action #swipebox-prev,#swipebox-action #swipebox-next,#swipebox-action #swipebox-close').addClass('svg')
         | 
| 155 | 
            +
            				}
         | 
| 156 | 
            +
             | 
| 157 | 
            +
            				$.each( elements,  function(){
         | 
| 158 | 
            +
            					$('#swipebox-slider').append('<div class="slide"></div>');
         | 
| 159 | 
            +
            				});
         | 
| 160 | 
            +
             | 
| 161 | 
            +
            				$this.setDim();
         | 
| 162 | 
            +
            				$this.actions();
         | 
| 163 | 
            +
            				$this.keyboard();
         | 
| 164 | 
            +
            				$this.gesture();
         | 
| 165 | 
            +
            				$this.animBars();
         | 
| 166 | 
            +
            				$this.resize();
         | 
| 167 | 
            +
             | 
| 168 | 
            +
            			},
         | 
| 169 | 
            +
             | 
| 170 | 
            +
            			setDim : function(){
         | 
| 171 | 
            +
             | 
| 172 | 
            +
            				var width, height, sliderCss = {};
         | 
| 173 | 
            +
             | 
| 174 | 
            +
            				if( "onorientationchange" in window ){
         | 
| 175 | 
            +
             | 
| 176 | 
            +
            					window.addEventListener("orientationchange", function() {
         | 
| 177 | 
            +
            						if( window.orientation == 0 ){
         | 
| 178 | 
            +
            							width = winWidth;
         | 
| 179 | 
            +
            							height = winHeight;
         | 
| 180 | 
            +
            						}else if( window.orientation == 90 || window.orientation == -90 ){
         | 
| 181 | 
            +
            							width = winHeight;
         | 
| 182 | 
            +
            							height = winWidth;
         | 
| 183 | 
            +
            						}
         | 
| 184 | 
            +
            					}, false);
         | 
| 185 | 
            +
             | 
| 186 | 
            +
             | 
| 187 | 
            +
            				}else{
         | 
| 188 | 
            +
             | 
| 189 | 
            +
            					width = window.innerWidth ? window.innerWidth : $(window).width();
         | 
| 190 | 
            +
            					height = window.innerHeight ? window.innerHeight : $(window).height();
         | 
| 191 | 
            +
            				}
         | 
| 192 | 
            +
             | 
| 193 | 
            +
            				sliderCss = {
         | 
| 194 | 
            +
            					width : width,
         | 
| 195 | 
            +
            					height : height
         | 
| 196 | 
            +
            				}
         | 
| 197 | 
            +
             | 
| 198 | 
            +
             | 
| 199 | 
            +
            				$('#swipebox-overlay').css(sliderCss);
         | 
| 200 | 
            +
             | 
| 201 | 
            +
            			},
         | 
| 202 | 
            +
             | 
| 203 | 
            +
            			resize : function (){
         | 
| 204 | 
            +
            				var $this = this;
         | 
| 205 | 
            +
             | 
| 206 | 
            +
            				$(window).resize(function() {
         | 
| 207 | 
            +
            					$this.setDim();
         | 
| 208 | 
            +
            				}).resize();
         | 
| 209 | 
            +
            			},
         | 
| 210 | 
            +
             | 
| 211 | 
            +
            			supportTransition : function() {
         | 
| 212 | 
            +
            				var prefixes = 'transition WebkitTransition MozTransition OTransition msTransition KhtmlTransition'.split(' ');
         | 
| 213 | 
            +
            				for(var i = 0; i < prefixes.length; i++) {
         | 
| 214 | 
            +
            					if(document.createElement('div').style[prefixes[i]] !== undefined) {
         | 
| 215 | 
            +
            						return prefixes[i];
         | 
| 216 | 
            +
            					}
         | 
| 217 | 
            +
            				}
         | 
| 218 | 
            +
            				return false;
         | 
| 219 | 
            +
            			},
         | 
| 220 | 
            +
             | 
| 221 | 
            +
            			doCssTrans : function(){
         | 
| 222 | 
            +
            				if(plugin.settings.useCSS && this.supportTransition() ){
         | 
| 223 | 
            +
            					return true;
         | 
| 224 | 
            +
            				}
         | 
| 225 | 
            +
            			},
         | 
| 226 | 
            +
             | 
| 227 | 
            +
            			gesture : function(){
         | 
| 228 | 
            +
            				if ( isTouch ){
         | 
| 229 | 
            +
            					var $this = this,
         | 
| 230 | 
            +
            					distance = null,
         | 
| 231 | 
            +
            					swipMinDistance = 10,
         | 
| 232 | 
            +
            					startCoords = {},
         | 
| 233 | 
            +
            					endCoords = {};
         | 
| 234 | 
            +
            					var bars = $('#swipebox-caption, #swipebox-action');
         | 
| 235 | 
            +
             | 
| 236 | 
            +
            					bars.addClass('visible-bars');
         | 
| 237 | 
            +
            					$this.setTimeout();
         | 
| 238 | 
            +
             | 
| 239 | 
            +
            					$('body').bind('touchstart', function(e){
         | 
| 240 | 
            +
             | 
| 241 | 
            +
            						$(this).addClass('touching');
         | 
| 242 | 
            +
             | 
| 243 | 
            +
            		  				endCoords = e.originalEvent.targetTouches[0];
         | 
| 244 | 
            +
            		    				startCoords.pageX = e.originalEvent.targetTouches[0].pageX;
         | 
| 245 | 
            +
             | 
| 246 | 
            +
            						$('.touching').bind('touchmove',function(e){
         | 
| 247 | 
            +
            							e.preventDefault();
         | 
| 248 | 
            +
            							e.stopPropagation();
         | 
| 249 | 
            +
            		    					endCoords = e.originalEvent.targetTouches[0];
         | 
| 250 | 
            +
             | 
| 251 | 
            +
            						});
         | 
| 252 | 
            +
             | 
| 253 | 
            +
            			           			return false;
         | 
| 254 | 
            +
             | 
| 255 | 
            +
            	           			}).bind('touchend',function(e){
         | 
| 256 | 
            +
            	           				e.preventDefault();
         | 
| 257 | 
            +
            					e.stopPropagation();
         | 
| 258 | 
            +
             | 
| 259 | 
            +
               					distance = endCoords.pageX - startCoords.pageX;
         | 
| 260 | 
            +
             | 
| 261 | 
            +
            	       				if( distance >= swipMinDistance ){
         | 
| 262 | 
            +
             | 
| 263 | 
            +
            	       					// swipeLeft
         | 
| 264 | 
            +
            	       					$this.getPrev();
         | 
| 265 | 
            +
             | 
| 266 | 
            +
            	       				}else if( distance <= - swipMinDistance ){
         | 
| 267 | 
            +
             | 
| 268 | 
            +
            	       					// swipeRight
         | 
| 269 | 
            +
            	       					$this.getNext();
         | 
| 270 | 
            +
             | 
| 271 | 
            +
            	       				}else{
         | 
| 272 | 
            +
            	       					// tap
         | 
| 273 | 
            +
            	       					if(!bars.hasClass('visible-bars')){
         | 
| 274 | 
            +
            							$this.showBars();
         | 
| 275 | 
            +
            							$this.setTimeout();
         | 
| 276 | 
            +
            						}else{
         | 
| 277 | 
            +
            							$this.clearTimeout();
         | 
| 278 | 
            +
            							$this.hideBars();
         | 
| 279 | 
            +
            						}
         | 
| 280 | 
            +
             | 
| 281 | 
            +
            	       				}
         | 
| 282 | 
            +
             | 
| 283 | 
            +
            	       				$('.touching').off('touchmove').removeClass('touching');
         | 
| 284 | 
            +
             | 
| 285 | 
            +
            					});
         | 
| 286 | 
            +
             | 
| 287 | 
            +
                       				}
         | 
| 288 | 
            +
            			},
         | 
| 289 | 
            +
             | 
| 290 | 
            +
            			setTimeout: function(){
         | 
| 291 | 
            +
            				if(plugin.settings.hideBarsDelay > 0){
         | 
| 292 | 
            +
            					var $this = this;
         | 
| 293 | 
            +
            					$this.clearTimeout();
         | 
| 294 | 
            +
            					$this.timeout = window.setTimeout( function(){
         | 
| 295 | 
            +
            						$this.hideBars() },
         | 
| 296 | 
            +
            						plugin.settings.hideBarsDelay
         | 
| 297 | 
            +
            					);
         | 
| 298 | 
            +
            				}
         | 
| 299 | 
            +
            			},
         | 
| 300 | 
            +
             | 
| 301 | 
            +
            			clearTimeout: function(){
         | 
| 302 | 
            +
            				window.clearTimeout(this.timeout);
         | 
| 303 | 
            +
            				this.timeout = null;
         | 
| 304 | 
            +
            			},
         | 
| 305 | 
            +
             | 
| 306 | 
            +
            			showBars : function(){
         | 
| 307 | 
            +
            				var bars = $('#swipebox-caption, #swipebox-action');
         | 
| 308 | 
            +
            				if(this.doCssTrans()){
         | 
| 309 | 
            +
            					bars.addClass('visible-bars');
         | 
| 310 | 
            +
            				}else{
         | 
| 311 | 
            +
            					$('#swipebox-caption').animate({ top : 0 }, 500);
         | 
| 312 | 
            +
            					$('#swipebox-action').animate({ bottom : 0 }, 500);
         | 
| 313 | 
            +
            					setTimeout(function(){
         | 
| 314 | 
            +
            						bars.addClass('visible-bars');
         | 
| 315 | 
            +
            					}, 1000);
         | 
| 316 | 
            +
            				}
         | 
| 317 | 
            +
            			},
         | 
| 318 | 
            +
             | 
| 319 | 
            +
            			hideBars : function(){
         | 
| 320 | 
            +
            				var bars = $('#swipebox-caption, #swipebox-action');
         | 
| 321 | 
            +
            				if(this.doCssTrans()){
         | 
| 322 | 
            +
            					bars.removeClass('visible-bars');
         | 
| 323 | 
            +
            				}else{
         | 
| 324 | 
            +
            					$('#swipebox-caption').animate({ top : '-50px' }, 500);
         | 
| 325 | 
            +
            					$('#swipebox-action').animate({ bottom : '-50px' }, 500);
         | 
| 326 | 
            +
            					setTimeout(function(){
         | 
| 327 | 
            +
            						bars.removeClass('visible-bars');
         | 
| 328 | 
            +
            					}, 1000);
         | 
| 329 | 
            +
            				}
         | 
| 330 | 
            +
            			},
         | 
| 331 | 
            +
             | 
| 332 | 
            +
            			animBars : function(){
         | 
| 333 | 
            +
            				var $this = this;
         | 
| 334 | 
            +
            				var bars = $('#swipebox-caption, #swipebox-action');
         | 
| 335 | 
            +
             | 
| 336 | 
            +
            				bars.addClass('visible-bars');
         | 
| 337 | 
            +
            				$this.setTimeout();
         | 
| 338 | 
            +
             | 
| 339 | 
            +
            				$('#swipebox-slider').click(function(e){
         | 
| 340 | 
            +
            					if(!bars.hasClass('visible-bars')){
         | 
| 341 | 
            +
            						$this.showBars();
         | 
| 342 | 
            +
            						$this.setTimeout();
         | 
| 343 | 
            +
            					}
         | 
| 344 | 
            +
            				});
         | 
| 345 | 
            +
             | 
| 346 | 
            +
            				$('#swipebox-action').hover(function() {
         | 
| 347 | 
            +
            				  		$this.showBars();
         | 
| 348 | 
            +
            						bars.addClass('force-visible-bars');
         | 
| 349 | 
            +
            						$this.clearTimeout();
         | 
| 350 | 
            +
             | 
| 351 | 
            +
            					},function() {
         | 
| 352 | 
            +
            						bars.removeClass('force-visible-bars');
         | 
| 353 | 
            +
            						$this.setTimeout();
         | 
| 354 | 
            +
             | 
| 355 | 
            +
            				});
         | 
| 356 | 
            +
            			},
         | 
| 357 | 
            +
             | 
| 358 | 
            +
            			keyboard : function(){
         | 
| 359 | 
            +
            				var $this = this;
         | 
| 360 | 
            +
            				$(window).bind('keyup', function(e){
         | 
| 361 | 
            +
            					e.preventDefault();
         | 
| 362 | 
            +
            					e.stopPropagation();
         | 
| 363 | 
            +
            					if (e.keyCode == 37){
         | 
| 364 | 
            +
            						$this.getPrev();
         | 
| 365 | 
            +
            					}
         | 
| 366 | 
            +
            					else if (e.keyCode==39){
         | 
| 367 | 
            +
            						$this.getNext();
         | 
| 368 | 
            +
            					}
         | 
| 369 | 
            +
            					else if (e.keyCode == 27) {
         | 
| 370 | 
            +
            						$this.closeSlide();
         | 
| 371 | 
            +
            					}
         | 
| 372 | 
            +
            				});
         | 
| 373 | 
            +
            			},
         | 
| 374 | 
            +
             | 
| 375 | 
            +
            			actions : function(){
         | 
| 376 | 
            +
            				var $this = this;
         | 
| 377 | 
            +
             | 
| 378 | 
            +
            				if( elements.length < 2 ){
         | 
| 379 | 
            +
            					$('#swipebox-prev, #swipebox-next').hide();
         | 
| 380 | 
            +
            				}else{
         | 
| 381 | 
            +
            					$('#swipebox-prev').bind('click touchend', function(e){
         | 
| 382 | 
            +
            						e.preventDefault();
         | 
| 383 | 
            +
            						e.stopPropagation();
         | 
| 384 | 
            +
            						$this.getPrev();
         | 
| 385 | 
            +
            						$this.setTimeout();
         | 
| 386 | 
            +
            					});
         | 
| 387 | 
            +
             | 
| 388 | 
            +
            					$('#swipebox-next').bind('click touchend', function(e){
         | 
| 389 | 
            +
            						e.preventDefault();
         | 
| 390 | 
            +
            						e.stopPropagation();
         | 
| 391 | 
            +
            						$this.getNext();
         | 
| 392 | 
            +
            						$this.setTimeout();
         | 
| 393 | 
            +
            					});
         | 
| 394 | 
            +
            				}
         | 
| 395 | 
            +
             | 
| 396 | 
            +
            				$('#swipebox-close').bind('click touchend', function(e){
         | 
| 397 | 
            +
            					$this.closeSlide();
         | 
| 398 | 
            +
            				});
         | 
| 399 | 
            +
            			},
         | 
| 400 | 
            +
             | 
| 401 | 
            +
            			setSlide : function (index, isFirst){
         | 
| 402 | 
            +
            				isFirst = isFirst || false;
         | 
| 403 | 
            +
             | 
| 404 | 
            +
            				var slider = $('#swipebox-slider');
         | 
| 405 | 
            +
             | 
| 406 | 
            +
            				if(this.doCssTrans()){
         | 
| 407 | 
            +
            					slider.css({ left : (-index*100)+'%' });
         | 
| 408 | 
            +
            				}else{
         | 
| 409 | 
            +
            					slider.animate({ left : (-index*100)+'%' });
         | 
| 410 | 
            +
            				}
         | 
| 411 | 
            +
             | 
| 412 | 
            +
            				$('#swipebox-slider .slide').removeClass('current');
         | 
| 413 | 
            +
            				$('#swipebox-slider .slide').eq(index).addClass('current');
         | 
| 414 | 
            +
            				this.setTitle(index);
         | 
| 415 | 
            +
             | 
| 416 | 
            +
            				if( isFirst ){
         | 
| 417 | 
            +
            					slider.fadeIn();
         | 
| 418 | 
            +
            				}
         | 
| 419 | 
            +
             | 
| 420 | 
            +
            				$('#swipebox-prev, #swipebox-next').removeClass('disabled');
         | 
| 421 | 
            +
            				if(index == 0){
         | 
| 422 | 
            +
            					$('#swipebox-prev').addClass('disabled');
         | 
| 423 | 
            +
            				}else if( index == elements.length - 1 ){
         | 
| 424 | 
            +
            					$('#swipebox-next').addClass('disabled');
         | 
| 425 | 
            +
            				}
         | 
| 426 | 
            +
             | 
| 427 | 
            +
            				$('#swipebox-count').text((index+1) + '/' + elements.length)
         | 
| 428 | 
            +
            			},
         | 
| 429 | 
            +
             | 
| 430 | 
            +
            			openSlide : function (index){
         | 
| 431 | 
            +
            				$('html').addClass('swipebox');
         | 
| 432 | 
            +
            				$(window).trigger('resize'); // fix scroll bar visibility on desktop
         | 
| 433 | 
            +
            				this.setSlide(index, true);
         | 
| 434 | 
            +
            			},
         | 
| 435 | 
            +
             | 
| 436 | 
            +
            			preloadMedia : function (index){
         | 
| 437 | 
            +
            				var $this = this, src = null;
         | 
| 438 | 
            +
             | 
| 439 | 
            +
            				if( elements[index] !== undefined )
         | 
| 440 | 
            +
            					src = elements[index].href;
         | 
| 441 | 
            +
             | 
| 442 | 
            +
            				if( !$this.isVideo(src) ){
         | 
| 443 | 
            +
            					setTimeout(function(){
         | 
| 444 | 
            +
            						$this.openMedia(index);
         | 
| 445 | 
            +
            					}, 1000);
         | 
| 446 | 
            +
            				}else{
         | 
| 447 | 
            +
            					$this.openMedia(index);
         | 
| 448 | 
            +
            				}
         | 
| 449 | 
            +
            			},
         | 
| 450 | 
            +
             | 
| 451 | 
            +
            			openMedia : function (index){
         | 
| 452 | 
            +
            				var $this = this, src = null;
         | 
| 453 | 
            +
             | 
| 454 | 
            +
            				if( elements[index] !== undefined )
         | 
| 455 | 
            +
            					src = elements[index].href;
         | 
| 456 | 
            +
             | 
| 457 | 
            +
            				if(index < 0 || index >= elements.length){
         | 
| 458 | 
            +
            					return false;
         | 
| 459 | 
            +
            				}
         | 
| 460 | 
            +
             | 
| 461 | 
            +
            				if( !$this.isVideo(src) ){
         | 
| 462 | 
            +
            					$this.loadMedia(src, function(){
         | 
| 463 | 
            +
            						$('#swipebox-slider .slide').eq(index).html(this);
         | 
| 464 | 
            +
            					});
         | 
| 465 | 
            +
            				}else{
         | 
| 466 | 
            +
            					$('#swipebox-slider .slide').eq(index).html($this.getVideo(src));
         | 
| 467 | 
            +
            				}
         | 
| 468 | 
            +
             | 
| 469 | 
            +
            			},
         | 
| 470 | 
            +
             | 
| 471 | 
            +
            			setTitle : function (index, isFirst){
         | 
| 472 | 
            +
            				var title = null;
         | 
| 473 | 
            +
             | 
| 474 | 
            +
            				$('#swipebox-caption').empty();
         | 
| 475 | 
            +
             | 
| 476 | 
            +
            				if( elements[index] !== undefined )
         | 
| 477 | 
            +
            					title = elements[index].title;
         | 
| 478 | 
            +
             | 
| 479 | 
            +
            				if(title){
         | 
| 480 | 
            +
            					$('#swipebox-caption').append(title);
         | 
| 481 | 
            +
            				}
         | 
| 482 | 
            +
            			},
         | 
| 483 | 
            +
             | 
| 484 | 
            +
            			isVideo : function (src){
         | 
| 485 | 
            +
             | 
| 486 | 
            +
            				if( src ){
         | 
| 487 | 
            +
            					if(
         | 
| 488 | 
            +
            						src.match(/youtube\.com\/watch\?v=([a-zA-Z0-9\-_]+)/)
         | 
| 489 | 
            +
            						|| src.match(/vimeo\.com\/([0-9]*)/)
         | 
| 490 | 
            +
            					){
         | 
| 491 | 
            +
            						return true;
         | 
| 492 | 
            +
            					}
         | 
| 493 | 
            +
            				}
         | 
| 494 | 
            +
             | 
| 495 | 
            +
            			},
         | 
| 496 | 
            +
             | 
| 497 | 
            +
            			getVideo : function(url){
         | 
| 498 | 
            +
            				var iframe = '';
         | 
| 499 | 
            +
            				var output = '';
         | 
| 500 | 
            +
            				var youtubeUrl = url.match(/watch\?v=([a-zA-Z0-9\-_]+)/);
         | 
| 501 | 
            +
            				var vimeoUrl = url.match(/vimeo\.com\/([0-9]*)/);
         | 
| 502 | 
            +
            				if( youtubeUrl ){
         | 
| 503 | 
            +
             | 
| 504 | 
            +
            					iframe = '<iframe width="560" height="315" src="//www.youtube.com/embed/'+youtubeUrl[1]+'" frameborder="0" allowfullscreen></iframe>';
         | 
| 505 | 
            +
             | 
| 506 | 
            +
            				}else if(vimeoUrl){
         | 
| 507 | 
            +
             | 
| 508 | 
            +
            					iframe = '<iframe width="560" height="315"  src="http://player.vimeo.com/video/'+vimeoUrl[1]+'?byline=0&portrait=0&color='+plugin.settings.vimeoColor+'" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
         | 
| 509 | 
            +
             | 
| 510 | 
            +
            				}
         | 
| 511 | 
            +
             | 
| 512 | 
            +
            				return '<div class="swipebox-video-container" style="max-width:'+plugin.settings.videomaxWidth+'px"><div class="swipebox-video">'+iframe+'</div></div>';
         | 
| 513 | 
            +
            			},
         | 
| 514 | 
            +
             | 
| 515 | 
            +
            			loadMedia : function (src, callback){
         | 
| 516 | 
            +
            				if( !this.isVideo(src) ){
         | 
| 517 | 
            +
            					var img = $('<img>').on('load', function(){
         | 
| 518 | 
            +
            						callback.call(img);
         | 
| 519 | 
            +
            					});
         | 
| 520 | 
            +
             | 
| 521 | 
            +
            					img.attr('src',src);
         | 
| 522 | 
            +
            				}
         | 
| 523 | 
            +
            			},
         | 
| 524 | 
            +
             | 
| 525 | 
            +
            			getNext : function (){
         | 
| 526 | 
            +
            				var $this = this;
         | 
| 527 | 
            +
            				index = $('#swipebox-slider .slide').index($('#swipebox-slider .slide.current'));
         | 
| 528 | 
            +
            				if(index+1 < elements.length){
         | 
| 529 | 
            +
            					index++;
         | 
| 530 | 
            +
            					$this.setSlide(index);
         | 
| 531 | 
            +
            					$this.preloadMedia(index+1);
         | 
| 532 | 
            +
            				}
         | 
| 533 | 
            +
            				else{
         | 
| 534 | 
            +
             | 
| 535 | 
            +
            					$('#swipebox-slider').addClass('rightSpring');
         | 
| 536 | 
            +
            					setTimeout(function(){
         | 
| 537 | 
            +
            						$('#swipebox-slider').removeClass('rightSpring');
         | 
| 538 | 
            +
            					},500);
         | 
| 539 | 
            +
            				}
         | 
| 540 | 
            +
            			},
         | 
| 541 | 
            +
             | 
| 542 | 
            +
            			getPrev : function (){
         | 
| 543 | 
            +
            				index = $('#swipebox-slider .slide').index($('#swipebox-slider .slide.current'));
         | 
| 544 | 
            +
            				if(index > 0){
         | 
| 545 | 
            +
            					index--;
         | 
| 546 | 
            +
            					this.setSlide(index);
         | 
| 547 | 
            +
            					this.preloadMedia(index-1);
         | 
| 548 | 
            +
            				}
         | 
| 549 | 
            +
            				else{
         | 
| 550 | 
            +
             | 
| 551 | 
            +
            					$('#swipebox-slider').addClass('leftSpring');
         | 
| 552 | 
            +
            					setTimeout(function(){
         | 
| 553 | 
            +
            						$('#swipebox-slider').removeClass('leftSpring');
         | 
| 554 | 
            +
            					},500);
         | 
| 555 | 
            +
            				}
         | 
| 556 | 
            +
            			},
         | 
| 557 | 
            +
             | 
| 558 | 
            +
             | 
| 559 | 
            +
            			closeSlide : function (){
         | 
| 560 | 
            +
            				$('html').removeClass('swipebox');
         | 
| 561 | 
            +
            				$(window).trigger('resize');
         | 
| 562 | 
            +
            				this.destroy();
         | 
| 563 | 
            +
            			},
         | 
| 564 | 
            +
             | 
| 565 | 
            +
            			destroy : function(){
         | 
| 566 | 
            +
            				$(window).unbind('keyup');
         | 
| 567 | 
            +
            				$('body').unbind('touchstart');
         | 
| 568 | 
            +
            				$('body').unbind('touchmove');
         | 
| 569 | 
            +
            				$('body').unbind('touchend');
         | 
| 570 | 
            +
            				$('#swipebox-slider').unbind();
         | 
| 571 | 
            +
            				$('#swipebox-overlay').remove();
         | 
| 572 | 
            +
            				if (!$.isArray(elem))
         | 
| 573 | 
            +
            					elem.removeData('_swipebox');
         | 
| 574 | 
            +
            				if ( this.target )
         | 
| 575 | 
            +
            					this.target.trigger('swipebox-destroy');
         | 
| 576 | 
            +
            				$.swipebox.isOpen = false;
         | 
| 577 | 
            +
            				if (plugin.settings.afterClose)
         | 
| 578 | 
            +
            					plugin.settings.afterClose();
         | 
| 579 | 
            +
             			}
         | 
| 580 | 
            +
             | 
| 581 | 
            +
            		};
         | 
| 582 | 
            +
             | 
| 583 | 
            +
            		plugin.init();
         | 
| 584 | 
            +
             | 
| 585 | 
            +
            	};
         | 
| 586 | 
            +
             | 
| 587 | 
            +
            	$.fn.swipebox = function(options){
         | 
| 588 | 
            +
            		if (!$.data(this, "_swipebox")) {
         | 
| 589 | 
            +
            			var swipebox = new $.swipebox(this, options);
         | 
| 590 | 
            +
            			this.data('_swipebox', swipebox);
         | 
| 591 | 
            +
            		}
         | 
| 592 | 
            +
            		return this.data('_swipebox');
         | 
| 593 | 
            +
            	}
         | 
| 594 | 
            +
             | 
| 595 | 
            +
            }(window, document, jQuery));
         |