Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add jcarousel

  • Loading branch information...
commit 2743a5058670aca74a8cf850d95b52a40cb1f3be 1 parent 40cda2c
Ken Duret authored
91 inc/jigoshop_functions.php
... ... @@ -1,9 +1,6 @@
1 1 <?php
2   -/* Stylesheet */
3   -function add_jigo_styles() {
4   - wp_enqueue_style('jigoshop', get_bloginfo('template_directory').'/jigoshop.css' . false, '1.0' );
5   -}
6   -add_action('wp_head', 'add_jigo_styles');
  2 +global $wpdb ;
  3 +
7 4 /* Content Wrappers */
8 5
9 6 function k_jigo_open_jigoshop_content_wrappers()
@@ -39,56 +36,40 @@ function jigoshop_get_product_thumbnail( $size = 'thumbnail' ) {
39 36 }
40 37 }
41 38
42   -// Home Page reecent products
43   -function k_jigo_recent() {
44   - echo '<div id="recent-products-home">';
45   - echo '<h2>Recently Added Products</h2>';
46   - // Set up query for recent products
47   - $query_args = array(
48   - 'showposts' => 5,
49   - 'post_type' => 'product',
50   - 'post_status' => 'publish',
51   - 'orderby' => 'date',
52   - 'order' => 'ASC',
53   - 'meta_query' => array(
54   - array(
55   - 'key' => 'visibility',
56   - 'value' => array('catalog', 'visible'),
57   - 'compare' => 'IN',
58   - ),
59   - )
60   - );
61   - $recent_jigo = new WP_Query($query_args);
62   -
63   - // If there are products
64   - if($recent_jigo->have_posts()) {
65   - // Open the list
66   - echo '<ul class="products">';
67   -
68   - // Print out each product
69   - while($recent_jigo->have_posts()) : $recent_jigo->the_post();
70   -
71   - // Get new jigoshop_product instance
72   - $_product = new jigoshop_product(get_the_ID());
73   -
74   - echo '<li class="product">';
75   - // Print the product image & title with a link to the permalink
76   - echo '<a href="'.get_permalink().'" title="'.esc_attr(get_the_title()).'">';
77   - echo (has_post_thumbnail()) ? the_post_thumbnail('thumbnail') : jigoshop_get_image_placeholder('shop_thumbnail');
78   - echo '<span class="k-jigo-recent-title">' . get_the_title() . '</span>';
79   - echo '</a>';
80   -
81   - // Print the price with html wrappers
82   - echo '<span class="k-jigo-recent-price">' . $_product->get_price_html() . '</span>';
83   - do_action('jigoshop_after_shop_loop_item', $post, $_product);
84   - echo '</li>';
85   - endwhile;
86   -
87   - echo '</ul>'; // Close the list
88   -
89   - wp_reset_postdata(); }
90   -
91   - echo '</div><!-- recent products home --><div style="clear:both;"></div>';
  39 +//Mini cart in header
  40 +if (of_get_option('show_mini_cart')) {
  41 +
  42 +function jigo_mini_cart() {
  43 + $extras = "<div class=\"header-mini-cart\">";
  44 + $extras .= '<a href="'.jigoshop_cart::get_cart_url().'" class="minicart">';
  45 + $extras .= '<span>';
  46 + $extras .= jigoshop_cart::$cart_contents_count.' items';
  47 + $extras .= '</span>';
  48 + $extras .= jigoshop_cart::get_cart_total();
  49 + $extras .= '</a>';
  50 + $extras .= "</div>";
  51 + echo apply_filters ('child_header_extras',$extras);
  52 +}
  53 +} // endif
  54 +
  55 +// Home Page featured products [featured_products per_page="12" columns="4"]
  56 +if (of_get_option('show_featured')) {
  57 + function k_jigo_featured() {
  58 + echo '<h3 class="widget-title">Featured Products</h3>';
  59 + if ( of_get_option('show_carousel_featured')) { echo '<div id="k-jigo-carousel-featured" class="k-jigo-carousel jcarousel">'; }
  60 + echo do_shortcode('[featured_products per_page="' . of_get_option('show_count_featured') . '" columns="5"]');
  61 + if ( of_get_option('show_carousel_featured')) { echo '</div>'; }
  62 + }
  63 +}
  64 +
  65 +// Home Page recent products [recent_products per_page="12" columns="4"]
  66 +if (of_get_option('show_recent')) {
  67 + function k_jigo_recent() {
  68 + echo '<h3 class="widget-title">Recent Products</h3>';
  69 + if ( of_get_option('show_carousel_recent')) { echo '<div id="k-jigo-carousel-recent" class="k-jigo-carousel jcarousel">'; }
  70 + echo do_shortcode('[recent_products per_page="' . of_get_option('show_count_recent') . '" columns="5"]');
  71 + if ( of_get_option('show_carousel_recent')) { echo '</div>'; }
  72 + }
92 73 }
93 74
94 75 if (!function_exists('jigoshop_get_sidebar')) {
16 js/jcarousel.min.js
... ... @@ -0,0 +1,16 @@
  1 +/*!
  2 + * jCarousel - Riding carousels with jQuery
  3 + * http://sorgalla.com/jcarousel/
  4 + *
  5 + * Copyright (c) 2006 Jan Sorgalla (http://sorgalla.com)
  6 + * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
  7 + * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
  8 + *
  9 + * Built on top of the jQuery library
  10 + * http://jquery.com
  11 + *
  12 + * Inspired by the "Carousel Component" by Bill Scott
  13 + * http://billwscott.com/carousel/
  14 + */
  15 +
  16 +(function(a,b){var c=typeof b.jCarouselAutoInstall!=="undefined"?b.jCarouselAutoInstall:true;var d=b.jCarousel={};d.version="@VERSION";var e=b.jCarousel;d.noConflict=function(){b.jCarousel=e;return this};d.intval=function(a){a=parseInt(a,10);return isNaN(a)?0:a};var f=/^([+\-]=)?(.+)$/;d.parseTarget=function(a){var b=false,c=typeof a!=="object"?f.exec(a):null;if(c){a=d.intval(c[2]);if(c[1]){b=true;if(c[1]==="-="){a*=-1}}}else if(typeof a!=="object"){a=d.intval(a)}return{target:a,relative:b}};d.detectCarousel=function(b){var c=b.data("jcarousel"),d=function(b){var c;b.find("*").each(function(){c=a.data(this,"jcarousel");if(c){return false}});return c};if(!c){while(b.size()>0){c=d(b);if(c){break}b=b.parent()}}return c};d.Plugin={version:d.version,options:{},pluginName:"jcarousel",pluginPrefix:"jcarousel",pluginFn:"jcarousel",_element:null,_carousel:null,_options:a.noop,_init:a.noop,_destroy:a.noop,_create:function(){this.carousel()._bind("destroy."+this.pluginName,a.proxy(this.destroy,this))},destroy:function(){this._destroy();this.carousel()._unbind("."+this.pluginName).element().unbind("."+this.pluginName);this.element().unbind("."+this.pluginName).removeData(this.pluginName);return this},element:function(){return this._element},option:function(b,c){if(arguments.length===0){return a.extend({},this.options)}if(typeof b==="string"){if(typeof c==="undefined"){return typeof this.options[b]==="undefined"?null:this.options[b]}this.options[b]=c}else{if(a.isFunction(b)){b=b.call(this)}this.options=a.extend({},this.options,b)}return this},carousel:function(){if(!!this.options.carousel){return this.options.carousel.jquery?this.options.carousel.data("jcarousel"):this.options.carousel}if(!this._carousel){this._carousel=d.detectCarousel(this.element());if(!this._carousel){a.error('Could not detect carousel for plugin "'+this.pluginName+'"')}}return this._carousel},_bind:function(a,b,c){(c||this.element()).bind(this.pluginName+a,b);return this},_unbind:function(a,b,c){(c||this.element()).unbind(this.pluginName+a,b);return this},_trigger:function(b,c,d,e){e=a.Event(e);e.type=(this.pluginName+b).toLowerCase();d=[this].concat(d||[]);if(e.originalEvent){for(var f=a.event.props.length,g;f;){g=a.event.props[--f];e[g]=e.originalEvent[g]}}(c||this.element()).trigger(e,d);return!e.isDefaultPrevented()}};var g=function(a,b,c,e){var f,g,h;if(c!=="jcarousel"){f="jcarousel"+c.toLowerCase();g="jcarousel-"+c.toLowerCase();h="jcarousel"+c.charAt(0).toUpperCase()+c.slice(1)}else{f=g=h=c}var i=function(b,c){if(!this._init){return new i(b,c)}this._element=a(b).data(f,this);this.options=a.extend({},this.options,this._options(),c);this._create();this._init()};i.prototype=a.extend({},d.Plugin,{pluginName:f,pluginPrefix:g,pluginFn:h},e.call(d,a,b));b[h]=function(b){var c=Array.prototype.slice.call(arguments,1),d=this;if(typeof b==="string"){this.each(function(){var e=a.data(this,f);if(!e){return a.error("Cannot call methods on "+h+" prior to initialization; "+'attempted to call method "'+b+'"')}if(!a.isFunction(e[b])||b.charAt(0)==="_"){return a.error('No such method "'+b+'" for '+h+" instance")}var g=e[b].apply(e,c);if(g!==e&&typeof g!=="undefined"){d=g;return false}})}else{this.each(function(){var c=a.data(this,f);if(c){if(b){c.option(b)}}else{i(this,b)}})}return d}};d.plugins={};d.plugin=function(b,e){d.plugins[b]=e;if(c!==false){g(a,a.fn,b,e)}};d.install=function(a,b){b=b||a.fn;a.each(d.plugins,function(c,d){g(a,b,c,d)})};d.plugin("jcarousel",function(a){var c=this;return{options:{list:">ul:eq(0)",items:">li",animation:"normal",wrap:null,vertical:null,rtl:null,center:false},animating:false,tail:0,inTail:false,resizeTimer:null,lt:null,vertical:false,rtl:false,circular:false,_list:null,_items:null,_target:null,_first:null,_last:null,_visible:null,_fullyvisible:null,_create:function(){},_init:function(){if(false===this._trigger("init")){return this}this._reload();var c=this;this.onWindowResize=function(){if(c.resizeTimer){clearTimeout(c.resizeTimer)}c.resizeTimer=setTimeout(function(){c.reload()},100)};a(b).bind("resize.jcarousel",this.onWindowResize);this.onAnimationComplete=function(b){c.animating=false;var d=c.list().find(".jcarousel-clone");if(d.size()>0){d.remove();c._reload()}c._trigger("animateEnd");if(a.isFunction(b)){b.call(c,true)}};this._trigger("initEnd");return this},destroy:function(){if(false===this._trigger("destroy")){return this}this.element().unbind("."+this.pluginName).removeData(this.pluginName);this.items().unbind(".jcarousel");a(b).unbind("resize.jcarousel",this.onWindowResize);this._trigger("destroyend");return this},reload:function(){if(false===this._trigger("reload")){return this}this._reload();this._trigger("reloadEnd");return this},list:function(){if(this._list===null){this._list=this.element().find(this.option("list"))}return this._list},items:function(){if(this._items===null){this._items=this.list().find(this.option("items")).not(".jcarousel-clone")}return this._items},target:function(){return this._target},first:function(){return this._first},last:function(){return this._last},visible:function(){return this._visible},fullyvisible:function(){return this._fullyvisible},hasNext:function(){var a=this.option("wrap"),b=this.items().size()-1;return b>=0&&(a&&a!=="first"||this._last.index()<b||this.tail&&!this.inTail)?true:false},hasPrev:function(){var a=this.option("wrap");return this.items().size()>0&&(a&&a!=="last"||this._first.index()>0||this.tail&&this.inTail)?true:false},scroll:function(b,d,e){if(this.animating){return this}if(false===this._trigger("scroll",null,[b,d])){return this}if(a.isFunction(d)){e=d;d=true}var f=c.parseTarget(b);if(f.relative){var g=this.items().size()-1,h=Math.abs(f.target),i,j,k,l;if(f.target>0){var m=this._last.index();if(m>=g&&this.tail){if(!this.inTail){this._scrollTail(d,e)}else{if(this.options.wrap=="both"||this.options.wrap=="last"){this._scroll(0,d,e)}else{this._scroll(Math.min(this._target.index()+h,g),d,e)}}}else{if(m===g&&(this.options.wrap=="both"||this.options.wrap=="last")){return this._scroll(0,d,e)}else{i=this._target.index();j=i+h;if(this.circular&&j>g){l=g;k=this.items().get(-1);while(l++<j){k=this.items().eq(0);k.after(k.clone(true).addClass("jcarousel-clone"));this.list().append(k);this._items=null}this._scroll(k,d,e)}else{this._scroll(Math.min(j,g),d,e)}}}}else{if(this.inTail){this._scroll(Math.max(this._first.index()-h+1,0),d,e)}else{i=this._target.index();j=i-h;if(i===0&&(this.options.wrap=="both"||this.options.wrap=="first")){this._scroll(g,d,e)}else{if(this.circular&&j<0){l=j;k=this.items().get(0);while(l++<0){k=this.items().eq(-1);k.after(k.clone(true).addClass("jcarousel-clone"));this.list().prepend(k);this._items=null;var n=c.intval(this.list().css(this.lt)),o=this._dimension(k);this.rtl?n+=o:n-=o;this.list().css(this.lt,n+"px")}this._scroll(k,d,e)}else{this._scroll(Math.max(i-h,0),d,e)}}}}}else{this._scroll(f.target,d,e)}this._trigger("scrollend");return this},_reload:function(){var b=this.element();this.vertical=this.options.vertical==null?(""+b.attr("class")).toLowerCase().indexOf("jcarousel-vertical")>-1:this.options.vertical;this.rtl=this.options.rtl==null?(""+b.attr("dir")).toLowerCase()==="rtl"||b.parents("[dir]").filter(function(){return/rtl/i.test(a(this).attr("dir"))}).size()>0:this.options.rtl;this.lt=this.vertical?"top":"left";this._items=null;var c=this._target||this.items().eq(0);this.circular=false;this.list().css({left:0,top:0});if(c.size()>0){this._prepare(c);this.list().find(".jcarousel-clone").remove();this._items=null;this.circular=this.options.wrap=="circular"&&this._fullyvisible.size()<this.items().size();this.list().css(this.lt,this._position(c)+"px")}return this},_scroll:function(b,d,e){if(this.animating){return this}if(typeof b!=="object"){b=this.items().eq(b)}if(b.size()===0){if(a.isFunction(e)){e.call(this,false)}return this}this.inTail=false;this._prepare(b);var f=this._position(b);if(f==c.intval(this.list().css(this.lt))){if(a.isFunction(e)){e.call(this,false)}return this}var g={};g[this.lt]=f+"px";this._animate(g,d,e);return this},_scrollTail:function(a,b){if(this.animating||!this.tail){return this}var c=this.list().position()[this.lt];this.rtl?c+=this.tail:c-=this.tail;this.inTail=true;var d={};d[this.lt]=c+"px";this._update({target:this._target.next(),fullyvisible:this._fullyvisible.slice(1).add(this._visible.last())});this._animate(d,a,b);return this},_animate:function(b,c,d){if(this.animating){return this}if(false===this._trigger("animate")){return this}this.animating=true;if(!this.options.animation||c===false){this.list().css(b);this.onAnimationComplete(d)}else{var e=this,f=typeof this.options.animation==="object"?this.options.animation:{duration:this.options.animation},g=f.complete;f.complete=function(){e.onAnimationComplete(d);if(a.isFunction(g)){g.call(this)}};this.list().animate(b,f)}return this},_prepare:function(b){var d=b.index(),e=d,f=this._dimension(b),g=this._clipping(),h={target:b,first:b,last:b,visible:b,fullyvisible:f<=g?b:a()},i=this.vertical?"bottom":this.rtl?"left":"right",j,k;if(this.options.center){f/=2;g/=2}if(f<g){while(true){j=this.items().eq(++e);if(j.size()===0){if(this.circular){j=this.items().eq(0);j.after(j.clone(true).addClass("jcarousel-clone"));this.list().append(j);this._items=null}else{break}}f+=this._dimension(j);h.last=j;h.visible=h.visible.add(j);k=c.intval(j.css("margin-"+i));if(f-k<=g){h.fullyvisible=h.fullyvisible.add(j)}if(f>=g){break}}}if(f<g){e=d;while(true){if(--e<0){break}j=this.items().eq(e);if(j.size()===0){break}f+=this._dimension(j);h.first=j;h.visible=h.visible.add(j);k=c.intval(j.css("margin-"+i));if(f-k<=g){h.fullyvisible=h.fullyvisible.add(j)}if(f>=g){break}}}this._update(h);this.tail=0;if(this.options.wrap!=="circular"&&this.options.wrap!=="custom"&&h.last.index()===this.items().size()-1){f-=c.intval(h.last.css("margin-"+i));if(f>g){this.tail=f-g}}return this},_position:function(a){var b=this._first,c=b.position()[this.lt];if(this.rtl&&!this.vertical){c-=this._clipping()-this._dimension(b)}if(this.options.center){c-=this._clipping()/2-this._dimension(b)/2}if((a.index()>b.index()||this.inTail)&&this.tail){c=this.rtl?c-this.tail:c+this.tail;this.inTail=true}else{this.inTail=false}return-c},_update:function(b){var c=this,d={target:this._target||a(),first:this._first||a(),last:this._last||a(),visible:this._visible||a(),fullyvisible:this._fullyvisible||a()},e=(b.first||d.first).index()<d.first.index();a.each(b,function(b,f){var g=f.filter(function(){return a.inArray(this,d[b])<0}),h=d[b].filter(function(){return a.inArray(this,f)<0});if(e){g=a().pushStack(g.get().reverse())}else{h=a().pushStack(h.get().reverse())}c._trigger("item"+b+"in",g);c._trigger("item"+b+"out",h);d[b].removeClass("jcarousel-item-"+b);f.addClass("jcarousel-item-"+b);c["_"+b]=f});return this},_clipping:function(){return this.element()["inner"+(this.vertical?"Height":"Width")]()},_dimension:function(a){return this.vertical?a.innerHeight()+c.intval(a.css("margin-top"))+c.intval(a.css("margin-bottom"))+c.intval(a.css("border-top-width"))+c.intval(a.css("border-bottom-width")):a.innerWidth()+c.intval(a.css("margin-left"))+c.intval(a.css("margin-right"))+c.intval(a.css("border-left-width"))+c.intval(a.css("border-right-width"))}}})})(jQuery,window)
11 js/jcarousel.swipe.min.js
... ... @@ -0,0 +1,11 @@
  1 +/*!
  2 + * jCarousel Swipe Plugin v@VERSION
  3 + * http://sorgalla.com/jcarousel/
  4 + *
  5 + * Copyright 2011, Jan Sorgalla
  6 + * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
  7 + * or GPL Version 2 (http://www.opensource.org/licenses/gpl-2.0.php) licenses.
  8 + *
  9 + * Date: @DATE
  10 + */
  11 +jCarousel.plugin("swipe",function(a){var b=this;return{started:false,startX:null,startY:null,startPos:null,width:0,_init:function(){this.eventNames={mousedown:(a.vmouse?"v":"")+"mousedown."+this.pluginName,mousemove:(a.vmouse?"v":"")+"mousemove."+this.pluginName,mouseup:(a.vmouse?"v":"")+"mouseup."+this.pluginName};this.carousel().element().bind(this.eventNames.mousedown,a.proxy(this._start,this)).bind(this.eventNames.mouseup,a.proxy(this._stop,this)).bind(this.eventNames.mousemove,a.proxy(this._move,this)).bind("mouseleave."+this.pluginName,a.proxy(this._stop,this))},_start:function(c){var d=this.carousel();this.started=true;this.startPos=b.intval(d.list().css(d.lt));this.startX=b.intval(c.pageX);this.startY=b.intval(c.pageY);var e=0,f=0,g=d.vertical?"bottom":d.rtl?"left":"right";d.items().each(function(){var b=a(this);e+=d._dimension(b);f=b.css("margin-"+g)});this.width=e-b.intval(f);c.stopPropagation();c.preventDefault();return this},_stop:function(){var c=function(){var b=this,c=this.items(),d=this.list().position()[this.lt],e=c.eq(0),f=false;if(this.rtl&&!this.vertical){d=(d+this.list().width()-this._clipping())*-1}c.each(function(){var c=a(this),g=b._dimension(c);d+=g;e=c;if(f){return false}if(d>=0){if(Math.abs(d)<g/2){f=true}else{return false}}});this.scroll(e)};var d=this.carousel();if(d.rtl&&!d.vertical){var e=b.intval(d.list().css("right"));if(e>0){d.scroll(0)}else if(e<-(this.width-d._clipping())){d.scroll(-1)}else{c.apply(d)}}else{var f=b.intval(d.list().css(d.lt));if(f>0){d.scroll(0)}else if(f<-(this.width-d._clipping())){d.scroll(-1)}else{c.apply(d)}}this.started=false;this.startPos=this.startX=this.startY=null;return this},_move:function(a){if(!this.started){return this}var c=this.carousel();var d=c.vertical?this.startY-b.intval(a.pageY):this.startX-b.intval(a.pageX);c.list().stop(true,false).css(c.lt,Math.ceil(this.startPos-d)+"px");return this}}})

0 comments on commit 2743a50

Please sign in to comment.
Something went wrong with that request. Please try again.