text: // Generated by CoffeeScript 1.12.7
  (function() {
    var Glide,
      bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
  
    Glide = (function() {
      Glide.prototype.stylesheetPath = '/';
  
      Glide.prototype.hooks = {
        'before:to': [],
        'after:to': []
      };
  
      Glide.prototype.isTransitioning = false;
  
      Glide.prototype.transitionAnimation = true;
  
      Glide.prototype.speed = 0.3;
  
      function Glide(options) {
        var key, ref, value;
        if (options == null) {
          options = {};
        }
        this.removePressed = bind(this.removePressed, this);
        this.onTouchStart = bind(this.onTouchStart, this);
        this.handleEvents = bind(this.handleEvents, this);
        this.isTouch = bind(this.isTouch, this);
        this.hideTransitionedPage = bind(this.hideTransitionedPage, this);
        this.to = bind(this.to, this);
        for (key in options) {
          value = options[key];
          this[key] = value;
        }
        ref = this.plugins;
        for (key in ref) {
          value = ref[key];
          this.plugins[key] = new value(this);
        }
        if (this.isTouch()) {
          document.body.addEventListener('touchstart', this.handleEvents, false);
        } else {
          document.body.addEventListener('mousedown', this.handleEvents, false);
        }
      }
  
      Glide.prototype.to = function(targetPage, animate) {
        var currentPage, hook, i, j, len, len1, oldAnimate, ref, ref1, results, transitionType;
        if (animate == null) {
          animate = true;
        }
        oldAnimate = this.transitionAnimation;
        this.transitionAnimation = animate;
        ref = this.hooks['before:to'];
        for (i = 0, len = ref.length; i < len; i++) {
          hook = ref[i];
          hook();
        }
        if (typeof targetPage === 'string') {
          this.targetPage = document.querySelector(targetPage);
        } else if (targetPage) {
          this.targetPage = targetPage;
        }
        if (this.targetPage === this.currentPage || this.isTransitioning) {
          return;
        }
        if (this.currentPage == null) {
          this.targetPage.style.display = '-webkit-box';
          this.currentPage = this.targetPage;
          return;
        }
        this.isTransitioning = true;
        if (this.back) {
          transitionType = this.currentPage.getAttribute('data-transition') || 'slide';
        } else {
          transitionType = this.targetPage.getAttribute('data-transition') || 'slide';
        }
        targetPage = this.targetPage;
        currentPage = this.currentPage;
        this.currentPage = this.targetPage;
        currentPage.classList.add('previousPage');
        document.body.addEventListener('webkitTransitionEnd', this.hideTransitionedPage, false);
        setTimeout((function(_this) {
          return function() {
            if (transitionType !== 'none') {
              _this[transitionType](targetPage, currentPage);
            } else {
              _this.displayPage(targetPage, currentPage);
            }
            return _this.transitionAnimation = oldAnimate;
          };
        })(this), 10);
        ref1 = this.hooks['after:to'];
        results = [];
        for (j = 0, len1 = ref1.length; j < len1; j++) {
          hook = ref1[j];
          results.push(hook());
        }
        return results;
      };
  
      Glide.prototype.slide = function(targetPage, currentPage) {
        var axis, screenWidth;
        targetPage.style.display = '-webkit-box';
        screenWidth = window.innerWidth + 'px';
        axis = 'X';
        if (this.back) {
          this.translate(currentPage, axis, '0%');
          this.translate(targetPage, axis, '-' + screenWidth, '0ms');
          setTimeout((function(_this) {
            return function() {
              return _this.translate(currentPage, axis, '100%');
            };
          })(this), 0);
        } else {
          this.translate(currentPage, axis, '0%');
          this.translate(targetPage, axis, screenWidth, '0ms');
          setTimeout((function(_this) {
            return function() {
              return _this.translate(currentPage, axis, '-100%');
            };
          })(this), 0);
        }
        return setTimeout((function(_this) {
          return function() {
            _this.translate(targetPage, axis, '0%');
            return _this.back = false;
          };
        })(this), 0);
      };
  
      Glide.prototype.slideUp = function(targetPage, currentPage) {
        var axis, screenHeight;
        targetPage.style.display = '-webkit-box';
        screenHeight = window.innerHeight + 'px';
        axis = 'Y';
        if (this.back) {
          setTimeout((function(_this) {
            return function() {
              return _this.translate(currentPage, axis, screenHeight);
            };
          })(this), 0);
        } else {
          targetPage.style.zIndex = '1000';
          this.translate(targetPage, axis, screenHeight, '0ms');
          setTimeout((function(_this) {
            return function() {
              return _this.translate(targetPage, axis, '0%');
            };
          })(this), 0);
        }
        return this.back = false;
      };
  
      Glide.prototype.translate = function(page, axis, distance, duration) {
        if (duration == null) {
          duration = this.speed + 's';
        }
        page.style.webkitTransition = duration + " cubic-bezier(.10, .10, .25, .90)";
        return page.style.webkitTransform = "translate" + axis + "(" + distance + ")";
      };
  
      Glide.prototype.displayPage = function(targetPage, currentPage) {
        this.isTransitioning = false;
        targetPage.style.display = '-webkit-box';
        currentPage.classList.add('previousPage');
        this.back = false;
        return this.hideTransitionedPage();
      };
  
      Glide.prototype.hideTransitionedPage = function(e) {
        var previousPage;
        this.isTransitioning = false;
        previousPage = document.querySelector('.previousPage');
        if (previousPage) {
          setTimeout((function(_this) {
            return function() {
              previousPage.classList.remove('previousPage');
              previousPage.style.display = 'none';
              return _this.translate(previousPage, 'X', '0%', '0ms');
            };
          })(this), 0);
        }
        return document.body.removeEventListener('webkitTransitionEnd', this.hideTransitionedPage, false);
      };
  
      Glide.prototype.isTouch = function() {
        if (typeof this.touch === 'undefined') {
          if (!!('ontouchstart' in window)) {
            return this.touch = true;
          } else {
            return this.touch = false;
          }
        } else {
          return this.touch;
        }
      };
  
      Glide.prototype.handleEvents = function(e) {
        if (this.isTouch()) {
          switch (e.type) {
            case 'touchstart':
              return this.onTouchStart(e);
            case 'touchmove':
              return this.removePressed();
            case 'touchend':
              return this.removePressed();
          }
        } else {
          switch (e.type) {
            case 'mousedown':
              return this.onTouchStart(e);
          }
        }
      };
  
      Glide.prototype.onTouchStart = function(e) {
        var ref;
        if (this.isTouch()) {
          this.theTarget = document.elementFromPoint(e.targetTouches[0].clientX, e.targetTouches[0].clientY);
        } else {
          this.theTarget = document.elementFromPoint(e.clientX, e.clientY);
        }
        if (((ref = this.theTarget) != null ? ref.nodeName : void 0) && this.theTarget.nodeName.toLowerCase() !== 'a' && (this.theTarget.nodeType === 3 || this.theTarget.nodeType === 1)) {
          this.oldTarget = this.theTarget;
          this.theTarget = $(this.theTarget).closest('a')[0];
        }
        if (this.theTarget === null || typeof this.theTarget === 'undefined') {
          return;
        }
        this.theTarget.classList.add('pressed');
        this.theTarget.addEventListener('touchmove', this.removePressed, false);
        this.theTarget.addEventListener('mouseout', this.removePressed, false);
        this.theTarget.addEventListener('touchend', this.removePressed, false);
        this.theTarget.addEventListener('mouseup', this.removePressed, false);
        return this.theTarget.addEventListener('touchcancel', this.removePressed, false);
      };
  
      Glide.prototype.removePressed = function(e) {
        var element, elements, i, len, results;
        elements = document.getElementsByClassName('pressed');
        results = [];
        for (i = 0, len = elements.length; i < len; i++) {
          element = elements[i];
          results.push(element != null ? element.classList.remove('pressed') : void 0);
        }
        return results;
      };
  
      return Glide;
  
    })();
  
    window.Glide = Glide;
  
  }).call(this);
  