sweet_portfolio 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/.document +5 -0
  2. data/.powrc +4 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +2 -0
  5. data/Gemfile +11 -0
  6. data/LICENSE +20 -0
  7. data/README.md +37 -0
  8. data/Rakefile +21 -0
  9. data/VERSION +1 -0
  10. data/app/assets/images/sweet_portfolio/blank.gif +0 -0
  11. data/app/assets/images/sweet_portfolio/border.png +0 -0
  12. data/app/assets/images/sweet_portfolio/controls.png +0 -0
  13. data/app/assets/images/sweet_portfolio/fancybox_loading.gif +0 -0
  14. data/app/assets/images/sweet_portfolio/fancybox_overlay.png +0 -0
  15. data/app/assets/images/sweet_portfolio/fancybox_sprite.png +0 -0
  16. data/app/assets/images/sweet_portfolio/jcrop.gif +0 -0
  17. data/app/assets/images/sweet_portfolio/loading.gif +0 -0
  18. data/app/assets/images/sweet_portfolio/loading_background.png +0 -0
  19. data/app/assets/images/sweet_portfolio/overlay.png +0 -0
  20. data/app/assets/javascripts/sweet_portfolio/jquery.colorbox.js +4 -0
  21. data/app/assets/javascripts/sweet_portfolio/jquery.fancybox-media.js +196 -0
  22. data/app/assets/javascripts/sweet_portfolio/jquery.fancybox-thumbs.js +162 -0
  23. data/app/assets/javascripts/sweet_portfolio/jquery.fancybox.pack.js +45 -0
  24. data/app/assets/javascripts/sweet_portfolio/jquery.jcrop.js +246 -0
  25. data/app/assets/stylesheets/sweet_portfolio/colorbox.css +61 -0
  26. data/app/assets/stylesheets/sweet_portfolio/jquery.fancybox-thumbs.css +54 -0
  27. data/app/assets/stylesheets/sweet_portfolio/jquery.fancybox.css +249 -0
  28. data/app/assets/stylesheets/sweet_portfolio/jquery.jcrop.css +32 -0
  29. data/app/controllers/admin/gallery/base_controller.rb +3 -0
  30. data/app/controllers/admin/gallery/galleries_controller.rb +72 -0
  31. data/app/controllers/admin/gallery/photos_controller.rb +90 -0
  32. data/app/controllers/application_controller.rb +7 -0
  33. data/app/helpers/gallery/application_helper.rb +12 -0
  34. data/app/models/gallery/gallery.rb +33 -0
  35. data/app/models/gallery/photo.rb +83 -0
  36. data/app/views/admin/gallery/_navigation.html.erb +1 -0
  37. data/app/views/admin/gallery/galleries/_form.html.haml +15 -0
  38. data/app/views/admin/gallery/galleries/edit.html.haml +5 -0
  39. data/app/views/admin/gallery/galleries/index.html.haml +28 -0
  40. data/app/views/admin/gallery/galleries/new.html.haml +5 -0
  41. data/app/views/admin/gallery/photos/_form.html.haml +12 -0
  42. data/app/views/admin/gallery/photos/crop.html.haml +50 -0
  43. data/app/views/admin/gallery/photos/edit.html.haml +5 -0
  44. data/app/views/admin/gallery/photos/index.html.haml +19 -0
  45. data/app/views/admin/gallery/photos/new.html.haml +5 -0
  46. data/app/views/layouts/gallery/application.html.haml +12 -0
  47. data/config.ru +4 -0
  48. data/config/application.rb +51 -0
  49. data/config/boot.rb +13 -0
  50. data/config/database.yml +16 -0
  51. data/config/environment.rb +5 -0
  52. data/config/environments/development.rb +25 -0
  53. data/config/environments/production.rb +52 -0
  54. data/config/environments/test.rb +39 -0
  55. data/config/initializers/paperclip.rb +3 -0
  56. data/config/initializers/sweet_portfolio.rb +12 -0
  57. data/config/routes.rb +3 -0
  58. data/db/migrate/01_create_sweet_portfolio.rb +37 -0
  59. data/lib/generators/sweet_portfolio/README +10 -0
  60. data/lib/generators/sweet_portfolio/sweet_portfolio.rb +37 -0
  61. data/lib/paperclip_processors/cropper.rb +31 -0
  62. data/lib/sweet_portfolio.rb +28 -0
  63. data/lib/sweet_portfolio/configuration.rb +26 -0
  64. data/lib/sweet_portfolio/engine.rb +21 -0
  65. data/lib/sweet_portfolio/form_builder.rb +50 -0
  66. data/lib/sweet_portfolio/routing.rb +21 -0
  67. data/lib/tasks/sweet_portfolio.rake +4 -0
  68. data/script/rails +6 -0
  69. data/sweet_portfolio.gemspec +134 -0
  70. data/test/fixtures/files/default.jpg +0 -0
  71. data/test/fixtures/files/default.txt +1 -0
  72. data/test/fixtures/files/default2.jpg +0 -0
  73. data/test/fixtures/gallery/galleries.yml +11 -0
  74. data/test/fixtures/gallery/photos.yml +8 -0
  75. data/test/functional/admin/gallery/galleries_controller_test.rb +107 -0
  76. data/test/functional/admin/gallery/photos_controller_test.rb +224 -0
  77. data/test/test_helper.rb +39 -0
  78. data/test/unit/configuration_test.rb +16 -0
  79. data/test/unit/gallery_test.rb +38 -0
  80. data/test/unit/photo_test.rb +40 -0
  81. metadata +228 -0
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.powrc ADDED
@@ -0,0 +1,4 @@
1
+ if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".ruby-version" ]; then
2
+ source "$rvm_path/scripts/rvm"
3
+ rvm use `cat .ruby-version`
4
+ fi
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-1.9.3-p362@cms
data/.travis.yml ADDED
@@ -0,0 +1,2 @@
1
+ rvm: 1.9.2
2
+ script: "bundle exec rake db:drop db:create db:migrate test"
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rails', '>=3.1.0'
4
+ gem 'paperclip', '>=2.3.0'
5
+ gem 'jquery-rails', '>=1.0.14'
6
+ gem 'haml', '~>4.0.1'
7
+
8
+ group :development do
9
+ gem 'sqlite3'
10
+ gem 'jeweler'
11
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 The Working Group
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+
2
+ Sweet Portfolio is an image gallery engine for Rails 3.1 apps. Also it integrates with ComfortableMexicanSofa CMS Engine
3
+
4
+ ## Installation
5
+
6
+ Add gem definition to your Gemfile:
7
+
8
+ gem 'sweet_portfolio'
9
+
10
+ Then from the Rails project's root run:
11
+
12
+ bundle install
13
+ rails generate sweet_portfolio
14
+ rake db:migrate
15
+
16
+ ## Usage
17
+
18
+ You can immediately access admin area by going to /admin/galleries.
19
+
20
+ If you are using Sweet Portfolio on it's own take a look in the initializer: [/config/initializers/sweet\_portfolio.rb]( https://github.com/stephenmmcleod/sweet-portfolio/blob/master/config/initializers/sweet_portfolio.rb)
21
+ You probably want to set the admin controller to be something that handles user authentication within your app. Same goes for the admin\_route\_prefix.
22
+
23
+ If you are using SweetPortfolio in conjunction with ComfortableMexicanSofa everything will be configured automatically.
24
+
25
+ Also you may use provided [ColorBox](http://jacklmoore.com/colorbox/) javascript to display galleries. Just declare these for asset pipeline
26
+
27
+ // in app/assets/javascripts/application.js
28
+ //= require sweet_portfolio/jquery.colorbox
29
+
30
+ // in app/assets/stylesheets/application.css
31
+ //= require sweet_portfolio/colorbox
32
+
33
+ ---
34
+
35
+ CMS Gallery is released under the [MIT license](https://github.com/stephenmmcleod/sweet-portfolio/raw/master/LICENSE)
36
+
37
+ Copyright 2013 Stephen McLeod
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require File.expand_path('../config/application', __FILE__)
2
+ require 'rubygems'
3
+ require 'rake'
4
+
5
+ SweetPortfolio::Application.load_tasks
6
+
7
+ begin
8
+ require 'jeweler'
9
+ Jeweler::Tasks.new do |gem|
10
+ gem.name = 'sweet_portfolio'
11
+ gem.homepage = 'https://github.com/stephenmmcleod/sweet-portfolio'
12
+ gem.license = 'MIT'
13
+ gem.summary = ''
14
+ gem.description = 'Sweet Portfolio is an image gallery engine with nice frontend capabilities for Rails 3.1 apps (and ComfortableMexicanSofa)'
15
+ gem.email = 'work@stephenmmcleod.com'
16
+ gem.authors = ['Stephen McLeod', 'The Working Group Inc.']
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,4 @@
1
+ // ColorBox v1.3.19 - jQuery lightbox plugin
2
+ // (c) 2011 Jack Moore - jacklmoore.com
3
+ // License: http://www.opensource.org/licenses/mit-license.php
4
+ (function(a,b,c){function Z(c,d,e){var g=b.createElement(c);return d&&(g.id=f+d),e&&(g.style.cssText=e),a(g)}function $(a){var b=y.length,c=(Q+a)%b;return c<0?b+c:c}function _(a,b){return Math.round((/%/.test(a)?(b==="x"?z.width():z.height())/100:1)*parseInt(a,10))}function ba(a){return K.photo||/\.(gif|png|jpe?g|bmp|ico)((#|\?).*)?$/i.test(a)}function bb(){var b;K=a.extend({},a.data(P,e));for(b in K)a.isFunction(K[b])&&b.slice(0,2)!=="on"&&(K[b]=K[b].call(P));K.rel=K.rel||P.rel||"nofollow",K.href=K.href||a(P).attr("href"),K.title=K.title||P.title,typeof K.href=="string"&&(K.href=a.trim(K.href))}function bc(b,c){a.event.trigger(b),c&&c.call(P)}function bd(){var a,b=f+"Slideshow_",c="click."+f,d,e,g;K.slideshow&&y[1]?(d=function(){F.text(K.slideshowStop).unbind(c).bind(j,function(){if(K.loop||y[Q+1])a=setTimeout(W.next,K.slideshowSpeed)}).bind(i,function(){clearTimeout(a)}).one(c+" "+k,e),r.removeClass(b+"off").addClass(b+"on"),a=setTimeout(W.next,K.slideshowSpeed)},e=function(){clearTimeout(a),F.text(K.slideshowStart).unbind([j,i,k,c].join(" ")).one(c,function(){W.next(),d()}),r.removeClass(b+"on").addClass(b+"off")},K.slideshowAuto?d():e()):r.removeClass(b+"off "+b+"on")}function be(b){U||(P=b,bb(),y=a(P),Q=0,K.rel!=="nofollow"&&(y=a("."+g).filter(function(){var b=a.data(this,e).rel||this.rel;return b===K.rel}),Q=y.index(P),Q===-1&&(y=y.add(P),Q=y.length-1)),S||(S=T=!0,r.show(),K.returnFocus&&a(P).blur().one(l,function(){a(this).focus()}),q.css({opacity:+K.opacity,cursor:K.overlayClose?"pointer":"auto"}).show(),K.w=_(K.initialWidth,"x"),K.h=_(K.initialHeight,"y"),W.position(),o&&z.bind("resize."+p+" scroll."+p,function(){q.css({width:z.width(),height:z.height(),top:z.scrollTop(),left:z.scrollLeft()})}).trigger("resize."+p),bc(h,K.onOpen),J.add(D).hide(),I.html(K.close).show()),W.load(!0))}function bf(){!r&&b.body&&(Y=!1,z=a(c),r=Z(X).attr({id:e,"class":n?f+(o?"IE6":"IE"):""}).hide(),q=Z(X,"Overlay",o?"position:absolute":"").hide(),s=Z(X,"Wrapper"),t=Z(X,"Content").append(A=Z(X,"LoadedContent","width:0; height:0; overflow:hidden"),C=Z(X,"LoadingOverlay").add(Z(X,"LoadingGraphic")),D=Z(X,"Title"),E=Z(X,"Current"),G=Z(X,"Next"),H=Z(X,"Previous"),F=Z(X,"Slideshow").bind(h,bd),I=Z(X,"Close")),s.append(Z(X).append(Z(X,"TopLeft"),u=Z(X,"TopCenter"),Z(X,"TopRight")),Z(X,!1,"clear:left").append(v=Z(X,"MiddleLeft"),t,w=Z(X,"MiddleRight")),Z(X,!1,"clear:left").append(Z(X,"BottomLeft"),x=Z(X,"BottomCenter"),Z(X,"BottomRight"))).find("div div").css({"float":"left"}),B=Z(X,!1,"position:absolute; width:9999px; visibility:hidden; display:none"),J=G.add(H).add(E).add(F),a(b.body).append(q,r.append(s,B)))}function bg(){return r?(Y||(Y=!0,L=u.height()+x.height()+t.outerHeight(!0)-t.height(),M=v.width()+w.width()+t.outerWidth(!0)-t.width(),N=A.outerHeight(!0),O=A.outerWidth(!0),r.css({"padding-bottom":L,"padding-right":M}),G.click(function(){W.next()}),H.click(function(){W.prev()}),I.click(function(){W.close()}),q.click(function(){K.overlayClose&&W.close()}),a(b).bind("keydown."+f,function(a){var b=a.keyCode;S&&K.escKey&&b===27&&(a.preventDefault(),W.close()),S&&K.arrowKey&&y[1]&&(b===37?(a.preventDefault(),H.click()):b===39&&(a.preventDefault(),G.click()))}),a("."+g,b).live("click",function(a){a.which>1||a.shiftKey||a.altKey||a.metaKey||(a.preventDefault(),be(this))})),!0):!1}var d={transition:"elastic",speed:300,width:!1,initialWidth:"600",innerWidth:!1,maxWidth:!1,height:!1,initialHeight:"450",innerHeight:!1,maxHeight:!1,scalePhotos:!0,scrolling:!0,inline:!1,html:!1,iframe:!1,fastIframe:!0,photo:!1,href:!1,title:!1,rel:!1,opacity:.9,preloading:!0,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:!1,returnFocus:!0,reposition:!0,loop:!0,slideshow:!1,slideshowAuto:!0,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:!1,onLoad:!1,onComplete:!1,onCleanup:!1,onClosed:!1,overlayClose:!0,escKey:!0,arrowKey:!0,top:!1,bottom:!1,left:!1,right:!1,fixed:!1,data:undefined},e="colorbox",f="cbox",g=f+"Element",h=f+"_open",i=f+"_load",j=f+"_complete",k=f+"_cleanup",l=f+"_closed",m=f+"_purge",n=!a.support.opacity&&!a.support.style,o=n&&!c.XMLHttpRequest,p=f+"_IE6",q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X="div",Y;if(a.colorbox)return;a(bf),W=a.fn[e]=a[e]=function(b,c){var f=this;b=b||{},bf();if(bg()){if(!f[0]){if(f.selector)return f;f=a("<a/>"),b.open=!0}c&&(b.onComplete=c),f.each(function(){a.data(this,e,a.extend({},a.data(this,e)||d,b))}).addClass(g),(a.isFunction(b.open)&&b.open.call(f)||b.open)&&be(f[0])}return f},W.position=function(a,b){function i(a){u[0].style.width=x[0].style.width=t[0].style.width=a.style.width,t[0].style.height=v[0].style.height=w[0].style.height=a.style.height}var c=0,d=0,e=r.offset(),g=z.scrollTop(),h=z.scrollLeft();z.unbind("resize."+f),r.css({top:-9e4,left:-9e4}),K.fixed&&!o?(e.top-=g,e.left-=h,r.css({position:"fixed"})):(c=g,d=h,r.css({position:"absolute"})),K.right!==!1?d+=Math.max(z.width()-K.w-O-M-_(K.right,"x"),0):K.left!==!1?d+=_(K.left,"x"):d+=Math.round(Math.max(z.width()-K.w-O-M,0)/2),K.bottom!==!1?c+=Math.max(z.height()-K.h-N-L-_(K.bottom,"y"),0):K.top!==!1?c+=_(K.top,"y"):c+=Math.round(Math.max(z.height()-K.h-N-L,0)/2),r.css({top:e.top,left:e.left}),a=r.width()===K.w+O&&r.height()===K.h+N?0:a||0,s[0].style.width=s[0].style.height="9999px",r.dequeue().animate({width:K.w+O,height:K.h+N,top:c,left:d},{duration:a,complete:function(){i(this),T=!1,s[0].style.width=K.w+O+M+"px",s[0].style.height=K.h+N+L+"px",K.reposition&&setTimeout(function(){z.bind("resize."+f,W.position)},1),b&&b()},step:function(){i(this)}})},W.resize=function(a){S&&(a=a||{},a.width&&(K.w=_(a.width,"x")-O-M),a.innerWidth&&(K.w=_(a.innerWidth,"x")),A.css({width:K.w}),a.height&&(K.h=_(a.height,"y")-N-L),a.innerHeight&&(K.h=_(a.innerHeight,"y")),!a.innerHeight&&!a.height&&(A.css({height:"auto"}),K.h=A.height()),A.css({height:K.h}),W.position(K.transition==="none"?0:K.speed))},W.prep=function(b){function g(){return K.w=K.w||A.width(),K.w=K.mw&&K.mw<K.w?K.mw:K.w,K.w}function h(){return K.h=K.h||A.height(),K.h=K.mh&&K.mh<K.h?K.mh:K.h,K.h}if(!S)return;var c,d=K.transition==="none"?0:K.speed;A.remove(),A=Z(X,"LoadedContent").append(b),A.hide().appendTo(B.show()).css({width:g(),overflow:K.scrolling?"auto":"hidden"}).css({height:h()}).prependTo(t),B.hide(),a(R).css({"float":"none"}),o&&a("select").not(r.find("select")).filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one(k,function(){this.style.visibility="inherit"}),c=function(){function q(){n&&r[0].style.removeAttribute("filter")}var b,c,g=y.length,h,i="frameBorder",k="allowTransparency",l,o,p;if(!S)return;l=function(){clearTimeout(V),C.hide(),bc(j,K.onComplete)},n&&R&&A.fadeIn(100),D.html(K.title).add(A).show();if(g>1){typeof K.current=="string"&&E.html(K.current.replace("{current}",Q+1).replace("{total}",g)).show(),G[K.loop||Q<g-1?"show":"hide"]().html(K.next),H[K.loop||Q?"show":"hide"]().html(K.previous),K.slideshow&&F.show();if(K.preloading){b=[$(-1),$(1)];while(c=y[b.pop()])o=a.data(c,e).href||c.href,a.isFunction(o)&&(o=o.call(c)),ba(o)&&(p=new Image,p.src=o)}}else J.hide();K.iframe?(h=Z("iframe")[0],i in h&&(h[i]=0),k in h&&(h[k]="true"),h.name=f+ +(new Date),K.fastIframe?l():a(h).one("load",l),h.src=K.href,K.scrolling||(h.scrolling="no"),a(h).addClass(f+"Iframe").appendTo(A).one(m,function(){h.src="//about:blank"})):l(),K.transition==="fade"?r.fadeTo(d,1,q):q()},K.transition==="fade"?r.fadeTo(d,0,function(){W.position(0,c)}):W.position(d,c)},W.load=function(b){var c,d,e=W.prep;T=!0,R=!1,P=y[Q],b||bb(),bc(m),bc(i,K.onLoad),K.h=K.height?_(K.height,"y")-N-L:K.innerHeight&&_(K.innerHeight,"y"),K.w=K.width?_(K.width,"x")-O-M:K.innerWidth&&_(K.innerWidth,"x"),K.mw=K.w,K.mh=K.h,K.maxWidth&&(K.mw=_(K.maxWidth,"x")-O-M,K.mw=K.w&&K.w<K.mw?K.w:K.mw),K.maxHeight&&(K.mh=_(K.maxHeight,"y")-N-L,K.mh=K.h&&K.h<K.mh?K.h:K.mh),c=K.href,V=setTimeout(function(){C.show()},100),K.inline?(Z(X).hide().insertBefore(a(c)[0]).one(m,function(){a(this).replaceWith(A.children())}),e(a(c))):K.iframe?e(" "):K.html?e(K.html):ba(c)?(a(R=new Image).addClass(f+"Photo").error(function(){K.title=!1,e(Z(X,"Error").text("This image could not be loaded"))}).load(function(){var a;R.onload=null,K.scalePhotos&&(d=function(){R.height-=R.height*a,R.width-=R.width*a},K.mw&&R.width>K.mw&&(a=(R.width-K.mw)/R.width,d()),K.mh&&R.height>K.mh&&(a=(R.height-K.mh)/R.height,d())),K.h&&(R.style.marginTop=Math.max(K.h-R.height,0)/2+"px"),y[1]&&(K.loop||y[Q+1])&&(R.style.cursor="pointer",R.onclick=function(){W.next()}),n&&(R.style.msInterpolationMode="bicubic"),setTimeout(function(){e(R)},1)}),setTimeout(function(){R.src=c},1)):c&&B.load(c,K.data,function(b,c,d){e(c==="error"?Z(X,"Error").text("Request unsuccessful: "+d.statusText):a(this).contents())})},W.next=function(){!T&&y[1]&&(K.loop||y[Q+1])&&(Q=$(1),W.load())},W.prev=function(){!T&&y[1]&&(K.loop||Q)&&(Q=$(-1),W.load())},W.close=function(){S&&!U&&(U=!0,S=!1,bc(k,K.onCleanup),z.unbind("."+f+" ."+p),q.fadeTo(200,0),r.stop().fadeTo(300,0,function(){r.add(q).css({opacity:1,cursor:"auto"}).hide(),bc(m),A.remove(),setTimeout(function(){U=!1,bc(l,K.onClosed)},1)}))},W.remove=function(){a([]).add(r).add(q).remove(),r=null,a("."+g).removeData(e).removeClass(g).die()},W.element=function(){return a(P)},W.settings=d})(jQuery,document,this);
@@ -0,0 +1,196 @@
1
+ /*!
2
+ * Media helper for fancyBox
3
+ * version: 1.0.5 (Tue, 23 Oct 2012)
4
+ * @requires fancyBox v2.0 or later
5
+ *
6
+ * Usage:
7
+ * $(".fancybox").fancybox({
8
+ * helpers : {
9
+ * media: true
10
+ * }
11
+ * });
12
+ *
13
+ * Set custom URL parameters:
14
+ * $(".fancybox").fancybox({
15
+ * helpers : {
16
+ * media: {
17
+ * youtube : {
18
+ * params : {
19
+ * autoplay : 0
20
+ * }
21
+ * }
22
+ * }
23
+ * }
24
+ * });
25
+ *
26
+ * Or:
27
+ * $(".fancybox").fancybox({,
28
+ * helpers : {
29
+ * media: true
30
+ * },
31
+ * youtube : {
32
+ * autoplay: 0
33
+ * }
34
+ * });
35
+ *
36
+ * Supports:
37
+ *
38
+ * Youtube
39
+ * http://www.youtube.com/watch?v=opj24KnzrWo
40
+ * http://www.youtube.com/embed/opj24KnzrWo
41
+ * http://youtu.be/opj24KnzrWo
42
+ * Vimeo
43
+ * http://vimeo.com/40648169
44
+ * http://vimeo.com/channels/staffpicks/38843628
45
+ * http://vimeo.com/groups/surrealism/videos/36516384
46
+ * http://player.vimeo.com/video/45074303
47
+ * Metacafe
48
+ * http://www.metacafe.com/watch/7635964/dr_seuss_the_lorax_movie_trailer/
49
+ * http://www.metacafe.com/watch/7635964/
50
+ * Dailymotion
51
+ * http://www.dailymotion.com/video/xoytqh_dr-seuss-the-lorax-premiere_people
52
+ * Twitvid
53
+ * http://twitvid.com/QY7MD
54
+ * Twitpic
55
+ * http://twitpic.com/7p93st
56
+ * Instagram
57
+ * http://instagr.am/p/IejkuUGxQn/
58
+ * http://instagram.com/p/IejkuUGxQn/
59
+ * Google maps
60
+ * http://maps.google.com/maps?q=Eiffel+Tower,+Avenue+Gustave+Eiffel,+Paris,+France&t=h&z=17
61
+ * http://maps.google.com/?ll=48.857995,2.294297&spn=0.007666,0.021136&t=m&z=16
62
+ * http://maps.google.com/?ll=48.859463,2.292626&spn=0.000965,0.002642&t=m&z=19&layer=c&cbll=48.859524,2.292532&panoid=YJ0lq28OOy3VT2IqIuVY0g&cbp=12,151.58,,0,-15.56
63
+ */
64
+ (function ($) {
65
+ "use strict";
66
+
67
+ //Shortcut for fancyBox object
68
+ var F = $.fancybox,
69
+ format = function( url, rez, params ) {
70
+ params = params || '';
71
+
72
+ if ( $.type( params ) === "object" ) {
73
+ params = $.param(params, true);
74
+ }
75
+
76
+ $.each(rez, function(key, value) {
77
+ url = url.replace( '$' + key, value || '' );
78
+ });
79
+
80
+ if (params.length) {
81
+ url += ( url.indexOf('?') > 0 ? '&' : '?' ) + params;
82
+ }
83
+
84
+ return url;
85
+ };
86
+
87
+ //Add helper object
88
+ F.helpers.media = {
89
+ defaults : {
90
+ youtube : {
91
+ matcher : /(youtube\.com|youtu\.be)\/(watch\?v=|v\/|u\/|embed\/?)?(videoseries\?list=(.*)|[\w-]{11}|\?listType=(.*)&list=(.*)).*/i,
92
+ params : {
93
+ autoplay : 1,
94
+ autohide : 1,
95
+ fs : 1,
96
+ rel : 0,
97
+ hd : 1,
98
+ wmode : 'opaque',
99
+ enablejsapi : 1
100
+ },
101
+ type : 'iframe',
102
+ url : '//www.youtube.com/embed/$3'
103
+ },
104
+ vimeo : {
105
+ matcher : /(?:vimeo(?:pro)?.com)\/(?:[^\d]+)?(\d+)(?:.*)/,
106
+ params : {
107
+ autoplay : 1,
108
+ hd : 1,
109
+ show_title : 1,
110
+ show_byline : 1,
111
+ show_portrait : 0,
112
+ fullscreen : 1
113
+ },
114
+ type : 'iframe',
115
+ url : '//player.vimeo.com/video/$1'
116
+ },
117
+ metacafe : {
118
+ matcher : /metacafe.com\/(?:watch|fplayer)\/([\w\-]{1,10})/,
119
+ params : {
120
+ autoPlay : 'yes'
121
+ },
122
+ type : 'swf',
123
+ url : function( rez, params, obj ) {
124
+ obj.swf.flashVars = 'playerVars=' + $.param( params, true );
125
+
126
+ return '//www.metacafe.com/fplayer/' + rez[1] + '/.swf';
127
+ }
128
+ },
129
+ dailymotion : {
130
+ matcher : /dailymotion.com\/video\/(.*)\/?(.*)/,
131
+ params : {
132
+ additionalInfos : 0,
133
+ autoStart : 1
134
+ },
135
+ type : 'swf',
136
+ url : '//www.dailymotion.com/swf/video/$1'
137
+ },
138
+ twitvid : {
139
+ matcher : /twitvid\.com\/([a-zA-Z0-9_\-\?\=]+)/i,
140
+ params : {
141
+ autoplay : 0
142
+ },
143
+ type : 'iframe',
144
+ url : '//www.twitvid.com/embed.php?guid=$1'
145
+ },
146
+ twitpic : {
147
+ matcher : /twitpic\.com\/(?!(?:place|photos|events)\/)([a-zA-Z0-9\?\=\-]+)/i,
148
+ type : 'image',
149
+ url : '//twitpic.com/show/full/$1/'
150
+ },
151
+ instagram : {
152
+ matcher : /(instagr\.am|instagram\.com)\/p\/([a-zA-Z0-9_\-]+)\/?/i,
153
+ type : 'image',
154
+ url : '//$1/p/$2/media/'
155
+ },
156
+ google_maps : {
157
+ matcher : /maps\.google\.([a-z]{2,3}(\.[a-z]{2})?)\/(\?ll=|maps\?)(.*)/i,
158
+ type : 'iframe',
159
+ url : function( rez ) {
160
+ return '//maps.google.' + rez[1] + '/' + rez[3] + '' + rez[4] + '&output=' + (rez[4].indexOf('layer=c') > 0 ? 'svembed' : 'embed');
161
+ }
162
+ }
163
+ },
164
+
165
+ beforeLoad : function(opts, obj) {
166
+ var url = obj.href || '',
167
+ type = false,
168
+ what,
169
+ item,
170
+ rez,
171
+ params;
172
+
173
+ for (what in opts) {
174
+ item = opts[ what ];
175
+ rez = url.match( item.matcher );
176
+
177
+ if (rez) {
178
+ type = item.type;
179
+ params = $.extend(true, {}, item.params, obj[ what ] || ($.isPlainObject(opts[ what ]) ? opts[ what ].params : null));
180
+
181
+ url = $.type( item.url ) === "function" ? item.url.call( this, rez, params, obj ) : format( item.url, rez, params );
182
+
183
+ break;
184
+ }
185
+ }
186
+
187
+ if (type) {
188
+ obj.href = url;
189
+ obj.type = type;
190
+
191
+ obj.autoHeight = false;
192
+ }
193
+ }
194
+ };
195
+
196
+ }(jQuery));
@@ -0,0 +1,162 @@
1
+ /*!
2
+ * Thumbnail helper for fancyBox
3
+ * version: 1.0.7 (Mon, 01 Oct 2012)
4
+ * @requires fancyBox v2.0 or later
5
+ *
6
+ * Usage:
7
+ * $(".fancybox").fancybox({
8
+ * helpers : {
9
+ * thumbs: {
10
+ * width : 50,
11
+ * height : 50
12
+ * }
13
+ * }
14
+ * });
15
+ *
16
+ */
17
+ (function ($) {
18
+ //Shortcut for fancyBox object
19
+ var F = $.fancybox;
20
+
21
+ //Add helper object
22
+ F.helpers.thumbs = {
23
+ defaults : {
24
+ width : 50, // thumbnail width
25
+ height : 50, // thumbnail height
26
+ position : 'bottom', // 'top' or 'bottom'
27
+ source : function ( item ) { // function to obtain the URL of the thumbnail image
28
+ var href;
29
+
30
+ if (item.element) {
31
+ href = $(item.element).find('img').attr('src');
32
+ }
33
+
34
+ if (!href && item.type === 'image' && item.href) {
35
+ href = item.href;
36
+ }
37
+
38
+ return href;
39
+ }
40
+ },
41
+
42
+ wrap : null,
43
+ list : null,
44
+ width : 0,
45
+
46
+ init: function (opts, obj) {
47
+ var that = this,
48
+ list,
49
+ thumbWidth = opts.width,
50
+ thumbHeight = opts.height,
51
+ thumbSource = opts.source;
52
+
53
+ //Build list structure
54
+ list = '';
55
+
56
+ for (var n = 0; n < obj.group.length; n++) {
57
+ list += '<li><a style="width:' + thumbWidth + 'px;height:' + thumbHeight + 'px;" href="javascript:jQuery.fancybox.jumpto(' + n + ');"></a></li>';
58
+ }
59
+
60
+ this.wrap = $('<div id="fancybox-thumbs"></div>').addClass(opts.position).appendTo('body');
61
+ this.list = $('<ul>' + list + '</ul>').appendTo(this.wrap);
62
+
63
+ //Load each thumbnail
64
+ $.each(obj.group, function (i) {
65
+ var href = thumbSource( obj.group[ i ] );
66
+
67
+ if (!href) {
68
+ return;
69
+ }
70
+
71
+ $("<img />").load(function () {
72
+ var width = this.width,
73
+ height = this.height,
74
+ widthRatio, heightRatio, parent;
75
+
76
+ if (!that.list || !width || !height) {
77
+ return;
78
+ }
79
+
80
+ //Calculate thumbnail width/height and center it
81
+ widthRatio = width / thumbWidth;
82
+ heightRatio = height / thumbHeight;
83
+
84
+ parent = that.list.children().eq(i).find('a');
85
+
86
+ if (widthRatio >= 1 && heightRatio >= 1) {
87
+ if (widthRatio > heightRatio) {
88
+ width = Math.floor(width / heightRatio);
89
+ height = thumbHeight;
90
+
91
+ } else {
92
+ width = thumbWidth;
93
+ height = Math.floor(height / widthRatio);
94
+ }
95
+ }
96
+
97
+ $(this).css({
98
+ width : width,
99
+ height : height,
100
+ top : Math.floor(thumbHeight / 2 - height / 2),
101
+ left : Math.floor(thumbWidth / 2 - width / 2)
102
+ });
103
+
104
+ parent.width(thumbWidth).height(thumbHeight);
105
+
106
+ $(this).hide().appendTo(parent).fadeIn(300);
107
+
108
+ }).attr('src', href);
109
+ });
110
+
111
+ //Set initial width
112
+ this.width = this.list.children().eq(0).outerWidth(true);
113
+
114
+ this.list.width(this.width * (obj.group.length + 1)).css('left', Math.floor($(window).width() * 0.5 - (obj.index * this.width + this.width * 0.5)));
115
+ },
116
+
117
+ beforeLoad: function (opts, obj) {
118
+ //Remove self if gallery do not have at least two items
119
+ if (obj.group.length < 2) {
120
+ obj.helpers.thumbs = false;
121
+
122
+ return;
123
+ }
124
+
125
+ //Increase bottom margin to give space for thumbs
126
+ obj.margin[ opts.position === 'top' ? 0 : 2 ] += ((opts.height) + 15);
127
+ },
128
+
129
+ afterShow: function (opts, obj) {
130
+ //Check if exists and create or update list
131
+ if (this.list) {
132
+ this.onUpdate(opts, obj);
133
+
134
+ } else {
135
+ this.init(opts, obj);
136
+ }
137
+
138
+ //Set active element
139
+ this.list.children().removeClass('active').eq(obj.index).addClass('active');
140
+ },
141
+
142
+ //Center list
143
+ onUpdate: function (opts, obj) {
144
+ if (this.list) {
145
+ this.list.stop(true).animate({
146
+ 'left': Math.floor($(window).width() * 0.5 - (obj.index * this.width + this.width * 0.5))
147
+ }, 150);
148
+ }
149
+ },
150
+
151
+ beforeClose: function () {
152
+ if (this.wrap) {
153
+ this.wrap.remove();
154
+ }
155
+
156
+ this.wrap = null;
157
+ this.list = null;
158
+ this.width = 0;
159
+ }
160
+ }
161
+
162
+ }(jQuery));