<commit_before>BEST.component('famous:components', {
    events: {
        handlers: {
            'align': function($align, $payload) {
                $align.set($payload[0], $payload[1], $payload[2]);
            },
            'align-x': function($align, $payload) {
                $align.setX($payload);
            },
            'align-y': function($align, $payload) {
                $align.setY($payload);
            },
            'align-z': function($align, $payload) {
                $align.setZ($payload);
            },
            'camera': function($camera, $payload) {
                $camera.set($payload[0], $payload[1]);
            },
            'mount-point': function($mountPoint, $payload) {
                $mountPoint.set($payload[0], $payload[1], $payload[2]);
            },
            'mount-point-x': function($mountPoint, $payload) {
                $mountPoint.setX($payload);
            },
            'mount-point-y': function($mountPoint, $payload) {
                $mountPoint.setY($payload);
            },
            'mount-point-z': function($mountPoint, $payload) {
                $mountPoint.setZ($payload);
            },
            'opacity': function($opacity, $payload) {
                $opacity.set($payload);
            },
            'origin': function($origin, $payload) {
                $origin.set($payload[0], $payload[1], $payload[2]);
            },
            'origin-x': function($origin, $payload) {
                $origin.setX($payload);
            },
            'origin-y': function($origin, $payload) {
                $origin.setY($payload);
            },
            'origin-z': function($origin, $payload) {
                $origin.setZ($payload);
            },
            'position': function($position, $payload) {
                $position.set($payload[0], $payload[1], $payload[2]);
            },
            'position-x': function($position, $payload) {
                $position.setX($payload);
            },
            'position-y': function($position, $payload) {
                $position.setY($payload);
            },
            'position-z': function($position, $payload) {
                $position.setZ($payload);
            },
            'rotation': function($rotation, $payload) {
                $rotation.set($payload[0], $payload[1], $payload[2]);
            },
            'rotation-x': function($rotation, $payload) {
                $rotation.setX($payload);
            },
            'rotation-y': function($rotation, $payload) {
                $rotation.setY($payload);
            },
            'rotation-z': function($rotation, $payload) {
                $rotation.setZ($payload);
            },
            'scale': function($scale, $payload) {
                $scale.set($payload[0], $payload[1], $payload[2]);
            },
            'scale-x': function($scale, $payload) {
                $scale.setX($payload);
            },
            'scale-y': function($scale, $payload) {
                $scale.setY($payload);
            },
            'scale-z': function($scale, $payload) {
                $scale.setZ($payload);
            },
            'size-absolute': function($size, $payload) {
                $size.setAbsolute($payload[0], $payload[1], $payload[2]);
            },
            'size-proportional': function($size, $payload) {
                $size.setProportional($payload[0], $payload[1], $payload[2]);
            },
            'size-differential': function($size, $payload) {
                $size.setDifferential($payload[0], $payload[1], $payload[2]);
            }
        }
    }
});
<commit_msg>Add guard for 3rd array value in components<commit_after>BEST.component('famous:components', {
    events: {
        handlers: {
            'align': function($align, $payload) {
                $align.set($payload[0], $payload[1], $payload[2] || 0);
            },
            'align-x': function($align, $payload) {
                $align.setX($payload);
            },
            'align-y': function($align, $payload) {
                $align.setY($payload);
            },
            'align-z': function($align, $payload) {
                $align.setZ($payload);
            },
            'camera': function($camera, $payload) {
                $camera.set($payload[0], $payload[1]);
            },
            'mount-point': function($mountPoint, $payload) {
                $mountPoint.set($payload[0], $payload[1], $payload[2] || 0);
            },
            'mount-point-x': function($mountPoint, $payload) {
                $mountPoint.setX($payload);
            },
            'mount-point-y': function($mountPoint, $payload) {
                $mountPoint.setY($payload);
            },
            'mount-point-z': function($mountPoint, $payload) {
                $mountPoint.setZ($payload);
            },
            'opacity': function($opacity, $payload) {
                console.log('set opacity to ', $payload);
                $opacity.set($payload);
                console.log('opacity is ', $opacity.get());
            },
            'origin': function($origin, $payload) {
                $origin.set($payload[0], $payload[1], $payload[2] || 0);
            },
            'origin-x': function($origin, $payload) {
                $origin.setX($payload);
            },
            'origin-y': function($origin, $payload) {
                $origin.setY($payload);
            },
            'origin-z': function($origin, $payload) {
                $origin.setZ($payload);
            },
            'position': function($position, $payload) {
                $position.set($payload[0], $payload[1], $payload[2] || 0);
            },
            'position-x': function($position, $payload) {
                $position.setX($payload);
            },
            'position-y': function($position, $payload) {
                $position.setY($payload);
            },
            'position-z': function($position, $payload) {
                $position.setZ($payload);
            },
            'rotation': function($rotation, $payload) {
                $rotation.set($payload[0], $payload[1], $payload[2] || 0);
            },
            'rotation-x': function($rotation, $payload) {
                $rotation.setX($payload);
            },
            'rotation-y': function($rotation, $payload) {
                $rotation.setY($payload);
            },
            'rotation-z': function($rotation, $payload) {
                $rotation.setZ($payload);
            },
            'scale': function($scale, $payload) {
                $scale.set($payload[0], $payload[1], $payload[2] || 1);
            },
            'scale-x': function($scale, $payload) {
                $scale.setX($payload);
            },
            'scale-y': function($scale, $payload) {
                $scale.setY($payload);
            },
            'scale-z': function($scale, $payload) {
                $scale.setZ($payload);
            },
            'size-absolute': function($size, $payload) {
                $size.setAbsolute($payload[0], $payload[1], $payload[2]);
            },
            'size-proportional': function($size, $payload) {
                $size.setProportional($payload[0], $payload[1], $payload[2]);
            },
            'size-differential': function($size, $payload) {
                $size.setDifferential($payload[0], $payload[1], $payload[2]);
            }
        }
    }
});
<|endoftext|>


<commit_before>/*!
 * Start Bootstrap - Grayscale Bootstrap Theme (http://startbootstrap.com)
 * Code licensed under the Apache License v2.0.
 * For details, see http://www.apache.org/licenses/LICENSE-2.0.
 */

// jQuery to collapse the navbar on scroll
$(window).scroll(function() {
    if ($(".navbar").offset().top > 50) {
        $(".navbar-fixed-top").addClass("top-nav-collapse");
    } else {
        $(".navbar-fixed-top").removeClass("top-nav-collapse");
    }
});

// jQuery for page scrolling feature - requires jQuery Easing plugin
$(function() {
    $('a.page-scroll').bind('click', function(event) {
        var $anchor = $(this);
        $('html, body').stop().animate({
            scrollTop: $($anchor.attr('href')).offset().top
        }, 1500, 'easeInOutExpo');
        event.preventDefault();
    });
});

// Closes the Responsive Menu on Menu Item Click
$('.navbar-collapse ul li a').click(function() {
    $('.navbar-toggle:visible').click();
});

// Google Maps Scripts
// When the window has finished loading create our google map below
google.maps.event.addDomListener(window, 'load', init);

function init() {
    // Basic options for a simple Google Map
    // For more options see: https://developers.google.com/maps/documentation/javascript/reference#MapOptions
    var mapOptions = {
        // How zoomed in you want the map to start at (always required)
        zoom: 15,

        // The latitude and longitude to center the map (always required)
        center: new google.maps.LatLng(48.5185584,-122.6122217), // Majestic inn and spa anacortes

        // Disables the default Google Maps UI components
       // disableDefaultUI: true,
        scrollwheel: false,
        //draggable: false,

        // How you would like to style the map.
        // This is where you would paste any style found on Snazzy Maps.
        styles: [
          {"featureType":"all",
          "elementType":"geometry",
          "stylers":[
            {"color":"#ffffff"}
          ]},
          {"featureType":"all",
          "elementType":"labels.text.fill",
          "stylers":[
            {"gamma":0.01},
            {"lightness":20}
          ]},
          {"featureType":"all",
          "elementType":"labels.text.stroke",
          "stylers":[
            {"saturation":-31},
            {"lightness":-33},
            {"weight":2},
            {"gamma":0.8}
          ]},
          {"featureType":"all",
          "elementType":"labels.icon",
          "stylers":[{"visibility":"off"}
        ]},
        {"featureType":"administrative.locality",
        "elementType":"labels.text.fill",
        "stylers":[
          {"color":"#050505"}
        ]},
        {"featureType":"administrative.locality",
        "elementType":"labels.text.stroke",
        "stylers":[
          {"color":"#fef3f3"},
          {"weight":"3.01"}
        ]},
        {"featureType":"administrative.neighborhood",
        "elementType":"labels.text.fill",
        "stylers":[
          {"color":"#0a0a0a"},
          {"visibility":"off"}
        ]},
        {"featureType":"administrative.neighborhood",
        "elementType":"labels.text.stroke",
        "stylers":[
          {"color":"#fffbfb"},
          {"weight":"3.01"},
          {"visibility":"off"}
        ]},
        {"featureType":"landscape",
        "elementType":"geometry",
        "stylers":[
          {"color": "#D6EBFA"}
        ]},
        {"featureType":"road",
        "elementType":"geometry",
        "stylers":[
          {"lightness":10},
          {"saturation":-30}
        ]},
        {"featureType":"road",
        "elementType":"geometry.stroke",
        "stylers":[
          {"saturation":25},
          {"lightness":25}
        ]},
        {"featureType":"road.highway",
        "elementType":"geometry.fill",
        "stylers":[
          {"visibility":"on"},
          {"color":"#a1a1a1"}
        ]},
        {"featureType":"road.highway",
        "elementType":"geometry.stroke",
        "stylers":[{"color":"#292929"}
      ]},
      {"featureType":"road.highway",
      "elementType":"labels.text.fill",
      "stylers":[
        {"visibility":"on"},
        {"color":"#202020"}
      ]},
      {"featureType":"road.highway",
      "elementType":"labels.text.stroke",
      "stylers":[
        {"visibility":"on"},
        {"color":"#ffffff"}
      ]},
      {"featureType":"road.highway",
      "elementType":"labels.icon",
      "stylers":[
        {"visibility":"simplified"},
        {"hue":"#0006ff"},
        {"saturation":"-100"},
        {"lightness":"13"},
        {"gamma":"0.00"}
      ]},
      {"featureType":"road.arterial",
      "elementType":"geometry.fill",
      "stylers":[
        {"visibility":"on"},
        {"color":"#686868"}
      ]},
      {"featureType":"road.arterial",
      "elementType":"geometry.stroke",
      "stylers":[
        {"visibility":"off"},
        {"color":"#8d8d8d"}
      ]},
      {"featureType":"road.arterial",
      "elementType":"labels.text.fill",
      "stylers":[
        {"visibility":"on"},
        {"color":"#353535"},
        {"lightness":"6"}
      ]},
      {"featureType":"road.arterial",
      "elementType":"labels.text.stroke",
      "stylers":[
        {"visibility":"on"},
        {"color":"#ffffff"},
        {"weight":"3.45"}
      ]},
      {"featureType":"road.local",
      "elementType":"geometry.fill",
      "stylers":[
        {"color":"#d0d0d0"}
      ]},
      {"featureType":"road.local",
      "elementType":"geometry.stroke",
      "stylers":[
        {"lightness":"2"},
        {"visibility":"on"},
        {"color":"#999898"}
      ]},
      {"featureType":"road.local",
      "elementType":"labels.text.fill",
      "stylers":[
        {"color":"#383838"}
      ]},
      {"featureType":"road.local",
      "elementType":"labels.text.stroke",
      "stylers":[
        {"color":"#faf8f8"}
      ]},
      {"featureType":"water",
      "elementType":"all",
      "stylers":[
        {"color": "#FFFFFF"}
      ]}]
    };

    // Get the HTML DOM element that will contain your map
    // We are using a div with id="map" seen below in the
    var mapElement = document.getElementById('map');

    // Create the Google Map using out element and options defined above
    var map = new google.maps.Map(mapElement, mapOptions);

    // Custom Map Marker Icon - Customize the map-marker.png file to customize your icon
    var image = 'img/map-marker.png';
    var myLatLng = new google.maps.LatLng(48.518465, -122.612075);
    var marker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        icon: image
    });

    marker.addListener('click', function() {
        location.href = "https://www.google.com/maps/dir//Majestic+Inn+%26+Spa,+419+Commercial+Ave,+Anacortes,+WA+98221,+United+States/@48.288843,-122.6663516,10z/data=!4m9!4m8!1m0!1m5!1m1!1s0x548579e12705e52f:0x9d5de961b6790b52!2m2!1d-122.6122217!2d48.5185584!3e0";
    });

    map.addListener('center_changed', function() {
        // after 6 seconds return to the marker
        window.setTimeout(function() {
            map.panTo(marker.getPosition());
            map.setZoom(15);
        }, 20000);
    });
}

/*
 *  Countdown
 */
// set the date we are counting down to
var target_date = new Date('Mar, 4, 2017').getTime();

// variables for time units
var days, hours, minutes, seconds;

// get tag elements
var countdown = document.getElementById('countdown');
var day = document.getElementById('day');
var hour = document.getElementById('hour');
var min = document.getElementById('min');
var sec = document.getElementById('sec');

// update the tag with id "countdown" every 1 second
setInterval(function () {

    // find the amount of "seconds" between now and target
    var current_date = new Date().getTime();
    var seconds_left = (target_date - current_date) / 1000;

    // do some time calculations
    days = parseInt(seconds_left / 86400);
    seconds_left = seconds_left % 86400;

    hours = parseInt(seconds_left / 3600);
    seconds_left = seconds_left % 3600;

    minutes = parseInt(seconds_left / 60);
    seconds = parseInt(seconds_left % 60);

    day.innerHTML = '' + days +  ' Days';
    hour.innerHTML = '' + hours + ' Hours';
    min.innerHTML = '' + minutes + ' Minutes';
    sec.innerHTML = '' + seconds + ' Seconds';
}, 1000);
<commit_msg>commented out old map js<commit_after>/*!
 * Start Bootstrap - Grayscale Bootstrap Theme (http://startbootstrap.com)
 * Code licensed under the Apache License v2.0.
 * For details, see http://www.apache.org/licenses/LICENSE-2.0.
 */

// jQuery to collapse the navbar on scroll
$(window).scroll(function() {
    if ($(".navbar").offset().top > 50) {
        $(".navbar-fixed-top").addClass("top-nav-collapse");
    } else {
        $(".navbar-fixed-top").removeClass("top-nav-collapse");
    }
});

// jQuery for page scrolling feature - requires jQuery Easing plugin
$(function() {
    $('a.page-scroll').bind('click', function(event) {
        var $anchor = $(this);
        $('html, body').stop().animate({
            scrollTop: $($anchor.attr('href')).offset().top
        }, 1500, 'easeInOutExpo');
        event.preventDefault();
    });
});

// Closes the Responsive Menu on Menu Item Click
$('.navbar-collapse ul li a').click(function() {
    $('.navbar-toggle:visible').click();
});
/*
// Google Maps Scripts
// When the window has finished loading create our google map below
google.maps.event.addDomListener(window, 'load', init);

function init() {
    // Basic options for a simple Google Map
    // For more options see: https://developers.google.com/maps/documentation/javascript/reference#MapOptions
    var mapOptions = {
        // How zoomed in you want the map to start at (always required)
        zoom: 15,

        // The latitude and longitude to center the map (always required)
        center: new google.maps.LatLng(48.5185584,-122.6122217), // Majestic inn and spa anacortes

        // Disables the default Google Maps UI components
       // disableDefaultUI: true,
        scrollwheel: false,
        //draggable: false,

        // How you would like to style the map.
        // This is where you would paste any style found on Snazzy Maps.
        styles: [
          {"featureType":"all",
          "elementType":"geometry",
          "stylers":[
            {"color":"#ffffff"}
          ]},
          {"featureType":"all",
          "elementType":"labels.text.fill",
          "stylers":[
            {"gamma":0.01},
            {"lightness":20}
          ]},
          {"featureType":"all",
          "elementType":"labels.text.stroke",
          "stylers":[
            {"saturation":-31},
            {"lightness":-33},
            {"weight":2},
            {"gamma":0.8}
          ]},
          {"featureType":"all",
          "elementType":"labels.icon",
          "stylers":[{"visibility":"off"}
        ]},
        {"featureType":"administrative.locality",
        "elementType":"labels.text.fill",
        "stylers":[
          {"color":"#050505"}
        ]},
        {"featureType":"administrative.locality",
        "elementType":"labels.text.stroke",
        "stylers":[
          {"color":"#fef3f3"},
          {"weight":"3.01"}
        ]},
        {"featureType":"administrative.neighborhood",
        "elementType":"labels.text.fill",
        "stylers":[
          {"color":"#0a0a0a"},
          {"visibility":"off"}
        ]},
        {"featureType":"administrative.neighborhood",
        "elementType":"labels.text.stroke",
        "stylers":[
          {"color":"#fffbfb"},
          {"weight":"3.01"},
          {"visibility":"off"}
        ]},
        {"featureType":"landscape",
        "elementType":"geometry",
        "stylers":[
          {"color": "#D6EBFA"}
        ]},
        {"featureType":"road",
        "elementType":"geometry",
        "stylers":[
          {"lightness":10},
          {"saturation":-30}
        ]},
        {"featureType":"road",
        "elementType":"geometry.stroke",
        "stylers":[
          {"saturation":25},
          {"lightness":25}
        ]},
        {"featureType":"road.highway",
        "elementType":"geometry.fill",
        "stylers":[
          {"visibility":"on"},
          {"color":"#a1a1a1"}
        ]},
        {"featureType":"road.highway",
        "elementType":"geometry.stroke",
        "stylers":[{"color":"#292929"}
      ]},
      {"featureType":"road.highway",
      "elementType":"labels.text.fill",
      "stylers":[
        {"visibility":"on"},
        {"color":"#202020"}
      ]},
      {"featureType":"road.highway",
      "elementType":"labels.text.stroke",
      "stylers":[
        {"visibility":"on"},
        {"color":"#ffffff"}
      ]},
      {"featureType":"road.highway",
      "elementType":"labels.icon",
      "stylers":[
        {"visibility":"simplified"},
        {"hue":"#0006ff"},
        {"saturation":"-100"},
        {"lightness":"13"},
        {"gamma":"0.00"}
      ]},
      {"featureType":"road.arterial",
      "elementType":"geometry.fill",
      "stylers":[
        {"visibility":"on"},
        {"color":"#686868"}
      ]},
      {"featureType":"road.arterial",
      "elementType":"geometry.stroke",
      "stylers":[
        {"visibility":"off"},
        {"color":"#8d8d8d"}
      ]},
      {"featureType":"road.arterial",
      "elementType":"labels.text.fill",
      "stylers":[
        {"visibility":"on"},
        {"color":"#353535"},
        {"lightness":"6"}
      ]},
      {"featureType":"road.arterial",
      "elementType":"labels.text.stroke",
      "stylers":[
        {"visibility":"on"},
        {"color":"#ffffff"},
        {"weight":"3.45"}
      ]},
      {"featureType":"road.local",
      "elementType":"geometry.fill",
      "stylers":[
        {"color":"#d0d0d0"}
      ]},
      {"featureType":"road.local",
      "elementType":"geometry.stroke",
      "stylers":[
        {"lightness":"2"},
        {"visibility":"on"},
        {"color":"#999898"}
      ]},
      {"featureType":"road.local",
      "elementType":"labels.text.fill",
      "stylers":[
        {"color":"#383838"}
      ]},
      {"featureType":"road.local",
      "elementType":"labels.text.stroke",
      "stylers":[
        {"color":"#faf8f8"}
      ]},
      {"featureType":"water",
      "elementType":"all",
      "stylers":[
        {"color": "#FFFFFF"}
      ]}]
    };

    // Get the HTML DOM element that will contain your map
    // We are using a div with id="map" seen below in the
    var mapElement = document.getElementById('map');

    // Create the Google Map using out element and options defined above
    var map = new google.maps.Map(mapElement, mapOptions);

    // Custom Map Marker Icon - Customize the map-marker.png file to customize your icon
    var image = 'img/map-marker.png';
    var myLatLng = new google.maps.LatLng(48.518465, -122.612075);
    var marker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        icon: image
    });

    marker.addListener('click', function() {
        location.href = "https://www.google.com/maps/dir//Majestic+Inn+%26+Spa,+419+Commercial+Ave,+Anacortes,+WA+98221,+United+States/@48.288843,-122.6663516,10z/data=!4m9!4m8!1m0!1m5!1m1!1s0x548579e12705e52f:0x9d5de961b6790b52!2m2!1d-122.6122217!2d48.5185584!3e0";
    });

    map.addListener('center_changed', function() {
        // after 6 seconds return to the marker
        window.setTimeout(function() {
            map.panTo(marker.getPosition());
            map.setZoom(15);
        }, 20000);
    });
}

*/

/*
 *  Countdown
 */
// set the date we are counting down to
var target_date = new Date('Mar, 4, 2017').getTime();

// variables for time units
var days, hours, minutes, seconds;

// get tag elements
var countdown = document.getElementById('countdown');
var day = document.getElementById('day');
var hour = document.getElementById('hour');
var min = document.getElementById('min');
var sec = document.getElementById('sec');

// update the tag with id "countdown" every 1 second
setInterval(function () {

    // find the amount of "seconds" between now and target
    var current_date = new Date().getTime();
    var seconds_left = (target_date - current_date) / 1000;

    // do some time calculations
    days = parseInt(seconds_left / 86400);
    seconds_left = seconds_left % 86400;

    hours = parseInt(seconds_left / 3600);
    seconds_left = seconds_left % 3600;

    minutes = parseInt(seconds_left / 60);
    seconds = parseInt(seconds_left % 60);

    day.innerHTML = '' + days +  ' Days';
    hour.innerHTML = '' + hours + ' Hours';
    min.innerHTML = '' + minutes + ' Minutes';
    sec.innerHTML = '' + seconds + ' Seconds';
}, 1000);
<|endoftext|>


<commit_before>/**
* @jsx React.DOM
*/

/*jslint node: true*/
'use strict';
var React         = require('react');
var AutoCompleteEditor  = require('./AutoCompleteEditor');

var AutoCompleteAsyncEditor =  React.createClass({

  propTypes : {
	cacheResults: React.PropTypes.bool,
  	column: React.PropTypes.object,
  	editorRowMetaData: React.PropTypes.object,
	height: React.PropTypes.number,
	label: React.PropTypes.string,
	onCommit: React.PropTypes.func,
	onKeyDown: React.PropTypes.func,
	resultIdentifier: React.PropTypes.string,
	searchSourceArgs: React.PropTypes.array,
	searchSourceUrl: React.PropTypes.func,
	value: React.PropTypes.string,
	valueParams: React.PropTypes.arrayOf(React.PropTypes.string)
  },

  getSearchParams() {
    var editorRowMetaData = this.props.editorRowMetaData;
    var searchParams =  this.props.searchSourceArgs.map(arg => {
      if(!editorRowMetaData[arg]){
        throw ("Cannot find Search Source Paramater " + arg + " in editorRowMetaData. You must add an entry for this in models/GridColumn.js")
      }
      return editorRowMetaData[arg]
    });
    return searchParams;
  },

  getInputNode(): HTMLInputElement{
    return this.getDOMNode().getElementsByTagName("input")[0];
  },

  getValue(){
    return this.refs.autocomplete.getValue();
  },

  hasResults(){
    return this.refs.autocomplete.hasResults();
  },

  _searchRemote(options, searchTerm, cb) {
    var searchParams = this.getSearchParams();
    //add onSuccessCallback at end of search params array
    searchParams.push(this._onXHRSuccess.bind(null, cb, searchTerm));
    this.props.searchUrl.apply(this, searchParams);
  },

  _onXHRSuccess(cb, searchTerm, data, status, xhr) {
    cb(null, this._filterData(data, searchTerm))
  },

  _onXHRError(cb, xhr, status, err) {
    cb(err)
  },

  _filterData(data, searchTerm) {
    var regexp = new RegExp(searchTerm, 'i')
    var results = []
    var label = this.props.label ? this.props.label : 'title';
	for (var i = 0, len = data.length; i < len; i++) {
      if (regexp.exec(data[i][label])) {
        results.push(data[i])
      }
    }
    return results.slice(0, 100)
  },

  render() {
    var value = typeof this.props.column.formatter === 'function' ? this.props.column.formatter(this.props) : this.props.value;
    return (
      <AutoCompleteEditor
		ref="autocomplete" {...this.props}
		options={[]}
		search={this._searchRemote}
		value={value}
		label={this.props.label}
		resultIdentifier={this.props.resultIdentifier}
	  />
    )
  }
});

module.exports = AutoCompleteAsyncEditor;
<commit_msg>Correctly named function<commit_after>/**
* @jsx React.DOM
*/

/*jslint node: true*/
'use strict';
var React         = require('react');
var AutoCompleteEditor  = require('./AutoCompleteEditor');

var AutoCompleteAsyncEditor =  React.createClass({

  propTypes : {
	cacheResults: React.PropTypes.bool,
  	column: React.PropTypes.object,
  	editorRowMetaData: React.PropTypes.object,
	height: React.PropTypes.number,
	label: React.PropTypes.string,
	onCommit: React.PropTypes.func,
	onKeyDown: React.PropTypes.func,
	resultIdentifier: React.PropTypes.string,
	searchSourceArgs: React.PropTypes.array,
	searchUrl: React.PropTypes.func,
	value: React.PropTypes.string,
	valueParams: React.PropTypes.arrayOf(React.PropTypes.string)
  },

  getSearchParams() {
    var editorRowMetaData = this.props.editorRowMetaData;
    var searchParams =  this.props.searchSourceArgs.map(arg => {
      if(!editorRowMetaData[arg]){
        throw ("Cannot find Search Source Paramater " + arg + " in editorRowMetaData. You must add an entry for this in models/GridColumn.js")
      }
      return editorRowMetaData[arg]
    });
    return searchParams;
  },

  getInputNode(): HTMLInputElement{
    return this.getDOMNode().getElementsByTagName("input")[0];
  },

  getValue(){
    return this.refs.autocomplete.getValue();
  },

  hasResults(){
    return this.refs.autocomplete.hasResults();
  },

  _searchRemote(options, searchTerm, cb) {
    var searchParams = this.getSearchParams();
    //add onSuccessCallback at end of search params array
    searchParams.push(this._onXHRSuccess.bind(null, cb, searchTerm));
    this.props.searchUrl.apply(this, searchParams);
  },

  _onXHRSuccess(cb, searchTerm, data, status, xhr) {
    cb(null, this._filterData(data, searchTerm))
  },

  _onXHRError(cb, xhr, status, err) {
    cb(err)
  },

  _filterData(data, searchTerm) {
    var regexp = new RegExp(searchTerm, 'i')
    var results = []
    var label = this.props.label ? this.props.label : 'title';
	for (var i = 0, len = data.length; i < len; i++) {
      if (regexp.exec(data[i][label])) {
        results.push(data[i])
      }
    }
    return results.slice(0, 100)
  },

  render() {
    var value = typeof this.props.column.formatter === 'function' ? this.props.column.formatter(this.props) : this.props.value;
    return (
      <AutoCompleteEditor
		ref="autocomplete" {...this.props}
		options={[]}
		search={this._searchRemote}
		value={value}
		label={this.props.label}
		resultIdentifier={this.props.resultIdentifier}
	  />
    )
  }
});

module.exports = AutoCompleteAsyncEditor;
<|endoftext|>


<commit_before>var defaults = {
	secret: 'changeThisFool',
	resave: true,
	saveUninitialized: true
};

module.exports = _.merge(defaults, {
	production: {
		redis: {
			port: 6379,
			host: 'localhost'
		}
	}
}[ENV]);

<commit_msg>Fixed redis (session) config.<commit_after>var redisStore;

var config = {
	secret: 'change-this-fool',
	resave: true,
	saveUninitialized: true
};

var redisConfig = {
	host: 'localhost',
	port: 6379
};

if(ENV === 'production') {
	var RedisStore = require('connect-redis')(require('express-session'));

	redisStore = new RedisStore(this.redis);

	redisStore.on('connect', function(){
		console.info("Redis connected succcessfully");
	});

	redisStore.on('disconnect', function(){
		console.error("[" + chalk.red('ERROR') + "]  Unable to connect to redis. Has it been started?");
		process.exit(2);
	});

	config.store = redisStore;
}

module.exports = config;
<|endoftext|>


<commit_before>(function() {
    'use strict';
    angular.module('theHiveControllers')
        .controller('SearchCtrl', function($scope, $stateParams, $uibModal, PSearchSrv, CaseTemplateSrv, CaseTaskSrv, NotificationSrv, EntitySrv, UserInfoSrv) {
            $scope.filter = {
                type: {
                    values: [
                        {
                            id: 'case',
                            label: 'Case'
                        },
                        {
                            id: 'case_task',
                            label: 'Task'
                        },
                        {
                            id: 'case_task_log',
                            label: 'Task log'
                        },
                        {
                            id: 'case_artifact',
                            label: 'Observable'
                        },
                        {
                            id: 'case_artifact_job',
                            label: 'Analyzer Job'
                        },
                        {
                            id: 'analyzer',
                            label: 'Analyzer'
                        }
                    ],
                    selection: [],
                    config: {
                        smartButtonMaxItems: 10,
                        smartButtonTextConverter: function(itemText) {
                            return itemText;
                        }
                    }
                }
            };

            $scope.getUserInfo = UserInfoSrv;
            $scope.searchResults = PSearchSrv(undefined, 'any', {
                'filter': angular.fromJson(Base64.decode($stateParams.q)),
                'baseFilter': {_string: '!_type:audit AND !_type:data AND !_type:user AND !_type:analyzer AND !_type:case_artifact_job_log AND !status:Deleted'},
                'nparent': 10,
                skipStream: true
            });

            $scope.openEntity = EntitySrv.open;
            $scope.isImage = function(contentType) {
                return angular.isString(contentType) && contentType.indexOf('image') === 0;
            };

            $scope.importAlert = function(event) {
                $uibModal.open({
                    templateUrl: 'views/partials/alert/event.dialog.html',
                    controller: 'AlertEventCtrl',
                    controllerAs: 'dialog',
                    size: 'max',
                    resolve: {
                        event: event,
                        templates: function() {
                            return CaseTemplateSrv.list();
                        }
                    }
                }).result.then(function(response) {
                  $scope.searchResults.update();
                });
            };
        });
})();
<commit_msg>#555 Remove dashboards from search results<commit_after>(function() {
    'use strict';
    angular.module('theHiveControllers')
        .controller('SearchCtrl', function($scope, $stateParams, $uibModal, PSearchSrv, CaseTemplateSrv, CaseTaskSrv, NotificationSrv, EntitySrv, UserInfoSrv) {
            $scope.filter = {
                type: {
                    values: [
                        {
                            id: 'case',
                            label: 'Case'
                        },
                        {
                            id: 'case_task',
                            label: 'Task'
                        },
                        {
                            id: 'case_task_log',
                            label: 'Task log'
                        },
                        {
                            id: 'case_artifact',
                            label: 'Observable'
                        },
                        {
                            id: 'case_artifact_job',
                            label: 'Analyzer Job'
                        },
                        {
                            id: 'analyzer',
                            label: 'Analyzer'
                        }
                    ],
                    selection: [],
                    config: {
                        smartButtonMaxItems: 10,
                        smartButtonTextConverter: function(itemText) {
                            return itemText;
                        }
                    }
                }
            };

            $scope.getUserInfo = UserInfoSrv;
            $scope.searchResults = PSearchSrv(undefined, 'any', {
                'filter': angular.fromJson(Base64.decode($stateParams.q)),
                'baseFilter': {_string: '!_type:dashboard AND !_type:audit AND !_type:data AND !_type:user AND !_type:analyzer AND !_type:case_artifact_job_log AND !status:Deleted'},
                'nparent': 10,
                skipStream: true
            });

            $scope.openEntity = EntitySrv.open;
            $scope.isImage = function(contentType) {
                return angular.isString(contentType) && contentType.indexOf('image') === 0;
            };

            $scope.importAlert = function(event) {
                $uibModal.open({
                    templateUrl: 'views/partials/alert/event.dialog.html',
                    controller: 'AlertEventCtrl',
                    controllerAs: 'dialog',
                    size: 'max',
                    resolve: {
                        event: event,
                        templates: function() {
                            return CaseTemplateSrv.list();
                        }
                    }
                }).result.then(function(response) {
                  $scope.searchResults.update();
                });
            };
        });
})();
<|endoftext|>


<commit_before>import PropTypes from 'prop-types';
import React from 'react';
import { baseFonts } from '@storybook/components';

const wrapperStyle = {
  marginTop: 20,
};

const headingStyle = {
  ...baseFonts,
  textTransform: 'uppercase',
  // letterSpacing: '1.5px',
  fontSize: '12px',
  fontWeight: 'normal',
  color: '#828282',
  textAlign: 'left',
  padding: '5px 13px',
  margin: 0,
  overflow: 'hidden',
};

const SubHeader = ({ name }) => (

{name}

);

SubHeader.defaultProps = {
  name: '',
};

SubHeader.propTypes = {
  name: PropTypes.string,
};

export default SubHeader;
<commit_msg>restored letterspacing sub header<commit_after>import PropTypes from 'prop-types';
import React from 'react';
import { baseFonts } from '@storybook/components';

const wrapperStyle = {
  marginTop: 20,
};

const headingStyle = {
  ...baseFonts,
  textTransform: 'uppercase',
  letterSpacing: '1.2px',
  fontSize: '12px',
  fontWeight: 'normal',
  color: '#828282',
  textAlign: 'left',
  padding: '5px 13px',
  margin: 0,
  overflow: 'hidden',
};

const SubHeader = ({ name }) => (

{name}

);

SubHeader.defaultProps = {
  name: '',
};

SubHeader.propTypes = {
  name: PropTypes.string,
};

export default SubHeader;
<|endoftext|>


<commit_before>import animationTest from './test/animations.js';

export const hasPromise = typeof window.Promise !== 'undefined';
export const hasFetch = typeof window.fetch !== 'undefined';
export const hasClassList = 'classList' in document.createElement('div');
export const hasAnimations = animationTest;

export default {
	Promise: hasPromise,
	fetch: hasFetch,
	classList: hasClassList,
	animations: hasAnimations
};
<commit_msg>Fix animation detection test import path<commit_after>import animationTest from './tests/animations.js';

export const hasPromise = typeof window.Promise !== 'undefined';
export const hasFetch = typeof window.fetch !== 'undefined';
export const hasClassList = 'classList' in document.createElement('div');
export const hasAnimations = animationTest;

export default {
	Promise: hasPromise,
	fetch: hasFetch,
	classList: hasClassList,
	animations: hasAnimations
};
<|endoftext|>


<commit_before>// @flow
import React from 'react'
import {
  Alert,
  Keyboard,
  StyleSheet,
  Text,
  TextInput,
  TouchableOpacity,
  ScrollView,
  View
} from 'react-native'
import SegmentedControlTab from 'react-native-segmented-control-tab'
import expect, { createSpy, spyOn, isSpy } from 'expect'
import moment from 'moment'
import { actionCreators, SRStudyTask, SRStudyTaskIntensity } from './dataModel/SRSimpleDataModel'
import { SRSpacedRepetition } from './SRSpacedRepetition'
import { uuid } from './utilities/UUID'
import { capitalizeFirstLetter } from './utilities/String+Capitalize'
import {SRDarkColor, SRYellowColor, SRBrightColor, SRRedColor} from './utilities/SRColors'

const studyTaskString = 'Study Task'
const notesString = 'Notes'

const inactiveColor = SRBrightColor
const buttonHeight = 46
const buttonCornerRadius = buttonHeight/2
const cancelButtonTint = SRDarkColor
const tintColor = SRRedColor

const dateSegmentedControlCornerRadius = 4

export default class SRStudyTaskEditor extends React.Component {

  static navigationOptions = ({navigation}) => {
    const { params = {} } = navigation.state

    return {
      headerTintColor: SRDarkColor,
      headerStyle: {
        backgroundColor: SRBrightColor
      },
      title: (params.readonly) ? 'Details' : 'Add a task',
    }
  }

  constructor(props) {
    super(props)

    const { params } = props.navigation.state

    this.state = {
      id:             params != null ? params.item.id            : uuid(),
      taskName:       params != null ? params.item.taskName      : null,
      notes:          params != null ? params.item.notes         : null,
      dates:          params != null ? params.item.dates         : [new Date()],
      ratingHistory:  params != null ? params.item.ratingHistory : [],
      srs:            params != null ? params.item.srs           : new SRSpacedRepetition(),
      intensity:      params != null ? params.item.intensity     : SRStudyTaskIntensity.NORMAL,

      readonly: params != null ? params.readonly : false,

      studyTaskLabelString: params != null ? studyTaskString : ' ',
      notesLabelString: params != null ? notesString : ' ',
      pickedDate: 'Other',
      selectedDateIndex: 0,
      selectedIntensityIndex: 0,
    }
  }

  props: {
    saveAction: (studyTask) => any,
  }

  componentWillReceiveProps() {
    const { notes, taskName } = this.state
    this.hideStudyTaskLabel(taskName == null || taskName == '')
    this.hideNotesLabel(notes == null || notes == '')
  }

  render() {
    const { dates, intensity, notes, readonly, studyTaskLabelString, taskName } = this.state

    const actionButtonTitle = (readonly == true) ? 'Edit' : 'Save'
    const destructiveButtonTitle = (readonly == true) ? 'Delete' : 'Cancel'

    const NOT_IMPLEMENTED = false

    return (
      <ScrollView style={styles.scrollView}>
        <View style={styles.edgePadding}>

          <View style={styles.sections}>
            <Text style={styles.sectionLabel}>{studyTaskLabelString}</Text>
            <TextInput
              style={styles.dataInputItemPadding}
              placeholder={studyTaskString}
              onSubmitEditing={Keyboard.dismiss}
              onChangeText={(taskName) => this.studyTextFieldOnChangeText(taskName)}
              value={taskName}
            />
            {this._renderSeparator(!readonly)}
          </View>

          {this._renderNotes(!readonly || (notes != null && notes != ''))}
          {this._renderDateSelection(!readonly)}
          {this._renderRatingHistory(NOT_IMPLEMENTED)}

          <View name='dataSeparator' style={[styles.sectionSeparator, styles.lastSectionSeparator]}/>

          <View style={[styles.sections, styles.bottomButtonsView]}>
            <TouchableOpacity
              style={[styles.dataInputItemPadding, styles.bottomButtons, styles.actionButton]}
              onPress={this.actionButtonAction}>
              <Text style={[styles.bottomButtonsText, styles.actionButtonText]}>{actionButtonTitle}</Text>
            </TouchableOpacity>

            <TouchableOpacity
              style={[styles.dataInputItemPadding, styles.bottomButtons, styles.cancelButton]}
              onPress={this.destructiveButtonAction}>
              <Text style={[styles.bottomButtonsText, styles.destructiveButtonText]}>{destructiveButtonTitle}</Text>
            </TouchableOpacity>
          </View>

        </View>
      </ScrollView>
    )
  }

  studyTextFieldOnChangeText = (taskName) => {
    this.hideStudyTaskLabel(taskName == null || taskName == '')
    this.setState({taskName})
  }

  notesTextFieldOnChangeText = (notes) => {
    this.hideNotesLabel(notes == null || notes == '')
    this.setState({notes})
  }

  hideStudyTaskLabel = (flag = true) => {
    this.setState({
      studyTaskLabelString: flag ? ' ' : studyTaskString
    })
  }

  hideNotesLabel = (flag = true) => {
    this.setState({
      notesLabelString: flag ? ' ' : notesString
    })
  }

  handleDateSelection = (index) => {
    this.setState({...this.state, selectedDateIndex: index})
  }

  handleIntensitySelection = (index) => {
    this.setState({...this.state, selectedIntensityIndex: index})
  }

  openDatePicker = () => {

  }

  changeIntensity = () => {

  }

  actionButtonAction = () => {
    const { store } = this.props.screenProps

    const studyTask = new SRStudyTask(
      this.state.id,
      this.state.taskName,
      this.state.notes,
      this.state.dates,
      this.state.ratingHistory,
      this.state.srs,
      this.state.intensity
    )

    if(this.state.readonly) {
      store.dispatch(actionCreators.replace(studyTask))
    } else {
      store.dispatch(actionCreators.add(studyTask))
      this.dismissView()
    }
  }

  destructiveButtonAction = () => {
    if (this.state.readonly) {
      Alert.alert(
        'Delete Study Task',
        'Are you sure you want to delete the study task?',
        [
          {text: 'Cancel', onPress: () => {}, style: 'cancel'},
          {text: 'Delete', onPress: () => {
            // expect(this.state.id).toEqual('ada', `this.state.id: ${this.state.id}`)
            this.props.screenProps.store.dispatch(actionCreators.remove({id: this.state.id}))
            this.dismissView()
          }},
        ],
        { cancelable: true }
      )
    } else {
      const { modalDismissAction } = this.props.screenProps
      modalDismissAction()
    }
  }

  _renderSeparator = (flag) => {
    if(flag) {
      return <View name='separator' style={styles.sectionSeparator}/>
    } else {
      return null
    }
  }

  _renderNotes = (flag) => {
      if(flag) {
        const { notes, notesLabelString, readonly } = this.state
        return(
          <View style={styles.sections}>
            <Text style={styles.sectionLabel}>{notesLabelString}</Text>
            <TextInput
              style={styles.dataInputItemPadding}
              placeholder={notesString}
              onSubmitEditing={Keyboard.dismiss}
              onChangeText={(notes) => this.notesTextFieldOnChangeText(notes)}
              value={notes}
            />
            {this._renderSeparator(!readonly)}
          </View>
        )
      } else {
        return null
      }
  }

  _renderDateSelection = (flag) => {
    if(flag) {
      const { pickedDate } = this.state
      const formattedPickedDate = pickedDate // TODO:
      return (
        <View style={styles.sections}>
          <Text style={styles.sectionLabel}>Date</Text>
          <SegmentedControlTab
            borderRadius={dateSegmentedControlCornerRadius}
            tabsContainerStyle={styles.tabsContainerStyle}
            tabStyle={styles.tabStyle}
            tabTextStyle={styles.tabTextStyle}
            activeTabStyle={styles.activeTabStyle}
            activeTabTextStyle={styles.activeTabTextStyle}
            values={['Today', 'Yesterday', formattedPickedDate]}
            selectedIndex={this.state.selectedDateIndex}
            onTabPress={this.handleDateSelection}
          />
        </View>
      )
    } else {
      return null
    }
  }

  _renderRatingHistory = (flag) => {
    if(flag) {

      return (
        <View style={styles.sections}>
          <Text style={styles.sectionLabel}>Rating History</Text>

        </View>
      )
    } else {
      return null
    }
  }

  dismissView = () => {

  }

}

const styles = StyleSheet.create({
  scrollView: {
    flex: 1,
    backgroundColor: SRBrightColor,
  },
  edgePadding: {
    padding: 15,
    flex:1,
  },
  dataInputItemPadding: {
    padding: 4,
  },
  sectionLabel: {
    fontSize: 14,
    color: tintColor,
  },
  sectionSeparator: {
    backgroundColor: cancelButtonTint,
    height: 1,
  },
  lastSectionSeparator: {
    marginTop: 8,
  },
  sections: {
    padding: 8,
  },
  bottomButtonsView: {
    flexDirection: 'column',
    paddingTop: 20,
  },
  bottomButtons: {
    alignItems: 'center',
    height: buttonHeight,
    justifyContent: 'center',
  },
  actionButton: {
    backgroundColor: tintColor,
    borderRadius: buttonCornerRadius,
    flex: 1,
  },
  cancelButton: {
    borderColor: cancelButtonTint,
    borderWidth: 2,
    borderRadius: buttonCornerRadius,
    flex: 1,
    marginTop: 10,
  },
  bottomButtonsText: {
    color: SRBrightColor,
    fontSize: 16,
    fontWeight: 'bold',
  },
  actionButtonText: {
    paddingTop: 1,
  },
  destructiveButtonText: {
    color: cancelButtonTint,
  },
  tabsContainerStyle: {
    paddingTop: 5,
    paddingBottom: 5,
    height: buttonHeight,
  },
  tabStyle: {
    backgroundColor: inactiveColor,
    borderColor: inactiveColor,
    borderRadius: dateSegmentedControlCornerRadius,
    marginLeft: 2,
    marginRight: 2,
  },
  tabTextStyle: {
    fontWeight: 'bold',
    color: SRBrightColor,
  },
  activeTabStyle: {
    backgroundColor: tintColor,
    borderColor: tintColor,
  },
  activeTabTextStyle: {
  },
})
<commit_msg>Updated Editor UI.<commit_after>// @flow
import React from 'react'
import {
  Alert,
  Keyboard,
  StyleSheet,
  Text,
  TextInput,
  TouchableOpacity,
  ScrollView,
  View
} from 'react-native'
import SegmentedControlTab from 'react-native-segmented-control-tab'
import expect, { createSpy, spyOn, isSpy } from 'expect'
import moment from 'moment'
import { actionCreators, SRStudyTask, SRStudyTaskIntensity } from './dataModel/SRSimpleDataModel'
import { SRSpacedRepetition } from './SRSpacedRepetition'
import { uuid } from './utilities/UUID'
import { capitalizeFirstLetter } from './utilities/String+Capitalize'
import {SRDarkColor, SRYellowColor, SRBrightColor, SRRedColor} from './utilities/SRColors'

const studyTaskString = 'STUDY TASK'
const notesString = 'NOTES'
const dateString = 'STARTING DATE'

const SRPlaceholderTextColor = 'rgba(251, 251, 253, 0.5)'

const inactiveColor = SRBrightColor
const buttonHeight = 46
const buttonCornerRadius = buttonHeight/2
const cancelButtonTint = SRDarkColor
const tintColor = SRRedColor

const dateSegmentedControlCornerRadius = 4

export default class SRStudyTaskEditor extends React.Component {

  static navigationOptions = ({navigation}) => {
    const { params = {} } = navigation.state

    return {
      headerTintColor: SRDarkColor,
      headerStyle: {
        backgroundColor: SRBrightColor
      },
      title: (params.readonly) ? 'Details' : 'Add a task',
    }
  }

  constructor(props) {
    super(props)

    const { params } = props.navigation.state

    this.state = {
      id:             params != null ? params.item.id            : uuid(),
      taskName:       params != null ? params.item.taskName      : null,
      notes:          params != null ? params.item.notes         : null,
      dates:          params != null ? params.item.dates         : [new Date()],
      ratingHistory:  params != null ? params.item.ratingHistory : [],
      srs:            params != null ? params.item.srs           : new SRSpacedRepetition(),
      intensity:      params != null ? params.item.intensity     : SRStudyTaskIntensity.NORMAL,

      readonly: params != null ? params.readonly : false,

      studyTaskLabelString: params != null ? studyTaskString : ' ',
      notesLabelString: params != null ? notesString : ' ',
      pickedDate: 'Other',
      selectedDateIndex: 0,
      selectedIntensityIndex: 0,
    }
  }

  props: {
    saveAction: (studyTask) => any,
  }

  componentWillReceiveProps() {
    const { notes, taskName } = this.state
    this.hideStudyTaskLabel(taskName == null || taskName == '')
    this.hideNotesLabel(notes == null || notes == '')
  }

  render() {
    const { dates, intensity, notes, readonly, studyTaskLabelString, taskName } = this.state

    const actionButtonTitle = (readonly == true) ? 'Edit' : 'Save'
    const destructiveButtonTitle = (readonly == true) ? 'Delete' : 'Cancel'

    const NOT_IMPLEMENTED = false

    return (
      <ScrollView style={styles.scrollView}>
        <View style={styles.edgePadding}>

          <View style={styles.sections}>
            <Text style={styles.sectionLabel}>{studyTaskLabelString}</Text>
            <TextInput
              style={[styles.dataInputItemPadding, styles.textInput]}
              placeholder={studyTaskString}
              placeholderTextColor={SRPlaceholderTextColor}
              onSubmitEditing={Keyboard.dismiss}
              onChangeText={(taskName) => this.studyTextFieldOnChangeText(taskName)}
              value={taskName}
            />
            {this._renderSeparator(!readonly)}
          </View>

          {this._renderNotes(!readonly || (notes != null && notes != ''))}
          {this._renderDateSelection(!readonly)}
          {this._renderRatingHistory(NOT_IMPLEMENTED)}

          <View name='dataSeparator' style={[styles.sectionSeparator, styles.lastSectionSeparator]}/>

          <View style={[styles.sections, styles.bottomButtonsView]}>
            <TouchableOpacity
              style={[styles.dataInputItemPadding, styles.bottomButtons, styles.actionButton]}
              onPress={this.actionButtonAction}>
              <Text style={[styles.bottomButtonsText, styles.actionButtonText]}>{actionButtonTitle}</Text>
            </TouchableOpacity>

            <TouchableOpacity
              style={[styles.dataInputItemPadding, styles.bottomButtons, styles.cancelButton]}
              onPress={this.destructiveButtonAction}>
              <Text style={[styles.bottomButtonsText, styles.destructiveButtonText]}>{destructiveButtonTitle}</Text>
            </TouchableOpacity>
          </View>

        </View>
      </ScrollView>
    )
  }

  studyTextFieldOnChangeText = (taskName) => {
    this.hideStudyTaskLabel(taskName == null || taskName == '')
    this.setState({taskName})
  }

  notesTextFieldOnChangeText = (notes) => {
    this.hideNotesLabel(notes == null || notes == '')
    this.setState({notes})
  }

  hideStudyTaskLabel = (flag = true) => {
    this.setState({
      studyTaskLabelString: flag ? ' ' : studyTaskString
    })
  }

  hideNotesLabel = (flag = true) => {
    this.setState({
      notesLabelString: flag ? ' ' : notesString
    })
  }

  handleDateSelection = (index) => {
    this.setState({...this.state, selectedDateIndex: index})
  }

  handleIntensitySelection = (index) => {
    this.setState({...this.state, selectedIntensityIndex: index})
  }

  openDatePicker = () => {

  }

  changeIntensity = () => {

  }

  actionButtonAction = () => {
    const { store } = this.props.screenProps

    const studyTask = new SRStudyTask(
      this.state.id,
      this.state.taskName,
      this.state.notes,
      this.state.dates,
      this.state.ratingHistory,
      this.state.srs,
      this.state.intensity
    )

    if(this.state.readonly) {
      store.dispatch(actionCreators.replace(studyTask))
    } else {
      store.dispatch(actionCreators.add(studyTask))
      this.dismissView()
    }
  }

  destructiveButtonAction = () => {
    if (this.state.readonly) {
      Alert.alert(
        'Delete Study Task',
        'Are you sure you want to delete the study task?',
        [
          {text: 'Cancel', onPress: () => {}, style: 'cancel'},
          {text: 'Delete', onPress: () => {
            // expect(this.state.id).toEqual('ada', `this.state.id: ${this.state.id}`)
            this.props.screenProps.store.dispatch(actionCreators.remove({id: this.state.id}))
            this.dismissView()
          }},
        ],
        { cancelable: true }
      )
    } else {
      const { modalDismissAction } = this.props.screenProps
      modalDismissAction()
    }
  }

  _renderSeparator = (flag) => {
    if(flag) {
      return <View name='separator' style={styles.sectionSeparator}/>
    } else {
      return null
    }
  }

  _renderNotes = (flag) => {
      if(flag) {
        const { notes, notesLabelString, readonly } = this.state
        return(
          <View style={styles.sections}>
            <Text style={styles.sectionLabel}>{notesLabelString}</Text>
            <TextInput
              style={[styles.dataInputItemPadding, styles.textInput]}
              placeholder={notesString}
              placeholderTextColor={SRPlaceholderTextColor}
              onSubmitEditing={Keyboard.dismiss}
              onChangeText={(notes) => this.notesTextFieldOnChangeText(notes)}
              value={notes}
            />
            {this._renderSeparator(!readonly)}
          </View>
        )
      } else {
        return null
      }
  }

  _renderDateSelection = (flag) => {
    if(flag) {
      const { pickedDate } = this.state
      const formattedPickedDate = pickedDate // TODO:
      return (
        <View style={styles.sections}>
          <Text style={styles.sectionLabel}>{dateString}</Text>
          <SegmentedControlTab
            borderRadius={dateSegmentedControlCornerRadius}
            tabsContainerStyle={styles.tabsContainerStyle}
            tabStyle={styles.tabStyle}
            tabTextStyle={styles.tabTextStyle}
            activeTabStyle={styles.activeTabStyle}
            activeTabTextStyle={styles.activeTabTextStyle}
            values={['Today', 'Yesterday', formattedPickedDate]}
            selectedIndex={this.state.selectedDateIndex}
            onTabPress={this.handleDateSelection}
          />
        </View>
      )
    } else {
      return null
    }
  }

  _renderRatingHistory = (flag) => {
    if(flag) {

      return (
        <View style={styles.sections}>
          <Text style={styles.sectionLabel}>Rating History</Text>

        </View>
      )
    } else {
      return null
    }
  }

  dismissView = () => {

  }

}

const styles = StyleSheet.create({
  scrollView: {
    flex: 1,
    backgroundColor: SRDarkColor,
  },
  edgePadding: {
    padding: 15,
    flex:1,
  },
  dataInputItemPadding: {
    padding: 4,
  },
  textInput: {
    fontSize: 48,
    color: SRBrightColor,
  },
  sectionLabel: {
    fontSize: 20,
    color: SRRedColor,
    fontWeight: 'bold'
  },
  sectionSeparator: {
    backgroundColor: SRBrightColor,
    height: 1,
  },
  lastSectionSeparator: {
    marginTop: 8,
  },
  sections: {
    padding: 8,
  },
  bottomButtonsView: {
    flexDirection: 'column',
    paddingTop: 20,
  },
  bottomButtons: {
    alignItems: 'center',
    height: buttonHeight,
    justifyContent: 'center',
  },
  actionButton: {
    backgroundColor: SRYellowColor,
    borderRadius: buttonCornerRadius,
    flex: 1,
  },
  cancelButton: {
    borderColor: SRYellowColor,
    borderWidth: 1,
    borderRadius: buttonCornerRadius,
    flex: 1,
    marginTop: 10,
  },
  bottomButtonsText: {
    color: SRDarkColor,
    fontSize: 16,
    fontWeight: 'bold',
  },
  actionButtonText: {
    paddingTop: 1,
  },
  destructiveButtonText: {
    color: SRYellowColor,
  },
  tabsContainerStyle: {
    paddingTop: 15,
    paddingBottom: 5,
    height: buttonHeight+14,
  },
  tabStyle: {
    backgroundColor: SRBrightColor,
    borderColor: SRBrightColor,
    borderRadius: dateSegmentedControlCornerRadius,
    marginLeft: 2,
    marginRight: 2,
  },
  tabTextStyle: {
    fontWeight: 'bold',
    color: SRDarkColor,
  },
  activeTabStyle: {
    backgroundColor: SRYellowColor,
    borderColor: SRYellowColor,
  },
  activeTabTextStyle: {
    color: SRDarkColor
  },
})
<|endoftext|>


<commit_before>// Copyright 2002-2013, University of Colorado Boulder

/**
 * PropertySet facilitates creation and use of multiple named Property instances.  There are still several API design issues in question, but this
 * class is ready for use.
 *
 * A PropertySet is a set of Property instances that provides support for:
 * -Easily creating several properties using an object literal (hash)
 * -Resetting them as a group
 * -Set multiple values at once, using propertySet.set({x:100,y:200,name:'alice'});
 * -Support for derived properties, which appear with the same interface as basic properties
 * -Convenient toString that prints e.g., PropertySet{name:'larry',age:101,kids:['alice','bob']}
 * -Wiring up to listen to multiple properties simultaneously
 * -Add properties after the PropertySet is created?  Don't forget to add to the key list as well.
 * -Remove properties that were added using addProperty or the constructor
 *
 * Sample usage:
 * var p = new PropertySet( {name: 'larry', age: 100, kids: ['alice', 'bob']} );
 * p.nameProperty.link( function( n ) {console.log( 'hello ' + n );} );
 * p.name = 'jensen';
 * p.age = 101;//Happy Birthday!
 * console.log( p );
 * p.reset();
 * console.log( p );
 * p.set({name:'clark',age:102,kids:['alice','bob','charlie']});
 *
 * How would this be done without PropertySet (for comparison)?
 * //Normally would be created in a class but that is omitted here for brevity.
 * var p ={name: new Property('larry'), age: new Property('age'), kids: new Property(['alice','bob'])}
 * p.reset = function(){
 *   this.name.reset();
 *   this.age.reset();
 *   this.kids.reset();
 * }
 * p.name.set('clark');
 * p.age.set('102');
 * p.kids.set(['alice','bob','charlie']);
 *
 * Note: If a subclass ever substitutes a property like this: person.ageProperty = new Property(person.age), then it would break the getter/setter
 * @author Sam Reid
 */

define( function( require ) {
  'use strict';

  // modules
  var Property = require( 'AXON/Property' );
  var DerivedProperty = require( 'AXON/DerivedProperty' );
  var Events = require( 'AXON/Events' );
  var axon = require( 'AXON/axon' );
  var inherit = require( 'PHET_CORE/inherit' );

  // constants
  var SUFFIX = 'Property';

  /**
   * @class PropertySet
   * @constructor
   * @param values an object hash with the initial values for the properties
   * @param {object} [options] -
   *                           - propertySetID: optional identifier used in data collection messages
   */
  axon.PropertySet = function PropertySet( values, options ) {
    var propertySet = this;
    this.propertySetID = options ? options.propertySetID : null;

    Events.call( this );

    //Keep track of the keys so we know which to reset
    this.keys = [];

    Object.getOwnPropertyNames( values ).forEach( function( value ) {
      propertySet.addProperty( value, values[ value ], propertySet.propertySetID );
    } );
  };

  return inherit( Events, axon.PropertySet, {

    /**
     * Adds a new property to this PropertySet
     * @param {string} propertyName
     * @param {*} value the property's initial value
     * @param {string} [propertySetID] optional identifier for data-collection studies
     */
    addProperty: function( propertyName, value, propertySetID ) {
      if ( propertySetID !== null && typeof( propertySetID ) !== 'undefined' && typeof( propertySetID ) !== 'string' ) {
        throw new Error( 'If defined, the propertySetID must be a string.' );
      }
      var propertyID;
      if ( typeof( propertySetID ) === 'string' ) {
        propertyID = propertySetID + '.' + propertyName;
      }
      else {
        propertyID = propertyName;
      }
      this[ propertyName + SUFFIX ] = new Property( value, { propertyID: propertyID } );
      this.addGetterAndSetter( propertyName );
      this.keys.push( propertyName );
    },

    /**
     * Remove any property (whether a derived property or not) that was added to this PropertySet
     * @param {String} propertyName
     */
    removeProperty: function( propertyName ) {

      //Remove from the keys (only for non-derived properties)
      var index = this.keys.indexOf( propertyName );
      if ( index !== -1 ) {
        this.keys.splice( index, 1 );
      }

      //Unregister the Property instance from the PropertySet
      delete this[ propertyName + SUFFIX ];

      //Unregister the getter/setter, if they exist
      delete this[ propertyName ];
    },

    /**
     * Adds a getter and setter using ES5 get/set syntax, similar to https://gist.github.com/dandean/1292057, same as in github/Atlas
     * @param {string} propertyName
     */
    addGetterAndSetter: function( propertyName ) {
      var property = this[ propertyName + SUFFIX ];

      Object.defineProperty( this, propertyName, {

        // Getter proxies to Model#get()...
        get: function() { return property.get();},

        // Setter proxies to Model#set(attributes)
        set: function( value ) { property.set( value );},

        // Make it configurable and enumerable so it's easy to override...
        configurable: true,
        enumerable: true
      } );
    },

    /**
     * Adds an ES5 getter to a property.
     * @param {string} propertyName
     */
    addGetter: function( propertyName ) {
      var property = this[ propertyName + SUFFIX ];

      Object.defineProperty( this, propertyName, {

        get: function() { return property.get();},

        // Make it configurable and enumerable so it's easy to override...
        configurable: true,
        enumerable: true
      } );
    },

    // Resets all of the properties associated with this PropertySet
    reset: function() {
      var propertySet = this;
      this.keys.forEach( function( key ) {
        propertySet[ key + SUFFIX ].reset();
      } );
    },

    /**
     * Creates a DerivedProperty from the given property property names and derivation.
     * @param {string[]} propertyNames
     * @param {function} derivation
     * @returns {DerivedProperty}
     */
    toDerivedProperty: function( propertyNames, derivation ) {
      return new DerivedProperty( this.getProperties( propertyNames ), derivation );
    },

    /**
     * Adds a derived property to the property set.
     * @param {string} propertyName name for the derived property
     * @param {string[]} dependencyNames names of the properties that it depends on
     * @param {function} derivation function that expects args in the same order as dependencies
     */
    addDerivedProperty: function( propertyName, dependencyNames, derivation ) {
      this[ propertyName + SUFFIX ] = this.toDerivedProperty( dependencyNames, derivation );
      this.addGetter( propertyName );
    },

    /**
     * Returns an array of the requested properties.
     * @param propertyNames
     * @returns {*}
     * @private
     */
    getProperties: function( propertyNames ) {
      var propertySet = this;
      return propertyNames.map( function( propertyName ) {
        var propertyKey = propertyName + SUFFIX;
        assert && assert( propertySet.hasOwnProperty( propertyKey ) );
        return propertySet[ propertyKey ];
      } );
    },

    /**
     * Set all of the values specified in the object hash
     * Allows you to use this form:
     * puller.set( {x: knot.x, y: knot.y, knot: knot} );
     *
     * instead of this:
     * puller.x.value = knot.x;
     * puller.y.value = knot.y;
     * puller.knot.value = knot;
     *
     * Throws an error if you try to set a value for which there is no property.
     */
    setValues: function( values ) {
      var propertySet = this;
      Object.getOwnPropertyNames( values ).forEach( function( propertyName ) {
        if ( typeof(propertySet[ propertyName + SUFFIX ] === 'Property') ) {
          propertySet[ propertyName + SUFFIX ].set( values[ propertyName ] );
        }
        else {
          throw new Error( 'property not found: ' + propertyName );
        }
      } );
    },

    /**
     * Get a JS object literal with all the current values of the properties in this property set, say for serialization.  See `set`
     * TODO: this works well to serialize numbers, strings, booleans.  How to handle complex state values such as Vector2 or nested Property?  Maybe that must be up to the client code.
     * TODO: This was named 'get' to mirror the 'set' method above, but I'm concerned this will make them difficult to find/replace and may confuse with real getters & setters.  Maybe setState/getState would be better?
     */
    getValues: function() {
      var state = {};
      for ( var i = 0; i < this.keys.length; i++ ) {
        var key = this.keys[ i ];
        state[ key ] = this.property( key ).value;
      }
      return state;
    },

    /**
     * Link to a property by name, see https://github.com/phetsims/axon/issues/16
     * @param {string} propertyName the name of the property to link to
     * @param {function }observer the callback to link to the property
     */
    link: function( propertyName, observer ) {
      this[ propertyName + SUFFIX ].link( observer );
    },

    /**
     * Unlink for a property by name, see https://github.com/phetsims/axon/issues/16
     * @param {string} propertyName the name of the property to link to
     * @param {function }observer the callback to link to the property
     */
    unlink: function( propertyName, observer ) {
      this[ propertyName + SUFFIX ].unlink( observer );
    },

    /**
     * Link an attribute to a property by name.  Return a handle to the observer so it can be removed using unlink().
     * @param {string} propertyName the property to link to
     * @param {object} object the object for which the attribute will be set
     * @param {string} attributeName the name of the attribute to set on the object
     */
    linkAttribute: function( propertyName, object, attributeName ) {
      return this.property( propertyName ).linkAttribute( object, attributeName );
    },

    /**
     * Unlink an observer added with linkAttribute.  Note: the args of linkAttribute do not match the args of
     * unlinkAttribute: here, you must pass the observer handle returned by linkAttribute rather than object and attributeName
     * @param {string} propertyName - the name of the property that the observer will be removed from
     * @param {function} observer
     */
    unlinkAttribute: function( propertyName, observer ) {
      this.property( propertyName ).unlink( observer );
    },

    /**
     * Registers an observer with multiple properties, then notifies the observer immediately.
     * @param {string[]} propertyNames
     * @param {function} observer no params, returns nothing
     */
    multilink: function( propertyNames, observer ) {
      return new axon.Multilink( this.getProperties( propertyNames ), observer, false );
    },

    lazyMultilink: function( propertyNames, observer ) {
      return new axon.Multilink( this.getProperties( propertyNames ), observer, true );
    },

    /**
     * Removes the multilink from this PropertySet.
     * Same as calling detach() on the multilink
     * @param {Multilink} multilink
     */
    unmultilink: function( multilink ) {
      multilink.detach();
    },

    toString: function() {
      var text = 'PropertySet{';
      var propertySet = this;
      for ( var i = 0; i < this.keys.length; i++ ) {
        var key = this.keys[ i ];
        text = text + key + ':' + propertySet[ key ].toString();
        if ( i < this.keys.length - 1 ) {
          text = text + ',';
        }
      }
      return text + '}';
    },

    /**
     * Get a property by name, see https://github.com/phetsims/axon/issues/16
     * @param {string} propertyName the name of the property to get
     */
    property: function( propertyName ) {
      return this[ propertyName + SUFFIX ];
    }
  } );
} );
<commit_msg>fix import of Multilink in PropertySet, results in failure of built sims, phetsims/axon#44, phetsims/graphing-lines#44<commit_after>// Copyright 2002-2013, University of Colorado Boulder

/**
 * PropertySet facilitates creation and use of multiple named Property instances.  There are still several API design issues in question, but this
 * class is ready for use.
 *
 * A PropertySet is a set of Property instances that provides support for:
 * -Easily creating several properties using an object literal (hash)
 * -Resetting them as a group
 * -Set multiple values at once, using propertySet.set({x:100,y:200,name:'alice'});
 * -Support for derived properties, which appear with the same interface as basic properties
 * -Convenient toString that prints e.g., PropertySet{name:'larry',age:101,kids:['alice','bob']}
 * -Wiring up to listen to multiple properties simultaneously
 * -Add properties after the PropertySet is created?  Don't forget to add to the key list as well.
 * -Remove properties that were added using addProperty or the constructor
 *
 * Sample usage:
 * var p = new PropertySet( {name: 'larry', age: 100, kids: ['alice', 'bob']} );
 * p.nameProperty.link( function( n ) {console.log( 'hello ' + n );} );
 * p.name = 'jensen';
 * p.age = 101;//Happy Birthday!
 * console.log( p );
 * p.reset();
 * console.log( p );
 * p.set({name:'clark',age:102,kids:['alice','bob','charlie']});
 *
 * How would this be done without PropertySet (for comparison)?
 * //Normally would be created in a class but that is omitted here for brevity.
 * var p ={name: new Property('larry'), age: new Property('age'), kids: new Property(['alice','bob'])}
 * p.reset = function(){
 *   this.name.reset();
 *   this.age.reset();
 *   this.kids.reset();
 * }
 * p.name.set('clark');
 * p.age.set('102');
 * p.kids.set(['alice','bob','charlie']);
 *
 * Note: If a subclass ever substitutes a property like this: person.ageProperty = new Property(person.age), then it would break the getter/setter
 * @author Sam Reid
 */

define( function( require ) {
  'use strict';

  // modules
  var Property = require( 'AXON/Property' );
  var DerivedProperty = require( 'AXON/DerivedProperty' );
  var Multilink = require( 'AXON/Multilink' );
  var Events = require( 'AXON/Events' );
  var axon = require( 'AXON/axon' );
  var inherit = require( 'PHET_CORE/inherit' );

  // constants
  var SUFFIX = 'Property';

  /**
   * @class PropertySet
   * @constructor
   * @param values an object hash with the initial values for the properties
   * @param {object} [options] -
   *                           - propertySetID: optional identifier used in data collection messages
   */
  axon.PropertySet = function PropertySet( values, options ) {
    var propertySet = this;
    this.propertySetID = options ? options.propertySetID : null;

    Events.call( this );

    //Keep track of the keys so we know which to reset
    this.keys = [];

    Object.getOwnPropertyNames( values ).forEach( function( value ) {
      propertySet.addProperty( value, values[ value ], propertySet.propertySetID );
    } );
  };

  return inherit( Events, axon.PropertySet, {

    /**
     * Adds a new property to this PropertySet
     * @param {string} propertyName
     * @param {*} value the property's initial value
     * @param {string} [propertySetID] optional identifier for data-collection studies
     */
    addProperty: function( propertyName, value, propertySetID ) {
      if ( propertySetID !== null && typeof( propertySetID ) !== 'undefined' && typeof( propertySetID ) !== 'string' ) {
        throw new Error( 'If defined, the propertySetID must be a string.' );
      }
      var propertyID;
      if ( typeof( propertySetID ) === 'string' ) {
        propertyID = propertySetID + '.' + propertyName;
      }
      else {
        propertyID = propertyName;
      }
      this[ propertyName + SUFFIX ] = new Property( value, { propertyID: propertyID } );
      this.addGetterAndSetter( propertyName );
      this.keys.push( propertyName );
    },

    /**
     * Remove any property (whether a derived property or not) that was added to this PropertySet
     * @param {String} propertyName
     */
    removeProperty: function( propertyName ) {

      //Remove from the keys (only for non-derived properties)
      var index = this.keys.indexOf( propertyName );
      if ( index !== -1 ) {
        this.keys.splice( index, 1 );
      }

      //Unregister the Property instance from the PropertySet
      delete this[ propertyName + SUFFIX ];

      //Unregister the getter/setter, if they exist
      delete this[ propertyName ];
    },

    /**
     * Adds a getter and setter using ES5 get/set syntax, similar to https://gist.github.com/dandean/1292057, same as in github/Atlas
     * @param {string} propertyName
     */
    addGetterAndSetter: function( propertyName ) {
      var property = this[ propertyName + SUFFIX ];

      Object.defineProperty( this, propertyName, {

        // Getter proxies to Model#get()...
        get: function() { return property.get();},

        // Setter proxies to Model#set(attributes)
        set: function( value ) { property.set( value );},

        // Make it configurable and enumerable so it's easy to override...
        configurable: true,
        enumerable: true
      } );
    },

    /**
     * Adds an ES5 getter to a property.
     * @param {string} propertyName
     */
    addGetter: function( propertyName ) {
      var property = this[ propertyName + SUFFIX ];

      Object.defineProperty( this, propertyName, {

        get: function() { return property.get();},

        // Make it configurable and enumerable so it's easy to override...
        configurable: true,
        enumerable: true
      } );
    },

    // Resets all of the properties associated with this PropertySet
    reset: function() {
      var propertySet = this;
      this.keys.forEach( function( key ) {
        propertySet[ key + SUFFIX ].reset();
      } );
    },

    /**
     * Creates a DerivedProperty from the given property property names and derivation.
     * @param {string[]} propertyNames
     * @param {function} derivation
     * @returns {DerivedProperty}
     */
    toDerivedProperty: function( propertyNames, derivation ) {
      return new DerivedProperty( this.getProperties( propertyNames ), derivation );
    },

    /**
     * Adds a derived property to the property set.
     * @param {string} propertyName name for the derived property
     * @param {string[]} dependencyNames names of the properties that it depends on
     * @param {function} derivation function that expects args in the same order as dependencies
     */
    addDerivedProperty: function( propertyName, dependencyNames, derivation ) {
      this[ propertyName + SUFFIX ] = this.toDerivedProperty( dependencyNames, derivation );
      this.addGetter( propertyName );
    },

    /**
     * Returns an array of the requested properties.
     * @param propertyNames
     * @returns {*}
     * @private
     */
    getProperties: function( propertyNames ) {
      var propertySet = this;
      return propertyNames.map( function( propertyName ) {
        var propertyKey = propertyName + SUFFIX;
        assert && assert( propertySet.hasOwnProperty( propertyKey ) );
        return propertySet[ propertyKey ];
      } );
    },

    /**
     * Set all of the values specified in the object hash
     * Allows you to use this form:
     * puller.set( {x: knot.x, y: knot.y, knot: knot} );
     *
     * instead of this:
     * puller.x.value = knot.x;
     * puller.y.value = knot.y;
     * puller.knot.value = knot;
     *
     * Throws an error if you try to set a value for which there is no property.
     */
    setValues: function( values ) {
      var propertySet = this;
      Object.getOwnPropertyNames( values ).forEach( function( propertyName ) {
        if ( typeof(propertySet[ propertyName + SUFFIX ] === 'Property') ) {
          propertySet[ propertyName + SUFFIX ].set( values[ propertyName ] );
        }
        else {
          throw new Error( 'property not found: ' + propertyName );
        }
      } );
    },

    /**
     * Get a JS object literal with all the current values of the properties in this property set, say for serialization.  See `set`
     * TODO: this works well to serialize numbers, strings, booleans.  How to handle complex state values such as Vector2 or nested Property?  Maybe that must be up to the client code.
     * TODO: This was named 'get' to mirror the 'set' method above, but I'm concerned this will make them difficult to find/replace and may confuse with real getters & setters.  Maybe setState/getState would be better?
     */
    getValues: function() {
      var state = {};
      for ( var i = 0; i < this.keys.length; i++ ) {
        var key = this.keys[ i ];
        state[ key ] = this.property( key ).value;
      }
      return state;
    },

    /**
     * Link to a property by name, see https://github.com/phetsims/axon/issues/16
     * @param {string} propertyName the name of the property to link to
     * @param {function }observer the callback to link to the property
     */
    link: function( propertyName, observer ) {
      this[ propertyName + SUFFIX ].link( observer );
    },

    /**
     * Unlink for a property by name, see https://github.com/phetsims/axon/issues/16
     * @param {string} propertyName the name of the property to link to
     * @param {function }observer the callback to link to the property
     */
    unlink: function( propertyName, observer ) {
      this[ propertyName + SUFFIX ].unlink( observer );
    },

    /**
     * Link an attribute to a property by name.  Return a handle to the observer so it can be removed using unlink().
     * @param {string} propertyName the property to link to
     * @param {object} object the object for which the attribute will be set
     * @param {string} attributeName the name of the attribute to set on the object
     */
    linkAttribute: function( propertyName, object, attributeName ) {
      return this.property( propertyName ).linkAttribute( object, attributeName );
    },

    /**
     * Unlink an observer added with linkAttribute.  Note: the args of linkAttribute do not match the args of
     * unlinkAttribute: here, you must pass the observer handle returned by linkAttribute rather than object and attributeName
     * @param {string} propertyName - the name of the property that the observer will be removed from
     * @param {function} observer
     */
    unlinkAttribute: function( propertyName, observer ) {
      this.property( propertyName ).unlink( observer );
    },

    /**
     * Registers an observer with multiple properties, then notifies the observer immediately.
     * @param {string[]} propertyNames
     * @param {function} observer no params, returns nothing
     */
    multilink: function( propertyNames, observer ) {
      return new Multilink( this.getProperties( propertyNames ), observer, false );
    },

    lazyMultilink: function( propertyNames, observer ) {
      return new Multilink( this.getProperties( propertyNames ), observer, true );
    },

    /**
     * Removes the multilink from this PropertySet.
     * Same as calling detach() on the multilink
     * @param {Multilink} multilink
     */
    unmultilink: function( multilink ) {
      multilink.detach();
    },

    toString: function() {
      var text = 'PropertySet{';
      var propertySet = this;
      for ( var i = 0; i < this.keys.length; i++ ) {
        var key = this.keys[ i ];
        text = text + key + ':' + propertySet[ key ].toString();
        if ( i < this.keys.length - 1 ) {
          text = text + ',';
        }
      }
      return text + '}';
    },

    /**
     * Get a property by name, see https://github.com/phetsims/axon/issues/16
     * @param {string} propertyName the name of the property to get
     */
    property: function( propertyName ) {
      return this[ propertyName + SUFFIX ];
    }
  } );
} );
<|endoftext|>


<commit_before>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
$(document).ready(function () {
    /*
     * Checking pk value for login and logout actions
     * Also checks setting link availabiliy
     */
    if (!$('#pk').val()) {
        $('#login_place').css('visibility', 'visible');
        $('#login_place').css('display', '');
        $('#logout_place').css('visibility', 'hidden');
        $('#logout_place').css('display', 'none');

        $('#setting_link').css('visibility', 'hidden');
        $('#setting_link_divider').css('visibility', 'hidden');
        $('#setting_link').css('display', 'none');
        $('#setting_link_divider').css('display', 'none');

//        $('#setting_link_a').attr('href', '');

        $('#user_profile_link').css('visibility', 'hidden');
        $('#user_profile_link_divider').css('visibility', 'hidden');
        $('#user_profile_link').css('display', 'none');
        $('#user_profile_link_divider').css('display', 'none');

    } else {
        $('#login_place').css('visibility', 'hidden');
        $('#login_place').css('display', 'none');
        $('#logout_place').css('visibility', 'visible');
        $('#logout_place').css('display', '');

        /*
         * User name on toolbar
         */
        $.ajax({
            url: 'https://proxy.sanalfabrika.com/SlimProxyBoot.php',
            data: {
                url: 'pkGetUserShortInformation_infoUsers',
                language_code: $("#langCode").val(),
                pk: $('#pk').val()
            },
            type: 'GET',
            dataType: 'json',
            //data: 'rowIndex='+rowData.id,
            success: function (data, textStatus, jqXHR) {
                if (data.length !== 0) {
                    $('#user_name').empty();
                    $('#user_name_hover').empty();
                    $('#user_membership').empty();
                    $('#user_reg_date').empty();
                    if (data[0].user_picture) {
                        $('#user_image_ph').css('display', '');
                        $('#user_image_ph').css('visibility', 'visible');
                        $('#user_image_ph').attr('src', 'https://' + window.location.host + '/onyuz/standard/assets/img/sfClients/' + data[0].user_picture);
                        $('#user_name').append(data[0].name + ' ' + data[0].surname);
                        $('#icon_ph').css('display', 'none');
                        $('#icon_ph').css('visibility', 'hidden');
                        $('#user_image_ph_hover').css('display', '');
                        $('#user_image_ph_hover').css('visibility', 'visible');
                        $('#user_image_ph_hover').attr('src', 'https://' + window.location.host + '/onyuz/standard/assets/img/sfClients/' + data[0].user_picture);

                    } else {
                        $('#user_image_ph').css('display', 'none');
                        $('#user_image_ph').css('visibility', 'hidden');
                        $('#user_name').append("    " + data[0].name + ' ' + data[0].surname);
                        $('#user_image_ph_hover').css('display', 'none');
                        $('#user_image_ph_hover').css('visibility', 'hidden');
                        $('#icon_ph').css('display', '');
                        $('#icon_ph').css('visibility', 'visible');
                        $('#user_image_ph_hover').css('display', 'none');
                        $('#user_image_ph_hover').css('visibility', 'hidden');
                        $('#user_image_ph_hover').append('');

                    }
//                    $('#user_name').append("" + data[0].name + ' ' + data[0].surname);
                    $('#user_name_hover').append(data[0].name + ' ' + data[0].surname);
                    $('#user_membership').append(data[0].mem_type);
                    $('#user_reg_date').append(data[0].registration_date);
                    $('#user_profile_link').attr('unpk', data[0].unpk);
                    $('#user_prof_address').attr('href', 'https://' + window.location.host + '/ostim/sanalfabrika/userprofile/' + data[0].unpk);
                    $('#membership_tag').attr('src', 'https://' + window.location.host + '/onyuz/standard/assets/img/sfSystem/' + data[0].mem_logo)
                    $('#link_to_user_profile').attr('href', 'https://' + window.location.host + '/ostim/sanalfabrika/userprofile/' + data[0].unpk);

                } else {
                    console.error('"consultants" servis datasÃ„Â± boÃ…Å¸tur!!');
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                console.error('"pkGetUserShortInformation_infoUsers" servis hatasÃ„Â±->' + textStatus);
            }
        });

        /*
         * User companies list
         */
        $.ajax({
            url: 'https://proxy.sanalfabrika.com/SlimProxyBoot.php',
            data: {
                url: 'pkGetUserCompanyShortInformation_infoFirmProfile',
                language_code: $("#langCode").val(),
                pk: $('#pk').val()
            },
            type: 'GET',
            dataType: 'json',
            //data: 'rowIndex='+rowData.id,
            success: function (data, textStatus, jqXHR) {
                if (data.rows.length !== 0) {
                    $('#topCompaniesBar_div').empty();
                    for (var i = 0; i < data.rows.length; i++) {
                        var company_link = "https://" + window.location.host + "/" + $('#langCode').val() +
                                "/ostim/sanalfabrika/companyprofile/" + data.rows[i].network_name + "/" + data.rows[i].npk;

                        var appending =
                                "
" +
                                "" +
                                "" +
                                data.rows[i].network_name +
                                "
";

                        $('#topCompaniesBar_div').append(appending);

                        $('#no_sub_company').css('visibility', 'hidden');
                        $('#no_sub_company').css('display', 'none');
                    }
                } else {
                    $('#no_sub_company').css('visibility', 'visible');
                    $('#no_sub_company').css('display', '');
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                console.error('"pkGetUserShortInformation_infoUsers" servis hatasÃ„Â±->' + textStatus);
            }
        });

        $('#setting_link').css('visibility', 'visible');
        $('#setting_link_divider').css('visibility', 'visible');
        $('#setting_link').css('display', '');
        $('#setting_link_divider').css('display', '');

        $('#user_profile_link').css('visibility', 'visible');
        $('#user_profile_link_divider').css('visibility', 'visible');
        $('#user_profile_link').css('display', '');
        $('#user_profile_link_divider').css('display', '');

    }
});

<commit_msg>setting link<commit_after>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
$(document).ready(function () {
    /*
     * Checking pk value for login and logout actions
     * Also checks setting link availabiliy
     */
    if (!$('#pk').val()) {
        $('#login_place').css('visibility', 'visible');
        $('#login_place').css('display', '');
        $('#logout_place').css('visibility', 'hidden');
        $('#logout_place').css('display', 'none');

        $('#setting_link').css('visibility', 'hidden');
        $('#setting_link_divider').css('visibility', 'hidden');
        $('#setting_link').css('display', 'none');
        $('#setting_link_divider').css('display', 'none');

//        $('#setting_link_a').attr('href', '');

        $('#user_profile_link').css('visibility', 'hidden');
        $('#user_profile_link_divider').css('visibility', 'hidden');
        $('#user_profile_link').css('display', 'none');
        $('#user_profile_link_divider').css('display', 'none');

    } else {

        $('#login_place').css('visibility', 'hidden');
        $('#login_place').css('display', 'none');
        $('#logout_place').css('visibility', 'visible');
        $('#logout_place').css('display', '');

        /*
         * User name on toolbar
         */
        $.ajax({
            url: 'https://proxy.sanalfabrika.com/SlimProxyBoot.php',
            data: {
                url: 'pkGetUserShortInformation_infoUsers',
                language_code: $("#langCode").val(),
                pk: $('#pk').val()
            },
            type: 'GET',
            dataType: 'json',
            //data: 'rowIndex='+rowData.id,
            success: function (data, textStatus, jqXHR) {
                if (data.length !== 0) {
                    $('#user_name').empty();
                    $('#user_name_hover').empty();
                    $('#user_membership').empty();
                    $('#user_reg_date').empty();
                    if (data[0].user_picture) {
                        $('#user_image_ph').css('display', '');
                        $('#user_image_ph').css('visibility', 'visible');
                        $('#user_image_ph').attr('src', 'https://' + window.location.host + '/onyuz/standard/assets/img/sfClients/' + data[0].user_picture);
                        $('#user_name').append(data[0].name + ' ' + data[0].surname);
                        $('#icon_ph').css('display', 'none');
                        $('#icon_ph').css('visibility', 'hidden');
                        $('#user_image_ph_hover').css('display', '');
                        $('#user_image_ph_hover').css('visibility', 'visible');
                        $('#user_image_ph_hover').attr('src', 'https://' + window.location.host + '/onyuz/standard/assets/img/sfClients/' + data[0].user_picture);

                    } else {
                        $('#user_image_ph').css('display', 'none');
                        $('#user_image_ph').css('visibility', 'hidden');
                        $('#user_name').append("    " + data[0].name + ' ' + data[0].surname);
                        $('#user_image_ph_hover').css('display', 'none');
                        $('#user_image_ph_hover').css('visibility', 'hidden');
                        $('#icon_ph').css('display', '');
                        $('#icon_ph').css('visibility', 'visible');
                        $('#user_image_ph_hover').css('display', 'none');
                        $('#user_image_ph_hover').css('visibility', 'hidden');
                        $('#user_image_ph_hover').append('');

                    }
//                    $('#user_name').append("" + data[0].name + ' ' + data[0].surname);
                    $('#user_name_hover').append(data[0].name + ' ' + data[0].surname);
                    $('#user_membership').append(data[0].mem_type);
                    $('#user_reg_date').append(data[0].registration_date);
                    $('#user_profile_link').attr('unpk', data[0].unpk);
                    $('#user_prof_address').attr('href', 'https://' + window.location.host + '/ostim/sanalfabrika/userprofile/' + data[0].unpk);
                    $('#membership_tag').attr('src', 'https://' + window.location.host + '/onyuz/standard/assets/img/sfSystem/' + data[0].mem_logo)
                    $('#link_to_user_profile').attr('href', 'https://' + window.location.host + '/ostim/sanalfabrika/userprofile/' + data[0].unpk);

                } else {
                    console.error('"consultants" servis datasÃ„Â± boÃ…Å¸tur!!');
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                console.error('"pkGetUserShortInformation_infoUsers" servis hatasÃ„Â±->' + textStatus);
            }
        });

        /*
         * User companies list
         */
        $.ajax({
            url: 'https://proxy.sanalfabrika.com/SlimProxyBoot.php',
            data: {
                url: 'pkGetUserCompanyShortInformation_infoFirmProfile',
                language_code: $("#langCode").val(),
                pk: $('#pk').val()
            },
            type: 'GET',
            dataType: 'json',
            //data: 'rowIndex='+rowData.id,
            success: function (data, textStatus, jqXHR) {
                if (data.rows.length !== 0) {
                    $('#topCompaniesBar_div').empty();
                    for (var i = 0; i < data.rows.length; i++) {
                        var company_link = "https://" + window.location.host + "/" + $('#langCode').val() +
                                "/ostim/sanalfabrika/companyprofile/" + data.rows[i].network_name + "/" + data.rows[i].npk;
                        var company_setting_link = "https://" + window.location.host + "/" + $('#langCode').val() +
                                "/ostim/sanalfabrika/cpgeneralset/" + data.rows[i].network_name + "/" + data.rows[i].npk;
                        var appending =
                                "
" +
                                "" +
                                "" +
                                data.rows[i].network_name +
                                "
" +
                                "
" +
                                "
" +
                                "" +
                                "<icon style='float:left; padding-right:20px; font-size:20px;margin:10px ' class='fa fa-cog'></icon>" +
                                data.rows[i].network_name +
                                "
";

                        $('#topCompaniesBar_div').append(appending);

                        $('#no_sub_company').css('visibility', 'hidden');
                        $('#no_sub_company').css('display', 'none');
                    }
                } else {
                    $('#no_sub_company').css('visibility', 'visible');
                    $('#no_sub_company').css('display', '');
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                console.error('"pkGetUserCompanyShortInformation_infoFirmProfile" servis hatasÃ„Â±->' + textStatus);
            }
        });

        $('#setting_link').css('visibility', 'visible');
        $('#setting_link_divider').css('visibility', 'visible');
        $('#setting_link').css('display', '');
        $('#setting_link_divider').css('display', '');

        $('#user_profile_link').css('visibility', 'visible');
        $('#user_profile_link_divider').css('visibility', 'visible');
        $('#user_profile_link').css('display', '');
        $('#user_profile_link_divider').css('display', '');

    }
});

<|endoftext|>