spree_essential_menus 0.1.8 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,43 @@
1
+ $ ->
2
+ #root level
3
+ rt = true
4
+ root_li = $("ul.image_menu").find("li.first-level")
5
+
6
+ root_li.mouseover ->
7
+ parent_id = $("ul.subimage_menu").data("parent")
8
+ $("#"+parent_id).find("img.grey").first().stop().animate({"opacity": "1"}, "fast")
9
+ $("#"+parent_id).find("img.color").first().stop().animate({"opacity": "0"}, "slow")
10
+ $("ul.subimage_menu").data("parent", $(@).attr("id"))
11
+ $(@).find("img.grey").first().stop().animate({"opacity": "0"}, "fast")
12
+ $(@).find("img.color").first().stop().animate({"opacity": "1"}, "fast")
13
+ if $(@).find("ul").find("li").length == 0
14
+ $("ul.subimage_menu").stop(true, true).fadeTo(2000,0)
15
+ else
16
+ $("ul.subimage_menu").html $(@).find("ul").html()
17
+ if $("ul.subimage_menu").css('display') == 'none'
18
+ $("ul.subimage_menu").stop(true, true).slideDown("slow").css('display','block')
19
+ else
20
+ $("ul.subimage_menu").stop().fadeTo(500,1)
21
+
22
+ root_li.mouseout ->
23
+ #$(@).find("img.grey").first().stop().animate({"opacity": "1"}, "fast")
24
+ #$(@).find("img.color").first().stop().animate({"opacity": "0"}, "slow")
25
+
26
+ $(".menu_container").mouseleave (e) ->
27
+ $("ul.subimage_menu").stop(true, true).delay(100).fadeOut(2000)
28
+ parent_id = $("ul.subimage_menu").data("parent")
29
+ $("#"+parent_id).find("img.grey").first().stop().animate({"opacity": "1"}, "fast")
30
+ $("#"+parent_id).find("img.color").first().stop().animate({"opacity": "0"}, "slow")
31
+ #e.stopPropagation()
32
+
33
+ $("ul.subimage_menu").on "mouseover", "li.second-level", ->
34
+ $(@).find("img.grey").first().stop().animate({"opacity": "0"}, "fast")
35
+ $(@).find("div.label").first().addClass("over").stop().animate({"opacity":"0.4"}, "fast")
36
+
37
+ $("ul.subimage_menu").on "mouseout", "li.second-level", ->
38
+ $(@).find("img.grey").first().stop().animate({"opacity": "1"}, "fast")
39
+ $("ul.subimage_menu").data("parent", $(@).find("ul").attr("id"))
40
+ $(@).find("div.label").first().removeClass("over").stop().animate({"opacity":"1"}, "fast")
41
+
42
+
43
+ #podpisy
@@ -0,0 +1 @@
1
+ (function($){function TouchCarousel(g,h){this.carouselRoot=$(g);var j=this;this._az=false;this._by=false;this._cx="";this._dw="";this._ev="";this._fu;this._gt;this._hs;this._ir;this._jq;this._kp=0;this.settings=$.extend({},$.fn.touchCarousel.defaults,h);this._lo=this.carouselRoot.find(".touchcarousel-container");this._loStyle=this._lo[0].style;this._az1=this._lo.wrap($('<div class="touchcarousel-wrapper" />')).parent();var k=this._lo.find(".touchcarousel-item");this.items=[];this.numItems=k.length;this._by1;this._cx1=false;this._dw1=0;this._ev1=0;this._fu1=0;this._gt1=false;this._hs1=false;this._ir1=false;if('ontouchstart'in window){this.hasTouch=true;this._cx='touchstart.rs';this._dw='touchmove.rs';this._ev='touchend.rs';this._jq1=this.settings.baseTouchFriction}else{this.hasTouch=false;this._jq1=this.settings.baseMouseFriction;if(this.settings.dragUsingMouse){this._cx='mousedown.rs';this._dw='mousemove.rs';this._ev='mouseup.rs';this._kp1;this._lo1;var l=$.browser;if(l.msie||l.opera){this._kp1=this._lo1="move"}else if(l.mozilla){this._kp1="-moz-grab";this._lo1="-moz-grabbing"}this._mn1()}else{this._az1.addClass('auto-cursor')}}if(this.hasTouch||this.settings.useWebkit3d){if(('WebKitCSSMatrix'in window&&'m11'in new WebKitCSSMatrix())){this._lo.css({'-webkit-transform-origin':'0 0','-webkit-transform':'translateZ(0)'});this._ir1=true}}if(this._ir1){this._az2='-webkit-transform';this._by2='translate3d(';this._cx2='px, 0, 0)'}else{this._az2='left';this._by2='';this._cx2='px'}if(this.hasTouch){this.settings.directionNavAutoHide=false}if(!this.settings.directionNav){if(this.settings.loopItems){this._dw2=true;this._ev2=true}else{this._dw2=false;this._ev2=false}this.settings.loopItems=true}var m,jqItem,dataSRC,slideImg,currPosX=0;k.eq(this.numItems-1).addClass('last');k.each(function(c){jqItem=$(this);m={};m.item=jqItem;m.index=c;m.posX=currPosX;m.width=(jqItem.outerWidth(true)||j.settings.itemFallbackWidth);currPosX+=m.width;if(!this.hasTouch){jqItem.find('a').bind('click.touchcarousel',function(e){if(j._cx1){e.preventDefault();return false}})}else{var d=jqItem.find('a');var f;d.each(function(){f=$(this);f.data('tc-href',f.attr('href'));f.data('tc-target',f.attr('target'));f.attr('href','#');f.bind('click',function(e){e.preventDefault();if(j._cx1){return false}else{var a=$(this).data('tc-href');var b=$(this).data('tc-target');if(!b||b.toLowerCase()==='_fu2'){window.location.href=a}else{window.open(a)}}})})}jqItem.find('.non-draggable').bind(j._cx,function(e){j._cx1=false;e.stopImmediatePropagation()});j.items.push(m)});this._gt2=this._fu=currPosX;if(this.settings.itemsPerMove>0){this._hs2=this.settings.itemsPerMove}else{this._hs2=1}if(this.settings.pagingNav){this.settings.snapToItems=true;this._ir2=true;this._jq2=Math.ceil(this.numItems/this._hs2);this._kp2=0;if(this.settings.pagingNavControls){this._lo2=$('<div class="tc-paging-container"><div class="tc-paging-centerer"><div class="tc-paging-centerer-inside"></div></div></div>');var n=this._lo2.find('.tc-paging-centerer-inside');var o;for(var i=1;i<=this._jq2;i++){o=$('<a class="tc-paging-item" href="#">'+i+'</a>').data('tc-id',i);if(i===this._kp2+1){o.addClass('current')}n.append(o)}this._mn2=n.find(".tc-paging-item").click(function(e){e.preventDefault();j.goTo(($(e.currentTarget).data('tc-id')-1)*j._hs2)});this._az1.after(this._lo2)}}else{this._ir2=false}this._lo.css({width:currPosX});if(this.settings.directionNav){this._az1.after("<a href='#' class='arrow-holder left'><span class='arrow-icon left'></span></a> <a href='#' class='arrow-holder right'><span class='arrow-icon right'></span></a>");this.arrowLeft=this.carouselRoot.find(".arrow-holder.left");this.arrowRight=this.carouselRoot.find(".arrow-holder.right");if(this.arrowLeft.length<1||this.arrowRight.length<1){this.settings.directionNav=false}else if(this.settings.directionNavAutoHide){this.arrowLeft.hide();this.arrowRight.hide();this.carouselRoot.one("mousemove.arrowshover",function(){j.arrowLeft.fadeIn("fast");j.arrowRight.fadeIn("fast")});this.carouselRoot.hover(function(){j.arrowLeft.fadeIn("fast");j.arrowRight.fadeIn("fast")},function(){j.arrowLeft.fadeOut("fast");j.arrowRight.fadeOut("fast")})}this._by3(0);if(this.settings.directionNav){this.arrowRight.click(function(e){e.preventDefault();if(j.settings.loopItems&&!j._gt1||!j._ev2)j.next()});this.arrowLeft.click(function(e){e.preventDefault();if(j.settings.loopItems&&!j._gt1||!j._dw2)j.prev()})}}this.carouselWidth;this._cx3='onorientationchange'in window?'orientationchange.touchcarousel':'resize.touchcarousel';var p;$(window).bind(this._cx3,function(){if(p)clearTimeout(p);p=setTimeout(function(){j.updateCarouselSize(false)},100)});if(this.settings.scrollbar){this._dw3=$("<div class='scrollbar-holder'><div class='scrollbar"+(this.settings.scrollbarTheme.toLowerCase()==="light"?" light":" dark")+"'></div></div>");this._dw3.appendTo(this.carouselRoot);this.scrollbarJQ=this._dw3.find('.scrollbar');this._ev3="";this._fu3=this.scrollbarJQ[0].style;this._gt3=0;if(this.settings.scrollbarAutoHide){this._hs3=false;this.scrollbarJQ.css("opacity",0)}else{this._hs3=true}}else{this.settings.scrollbarAutoHide=false}this.updateCarouselSize(true);this._az1.bind(this._cx,function(e){j._ir3(e)});if(this.settings.autoplay&&this.settings.autoplayDelay>0){this._jq3=false;this.autoplayTimer='';this.wasAutoplayRunning=true;if(!this.hasTouch){this.carouselRoot.hover(function(){j._jq3=true;j._kp3()},function(){j._jq3=false;j._lo3()})}this.autoplay=true;this._mn3()}else{this.autoplay=false}if(this.settings.keyboardNav){$(document).bind("keydown.touchcarousel",function(e){if(!j._gt1){if(e.keyCode===37){j.prev()}else if(e.keyCode===39){j.next()}}})}this.carouselRoot.css("overflow","visible")}TouchCarousel.prototype={goTo:function(a,b){var c=this.items[a];if(c){if(!b&&this.autoplay&&this.settings.autoplayStopAtAction){this.stopAutoplay()}this._az4(a);this.endPos=this._by4();var d=-c.posX;if(d>0){d=0}else if(d<this.carouselWidth-this._gt2){d=this.carouselWidth-this._gt2}this.animateTo(d,this.settings.transitionSpeed,"easeInOutSine")}},next:function(a){var b=this._by4();var c=this._cx4(b).index;if(!this._ir2){c=c+this._hs2;if(this.settings.loopItems){if(b<=this.carouselWidth-this._gt2){c=0}}if(c>this.numItems-1){c=this.numItems-1}}else{var d=this._kp2+1;if(d>this._jq2-1){if(this.settings.loopItems){c=0}else{c=(this._jq2-1)*this._hs2}}else{c=d*this._hs2}}this.goTo(c,a)},prev:function(a){var b=this._by4();var c=this._cx4(b).index;if(!this._ir2){c=c-this._hs2;if(c<0){if(this.settings.loopItems){if(b<0){c=0}else{c=this.numItems-1}}else{c=0}}}else{var d=this._kp2-1;if(d<0){if(this.settings.loopItems){c=(this._jq2-1)*this._hs2}else{c=0}}else{c=d*this._hs2}}this.goTo(c,a)},getCurrentId:function(){var a=this._cx4(this._by4()).index;return a},setXPos:function(a,b){if(!b){this._loStyle[this._az2]=(this._by2+a+this._cx2)}else{this._fu3[this._az2]=(this._by2+a+this._cx2)}},stopAutoplay:function(){this._kp3();this.autoplay=false;this.wasAutoplayRunning=false},resumeAutoplay:function(){this.autoplay=true;if(!this.wasAutoplayRunning){this._lo3()}},updateCarouselSize:function(a){var b=this;this.carouselWidth=this.carouselRoot.width();if(this.settings.scrollToLast){var c=0;if(this._ir2){var d=(this.numItems%this._hs2);if(d>0){for(var i=this.numItems-d;i<this.numItems;i++){c+=this.items[i].width}}else{c=this.carouselWidth}}else{c=this.items[this.numItems-1].width}this._gt2=this._fu+this.carouselWidth-c}else{this._gt2=this._fu}if(this.settings.scrollbar){var e=Math.round(this._dw3.width()/(this._gt2/this.carouselWidth));this.scrollbarJQ.css('width',e);this._gt3=this._dw3.width()-e}if(!this.settings.scrollToLast){if(this.carouselWidth>=this._fu){this._hs1=true;if(!this.settings.loopItems){this._ev2=true;this.arrowRight.addClass("disabled");this._dw2=true;this.arrowLeft.addClass("disabled")}this.setXPos(0);return}else if(this._hs1){this._hs1=false;this._ev2=false;this._dw2=false;this.arrowRight.removeClass("disabled");this.arrowLeft.removeClass("disabled")}}if(!a){var f=this.endPos=this._by4();if(f>0){f=0}else if(f<this.carouselWidth-this._gt2){f=this.carouselWidth-this._gt2}this.animateTo(f,300,"easeInOutSine")}},animateTo:function(a,b,c,d,e,f,g){if(this.settings.onAnimStart!==null){this.settings.onAnimStart.call(this)}if(this.autoplay&&this.autoplayTimer){this.wasAutoplayRunning=true;this._kp3()}this._dw4();var h=this;var i=this.settings.scrollbar,prop=h._az2,pref=h._by2,suf=h._cx2,from={containerPos:this.endPos},to={containerPos:a},to2={containerPos:e},e=d?e:a,dContainer=h._loStyle;h._by=true;if(i){var j=this._fu3;var k=h._gt2-h.carouselWidth;if(this.settings.scrollbarAutoHide){if(!this._hs3){this._ev4()}}}this._by3(e);function animationComplete(){h._by=false;h._mn3();if(h.settings.scrollbarAutoHide){h._fu4()}if(h.settings.onAnimComplete!==null){h.settings.onAnimComplete.call(h)}}this._by1=$(from).animate(to,{duration:b,easing:c,step:function(){if(i){j[prop]=(pref+Math.round((h._gt3)*(-this.containerPos/k))+suf)}dContainer[prop]=(pref+Math.round(this.containerPos)+suf)},complete:function(){if(d){h._by1=$(to).animate(to2,{duration:f,easing:g,step:function(){if(i){j[prop]=(pref+Math.round((h._gt3)*(-this.containerPos/k))+suf)}dContainer[prop]=(pref+Math.round(this.containerPos)+suf)},complete:function(){if(i){j[prop]=(pref+Math.round((h._gt3)*(-to2.containerPos/k))+suf)}dContainer[prop]=(pref+Math.round(to2.containerPos)+suf);animationComplete()}})}else{if(i){j[prop]=(pref+Math.round((h._gt3)*(-to.containerPos/k))+suf)}dContainer[prop]=(pref+Math.round(to.containerPos)+suf);animationComplete()}}})},destroy:function(){this.stopAutoplay();this._az1.unbind(this._cx);$(document).unbind(this._dw).unbind(this._ev);$(window).unbind(this._cx3);if(this.settings.keyboardNav){$(document).unbind("keydown.touchcarousel")}this.carouselRoot.remove()},_az4:function(a){if(this._ir2){var b=this._gt4(a);this._kp2=b;if(this.settings.pagingNavControls){this._mn2.removeClass('current');this._mn2.eq(b).addClass('current')}}},_gt4:function(a){var b=this._hs2;for(var i=0;i<this._jq2;i++){if(a>=i*b&&a<i*b+b){return i}}if(a<0){return 0}else if(a>=this._jq2){return this._jq2-1}return false},_hs4:function(){if(!this.settings.loopItems){if(this._dw2){this._dw2=false;this.arrowLeft.removeClass("disabled")}else if(this._ev2){this._ev2=false;this.arrowRight.removeClass("disabled")}}},_az3:function(){if(!this._dw2&&!this.settings.loopItems){this._dw2=true;this.arrowLeft.addClass("disabled");if(this._ev2){this._ev2=false;this.arrowRight.removeClass("disabled")}}},_ir4:function(){if(!this._ev2&&!this.settings.loopItems){this._ev2=true;this.arrowRight.addClass("disabled");if(this._dw2){this._dw2=false;this.arrowLeft.removeClass("disabled")}}},_cx4:function(a){var b=this;a=-a;var c;for(var i=0;i<b.numItems;i++){c=b.items[i];if(a>=c.posX&&a<c.posX+c.width){return c}}return-1},_mn3:function(){if(this.autoplay){if(this.wasAutoplayRunning){if(!this._jq3){this._lo3()}this.wasAutoplayRunning=false}}},_fu4:function(){var a=this;this._hs3=false;if(this._ev3){clearTimeout(this._ev3)}this._ev3=setTimeout(function(){a.scrollbarJQ.animate({opacity:0},150,"linear")},450)},_ev4:function(){this._hs3=true;if(this._ev3){clearTimeout(this._ev3)}this.scrollbarJQ.stop().animate({opacity:1},150,"linear")},_dw4:function(){if(this._by1){this._by1.stop()}},_lo3:function(){if(this.autoplay){var a=this;if(!this.autoplayTimer){this.autoplayTimer=setInterval(function(){if(!a._jq4&&!a._by){a.next(true)}},this.settings.autoplayDelay)}}},_kp3:function(){if(this.autoplayTimer){clearInterval(this.autoplayTimer);this.autoplayTimer=''}},_by4:function(a){var b=!a?this._lo:this.scrollbarJQ;if(!this._ir1){return Math.round(b.position().left)}else{var c=b.css("-webkit-transform");var d=c.replace(/^matrix\(/i,'').split(/, |\)$/g);return parseInt(d[4],10)}},_ir3:function(e){if(!this._jq4){if(this.autoplay&&this.settings.autoplayStopAtAction){this.stopAutoplay()}this._dw4();if(this.settings.scrollbarAutoHide){this._ev4()}var a;if(this.hasTouch){this._az=false;var b=e.originalEvent.touches;if(b&&b.length>0){a=b[0]}else{return false}}else{a=e;e.preventDefault()}this._kp4();this._jq4=true;var c=this;if(this._ir1){c._lo.css({'-webkit-transition-duration':'0','-webkit-transition-property':'none'})}$(document).bind(this._dw,function(e){c._lo4(e)});$(document).bind(this._ev,function(e){c._mn4(e)});this._az5=this._by4();this._ir=a.clientX;this._cx1=false;this._kp=e.timeStamp||Date.now();this._fu1=0;this._ev1=this._dw1=a.clientX;this._by5=a.clientY}},_lo4:function(e){var a=(e.timeStamp||Date.now());var b;if(this.hasTouch){if(this._az){return false}var c=e.originalEvent.touches;if(c.length>1){return false}b=c[0];if(Math.abs(b.clientY-this._by5)>Math.abs(b.clientX-this._dw1)+3){if(this.settings.lockAxis){this._az=true}return false}e.preventDefault()}else{b=e;e.preventDefault()}this._jq=b.clientX;this._cx5=this._dw5;var d=b.clientX-this._ev1;if(this._cx5!=d){this._dw5=d}if(d!=0){var f=this._az5+this._fu1;if(f>=0){d=d/4;this._az3()}else if(f<=this.carouselWidth-this._gt2){this._ir4();d=d/4}else{this._hs4()}this._fu1+=d;this.setXPos(f);if(this.settings.scrollbar){this.setXPos((this._gt3)*(-f/(this._gt2-this.carouselWidth)),true)}}this._ev1=b.clientX;if(a-this._kp>350){this._kp=a;this._ir=b.clientX}if(this.settings.onDragStart!==null){this.settings.onDragStart.call(this)}return false},_mn4:function(e){if(this._jq4){var b=this;this._jq4=false;this._mn1();this.endPos=this._by4();this.isdrag=false;$(document).unbind(this._dw).unbind(this._ev);if(this.endPos==this._az5){this._cx1=false;if(this.settings.scrollbarAutoHide){this._fu4()}return}else{this._cx1=true}var c=(this._jq-this._ir);var d=Math.max(40,(e.timeStamp||Date.now())-this._kp);var f=0.5,mass=2,v0=Math.abs(c)/d;function getCorrectXPos(a){if(a>0){a=0}else if(a<b.carouselWidth-b._gt2){a=b.carouselWidth-b._gt2}return a}if(!this.settings.snapToItems){var g=0;if(v0<=2){f=this._jq1*3.5;g=0}else if(v0>2&&v0<=3){f=this._jq1*4;g=200}else if(v0>3){g=300;if(v0>4){v0=4;g=400;f=this._jq1*6}f=this._jq1*5}var S=(v0*v0*mass)/(2*f);S=S*(c<0?-1:1);var t=v0*mass/f+g;if(this.endPos+S>0){if(this.endPos>0){this.animateTo(0,800,"easeOutCubic")}else{this.animateTo((this.carouselWidth/10)*((g+200)/1000),(Math.abs(this.endPos)*1.1)/v0,"easeOutSine",true,0,400,"easeOutCubic")}}else if(this.endPos+S<this.carouselWidth-this._gt2){if(this.endPos<this.carouselWidth-this._gt2){this.animateTo(this.carouselWidth-this._gt2,800,"easeOutCubic")}else{this.animateTo(this.carouselWidth-this._gt2-(this.carouselWidth/10)*((g+200)/1000),(Math.abs(this.carouselWidth-this._gt2-this.endPos)*1.1)/v0,"easeOutSine",true,this.carouselWidth-this._gt2,400,"easeOutCubic")}}else{this.animateTo(this.endPos+S,t,"easeOutCubic")}}else{if(this.autoplay&&this.settings.autoplayStopAtAction){this.stopAutoplay()}var h=Boolean(this._dw1-this._ev1>0);var i=getCorrectXPos(this._by4());var j=this._cx4(i).index;if(!this._ir2){j=j+(h?this._hs2:(-this._hs2+1))}else{if(h){i=Math.max(i-this.carouselWidth-1,1-b._gt2);j=this._cx4(i).index;if(j===undefined){j=this.numItems-1}}var k=this._gt4(j);j=k*this._hs2}if(h){j=Math.min(j,this.numItems-1)}else{j=Math.max(j,0)}var l=this.items[j];this._az4(j);if(l){i=getCorrectXPos(-l.posX);var m=Math.abs(this.endPos-i);var n=Math.max((m*1.08)/v0,150);var o=Boolean(n<180);var p=m*0.08;if(h){p=p*-1}this.animateTo(o?(i+p):i,Math.min(n,400),"easeOutSine",o,i,300,"easeOutCubic")}}if(this.settings.onDragRelease!==null){this.settings.onDragRelease.call(this)}}return false},_by3:function(a){if(a===undefined){a=this._by4()}if(!this.settings.loopItems){if(a>=0){this._az3()}else if(a<=this.carouselWidth-this._gt2){this._ir4()}else{this._hs4()}}},_mn1:function(){if(this._kp1){this._az1.css('cursor',this._kp1)}else{this._az1.removeClass('grabbing-cursor');this._az1.addClass('grab-cursor')}},_kp4:function(){if(this._lo1){this._az1.css('cursor',this._lo1)}else{this._az1.removeClass('grab-cursor');this._az1.addClass('grabbing-cursor')}}};$.fn.touchCarousel=function(b){return this.each(function(){var a=new TouchCarousel($(this),b);$(this).data("touchCarousel",a)})};$.fn.touchCarousel.defaults={itemsPerMove:1,snapToItems:false,pagingNav:false,pagingNavControls:true,autoplay:false,autoplayDelay:3000,autoplayStopAtAction:true,scrollbar:true,scrollbarAutoHide:false,scrollbarTheme:"dark",transitionSpeed:600,directionNav:true,directionNavAutoHide:false,loopItems:false,keyboardNav:false,dragUsingMouse:true,scrollToLast:false,itemFallbackWidth:500,baseMouseFriction:0.0012,baseTouchFriction:0.0008,lockAxis:true,useWebkit3d:false,onAnimStart:null,onAnimComplete:null,onDragStart:null,onDragRelease:null};$.fn.touchCarousel.settings={};$.extend(jQuery.easing,{easeInOutSine:function(x,t,b,c,d){return-c/2*(Math.cos(Math.PI*t/d)-1)+b},easeOutSine:function(x,t,b,c,d){return c*Math.sin(t/d*(Math.PI/2))+b},easeOutCubic:function(x,t,b,c,d){return c*((t=t/d-1)*t*t+1)+b}})})(jQuery);
@@ -0,0 +1,14 @@
1
+ $ ->
2
+ window.onload = ->
3
+ $(".touchcarousel").touchCarousel
4
+ scrollbar: false
5
+ itemsPerMove: 4
6
+ snapToItems: true
7
+ loopItems: true
8
+ dragUsingMouse: false
9
+ if $(".touchcarousel").find("ul").find("li").length <= 4
10
+ $(".touchcarousel").find("a.arrow-holder").css('display','none')
11
+ $(".touchcarousel-item").mouseover ->
12
+ $(@).find("img.grey").first().stop().animate({"opacity": "0"}, "fast")
13
+ $(".touchcarousel-item").mouseout ->
14
+ $(@).find("img.grey").first().stop().animate({"opacity": "1"}, "fast")
@@ -1 +1,2 @@
1
1
  //= require store/spree_core
2
+ //= require store/image_menu
@@ -0,0 +1,3 @@
1
+ //= require store/image_menu
2
+ //= require store/jquery.touchcarousel.min
3
+ //= require store/slider_menu
@@ -0,0 +1,71 @@
1
+ $szary: #A7A7A7
2
+ $wysokosc_obrazka_submenu: 109px
3
+ $szerokosc_obrazka_submenu: 218px
4
+
5
+ ul.image_menu
6
+ display: block
7
+ text-align: center
8
+ height: 30px
9
+ width: 920px
10
+ &:hover
11
+ cursor: pointer
12
+ li
13
+ display: inline-block
14
+ position: relative
15
+ padding-left: 0px
16
+ height: auto
17
+ margin-left: 10px
18
+ img
19
+ display: block
20
+ &.grey
21
+ position: absolute
22
+ left: 0px
23
+ top: 0
24
+ &.color
25
+ opacity: 0
26
+ ul
27
+ display: none
28
+ padding: 0
29
+ position: relative
30
+ margin: auto
31
+ border: 1px solid $szary
32
+ height: auto
33
+ width: 875px
34
+ text-align: left
35
+ z-index: 100
36
+ background: image-url('store/image_menu_bg.png') repeat-x
37
+ li
38
+ margin: 0 -2px -4px auto
39
+ padding: 0
40
+ img.grey
41
+ left: 0px
42
+ img.color
43
+ opacity: 1
44
+ div.close
45
+ width: 60px
46
+ border-radius: 5px
47
+ position: absoulte
48
+ bottom: 0
49
+ right: 0
50
+ background: $szary
51
+ color: white
52
+ div.label
53
+ $wysokosc_etykiety: 20px
54
+ position: absolute
55
+ top: $wysokosc_obrazka_submenu - $wysokosc_etykiety
56
+ width: $szerokosc_obrazka_submenu
57
+ height: $wysokosc_etykiety
58
+ background-color: #F9F9F9
59
+ text-align: left
60
+ color: black
61
+ &.over
62
+ background-color: black
63
+ color: #F9F9F9
64
+ &.subimage_menu
65
+ min-height: 1px
66
+ div.subimage_menu_container
67
+ display: block
68
+ margin-top: 10px
69
+ div.clearfix
70
+ clear: both
71
+
@@ -0,0 +1,98 @@
1
+ @import compass
2
+ #slider
3
+ border-top: 1px solid #fff
4
+ +box-shadow(0 0 6px 1px rgba(0,0,0,0.3))
5
+ position: fixed
6
+ margin: auto
7
+ width: 100%
8
+ bottom: 35px
9
+ z-index: 10
10
+ padding: 5px 0
11
+ +background(mix(#BCBCBC, #fff) linear-gradient(#BCBCBC, #fff))
12
+ @extend .pie
13
+ .inner
14
+ width: 750px
15
+ margin: 0 auto
16
+
17
+ .touchcarousel
18
+ position: relative
19
+ overflow: hidden
20
+ .touchcarousel-container
21
+ position: relative
22
+ margin: 0
23
+ padding: 0
24
+ list-style: none
25
+ left: 0
26
+ width: 9999px
27
+ .touchcarousel-wrapper
28
+ position: relative
29
+ overflow: hidden
30
+ width: 100%
31
+ height: 100%
32
+ .touchcarousel-item
33
+ margin: 0 23px 0 0
34
+ padding: 0
35
+ float: left
36
+ border: 1px solid #818181
37
+ +border-radius(2px)
38
+ position: relative
39
+ img
40
+ display: block
41
+ &.grey
42
+ position: absolute
43
+ left: 0px
44
+ top: 0
45
+ &.color
46
+ &.last
47
+ margin-right: 0 !important
48
+ .arrow-holder
49
+ height: 100%
50
+ width: 45px
51
+ position: absolute
52
+ top: 0
53
+ display: block
54
+ cursor: pointer
55
+ z-index: 25
56
+ outline: none
57
+ &.left
58
+ left: 0
59
+ &.right
60
+ right: 0
61
+ .arrow-icon
62
+ top: 50%
63
+ margin-top: - (image_height('store/slider-prev.png') / 2)
64
+ position: absolute
65
+ cursor: pointer
66
+ &.left
67
+ +replace-text-with-dimensions('store/slider-prev.png')
68
+ left: -50px
69
+ &.right
70
+ +replace-text-with-dimensions('store/slider-next.png')
71
+ right: -50px
72
+ .arrow-holder
73
+ &:hover .arrow-icon
74
+ &.disabled
75
+ cursor: default
76
+ .arrow-icon
77
+ cursor: default
78
+ .tc-paging-container
79
+ width: 100%
80
+ overflow: hidden
81
+ position: absolute
82
+ margin-top: -20px
83
+ z-index: 25
84
+ .tc-paging-centerer
85
+ float: left
86
+ position: relative
87
+ left: 50%
88
+ .tc-paging-centerer-inside
89
+ float: left
90
+ position: relative
91
+ left: -50%
92
+ .tc-paging-item
93
+ float: left
94
+ cursor: pointer
95
+ position: relative
96
+ display: block
97
+ text-indent: -9999px
98
+
@@ -1,3 +1,4 @@
1
1
  /*
2
2
  *= require store/spree_core
3
+ *= require store/image_menu
3
4
  */
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require store/slider
3
+ */
@@ -42,7 +42,7 @@ class Spree::Admin::MenusController < Spree::Admin::ResourceController
42
42
  params[:q] ||= {}
43
43
  params[:q][:sort] ||= "menu_bar.asc"
44
44
  @search = parent.menus.search(params[:q])
45
- @collection = @search.result.page(params[:menu_bar]).per(Spree::Config[:orders_per_page])
45
+ @collection = @search.result#.page(params[:menu_bar]).per(Spree::Config[:orders_per_page])
46
46
  end
47
47
 
48
48
 
@@ -8,6 +8,8 @@ class Spree::Menu < ActiveRecord::Base
8
8
  attr_accessible :page_id, :sequence,:parent_id, :link_text, :url, :visible, :menu_bar_id
9
9
  alias_attribute :position, :sequence
10
10
 
11
+ attr_accessible :alt, :menu_image, :vieweable
12
+
11
13
  acts_as_tree :order => "sequence"
12
14
 
13
15
  #validates_presence_of :sequence
@@ -20,6 +22,23 @@ class Spree::Menu < ActiveRecord::Base
20
22
  default_scope order(:sequence)
21
23
  scope :visible, where(:visible => true)
22
24
 
25
+ has_attached_file :menu_image,
26
+ :styles => Proc.new{ |clip| clip.instance.attachment_sizes },
27
+ :default_style => :medium,
28
+ :url => '/spree/menus/:id/:style/:basename.:extension',
29
+ :path => ':rails_root/public/spree/menus/:id/:style/:basename.:extension'
30
+
31
+ def image_content?
32
+ menu_image_content_type.to_s.match(/\/(jpeg|png|gif|tiff|x-photoshop)/)
33
+ end
34
+
35
+ def attachment_sizes
36
+ hash = {}
37
+ hash.merge!(:mini => '48x48>', :greyscale => {:processors => [:grayscale]}) if image_content?
38
+ hash.merge!(:logo_color => '123x81>', :logo_grey => {:geometry => '123x81>', :processors => [:thumbnail,:grayscale]}) if parent_id.nil?
39
+ hash
40
+ end
41
+
23
42
  private
24
43
  def get_static_page_path
25
44
  if attribute_present?("page_id")
@@ -1,6 +1,7 @@
1
1
  class Spree::MenuBar < ActiveRecord::Base
2
2
 
3
3
  has_many :menus
4
+ has_many :images, :as => :viewable, :class_name => "Spree::MenuImage", :order => :position, :dependent => :destroy
4
5
 
5
6
  attr_accessible :name, :description, :css_class
6
7
 
@@ -24,15 +24,18 @@
24
24
  = form.label :visible, t('spree.admin.menus.visible')
25
25
  %em= t("spree.admin.menus.explain_visible")
26
26
  = error_message_on :menu, :visible
27
+
27
28
  %h3 Opcjonalnie
28
- - if Spree::Menu.all.count > 0 and false#turn off for futher improvement
29
+ - if Spree::Menu.all.count > 0 #and false#turn off for futher improvement
29
30
  = form.field_container :parent_id do
30
31
  = form.label :parent_id, t('spree.admin.menus.parent_id')
31
32
  %br
32
- = collection_select(:menu,:parent_id,Spree::Menu.where(:menu_bar_id => @menu_bar.id).all, :id, :link_text, :prompt => t("spree.admin.menus.select_parent"))
33
+ = collection_select(:menu,:parent_id,Spree::Menu.where(:menu_bar_id => @menu_bar.id, :parent_id => nil).all, :id, :link_text, :prompt => t("spree.admin.menus.select_parent"))
33
34
  %em= t("spree.admin.menus.explain_parent_id")
34
35
  = error_message_on :menu, :parent_id
35
-
36
+ = form.field_container :menu_image do
37
+ = form.label :menu_image, t('spree.admin.menus.menu_image')
38
+ = form.file_field :menu_image
36
39
 
37
40
 
38
41
  - if Spree::Page.all.count > 0
@@ -13,6 +13,8 @@
13
13
  %th= sort_link @search, :link_text, t('spree.admin.menus.link_text')
14
14
  %th= sort_link @search, :url, t('spree.admin.menus.url')
15
15
  %th= t('spree.admin.menus.page_id')
16
+ %th= t('spree.admin.menus.parent_id')
17
+ %th= t('spree.admin.menus.menu_image')
16
18
  %th= t('action')
17
19
  %tbody
18
20
  - @collection.each do |menu|
@@ -27,10 +29,21 @@
27
29
  = link_to menu.page.title
28
30
  - else
29
31
  = t('.static_path')
32
+ %td
33
+ - if menu.parent_id.nil?
34
+ -
35
+ - else
36
+ = menu.parent.link_text
37
+ %td
38
+ - if menu.menu_image.present?
39
+ = link_to image_tag(menu.menu_image.url(:mini)), menu.menu_image.url(:color), :target => "_blank"
40
+ - else
41
+ brak
30
42
  %td
31
43
  = link_to_edit menu
32
44
  &nbsp;
33
45
  = link_to_delete menu
46
+ =# paginate @collection
34
47
 
35
- = render :partial => 'spree/admin/shared/spree_menus_sidebar'
48
+ = render :partial => 'spree/admin/shared/spree_menus_sidebar', :locals => {:current => "menu_elements"}
36
49
 
@@ -0,0 +1,19 @@
1
+ - if menu_bar.present?
2
+ %div.menu_container
3
+ %ul{:class => "image_menu #{menu_bar.css_class}"}
4
+ - menu_bar.menus.visible.where(:parent_id => nil).each do |parent|
5
+ %li{:id => "element#{parent.id}", :class => "first-level"}
6
+ %a{:href => "#{parent.url}"}
7
+ = image_tag(parent.menu_image.url(:logo_color), :class => "color")
8
+ = image_tag(parent.menu_image.url(:logo_grey), :class => "grey")
9
+ - if parent.children.count > 0
10
+ %ul
11
+ - parent.children.each do |child|
12
+ %li.second-level{:"data-image-color" => child.menu_image.url(:original),:"data-image-grey" => child.menu_image.url(:greyscale)}
13
+ %a{:href => "#{child.url}"}
14
+ = image_tag(child.menu_image.url(:original), :class => "color")
15
+ = image_tag(child.menu_image.url(:greyscale), :class => "grey")
16
+ %div.label= child.link_text.upcase
17
+
18
+ %div.subimage_menu_container
19
+ %ul.subimage_menu
@@ -0,0 +1,10 @@
1
+ - if menu_bar.present?
2
+ %section#slider
3
+ .inner.touchcarousel
4
+ %ul.touchcarousel-container
5
+ - menu_bar.menus.visible.each do |menu|
6
+ %li{:class => "touchcarousel-item", :"data-href" => "#{menu.url}"}
7
+ =# link_to image_tag(menu.menu_image.url(:original)), menu.url
8
+ %a{:href => "menu.url"}
9
+ = image_tag(menu.menu_image.url(:original), :class => "color")
10
+ = image_tag(menu.menu_image.url(:greyscale), :class => "grey")
@@ -1,6 +1,7 @@
1
1
  pl:
2
2
  menus: Menu
3
3
  menu_bars: Paski menu
4
+ menu_images: Obrazki menu
4
5
 
5
6
  spree:
6
7
  admin:
@@ -26,8 +27,10 @@ pl:
26
27
  select_page_id: "Wybierz stronę statyczną"
27
28
  explain_page_id: "Wybierz stronę statyczną, do której odnosi się pozycja"
28
29
  sequence: "Kolejność"
30
+ menu_image: "Obrazek"
29
31
  menu_bars:
30
32
  list_of_menu_bars: "Lista pasków menu"
33
+ editing_menu_bar: "Edycja paska"
31
34
  new_menu_bar: "Nowy pasek menu"
32
35
  name: "Nazwa"
33
36
  description: "Krótki opis"
@@ -0,0 +1,8 @@
1
+ class AddMenuImagesToMenus < ActiveRecord::Migration
2
+ def change
3
+ add_column :spree_menus, :menu_image_file_name, :string
4
+ add_column :spree_menus, :menu_image_content_type, :string
5
+ add_column :spree_menus, :menu_image_file_size, :integer
6
+ add_column :spree_menus, :menu_image_updated_at, :datetime
7
+ end
8
+ end
@@ -0,0 +1,26 @@
1
+ module Paperclip
2
+ class Grayscale < Processor
3
+ def initialize file, options = {}, attachment = nil
4
+ super
5
+ @file = file
6
+ @current_format = File.extname(@file.path)
7
+ @basename = File.basename(@file.path, @current_format)
8
+ end
9
+
10
+ def make
11
+ dst = Tempfile.new(@basename)
12
+ dst.binmode
13
+
14
+ command = "#{File.expand_path(@file.path)} -colorspace Gray #{File.expand_path(dst.path)}"
15
+
16
+ begin
17
+ success = Paperclip.run("convert", command)
18
+ rescue PaperclipCommandLineError
19
+ raise PaperclipError, "There was an error converting the image to grayscale for #{@basename}"
20
+ end
21
+
22
+ dst
23
+ end
24
+ end
25
+ end
26
+
@@ -1,3 +1,3 @@
1
1
  module SpreeEssentialMenus
2
- VERSION = "0.1.8"
2
+ VERSION = "0.2.3"
3
3
  end
Binary file
@@ -12,15 +12,18 @@ Gem::Specification.new do |s|
12
12
  s.author = 'Grzegorz Brzezinka'
13
13
  s.email = 'grzegorz@brzezinka.eu'
14
14
  s.homepage = 'http://www.brzezinka.eu'
15
+ s.has_rdoc = false
15
16
 
16
17
  s.files = `git ls-files`.split("\n")
17
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
- s.require_path = 'lib'
19
+ s.require_paths = ['lib','lib/paperclip_processors']
19
20
  s.requirements << 'none'
20
21
 
21
22
  #s.add_dependency 'spree_core', '~> 1.1.0'
22
23
  # Spree Essentials
23
24
  s.add_runtime_dependency('spree_essentials', '~> 0.5.0.rc1')
25
+ s.add_runtime_dependency('coffee-rails')
26
+ s.add_runtime_dependency("acts_as_tree", '~> 0.2.0')
24
27
 
25
28
  s.add_runtime_dependency('haml')
26
29
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_essential_menus
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 8
10
- version: 0.1.8
8
+ - 2
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Grzegorz Brzezinka
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-05-07 00:00:00 Z
18
+ date: 2012-05-28 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: spree_essentials
@@ -36,7 +36,7 @@ dependencies:
36
36
  type: :runtime
37
37
  version_requirements: *id001
38
38
  - !ruby/object:Gem::Dependency
39
- name: haml
39
+ name: coffee-rails
40
40
  prerelease: false
41
41
  requirement: &id002 !ruby/object:Gem::Requirement
42
42
  none: false
@@ -50,9 +50,39 @@ dependencies:
50
50
  type: :runtime
51
51
  version_requirements: *id002
52
52
  - !ruby/object:Gem::Dependency
53
- name: capybara
53
+ name: acts_as_tree
54
54
  prerelease: false
55
55
  requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ hash: 23
61
+ segments:
62
+ - 0
63
+ - 2
64
+ - 0
65
+ version: 0.2.0
66
+ type: :runtime
67
+ version_requirements: *id003
68
+ - !ruby/object:Gem::Dependency
69
+ name: haml
70
+ prerelease: false
71
+ requirement: &id004 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ type: :runtime
81
+ version_requirements: *id004
82
+ - !ruby/object:Gem::Dependency
83
+ name: capybara
84
+ prerelease: false
85
+ requirement: &id005 !ruby/object:Gem::Requirement
56
86
  none: false
57
87
  requirements:
58
88
  - - "="
@@ -64,11 +94,11 @@ dependencies:
64
94
  - 1
65
95
  version: 1.0.1
66
96
  type: :development
67
- version_requirements: *id003
97
+ version_requirements: *id005
68
98
  - !ruby/object:Gem::Dependency
69
99
  name: factory_girl
70
100
  prerelease: false
71
- requirement: &id004 !ruby/object:Gem::Requirement
101
+ requirement: &id006 !ruby/object:Gem::Requirement
72
102
  none: false
73
103
  requirements:
74
104
  - - ~>
@@ -80,11 +110,11 @@ dependencies:
80
110
  - 4
81
111
  version: 2.6.4
82
112
  type: :development
83
- version_requirements: *id004
113
+ version_requirements: *id006
84
114
  - !ruby/object:Gem::Dependency
85
115
  name: ffaker
86
116
  prerelease: false
87
- requirement: &id005 !ruby/object:Gem::Requirement
117
+ requirement: &id007 !ruby/object:Gem::Requirement
88
118
  none: false
89
119
  requirements:
90
120
  - - ">="
@@ -94,11 +124,11 @@ dependencies:
94
124
  - 0
95
125
  version: "0"
96
126
  type: :development
97
- version_requirements: *id005
127
+ version_requirements: *id007
98
128
  - !ruby/object:Gem::Dependency
99
129
  name: rspec-rails
100
130
  prerelease: false
101
- requirement: &id006 !ruby/object:Gem::Requirement
131
+ requirement: &id008 !ruby/object:Gem::Requirement
102
132
  none: false
103
133
  requirements:
104
134
  - - ~>
@@ -109,11 +139,11 @@ dependencies:
109
139
  - 9
110
140
  version: "2.9"
111
141
  type: :development
112
- version_requirements: *id006
142
+ version_requirements: *id008
113
143
  - !ruby/object:Gem::Dependency
114
144
  name: sqlite3
115
145
  prerelease: false
116
- requirement: &id007 !ruby/object:Gem::Requirement
146
+ requirement: &id009 !ruby/object:Gem::Requirement
117
147
  none: false
118
148
  requirements:
119
149
  - - ">="
@@ -123,7 +153,7 @@ dependencies:
123
153
  - 0
124
154
  version: "0"
125
155
  type: :development
126
- version_requirements: *id007
156
+ version_requirements: *id009
127
157
  description: Add menu customization for Spree. It's designed to be used with the spree_essentials base.
128
158
  email: grzegorz@brzezinka.eu
129
159
  executables: []
@@ -141,11 +171,21 @@ files:
141
171
  - README.md
142
172
  - Rakefile
143
173
  - Versionfile
174
+ - app/assets/images/store/image_menu_bg.png
175
+ - app/assets/images/store/slider-next.png
176
+ - app/assets/images/store/slider-prev.png
144
177
  - app/assets/javascripts/admin/spree_essential_menus.js
178
+ - app/assets/javascripts/store/image_menu.js.coffee
179
+ - app/assets/javascripts/store/jquery.touchcarousel.min.js
180
+ - app/assets/javascripts/store/slider_menu.js.coffee
145
181
  - app/assets/javascripts/store/spree_essential_menus.js
182
+ - app/assets/javascripts/store/spree_essential_menus_slider.js
146
183
  - app/assets/stylesheets/admin/admin_tabs.css
147
184
  - app/assets/stylesheets/admin/spree_essential_menus.css
185
+ - app/assets/stylesheets/store/image_menu.css.sass
186
+ - app/assets/stylesheets/store/slider.css.sass
148
187
  - app/assets/stylesheets/store/spree_essential_menus.css
188
+ - app/assets/stylesheets/store/spree_essential_menus_slider.css
149
189
  - app/controllers/spree/admin/menu_bars_controller.rb
150
190
  - app/controllers/spree/admin/menus_controller.rb
151
191
  - app/models/spree/menu.rb
@@ -159,18 +199,23 @@ files:
159
199
  - app/views/spree/admin/menus/index.html.haml
160
200
  - app/views/spree/admin/menus/new.html.haml
161
201
  - app/views/spree/admin/shared/_spree_menus_sidebar.html.haml
202
+ - app/views/spree/shared/_render_image_menu.html.haml
162
203
  - app/views/spree/shared/_render_menu.html.haml
204
+ - app/views/spree/shared/_render_scroll_menu.html.haml
163
205
  - config/locales/en.yml
164
206
  - config/locales/pl.yml
165
207
  - config/routes.rb
166
208
  - db/migrate/20120424223831_create_spree_menu.rb
167
209
  - db/migrate/20120427043237_create_spree_menu_bars.rb
210
+ - db/migrate/20120509085046_add_menu_images_to_menus.rb
168
211
  - lib/generators/spree_essential_menus/install/install_generator.rb
212
+ - lib/paperclip_processors/grayscale.rb
169
213
  - lib/spree_essential_menus.rb
170
214
  - lib/spree_essential_menus/engine.rb
171
215
  - lib/spree_essential_menus/version.rb
172
216
  - script/rails
173
217
  - spec/spec_helper.rb
218
+ - spree_essential_menus-0.1.8.gem
174
219
  - spree_essential_menus.gemspec
175
220
  homepage: http://www.brzezinka.eu
176
221
  licenses: []
@@ -180,6 +225,7 @@ rdoc_options: []
180
225
 
181
226
  require_paths:
182
227
  - lib
228
+ - lib/paperclip_processors
183
229
  required_ruby_version: !ruby/object:Gem::Requirement
184
230
  none: false
185
231
  requirements: