<commit_before>/** module for providing a simple interface to a kind of database (only in memory)
 *  @description
 *  primary methods exposed as public:
 *  - select (String type, Number id) [@returns undefined, one element or array of elements]
 *  - insert (String type, Object element) [@returns ID of new element]
 *  - replace (String type, Number id, Object element) [@returns this (the store object)]
 *  - remove (String type, Number id) [@returns this (the store object)]
 *
 *  All methods throw Errors if something went wrong.
 *  Elements stored in store are expected to have an .id property with a numeric value > 0 (except on insert(..))
 @author Johannes Konert
 @licence  CC BY-SA 4.0
 @fires Error in methods if something went wrong
 */
"use strict";

// a singleton for ID generation
var globalCounter = (function() {
    var i = 100;
    return function() {
        return ++i;
    }

})();

// some default store content
var tweets = [
    {   id: globalCounter(),
        message: "Hello world tweet",
        creator: {
            href: "http://localhost:3000/users/103"
        }
    },
    {   id: globalCounter(),
        message: "Another nice tweet",
        creator: {
            href: "http://localhost:3000/users/104"
        }
    }
];
var users = [
    {   id: globalCounter(),
        firstname: "Super",
        lastname: "Woman"
    },
    {   id: globalCounter(),
        firstname: "Jane",
        lastname: "Doe"
    }
];

// our "in memory database" is a simple object!
var memory = {};
memory.tweets = tweets;
memory.users = users;

// private helper functions
var checkElement = function(element) {
    if (typeof(element) !== 'object') {
        throw new Error('Element is not an object to store', element);
    }
};

var store = {

    /** Selects all of one specific element from a given type list
     *
     * @param [string} type - the String identifier of the DB table
     * @param {string or number} id - (optional) ID of element to select only one
     * @returns {[],{}, undefined} - undefined if nothing found, array of objects or one object only if ID was given
     */
    select: function(type, id) {
        var list = memory[type];
        id = parseInt(id);
        if (list != undefined && list.length > 0 && !isNaN(id)) {
            list = list.filter(function(element) {
                return element.id === id;
            });
            list =  (list.length === 0)? undefined: list[0]; // only return the 1 found element; prevent empty []
        }
        return list; // may contain undefined, object or array;
    },

    /** Inserts an element into the list of type
     *
     * @param {string} type
     * @param {object} element
     * @returns {Number} the new id of the inserted element as a Number
     */
    insert: function(type, element) {
        checkElement(element);
        if (element.id !== undefined) {
            throw new Error("element already has an .id value, but should not on insert!",e);
        }
        element.id = globalCounter();
        memory[type].push(element);
        return element.id;
    },

    /** Replaces an existing element. id and newElement.id must be identical
     *
     * @param {string} type
     * @param {string} id
     * @param {object} newElement  needs to have .id property of same value as id
     * @returns {this} the store object itself for pipelining
     */
    replace: function(type, id, newElement) {
        var index = null;
        checkElement(newElement);
        var found = store.select(type, id);
        if (found === undefined) {
            throw new Error('element with id '+id+' does not exist in store type '+type, newElement);
        }
        id = parseInt(id);
        // now get the index of the element
        memory[type].forEach(function(item, i) {
            if (item.id === id) {
                index = i;
            }
        });
        // case of index = null cannot happen as it was found before, but...
        if (!newElement.id == id) {
            throw new Error("element.id and given id are not identical! Cannot replace");
        }
        memory[type][index] = newElement;
        return this;
    },

    /** Removes an element of given id from the store
     *
     * @param {string} type
     * @param {Number} id numerical id of element to remove
     * @returns {this} store object itself for pipelining
     */
    remove: function(type, id) {
        var index = null;
        var found = store.select(type, id);
        if (found === undefined) {
            throw new Error('element with id '+id+' does not exist in store type '+type);
        }
        id = parseInt(id);
        // now get the index of the element
        memory[type].forEach(function(item, i) {
            if (item.id === id) {
                index = i;
            }
        });
        delete memory[type][index];
        return this;
    }
};
module.exports = store; // let require use the store object<commit_msg>adding creator id to the tweets<commit_after>/** module for providing a simple interface to a kind of database (only in memory)
 *  @description
 *  primary methods exposed as public:
 *  - select (String type, Number id) [@returns undefined, one element or array of elements]
 *  - insert (String type, Object element) [@returns ID of new element]
 *  - replace (String type, Number id, Object element) [@returns this (the store object)]
 *  - remove (String type, Number id) [@returns this (the store object)]
 *
 *  All methods throw Errors if something went wrong.
 *  Elements stored in store are expected to have an .id property with a numeric value > 0 (except on insert(..))
 @author Johannes Konert
 @licence  CC BY-SA 4.0
 @fires Error in methods if something went wrong
 */
"use strict";

// a singleton for ID generation
var globalCounter = (function() {
    var i = 100;
    return function() {
        return ++i;
    }

})();

// some default store content
var tweets = [
    {   id: globalCounter(),
        message: "Hello world tweet",
        creator_id: 103,
        creator: {
            href: "http://localhost:3000/users/103"
        }
    },
    {   id: globalCounter(),
        message: "Another nice tweet",
        creator_id: 104,
        creator: {
            href: "http://localhost:3000/users/104"
        }
    }
];
var users = [
    {   id: globalCounter(),
        firstname: "Super",
        lastname: "Woman"
    },
    {   id: globalCounter(),
        firstname: "Jane",
        lastname: "Doe"
    }
];

// our "in memory database" is a simple object!
var memory = {};
memory.tweets = tweets;
memory.users = users;

// private helper functions
var checkElement = function(element) {
    if (typeof(element) !== 'object') {
        throw new Error('Element is not an object to store', element);
    }
};

var store = {

    /** Selects all of one specific element from a given type list
     *
     * @param [string} type - the String identifier of the DB table
     * @param {string or number} id - (optional) ID of element to select only one
     * @returns {[],{}, undefined} - undefined if nothing found, array of objects or one object only if ID was given
     */
    select: function(type, id) {
        var list = memory[type];
        id = parseInt(id);
        if (list != undefined && list.length > 0 && !isNaN(id)) {
            list = list.filter(function(element) {
                return element.id === id;
            });
            list =  (list.length === 0)? undefined: list[0]; // only return the 1 found element; prevent empty []
        }
        return list; // may contain undefined, object or array;
    },

    /** Inserts an element into the list of type
     *
     * @param {string} type
     * @param {object} element
     * @returns {Number} the new id of the inserted element as a Number
     */
    insert: function(type, element) {
        checkElement(element);
        if (element.id !== undefined) {
            throw new Error("element already has an .id value, but should not on insert!",e);
        }
        element.id = globalCounter();
        memory[type].push(element);
        return element.id;
    },

    /** Replaces an existing element. id and newElement.id must be identical
     *
     * @param {string} type
     * @param {string} id
     * @param {object} newElement  needs to have .id property of same value as id
     * @returns {this} the store object itself for pipelining
     */
    replace: function(type, id, newElement) {
        var index = null;
        checkElement(newElement);
        var found = store.select(type, id);
        if (found === undefined) {
            throw new Error('element with id '+id+' does not exist in store type '+type, newElement);
        }
        id = parseInt(id);
        // now get the index of the element
        memory[type].forEach(function(item, i) {
            if (item.id === id) {
                index = i;
            }
        });
        // case of index = null cannot happen as it was found before, but...
        if (!newElement.id == id) {
            throw new Error("element.id and given id are not identical! Cannot replace");
        }
        memory[type][index] = newElement;
        return this;
    },

    /** Removes an element of given id from the store
     *
     * @param {string} type
     * @param {Number} id numerical id of element to remove
     * @returns {this} store object itself for pipelining
     */
    remove: function(type, id) {
        var index = null;
        var found = store.select(type, id);
        if (found === undefined) {
            throw new Error('element with id '+id+' does not exist in store type '+type);
        }
        id = parseInt(id);
        // now get the index of the element
        memory[type].forEach(function(item, i) {
            if (item.id === id) {
                index = i;
            }
        });
        delete memory[type][index];
        return this;
    }
};
module.exports = store; // let require use the store object<|endoftext|>


<commit_before>// You can fiddle with these variables

function mini_histo(width, height, parent, opinions) {
    width = width || 400
    height = height || 70

    // Big power, slow
    var n = 35,           // Number of opinions
        r = 10,           // Size of each avatar
        fade_in_time = 0,
        x_force_mult = 2,
        y_force_mult = 1,
        ratio_filled = .3,
        targets = 'power'

    // (2*r)^2 * length == width * height * ratio_filled
    // (width * height / length) * 2 = (2*r)^2
    // sqrt(width * height / length * 2) = r
    r = Math.sqrt(width * height / opinions.length * ratio_filled)/2
    r = Math.min(r, width/2, height/2)
    if (opinions.length > 10) {
        // Now round r up until it fits perfectly within height
        var times_fit = height / (2*r)
        r = (height / (Math.floor(times_fit))) / 2 - .001
    }
    function x_target(i) {
        var x = i / n

        return (opinions[i].stance + 1)/2 * width

        // if (targets == 'power')
        //     return r + (x * x * width) * ((width - 2*r) / width)

        // else if (targets == 'stacks') {
        //     var num_stacks = 10
        //     return r + (Math.ceil((i / n) * num_stacks) * (width-r-r)) / num_stacks
        // }
    }

    //var svg = d3.select(parent).append("svg")
    var fill = d3.scale.category10()
    var color = d3.scale.linear()
        .domain([0, 10, 20])
        //.range(["#755", '#fff', "#575"])
        //.range(["red", '#fff', "green"])
        .range(["#555", '#fff', "#555"])
        .interpolate(d3.interpolateLab);
    var nodes
    var node
    var force
    var opinions = opinions.slice().sort(function (a,b) {return a.stance-b.stance})
    n = opinions.length

    function init() {
        // svg.attr('width', width)
        //     .attr('height', height)
        //     .style("opacity", 1e-6)
        //     .transition()
        //     .duration(fade_in_time)
        //     .style("opacity", 1)

        nodes = d3.range(opinions.length).map(function(i) {
            //return {index: i, radius: r, x: x_target(i), y: height};
            return {index: i, radius: r,
                    x: r + (width-r-r) * (i / n),
                    //x: r + Math.random() * (width - r - r),  // With random
                    y: r + Math.random() * (height - r-r)// r + (i * 400 / n) % (height-r-r)
                   }
        })

        force = d3.layout.force()
            .nodes(nodes)
        //.size([width, height])
            .on("tick", tick)
            .on('end', function () {console.log('simulation complete')})
            .gravity(0)
            .charge(0)
            .chargeDistance(0)
        //.friction(-.1)
            .start()
        //.alpha(.02)

        // if (node)
        //     svg.selectAll('.node').remove()

        // node = d3.select(parent).selectAll("img")
        //     .data(nodes)
        //     .call(force.drag)
        //     .on("mousedown", function() { d3.event.stopPropagation() })
        //     .on('dragstart', function () { force.alpha(.03) })
        //     // .enter().append("circle")
        //     // .attr("class", "node")
        //     // .attr("cx", function(d) { return d.x })
        //     // .attr("cy", function(d) { return d.y })
        //     // .attr("r", r)
        //     // //.style("fill", function(d, i) { return color(20 - i / n * 20) })
        //     // .style("fill", function(d, i) {
        //     //     return color((opinions[i].stance / 2 + .5) * 20) })
        //     // .style("stroke", function(d, i) {
        //     //     return Math.abs(opinions[i].stance) < .2 && '#ccc' }) //d3.rgb(fill(1)).darker(2) })

        for (var i=0; i<opinions.length; i++)
            opinions[i].icon.style.width = opinions[i].icon.style.height = r*2 + 'px'

        hist = fetch('histogram')
        hist.avatar_size = r*2
        save(hist)
    }
    init()

    //d3.select("body").on("mousedown", scatter)

    function tick(e) {
        // Collision detection
        var q = d3.geom.quadtree(nodes),
            i = 0,
            n = nodes.length

        while (++i < n)
            q.visit(collide(nodes[i]))

        // Apply forces and stuff
        nodes.forEach(function(o, i) {

            // Move for NaNs
            if (isNaN(o.y) || isNaN(o.x)) {
                console.error('Nan0 at', o.x, o.y)
                o.y = height/2
                o.x = x_target(o.index)//width/2
            }

            // Apply forces
            // var time_scale = Math.min(.01 * t++, 1)
            // var k = time_scale * e.alpha
            o.x += e.alpha * (x_force_mult * width  * .001) * (x_target(o.index) - o.x)
            o.y += e.alpha * y_force_mult

            // Clip to bounding box
            o.x = Math.max(r, Math.min(width  - r, o.x))
            o.y = Math.max(r, Math.min(height - r, o.y))

            // Draw
            opinions[i].icon.style.left = o.x - r + 'px'
            opinions[i].icon.style.top  = o.y - r + 'px'
        })

        // node.attr("cx", function(d) { return d.x })
        //     .attr("cy", function(d) { return d.y })
    }

    function collide(node) {
        var r = node.radius + 16,
            nx1 = node.x - r,
            nx2 = node.x + r,
            ny1 = node.y - r,
            ny2 = node.y + r
        return function(quad, x1, y1, x2, y2) {
            if (quad.point && (quad.point !== node)) {
                var x = node.x - quad.point.x,
                    y = node.y - quad.point.y,
                    l = Math.sqrt(x * x + y * y),
                    r = node.radius + quad.point.radius
                if (l < r) {
                    l = (l - r) / l * .5
                    node.x -= x *= l
                    node.y -= y *= l
                    quad.point.x += x
                    quad.point.y += y
                }
            }
            return x1 > nx2
                || x2 < nx1
                || y1 > ny2
                || y2 < ny1
        }
    }
}<commit_msg>adjust y_force_mult based on height<commit_after>// You can fiddle with these variables

function mini_histo(width, height, parent, opinions) {
    width = width || 400
    height = height || 70

    // Big power, slow
    var n = 35,           // Number of opinions
        r = 10,           // Size of each avatar
        fade_in_time = 0,
        x_force_mult = 2,
        y_force_mult = height <= 100 ? 1 : 2,
        ratio_filled = .3,
        targets = 'power'

    // (2*r)^2 * length == width * height * ratio_filled
    // (width * height / length) * 2 = (2*r)^2
    // sqrt(width * height / length * 2) = r
    r = Math.sqrt(width * height / opinions.length * ratio_filled)/2
    r = Math.min(r, width/2, height/2)
    if (opinions.length > 10) {
        // Now round r up until it fits perfectly within height
        var times_fit = height / (2*r)
        r = (height / (Math.floor(times_fit))) / 2 - .001
    }
    function x_target(i) {
        var x = i / n

        return (opinions[i].stance + 1)/2 * width

        // if (targets == 'power')
        //     return r + (x * x * width) * ((width - 2*r) / width)

        // else if (targets == 'stacks') {
        //     var num_stacks = 10
        //     return r + (Math.ceil((i / n) * num_stacks) * (width-r-r)) / num_stacks
        // }
    }

    //var svg = d3.select(parent).append("svg")
    var fill = d3.scale.category10()
    var color = d3.scale.linear()
        .domain([0, 10, 20])
        //.range(["#755", '#fff', "#575"])
        //.range(["red", '#fff', "green"])
        .range(["#555", '#fff', "#555"])
        .interpolate(d3.interpolateLab);
    var nodes
    var node
    var force
    var opinions = opinions.slice().sort(function (a,b) {return a.stance-b.stance})
    n = opinions.length

    function init() {
        // svg.attr('width', width)
        //     .attr('height', height)
        //     .style("opacity", 1e-6)
        //     .transition()
        //     .duration(fade_in_time)
        //     .style("opacity", 1)

        nodes = d3.range(opinions.length).map(function(i) {
            //return {index: i, radius: r, x: x_target(i), y: height};
            return {index: i, radius: r,
                    x: r + (width-r-r) * (i / n),
                    //x: r + Math.random() * (width - r - r),  // With random
                    y: r + Math.random() * (height - r-r)// r + (i * 400 / n) % (height-r-r)
                   }
        })

        force = d3.layout.force()
            .nodes(nodes)
        //.size([width, height])
            .on("tick", tick)
            .on('end', function () {console.log('simulation complete')})
            .gravity(0)
            .charge(0)
            .chargeDistance(0)
        //.friction(-.1)
            .start()
        //.alpha(.02)

        // if (node)
        //     svg.selectAll('.node').remove()

        // node = d3.select(parent).selectAll("img")
        //     .data(nodes)
        //     .call(force.drag)
        //     .on("mousedown", function() { d3.event.stopPropagation() })
        //     .on('dragstart', function () { force.alpha(.03) })
        //     // .enter().append("circle")
        //     // .attr("class", "node")
        //     // .attr("cx", function(d) { return d.x })
        //     // .attr("cy", function(d) { return d.y })
        //     // .attr("r", r)
        //     // //.style("fill", function(d, i) { return color(20 - i / n * 20) })
        //     // .style("fill", function(d, i) {
        //     //     return color((opinions[i].stance / 2 + .5) * 20) })
        //     // .style("stroke", function(d, i) {
        //     //     return Math.abs(opinions[i].stance) < .2 && '#ccc' }) //d3.rgb(fill(1)).darker(2) })

        for (var i=0; i<opinions.length; i++)
            opinions[i].icon.style.width = opinions[i].icon.style.height = r*2 + 'px'

        hist = fetch('histogram')
        hist.avatar_size = r*2
        save(hist)
    }
    init()

    //d3.select("body").on("mousedown", scatter)

    function tick(e) {
        // Collision detection
        var q = d3.geom.quadtree(nodes),
            i = 0,
            n = nodes.length

        while (++i < n)
            q.visit(collide(nodes[i]))

        // Apply forces and stuff
        nodes.forEach(function(o, i) {

            // Move for NaNs
            if (isNaN(o.y) || isNaN(o.x)) {
                console.error('Nan0 at', o.x, o.y)
                o.y = height/2
                o.x = x_target(o.index)//width/2
            }

            // Apply forces
            // var time_scale = Math.min(.01 * t++, 1)
            // var k = time_scale * e.alpha
            o.x += e.alpha * (x_force_mult * width  * .001) * (x_target(o.index) - o.x)
            o.y += e.alpha * y_force_mult

            // Clip to bounding box
            o.x = Math.max(r, Math.min(width  - r, o.x))
            o.y = Math.max(r, Math.min(height - r, o.y))

            // Draw
            opinions[i].icon.style.left = o.x - r + 'px'
            opinions[i].icon.style.top  = o.y - r + 'px'
        })

        // node.attr("cx", function(d) { return d.x })
        //     .attr("cy", function(d) { return d.y })
    }

    function collide(node) {
        var r = node.radius + 16,
            nx1 = node.x - r,
            nx2 = node.x + r,
            ny1 = node.y - r,
            ny2 = node.y + r
        return function(quad, x1, y1, x2, y2) {
            if (quad.point && (quad.point !== node)) {
                var x = node.x - quad.point.x,
                    y = node.y - quad.point.y,
                    l = Math.sqrt(x * x + y * y),
                    r = node.radius + quad.point.radius
                if (l < r) {
                    l = (l - r) / l * .5
                    node.x -= x *= l
                    node.y -= y *= l
                    quad.point.x += x
                    quad.point.y += y
                }
            }
            return x1 > nx2
                || x2 < nx1
                || y1 > ny2
                || y2 < ny1
        }
    }
}<|endoftext|>


<commit_before>import PropTypes from 'prop-types'
import React, { Component } from 'react'

import { asFormField } from '../containers'

class FormCheckbox extends Component {
  static propTypes = {
    disabled: PropTypes.bool.isRequired,
    input: PropTypes.object.isRequired,
  }

  onBlur() {
    this.props.input.onBlur(this._checkboxElem.checked)
  }

  onChange() {
    this.props.input.onChange(this._checkboxElem.checked)
  }

  render() {
    const { disabled, input } = this.props

    return (
      <input
        checked={this.props.input.value}
        className="form__field-input form__field-checkbox"
        disabled={disabled}
        ref={c => { this._refCheckbox = c }}
        type="checkbox"
        {...input}
        onBlur={this.onBlur}
        onChange={this.onChange}
      />
    )
  }

  constructor(props) {
    super(props)

    this.onBlur = this.onBlur.bind(this)
    this.onChange = this.onChange.bind(this)
  }
}

export default asFormField(FormCheckbox)
<commit_msg>Fix wrong reference<commit_after>import PropTypes from 'prop-types'
import React, { Component } from 'react'

import { asFormField } from '../containers'

class FormCheckbox extends Component {
  static propTypes = {
    disabled: PropTypes.bool.isRequired,
    input: PropTypes.object.isRequired,
  }

  onBlur() {
    this.props.input.onBlur(this._checkboxElem.checked)
  }

  onChange() {
    this.props.input.onChange(this._checkboxElem.checked)
  }

  render() {
    const { disabled, input } = this.props

    return (
      <input
        checked={this.props.input.value}
        className="form__field-input form__field-checkbox"
        disabled={disabled}
        ref={c => { this._checkboxElem = c }}
        type="checkbox"
        {...input}
        onBlur={this.onBlur}
        onChange={this.onChange}
      />
    )
  }

  constructor(props) {
    super(props)

    this.onBlur = this.onBlur.bind(this)
    this.onChange = this.onChange.bind(this)
  }
}

export default asFormField(FormCheckbox)
<|endoftext|>


<commit_before>(function() {
  function LandingCtrl() {
    this.heroTitle = "Turn the Music Up!";
  }

  angular
    .module('blocJams')
    .controller('LandingCtrl', LandingCtrl);
})();<commit_msg>Selling points display on home page when scrolled down<commit_after>(function() {
  function LandingCtrl($scope) {
    $scope.heroTitle = "Turn the Music Up!";

    var animatePoints = function() {
    var revealPoint = function() {
      $(this).css({
        opacity: 1,
        transform: 'scaleX(1) translateY(0)'
        });
    };
      $.each($('.point'), revealPoint);
    };

    $(window).load(function() {
      if ($(window).height() > 950) {
        animatePoints();
      }
    var scrollDistance = $('.selling-points').offset().top - $(window).height() + 200;
      $(window).scroll(function(event) {
        if ($(window).scrollTop() >= scrollDistance) {
          animatePoints();
        }
      });
    });
  }

  angular
    .module('blocJams')
    .controller('LandingCtrl', LandingCtrl);
})();<|endoftext|>


<commit_before>/*
    EP_Tools (Eros Pedrini Tools) Thickbox Valdation Fix (js lib)

    This javascript fixs some bugs of the thickbox library and with the provided
    css files permits to validate correctly the thickbox library.

    Coded by Eros Pedrini   (mailto: contezero74@yahoo.it)

    Version: 1.2

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

function getHeight() {
    var h = 0;

    if (typeof(window.innerHeight) == "number") {
        h = window.innerHeight;
    } else {
        if (document.documentElement && document.documentElement.clientHeight) {
            h = document.documentElement.clientHeight;
        } else {
            if (document.body && document.body.clientHeight) {
                h = document.body.clientHeight;
            }
        }
    }

    return h;
}

jQuery(document).ready(function(){
    jQuery('a.thickbox, area.thickbox, input.thickbox').click(function(){
        jQuery('.TB_overlayBG').css({'filter':'alpha(opacity=75)', '-moz-opacity':'0.75', 'opacity':'0.75'});    // lines 41  - 43
        jQuery('#TB_HideSelect').css({'filter':'alpha(opacity=0)', '-moz-opacity':'0', 'opacity':'0'});          // lines 154 - 156
        jQuery('#TB_iframeContent').css({'_margin-bottom':'1px'});                                              // line  175

        var isMSIE6 = jQuery.browser.msie && /MSIE 6\.0/i.test(window.navigator.userAgent) && !/MSIE 7\.0/i.test(window.navigator.userAgent);

        // IE 6 hacks
        if (isMSIE6) {
            var Height_0 = document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'
            jQuery('#TB_overlay').css({'height':Height_0});                                                     // line  50

            var MarginTop_0 = 0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px';
            jQuery('#TB_window').css({'margin-top':MarginTop_0});                                               // line  69

            var MarginTop_1 = 0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px';
            jQuery('#TB_load').css({'margin-top':MarginTop_1});                                                 // line  142

            var Height_1 = document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px';
            jQuery('#TB_HideSelect').css({'height':Height_1});                                                  // line  165
        }

        var TB_HEIGHT = getHeight() - 50; // 50px seems to work in all most cases
        if (!isMSIE6) {
            jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
        }

        return false;
    });
});<commit_msg><commit_after>/*
    EP_Tools (Eros Pedrini Tools) Thickbox Valdation Fix (js lib)

    This javascript fixs some bugs of the thickbox library and with the provided
    css files permits to validate correctly the thickbox library.

    Coded by Eros Pedrini   (mailto: contezero74@yahoo.it)

    Version: 1.3

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

function getHeight() {
    var h = 0;

    if (typeof(window.innerHeight) == "number") {
        h = window.innerHeight;
    } else {
        if (document.documentElement && document.documentElement.clientHeight) {
            h = document.documentElement.clientHeight;
        } else {
            if (document.body && document.body.clientHeight) {
                h = document.body.clientHeight;
            }
        }
    }

    return h;
}

jQuery(document).ready(function(){
    jQuery('a.thickbox, area.thickbox, input.thickbox').click(function(){
        jQuery('.TB_overlayBG').css({'filter':'alpha(opacity=75)', '-moz-opacity':'0.75', 'opacity':'0.75'});    // lines 41  - 43
        jQuery('#TB_HideSelect').css({'filter':'alpha(opacity=0)', '-moz-opacity':'0', 'opacity':'0'});          // lines 154 - 156
        jQuery('#TB_iframeContent').css({'_margin-bottom':'1px'});                                              // line  175

        var isMSIE6 = jQuery.browser.msie && /MSIE 6\.0/i.test(window.navigator.userAgent) && !/MSIE 7\.0/i.test(window.navigator.userAgent);

        // IE 6 hacks
        if (isMSIE6) {
            var Height_0 = document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'
            jQuery('#TB_overlay').css({'height':Height_0});                                                     // line  50

            var MarginTop_0 = 0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px';
            jQuery('#TB_window').css({'margin-top':MarginTop_0});                                               // line  69

            var MarginTop_1 = 0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px';
            jQuery('#TB_load').css({'margin-top':MarginTop_1});                                                 // line  142

            var Height_1 = document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px';
            jQuery('#TB_HideSelect').css({'height':Height_1});                                                  // line  165
        }

        var TB_HEIGHT = getHeight() - 50; // 50px seems to work in all most cases
        if (!isMSIE6) {
            jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
        }

        return false;
    });
});<|endoftext|>


<commit_before>/*
 * multirange.js v0.1.4
 * (c) 2015 Ahmad Ali, ahmadalibaloch@gmail.com
 * License: MIT
 */

'use strict';

angular.module('vds.multirange', ['vds.multirange.lite', 'vds.utils'])
  .directive('vdsMultirange', function (vdsMultirangeViews) {
    return {
      required: 'ngModel',
      scope: {
        ngModel: '=',
        _views: '=views',
        _view: '=view',
		gradient:'='
      },
      template:
      '
' +
        '<vds-multirange-labels render="renderedStyle" ng-model="ngModel"></vds-multirange-labels>' +
        '<vds-multirange-lite ng-model="ngModel" ng-style="renderedStyle.multirange" gradient="gradient" step="step"></vds-multirange-lite>' +
        '<vds-multirange-hairlines render="renderedStyle" ng-model="units"></vds-multirange-hairlines>' +
      '
',
      link: function (scope, elem, attr) {
        scope.getPercent = function(value) {
          return (value*100) + '%';
        };

        scope.changeView = function (n) {
          if(typeof n == 'undefined' || typeof scope.views == 'undefined') return;
          var l = scope.views.length-1, view;
          n = (n < 0)? 0 : ( (n > l)? l : n );
          view = scope.views[n];
          if(typeof view != 'undefined') {
            scope.zoom = view.zoom;
            scope.step = view.step;
            scope.units = view.units;
            scope.renderer();
          }
        };

        scope.$watch('_view', function (n) {
          scope.changeView(n);
        });

        scope.$watch('_views', function (n) {
          scope.views = n;
          scope.view = 0;
          scope.changeView(0);
        });

        scope.renderer = function () {
          if(typeof scope.zoom == 'undefined') return;
          var render = {
            container: {},
            content: {},
            multirange: {
              width: scope.getPercent(scope.zoom),
              display: 'block',
              margin: 'auto'
            }
          };

          if(scope.zoom < 1) {
            render.content.margin = '2 auto';
            render.content.width = 'calc('+scope.getPercent(scope.zoom)+' - 10px)';
            render.container.marginLeft = '0';
          } else {
            render.content.margin = '2 0';
            render.content.width = 'calc('+scope.getPercent(scope.zoom)+' - '+ ( 10 - ( scope.zoom * 5 ) ) +'px)';
            render.container.marginLeft = '5px';
          }
          return scope.renderedStyle = render;
        };

        // set default view config
        if(typeof scope.views == 'undefined') {
          scope.views = vdsMultirangeViews.DEFAULT;
          scope.view = 0;
          scope.changeView(0);
        }

      }
    };
  })
  .directive('vdsMultirangeLabels', function () {
    return {
      restrict: 'E',
      scope: {
        ngModel: '=',
        render: '='
      },
      template:
      '
' +
        '
' +
          '
' +
            '{{ range.name }}' +
			'<input type="text" ng-show="range.editing" ng-keydown="done($event,range)" ng-model="range.name" />' +
          '
' +
        '
' +
      '
',
      link: function (scope, elem, attr) {
		scope.lblDblClick = function(range){
			range.editing = true;
			scope.backuptext=range.name;
		};
		scope.done = function($event,range){
			if ($event.which === 13){
				range.editing=false;
			}
			else if($event.which===8){
				if(range.name.length > 0)return;
				range.name=scope.backuptext;
				range.editing=false;
			}
		}

        scope.renderRange = function (range) {
          return {
            left: (range.value*100)+'%',
            zIndex: range._depth
          }
        }
      }
    }
  })
  .directive('vdsMultirangeHairlines', function () {
    return {
      restrict: 'E',
      scope: {
        ngModel: '=',
        render: '='
      },
      template:
      '
'+
        '
' +
          '
' +
            '{{ hairline.label }}' +
          '
' +
        '
' +
      '
',
      link: function (scope, elem, attr) {

        scope.$watch('ngModel', function (n) {
          if(typeof n == 'undefined') return;
          scope.hairlines = [];
          var levels = n.length, hairHeight = 12, hairline, i, j, u;
          for(i = 0; i < levels; i++) {
            u = n[i];
            for( j = 0; ((j>1)? Math.round(j*1000)/1000 : j) <= 1; j = parseFloat((j + u.value).toFixed(8)) ) {
              hairline = {
                render: {
                  height: hairHeight * (1 - i / levels),
                  left: (j*100)+'%'
                }
              }
              if(typeof u.labeller == 'function') {
                hairline.label = u.labeller(j);
              } else if(typeof u.labeller != 'undefined') {
                hairline.label = j;
              }
              scope.hairlines.push(hairline);
            }
          }
        });

      }
    };
  })
  .factory('vdsMultirangeViews', function (vdsUtils) {
    var tv = vdsUtils.time.fromTimeToValue,
      vt = vdsUtils.time.fromValueToTime,
      pad = vdsUtils.format.padZeroes;
    return {
      TIME: [
        { zoom: 0.9, step: tv(0,15), units: [
          { value: tv(1,0), labeller: function (n) { return vt(n).hours+'h' } },
          { value: tv(0,30) }
        ] },
        { zoom: 1.2, step: tv(0,10), units: [
          { value: tv(1,0), labeller: function (n) { return vt(n).hours+'h' } },
          { value: tv(0,30) }
        ] },
        { zoom: 1.4, step: tv(0,6), units: [
          { value: tv(1,0), labeller: function (n) { return vt(n).hours+'h' } },
          { value: tv(0,30) },
          { value: tv(0,12) }
        ] },
        { zoom: 3.4, step: tv(0,1), units: [
          { value: tv(1,0) },
          { value: tv(0,15), labeller: function (n) {
            var h = vt(n).hours, m = vt(n).minutes;
            return (m==0)? h+'h' : h+':'+pad(m,2);
          } },
          { value: tv(0,5) }
        ] }
      ],
      DEFAULT: [
        { zoom: 0.9, step: 1/40, units: [ { value: 1/10, labeller: function (n) { return n*10 } }, { value: 1/20, } ] },
        { zoom: 1.5, step: 1/80, units: [ { value: 1/20, labeller: function (n) { return n*10 } }, { value: 1/40, } ] }
      ]
    }
  });

angular.module('vds.multirange.lite', [])
  .directive('vdsMultirangeLite', function () {
    return {
      required: 'ngModel',
      scope: {
        ngModel: '=',
        step: '=',
		gradient:'='
      },
      template:
      '
' +
        '

' +
        '
' +
          '<vds-range class="vds-multirange" position="range.value" min="0" max="{{ precision }}" step="{{ preciseStep }}">' +
        '
' +
      '
',
      link: function (scope, elem, attr) {
		  		console.log(scope.gradient);

        var mousex;
        scope.precision = 1000000;
        scope.preciseStep = 1;
        scope.onMouseMove = function (evt) {
          var bound = elem[0].getBoundingClientRect();
          mousex = (evt.pageX - bound.left) / bound.width;
        };
        scope.computeDepth = function (range) {
          range._depth = 100 - Math.round(Math.abs(mousex-range.value)*100);
          return {
            zIndex: range._depth
          };
        };
        scope.$watch('step', function () {
          if(typeof scope.step == 'undefined') {
            scope.preciseStep = 1;
          } else {
            scope.preciseStep = scope.step * scope.precision;
          }
        });
		//Multi-Color
		//Sort by value
		scope.ngModel.sort(
		function(a,b)
		{
			if(a.valueb.value)return 1;
			return 0;
		});

		//===========================================
		var defaultColor = "rgb(235, 235, 235)";
		//
		scope.ngModel.map(function(el){if(!el.color || el.color=="undefined" || el.color.length < 3)el.color=defaultColor;});
		scope.$watch('ngModel',function(nv,ov){
					if(nv==ov)return;
					// Control the sliders positions
					var thisSliderVal;
					var nextSliderVal;
					var prevSliderVal;
					var colorString = "";
					var sCount = scope.ngModel.length;
					for(var i=0;i<sCount;i++){
						thisSliderVal = scope.ngModel[i].value;
						if(i<(sCount-1) && i > 0){//not last or first
							nextSliderVal = scope.ngModel[i+1].value;
							prevSliderVal = scope.ngModel[i-1].value;

								if(thisSliderVal >= nextSliderVal){
									scope.ngModel[i].value=nextSliderVal;
								}
								if(thisSliderVal <= prevSliderVal){
									scope.ngModel[i].value=prevSliderVal;
								}
								//color
								if(scope.gradient){
									colorString +=scope.ngModel[i].color+" "+scope.ngModel[i].value*100+"%,";
								}
								else{
									colorString += scope.ngModel[i].color+" "+scope.ngModel[i-1].value*100+"%,"+scope.ngModel[i].color+" "+scope.ngModel[i].value*100+"%,";
								}
						}
						else if(i==0){//first
							nextSliderVal = scope.ngModel[i+1].value;

							if(thisSliderVal >= nextSliderVal){
									scope.ngModel[i].value=nextSliderVal;
								}
								if(thisSliderVal <= 0){
									scope.ngModel[i].value=0;
								}
								//color
								if(scope.gradient){
									colorString +=scope.ngModel[i].color+" "+scope.ngModel[i].value*100+"%,";
								}
								else{
								colorString += scope.ngModel[i].color+" 0%,"+scope.ngModel[i].color+" "+scope.ngModel[i].value*100+"%,";
								}
						}
						else if(i==sCount-1){//last
							prevSliderVal = scope.ngModel[i-1].value;

								if(thisSliderVal >= scope.MAX_VALUE){
									scope.ngModel[i].value=scope.MAX_VALUE;
								}
								if(thisSliderVal <= prevSliderVal){
									scope.ngModel[i].value=prevSliderVal;
								}
								if(scope.gradient){
									colorString +=scope.ngModel[i].color+" "+scope.ngModel[i].value*100+"%,";
								}
								else{
								colorString += scope.ngModel[i].color+" "+scope.ngModel[i-1].value*100+"%,"+scope.ngModel[i].color+" "+scope.ngModel[i].value*100+"%,";
								colorString += defaultColor+" "+scope.ngModel[i].value*100+"%,"+defaultColor;
								}
						}
					}
					// Update track bar color
					colorString = colorString.substring(0,colorString.length-1);
					var bc = "linear-gradient(left,"+colorString+")";
					//find track bar div
					var track = angular.element(elem).find("div")[0].children[0];
					// multi-browser prefixes for linear-gradient (an empty element represents no prefix, i.e. 'linear-gradient')
					['-webkit-', '-moz-', '-o-', ''].forEach(function(prefix) {
						angular.element(track).css('background', prefix + bc);
					});
				},true);
      }
    };
  })
  .directive('vdsRange', function ($timeout) {
    return {
      template: '<input type="range" ng-model="rdh.mulValue">',
      restrict: 'E',
      replace: true,
      scope: {
        position: '='
      },
      link: function (scope, elem, attr) {
        var RangeDataHelper = function(value, multiplier) {
          this.value = isNaN(value)? 0 : value;
          this.multiplier = multiplier;
          Object.defineProperty(this, 'mulValue', {
            get: function() {
              return (parseFloat(this.value) * this.multiplier) +'';
            },
            set: function(n) {
              this.value = parseInt(n) / this.multiplier;
              scope.position = this.value;
            }
          });
        };
        scope.$watch('position', function (n) {
          if(typeof scope.rdh == 'undefined') {
            scope.rdh = new RangeDataHelper(n, parseInt(attr.max) || 100);
          } else {
            // scope.rdh.multiplier = parseInt(attr.max) || 100;
            scope.rdh.value = n;
          }
        });
      }
    }
  });

angular.module('vds.utils', [])
  .factory('vdsUtils', function() {
    var dayConst = 24*60*60*1000;
    return {
      time: {
        fromTimeToValue: function (hours, minutes) {
          var d = new Date(0);
          d.setUTCHours(hours);
          d.setUTCMinutes(minutes);
          return d.getTime() / dayConst;
        },
        fromValueToTime: function (value) {
          var d = new Date(dayConst * value);
          return {
            hours: d.getUTCHours() + ( (d.getUTCDate()-1) * 24 ),
            minutes: d.getUTCMinutes()
          };
        }
      },
      format: {
        padZeroes: function (num, size) {
          var s = "000000000" + num;
          return s.substr(s.length-size);
        }
      }
    }
  });
<commit_msg>range._depth has to stay >= 0, so z-index works well<commit_after>/*
 * multirange.js v0.1.4
 * (c) 2015 Ahmad Ali, ahmadalibaloch@gmail.com
 * License: MIT
 */

'use strict';

angular.module('vds.multirange', ['vds.multirange.lite', 'vds.utils'])
  .directive('vdsMultirange', function (vdsMultirangeViews) {
    return {
      required: 'ngModel',
      scope: {
        ngModel: '=',
        _views: '=views',
        _view: '=view',
		gradient:'='
      },
      template:
      '
' +
        '<vds-multirange-labels render="renderedStyle" ng-model="ngModel"></vds-multirange-labels>' +
        '<vds-multirange-lite ng-model="ngModel" ng-style="renderedStyle.multirange" gradient="gradient" step="step"></vds-multirange-lite>' +
        '<vds-multirange-hairlines render="renderedStyle" ng-model="units"></vds-multirange-hairlines>' +
      '
',
      link: function (scope, elem, attr) {
        scope.getPercent = function(value) {
          return (value*100) + '%';
        };

        scope.changeView = function (n) {
          if(typeof n == 'undefined' || typeof scope.views == 'undefined') return;
          var l = scope.views.length-1, view;
          n = (n < 0)? 0 : ( (n > l)? l : n );
          view = scope.views[n];
          if(typeof view != 'undefined') {
            scope.zoom = view.zoom;
            scope.step = view.step;
            scope.units = view.units;
            scope.renderer();
          }
        };

        scope.$watch('_view', function (n) {
          scope.changeView(n);
        });

        scope.$watch('_views', function (n) {
          scope.views = n;
          scope.view = 0;
          scope.changeView(0);
        });

        scope.renderer = function () {
          if(typeof scope.zoom == 'undefined') return;
          var render = {
            container: {},
            content: {},
            multirange: {
              width: scope.getPercent(scope.zoom),
              display: 'block',
              margin: 'auto'
            }
          };

          if(scope.zoom < 1) {
            render.content.margin = '2 auto';
            render.content.width = 'calc('+scope.getPercent(scope.zoom)+' - 10px)';
            render.container.marginLeft = '0';
          } else {
            render.content.margin = '2 0';
            render.content.width = 'calc('+scope.getPercent(scope.zoom)+' - '+ ( 10 - ( scope.zoom * 5 ) ) +'px)';
            render.container.marginLeft = '5px';
          }
          return scope.renderedStyle = render;
        };

        // set default view config
        if(typeof scope.views == 'undefined') {
          scope.views = vdsMultirangeViews.DEFAULT;
          scope.view = 0;
          scope.changeView(0);
        }

      }
    };
  })
  .directive('vdsMultirangeLabels', function () {
    return {
      restrict: 'E',
      scope: {
        ngModel: '=',
        render: '='
      },
      template:
      '
' +
        '
' +
          '
' +
            '{{ range.name }}' +
			'<input type="text" ng-show="range.editing" ng-keydown="done($event,range)" ng-model="range.name" />' +
          '
' +
        '
' +
      '
',
      link: function (scope, elem, attr) {
		scope.lblDblClick = function(range){
			range.editing = true;
			scope.backuptext=range.name;
		};
		scope.done = function($event,range){
			if ($event.which === 13){
				range.editing=false;
			}
			else if($event.which===8){
				if(range.name.length > 0)return;
				range.name=scope.backuptext;
				range.editing=false;
			}
		}

        scope.renderRange = function (range) {
          return {
            left: (range.value*100)+'%',
            zIndex: range._depth
          }
        }
      }
    }
  })
  .directive('vdsMultirangeHairlines', function () {
    return {
      restrict: 'E',
      scope: {
        ngModel: '=',
        render: '='
      },
      template:
      '
'+
        '
' +
          '
' +
            '{{ hairline.label }}' +
          '
' +
        '
' +
      '
',
      link: function (scope, elem, attr) {

        scope.$watch('ngModel', function (n) {
          if(typeof n == 'undefined') return;
          scope.hairlines = [];
          var levels = n.length, hairHeight = 12, hairline, i, j, u;
          for(i = 0; i < levels; i++) {
            u = n[i];
            for( j = 0; ((j>1)? Math.round(j*1000)/1000 : j) <= 1; j = parseFloat((j + u.value).toFixed(8)) ) {
              hairline = {
                render: {
                  height: hairHeight * (1 - i / levels),
                  left: (j*100)+'%'
                }
              }
              if(typeof u.labeller == 'function') {
                hairline.label = u.labeller(j);
              } else if(typeof u.labeller != 'undefined') {
                hairline.label = j;
              }
              scope.hairlines.push(hairline);
            }
          }
        });

      }
    };
  })
  .factory('vdsMultirangeViews', function (vdsUtils) {
    var tv = vdsUtils.time.fromTimeToValue,
      vt = vdsUtils.time.fromValueToTime,
      pad = vdsUtils.format.padZeroes;
    return {
      TIME: [
        { zoom: 0.9, step: tv(0,15), units: [
          { value: tv(1,0), labeller: function (n) { return vt(n).hours+'h' } },
          { value: tv(0,30) }
        ] },
        { zoom: 1.2, step: tv(0,10), units: [
          { value: tv(1,0), labeller: function (n) { return vt(n).hours+'h' } },
          { value: tv(0,30) }
        ] },
        { zoom: 1.4, step: tv(0,6), units: [
          { value: tv(1,0), labeller: function (n) { return vt(n).hours+'h' } },
          { value: tv(0,30) },
          { value: tv(0,12) }
        ] },
        { zoom: 3.4, step: tv(0,1), units: [
          { value: tv(1,0) },
          { value: tv(0,15), labeller: function (n) {
            var h = vt(n).hours, m = vt(n).minutes;
            return (m==0)? h+'h' : h+':'+pad(m,2);
          } },
          { value: tv(0,5) }
        ] }
      ],
      DEFAULT: [
        { zoom: 0.9, step: 1/40, units: [ { value: 1/10, labeller: function (n) { return n*10 } }, { value: 1/20, } ] },
        { zoom: 1.5, step: 1/80, units: [ { value: 1/20, labeller: function (n) { return n*10 } }, { value: 1/40, } ] }
      ]
    }
  });

angular.module('vds.multirange.lite', [])
  .directive('vdsMultirangeLite', function () {
    return {
      required: 'ngModel',
      scope: {
        ngModel: '=',
        step: '=',
		gradient:'='
      },
      template:
      '
' +
        '

' +
        '
' +
          '<vds-range class="vds-multirange" position="range.value" min="0" max="{{ precision }}" step="{{ preciseStep }}">' +
        '
' +
      '
',
      link: function (scope, elem, attr) {
		  		console.log(scope.gradient);

        var mousex;
        scope.precision = 1000000;
        scope.preciseStep = 1;
        scope.onMouseMove = function (evt) {
          var bound = elem[0].getBoundingClientRect();
          mousex = (evt.pageX - bound.left) / bound.width;
        };
        scope.computeDepth = function (range) {
          var depth = 100 - Math.round(Math.abs(mousex-range.value)*100);
          range._depth = depth >=0 ? depth : 0;
          return {
            zIndex: range._depth
          };
        };
        scope.$watch('step', function () {
          if(typeof scope.step == 'undefined') {
            scope.preciseStep = 1;
          } else {
            scope.preciseStep = scope.step * scope.precision;
          }
        });
		//Multi-Color
		//Sort by value
		scope.ngModel.sort(
		function(a,b)
		{
			if(a.valueb.value)return 1;
			return 0;
		});

		//===========================================
		var defaultColor = "rgb(235, 235, 235)";
		//
		scope.ngModel.map(function(el){if(!el.color || el.color=="undefined" || el.color.length < 3)el.color=defaultColor;});
		scope.$watch('ngModel',function(nv,ov){
					if(nv==ov)return;
					// Control the sliders positions
					var thisSliderVal;
					var nextSliderVal;
					var prevSliderVal;
					var colorString = "";
					var sCount = scope.ngModel.length;
					for(var i=0;i<sCount;i++){
						thisSliderVal = scope.ngModel[i].value;
						if(i<(sCount-1) && i > 0){//not last or first
							nextSliderVal = scope.ngModel[i+1].value;
							prevSliderVal = scope.ngModel[i-1].value;

								if(thisSliderVal >= nextSliderVal){
									scope.ngModel[i].value=nextSliderVal;
								}
								if(thisSliderVal <= prevSliderVal){
									scope.ngModel[i].value=prevSliderVal;
								}
								//color
								if(scope.gradient){
									colorString +=scope.ngModel[i].color+" "+scope.ngModel[i].value*100+"%,";
								}
								else{
									colorString += scope.ngModel[i].color+" "+scope.ngModel[i-1].value*100+"%,"+scope.ngModel[i].color+" "+scope.ngModel[i].value*100+"%,";
								}
						}
						else if(i==0){//first
							nextSliderVal = scope.ngModel[i+1].value;

							if(thisSliderVal >= nextSliderVal){
									scope.ngModel[i].value=nextSliderVal;
								}
								if(thisSliderVal <= 0){
									scope.ngModel[i].value=0;
								}
								//color
								if(scope.gradient){
									colorString +=scope.ngModel[i].color+" "+scope.ngModel[i].value*100+"%,";
								}
								else{
								colorString += scope.ngModel[i].color+" 0%,"+scope.ngModel[i].color+" "+scope.ngModel[i].value*100+"%,";
								}
						}
						else if(i==sCount-1){//last
							prevSliderVal = scope.ngModel[i-1].value;

								if(thisSliderVal >= scope.MAX_VALUE){
									scope.ngModel[i].value=scope.MAX_VALUE;
								}
								if(thisSliderVal <= prevSliderVal){
									scope.ngModel[i].value=prevSliderVal;
								}
								if(scope.gradient){
									colorString +=scope.ngModel[i].color+" "+scope.ngModel[i].value*100+"%,";
								}
								else{
								colorString += scope.ngModel[i].color+" "+scope.ngModel[i-1].value*100+"%,"+scope.ngModel[i].color+" "+scope.ngModel[i].value*100+"%,";
								colorString += defaultColor+" "+scope.ngModel[i].value*100+"%,"+defaultColor;
								}
						}
					}
					// Update track bar color
					colorString = colorString.substring(0,colorString.length-1);
					var bc = "linear-gradient(left,"+colorString+")";
					//find track bar div
					var track = angular.element(elem).find("div")[0].children[0];
					// multi-browser prefixes for linear-gradient (an empty element represents no prefix, i.e. 'linear-gradient')
					['-webkit-', '-moz-', '-o-', ''].forEach(function(prefix) {
						angular.element(track).css('background', prefix + bc);
					});
				},true);
      }
    };
  })
  .directive('vdsRange', function ($timeout) {
    return {
      template: '<input type="range" ng-model="rdh.mulValue">',
      restrict: 'E',
      replace: true,
      scope: {
        position: '='
      },
      link: function (scope, elem, attr) {
        var RangeDataHelper = function(value, multiplier) {
          this.value = isNaN(value)? 0 : value;
          this.multiplier = multiplier;
          Object.defineProperty(this, 'mulValue', {
            get: function() {
              return (parseFloat(this.value) * this.multiplier) +'';
            },
            set: function(n) {
              this.value = parseInt(n) / this.multiplier;
              scope.position = this.value;
            }
          });
        };
        scope.$watch('position', function (n) {
          if(typeof scope.rdh == 'undefined') {
            scope.rdh = new RangeDataHelper(n, parseInt(attr.max) || 100);
          } else {
            // scope.rdh.multiplier = parseInt(attr.max) || 100;
            scope.rdh.value = n;
          }
        });
      }
    }
  });

angular.module('vds.utils', [])
  .factory('vdsUtils', function() {
    var dayConst = 24*60*60*1000;
    return {
      time: {
        fromTimeToValue: function (hours, minutes) {
          var d = new Date(0);
          d.setUTCHours(hours);
          d.setUTCMinutes(minutes);
          return d.getTime() / dayConst;
        },
        fromValueToTime: function (value) {
          var d = new Date(dayConst * value);
          return {
            hours: d.getUTCHours() + ( (d.getUTCDate()-1) * 24 ),
            minutes: d.getUTCMinutes()
          };
        }
      },
      format: {
        padZeroes: function (num, size) {
          var s = "000000000" + num;
          return s.substr(s.length-size);
        }
      }
    }
  });
<|endoftext|>


<commit_before>define(["Tone/core/Tone", "Tone/core/Context"], function (Tone) {

	/**
	 *  @class Tone.AudioNode is a base class for classes which process audio.
	 *         AudioNodes have inputs and outputs.
	 *  @param	{AudioContext=} context	The audio context to use with the class
	 *  @extends {Tone}
	 */
	Tone.AudioNode = function(){
		Tone.call(this);

		//use the default context if one is not passed in
		var options = Tone.defaults(arguments, ["context"], {
			"context" : Tone.context
		});

		/**
		 * The AudioContext of this instance
		 * @private
		 * @type {AudioContext}
		 */
		this._context = options.context;
	};

	Tone.extend(Tone.AudioNode);

	/**
	 * Get the audio context belonging to this instance.
	 * @type {AudioNode}
	 * @memberOf Tone.AudioNode#
	 * @name context
	 * @readOnly
	 */
	Object.defineProperty(Tone.AudioNode.prototype, "context", {
		get : function(){
			return this._context;
		}
	});

	/**
	 *  Create input and outputs for this object.
	 *  @param  {Number}  [input=0]   The number of inputs
	 *  @param  {Number}  [outputs=0]  The number of outputs
	 *  @return  {Tone}  this
	 *  @private
	 */
	Tone.AudioNode.prototype.createInsOuts = function(inputs, outputs){

		if (inputs === 1){
			this.input = this.context.createGain();
		} else if (inputs > 1){
			this.input = new Array(inputs);
		}

		if (outputs === 1){
			this.output = this.context.createGain();
		} else if (outputs > 1){
			this.output = new Array(outputs);
		}
	};

	/**
	 *  The number of inputs feeding into the AudioNode.
	 *  For source nodes, this will be 0.
	 *  @memberOf Tone#
	 *  @type {Number}
	 *  @name numberOfInputs
	 *  @readOnly
	 */
	Object.defineProperty(Tone.AudioNode.prototype, "numberOfInputs", {
		get : function(){
			if (this.input){
				if (Tone.isArray(this.input)){
					return this.input.length;
				} else {
					return 1;
				}
			} else {
				return 0;
			}
		}
	});

	/**
	 *  The number of outputs coming out of the AudioNode.
	 *  @memberOf Tone#
	 *  @type {Number}
	 *  @name numberOfOutputs
	 *  @readOnly
	 */
	Object.defineProperty(Tone.AudioNode.prototype, "numberOfOutputs", {
		get : function(){
			if (this.output){
				if (Tone.isArray(this.output)){
					return this.output.length;
				} else {
					return 1;
				}
			} else {
				return 0;
			}
		}
	});

		/**
	 *  connect the output of a ToneNode to an AudioParam, AudioNode, or ToneNode
	 *  @param  {Tone | AudioParam | AudioNode} unit
	 *  @param {number} [outputNum=0] optionally which output to connect from
	 *  @param {number} [inputNum=0] optionally which input to connect to
	 *  @returns {Tone} this
	 *  @memberOf Tone#
	 */
	Tone.AudioNode.prototype.connect = function(unit, outputNum, inputNum){
		if (Tone.isArray(this.output)){
			outputNum = Tone.defaultArg(outputNum, 0);
			this.output[outputNum].connect(unit, 0, inputNum);
		} else {
			this.output.connect(unit, outputNum, inputNum);
		}
		return this;
	};

	/**
	 *  disconnect the output
	 *  @param {Number|AudioNode} output Either the output index to disconnect
	 *                                   if the output is an array, or the
	 *                                   node to disconnect from.
	 *  @returns {Tone} this
	 *  @memberOf Tone#
	 */
	Tone.AudioNode.prototype.disconnect = function(destination, outputNum, inputNum){
		if (Tone.isArray(this.output)){
			if (Tone.isNumber(destination)){
				this.output[destination].disconnect();
			} else {
				outputNum = Tone.defaultArg(outputNum, 0);
				this.output[outputNum].disconnect(destination, 0, inputNum);
			}
		} else {
			this.output.disconnect.apply(this.output, arguments);
		}
	};

	/**
	 *  Connect the output of this node to the rest of the nodes in series.
	 *  @example
	 *  //connect a node to an effect, panVol and then to the master output
	 *  node.chain(effect, panVol, Tone.Master);
	 *  @param {...AudioParam|Tone|AudioNode} nodes
	 *  @returns {Tone} this
	 *  @memberOf Tone#
	 */
	Tone.AudioNode.prototype.chain = function(){
		var currentUnit = this;
		for (var i = 0; i < arguments.length; i++){
			var toUnit = arguments[i];
			currentUnit.connect(toUnit);
			currentUnit = toUnit;
		}
		return this;
	};

	/**
	 *  connect the output of this node to the rest of the nodes in parallel.
	 *  @param {...AudioParam|Tone|AudioNode} nodes
	 *  @returns {Tone} this
	 *  @memberOf Tone#
	 */
	Tone.AudioNode.prototype.fan = function(){
		for (var i = 0; i < arguments.length; i++){
			this.connect(arguments[i]);
		}
		return this;
	};

	if (window.AudioNode){
		//give native nodes chain and fan methods
		AudioNode.prototype.chain = Tone.AudioNode.prototype.chain;
		AudioNode.prototype.fan = Tone.AudioNode.prototype.fan;
	}

	/**
	 * Dispose and disconnect
	 * @return {Tone.AudioNode} this
	 */
	Tone.AudioNode.prototype.dispose = function () {
		if (!Tone.isUndef(this.input)){
			if (this.input instanceof AudioNode){
				this.input.disconnect();
			}
			this.input = null;
		}
		if (!Tone.isUndef(this.output)){
			if (this.output instanceof AudioNode){
				this.output.disconnect();
			}
			this.output = null;
		}
		this._context = null;
		return this;
	};

	return Tone.AudioNode;
});
<commit_msg>updating connect methods jsdocs<commit_after>define(["Tone/core/Tone", "Tone/core/Context"], function (Tone) {

	/**
	 *  @class Tone.AudioNode is a base class for classes which process audio.
	 *         AudioNodes have inputs and outputs.
	 *  @param	{AudioContext=} context	The audio context to use with the class
	 *  @extends {Tone}
	 */
	Tone.AudioNode = function(){
		Tone.call(this);

		//use the default context if one is not passed in
		var options = Tone.defaults(arguments, ["context"], {
			"context" : Tone.context
		});

		/**
		 * The AudioContext of this instance
		 * @private
		 * @type {AudioContext}
		 */
		this._context = options.context;
	};

	Tone.extend(Tone.AudioNode);

	/**
	 * Get the audio context belonging to this instance.
	 * @type {AudioNode}
	 * @memberOf Tone.AudioNode#
	 * @name context
	 * @readOnly
	 */
	Object.defineProperty(Tone.AudioNode.prototype, "context", {
		get : function(){
			return this._context;
		}
	});

	/**
	 *  Create input and outputs for this object.
	 *  @param  {Number}  [input=0]   The number of inputs
	 *  @param  {Number}  [outputs=0]  The number of outputs
	 *  @return  {Tone.AudioNode}  this
	 *  @private
	 */
	Tone.AudioNode.prototype.createInsOuts = function(inputs, outputs){

		if (inputs === 1){
			this.input = this.context.createGain();
		} else if (inputs > 1){
			this.input = new Array(inputs);
		}

		if (outputs === 1){
			this.output = this.context.createGain();
		} else if (outputs > 1){
			this.output = new Array(outputs);
		}
	};

	/**
	 *  The number of inputs feeding into the AudioNode.
	 *  For source nodes, this will be 0.
	 *  @type {Number}
	 *  @name numberOfInputs
	 *  @readOnly
	 */
	Object.defineProperty(Tone.AudioNode.prototype, "numberOfInputs", {
		get : function(){
			if (this.input){
				if (Tone.isArray(this.input)){
					return this.input.length;
				} else {
					return 1;
				}
			} else {
				return 0;
			}
		}
	});

	/**
	 *  The number of outputs coming out of the AudioNode.
	 *  @type {Number}
	 *  @name numberOfOutputs
	 *  @readOnly
	 */
	Object.defineProperty(Tone.AudioNode.prototype, "numberOfOutputs", {
		get : function(){
			if (this.output){
				if (Tone.isArray(this.output)){
					return this.output.length;
				} else {
					return 1;
				}
			} else {
				return 0;
			}
		}
	});

		/**
	 *  connect the output of a ToneNode to an AudioParam, AudioNode, or ToneNode
	 *  @param  {Tone | AudioParam | AudioNode} unit
	 *  @param {number} [outputNum=0] optionally which output to connect from
	 *  @param {number} [inputNum=0] optionally which input to connect to
	 *  @returns {Tone.AudioNode} this
	 */
	Tone.AudioNode.prototype.connect = function(unit, outputNum, inputNum){
		if (Tone.isArray(this.output)){
			outputNum = Tone.defaultArg(outputNum, 0);
			this.output[outputNum].connect(unit, 0, inputNum);
		} else {
			this.output.connect(unit, outputNum, inputNum);
		}
		return this;
	};

	/**
	 *  disconnect the output
	 *  @param {Number|AudioNode} output Either the output index to disconnect
	 *                                   if the output is an array, or the
	 *                                   node to disconnect from.
	 *  @returns {Tone.AudioNode} this
	 */
	Tone.AudioNode.prototype.disconnect = function(destination, outputNum, inputNum){
		if (Tone.isArray(this.output)){
			if (Tone.isNumber(destination)){
				this.output[destination].disconnect();
			} else {
				outputNum = Tone.defaultArg(outputNum, 0);
				this.output[outputNum].disconnect(destination, 0, inputNum);
			}
		} else {
			this.output.disconnect.apply(this.output, arguments);
		}
	};

	/**
	 *  Connect the output of this node to the rest of the nodes in series.
	 *  @example
	 *  //connect a node to an effect, panVol and then to the master output
	 *  node.chain(effect, panVol, Tone.Master);
	 *  @param {...AudioParam|Tone|AudioNode} nodes
	 *  @returns {Tone.AudioNode} this
	 */
	Tone.AudioNode.prototype.chain = function(){
		var currentUnit = this;
		for (var i = 0; i < arguments.length; i++){
			var toUnit = arguments[i];
			currentUnit.connect(toUnit);
			currentUnit = toUnit;
		}
		return this;
	};

	/**
	 *  connect the output of this node to the rest of the nodes in parallel.
	 *  @param {...AudioParam|Tone|AudioNode} nodes
	 *  @returns {Tone.AudioNode} this
	 */
	Tone.AudioNode.prototype.fan = function(){
		for (var i = 0; i < arguments.length; i++){
			this.connect(arguments[i]);
		}
		return this;
	};

	if (window.AudioNode){
		//give native nodes chain and fan methods
		AudioNode.prototype.chain = Tone.AudioNode.prototype.chain;
		AudioNode.prototype.fan = Tone.AudioNode.prototype.fan;
	}

	/**
	 * Dispose and disconnect
	 * @return {Tone.AudioNode} this
	 */
	Tone.AudioNode.prototype.dispose = function () {
		if (!Tone.isUndef(this.input)){
			if (this.input instanceof AudioNode){
				this.input.disconnect();
			}
			this.input = null;
		}
		if (!Tone.isUndef(this.output)){
			if (this.output instanceof AudioNode){
				this.output.disconnect();
			}
			this.output = null;
		}
		this._context = null;
		return this;
	};

	return Tone.AudioNode;
});
<|endoftext|>


<commit_before>app.directive("searchBar", function() {
  return {
    restrict: "E",
    templateUrl: "app/search_bar/search_bar.html",
    controller: function($scope, $location, $http, settings) {
      $scope.sampleDeckUrl = settings.SAMPLE_DECK_URL;

      $scope.search = function() {
        var query = $("#query").val();
        if (query.trim().length > 0) {
          $location.path("/recommendations").search({ "q": query });
        }
      };

      $http.get("public/commanders.txt").then(function(result) {
        $("#query").autocomplete({
          source: result.data.split("\n"),
          minLength: 2,
          select: function(event, ui) {
            $("#search_button").click();
          }
        });
      });

      $("#query").focus();
    }
  }
});
<commit_msg>No need for min length on autocomplete<commit_after>app.directive("searchBar", function() {
  return {
    restrict: "E",
    templateUrl: "app/search_bar/search_bar.html",
    controller: function($scope, $location, $http, settings) {
      $scope.sampleDeckUrl = settings.SAMPLE_DECK_URL;

      $scope.search = function() {
        var query = $("#query").val();
        if (query.trim().length > 0) {
          $location.path("/recommendations").search({ "q": query });
        }
      };

      $http.get("public/commanders.txt").then(function(result) {
        $("#query").autocomplete({
          source: result.data.split("\n"),
          select: function(event, ui) {
            $("#search_button").click();
          }
        });
      });

      $("#query").focus();
    }
  }
});
<|endoftext|>


<commit_before>var async = require('async');

var replicate = function(n, x) {
  if (n == 0) {
    return [];
  } else {
    return [x].concat(replicate(n - 1, x));
  }
};

// Sometimes getters are having more then one argument, filling those
// arguments with nulls here, assuming last argument is a callback for
// return value.
var funcall = function(context, f, callback) {
  f.apply(context, replicate(f.length - 1, null).concat([callback]));
};

exports.addSerializer = function() {
  var AbstractSerializer = function(object, strategy) {
    this.object   = object;
    this.strategy = strategy;
  };

  AbstractSerializer.prototype = {
    END_POINT: 1,
    NESTED_STRATEGY: 2,
    THROUGH_POINT: 3,

    getField: function(field, f) {
      if (!this.object) {
        f(null, null);
      } else if (!this.object[field]) {
        var method = this.object["get" + field.capitalize()];

        method ? funcall(this.object, method, f) : f(null, null);
      } else {
        f(null, this.object[field]);
      }
    },

    decideNode: function(field) {
      if (!this.strategy[field]) {
        return this.END_POINT;
      } else {
        if (this.strategy[field].through) {
          return this.THROUGH_POINT;
        } else {
          return this.NESTED_STRATEGY;
        }
      }
    },

    processMultiObjects: function(objects, strategy, f, serializer) {
      var result = [];
      var jsonAdder = function(done) {
        return function(err, json) {
          result.push(json);
          done(err);
        };
      };

      async.forEach(objects, function(object, done) {
        if (serializer) {
          new serializer(object).toJSON(jsonAdder(done));
        } else {
          new AbstractSerializer(object, strategy).toJSON(jsonAdder(done));
        }
      }, function(err) {
        f(err, result);
      });
    },

    getMaybeObjects: function(field, one, many) {
      this.getField(field, function(err, object) {
        Array.isArray(object) ? many(object) : one(object);
      });
    },

    processNestedStrategy: function(field, f) {
      var serializer = this;

      serializer.getMaybeObjects(field, function(object) {
        new AbstractSerializer(object, serializer.strategy[field]).toJSON(f);
      }, function(objects) {
        serializer.processMultiObjects(objects, serializer.strategy[field], f);
      });
    },

    processThroughPoint: function(field, f) {
      var serializer = this;

      serializer.getMaybeObjects(field, function(object) {
        new serializer.strategy[field].through(object).toJSON(f);
      }, function(objects) {
        serializer.processMultiObjects(objects, null, f, serializer.strategy[field].through);
      });
    },

    processNode: function(jsonAdder) {
      var serializer = this;

      return function(field, done) {
        switch (serializer.decideNode(field)) {

        case serializer.END_POINT:
          serializer.getField(field, jsonAdder(field, done));
          break;

        case serializer.NESTED_STRATEGY:
          serializer.processNestedStrategy(field, jsonAdder(field, done));
          break;

        case serializer.THROUGH_POINT:
          serializer.processThroughPoint(field, jsonAdder(field, done));
          break;
        }
      };
    },

    toJSON: function(f) {
      var json = {};
      var jsonAdder = function(field, done) {
        return function(err, res) {
          json[field] = res;
          done(err);
        };
      };

      async.forEach(this.strategy.select, this.processNode(jsonAdder) , function(err) {
        f(err, json);
      });
    }
  };

  return AbstractSerializer;
};
<commit_msg>Implements embedded attributes for serializers.<commit_after>var async = require('async');

var replicate = function(n, x) {
  if (n == 0) {
    return [];
  } else {
    return [x].concat(replicate(n - 1, x));
  }
};

// Sometimes getters are having more then one argument, filling those
// arguments with nulls here, assuming last argument is a callback for
// return value.
var funcall = function(context, f, callback) {
  f.apply(context, replicate(f.length - 1, null).concat([callback]));
};

exports.addSerializer = function() {
  var AbstractSerializer = function(object, strategy) {
    this.object   = object;
    this.strategy = strategy;
  };

  AbstractSerializer.prototype = {
    END_POINT: 1,
    NESTED_STRATEGY: 2,
    THROUGH_POINT: 3,

    getField: function(field, f) {
      if (!this.object) {
        f(null, null);
      } else if (!this.object[field]) {
        var method = this.object["get" + field.capitalize()];

        method ? funcall(this.object, method, f) : f(null, null);
      } else {
        f(null, this.object[field]);
      }
    },

    decideNode: function(field) {
      if (!this.strategy[field]) {
        return this.END_POINT;
      } else {
        if (this.strategy[field].through) {
          return this.THROUGH_POINT;
        } else {
          return this.NESTED_STRATEGY;
        }
      }
    },

    prepareNestedField: function(name) {
      var nestedField = name

      if (name[name.length - 1] === 's') {
        nestedField = name.substr(0, name.length-1) + "Ids"
      } else {
        nestedField += "Id"
      }

      return nestedField
    },

    processMultiObjects: function(objects, strategy, serializer, root, level, f) {
      var result = [];
      var jsonAdder = function(done) {
        return function(err, json) {
          result.push(json);
          done(err);
        };
      };

      async.forEach(objects, function(object, done) {
        if (serializer) {
          new serializer(object).toJSON(jsonAdder(done), root, level + 1);
        } else {
          new AbstractSerializer(object, strategy).toJSON(jsonAdder(done), root, level + 1);
        }
      }, function(err) {
        f(err, result);
      });
    },

    processMultiObjectsWithRoot: function(field, objects, strategy, serializer, root, level, f) {
      var result = [];
      var jsonAdder = function(done) {
        return function(err, json) {
          result.push(json);
          done(err);
        };
      };

      async.forEach(objects, function(object, done) {
        if (serializer) {
          new serializer(object).toJSON(jsonAdder(done), root, level + 1);
        } else {
          new AbstractSerializer(object, strategy).toJSON(jsonAdder(done), root, level + 1);
        }
      }, function(err) {
        if (typeof root[field] === 'undefined') {
          root[field] = result
        } else {
          root[field] = Object.extend(root[field], result)
        }

        f(err)
      });
    },

    getMaybeObjects: function(field, one, many) {
      this.getField(field, function(err, object) {
        Array.isArray(object) ? many(object) : one(object);
      });
    },

    processNestedStrategy: function(field, f, root, level) {
      var serializer = this;

      serializer.getMaybeObjects(field, function(object) {
        new AbstractSerializer(object, serializer.strategy[field]).toJSON(f, root, level + 1);
      }, function(objects) {
        serializer.processMultiObjects(objects, serializer.strategy[field], null, root, level, f);
      });
    },

    processThroughPoint: function(field, f, root, level) {
      var serializer = this;

      serializer.getMaybeObjects(field, function(object) {
        if (serializer.strategy[field].embed) {
          var object_id = object.id

          f(null, object_id)
        } else {
          new serializer.strategy[field].through(object).toJSON(f);
        }
      }, function(objects) {
        var object_ids = objects.map(function(e) { return e.id })

        if (serializer.strategy[field].embed)
          serializer.processMultiObjectsWithRoot(field, objects, serializer.strategy[field], serializer.strategy[field].through, root, level, function(err) {
            f(err, object_ids)
          })
        else {
          serializer.processMultiObjects(objects, null, serializer.strategy[field].through, root, level, f)
        }
      });
    },

    processNode: function(jsonAdder, root, level) {
      var serializer = this;

      return function(field, done) {
        switch (serializer.decideNode(field)) {

        case serializer.END_POINT:
          serializer.getField(field, jsonAdder(field, done));
          break;

        case serializer.NESTED_STRATEGY:
          serializer.processNestedStrategy(field, jsonAdder(field, done), root, level);
          break;

        case serializer.THROUGH_POINT:
          var node = serializer.embed ? serializer.prepareNestedField(field) : field
          serializer.processThroughPoint(field, jsonAdder(node, done), root, level);
          break;
        }
      };
    },

    toJSON: function(f, root, level) {
      var json = {};
      root = root || {}
      level = level || 0
      var jsonAdder = function(field, done) {
        return function(err, res) {
          json[field] = res;
          done(err);
        };
      };

      async.forEach(this.strategy.select, this.processNode(jsonAdder, root, level + 1) , function(err) {
        if (level === 0)
          json = Object.extend(json, root)

        f(err, json);
      });
    }
  };

  return AbstractSerializer;
};
<|endoftext|>


<commit_before>/**
 * Created by jules on 20/01/17.
 **/

import React, { Component } from 'react';
import { Platform } from 'react-native';
import { Router, Scene } from 'react-native-mobx';
import Login from './login/Login';
import Home from './home/Home'
import Calendar from './calendar/Calendar';
import Activity from './calendar/Activity/Activity';
import AvailableSlots from './calendar/Activity/slots/AvailableSlots';
import News from './news/News';
import Projects from './projects/Projects';
import ProjectDetails from './projects/ProjectDetails';
import Marks from './marks/Marks';
import MarkDetails from './marks/MarkDetails';
import Stats from './stats/Stats';
import Token from './token/Token';
import Ranking from './ranking/Ranking';
import store from '../stores';
import _ from 'lodash';

const getSceneStyle = (/* NavigationSceneRendererProps */ props, computedProps) => {
    const style = {
        flex: 1,
        backgroundColor: '#fff',
        shadowColor: null,
        shadowOffset: null,
        shadowOpacity: null,
        shadowRadius: null,
    };
    if (computedProps.isActive) {
        style.marginTop = computedProps.hideNavBar ? 0 : Platform.OS === 'android' ? 54 : 64;
    }
    return style;
};

const getHeaderStyle = () => {
    return { backgroundColor: '#233445', elevation: 5, borderBottomWidth: 0 }
};

const getTitleStyle = () => {
    return { color: '#FFFFFF', marginTop: -3}
};

const getImageStyle = () => {
    return { width: 20, height: 20, marginRight: 5}
};

/*
* type 'reset' on Login Scene forces all scenes to unmount when logging out.
* This prevents mobx from re-rendering Home scene when logging in again (by changing variable that Home observes)
* even though the scene is not in foreground, and therefore causing the app to crash.
*/

class Main extends Component {
    render() {
        return (
            <Router
                store={store}
                getSceneStyle={getSceneStyle}
                navigationBarStyle={getHeaderStyle()}
                titleStyle={getTitleStyle()}
                backButtonImage={ require(`../assets/left-arr.png`)}
            >

                <Scene key="root">

                    <Scene
                        initial
                        key="login"
                        hideNavBar={true}
                        component={Login}
                        type="reset"
                    />

                    <Scene
                        key="home"
                        component={Home}
                        panHandlers={null}
                        hideBackImage={true}
                        hideNavBar
                        onBack={_.noop}
                        onRight={_.noop}
                        type="reset"
                    />

                    <Scene
                        key="calendar"
                        title="Calendar"
                        hideNavBar={false}
                        component={Calendar}
                        panHandlers={null}
                    />

                    <Scene
                        key="activity"
                        hideNavBar={false}
                        component={Activity}
                    />

                    <Scene
                        key="availableSlots"
                        hideNavBar={false}
                        component={AvailableSlots}
                    />

                    <Scene
                        key="news"
                        title="Notifications"
                        hideNavBar={false}
                        component={News}
                    />

                    <Scene
                        key="projects"
                        title="Projects"
                        hideNavBar={false}
                        component={Projects}
                    />

                    <Scene
                        key="projectDetails"
                        title="projects-details"
                        hideNavBar={false}
                        component={ProjectDetails}
                    />

                    <Scene
                        key="marks"
                        title="Marks"
                        hideNavBar={false}
                        component={Marks}
                    />

                    <Scene
                        key="markDetails"
                        title="marks-details"
                        hideNavBar={false}
                        component={MarkDetails}
                        onRight={() => store.marks.sort()}
                        rightButtonImage={require('../assets/sort.png')}
                        rightButtonIconStyle={getImageStyle()}
                    />

                    <Scene
                        key="ranking"
                        title="Ranking"
                        hideNavBar={false}
                        component={Ranking}
                        onRight={() => store.ranking.computePromotion({ refreshCache: true })}
                        rightButtonImage={require('../assets/reload.png')}
                        rightButtonIconStyle={getImageStyle()}
                    />

                    <Scene
                        key="token"
                        title="Token"
                        hideNavBar={false}
                        component={Token}
                    />

                    <Scene
                        key="stats"
                        title="Statistics"
                        hideNavBar={false}
                        component={Stats}
                    />

                </Scene>
            </Router>
        );
    }
}

export default Main;
<commit_msg>Fix spelling mistake<commit_after>/**
 * Created by jules on 20/01/17.
 **/

import React, { Component } from 'react';
import { Platform } from 'react-native';
import { Router, Scene } from 'react-native-mobx';
import Login from './login/Login';
import Home from './home/Home'
import Calendar from './calendar/Calendar';
import Activity from './calendar/Activity/Activity';
import AvailableSlots from './calendar/Activity/slots/AvailableSlots';
import News from './news/News';
import Projects from './projects/Projects';
import ProjectDetails from './projects/ProjectDetails';
import Marks from './marks/Marks';
import MarkDetails from './marks/MarkDetails';
import Stats from './stats/Stats';
import Token from './token/Token';
import Ranking from './ranking/Ranking';
import store from '../stores';
import _ from 'lodash';

const getSceneStyle = (/* NavigationSceneRendererProps */ props, computedProps) => {
    const style = {
        flex: 1,
        backgroundColor: '#fff',
        shadowColor: null,
        shadowOffset: null,
        shadowOpacity: null,
        shadowRadius: null,
    };
    if (computedProps.isActive) {
        style.marginTop = computedProps.hideNavBar ? 0 : Platform.OS === 'android' ? 54 : 64;
    }
    return style;
};

const getHeaderStyle = () => {
    return { backgroundColor: '#233445', elevation: 5, borderBottomWidth: 0 }
};

const getTitleStyle = () => {
    return { color: '#FFFFFF', marginTop: -3}
};

const getImageStyle = () => {
    return { width: 20, height: 20, marginRight: 5}
};

/*
* type 'reset' on Login Scene forces all scenes to unmount when logging out.
* This prevents mobx from re-rendering Home scene when logging in again (by changing variable that Home observes)
* even though the scene is not in foreground, and therefore causing the app to crash.
*/

class Main extends Component {
    render() {
        return (
            <Router
                store={store}
                getSceneStyle={getSceneStyle}
                navigationBarStyle={getHeaderStyle()}
                titleStyle={getTitleStyle()}
                backButtonImage={ require(`../assets/left-arr.png`)}
            >

                <Scene key="root">

                    <Scene
                        initial
                        key="login"
                        hideNavBar={true}
                        component={Login}
                        type="reset"
                    />

                    <Scene
                        key="home"
                        component={Home}
                        panHandlers={null}
                        hideBackImage={true}
                        hideNavBar
                        onBack={_.noop}
                        onRight={_.noop}
                        type="reset"
                    />

                    <Scene
                        key="calendar"
                        title="Calendar"
                        hideNavBar={false}
                        component={Calendar}
                        panHandlers={null}
                    />

                    <Scene
                        key="activity"
                        hideNavBar={false}
                        component={Activity}
                    />

                    <Scene
                        key="availableSlots"
                        hideNavBar={false}
                        component={AvailableSlots}
                    />

                    <Scene
                        key="news"
                        title="Notifications"
                        hideNavBar={false}
                        component={News}
                    />

                    <Scene
                        key="projects"
                        title="Projects"
                        hideNavBar={false}
                        component={Projects}
                    />

                    <Scene
                        key="projectDetails"
                        title="projects-details"
                        hideNavBar={false}
                        component={ProjectDetails}
                    />

                    <Scene
                        key="marks"
                        title="Marks"
                        hideNavBar={false}
                        component={Marks}
                    />

                    <Scene
                        key="markDetails"
                        title="marks-details"
                        hideNavBar={false}
                        component={MarkDetails}
                        onRight={() => store.marks.sort()}
                        rightButtonImage={require('../assets/sort.png')}
                        rightButtonIconStyle={getImageStyle()}
                    />

                    <Scene
                        key="ranking"
                        title="Ranking"
                        hideNavBar={false}
                        component={Ranking}
                        onRight={() => store.ranking.computePromotion({ refreshCache: true })}
                        rightButtonImage={require('../assets/reload.png')}
                        rightButtonIconStyle={getImageStyle()}
                    />

                    <Scene
                        key="token"
                        title="Tokens"
                        hideNavBar={false}
                        component={Token}
                    />

                    <Scene
                        key="stats"
                        title="Statistics"
                        hideNavBar={false}
                        component={Stats}
                    />

                </Scene>
            </Router>
        );
    }
}

export default Main;
<|endoftext|>