<commit_before>$(document).ready(function(){
   var scrollStart = 0;
   var startChange = $("#body");
   var offset = startChange.offset();
   $(document).scroll(function() {
      scrollStart = $(this).scrollTop();
      if(scrollStart > offset.top) {
          $("#navigation").css("color", "#191919");
          $("#navigation").css("background", "#fff");
          $("ul#navigation li a").css("color", "#191919");
       } else {
          $("#navigation").css("color", "#fff");
          $("ul#navigation li a").css("color", "#fff");
          $("#navigation").css("background", "transparent");
       }
   });
});

var strings = ["vývojář^1000", "krocan^1000", "šílenec^1000", "student^1000", "redaktor^1000", "hráč^1000"];
$(function(){
    $(".animated").typed({
        strings: strings,
        typeSpeed: 50,
        loop: true,
        loopCount: Infinity,
        shuffle: true
    });
});

function toggleMenu() {
    var x = document.getElementById("navigation");
    if (x.className === "shown") {
        x.className = "hidden";
        Console.log("hidden");
    } else {
        x.className = "shown";
        Console.log("shown");
    }
}

window.setInterval(function(){
    var d2 = new Date();
    var d1 = new Date(2001, 9, 13);
    var diff = d2.getTime() - d1.getTime();
    $(".current-age").html(diff / (1000 * 60 * 60 * 24 * 365.25).toFixed(10));
}, 100);

$(function () {
  $("[data-toggle=\"tooltip\"]").tooltip();
});<commit_msg>Upraveny chyby v kódu<commit_after>$(document).ready(function(){
   var scrollStart = 0;
   var startChange = $("#body");
   var offset = startChange.offset();
   $(document).scroll(function() {
      scrollStart = $(this).scrollTop();
      if(scrollStart > offset.top) {
          $("#navigation").css("color", "#191919");
          $("#navigation").css("background", "#fff");
          $("ul#navigation li a").css("color", "#191919");
       } else {
          $("#navigation").css("color", "#fff");
          $("ul#navigation li a").css("color", "#fff");
          $("#navigation").css("background", "transparent");
       }
   });
});

var strings = ["vývojář^1000", "krocan^1000", "šílenec^1000", "student^1000", "redaktor^1000", "hráč^1000"];
$(function(){
    $(".animated").typed({
        strings: strings,
        typeSpeed: 50,
        loop: true,
        loopCount: Infinity,
        shuffle: true
    });
});

function toggleMenu() {
    var x = document.getElementById("navigation");
    if (x.className === "shown") {
        x.className = "hidden";
        console.log('hidden');
    } else {
        x.className = "shown";
        console.log('shown');
    }
}

window.setInterval(function(){
    var d2 = new Date();
    var d1 = new Date(2001, 9, 13);
    var diff = d2.getTime() - d1.getTime();
    $(".current-age").html(diff / (1000 * 60 * 60 * 24 * 365.25).toFixed(10));
}, 100);

$(function () {
  $("[data-toggle=\"tooltip\"]").tooltip();
});<|endoftext|>


<commit_before>goog.provide('annotorious.plugins.selection.RectDragSelector');

goog.require('goog.events');

goog.require('annotorious.events.ui');

/**
 * The default selector: a simple click-and-drag rectangle selection tool.
 * @constructor
 */
annotorious.plugins.selection.RectDragSelector = function() { }

/**
 * Initializes the selector.
 * @param {Element} canvas the canvas to draw on
 * @param {Object} annotator reference to the annotator
 */
annotorious.plugins.selection.RectDragSelector.prototype.init = function(annotator, canvas) {
  /** @private **/
  this._OUTLINE = '#000000';

  /** @private **/
  this._STROKE = '#ffffff';

  /** @private **/
  this._FILL = false;

  /** @private **/
  this._HI_OUTLINE = '#000000';

  /** @private **/
  this._HI_STROKE = '#fff000';

  /** @private **/
  this._HI_FILL = false;

  /** @private **/
  this._OUTLINE_WIDTH = 1;

  /** @private **/
  this._STROKE_WIDTH = 1;

  /** @private **/
  this._HI_OUTLINE_WIDTH = 1;

  /** @private **/
  this._HI_STROKE_WIDTH = 1.2;

  /** @private **/
  this._canvas = canvas;

  /** @private **/
  this._annotator = annotator;

  /** @private **/
  this._g2d = canvas.getContext('2d');
  this._g2d.lineWidth = 1;

  /** @private **/
  this._anchor;

  /** @private **/
  this._opposite;

  /** @private **/
  this._enabled = false;

  /** @private **/
  this._mouseMoveListener;

  /** @private **/
  this._mouseUpListener;
}

/**
 * Attaches MOUSEUP and MOUSEMOVE listeners to the editing canvas.
 * @private
 */
annotorious.plugins.selection.RectDragSelector.prototype._attachListeners = function(startPoint) {
  var self = this;
  var canvas = this._canvas;

  this._mouseMoveListener = goog.events.listen(this._canvas, annotorious.events.ui.EventType.MOVE, function(event) {
    var points = annotorious.events.ui.sanitizeCoordinates(event, canvas);
    if (self._enabled) {
      self._opposite = { x: points.x, y: points.y };

      self._g2d.clearRect(0, 0, canvas.width, canvas.height);

      var width = self._opposite.x - self._anchor.x;
      var height = self._opposite.y - self._anchor.y;

      if (self._OUTLINE) {
        self._g2d.strokeStyle = self._OUTLINE;
        self._g2d.lineWidth = self._OUTLINE_WIDTH;
        self._g2d.strokeRect(
          self._anchor.x + self._OUTLINE_WIDTH/2,
          self._anchor.y + self._OUTLINE_WIDTH/2,
          width - self._OUTLINE_WIDTH,
          height - self._OUTLINE_WIDTH
        );
      }
      if (self._STROKE) {
        self._g2d.strokeStyle = self._STROKE;
        self._g2d.lineWidth = self._STROKE_WIDTH;

        if (width > 0 && height > 0) {
          self._g2d.strokeRect(
            self._anchor.x + self._OUTLINE_WIDTH + self._STROKE_WIDTH/2,
            self._anchor.y + self._OUTLINE_WIDTH + self._STROKE_WIDTH/2,
            width - self._OUTLINE_WIDTH*2 - self._STROKE_WIDTH,
            height - self._OUTLINE_WIDTH*2 - self._STROKE_WIDTH
          );
        } else if (width > 0 && height < 0) {
          self._g2d.strokeRect(
            self._anchor.x + self._OUTLINE_WIDTH + self._STROKE_WIDTH/2,
            self._anchor.y - self._OUTLINE_WIDTH + self._STROKE_WIDTH/2,
            width - self._OUTLINE_WIDTH*2 - self._STROKE_WIDTH,
            height + self._OUTLINE_WIDTH*2 - self._STROKE_WIDTH
          );
        } else if (width < 0 && height < 0) {
          self._g2d.strokeRect(
            self._anchor.x - self._OUTLINE_WIDTH + self._STROKE_WIDTH/2,
            self._anchor.y - self._OUTLINE_WIDTH + self._STROKE_WIDTH/2,
            width + self._OUTLINE_WIDTH*2 - self._STROKE_WIDTH,
            height + self._OUTLINE_WIDTH*2 - self._STROKE_WIDTH
          );
        } else {
          self._g2d.strokeRect(
            self._anchor.x - self._OUTLINE_WIDTH + self._STROKE_WIDTH/2,
            self._anchor.y + self._OUTLINE_WIDTH + self._STROKE_WIDTH/2,
            width + self._OUTLINE_WIDTH*2 - self._STROKE_WIDTH,
            height - self._OUTLINE_WIDTH*2 - self._STROKE_WIDTH
          );
        }
      }
    }
  });

  this._mouseUpListener = goog.events.listen(canvas, annotorious.events.ui.EventType.UP, function(event) {
    var points = annotorious.events.ui.sanitizeCoordinates(event, canvas);
    var shape = self.getShape();
    event = (event.event_) ? event.event_ : event;

    self._enabled = false;
    if (shape) {
      self._detachListeners();
      self._annotator.fireEvent(annotorious.events.EventType.SELECTION_COMPLETED,
        { mouseEvent: event, shape: shape, viewportBounds: self.getViewportBounds() });
    } else {
      self._annotator.fireEvent(annotorious.events.EventType.SELECTION_CANCELED);

      // On cancel, we "relay" the selection event to the annotator
      var annotations = self._annotator.getAnnotationsAt(points.x, points.y);
      if (annotations.length > 0)
        self._annotator.highlightAnnotation(annotations[0]);
    }
  });
}

/**
 * Detaches MOUSEUP and MOUSEMOVE listeners from the editing canvas.
 * @private
 */
annotorious.plugins.selection.RectDragSelector.prototype._detachListeners = function() {
  if (this._mouseMoveListener) {
    goog.events.unlistenByKey(this._mouseMoveListener);
    delete this._mouseMoveListener;
  }

  if (this._mouseUpListener) {
    goog.events.unlistenByKey(this._mouseUpListener);
    delete this._mouseUpListener;
  }
}

/**
 * Selector API method: returns the selector name.
 * @returns the selector name
 */
annotorious.plugins.selection.RectDragSelector.prototype.getName = function() {
  return 'rect_drag';
}

/**
 * Selector API method: returns the supported shape type.
 *
 * TODO support for multiple shape types?
 *
 * @return the supported shape type
 */
annotorious.plugins.selection.RectDragSelector.prototype.getSupportedShapeType = function() {
  return annotorious.shape.ShapeType.RECTANGLE;
}

/**
 * Sets the properties on this selector.
 */
annotorious.plugins.selection.RectDragSelector.prototype.setProperties = function(props) {
  if (props.hasOwnProperty('outline'))
    this._OUTLINE = props['outline'];

  if (props.hasOwnProperty('stroke'))
    this._STROKE = props['stroke'];

  if (props.hasOwnProperty('fill'))
    this._FILL = props['fill'];

  if (props.hasOwnProperty('hi_outline'))
    this._HI_OUTLINE = props['hi_outline'];

  if (props.hasOwnProperty('hi_stroke'))
    this._HI_STROKE = props['hi_stroke'];

  if (props.hasOwnProperty('hi_fill'))
    this._HI_FILL = props['hi_fill'];

  if (props.hasOwnProperty('outline_width'))
    this._OUTLINE_WIDTH = props['outline_width'];

  if (props.hasOwnProperty('stroke_width'))
    this._STROKE_WIDTH = props['stroke_width'];

  if (props.hasOwnProperty('hi_outline_width'))
    this._HI_OUTLINE_WIDTH = props['hi_outline_width'];

  if (props.hasOwnProperty('hi_stroke_width'))
    this._HI_STROKE_WIDTH = props['hi_stroke_width'];
}

/**
 * Selector API method: starts the selection at the specified coordinates.
 * @param {number} x the X coordinate
 * @param {number} y the Y coordinate
 */
annotorious.plugins.selection.RectDragSelector.prototype.startSelection = function(x, y) {
  var startPoint = {
    x: x,
    y: y
  };
  this._enabled = true;
  this._attachListeners(startPoint);
  this._anchor = new annotorious.shape.geom.Point(x, y);
  this._annotator.fireEvent(annotorious.events.EventType.SELECTION_STARTED, {
    offsetX: x, offsetY: y});

  goog.style.setStyle(document.body, '-webkit-user-select', 'none');
}

/**
 * Selector API method: stops the selection.
 */
annotorious.plugins.selection.RectDragSelector.prototype.stopSelection = function() {
  this._detachListeners();
  this._g2d.clearRect(0, 0, this._canvas.width, this._canvas.height);
  goog.style.setStyle(document.body, '-webkit-user-select', 'auto');
  delete this._opposite;
}

/**
 * Selector API method: returns the currently edited shape.
 * @return {annotorious.shape.Shape | undefined} the shape
 */
annotorious.plugins.selection.RectDragSelector.prototype.getShape = function() {
  if (this._opposite &&
     (Math.abs(this._opposite.x - this._anchor.x) > 3) &&
     (Math.abs(this._opposite.y - this._anchor.y) > 3)) {

    var viewportBounds = this.getViewportBounds();
    var item_anchor = this._annotator.toItemCoordinates({x: viewportBounds.left, y: viewportBounds.top});
    var item_opposite = this._annotator.toItemCoordinates({x: viewportBounds.right - 1, y: viewportBounds.bottom - 1});

    var rect = new annotorious.shape.geom.Rectangle(
      item_anchor.x,
      item_anchor.y,
      item_opposite.x - item_anchor.x,
      item_opposite.y - item_anchor.y
    );

    return new annotorious.shape.Shape(annotorious.shape.ShapeType.RECTANGLE, rect);
  } else {
    return undefined;
  }
}

/**
 * Selector API method: returns the bounds of the selected shape, in viewport (= pixel) coordinates.
 * @returns {Object} the shape viewport bounds
 */
annotorious.plugins.selection.RectDragSelector.prototype.getViewportBounds = function() {
  var right, left;
  if (this._opposite.x > this._anchor.x) {
    right = this._opposite.x;
    left = this._anchor.x;
  } else {
    right = this._anchor.x;
    left = this._opposite.x;
  }

  var top, bottom;
  if (this._opposite.y > this._anchor.y) {
    top = this._anchor.y;
    bottom = this._opposite.y;
  } else {
    top = this._opposite.y;
    bottom = this._anchor.y;
  }

  return {top: top, right: right, bottom: bottom, left: left};
}

/**
 * TODO not sure if this is really the best way/architecture to handle viewer shape drawing
 * @param {Object} g2d graphics context
 * @param {annotorious.shape.Shape} shape the shape to draw
 * @param {boolean=} highlight if true, shape will be drawn highlighted
 */
annotorious.plugins.selection.RectDragSelector.prototype.drawShape = function(g2d, shape, highlight) {
  var geom, stroke, fill, outline;

  if (shape.type == annotorious.shape.ShapeType.RECTANGLE) {
    if ('style' in shape) {
        if (highlight) {
          fill = shape.style.hi_fill;
          stroke = shape.style.hi_stroke;
          outline = shape.style.hi_outline;
          outline_width = shape.style.hi_outline_width;
          stroke_width = shape.style.hi_stroke_width;
        } else {
          fill = shape.style.fill;
          stroke = shape.style.stroke;
          outline = shape.style.outline;
          outline_width = shape.style.outline_width;
          stroke_width = shape.style.stroke_width;
        }
    } else {
        if (highlight) {
          fill = this._HI_FILL;
          stroke = this._HI_STROKE;
          outline = this._HI_OUTLINE;
          outline_width = this._HI_OUTLINE_WIDTH;
          stroke_width = this._HI_STROKE_WIDTH;
        } else {
          fill = this._FILL;
          stroke = this._STROKE;
          outline = this._OUTLINE;
          outline_width = this._OUTLINE_WIDTH;
          stroke_width = this._STROKE_WIDTH;
        }
    }

    g2d.lineJoin = "round";

    geom = shape.geometry;

    // Outline
    if (outline) {
        g2d.lineWidth = outline_width;
        g2d.strokeStyle = outline;
        g2d.strokeRect(
          geom.x + outline_width/2,
          geom.y + outline_width/2,
          geom.width - outline_width,
          geom.height - outline_width
        );
    }

    // Stroke
    if (stroke) {
      g2d.lineWidth = stroke_width;
      g2d.strokeStyle = stroke;
      g2d.strokeRect(
        geom.x + outline_width + stroke_width/2,
        geom.y + outline_width + stroke_width/2,
        geom.width - outline_width*2 - stroke_width,
        geom.height - outline_width*2 - stroke_width
      );
    }

    // Fill
    if (fill) {
      g2d.lineWidth = stroke_width;
      g2d.fillStyle = fill;
      g2d.fillRect(
        geom.x + outline_width + stroke_width/2,
        geom.y + outline_width + stroke_width/2,
        geom.width - outline_width*2 - stroke_width,
        geom.height - outline_width*2 - stroke_width
      );
    }
  }
}
<commit_msg>Fixed geometry differences between selection and saved annotation<commit_after>goog.provide('annotorious.plugins.selection.RectDragSelector');

goog.require('goog.events');

goog.require('annotorious.events.ui');

/**
 * The default selector: a simple click-and-drag rectangle selection tool.
 * @constructor
 */
annotorious.plugins.selection.RectDragSelector = function() { }

/**
 * Initializes the selector.
 * @param {Element} canvas the canvas to draw on
 * @param {Object} annotator reference to the annotator
 */
annotorious.plugins.selection.RectDragSelector.prototype.init = function(annotator, canvas) {
  /** @private **/
  this._OUTLINE = '#000000';

  /** @private **/
  this._STROKE = '#ffffff';

  /** @private **/
  this._FILL = false;

  /** @private **/
  this._HI_OUTLINE = '#000000';

  /** @private **/
  this._HI_STROKE = '#fff000';

  /** @private **/
  this._HI_FILL = false;

  /** @private **/
  this._OUTLINE_WIDTH = 1;

  /** @private **/
  this._STROKE_WIDTH = 1;

  /** @private **/
  this._HI_OUTLINE_WIDTH = 1;

  /** @private **/
  this._HI_STROKE_WIDTH = 1.2;

  /** @private **/
  this._canvas = canvas;

  /** @private **/
  this._annotator = annotator;

  /** @private **/
  this._g2d = canvas.getContext('2d');
  this._g2d.lineWidth = 1;

  /** @private **/
  this._anchor;

  /** @private **/
  this._opposite;

  /** @private **/
  this._enabled = false;

  /** @private **/
  this._mouseMoveListener;

  /** @private **/
  this._mouseUpListener;
}

/**
 * Attaches MOUSEUP and MOUSEMOVE listeners to the editing canvas.
 * @private
 */
annotorious.plugins.selection.RectDragSelector.prototype._attachListeners = function(startPoint) {
  var self = this;
  var canvas = this._canvas;

  this._mouseMoveListener = goog.events.listen(this._canvas, annotorious.events.ui.EventType.MOVE, function(event) {
    var points = annotorious.events.ui.sanitizeCoordinates(event, canvas);
    if (self._enabled) {
      self._opposite = { x: points.x, y: points.y };

      self._g2d.clearRect(0, 0, canvas.width, canvas.height);

      var width = self._opposite.x - self._anchor.x;
      var height = self._opposite.y - self._anchor.y;

      self.drawShape(self._g2d, {
        type: annotorious.shape.ShapeType.RECTANGLE,
        geometry: {
          x: width > 0 ? self._anchor.x : self._opposite.x,
          y: height > 0 ? self._anchor.y : self._opposite.y,
          width: Math.abs(width),
          height: Math.abs(height)
        }
      });
    }
  });

  this._mouseUpListener = goog.events.listen(canvas, annotorious.events.ui.EventType.UP, function(event) {
    var points = annotorious.events.ui.sanitizeCoordinates(event, canvas);
    var shape = self.getShape();
    event = (event.event_) ? event.event_ : event;

    self._enabled = false;
    if (shape) {
      self._detachListeners();
      self._annotator.fireEvent(annotorious.events.EventType.SELECTION_COMPLETED,
        { mouseEvent: event, shape: shape, viewportBounds: self.getViewportBounds() });
    } else {
      self._annotator.fireEvent(annotorious.events.EventType.SELECTION_CANCELED);

      // On cancel, we "relay" the selection event to the annotator
      var annotations = self._annotator.getAnnotationsAt(points.x, points.y);
      if (annotations.length > 0)
        self._annotator.highlightAnnotation(annotations[0]);
    }
  });
}

/**
 * Detaches MOUSEUP and MOUSEMOVE listeners from the editing canvas.
 * @private
 */
annotorious.plugins.selection.RectDragSelector.prototype._detachListeners = function() {
  if (this._mouseMoveListener) {
    goog.events.unlistenByKey(this._mouseMoveListener);
    delete this._mouseMoveListener;
  }

  if (this._mouseUpListener) {
    goog.events.unlistenByKey(this._mouseUpListener);
    delete this._mouseUpListener;
  }
}

/**
 * Selector API method: returns the selector name.
 * @returns the selector name
 */
annotorious.plugins.selection.RectDragSelector.prototype.getName = function() {
  return 'rect_drag';
}

/**
 * Selector API method: returns the supported shape type.
 *
 * TODO support for multiple shape types?
 *
 * @return the supported shape type
 */
annotorious.plugins.selection.RectDragSelector.prototype.getSupportedShapeType = function() {
  return annotorious.shape.ShapeType.RECTANGLE;
}

/**
 * Sets the properties on this selector.
 */
annotorious.plugins.selection.RectDragSelector.prototype.setProperties = function(props) {
  if (props.hasOwnProperty('outline'))
    this._OUTLINE = props['outline'];

  if (props.hasOwnProperty('stroke'))
    this._STROKE = props['stroke'];

  if (props.hasOwnProperty('fill'))
    this._FILL = props['fill'];

  if (props.hasOwnProperty('hi_outline'))
    this._HI_OUTLINE = props['hi_outline'];

  if (props.hasOwnProperty('hi_stroke'))
    this._HI_STROKE = props['hi_stroke'];

  if (props.hasOwnProperty('hi_fill'))
    this._HI_FILL = props['hi_fill'];

  if (props.hasOwnProperty('outline_width'))
    this._OUTLINE_WIDTH = props['outline_width'];

  if (props.hasOwnProperty('stroke_width'))
    this._STROKE_WIDTH = props['stroke_width'];

  if (props.hasOwnProperty('hi_outline_width'))
    this._HI_OUTLINE_WIDTH = props['hi_outline_width'];

  if (props.hasOwnProperty('hi_stroke_width'))
    this._HI_STROKE_WIDTH = props['hi_stroke_width'];
}

/**
 * Selector API method: starts the selection at the specified coordinates.
 * @param {number} x the X coordinate
 * @param {number} y the Y coordinate
 */
annotorious.plugins.selection.RectDragSelector.prototype.startSelection = function(x, y) {
  var startPoint = {
    x: x,
    y: y
  };
  this._enabled = true;
  this._attachListeners(startPoint);
  this._anchor = new annotorious.shape.geom.Point(x, y);
  this._annotator.fireEvent(annotorious.events.EventType.SELECTION_STARTED, {
    offsetX: x, offsetY: y});

  goog.style.setStyle(document.body, '-webkit-user-select', 'none');
}

/**
 * Selector API method: stops the selection.
 */
annotorious.plugins.selection.RectDragSelector.prototype.stopSelection = function() {
  this._detachListeners();
  this._g2d.clearRect(0, 0, this._canvas.width, this._canvas.height);
  goog.style.setStyle(document.body, '-webkit-user-select', 'auto');
  delete this._opposite;
}

/**
 * Selector API method: returns the currently edited shape.
 * @return {annotorious.shape.Shape | undefined} the shape
 */
annotorious.plugins.selection.RectDragSelector.prototype.getShape = function() {
  if (this._opposite &&
     (Math.abs(this._opposite.x - this._anchor.x) > 3) &&
     (Math.abs(this._opposite.y - this._anchor.y) > 3)) {

    var viewportBounds = this.getViewportBounds();
    var item_anchor = this._annotator.toItemCoordinates({x: viewportBounds.left, y: viewportBounds.top});
    var item_opposite = this._annotator.toItemCoordinates({x: viewportBounds.right, y: viewportBounds.bottom});

    var rect = new annotorious.shape.geom.Rectangle(
      item_anchor.x,
      item_anchor.y,
      item_opposite.x - item_anchor.x,
      item_opposite.y - item_anchor.y
    );

    return new annotorious.shape.Shape(annotorious.shape.ShapeType.RECTANGLE, rect);
  } else {
    return undefined;
  }
}

/**
 * Selector API method: returns the bounds of the selected shape, in viewport (= pixel) coordinates.
 * @returns {Object} the shape viewport bounds
 */
annotorious.plugins.selection.RectDragSelector.prototype.getViewportBounds = function() {
  var right, left;
  if (this._opposite.x > this._anchor.x) {
    right = this._opposite.x;
    left = this._anchor.x;
  } else {
    right = this._anchor.x;
    left = this._opposite.x;
  }

  var top, bottom;
  if (this._opposite.y > this._anchor.y) {
    top = this._anchor.y;
    bottom = this._opposite.y;
  } else {
    top = this._opposite.y;
    bottom = this._anchor.y;
  }

  return {top: top, right: right, bottom: bottom, left: left};
}

/**
 * TODO not sure if this is really the best way/architecture to handle viewer shape drawing
 * @param {Object} g2d graphics context
 * @param {annotorious.shape.Shape} shape the shape to draw
 * @param {boolean=} highlight if true, shape will be drawn highlighted
 */
annotorious.plugins.selection.RectDragSelector.prototype.drawShape = function(g2d, shape, highlight) {
  var geom, stroke, fill, outline, outline_width, stroke_width;

  if (shape.type == annotorious.shape.ShapeType.RECTANGLE) {
    if ('style' in shape) {
        if (highlight) {
          fill = shape.style.hi_fill;
          stroke = shape.style.hi_stroke;
          outline = shape.style.hi_outline;
          outline_width = shape.style.hi_outline_width;
          stroke_width = shape.style.hi_stroke_width;
        } else {
          fill = shape.style.fill;
          stroke = shape.style.stroke;
          outline = shape.style.outline;
          outline_width = shape.style.outline_width;
          stroke_width = shape.style.stroke_width;
        }
    } else {
        if (highlight) {
          fill = this._HI_FILL;
          stroke = this._HI_STROKE;
          outline = this._HI_OUTLINE;
          outline_width = this._HI_OUTLINE_WIDTH;
          stroke_width = this._HI_STROKE_WIDTH;
        } else {
          fill = this._FILL;
          stroke = this._STROKE;
          outline = this._OUTLINE;
          outline_width = this._OUTLINE_WIDTH;
          stroke_width = this._STROKE_WIDTH;
        }
    }

    geom = shape.geometry;

    // Outline
    if (outline) {
        g2d.lineJoin = "round";
        g2d.lineWidth = outline_width;
        g2d.strokeStyle = outline;
        g2d.strokeRect(
          geom.x + outline_width/2,
          geom.y + outline_width/2,
          geom.width - outline_width,
          geom.height - outline_width
        );
    }

    // Stroke
    if (stroke) {
      g2d.lineJoin = "miter";
      g2d.lineWidth = stroke_width;
      g2d.strokeStyle = stroke;
      g2d.strokeRect(
        geom.x + outline_width + stroke_width/2,
        geom.y + outline_width + stroke_width/2,
        geom.width - outline_width*2 - stroke_width,
        geom.height - outline_width*2 - stroke_width
      );
    }

    // Fill
    if (fill) {
      g2d.lineJoin = "miter";
      g2d.lineWidth = stroke_width;
      g2d.fillStyle = fill;
      g2d.fillRect(
        geom.x + outline_width + stroke_width/2,
        geom.y + outline_width + stroke_width/2,
        geom.width - outline_width*2 - stroke_width,
        geom.height - outline_width*2 - stroke_width
      );
    }
  }
}
<|endoftext|>


<commit_before>const BASE_URL = 'https://api.datausa.io/api/?show=geo&sumlevel=state&required=pop,age,income'
var states; // Global object that holds state information
let stats = ["population", "median_age", "median_income"];

// Loads state object
$(document).ready(function($) {

  getWikipedia(5407);

  $.ajax({
    url: 'https://raw.githubusercontent.com/takatanium/UCB-Project1/master/assets/json/states.json',
    dataType: 'json',
    method: 'GET',
    success: function(res) {
      states = res;

      for (let i = 0; i < states.length; i++) {
        states[i]['population'] = {}
        states[i]['median_age'] = {}
        states[i]['median_income'] = {}
      }
      getData();
    },
    error: function(e) {
      console.log(e);
    }
  })
});

/**
 * [getData description]
 * @return {[type]} [description]
 */
function getData() {
  $.ajax({
    url: BASE_URL,
    dataType: 'json',
    method: 'GET',
    success: function(res) {

      for (let i = 0; i < res.data.length; i++) {
        let id = res.data[i][1];

        for (let j = 0; j < states.length; j++) {

          if (id == states[j].id) {

            let year = res.data[i][0];

            if (!states[j]['population'].hasOwnProperty(year)) {
              states[j]['population'][year] = res.data[i][2];
            }

            if (!states[j]['median_age'].hasOwnProperty(year)) {
              states[j]['median_age'][year] = res.data[i][3];
            }

            if (!states[j]['median_income'].hasOwnProperty(year)) {
              states[j]['median_income'][year] = res.data[i][4];
            }
          }
        }
      }

      console.log(states);
      createAllDivs();
      $.scrollify.move('#landing');
      $('#landing-page').fadeTo(2000, 1);
      initiateInput('landing');
      popDataInfo();
    },
    error: function(e) {
      console.log(e);
    }
  })
}

/**
 * Formats a received Wikipedia Response Object
 * to make it ready for immediate insertion into DOM
 * @param  {obj} data Response object
 * @return {string}      Formatted string
 */
function formatWikipedia(data) {
  console.log(data);

  console.log(data.query.pages)

  for (var key in data.query.pages) {
    console.log(key);
  }
}

// TODO: specify the calls to be only of a category
// so calls return the expected articles back.

/**
 * Returns a Wikipedia API response object
 * @param  {string} state The state we are retrieving data for
 * @return {object}       Wikipedia API response
 */
function getWikipedia(state) {
  let BASEURL = 'https://en.wikipedia.org/w/api.php'
  let url = BASEURL + '?' + $.param({
    action: 'query',
    prop: 'extracts',
    exintro: null,
    explaintext: null,
    titles: state,
    format: 'json'
  });

  console.log(url);

  $.ajax({
    url: url,
    dataType: 'jsonp',
    crossDomain: true,
    method: 'GET',
    success: function(res) {
      formatWikipedia(res);

    },
    error: function(e) {
      console.log(e);
    }
  })
}
<commit_msg>added wiki extract functionality<commit_after>const BASE_URL = 'https://api.datausa.io/api/?show=geo&sumlevel=state&required=pop,age,income'
var states; // Global object that holds state information
let stats = ["population", "median_age", "median_income"];

// Loads state object
$(document).ready(function($) {

  getWikipedia(5407);

  $.ajax({
    url: 'https://raw.githubusercontent.com/takatanium/UCB-Project1/master/assets/json/states.json',
    dataType: 'json',
    method: 'GET',
    success: function(res) {
      states = res;

      for (let i = 0; i < states.length; i++) {
        states[i]['population'] = {}
        states[i]['median_age'] = {}
        states[i]['median_income'] = {}
      }
      getData();
    },
    error: function(e) {
      console.log(e);
    }
  })
});

/**
 * [getData description]
 * @return {[type]} [description]
 */
function getData() {
  $.ajax({
    url: BASE_URL,
    dataType: 'json',
    method: 'GET',
    success: function(res) {

      for (let i = 0; i < res.data.length; i++) {
        let id = res.data[i][1];

        for (let j = 0; j < states.length; j++) {

          if (id == states[j].id) {

            let year = res.data[i][0];

            // @mmenschig - would love for this to be dynamic
            if (!states[j]['population'].hasOwnProperty(year)) {
              states[j]['population'][year] = res.data[i][2];
            }

            if (!states[j]['median_age'].hasOwnProperty(year)) {
              states[j]['median_age'][year] = res.data[i][3];
            }

            if (!states[j]['median_income'].hasOwnProperty(year)) {
              states[j]['median_income'][year] = res.data[i][4];
            }
          }
        }
      }

      createAllDivs();
      $.scrollify.move('#landing');
      $('#landing-page').fadeTo(2000, 1);
      initiateInput('landing');
      popDataInfo();
    },
    error: function(e) {
      console.log(e);
    }
  })
}

/**
 * Returns a Wikipedia API response object
 * @param  {string} state The state we are retrieving data for
 * @return {object}       Wikipedia API response
 */
function getWikipedia(pageid) {
  let BASEURL = 'https://en.wikipedia.org/w/api.php'
  let url = BASEURL + '?' + $.param({
    action: 'query',
    prop: 'extracts',
    exintro: null,
    explaintext: null,
    exsentences: 5,
    pageids: pageid,
    format: 'json'
  });

  console.log(url);

  $.ajax({
    url: url,
    dataType: 'jsonp',
    crossDomain: true,
    method: 'GET',
    success: function(res) {

      let extract = getExtract(res);
      console.log(extract);
      return extract;
    },
    error: function(e) {
      console.log(e);
    }
  })
}

function getExtract(data) {
  let pages = data.query.pages;

  for (var key in pages) {
    if (pages.hasOwnProperty(key)) {
      return pages[key]["extract"];
    }
  }

}
<|endoftext|>


<commit_before>// Copyright 2016 Joseph W. May. All Rights Reserved.
//
// 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.

/**
 * Passed into the configuration factory constructor
 * @return {myproj.json.Configuration} Default configuration settings.
 */
function getDefaultConfiguration_() {
  return {
    debug: false,

    debugSpreadsheetId: null,

    sheets: {
      classScheduleSheet: {
        name: 'Class Schedule',
        rows: 25,
        cols: 6
      },

      masteryDataSheet: {
        name: 'Mastery Data',
        rows: 68,
        cols: 241
      },

      masteryTrackerSheet: {
        name: 'Mastery Tracker',
        rows: 60,
        cols: 26
      },

      constantsSheet: {
        name: 'Constants',
        rows: 142,
        cols: 8
      }
    },

    studentNumberRange: {
      row: 9,
      col: 1,
      numRows: 60
    }
  };
}

/**
 * Imports the given assignments into the respective learning goal columns of
 * the mastery data sheet. Takes into account whether an assignment is a retake.
 *
 * @param {number} period The class period.
 * @param {array} assignments Array of assignment numbers to import.
 * @param {array} lgNums Array of learning goal numbers as targets for
 *     the import.
 * @param {array} lgNames Array of learning goal names for the import.
 * @param {array} retakes Array of booleans indicating which learning goals
 *     are to be imported as retakes.
 * @returns A string.
 */
function importMasteryData(period, assignments, lgNums, lgNames, retakes) {
  // Get the current gradebook.
  var storage = new PropertyStore();
  var sheetId = storage.getProperty('currentSheetId');
  var gradebook = new Gradebook(sheetId);
  var masteryData = new MasteryData();

  // Verify that the imported data arrays are equal in length.
  if ((assignments.length !== lgNums.length) &&
          (lgNums.length !== lgNames.length) &&
          (lgNames.length !== retakes.length)) {
    throw new Error('There was a problem importing the data. ' +
            'Please try again later.');
  }

  for (var i = 0; i < lgNums.length; i++) {
    // Set the learning goal name if given.
    masteryData.setLearningGoalName(lgNums[i], lgNames[i]);

    // Set the mastery scores.
    var scores = gradebook.getAssignmentScores(assignments[i]);
    masteryData.setLearningGoalScores(period, lgNums[i], scores, retakes[i]);
  }

  return 'Import complete';
}<commit_msg>move import function to scores.controller.server<commit_after>// Copyright 2016 Joseph W. May. All Rights Reserved.
//
// 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.

/**
 * Passed into the configuration factory constructor
 * @return {myproj.json.Configuration} Default configuration settings.
 */
function getDefaultConfiguration_() {
  return {
    debug: false,

    debugSpreadsheetId: null,

    sheets: {
      classScheduleSheet: {
        name: 'Class Schedule',
        rows: 25,
        cols: 6
      },

      masteryDataSheet: {
        name: 'Mastery Data',
        rows: 68,
        cols: 241
      },

      masteryTrackerSheet: {
        name: 'Mastery Tracker',
        rows: 60,
        cols: 26
      },

      constantsSheet: {
        name: 'Constants',
        rows: 142,
        cols: 8
      }
    },

    studentNumberRange: {
      row: 9,
      col: 1,
      numRows: 60
    }
  };
}<|endoftext|>


<commit_before>var colapse = 0;
$(document).ready(function(){

    var validation;
    if (typeof(reglas) != "undefined") {
      validation = {
        debug: false,
        errorPlacement: function(error, element) {
    			// Append error within linked label
    			$( element )
    				.closest( "div" )
    					.append( error );
      	},
        invalidHandler: function(event, validator) {
          $('input[type=submit]').prop( "disabled", false );
          $('input[type=submit]').val('Guardar');
        },
        rules: reglas.rules,
        messages: reglas.messages,
      };
    }

    $('form').submit(function() {
      $('input[type=submit]').val('Procesando');
      $('input[type=submit]').prop( "disabled", true );

      $("form input[type=text]").each(function(){
          $(this).val($(this).val().toUpperCase());
      });

      return true;
    }).validate(validation);

    // menu
    var w = $(window).width();
    if(w > 767) {

      $('.cbp-vimenu > li').hover(function() {
        if (colapse == 0) {
          var i = $(this).index();
          $('.cbp-vimenu > li:eq('+i+') a span').show(100);
        }
      }, function () {
        if (colapse == 0) {
          var i = $(this).index();
          $('.cbp-vimenu > li:eq('+i+') a span').hide(50);
        }
      });

      $("li.content-submenu").click(function() {
        var i = $(this).index()-1;
        var submenu = '.submenu-'+i;
        $(submenu).show(500);
        $('.cbp-vimenu > li a span').hide(50);

        if (0 == colapse) {
          $('ul'+submenu+' > li').hover(function() {
            if (0 == colapse) {
              var i = $(this).index();
              $('ul'+submenu+' > li:eq('+i+') a span').show(100);
            }
          }, function () {
            if (0 == colapse) {
              var i = $(this).index();
              $('ul'+submenu+' > li:eq('+i+') a span').hide(50);
            }
          });
        } else if (1 == colapse) {
          $('ul'+submenu+' > li a span').show(100);
        }
      });

      $("li.content-subsubmenu").click(function() {
        var padre = $(this).parent().attr('class').split(" ")[1].split("-")[1];
        var i = $(this).index()-1;
        var subsubmenu = '.submenu-'+padre+'-'+i;
        $(subsubmenu).css('z-index', '10000');
        $(subsubmenu).show(500);
        $('.cbp-submenu > li a span').hide(50);

        if (0 == colapse) {
          $('ul'+subsubmenu+' > li').hover(function() {
            if (0 == colapse) {
              var i = $(this).index();
              $('ul'+subsubmenu+' > li:eq('+i+') a span').show(100);
            }
          }, function () {
            if (0 == colapse) {
              var i = $(this).index();
              $('ul'+subsubmenu+' > li:eq('+i+') a span').hide(50);
            }
          });
        } else if (1 == colapse) {
          $('ul'+subsubmenu+' > li a span').show(100);
        }
      });

      $(".undo").click(function() {
        $(this).parent().parent().hide(500);

        if (1 == colapse) {
          var clases = $(this).parent().parent().attr('class').split(" ");
          var menus = clases[1].split("-");
          if (2 == menus.length) {
            // se puede cargar el menu principal
            $('.cbp-vimenu .cbp-vimenu-oc').each(function() {
              $(this).show(500);
            });
          } if (3 == menus.length) {
            // se puede cargar un submenu con numero ??
            $('.submenu-'+menus[1]+' .cbp-vimenu-oc').each(function() {
              $(this).show(500);
            });
          }
        }
      });

      $(".pull").click(function() {
        if (0 == colapse) {
          //colapse activo
          colapse = 1;
          $('.cbp-vimenu').css({'width': '13.65em'});
          $(this).parent().siblings().each(function() {
            $(this).find('span').show(500);
          });
        } else if (1 == colapse) {
          colapse = 0;
          $('.cbp-vimenu').css('width', '3em');
          $('.cbp-vimenu-oc').each(function() {
            $(this).hide(500);
          });
        }

      });

    }

    $(function() {
      var pull = $('.pull');
        menu = $('nav ul.cbp-vimenu');
        menuHeight = menu.height();
        w = $(window).width();

        if(w < 767){
          $(".hbp-vimenu li:nth-child(2) > #usuario_sistema").text("");
          $(pull).on('click', function(e) {
              e.preventDefault();
              menu.slideToggle();
              $(".cbp-submenu").hide(250);

              $("li.content-submenu").click(function() {
                var i = $(this).index()-1;
                var submenu = '.submenu-'+i;
                $(submenu).show(500);
              });

              $("li.content-subsubmenu").click(function() {
                var padre = $(this).parent().attr('class').split(" ")[1].split("-")[1];
                var i = $(this).index()-1;
                var subsubmenu = '.submenu-'+padre+'-'+i;
                $(subsubmenu).css('z-index', '10000');
                $(subsubmenu).show(500);
              });
          });

          $(".undo").click(function() {
            $(this).parent().parent().hide(500)
          });
        }
    });

    $(window).resize(function() {
        if(w > 767 && menu.is(':hidden')) {
            menu.removeAttr('style');
        }
    });
    // termina menu

    $('#buscar').keyup(
      function (event) {
        var code = event.keyCode;

        if((code>47 && code<91)||(code>96 && code<123) || code == 8 ) {
          $('.table').remove();
          $.ajax({
            type: 'post',
            url: baseurl + $(this).attr('url'),
            data: { busca: $('#buscar').val().toUpperCase() },
            beforeSend: function(){
              $(".content_table > .limit-content > .table-content").html("

");
              var angulo = 0;
              setInterval(function(){
                    angulo += 3;
                   $("#cargando").rotate(angulo);
              },10);
            },
            success: function(result) {
              $('.content_table > .limit-content > .table-content').html(result);
            },
          });
        }
      }
    );

    $(".close").click(function(){
        $("#myAlert").slideUp();
    });

    $("form").keypress(function(e){
      if(e == 13){
        return false;
      }
    });

    $('input').keypress(function(e){
      if(e.which == 13){
        return false;
      }
    });
});

/*FUNCIONES*/

jQuery.extend({
    stepForm: function(txtBack, txtNext, token){
    	var fieldsets = $((token || 'fieldset'), $("form.stepMe"));
      var cont_form = $('.content-form');
      var barra = $('.barra_carga', $('.content-form'));
      var w = $(cont_form).width();
      var total = $(fieldsets).length;
      var pcu = w/total;
      $(barra).css('width', pcu + 'px');
	    $(fieldsets).each(function(x,el){
			    if (x > 0) {
			      $(el).hide();
			      $(el).append(''+ (txtBack || 'Volver') +'');
			      $(".backStep", $(el)).bind("click", function(){
                $("#x_" + (x - 1)).show();
                $(el).hide();
                $(barra).css('width', pcu*(x) + 'px');
			       });
			    }

			    if ((x+1)< total) {
  	        $(el).append(''+(txtNext || 'Seguir')+'');
  	        $(".nextStep", $(el)).bind("click", function(){
              $("#x_" + (x + 1)).show();
              $(el).hide();
              $(barra).css('width', pcu*(x+2) + 'px');
  	        });
			    }
			    $(el).attr("id", "x_" + x);
	    });
    },

    /*
     * ajaxdata: es el data que recibe el controlador desde el data del ajax
     */
    autocomplete : function ( param ) {
      //variable que controla los autocomplete para teclados
      var mark = 0;

      var elemet = param['elemet'];
      var content = param['content'];
      var uri = param['url'];
      var ajaxdata = {autocomplete: ''}

      if (param.hasOwnProperty('addfunction')) {
        var func = param['addfunction'];
      }

      if (param.hasOwnProperty('asociacion1')) {
        var asociacion1 = param['asociacion1'];
      }

      if (param.hasOwnProperty('ajaxdata')) {
        ajaxdata = param['ajaxdata'];
      }

      elemet.focus(function() {
        ajaxdata['autocomplete'] = elemet.val();
        $.ajax({
          type: 'post',
          url: baseurl + uri,
          data: ajaxdata,
          beforeSend: function(){
            $("#"+content).html("

");
            var angulo = 0;
            setInterval(function(){
                  angulo += 3;
                 $("#cargando").rotate(angulo);
            },10);
          },
          success: function(result) {
            $('#'+content).fadeIn(300).html(result);

            $('.suggest-element').click(function(){
              //Obtenemos la id unica de la sugerencia pulsada
              var id = $(this).attr('ida');
              //Editamos el valor del input con data de la sugerencia pulsada
              elemet.val($('#'+id).attr("data1"));
              $('input[name='+param['name']+']').val($('#'+id).attr("data"));
              //Hacemos desaparecer el resto de sugerencias
              $('#'+content).fadeOut(300);
              //Ejecutamos funcion obtenida
              if (param.hasOwnProperty('addfunction')) {
                func();
              }

              if (param.hasOwnProperty('asociacion1')) {
                $('input[name='+asociacion1+']').val($('#'+id).attr("data2"));
              }
            });
          },
        });
      });

      elemet.keyup( function(event) {
          var code = event.keyCode;

          if((code>47 && code<91)||(code>96 && code<123) || code == 8 ) {
            ajaxdata['autocomplete'] = elemet.val();
            $.ajax({
              type: 'post',
              url: baseurl + uri,
              data: ajaxdata,
              beforeSend: function(){
                $("#"+content).html("

");
                var angulo = 0;
                setInterval(function(){
                      angulo += 3;
                     $("#cargando").rotate(angulo);
                },10);
              },
              success: function(result) {
                $('#'+content).fadeIn(300).html(result);

                $('.suggest-element').click(function(){
                  //Obtenemos la id unica de la sugerencia pulsada
                  var id = $(this).attr('ida');
                  //Editamos el valor del input con data de la sugerencia pulsada
                  elemet.val($('#'+id).attr("data1"));
                  $('input[name='+param['name']+']').val($('#'+id).attr("data"));
                  //Hacemos desaparecer el resto de sugerencias
                  $('#'+content).fadeOut(300);
                  //Ejecutamos funcion obtenida
                  if (param.hasOwnProperty('addfunction')) {
                    func();
                  }

                  if (param.hasOwnProperty('asociacion1')) {
                    $('input[name='+asociacion1+']').val($('#'+id).attr("data2"));
                  }
                });
              },
            });
          } else if(code==40 || code ==38 ) {
              var elements = $('#'+content+' .suggest-element');
              elements.removeClass('suggest-element-select');
              if (elements.size() > 0) {
                if (code==38){
                    mark --;
                }else{
                    mark ++;
                }

                if (mark > elements.size()){
                    mark=0;
                }else if (mark < 0){
                    mark=elements.size();
                }

                elements.each(function(){
                    if ($(this).attr('id') == mark)
                    {
                        $(this).addClass('suggest-element-select');
                    }
                });
              }
          } else if (code == 13) {
            var elements = $('#'+content+' .suggest-element');
            elements.each(function(){
                if ($(this).attr('id') == mark)
                {
                  //Obtenemos la id unica de la sugerencia pulsada
                  var id = $(this).attr('ida');
                  //Editamos el valor del input con data de la sugerencia pulsada
                  elemet.val($('#'+id).attr("data1"));
                  $('input[name='+param['name']+']').val($('#'+id).attr("data"));
                  //Hacemos desaparecer el resto de sugerencias
                  $('#'+content).fadeOut(300);
                  //Ejecutamos funcion obtenida
                  if (param.hasOwnProperty('addfunction')) {
                    func();
                  }

                  if (param.hasOwnProperty('asociacion1')) {
                    $('input[name='+asociacion1+']').val($('#'+id).attr("data2"));
                  }
                  return false;
                }
            });
          }
        }
      );

      //$('body').click(function(){ $('#'+content).fadeOut(300); });
      elemet.focusout(function () {
        $('#'+content).fadeOut(300);
      });
      $('input[name='+param['siguiente']+']').focus(function(){ $('#'+content).fadeOut(300); });
    }
});
<commit_msg>ocultacion automatica de alerts<commit_after>var colapse = 0;
$(document).ready(function(){

    var validation;
    if (typeof(reglas) != "undefined") {
      validation = {
        debug: false,
        errorPlacement: function(error, element) {
    			// Append error within linked label
    			$( element )
    				.closest( "div" )
    					.append( error );
      	},
        invalidHandler: function(event, validator) {
          $('input[type=submit]').prop( "disabled", false );
          $('input[type=submit]').val('Guardar');
        },
        rules: reglas.rules,
        messages: reglas.messages,
      };
    }

    $('form').submit(function() {
      $('input[type=submit]').val('Procesando');
      $('input[type=submit]').prop( "disabled", true );

      $("form input[type=text]").each(function(){
          $(this).val($(this).val().toUpperCase());
      });

      return true;
    }).validate(validation);

    // menu
    var w = $(window).width();
    if(w > 767) {

      $('.cbp-vimenu > li').hover(function() {
        if (colapse == 0) {
          var i = $(this).index();
          $('.cbp-vimenu > li:eq('+i+') a span').show(100);
        }
      }, function () {
        if (colapse == 0) {
          var i = $(this).index();
          $('.cbp-vimenu > li:eq('+i+') a span').hide(50);
        }
      });

      $("li.content-submenu").click(function() {
        var i = $(this).index()-1;
        var submenu = '.submenu-'+i;
        $(submenu).show(500);
        $('.cbp-vimenu > li a span').hide(50);

        if (0 == colapse) {
          $('ul'+submenu+' > li').hover(function() {
            if (0 == colapse) {
              var i = $(this).index();
              $('ul'+submenu+' > li:eq('+i+') a span').show(100);
            }
          }, function () {
            if (0 == colapse) {
              var i = $(this).index();
              $('ul'+submenu+' > li:eq('+i+') a span').hide(50);
            }
          });
        } else if (1 == colapse) {
          $('ul'+submenu+' > li a span').show(100);
        }
      });

      $("li.content-subsubmenu").click(function() {
        var padre = $(this).parent().attr('class').split(" ")[1].split("-")[1];
        var i = $(this).index()-1;
        var subsubmenu = '.submenu-'+padre+'-'+i;
        $(subsubmenu).css('z-index', '10000');
        $(subsubmenu).show(500);
        $('.cbp-submenu > li a span').hide(50);

        if (0 == colapse) {
          $('ul'+subsubmenu+' > li').hover(function() {
            if (0 == colapse) {
              var i = $(this).index();
              $('ul'+subsubmenu+' > li:eq('+i+') a span').show(100);
            }
          }, function () {
            if (0 == colapse) {
              var i = $(this).index();
              $('ul'+subsubmenu+' > li:eq('+i+') a span').hide(50);
            }
          });
        } else if (1 == colapse) {
          $('ul'+subsubmenu+' > li a span').show(100);
        }
      });

      $(".undo").click(function() {
        $(this).parent().parent().hide(500);

        if (1 == colapse) {
          var clases = $(this).parent().parent().attr('class').split(" ");
          var menus = clases[1].split("-");
          if (2 == menus.length) {
            // se puede cargar el menu principal
            $('.cbp-vimenu .cbp-vimenu-oc').each(function() {
              $(this).show(500);
            });
          } if (3 == menus.length) {
            // se puede cargar un submenu con numero ??
            $('.submenu-'+menus[1]+' .cbp-vimenu-oc').each(function() {
              $(this).show(500);
            });
          }
        }
      });

      $(".pull").click(function() {
        if (0 == colapse) {
          //colapse activo
          colapse = 1;
          $('.cbp-vimenu').css({'width': '13.65em'});
          $(this).parent().siblings().each(function() {
            $(this).find('span').show(500);
          });
        } else if (1 == colapse) {
          colapse = 0;
          $('.cbp-vimenu').css('width', '3em');
          $('.cbp-vimenu-oc').each(function() {
            $(this).hide(500);
          });
        }

      });

    }

    $(function() {
      var pull = $('.pull');
        menu = $('nav ul.cbp-vimenu');
        menuHeight = menu.height();
        w = $(window).width();

        if(w < 767){
          $(".hbp-vimenu li:nth-child(2) > #usuario_sistema").text("");
          $(pull).on('click', function(e) {
              e.preventDefault();
              menu.slideToggle();
              $(".cbp-submenu").hide(250);

              $("li.content-submenu").click(function() {
                var i = $(this).index()-1;
                var submenu = '.submenu-'+i;
                $(submenu).show(500);
              });

              $("li.content-subsubmenu").click(function() {
                var padre = $(this).parent().attr('class').split(" ")[1].split("-")[1];
                var i = $(this).index()-1;
                var subsubmenu = '.submenu-'+padre+'-'+i;
                $(subsubmenu).css('z-index', '10000');
                $(subsubmenu).show(500);
              });
          });

          $(".undo").click(function() {
            $(this).parent().parent().hide(500)
          });
        }
    });

    $(window).resize(function() {
        if(w > 767 && menu.is(':hidden')) {
            menu.removeAttr('style');
        }
    });
    // termina menu

    $('#buscar').keyup(
      function (event) {
        var code = event.keyCode;

        if((code>47 && code<91)||(code>96 && code<123) || code == 8 ) {
          $('.table').remove();
          $.ajax({
            type: 'post',
            url: baseurl + $(this).attr('url'),
            data: { busca: $('#buscar').val().toUpperCase() },
            beforeSend: function(){
              $(".content_table > .limit-content > .table-content").html("

");
              var angulo = 0;
              setInterval(function(){
                    angulo += 3;
                   $("#cargando").rotate(angulo);
              },10);
            },
            success: function(result) {
              $('.content_table > .limit-content > .table-content').html(result);
            },
          });
        }
      }
    );

    $(".close").click(function(){
        $("#myAlert").slideUp();
    });

    setInterval(function() {
        $("#myAlert").slideUp();
    }, 5000);

    $("form").keypress(function(e){
      if(e == 13){
        return false;
      }
    });

    $('input').keypress(function(e){
      if(e.which == 13){
        return false;
      }
    });
});

/*FUNCIONES*/

jQuery.extend({
    stepForm: function(txtBack, txtNext, token){
    	var fieldsets = $((token || 'fieldset'), $("form.stepMe"));
      var cont_form = $('.content-form');
      var barra = $('.barra_carga', $('.content-form'));
      var w = $(cont_form).width();
      var total = $(fieldsets).length;
      var pcu = w/total;
      $(barra).css('width', pcu + 'px');
	    $(fieldsets).each(function(x,el){
			    if (x > 0) {
			      $(el).hide();
			      $(el).append(''+ (txtBack || 'Volver') +'');
			      $(".backStep", $(el)).bind("click", function(){
                $("#x_" + (x - 1)).show();
                $(el).hide();
                $(barra).css('width', pcu*(x) + 'px');
			       });
			    }

			    if ((x+1)< total) {
  	        $(el).append(''+(txtNext || 'Seguir')+'');
  	        $(".nextStep", $(el)).bind("click", function(){
              $("#x_" + (x + 1)).show();
              $(el).hide();
              $(barra).css('width', pcu*(x+2) + 'px');
  	        });
			    }
			    $(el).attr("id", "x_" + x);
	    });
    },

    /*
     * ajaxdata: es el data que recibe el controlador desde el data del ajax
     */
    autocomplete : function ( param ) {
      //variable que controla los autocomplete para teclados
      var mark = 0;

      var elemet = param['elemet'];
      var content = param['content'];
      var uri = param['url'];
      var ajaxdata = {autocomplete: ''}

      if (param.hasOwnProperty('addfunction')) {
        var func = param['addfunction'];
      }

      if (param.hasOwnProperty('asociacion1')) {
        var asociacion1 = param['asociacion1'];
      }

      if (param.hasOwnProperty('ajaxdata')) {
        ajaxdata = param['ajaxdata'];
      }

      elemet.focus(function() {
        ajaxdata['autocomplete'] = elemet.val();
        $.ajax({
          type: 'post',
          url: baseurl + uri,
          data: ajaxdata,
          beforeSend: function(){
            $("#"+content).html("

");
            var angulo = 0;
            setInterval(function(){
                  angulo += 3;
                 $("#cargando").rotate(angulo);
            },10);
          },
          success: function(result) {
            $('#'+content).fadeIn(300).html(result);

            $('.suggest-element').click(function(){
              //Obtenemos la id unica de la sugerencia pulsada
              var id = $(this).attr('ida');
              //Editamos el valor del input con data de la sugerencia pulsada
              elemet.val($('#'+id).attr("data1"));
              $('input[name='+param['name']+']').val($('#'+id).attr("data"));
              //Hacemos desaparecer el resto de sugerencias
              $('#'+content).fadeOut(300);
              //Ejecutamos funcion obtenida
              if (param.hasOwnProperty('addfunction')) {
                func();
              }

              if (param.hasOwnProperty('asociacion1')) {
                $('input[name='+asociacion1+']').val($('#'+id).attr("data2"));
              }
            });
          },
        });
      });

      elemet.keyup( function(event) {
          var code = event.keyCode;

          if((code>47 && code<91)||(code>96 && code<123) || code == 8 ) {
            ajaxdata['autocomplete'] = elemet.val();
            $.ajax({
              type: 'post',
              url: baseurl + uri,
              data: ajaxdata,
              beforeSend: function(){
                $("#"+content).html("

");
                var angulo = 0;
                setInterval(function(){
                      angulo += 3;
                     $("#cargando").rotate(angulo);
                },10);
              },
              success: function(result) {
                $('#'+content).fadeIn(300).html(result);

                $('.suggest-element').click(function(){
                  //Obtenemos la id unica de la sugerencia pulsada
                  var id = $(this).attr('ida');
                  //Editamos el valor del input con data de la sugerencia pulsada
                  elemet.val($('#'+id).attr("data1"));
                  $('input[name='+param['name']+']').val($('#'+id).attr("data"));
                  //Hacemos desaparecer el resto de sugerencias
                  $('#'+content).fadeOut(300);
                  //Ejecutamos funcion obtenida
                  if (param.hasOwnProperty('addfunction')) {
                    func();
                  }

                  if (param.hasOwnProperty('asociacion1')) {
                    $('input[name='+asociacion1+']').val($('#'+id).attr("data2"));
                  }
                });
              },
            });
          } else if(code==40 || code ==38 ) {
              var elements = $('#'+content+' .suggest-element');
              elements.removeClass('suggest-element-select');
              if (elements.size() > 0) {
                if (code==38){
                    mark --;
                }else{
                    mark ++;
                }

                if (mark > elements.size()){
                    mark=0;
                }else if (mark < 0){
                    mark=elements.size();
                }

                elements.each(function(){
                    if ($(this).attr('id') == mark)
                    {
                        $(this).addClass('suggest-element-select');
                    }
                });
              }
          } else if (code == 13) {
            var elements = $('#'+content+' .suggest-element');
            elements.each(function(){
                if ($(this).attr('id') == mark)
                {
                  //Obtenemos la id unica de la sugerencia pulsada
                  var id = $(this).attr('ida');
                  //Editamos el valor del input con data de la sugerencia pulsada
                  elemet.val($('#'+id).attr("data1"));
                  $('input[name='+param['name']+']').val($('#'+id).attr("data"));
                  //Hacemos desaparecer el resto de sugerencias
                  $('#'+content).fadeOut(300);
                  //Ejecutamos funcion obtenida
                  if (param.hasOwnProperty('addfunction')) {
                    func();
                  }

                  if (param.hasOwnProperty('asociacion1')) {
                    $('input[name='+asociacion1+']').val($('#'+id).attr("data2"));
                  }
                  return false;
                }
            });
          }
        }
      );

      //$('body').click(function(){ $('#'+content).fadeOut(300); });
      elemet.focusout(function () {
        $('#'+content).fadeOut(300);
      });
      $('input[name='+param['siguiente']+']').focus(function(){ $('#'+content).fadeOut(300); });
    }
});
<|endoftext|>


<commit_before>(function($, exports) {
  Dexter.Maps = function() {
    var self = this;

    self.init = function() {
      if ($('#slippy-map').length === 0) {
        return;
      }

      // resize maps when a tab is toggled
      $('a[data-toggle="tab"]').on('shown.bs.tab', function(e) {
        $($(this).attr('href') + ' .leaflet-container').each(function(i, map) {
          self.map.invalidateSize(false);
        });
      });

      self.map = L.map('slippy-map');
      self.map.setView({lat: -28.4796, lng: 24.698445}, 5);

      var osm = new L.TileLayer('//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
        minZoom: 1,
        maxZoom: 16,
        attribution: 'Map data © OpenStreetMap contributors'});
      self.map.addLayer(osm);

      self.loadAndDrawPlaces();
    };

    self.placesUrl = function() {
      var url = document.location;

      if (document.location.search === "") {
        url = url + "?";
      } else {
        url = url + "&";
      }

      return url + "format=places-json";
    };

    self.loadAndDrawPlaces = function() {
      $.getJSON(self.placesUrl(), self.drawPlaces);
    };

    self.drawPlaceMarker = function(place, coords, radius) {
      L.circleMarker(coords, {
          color: 'red',
          fillColor: '#f03',
          fillOpacity: 0.5
        })
        .setRadius(radius)
        .addTo(self.map)
        .bindPopup(place.full_name + " (" + place.documents.length + ")");
    };

    self.drawPlaces = function(data) {
      var total = data.document_count;

      _.each(data.mentions, function(place) {
        // radius is between 5 and 25, based on the %age of all documents
        // this place relates to
        var radius = 5 + 30 * (place.documents.length / total);

        if (place.type == 'point') {
          // it's a point
          self.drawPlaceMarker(place, place.coordinates, radius);
        } else {
          // it's a region, get the centroid
          d3.json("//maps.code4sa.org/political/2011/" + place.level + '?filter[' + place.level + ']=' + place.code + '&quantization=5000', function(error, topo) {
            if (!topo)
              return;

            var region = L.geoJson(topojson.feature(topo, topo.objects.demarcation));
            self.drawPlaceMarker(place, region.getBounds().getCenter(), radius);
          });
        }
      });
    };
  };
})(jQuery, window);

$(function() {
  new Dexter.Maps().init();
});
<commit_msg>Use http for maps.code4sa.org because the cert is self-signed.<commit_after>(function($, exports) {
  Dexter.Maps = function() {
    var self = this;

    self.init = function() {
      if ($('#slippy-map').length === 0) {
        return;
      }

      // resize maps when a tab is toggled
      $('a[data-toggle="tab"]').on('shown.bs.tab', function(e) {
        $($(this).attr('href') + ' .leaflet-container').each(function(i, map) {
          self.map.invalidateSize(false);
        });
      });

      self.map = L.map('slippy-map');
      self.map.setView({lat: -28.4796, lng: 24.698445}, 5);

      var osm = new L.TileLayer('//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
        minZoom: 1,
        maxZoom: 16,
        attribution: 'Map data © OpenStreetMap contributors'});
      self.map.addLayer(osm);

      self.loadAndDrawPlaces();
    };

    self.placesUrl = function() {
      var url = document.location;

      if (document.location.search === "") {
        url = url + "?";
      } else {
        url = url + "&";
      }

      return url + "format=places-json";
    };

    self.loadAndDrawPlaces = function() {
      $.getJSON(self.placesUrl(), self.drawPlaces);
    };

    self.drawPlaceMarker = function(place, coords, radius) {
      L.circleMarker(coords, {
          color: 'red',
          fillColor: '#f03',
          fillOpacity: 0.5
        })
        .setRadius(radius)
        .addTo(self.map)
        .bindPopup(place.full_name + " (" + place.documents.length + ")");
    };

    self.drawPlaces = function(data) {
      var total = data.document_count;

      _.each(data.mentions, function(place) {
        // radius is between 5 and 25, based on the %age of all documents
        // this place relates to
        var radius = 5 + 30 * (place.documents.length / total);

        if (place.type == 'point') {
          // it's a point
          self.drawPlaceMarker(place, place.coordinates, radius);
        } else {
          // it's a region, get the centroid
          d3.json("http://maps.code4sa.org/political/2011/" + place.level + '?filter[' + place.level + ']=' + place.code + '&quantization=5000', function(error, topo) {
            if (!topo)
              return;

            var region = L.geoJson(topojson.feature(topo, topo.objects.demarcation));
            self.drawPlaceMarker(place, region.getBounds().getCenter(), radius);
          });
        }
      });
    };
  };
})(jQuery, window);

$(function() {
  new Dexter.Maps().init();
});
<|endoftext|>


<commit_before>//	Settings
var setting = {
	mediaQuery:	{
		small: 768,
		medium: 1024,
		large: 1140,
		huge: 1300
	}
};

//	Variables
var $core = {
	win: $(window),
	doc: $(document),
	body: $('body')
};

var $site = {
	wrapper: $('#site-wrapper'),
	page: $('#page-wrapper')
};

var site = {
	resize: {
		timer: false,
		before: {},
		after: {}
	},
	width: $core.win.width(),
	height: $core.win.height(),
	scroll: {
		x: 0,
		y: 0
	},
	transitions: $.support.transition
};

/*--------------------------------

	Functions

--------------------------------*/

/**
 *  Updates site metrics and calls any necessary
 *  functions before and then after a browser resize.
 */
var beforeResize = function(){

	$.each(site.resize.before, function(){

		this();

	});

};

var afterResize = function(){

	site.width = $core.win.width();
	site.height = $core.win.height();

	$.each(site.resize.after, function(){

		this();

	});

};

/*--------------------------------

	Direct events

--------------------------------*/

/*--------------------------------

	Indirect events

--------------------------------*/

$core.win.on({

	resize: function(){

		if( !site.resize.timer )
			beforeResize();

		clearTimeout(site.resize.timer);

		site.resize.timer = setTimeout(function(){

			afterResize();

			site.resize.timer = false;

		}, 200);

	},
	scroll: function(){

		site.scroll.y = document.documentElement.scrollTop;
		site.scroll.y = site.scroll.y === 0 ? document.body.scrollTop : site.scroll.y;

		site.scroll.x = document.documentElement.scrollLeft;
		site.scroll.x = site.scroll.x === 0 ? document.body.scrollLeft : site.scroll.x;

	}

});

/*--------------------------------

    Ready? Go!

--------------------------------*/

$(function(){

	FastClick.attach(document.body);

	$core.body.on('click', 'a:external', function(e){

		if( e.which != 2 ){

			window.open( $(this).attr('href') );

			e.preventDefault();

		}

	});

	$('select').simpleSelect();

});

/*--------------------------------

    Custom plugins

--------------------------------*/

(function($){

	$.fn.simpleSelect = function(settings) {

		// Settings
		var defaults = {
			defaultText: null,
			ready: function(){},
			click: function(){},
			change: function(){}
		};

		var o = $.extend(defaults, settings);

		return this.each(function(){

			// Objects
			var $this = $(this),
				// Are there classes
				classes = 'select ' + ($this.attr('class') ?
					$this.attr('class') : ''),
				// Set the initial text
				initial = o.defaultText === null
					? $this.find('option:selected').text()
					: o.defaultText,
				// The new select
				$s;

			// Wrap everything up
			$this
				.wrap('');

			$s = $this
				.parent('.select');

			// Add in the other contnent
			$s
				.prepend('' + initial + '');

			// Sort out the original select
			$this
				.css({
					width: $s.innerWidth(),
					height: $s.innerHeight(),
					opacity: 0
				}).on({
					change: function(){

						$s.find('span')
							.text( $this.find('option:selected').text() );

						o.change.apply($this);

					},
					click: function(){

						o.click.apply($this);

					},
					focus: function(){

						$s.addClass('focus');

					},
					blur: function(){

						$s.removeClass('focus');

					},
					mouseenter: function(){

						$s.addClass('hover');

					},
					mouseleave: function(){

						$s.removeClass('hover');

					}

				});

			o.ready.apply($this);

		});

	};

})(jQuery);

/*--------------------------------

    Easing

--------------------------------*/

jQuery.extend( jQuery.easing,
{
	def: 'OutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	},
	easeSmoothFade: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	}
});

/*--------------------------------

    External/internal links

--------------------------------*/

jQuery.extend( jQuery.expr[':'],{
	external: function(obj, index, meta, stack){

		return /:\/\//.test($(obj).attr('href'));

	},
	internal: function(obj, index, meta, stack){

		return !/:\/\//.test($(obj).attr('href'));

	}
});<commit_msg>Update site.js<commit_after>//	Settings
var setting = {
	mediaQuery:	{
		small: 768,
		medium: 1024,
		large: 1140,
		huge: 1300
	}
};

//	Variables
var $core = {
	win: $(window),
	doc: $(document),
	body: $('body')
};

var $site = {
	wrapper: $('#site-wrapper'),
	page: $('#page-wrapper')
};

var site = {
	resize: {
		timer: false,
		before: {},
		after: {}
	},
	width: $core.win.width(),
	height: $core.win.height(),
	scroll: {
		x: 0,
		y: 0
	},
	transitions: $.support.transition
};

/*--------------------------------

	Functions

--------------------------------*/

/**
 *  Updates site metrics and calls any necessary
 *  functions before and then after a browser resize.
 */
var beforeResize = function(){

	$.each(site.resize.before, function(){

		this();

	});

};

var afterResize = function(){

	site.width = $core.win.width();
	site.height = $core.win.height();

	$.each(site.resize.after, function(){

		this();

	});

};

/*--------------------------------

	Direct events

--------------------------------*/

/*--------------------------------

	Indirect events

--------------------------------*/

$core.win.on({

	resize: function(){

		if( !site.resize.timer )
			beforeResize();

		clearTimeout(site.resize.timer);

		site.resize.timer = setTimeout(function(){

			afterResize();

			site.resize.timer = false;

		}, 200);

	},
	scroll: function(){

		site.scroll.y = document.documentElement.scrollTop;
		site.scroll.y = site.scroll.y === 0 ? document.body.scrollTop : site.scroll.y;

		site.scroll.x = document.documentElement.scrollLeft;
		site.scroll.x = site.scroll.x === 0 ? document.body.scrollLeft : site.scroll.x;

	}

});

/*--------------------------------

    Ready? Go!

--------------------------------*/

$(function(){

	FastClick.attach(document.body);

	$core.body.on('click', 'a:external', function(e){

		if( e.which != 2 ){

			window.open( $(this).attr('href') );

			e.preventDefault();

		}

	});

	$('select').simpleSelect();

});

/*--------------------------------

    Custom plugins

--------------------------------*/

(function($){

	$.fn.simpleSelect = function(settings) {

		// Settings
		var defaults = {
			defaultText: null,
			ready: function(){},
			click: function(){},
			change: function(){}
		};

		var o = $.extend(defaults, settings);

		return this.each(function(){

			// Objects
			var $this = $(this),
				// Are there classes
				classes = 'select ' + ($this.attr('class') ?
					$this.attr('class') : ''),
				// Set the initial text
				initial = o.defaultText === null
					? $this.find('option:selected').text()
					: o.defaultText,
				// The new select
				$s;

			// Wrap everything up
			$this
				.wrap('');

			$s = $this
				.parent('.select');

			// Add in the other contnent
			$s
				.prepend('' + initial + '');

			// Sort out the original select
			$this
				.css({
					width: $s.innerWidth(),
					height: $s.innerHeight(),
					opacity: 0
				}).on({
					change: function(){

						$s.find('span')
							.text( $this.find('option:selected').text() );

						o.change.apply($this);

					},
					click: function(){

						o.click.apply($this);

					},
					focus: function(){

						$s.addClass('focus');

					},
					blur: function(){

						$s.removeClass('focus');

					},
					mouseenter: function(){

						$s.addClass('hover');

					},
					mouseleave: function(){

						$s.removeClass('hover');

					}

				});

			o.ready.apply($this);

		});

	};

})(jQuery);

/*--------------------------------

    Easing

--------------------------------*/

jQuery.extend( jQuery.easing,
{
	def: 'OutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	},
	easeSmoothFade: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	}
});

/*--------------------------------

    External/internal links

--------------------------------*/

jQuery.extend( jQuery.expr[':'],{
	external: function(obj, index, meta, stack){

		return (obj.hostname != location.hostname) && /:\/\//.test($(obj).attr('href'));

	},
	internal: function(obj, index, meta, stack){

		return (obj.hostname == location.hostname) || !/:\/\//.test($(obj).attr('href'));

	}
});
<|endoftext|>


<commit_before>var exec = require('cordova/exec');

/* constructor */
function Wurst() {}

Wurst.prototype.dummy = function() {
        exec(
            function(result){ alert('ok: '+reply);      },
            function(err){ alert('Error: '+err); }
        , "Wurst", "echoTest", ['dummy']);
}

Wurst.prototype.echoTest = function(str, callback) {
        exec(
            function(reply){ callback('ok: '+reply);      },
            function(err){ callback('Error: '+err); }
        , "Wurst", "echoTest", [str]);
};

Wurst.prototype.backgroundTest = function(str, callback) {
        exec(
            function(reply){ callback('ok: '+reply);      },
            function(err){ callback('Error: '+err); }
        , "Wurst", "backgroundJobTest", [str]);
};

var wurst = new Wurst();
module.exports = wurst;
<commit_msg>Update Wurst.js<commit_after>var exec = require('cordova/exec');

/* constructor */
function Wurst() {}

Wurst.prototype.dummy = function() {
        exec(
            function(reply){ alert('ok: '+reply);      },
            function(err){ alert('Error: '+err); }
        , "Wurst", "echoTest", ['dummy']);
}

Wurst.prototype.echoTest = function(str, callback) {
        exec(
            function(reply){ callback('ok: '+reply);      },
            function(err){ callback('Error: '+err); }
        , "Wurst", "echoTest", [str]);
};

Wurst.prototype.backgroundTest = function(str, callback) {
        exec(
            function(reply){ callback('ok: '+reply);      },
            function(err){ callback('Error: '+err); }
        , "Wurst", "backgroundJobTest", [str]);
};

var wurst = new Wurst();
module.exports = wurst;
<|endoftext|>