/*!Extend touch.js*/


(function(i){var g={},b,k,h,e=750,a;function c(m){return"tagName" in m?m:m.parentNode}function j(n,m,p,o){var r=Math.abs(n-m),q=Math.abs(p-o);return r>=q?(n-m>0?"Left":"Right"):(p-o>0?"Up":"Down")}function l(){a=null;if(g.last){g.el.trigger("longTap");g={}}}function d(){if(a){clearTimeout(a)}a=null}function f(){if(b){clearTimeout(b)}if(k){clearTimeout(k)}if(h){clearTimeout(h)}if(a){clearTimeout(a)}b=k=h=a=null;g={}}i(document).ready(function(){var m,n;i(document.body).bind("touchstart",function(o){m=Date.now();n=m-(g.last||m);g.el=i(c(o.touches[0].target));b&&clearTimeout(b);g.x1=o.touches[0].pageX;g.y1=o.touches[0].pageY;if(n>0&&n<=250){g.isDoubleTap=true}g.last=m;a=setTimeout(l,e)}).bind("touchmove",function(o){d();g.x2=o.touches[0].pageX;g.y2=o.touches[0].pageY;if(Math.abs(g.x1-g.x2)>10){o.preventDefault()}}).bind("touchend",function(o){d();if((g.x2&&Math.abs(g.x1-g.x2)>30)||(g.y2&&Math.abs(g.y1-g.y2)>30)){h=setTimeout(function(){g.el.trigger("swipe");g.el.trigger("swipe"+(j(g.x1,g.x2,g.y1,g.y2)));g={}},0)}else{if("last" in g){k=setTimeout(function(){var p=i.Event("tap");p.cancelTouch=f;g.el.trigger(p);if(g.isDoubleTap){g.el.trigger("doubleTap");g={}}else{b=setTimeout(function(){b=null;g.el.trigger("singleTap");g={}},250)}},0)}}}).bind("touchcancel",f);i(window).bind("scroll",f)});["swipe","swipeLeft","swipeRight","swipeUp","swipeDown","doubleTap","tap","singleTap","longTap"].forEach(function(n){i.fn[n]=function(m){return this.bind(n,m)}})})(Zepto);

/*!Extend zepto.extend.js*/

(function(a){a.extend(a,{contains:function(b,c){return b.compareDocumentPosition?!!(b.compareDocumentPosition(c)&16):b!==c&&b.contains(c)}})})(Zepto);(function(a,c){a.extend(a,{toString:function(d){return Object.prototype.toString.call(d)},slice:function(e,d){return Array.prototype.slice.call(e,d||0)},later:function(f,d,h,e,g){return window["set"+(h?"Interval":"Timeout")](function(){f.apply(e,g)},d||0)},parseTpl:function(g,f){var d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+g.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/<%=([\s\S]+?)%>/g,function(h,i){return"',"+i.replace(/\\'/g,"'")+",'"}).replace(/<%([\s\S]+?)%>/g,function(h,i){return"');"+i.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+"__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');";var e=new Function("obj",d);return f?e(f):e},throttle:function(d,e,i){var g=0,f;if(typeof e!=="function"){i=e;e=d;d=250}function h(){var m=this,n=Date.now()-g,l=arguments;function k(){g=Date.now();e.apply(m,l)}function j(){f=c}if(i&&!f){k()}f&&clearTimeout(f);if(i===c&&n>d){k()}else{f=setTimeout(i?j:k,i===c?d-n:d)}}h._zid=e._zid=e._zid||a.proxy(e)._zid;return h},debounce:function(d,f,e){return f===c?a.throttle(250,d,false):a.throttle(d,f,e===c?false:e!==false)}});a.each("String Boolean RegExp Number Date Object Null Undefined".split(" "),function(e,d){var f;if("is"+d in a){return}switch(d){case"Null":f=function(g){return g===null};break;case"Undefined":f=function(g){return g===c};break;default:f=function(g){return new RegExp(d+"]","i").test(b(g))}}a["is"+d]=f});var b=a.toString})(Zepto);(function(d,g){var c=navigator.userAgent,a=navigator.appVersion,b=d.browser;d.extend(b,{qq:/qq/i.test(c),uc:/UC/i.test(c)||/UC/i.test(a)});b.uc=b.uc||!b.qq&&!b.chrome&&!b.firefox&&!/safari/i.test(c);try{b.version=b.uc?a.match(/UC(?:Browser)?\/([\d.]+)/)[1]:b.qq?c.match(/MQQBrowser\/([\d.]+)/)[1]:b.version}catch(f){}d.support=d.extend(d.support||{},{orientation:!(b.uc||(parseFloat(d.os.version)<5&&(b.qq||b.chrome)))&&!(d.os.android&&parseFloat(d.os.version)>3)&&"orientation" in window&&"onorientationchange" in window,touch:"ontouchend" in document,cssTransitions:"WebKitTransitionEvent" in window,has3d:"WebKitCSSMatrix" in window&&"m11" in new WebKitCSSMatrix()})})(Zepto);(function(b){b.matchMedia=(function(){var g=0,e="gmu-media-detect",d=b.fx.transitionEnd,h=b.fx.cssPrefix,f=b("<style></style>").append("."+e+"{"+h+"transition: width 0.001ms; width: 0; position: absolute; top: -10000px;}\n").appendTo("head");return function(k){var m=e+g++,l=b('<div class="'+e+'" id="'+m+'"></div>').appendTo("body"),j=[],i;f.append("@media "+k+" { #"+m+" { width: 1px; } }\n");if("matchMedia" in window){return window.matchMedia(k)}l.on(d,function(){i.matches=l.width()===1;b.each(j,function(n,o){b.isFunction(o)&&o.call(i,i)})});i={matches:l.width()===1,media:k,addListener:function(n){j.push(n);return this},removeListener:function(o){var n=j.indexOf(o);~n&&j.splice(n,1);return this}};return i}}());b(function(){var d=function(e){b(window).trigger("ortchange")};b.mediaQuery={ortchange:"screen and (width: "+window.innerWidth+"px)"};b.matchMedia(b.mediaQuery.ortchange).addListener(d)});function a(){b(window).on("scroll",b.debounce(80,function(){b(document).trigger("scrollStop")},false))}function c(){b(window).off("scroll");a()}a();b(window).on("pageshow",function(d){if(d.persisted){b(document).off("touchstart",c).one("touchstart",c)}})})(Zepto);

/*!Extend zepto.ui.js*/

(function(f,c){var b=1,e=function(){},j="<%=name%>-<%=id%>",h=(function(){var n={},o=0,m="GMUWidget"+(+new Date());return function(s,r,t){var p=s[m]||(s[m]=++o),q=n[p]||(n[p]={});!f.isUndefined(t)&&(q[r]=t);f.isNull(t)&&delete q[r];return q[r]}})();f.ui=f.ui||{version:"2.0.5",guid:g,define:function(n,p,o){if(o){p.inherit=o}var m=f.ui[n]=d(function(r,q){var s=k(m.prototype,{_id:f.parseTpl(j,{name:n,id:g()})});s._createWidget.call(s,r,q,m.plugins);return s},p);return i(n,m)},isWidget:function(n,m){return n instanceof (m===c?l:f.ui[m]||e)}};function g(){return b++}function k(m,n){var o={};Object.create?o=Object.create(m):o.__proto__=m;return f.extend(o,n||{})}function d(m,n){if(n){a(m,n);f.extend(m.prototype,n)}return f.extend(m,{plugins:[],register:function(o){if(f.isObject(o)){f.extend(this.prototype,o);return}this.plugins.push(o)}})}function a(m,p){var n=p.inherit||l,o=n.prototype,q;q=m.prototype=k(o,{$factory:m,$super:function(r){var s=o[r];return f.isFunction(s)?s.apply(this,f.slice(arguments,1)):s}});q._data=f.extend({},o._data,p._data);delete p._data;return m}function i(m){f.fn[m]=function(p){var o,q,n=f.slice(arguments,1);f.each(this,function(r,s){q=h(s,m)||f.ui[m](s,f.extend(f.isPlainObject(p)?p:{},{setup:true}));if(f.isString(p)){if(!f.isFunction(q[p])&&p!=="this"){throw new Error(m+"\u7ec4\u4ef6\u6ca1\u6709\u6b64\u65b9\u6cd5")}o=f.isFunction(q[p])?q[p].apply(q,n):c}if(o!==c&&o!==q||p==="this"&&(o=q)){return false}o=c});return o!==c?o:this}}var l=function(){};f.extend(l.prototype,{_data:{status:true},data:function(m,o){var n=this._data;if(f.isObject(m)){return f.extend(n,m)}else{return !f.isUndefined(o)?n[m]=o:n[m]}},_createWidget:function(o,q,m){if(f.isObject(o)){q=o||{};o=c}var r=f.extend({},this._data,q);f.extend(this,{_el:o?f(o):c,_data:r});var p=this;f.each(m,function(u,v){var s=v.apply(p);if(s&&f.isPlainObject(s)){var t=p._data.disablePlugin;if(!t||f.isString(t)&&!~t.indexOf(s.pluginName)){delete s.pluginName;f.each(s,function(w,y){var x;if((x=p[w])&&f.isFunction(y)){p[w]=function(){p[w+"Org"]=x;return y.apply(p,arguments)}}else{p[w]=y}})}}});if(r.setup){this._setup(o&&o.getAttribute("data-mode"))}else{this._create()}this._init();var p=this,n=this.trigger("init").root();n.on("tap",function(s){(s.bubblesList||(s.bubblesList=[])).push(p)});h(n[0],p._id.split("-")[0],p)},_create:function(){},_setup:function(m){},root:function(m){return this._el=m||this._el},id:function(m){return this._id=m||this._id},destroy:function(){var n=this,m;m=this.trigger("destroy").off().root();m.find("*").off();h(m[0],n._id.split("-")[0],null);m.off().remove();this.__proto__=null;f.each(this,function(o){delete n[o]})},on:function(m,n){this.root().on(m,f.proxy(n,this));return this},off:function(m,n){this.root().off(m,n);return this},trigger:function(n,o){n=f.isString(n)?f.Event(n):n;var p=this.data(n.type),m;if(p&&f.isFunction(p)){n.data=o;m=p.apply(this,[n].concat(o));if(m===false||n.defaultPrevented){return this}}this.root().trigger(n,o);return this}})})(Zepto);

(function() {
  /*!
  Copyright 2011 Gaetan Renaudeau
  http://greweb.fr/slider
  
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
  
  http://www.apache.org/licenses/LICENSE-2.0
  
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  */
  var Slider, SliderTransitionFunctions, SliderUtils, SliderWithCanvas, currentTime, mod, requestAnimationFrame, tmplSlider, tmplSliderWithCanvas;
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
    for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
    function ctor() { this.constructor = child; }
    ctor.prototype = parent.prototype;
    child.prototype = new ctor;
    child.__super__ = parent.prototype;
    return child;
  };
  mod = function(X, Y) {
    return X - Y * Math.floor(X / Y);
  };
  requestAnimationFrame = function(a,b){while(a--&&!(b=window["oR0msR0mozR0webkitR0r".split(0)[a]+"equestAnimationFrame"]));return b||function(a){setTimeout(a,15)}}(5);
  currentTime = function(){return new Date().getTime()};
  tmplSlider = function(o) {
    var slider;
    slider = $("<div class=\"slider\">\n  <div class=\"loader\"><span class=\"spinner\"></span> <span class=\"percent\">0</span>%</div>\n  <div class=\"slide-images\"></div>\n  <div class=\"options\">\n    <a class=\"prevSlide\" href=\"javascript:;\">prev</a>\n    <span class=\"slide-pager\"></span>\n    <a class=\"nextSlide\" href=\"javascript:;\">next</a>\n  </div>\n</div>");
    slider.find('.slide-images').append($.map(o.slides, function(slide) {
      return $('<div class="slide-image">' + (slide.link ? '<a href="' + slide.link + '" target="_blank">' : '') + '<img src="' + slide.src + '">' + (slide.name ? '<span class="caption">' + slide.name + '</span>' : '') + (slide.link ? '</a>' : '') + '</div>')[0];
    }));
    slider.find('.slide-pager').append($.map(o.slides, function(slide, i) {
      return $('<a href="javascript:;">' + (i + 1) + '</a>')[0];
    }));
    return slider;
  };
  tmplSliderWithCanvas = function(o) {
    var node;
    node = tmplSlider(o);
    node.find('div.slide-images').append('<canvas class="slide-images" />');
    return node;
  };
  SliderUtils = {
    extractImageData: function(self, from, to) {
      var fromData, height, output, toData, width, _ref;
      _ref = self.canvas[0], width = _ref.width, height = _ref.height;
      self.clean();
      self.drawImage(self.images[from]);
      fromData = self.ctx.getImageData(0, 0, width, height);
      self.clean();
      self.drawImage(self.images[to]);
      toData = self.ctx.getImageData(0, 0, width, height);
      output = self.ctx.createImageData(width, height);
      return {
        fromData: fromData,
        toData: toData,
        output: output
      };
    },
    clippedTransition: function(clipFunction) {
      return function(self, from, to, progress) {
        var ctx, height, width, _ref;
        _ref = self.canvas[0], width = _ref.width, height = _ref.height;
        ctx = self.ctx;
        self.drawImage(self.images[from]);
        ctx.save();
        ctx.beginPath();
        clipFunction(ctx, width, height, progress);
        ctx.clip();
        self.drawImage(self.images[to]);
        return ctx.restore();
      };
    }
  };
  SliderTransitionFunctions = {
    clock: {
      render: SliderUtils.clippedTransition(function(ctx, w, h, p) {
        ctx.moveTo(w / 2, h / 2);
        return ctx.arc(w / 2, h / 2, Math.max(w, h), 0, Math.PI * 2 * p, false);
      })
    },
    circle: {
      render: SliderUtils.clippedTransition(function(ctx, w, h, p) {
        return ctx.arc(w / 2, h / 2, 0.6 * p * Math.max(w, h), 0, Math.PI * 2, false);
      })
    },
    diamond: {
      render: SliderUtils.clippedTransition(function(ctx, w, h, p) {
        var dh, dw, h2, w2;
        w2 = w / 2;
        h2 = h / 2;
        dh = p * h;
        dw = p * w;
        ctx.moveTo(w2, h2 - dh);
        ctx.lineTo(w2 + dw, h2);
        ctx.lineTo(w2, h2 + dh);
        return ctx.lineTo(w2 - dw, h2);
      })
    },
    verticalOpen: {
      render: SliderUtils.clippedTransition(function(ctx, w, h, p) {
        var h1, h2, hi, nbSpike, pw, spikeh, spikel, spiker, spikew, xl, xr, _results;
        nbSpike = 8;
        spikeh = h / (2 * nbSpike);
        spikew = spikeh;
        pw = p * w / 2;
        xl = w / 2 - pw;
        xr = w / 2 + pw;
        spikel = xl - spikew;
        spiker = xr + spikew;
        ctx.moveTo(xl, 0);
        for (hi = 0; 0 <= nbSpike ? hi <= nbSpike : hi >= nbSpike; 0 <= nbSpike ? hi++ : hi--) {
          h1 = (2 * hi) * spikeh;
          h2 = h1 + spikeh;
          ctx.lineTo(spikel, h1);
          ctx.lineTo(xl, h2);
        }
        ctx.lineTo(spiker, h);
        _results = [];
        for (hi = nbSpike; nbSpike <= 0 ? hi <= 0 : hi >= 0; nbSpike <= 0 ? hi++ : hi--) {
          h1 = (2 * hi) * spikeh;
          h2 = h1 - spikeh;
          ctx.lineTo(xr, h1);
          _results.push(ctx.lineTo(spiker, h2));
        }
        return _results;
      })
    },
    horizontalOpen: {
      render: SliderUtils.clippedTransition(function(ctx, w, h, p) {
        return ctx.rect(0, (1 - p) * h / 2, w, h * p);
      })
    },
    horizontalSunblind: {
      render: SliderUtils.clippedTransition(function(ctx, w, h, p) {
        var blind, blindHeight, blinds, _results;
        p = 1 - (1 - p) * (1 - p);
        blinds = 6;
        blindHeight = h / blinds;
        _results = [];
        for (blind = 0; 0 <= blinds ? blind <= blinds : blind >= blinds; 0 <= blinds ? blind++ : blind--) {
          _results.push(ctx.rect(0, blindHeight * blind, w, blindHeight * p));
        }
        return _results;
      })
    },
    verticalSunblind: {
      render: SliderUtils.clippedTransition(function(ctx, w, h, p) {
        var blind, blindWidth, blinds, prog, _results;
        p = 1 - (1 - p) * (1 - p);
        blinds = 10;
        blindWidth = w / blinds;
        _results = [];
        for (blind = 0; 0 <= blinds ? blind <= blinds : blind >= blinds; 0 <= blinds ? blind++ : blind--) {
          prog = Math.max(0, Math.min(2 * p - (blind + 1) / blinds, 1));
          _results.push(ctx.rect(blindWidth * blind, 0, blindWidth * prog, h));
        }
        return _results;
      })
    },
    circles: {
      render: SliderUtils.clippedTransition(function(ctx, w, h, p) {
        var circleH, circleW, circlesX, circlesY, cx, cy, maxRad, maxWH, r, x, y, _results;
        circlesY = 6;
        circlesX = Math.floor(circlesY * w / h);
        circleW = w / circlesX;
        circleH = h / circlesY;
        maxWH = Math.max(w, h);
        maxRad = 0.7 * Math.max(circleW, circleH);
        _results = [];
        for (x = 0; 0 <= circlesX ? x <= circlesX : x >= circlesX; 0 <= circlesX ? x++ : x--) {
          _results.push((function() {
            var _results2;
            _results2 = [];
            for (y = 0; 0 <= circlesY ? y <= circlesY : y >= circlesY; 0 <= circlesY ? y++ : y--) {
              cx = (x + 0.5) * circleW;
              cy = (y + 0.5) * circleH;
              r = Math.max(0, Math.min(2 * p - cx / w, 1)) * maxRad;
              ctx.moveTo(cx, cy);
              _results2.push(ctx.arc(cx, cy, r, 0, Math.PI * 2, false));
            }
            return _results2;
          })());
        }
        return _results;
      })
    },
    squares: {
      render: SliderUtils.clippedTransition(function(ctx, w, h, p) {
        var blindHeight, blindWidth, blindsX, blindsY, prog, rh, rw, sx, sy, x, y, _results;
        p = 1 - (1 - p) * (1 - p);
        blindsY = 5;
        blindsX = Math.floor(blindsY * w / h);
        blindWidth = w / blindsX;
        blindHeight = h / blindsY;
        _results = [];
        for (x = 0; 0 <= blindsX ? x <= blindsX : x >= blindsX; 0 <= blindsX ? x++ : x--) {
          _results.push((function() {
            var _results2;
            _results2 = [];
            for (y = 0; 0 <= blindsY ? y <= blindsY : y >= blindsY; 0 <= blindsY ? y++ : y--) {
              sx = blindWidth * x;
              sy = blindHeight * y;
              prog = Math.max(0, Math.min(3 * p - sx / w - sy / h, 1));
              rw = blindWidth * prog;
              rh = blindHeight * prog;
              _results2.push(ctx.rect(sx - rw / 2, sy - rh / 2, rw, rh));
            }
            return _results2;
          })());
        }
        return _results;
      })
    },
    fadeLeft: {
      init: function(self, from, to) {
        var data, h, y;
        data = SliderUtils.extractImageData(self, from, to);
        data.randomTrait = [];
        h = self.canvas[0].height;
        for (y = 0; 0 <= h ? y <= h : y >= h; 0 <= h ? y++ : y--) {
          data.randomTrait[y] = Math.random();
        }
        return data;
      },
      render: function(self, from, to, progress, data) {
        var blur, ctx, fd, height, out, randomTrait, td, width, _ref;
        blur = 150;
        _ref = self.canvas[0], width = _ref.width, height = _ref.height;
        ctx = self.ctx;
        fd = data.fromData.data;
        td = data.toData.data;
        out = data.output.data;
        randomTrait = data.randomTrait;
        (function(){
        var wpdb = width*progress/blur;
        for (var x = 0; x < width; ++x) {
          var xdb = x/blur;
          for (var y = 0; y < height; ++y) {
            var b = (y*width + x)*4
            var p1 = Math.min(Math.max((xdb-wpdb*(1+randomTrait[y]/10)), 0), 1)
            var p2 = 1-p1
            for (var c = 0; c < 3; ++c) {
              var i = b + c;
              out[i] = p1 * (fd[i] ) + p2 * (td[i] )
            }
            out[b + 3] = 255;
          }
        }
      }());
        return self.ctx.putImageData(data.output, 0, 0);
      }
    }
  };
  Slider = (function() {
    function Slider(container) {
      this.container = $(container);
    }
    Slider.prototype.current = 0;
    Slider.prototype.lastHumanNav = 0;
    Slider.prototype.duration = 4000;
    Slider.prototype.w = '640px';
    Slider.prototype.h = '430px';
    Slider.prototype.theme = 'theme-dark';
    Slider.prototype.tmpl = tmplSlider;
    Slider.prototype.circular = function(num) {
      return mod(num, this.slides.size());
    };
    Slider.prototype.slide = function(num) {
      if (this.slides && this.pages) {
        num = Math.max(0, Math.min(num, this.slides.size() - 1));
        this.slides.eq(this.current).removeClass("current");
        this.slides.eq(num).addClass("current");
        this.pages.eq(this.current).removeClass("current");
        this.pages.eq(num).addClass("current");
      }
      this.current = num;
      return this;
    };
    Slider.prototype.next = function() {
      return this.slide(this.circular(this.current + 1));
    };
    Slider.prototype.prev = function() {
      return this.slide(this.circular(this.current - 1));
    };
    Slider.prototype.setDuration = function(duration) {
      this.duration = duration;
      return this;
    };
    Slider.prototype.setTransition = function(transition) {
      if (this.node) {
        if (this.transition) {
          this.node.removeClass(this.transition);
        }
        if (transition) {
          this.node.addClass(transition);
        }
      }
      this.transition = transition;
      return this;
    };
    Slider.prototype.setTheme = function(theme) {
      if (theme == null) {
        theme = "theme-dark";
      }
      if (this.node) {
        if (this.theme) {
          this.node.removeClass(this.theme);
        }
        if (theme) {
          this.node.addClass(theme);
        }
      }
      this.theme = theme;
      return this;
    };
    Slider.prototype.setSize = function(w, h) {
      this.w = w;
      this.h = h;
      if (this.node) {
        this.node.width(w);
        this.node.find(".slide-image").width(w);
        this.node.find(".slide-images").height(h);
      }
      return this;
    };
    Slider.prototype.fetchJson = function(url, options, transformer) {
      var params;
      params = $.extend({}, options);
      if (transformer == null) {
        transformer = function(json) {
          return json;
        };
      }
      $.getJSON(url, params, __bind(function(json) {
        return this.setPhotos(transformer(json));
      }, this));
      return this;
    };
    Slider.prototype._sync = function() {
      this.setTransition(this.transition);
      this.setTheme(this.theme);
      this.setSize(this.w, this.h);
      return this.slide(this.current);
    };
    Slider.prototype.setPhotos = function(photos) {
      var imgs, nbLoad;
      this.photos = photos;
      this.node = this.tmpl({
        slides: photos
      }).addClass("loading");
      this.container.empty().append(this.node);
      this._sync();
      nbLoad = 0;
      imgs = this.node.find(".slide-image img").bind("load", __bind(function() {
        var total;
        total = imgs.size();
        if (++nbLoad === total) {
          this.node.removeClass("loading");
          this.start();
        }
        return this.node.find(".loader .percent").text(Math.floor(100 * nbLoad / total));
      }, this));
      if (imgs.size() === 0) {
        this.node.find(".loader").text("No photo");
      }
      return this;
    };
    Slider.prototype.start = function() {
      this.slides = this.node.find(".slide-image");
      this.pages = this.node.find(".slide-pager a");
      this._sync();
      this._bind();
      return this;
    };
    Slider.prototype.stop = function() {
      this._unbind();
      return this;
    };
    Slider.prototype._bind = function() {
      var loop_, now, self;
      this._unbind();
      this.node.find(".prevSlide").click(__bind(function() {
        return this.prev();
      }, this));
      this.node.find(".nextSlide").click(__bind(function() {
        return this.next();
      }, this));
      self = this;
      if (this.node) {
        this.node.find(".slide-pager a").each(function(i) {
          return $(this).click(function() {
            return self.slide(i);
          });
        });
        now = function() {
          return currentTime();
        };
        this.node.find(".options a").click(__bind(function() {
          return this.lastHumanNav = now();
        }, this));
      }
      if (!this.timeout) {
        loop_ = __bind(function() {
          if (now() - this.lastHumanNav > 2000) {
            this.next();
          }
          return this.timeout = setTimeout(loop_, this.duration);
        }, this);
        this.timeout = setTimeout(loop_, this.duration);
      }
      return this;
    };
    Slider.prototype._unbind = function() {
      if (this.node) {
        this.node.find(".prevSlide, .nextSlide, .slide-pager a, .options a").unbind('click');
      }
      if (this.timeout) {
        clearTimeout(this.timeout);
        return this.timeout = null;
      }
    };
    return Slider;
  })();
  SliderWithCanvas = (function() {
    __extends(SliderWithCanvas, Slider);
    function SliderWithCanvas() {
      SliderWithCanvas.__super__.constructor.apply(this, arguments);
    }
    SliderWithCanvas.prototype.transitionFunction = SliderTransitionFunctions.clock;
    SliderWithCanvas.prototype.transitionDuration = 1500;
    SliderWithCanvas.prototype.tmpl = tmplSliderWithCanvas;
    SliderWithCanvas.prototype._sync = function() {
      var renderMode;
      renderMode = this.renderMode;
      SliderWithCanvas.__super__._sync.apply(this, arguments);
      return this.setRenderMode(renderMode);
    };
    SliderWithCanvas.prototype.start = function() {
      this.notCanvas = this.node.find('.slide-images:not(canvas) img');
      this.canvas = this.node.find('canvas.slide-images');
      if (this.canvas[0] && this.canvas[0].getContext) {
        this.ctx = this.canvas[0].getContext('2d');
      }
      if (this.photos) {
        this.images = $.map(this.photos, (__bind(function(photo) {
          var img;
          img = new Image();
          img.src = photo.src;
          return img;
        }, this)));
      }
      return SliderWithCanvas.__super__.start.apply(this, arguments);
    };
    SliderWithCanvas.prototype.setSize = function(w, h) {
      SliderWithCanvas.__super__.setSize.call(this, w, h);
      if (this.canvas) {
        this.canvas.attr("height", h).attr("width", w);
      }
      return this;
    };
    SliderWithCanvas.prototype.setRenderMode = function(renderMode) {
      this.renderMode = renderMode;
      if (this.ctx) {
        if (this.renderMode === 'canvas') {
          this.drawImage(this.images[this.current]);
          this.notCanvas.hide();
          this.canvas.show();
        } else {
          this.canvas.hide();
          this.notCanvas.show();
        }
      }
      return this;
    };
    SliderWithCanvas.prototype.setTransition = function(transition) {
      this.setRenderMode('css');
      SliderWithCanvas.__super__.setTransition.call(this, transition);
      return this;
    };
    SliderWithCanvas.prototype.setTransitionFunction = function(transitionFunction) {
      this.transitionFunction = transitionFunction;
      this.setRenderMode('canvas');
      return this;
    };
    SliderWithCanvas.prototype.setTransitionDuration = function(transitionDuration) {
      this.transitionDuration = transitionDuration;
      this.setRenderMode('canvas');
      return this;
    };
    SliderWithCanvas.prototype.slide = function(num) {
      this.fromSlide = this.current;
      this.toSlide = num;
      this.transitionStart = currentTime();
      if (this.ctx && this.renderMode === 'canvas') {
        this.startRender();
      }
      return SliderWithCanvas.__super__.slide.call(this, num);
    };
    SliderWithCanvas.prototype.clean = function() {
      return this.ctx.clearRect(0, 0, this.canvas[0].width, this.canvas[0].height);
    };
    SliderWithCanvas.prototype.drawImage = function(img) {
      var height, width, _ref;
      _ref = this.canvas[0], width = _ref.width, height = _ref.height;
      return this.ctx.drawImage(img, 0, 0, width, width * img.height / img.width);
    };
    SliderWithCanvas.prototype._renderId = 0;
    SliderWithCanvas.prototype.startRender = function() {
      if (this.transitionFunction.init) {
        this.tfdata = this.transitionFunction.init(this, this.fromSlide, this.toSlide);
      }
      return this.render(++this._renderId, this.transitionFunction);
    };
    SliderWithCanvas.prototype.render = function(id, transitionFunction) {
      var now, progress;
      now = currentTime();
      if (id === this._renderId && now >= this.transitionStart) {
        progress = Math.min(1, (now - this.transitionStart) / this.transitionDuration);
        if (progress === 1) {
          this.clean();
          return this.drawImage(this.images[this.toSlide]);
        } else {
          transitionFunction.render(this, this.fromSlide, this.toSlide, progress, this.tfdata);
          return requestAnimationFrame((__bind(function() {
            return this.render(id, transitionFunction);
          }, this)), this.canvas[0]);
        }
      }
    };
    return SliderWithCanvas;
  })();
  window.Slider = SliderWithCanvas;
  window.SliderTransitionFunctions = SliderTransitionFunctions;
  window.SliderUtils = SliderUtils;
}).call(this);
