<commit_before>import React from 'react'
import { Map, Marker, TileLayer, Circle } from 'react-leaflet'
import '../css/map.css'

const CENTER_RESET_DELAY = 6000

const getLatLng = (position) => [position.coords.latitude, position.coords.longitude]

class NavScreen extends React.Component{
  constructor(props) {
    super(props);
    const { position } = props;
    this.state = {
      center: getLatLng(position),
      followMarker: true
    }
    this.handleMoveend = this.handleMoveend.bind(this);
    this.returnToMarker = this.returnToMarker.bind(this);
    this.handleMove = this.handleMove.bind(this);
  }
  handleMove() {
    const { timeoutId } = this.state
    if (!timeoutId) return
    window.clearTimeout(timeoutId)
    this.setState({timeoutId: null})
  }
  handleMoveend(ev) {
    const center = ev.target.getCenter()
    const timeoutId = window.setTimeout(this.returnToMarker, CENTER_RESET_DELAY)
    this.setState({center, timeoutId, followMarker: false})
  }
  returnToMarker() {
    const { position } = this.props
    this.setState({center: getLatLng(position), followMarker: true})
  }
  render() {
    const { position, size } = this.props;
    const { center, followMarker } = this.state;
    if (!position) return null;
    const me = getLatLng(position);
    const mapCenter = (followMarker ? me : center)
    return (
      <Map
        center={center}
        zoom={20}
        onMove={this.handleMove}
        onMoveend={this.handleMoveend}
        useFlyTo={true}
        >
        <TileLayer
          url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
          attribution='© OpenStreetMap contributors'
        />
        <Marker position={me}/>
        <Circle center={me} radius={size}/>
      </Map>
    )
  }
}

export default NavScreen
<commit_msg>fixed the only error travis will ever find<commit_after>import React from 'react'
import { Map, Marker, TileLayer, Circle } from 'react-leaflet'
import '../css/map.css'

const CENTER_RESET_DELAY = 6000

const getLatLng = (position) => [position.coords.latitude, position.coords.longitude]

class NavScreen extends React.Component{
  constructor(props) {
    super(props);
    const { position } = props;
    this.state = {
      center: getLatLng(position),
      followMarker: true
    }
    this.handleMoveend = this.handleMoveend.bind(this);
    this.returnToMarker = this.returnToMarker.bind(this);
    this.handleMove = this.handleMove.bind(this);
  }
  handleMove() {
    const { timeoutId } = this.state
    if (!timeoutId) return
    window.clearTimeout(timeoutId)
    this.setState({timeoutId: null})
  }
  handleMoveend(ev) {
    const center = ev.target.getCenter()
    const timeoutId = window.setTimeout(this.returnToMarker, CENTER_RESET_DELAY)
    this.setState({center, timeoutId, followMarker: false})
  }
  returnToMarker() {
    const { position } = this.props
    this.setState({center: getLatLng(position), followMarker: true})
  }
  render() {
    const { position, size } = this.props;
    const { center, followMarker } = this.state;
    if (!position) return null;
    const me = getLatLng(position);
    const mapCenter = (followMarker ? me : center)
    return (
      <Map
        center={mapCenter}
        zoom={20}
        onMove={this.handleMove}
        onMoveend={this.handleMoveend}
        useFlyTo={true}
        >
        <TileLayer
          url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
          attribution='© OpenStreetMap contributors'
        />
        <Marker position={me}/>
        <Circle center={me} radius={size}/>
      </Map>
    )
  }
}

export default NavScreen
<|endoftext|>


<commit_before>import React, { PropTypes } from 'react';

const Paragraph = ({
  text,
  color = 'rgba(20, 20, 20, 0.9)',
  backgroundColor = 'rgba(200, 200, 200, 1.0)',
  lineHeight = '170%',
  height = '',
  textAlign = 'left',
  extraStyle = {},
}) => {
  const textStyle = {
    color,
    backgroundColor,
    lineHeight,
    height,
    textAlign,
    ...extraStyle,
  };
  return (

      {text}

  );
};

Paragraph.propTypes = {
  text: PropTypes.string.isRequired,
  color: PropTypes.string,
  backgroundColor: PropTypes.string,
  lineHeight: PropTypes.string,
  height: PropTypes.string,
  textAlign: PropTypes.string,
  extraStyle: PropTypes.object,
};

export default Paragraph;
<commit_msg>use flexgrid to make Paragraph responsive<commit_after>import React, { PropTypes } from 'react';
import { default as cn } from 'classnames';

const Paragraph = ({
  text,
  color = 'rgba(20, 20, 20, 0.9)',
  backgroundColor = 'rgba(200, 200, 200, 1.0)',
  lineHeight = '170%',
  height = '',
  textAlign = 'left',
  extraStyle = {},
}) => {
  const textStyle = {
    color,
    backgroundColor,
    lineHeight,
    height,
    textAlign,
    ...extraStyle,
  };
  const flexClasses = cn(
    'col-xs-12',
    'col-sm-offset-2',
    'col-sm-8',
    'col-md-offset-6',
    'col-md-6',
    'col-lg-offset-4',
    'col-lg-4',
  );
  return (

          {text}

  );
};

Paragraph.propTypes = {
  text: PropTypes.string.isRequired,
  color: PropTypes.string,
  backgroundColor: PropTypes.string,
  lineHeight: PropTypes.string,
  height: PropTypes.string,
  textAlign: PropTypes.string,
  extraStyle: PropTypes.object,
};

export default Paragraph;
<|endoftext|>


<commit_before>import React, { Component } from 'react'
import { connect } from 'react-redux'
import queryString from 'query-string'

import { Button, Icon, Popup, Input } from 'semantic-ui-react'

import { requestFollow, requestUnfollow } from '../actions/index.js'
import {
  userSelector, followingSelector, remoteFollowingSelector
} from '../selectors.js'
import { remoteUserPage } from '../pages.js'
import { isRemoteHost } from '../utils.js'

const mapStateToProps = (state, { user }) => {
  const currentUser = userSelector(state)
  const following = followingSelector(state)
  const remoteFollowing = remoteFollowingSelector(state)
  return {
    currentUser,
    user,
    following,
    remoteFollowing
  }
}

const actionCreators = {
  requestFollow, requestUnfollow
}

class FollowButton extends Component {
  constructor(props) {
    super(props)
    this.follow = this.follow.bind(this)
    this.unfollow = this.unfollow.bind(this)
    this.changeHost = this.changeHost.bind(this)
    this.state = {
      host: ''
    }
  }

  follow() {
    const { requestFollow, user } = this.props
    const host = user.host
    requestFollow(user.name, host)
  }

  unfollow() {
    const { requestUnfollow, user } = this.props
    const host = user.host
    requestUnfollow(user.name, host)
  }

  changeHost(event) {
    this.setState({
      host: event.target.value
    })
  }

  render() {
    const { currentUser, remoteFollowing, following, user, floated, large } = this.props
    const host = user.host
    if (!isRemoteHost(host) && currentUser.name == user.name) {
      return null
    }
    const isFollowing = isRemoteHost(host)
      ? remoteFollowing.some(([h, n]) => h == host && n == user.name)
      : following.includes(user.name)
    if (isFollowing) {
      return (
        <Popup
          trigger={large ? (
            <Button color='blue' floated={floated}>
              <Icon name='user' />
              Following
            </Button>
          ) : (
            <Button size='mini' icon='user' color='blue' floated={floated} />
          )}
          flowing
          hoverable
          on='click'
          hideOnScroll
        >
          <Button color='red' onClick={this.unfollow}><Icon name='remove user' />Unfollow</Button>
        </Popup>
      )
    } else if (currentUser == null || currentUser.name == null) {
      const path = remoteUserPage.path()
      const query = queryString.stringify({host: location.host, name: user.name})
      const url = `https://${this.state.host}${path}?${query}`
      return (
        <Popup
          trigger={(
            <Button size='mini' floated={floated}>
              <Icon name='add user' />
              Remote Follow
            </Button>
          )}
          flowing
          hoverable
          on='click'
          hideOnScroll
        >
          <Input size='mini' value={this.state.host}
            placeholder='Host' onChange={this.changeHost} />
          {this.state.host.length != 0 ? (
            <Button as='a' href={url}>
              <Icon name='external' />
              Open
            </Button>
          ) : null}
        </Popup>
      )
    } else {
      if (large) {
        return (
          <Button onClick={this.follow} floated={floated}>
            <Icon name='add user' color='blue' />
            Follow
          </Button>
        )
      } else {
        return (
          <Button icon size='mini' onClick={this.follow} floated={floated}>
            <Icon name='add user' color='blue' />
          </Button>
        )
      }
    }
  }
}

FollowButton.propTypes = {
  user: React.PropTypes.object.isRequired,
  floated: React.PropTypes.oneOf(['left', 'right']),
  large: React.PropTypes.bool
}

export default connect(mapStateToProps, actionCreators)(FollowButton)
<commit_msg>Fix remote follow button to work properly with remote users<commit_after>import React, { Component } from 'react'
import { connect } from 'react-redux'
import queryString from 'query-string'

import { Button, Icon, Popup, Input } from 'semantic-ui-react'

import { requestFollow, requestUnfollow } from '../actions/index.js'
import {
  userSelector, followingSelector, remoteFollowingSelector
} from '../selectors.js'
import { remoteUserPage } from '../pages.js'
import { isRemoteHost } from '../utils.js'

const mapStateToProps = (state, { user }) => {
  const currentUser = userSelector(state)
  const following = followingSelector(state)
  const remoteFollowing = remoteFollowingSelector(state)
  return {
    currentUser,
    user,
    following,
    remoteFollowing
  }
}

const actionCreators = {
  requestFollow, requestUnfollow
}

class FollowButton extends Component {
  constructor(props) {
    super(props)
    this.follow = this.follow.bind(this)
    this.unfollow = this.unfollow.bind(this)
    this.changeHost = this.changeHost.bind(this)
    this.state = {
      host: ''
    }
  }

  follow() {
    const { requestFollow, user } = this.props
    const host = user.host
    requestFollow(user.name, host)
  }

  unfollow() {
    const { requestUnfollow, user } = this.props
    const host = user.host
    requestUnfollow(user.name, host)
  }

  changeHost(event) {
    this.setState({
      host: event.target.value
    })
  }

  render() {
    const { currentUser, remoteFollowing, following, user, floated, large } = this.props
    const host = user.host
    if (!isRemoteHost(host) && currentUser.name == user.name) {
      return null
    }
    const isFollowing = isRemoteHost(host)
      ? remoteFollowing.some(([h, n]) => h == host && n == user.name)
      : following.includes(user.name)
    if (isFollowing) {
      return (
        <Popup
          trigger={large ? (
            <Button color='blue' floated={floated}>
              <Icon name='user' />
              Following
            </Button>
          ) : (
            <Button size='mini' icon='user' color='blue' floated={floated} />
          )}
          flowing
          hoverable
          on='click'
          hideOnScroll
        >
          <Button color='red' onClick={this.unfollow}><Icon name='remove user' />Unfollow</Button>
        </Popup>
      )
    } else if (currentUser == null || currentUser.name == null) {
      const path = remoteUserPage.path()
      const query = queryString.stringify({host: user.host || location.host, name: user.name})
      const url = `https://${this.state.host}${path}?${query}`
      return (
        <Popup
          trigger={(
            <Button size='mini' floated={floated}>
              <Icon name='add user' />
              Remote Follow
            </Button>
          )}
          flowing
          hoverable
          on='click'
          hideOnScroll
        >
          <Input size='mini' value={this.state.host}
            placeholder='Host' onChange={this.changeHost} />
          {this.state.host.length != 0 ? (
            <Button as='a' href={url}>
              <Icon name='external' />
              Open
            </Button>
          ) : null}
        </Popup>
      )
    } else {
      if (large) {
        return (
          <Button onClick={this.follow} floated={floated}>
            <Icon name='add user' color='blue' />
            Follow
          </Button>
        )
      } else {
        return (
          <Button icon size='mini' onClick={this.follow} floated={floated}>
            <Icon name='add user' color='blue' />
          </Button>
        )
      }
    }
  }
}

FollowButton.propTypes = {
  user: React.PropTypes.object.isRequired,
  floated: React.PropTypes.oneOf(['left', 'right']),
  large: React.PropTypes.bool
}

export default connect(mapStateToProps, actionCreators)(FollowButton)
<|endoftext|>


<commit_before>/*
 * Copyright (c) 2010 Kevin Decker (http://www.incaseofstairs.com/)
 * See LICENSE for license information
 */
$(document).ready(function() {
    var pathToImage = $("#pathToImage"),
        editorEl = $("#editorEl"),
        imageEl = $("#imageEl"),
        dividers = $(".divider"),
        sliders = $(".slider"),
        cssEl = $("#cssEl"),
        repeat = $(".repeat"),

        validImage = false,
        naturalSize = {},

        state = {
            src: "",

            linkBorder: true,
            borderWidth: [0, 0, 0, 0],
            imageOffset: [0, 0, 0, 0],

            setRepat: false,
            repeat: ["stretch", "stretch"],

            scaleFactor: 3
        };

    var sliderMap = {
        imageTop: { array: "imageOffset", index: 0 },
        imageRight: { array: "imageOffset", index: 1 },
        imageBottom: { array: "imageOffset", index: 2 },
        imageLeft: { array: "imageOffset", index: 3 },

        borderTop: { array: "borderWidth", index: 0 },
        borderRight: { array: "borderWidth", index: 1 },
        borderBottom: { array: "borderWidth", index: 2 },
        borderLeft: { array: "borderWidth", index: 3 },
    }, dividerMap = {
        dividerTop: {
            setValue: function(el) { state.imageOffset[0] = calcPixels($(el).position().top) },
            updatePos: function(el) { $(el).css("top", state.imageOffset[0]*state.scaleFactor); }
        },
        dividerRight: {
            setValue: function(el) { state.imageOffset[1] = calcPixels(editorEl.innerWidth() - $(el).position().left + 2) },
            updatePos: function(el) { $(el).css("left", (editorEl.innerWidth() - 2 - state.imageOffset[1]*state.scaleFactor)); }
        },
        dividerBottom: {
            setValue: function(el) { state.imageOffset[2] = calcPixels(editorEl.innerHeight() - $(el).position().top + 2) },
            updatePos: function(el) { $(el).css("top", (editorEl.innerHeight() - 2 - state.imageOffset[2]*state.scaleFactor)); }
        },
        dividerLeft: {
            setValue: function(el) { state.imageOffset[3] = calcPixels($(el).position().left) },
            updatePos: function(el) { $(el).css("left", state.imageOffset[3]*state.scaleFactor); }
        },
    }, repeatMap = {
        repeatVertical: { index: 1 },
        repeatHorizontal: { index: 0 },
    };

    function calcPixels(pos) {
        return (pos / state.scaleFactor) | 0;
    }
    function updateSliders() {
        $(".slider").each(function(index, el) {
            var map = sliderMap[el.id];
            $(el).slider("option", "value", state[map.array][map.index]);
        });
    }
    function updateDividers() {
        dividers.each(function(index, el) {
            dividerMap[el.id].updatePos(el);
        });
    }
    function updateRepeat() {
        repeat.each(function(index, el) {
            var map = repeatMap[el.id];
            $(el).val(state.repeat[map.index]);
        })
    }
    function updateHash() {
        HistoryHandler.store(JSON.stringify(state));
    }
    function joinValues(values, join) {
        var ret = [];
        if (values[3] && values[3] !== values[1]) {
            ret.unshift(values[3]);
        }
        if (ret.length || (values[2] && values[2] !== values[0])) {
            ret.unshift(values[2]);
        }
        if (ret.length || (values[1] && values[1] !== values[0])) {
            ret.unshift(values[1]);
        }
        ret.unshift(values[0]);
        return ret.join(join || " ");
    }
    function updateCSS() {
        var borderImage = "", borderWidthStr = "", style = "",
            repeatStr = state.setRepeat ? " " + joinValues(state.repeat) : "";

        if (validImage) {
            var img = "url(" + ImageList.getDisplayName() + ")",
                imageOffset = state.imageOffset,
                borderWidth = state.linkBorder ? state.imageOffset : state.borderWidth;

            borderImage = img + " " + joinValues(imageOffset);
            borderWidthStr = joinValues(borderWidth, "px ") + "px";
            style = "border-width: " + borderWidthStr + ";\n"
                + "-moz-border-image: " + borderImage + repeatStr + ";\n"
                + "-webkit-border-image: " + borderImage + repeatStr + ";\n"
                + "border-image: " + borderImage + repeatStr + ";\n";

            borderImage = "url(" + ImageList.getSrc() + ") " + joinValues(imageOffset);
        }

        $("#cssEl").html(style)
                .css("border-width", borderWidthStr)
                .css("-moz-border-image", borderImage + repeatStr)
                .css("-webkit-border-image", borderImage + repeatStr)
                .css("border-image", borderImage + repeatStr);
    }

    sliders.slider({
        max: 100,
        slide: function(event, ui) {
            var map = sliderMap[event.target.id];
            state[map.array][map.index] = ui.value;

            updateCSS();
            updateDividers();
        },
        stop: function() {
            updateHash();
        }
    });
    dividers.draggable({
        containment: "parent",
        drag: function(event, ui) {
            dividerMap[event.target.id].setValue(event.target);
            updateCSS();
            updateSliders();
        },
        stop: function() {
            updateHash();
        }
    });
    dividers.filter(":even").draggable("option", "axis", "y");
    dividers.filter(":odd").draggable("option", "axis", "x");

    repeat.change(function() {
        var map = repeatMap[this.id];
        state.repeat[map.index] = $(this).val();
        updateCSS();
        updateHash();
    });

    ImageList.setEl(imageEl[0]);
    imageEl.load(function() {
        var img = this,
            natWidth = img.naturalWidth || img.width,
            natHeight = img.naturalHeight || img.height,
            width = natWidth*state.scaleFactor,
            height = natHeight*state.scaleFactor;

        // Ensure that the initial scale for the image is always smaller that the size of the screen
        if (width > window.innerWidth || height > window.innerHeight) {
            state.scaleFactor = Math.min(window.innerWidth/width, window.innerHeight/height);
            width = natWidth*state.scaleFactor;
            height = natHeight*state.scaleFactor;
        }

        naturalSize = {
            width: natWidth,
            height: natHeight
        };

        // Correct for any HTTP escaping issues in the input
        state.src = ImageList.getCurEntry();

        editorEl.width(width).height(height);
        editorEl.show();

        $(".errorMsg").hide();
        validImage = true;

        sliders.filter(":odd").slider("option", "max", natWidth);
        sliders.filter(":even").slider("option", "max", natHeight);
        updateSliders();
        updateDividers();
        updateCSS();
        updateHash();
    });

    function errorHandler(code) {
        var msg;
        if (code === FileError.NOT_FOUND_ERR) {
            msg = "Unable to find image. This may be due to an incorrect path name or a local file that has not been properly loaded.";
        } else if (code) {
            msg = "Failed to load image. Error code: " + code;
        } else {
            msg = "Unknown error occured loading image " + ImageList.getDisplayName();
        }

        // Only show the message if the user as attempted to load an image
        if (ImageList.getCurEntry()) {
            $(".errorMsg").html("*** " + msg).show();
        }

        editorEl.hide();
        validImage = false;

        updateCSS();
    }
    imageEl.error(function() { errorHandler(); });
    pathToImage.change(function(event) {
        // Clear the frame size so Opera can scale the editor down if the new image is smaller than the last
        editorEl.width("auto").height("auto");
        ImageList.load(pathToImage.val(), errorHandler);
    });

    function setFlag(name, value) {
        return function() {
            state[name] = value;
            updateCSS();
            updateHash();
        };
    }
    $("#borderOptionsExpander").expander("#borderOptions", setFlag("linkBorder", false), setFlag("linkBorder", true));
    $("#repeatOptionsExpander").expander("#repeatOptions", setFlag("setRepeat", true), setFlag("setRepeat", false));

    editorEl.resizable({
        reverseXAxis: true,
        handles: "s, w, sw",
        aspectRatio: true,
        resize: function() {
            state.scaleFactor = editorEl.innerWidth() / naturalSize.width;

            updateSliders();
            updateDividers();
            updateCSS();
        },
        stop: function() {
            updateHash();
        }
    });

    if (ImageList.isLocalSupported()) {
        $("body").bind("dragenter dragover", function(event) {
            // We have to cancel these events or we will not recieve the drop event
            event.preventDefault();
            event.stopPropagation();
        });
        $("body").bind("drop", function(event) {
            event.preventDefault();
            event.stopPropagation();
            var dataTransfer = event.originalEvent.dataTransfer,
                file = dataTransfer.files[0];

            ImageList.load(file, errorHandler);
        });
        $("#localImage").bind("change", function(event) {
            var file = this.files[0];

            ImageList.load(file, errorHandler);
        });
    } else {
        $("body").addClass("no-local");
    }

    HistoryHandler.init(function(hash) {
        var prevScale = state.scaleFactor;

        if (hash) {
            $.extend(state, JSON.parse(hash));
        }
        if ($("#borderOptions").is(":visible") === state.linkBorder) {
            $("#borderOptionsExpander").click();
        }
        if ($("#repeatOptions").is(":visible") !== state.setRepeat) {
            $("#repeatOptionsExpander").click();
        }

        if (ImageList.getCurEntry() !== state.src) {
            // The other values will update when the image loads
            ImageList.load(state.src, errorHandler);
        } else if (prevScale !== state.scaleFactor) {
            imageEl.load();
        } else {
            updateSliders();
            updateDividers();
            updateCSS();
        }

        updateRepeat();
    });
});
<commit_msg>Update the image path text on load<commit_after>/*
 * Copyright (c) 2010 Kevin Decker (http://www.incaseofstairs.com/)
 * See LICENSE for license information
 */
$(document).ready(function() {
    var pathToImage = $("#pathToImage"),
        editorEl = $("#editorEl"),
        imageEl = $("#imageEl"),
        dividers = $(".divider"),
        sliders = $(".slider"),
        cssEl = $("#cssEl"),
        repeat = $(".repeat"),

        validImage = false,
        naturalSize = {},

        state = {
            src: "",

            linkBorder: true,
            borderWidth: [0, 0, 0, 0],
            imageOffset: [0, 0, 0, 0],

            setRepat: false,
            repeat: ["stretch", "stretch"],

            scaleFactor: 3
        };

    var sliderMap = {
        imageTop: { array: "imageOffset", index: 0 },
        imageRight: { array: "imageOffset", index: 1 },
        imageBottom: { array: "imageOffset", index: 2 },
        imageLeft: { array: "imageOffset", index: 3 },

        borderTop: { array: "borderWidth", index: 0 },
        borderRight: { array: "borderWidth", index: 1 },
        borderBottom: { array: "borderWidth", index: 2 },
        borderLeft: { array: "borderWidth", index: 3 },
    }, dividerMap = {
        dividerTop: {
            setValue: function(el) { state.imageOffset[0] = calcPixels($(el).position().top) },
            updatePos: function(el) { $(el).css("top", state.imageOffset[0]*state.scaleFactor); }
        },
        dividerRight: {
            setValue: function(el) { state.imageOffset[1] = calcPixels(editorEl.innerWidth() - $(el).position().left + 2) },
            updatePos: function(el) { $(el).css("left", (editorEl.innerWidth() - 2 - state.imageOffset[1]*state.scaleFactor)); }
        },
        dividerBottom: {
            setValue: function(el) { state.imageOffset[2] = calcPixels(editorEl.innerHeight() - $(el).position().top + 2) },
            updatePos: function(el) { $(el).css("top", (editorEl.innerHeight() - 2 - state.imageOffset[2]*state.scaleFactor)); }
        },
        dividerLeft: {
            setValue: function(el) { state.imageOffset[3] = calcPixels($(el).position().left) },
            updatePos: function(el) { $(el).css("left", state.imageOffset[3]*state.scaleFactor); }
        },
    }, repeatMap = {
        repeatVertical: { index: 1 },
        repeatHorizontal: { index: 0 },
    };

    function calcPixels(pos) {
        return (pos / state.scaleFactor) | 0;
    }
    function updateSliders() {
        $(".slider").each(function(index, el) {
            var map = sliderMap[el.id];
            $(el).slider("option", "value", state[map.array][map.index]);
        });
    }
    function updateDividers() {
        dividers.each(function(index, el) {
            dividerMap[el.id].updatePos(el);
        });
    }
    function updateRepeat() {
        repeat.each(function(index, el) {
            var map = repeatMap[el.id];
            $(el).val(state.repeat[map.index]);
        })
    }
    function updateHash() {
        HistoryHandler.store(JSON.stringify(state));
    }
    function joinValues(values, join) {
        var ret = [];
        if (values[3] && values[3] !== values[1]) {
            ret.unshift(values[3]);
        }
        if (ret.length || (values[2] && values[2] !== values[0])) {
            ret.unshift(values[2]);
        }
        if (ret.length || (values[1] && values[1] !== values[0])) {
            ret.unshift(values[1]);
        }
        ret.unshift(values[0]);
        return ret.join(join || " ");
    }
    function updateCSS() {
        var borderImage = "", borderWidthStr = "", style = "",
            repeatStr = state.setRepeat ? " " + joinValues(state.repeat) : "";

        if (validImage) {
            var img = "url(" + ImageList.getDisplayName() + ")",
                imageOffset = state.imageOffset,
                borderWidth = state.linkBorder ? state.imageOffset : state.borderWidth;

            borderImage = img + " " + joinValues(imageOffset);
            borderWidthStr = joinValues(borderWidth, "px ") + "px";
            style = "border-width: " + borderWidthStr + ";\n"
                + "-moz-border-image: " + borderImage + repeatStr + ";\n"
                + "-webkit-border-image: " + borderImage + repeatStr + ";\n"
                + "border-image: " + borderImage + repeatStr + ";\n";

            borderImage = "url(" + ImageList.getSrc() + ") " + joinValues(imageOffset);
        }

        $("#cssEl").html(style)
                .css("border-width", borderWidthStr)
                .css("-moz-border-image", borderImage + repeatStr)
                .css("-webkit-border-image", borderImage + repeatStr)
                .css("border-image", borderImage + repeatStr);
    }

    sliders.slider({
        max: 100,
        slide: function(event, ui) {
            var map = sliderMap[event.target.id];
            state[map.array][map.index] = ui.value;

            updateCSS();
            updateDividers();
        },
        stop: function() {
            updateHash();
        }
    });
    dividers.draggable({
        containment: "parent",
        drag: function(event, ui) {
            dividerMap[event.target.id].setValue(event.target);
            updateCSS();
            updateSliders();
        },
        stop: function() {
            updateHash();
        }
    });
    dividers.filter(":even").draggable("option", "axis", "y");
    dividers.filter(":odd").draggable("option", "axis", "x");

    repeat.change(function() {
        var map = repeatMap[this.id];
        state.repeat[map.index] = $(this).val();
        updateCSS();
        updateHash();
    });

    ImageList.setEl(imageEl[0]);
    imageEl.load(function() {
        var img = this,
            natWidth = img.naturalWidth || img.width,
            natHeight = img.naturalHeight || img.height,
            width = natWidth*state.scaleFactor,
            height = natHeight*state.scaleFactor;

        // Ensure that the initial scale for the image is always smaller that the size of the screen
        if (width > window.innerWidth || height > window.innerHeight) {
            state.scaleFactor = Math.min(window.innerWidth/width, window.innerHeight/height);
            width = natWidth*state.scaleFactor;
            height = natHeight*state.scaleFactor;
        }

        naturalSize = {
            width: natWidth,
            height: natHeight
        };

        // Correct for any HTTP escaping issues in the input
        state.src = ImageList.getCurEntry();
        pathToImage.val(ImageList.getDisplayName());

        editorEl.width(width).height(height);
        editorEl.show();

        $(".errorMsg").hide();
        validImage = true;

        sliders.filter(":odd").slider("option", "max", natWidth);
        sliders.filter(":even").slider("option", "max", natHeight);
        updateSliders();
        updateDividers();
        updateCSS();
        updateHash();
    });

    function errorHandler(code) {
        var msg;
        if (code === FileError.NOT_FOUND_ERR) {
            msg = "Unable to find image. This may be due to an incorrect path name or a local file that has not been properly loaded.";
        } else if (code) {
            msg = "Failed to load image. Error code: " + code;
        } else {
            msg = "Unknown error occured loading image " + ImageList.getDisplayName();
        }

        // Only show the message if the user as attempted to load an image
        if (ImageList.getCurEntry()) {
            $(".errorMsg").html("*** " + msg).show();
        }

        editorEl.hide();
        validImage = false;

        updateCSS();
    }
    imageEl.error(function() { errorHandler(); });
    pathToImage.change(function(event) {
        // Clear the frame size so Opera can scale the editor down if the new image is smaller than the last
        editorEl.width("auto").height("auto");
        ImageList.load(pathToImage.val(), errorHandler);
    });

    function setFlag(name, value) {
        return function() {
            state[name] = value;
            updateCSS();
            updateHash();
        };
    }
    $("#borderOptionsExpander").expander("#borderOptions", setFlag("linkBorder", false), setFlag("linkBorder", true));
    $("#repeatOptionsExpander").expander("#repeatOptions", setFlag("setRepeat", true), setFlag("setRepeat", false));

    editorEl.resizable({
        reverseXAxis: true,
        handles: "s, w, sw",
        aspectRatio: true,
        resize: function() {
            state.scaleFactor = editorEl.innerWidth() / naturalSize.width;

            updateSliders();
            updateDividers();
            updateCSS();
        },
        stop: function() {
            updateHash();
        }
    });

    if (ImageList.isLocalSupported()) {
        $("body").bind("dragenter dragover", function(event) {
            // We have to cancel these events or we will not recieve the drop event
            event.preventDefault();
            event.stopPropagation();
        });
        $("body").bind("drop", function(event) {
            event.preventDefault();
            event.stopPropagation();
            var dataTransfer = event.originalEvent.dataTransfer,
                file = dataTransfer.files[0];

            ImageList.load(file, errorHandler);
        });
        $("#localImage").bind("change", function(event) {
            var file = this.files[0];

            ImageList.load(file, errorHandler);
        });
    } else {
        $("body").addClass("no-local");
    }

    HistoryHandler.init(function(hash) {
        var prevScale = state.scaleFactor;

        if (hash) {
            $.extend(state, JSON.parse(hash));
        }
        if ($("#borderOptions").is(":visible") === state.linkBorder) {
            $("#borderOptionsExpander").click();
        }
        if ($("#repeatOptions").is(":visible") !== state.setRepeat) {
            $("#repeatOptionsExpander").click();
        }

        if (ImageList.getCurEntry() !== state.src) {
            // The other values will update when the image loads
            ImageList.load(state.src, errorHandler);
        } else if (prevScale !== state.scaleFactor) {
            imageEl.load();
        } else {
            updateSliders();
            updateDividers();
            updateCSS();
        }

        updateRepeat();
    });
});
<|endoftext|>


<commit_before>import { expect } from 'chai';

import '../../browser';

import React from 'react';
import { shallow } from 'enzyme';

import Header from '../../../src/components/header';

import AppLogo from '../../../src/containers/app-logo';
import Navbar from '../../../src/containers/nav-bar';

describe('<Header/>', () => {
    const location = { pathname: 'foo-pathname' };
    const wrapper = shallow(<Header location={location} />);

    it('should render a navbar', () => expect(wrapper.find('.navbar')).to.have.length(1));

    const inner = wrapper.find('.navbar > .inner');
    it('should render an inner div', () => expect(inner).to.have.length(1));

    it('should render <AppLogo />', () => expect(inner.find(AppLogo)).to.have.length(1));

    const navbar = inner.find(Navbar);
    it('should render <Navbar />', () => expect(navbar).to.have.length(1));
    it('should pass pathname as a prop to the Navbar', () => {
        expect(navbar.props()).to.deep.equal({
            pathname: 'foo-pathname'
        });
    });
});

<commit_msg>Updated <Header /> spec<commit_after>/* eslint-disable newline-per-chained-call */
import { expect } from 'chai';

import '../../browser';

import React from 'react';
import { shallow } from 'enzyme';

import Header from '../../../src/components/header';

import AppLogo from '../../../src/containers/app-logo';
import Navbar from '../../../src/containers/nav-bar';

describe('<Header/>', () => {
    const props = {
        location: {
            pathname: 'foo-pathname'
        }
    };

    it('should render its basic structure', () => {
        const wrapper = shallow(<Header {...props} />);

        expect(wrapper.is('div.navbar')).to.equal(true);
        expect(wrapper.children()).to.have.length(1);
        expect(wrapper.childAt(0).is('div.inner')).to.equal(true);
        expect(wrapper.childAt(0).children()).to.have.length(2);
    });

    it('should render an <AppLogo />', () => {
        const wrapper = shallow(<Header {...props} />);

        expect(wrapper.childAt(0).childAt(0).is(AppLogo)).to.equal(true);
    });

    it('should render an <Navbar />', () => {
        const wrapper = shallow(<Header {...props} />);

        expect(wrapper.childAt(0).childAt(1).is(Navbar)).to.equal(true);
        expect(wrapper.childAt(0).childAt(1).props()).to.have.property('pathname', 'foo-pathname');
    });
});

<|endoftext|>


<commit_before>Homes = new Mongo.Collection('homes');

var HomesSchema = new SimpleSchema({
  name:{
    type:String,
    label: 'Home Name',
  },
  groupId: {
    type: String,
    label: 'Group',
    autoform: {
      options: function() {
        return _.map(Groups.find().fetch(), function(group) {
          return {
            label: group.name,
            value: group._id
          };
        });
      }
    }
  }
});

Homes.attachSchema(HomesSchema);
<commit_msg>Added groupName helper.<commit_after>Homes = new Mongo.Collection('homes');

var HomesSchema = new SimpleSchema({
  name:{
    type:String,
    label: 'Home Name',
  },
  groupId: {
    type: String,
    label: 'Group',
    autoform: {
      options: function() {
        return _.map(Groups.find().fetch(), function(group) {
          return {
            label: group.name,
            value: group._id
          };
        });
      }
    }
  }
});

Homes.attachSchema(HomesSchema);

Homes.helpers({
  groupName: function () {
    // Get the Group ID;
    var groupId = this.groupId;

    // Get Group from Groups collection, by ID(s)
    var group = Groups.findOne(groupId);

    // Return the Group name
    return group.name;
  }
});
<|endoftext|>


<commit_before>import DomMock from '../../helpers/dom-mock';
import jsdom from 'mocha-jsdom';
import expect from 'expect';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import Rating from '../../../portal/src/components/Form/Rating';
import Question from '../../../portal/src/components/Form/Question';

DomMock('');

describe('[Portal] Testing Form Rating Component', () => {
    jsdom({ skipWindowCheck: true });

    const props = {
        data: {
            id: '97AN2A1A0FBNAL',
            type: 'rating',
            label: 'Question title',
            data: [
                { value: '1A0F97AN2ABAGR', label: 'Very dissatisfied' },
                { value: '1A0F97AN2A3FEF', label: 'Dissatisfied' },
                { value: '1A0F97AN2A6E3V', label: 'Satisfied' },
                { value: '1A0F97AN25H69O', label: 'Very satisfied' }
            ],
            input: 'Tell me the reason.',
            required: false
        },
        onClick: () => {}
    };
    const content = TestUtils.renderIntoDocument(
        <Rating {...props} />
    );

    it('rating: question type', () => {
        const que = TestUtils.scryRenderedComponentsWithType(content, Question);
        expect(que.length).toEqual(1);
        expect(que[0].props.text).toEqual(props.data.label);
    });

    it('rating: option numbers', () => {
        const opt = TestUtils.scryRenderedDOMComponentsWithClass(content, 'ut-rating');
        expect(opt.length).toEqual(4);
    });

    it('rating: option label numbers', () => {
        const opt = TestUtils.scryRenderedDOMComponentsWithClass(content, 'ut-label');
        expect(opt.length).toEqual(2);
    });

    it('rating: question input', () => {
        const input = TestUtils.findRenderedDOMComponentWithClass(content, 'ut-input');
        expect(input.getAttribute('placeholder')).toEqual(props.data.input);
    });
});
<commit_msg>Remove useless rating label test<commit_after>import DomMock from '../../helpers/dom-mock';
import jsdom from 'mocha-jsdom';
import expect from 'expect';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import Rating from '../../../portal/src/components/Form/Rating';
import Question from '../../../portal/src/components/Form/Question';

DomMock('');

describe('[Portal] Testing Form Rating Component', () => {
    jsdom({ skipWindowCheck: true });

    const props = {
        data: {
            id: '97AN2A1A0FBNAL',
            type: 'rating',
            label: 'Question title',
            data: [
                { value: '1A0F97AN2ABAGR', label: 'Very dissatisfied' },
                { value: '1A0F97AN2A3FEF', label: 'Dissatisfied' },
                { value: '1A0F97AN2A6E3V', label: 'Satisfied' },
                { value: '1A0F97AN25H69O', label: 'Very satisfied' }
            ],
            input: 'Tell me the reason.',
            required: false
        },
        onClick: () => {}
    };
    const content = TestUtils.renderIntoDocument(
        <Rating {...props} />
    );

    it('rating: question type', () => {
        const que = TestUtils.scryRenderedComponentsWithType(content, Question);
        expect(que.length).toEqual(1);
        expect(que[0].props.text).toEqual(props.data.label);
    });

    it('rating: option numbers', () => {
        const opt = TestUtils.scryRenderedDOMComponentsWithClass(content, 'ut-rating');
        expect(opt.length).toEqual(4);
    });

    it('rating: question input', () => {
        const input = TestUtils.findRenderedDOMComponentWithClass(content, 'ut-input');
        expect(input.getAttribute('placeholder')).toEqual(props.data.input);
    });
});
<|endoftext|>


<commit_before>/* healthIconDirective
 * directive for displaying health of a service/instance
 * in icon form with helpful popover details
 */
(function() {
    'use strict';

    angular.module('healthIcon', [])
    .directive("healthIcon", ["hcStatus",
    function(hcStatus){
        let {OK, FAILED, NOT_RUNNING, UNKNOWN} = hcStatus;

        return {
            restrict: "E",
            scope: {
                // status object generated by serviceHealth
                status: "="
            },
            template: '

',
            link: function($scope, element, attrs){
                var STATUS_STYLES = {
                    [FAILED]: "glyphicon glyphicon-exclamation bad",
                    [OK]: "glyphicon glyphicon-ok good",
                    [UNKNOWN]: "glyphicon glyphicon-question unknown",
                    [NOT_RUNNING]: "glyphicon glyphicon-minus disabled"
                };

                // cache some DOM elements
                var $el = $(element),
                    $badge = $el.find(".healthIconBadge"),
                    lastStatus;

                function update(){
                    var statusObj, popoverHTML,
                        hideHealthChecks,
                        placement = "right",
                        popoverObj, template;

                    statusObj = $scope.status;

                    if(!statusObj){
                        // TODO - re-implement?
                        //statusObj = new Status(id, "", 1);
                        //statusObj.statusRollup.incNotRunning();
                        //statusObj.evaluateStatus();
                        return;
                    }

                    // determine if we should hide healthchecks
                    hideHealthChecks = statusObj.statusRollup.allOK() ||
                        statusObj.statusRollup.allNotRunning() ||
                        statusObj.desiredState  === 0;

                    // if service should be up and there is more than 1 instance, show number of instances
                    if(statusObj.desiredState === 1 && statusObj.statusRollup.total > 1){
                        $el.addClass("wide");
                        $badge.text(statusObj.statusRollup.ok +"/"+ statusObj.statusRollup.total).show();

                    // else, hide the badge
                    } else {
                        $el.removeClass("wide");
                        $badge.hide();
                    }

                    // setup popover

                    // if this $el is inside a .serviceTitle, make the popover point down
                    if($el.parent().hasClass("serviceTitle")){
                        placement = "bottom";
                    }

                    // if this statusObj has children, we wanna show
                    // them in the healtcheck tooltip, so generate
                    // some yummy html
                    if(statusObj.children.length){
                        popoverHTML = [];

                        var isHealthCheckStatus = function(status){
                           return !status.id;
                        };

                        // if this status's children are healthchecks,
                        // no need for instance rows, go straight to healthcheck rows
                        if(statusObj.children.length && isHealthCheckStatus(statusObj.children[0])){
                            // if these are JUST healthchecks, then don't allow them
                            // to be hidden. this ensures that healthchecks show up for
                            // running instances.
                            hideHealthChecks = false;
                            // don't show count badge for healthchecks either
                            $badge.hide();
                            $el.removeClass("wide");

                            statusObj.children.forEach(function(hc){
                                popoverHTML.push(bindHealthCheckRowTemplate(hc));
                            });

                        // else these are instances, so create instance rows
                        // AND healthcheck rows
                        } else {
                            statusObj.children.forEach(function(instanceStatus){
                                // if this is becoming too long, stop adding rows
                                if(popoverHTML.length >= 15){
                                    // add an overflow indicator if not already there
                                    if(popoverHTML[popoverHTML.length-1] !== "..."){
                                        popoverHTML.push("...");
                                    }
                                    return;
                                }

                                // only create an instance row for this instance if
                                // it's in a bad or unknown state
                                if(instanceStatus.status === FAILED ||
                                      instanceStatus.status === UNKNOWN){
                                    popoverHTML.push("
");
                                    popoverHTML.push("
"+ instanceStatus.name +"
");
                                    instanceStatus.children.forEach(function(hc){
                                        popoverHTML.push(bindHealthCheckRowTemplate(hc));
                                    });
                                    popoverHTML.push("
");
                                }
                            });
                        }

                        popoverHTML = popoverHTML.join("");
                    }

                    // choose a popover template which is just a title,
                    // or a title and content
                    template = hideHealthChecks || !popoverHTML ?
                        '

' :
                        '

';

                    // NOTE: directly accessing the bootstrap popover
                    // data object here.
                    popoverObj = $el.data("bs.popover");

                    // if popover element already exists, update it
                    if(popoverObj){
                        // update title, content, and template
                        popoverObj.options.title = statusObj.description;
                        popoverObj.options.content = popoverHTML;
                        popoverObj.options.template = template;

                        // if the tooltip already exists, change the contents
                        // to the new template
                        if(popoverObj.$tip){
                            popoverObj.$tip.html($(template).html());
                        }

                        // force popover to update using the new options
                        popoverObj.setContent();

                        // if the popover is currently visible, update
                        // it immediately, but turn off animation to
                        // prevent it fading in
                        if(popoverObj.$tip.is(":visible")){
                            popoverObj.options.animation = false;
                            popoverObj.show();
                            popoverObj.options.animation = true;
                        }

                    // if popover element doesn't exist, create it
                    } else {
                        $el.popover({
                            trigger: "hover",
                            placement: placement,
                            delay: 0,
                            title: statusObj.description,
                            html: true,
                            content: popoverHTML,
                            template: template
                        });
                    }

                    $el.removeClass(Object.keys(STATUS_STYLES).join(" "))
                        .addClass(statusObj.status);

                    // if the status has changed since last tick, or
                    // it was and is still unknown, notify user
                    if(lastStatus !== statusObj.status || lastStatus === UNKNOWN && statusObj.status === UNKNOWN){
                        bounceStatus($el);
                    }
                    // store the status for comparison later
                    lastStatus = statusObj.status;
                }

                // if status object updates, update icon
                $scope.$watch("status", update);

                // TODO - cleanup watch
                $scope.$on("$destroy", function(){});

                function bindHealthCheckRowTemplate(hc){
                    return "
\
                            \

"+ hc.name +"
\

";
                }

                function bounceStatus($el){
                    $el.addClass("zoom");

                    $el.on("webkitAnimationEnd animationend", function(){
                        $el.removeClass("zoom");
                        // clean up animation end listener
                        $el.off("webkitAnimationEnd animationend");
                    });
                }

            }
        };
    }]);
})();
<commit_msg>fix missed healthcheck constant<commit_after>/* healthIconDirective
 * directive for displaying health of a service/instance
 * in icon form with helpful popover details
 */
(function() {
    'use strict';

    angular.module('healthIcon', [])
    .directive("healthIcon", ["hcStatus",
    function(hcStatus){
        let {OK, FAILED, NOT_RUNNING, UNKNOWN} = hcStatus;

        return {
            restrict: "E",
            scope: {
                // status object generated by serviceHealth
                status: "="
            },
            template: '

',
            link: function($scope, element, attrs){
                var STATUS_STYLES = {
                    [FAILED]: "glyphicon glyphicon-exclamation bad",
                    [OK]: "glyphicon glyphicon-ok good",
                    [UNKNOWN]: "glyphicon glyphicon-question unknown",
                    [NOT_RUNNING]: "glyphicon glyphicon-minus disabled"
                };

                // cache some DOM elements
                var $el = $(element),
                    $badge = $el.find(".healthIconBadge"),
                    lastStatus;

                function update(){
                    var statusObj, popoverHTML,
                        hideHealthChecks,
                        placement = "right",
                        popoverObj, template;

                    statusObj = $scope.status;

                    if(!statusObj){
                        // TODO - re-implement?
                        //statusObj = new Status(id, "", 1);
                        //statusObj.statusRollup.incNotRunning();
                        //statusObj.evaluateStatus();
                        return;
                    }

                    // determine if we should hide healthchecks
                    hideHealthChecks = statusObj.statusRollup.allOK() ||
                        statusObj.statusRollup.allNotRunning() ||
                        statusObj.desiredState  === 0;

                    // if service should be up and there is more than 1 instance, show number of instances
                    if(statusObj.desiredState === 1 && statusObj.statusRollup.total > 1){
                        $el.addClass("wide");
                        $badge.text(statusObj.statusRollup[OK] +"/"+ statusObj.statusRollup.total).show();

                    // else, hide the badge
                    } else {
                        $el.removeClass("wide");
                        $badge.hide();
                    }

                    // setup popover

                    // if this $el is inside a .serviceTitle, make the popover point down
                    if($el.parent().hasClass("serviceTitle")){
                        placement = "bottom";
                    }

                    // if this statusObj has children, we wanna show
                    // them in the healtcheck tooltip, so generate
                    // some yummy html
                    if(statusObj.children.length){
                        popoverHTML = [];

                        var isHealthCheckStatus = function(status){
                           return !status.id;
                        };

                        // if this status's children are healthchecks,
                        // no need for instance rows, go straight to healthcheck rows
                        if(statusObj.children.length && isHealthCheckStatus(statusObj.children[0])){
                            // if these are JUST healthchecks, then don't allow them
                            // to be hidden. this ensures that healthchecks show up for
                            // running instances.
                            hideHealthChecks = false;
                            // don't show count badge for healthchecks either
                            $badge.hide();
                            $el.removeClass("wide");

                            statusObj.children.forEach(function(hc){
                                popoverHTML.push(bindHealthCheckRowTemplate(hc));
                            });

                        // else these are instances, so create instance rows
                        // AND healthcheck rows
                        } else {
                            statusObj.children.forEach(function(instanceStatus){
                                // if this is becoming too long, stop adding rows
                                if(popoverHTML.length >= 15){
                                    // add an overflow indicator if not already there
                                    if(popoverHTML[popoverHTML.length-1] !== "..."){
                                        popoverHTML.push("...");
                                    }
                                    return;
                                }

                                // only create an instance row for this instance if
                                // it's in a bad or unknown state
                                if(instanceStatus.status === FAILED ||
                                      instanceStatus.status === UNKNOWN){
                                    popoverHTML.push("
");
                                    popoverHTML.push("
"+ instanceStatus.name +"
");
                                    instanceStatus.children.forEach(function(hc){
                                        popoverHTML.push(bindHealthCheckRowTemplate(hc));
                                    });
                                    popoverHTML.push("
");
                                }
                            });
                        }

                        popoverHTML = popoverHTML.join("");
                    }

                    // choose a popover template which is just a title,
                    // or a title and content
                    template = hideHealthChecks || !popoverHTML ?
                        '

' :
                        '

';

                    // NOTE: directly accessing the bootstrap popover
                    // data object here.
                    popoverObj = $el.data("bs.popover");

                    // if popover element already exists, update it
                    if(popoverObj){
                        // update title, content, and template
                        popoverObj.options.title = statusObj.description;
                        popoverObj.options.content = popoverHTML;
                        popoverObj.options.template = template;

                        // if the tooltip already exists, change the contents
                        // to the new template
                        if(popoverObj.$tip){
                            popoverObj.$tip.html($(template).html());
                        }

                        // force popover to update using the new options
                        popoverObj.setContent();

                        // if the popover is currently visible, update
                        // it immediately, but turn off animation to
                        // prevent it fading in
                        if(popoverObj.$tip.is(":visible")){
                            popoverObj.options.animation = false;
                            popoverObj.show();
                            popoverObj.options.animation = true;
                        }

                    // if popover element doesn't exist, create it
                    } else {
                        $el.popover({
                            trigger: "hover",
                            placement: placement,
                            delay: 0,
                            title: statusObj.description,
                            html: true,
                            content: popoverHTML,
                            template: template
                        });
                    }

                    $el.removeClass(Object.keys(STATUS_STYLES).join(" "))
                        .addClass(statusObj.status);

                    // if the status has changed since last tick, or
                    // it was and is still unknown, notify user
                    if(lastStatus !== statusObj.status || lastStatus === UNKNOWN && statusObj.status === UNKNOWN){
                        bounceStatus($el);
                    }
                    // store the status for comparison later
                    lastStatus = statusObj.status;
                }

                // if status object updates, update icon
                $scope.$watch("status", update);

                // TODO - cleanup watch
                $scope.$on("$destroy", function(){});

                function bindHealthCheckRowTemplate(hc){
                    return "
\
                            \

"+ hc.name +"
\

";
                }

                function bounceStatus($el){
                    $el.addClass("zoom");

                    $el.on("webkitAnimationEnd animationend", function(){
                        $el.removeClass("zoom");
                        // clean up animation end listener
                        $el.off("webkitAnimationEnd animationend");
                    });
                }

            }
        };
    }]);
})();
<|endoftext|>


<commit_before>angular.module('CS6310').factory('ToastService', function ($toast) {
  var svc = {};

  svc.showToast = function (text, action, position) {
    var toast = $mdToast.simple()
      .textContent(text)
      .action(action || 'OK')
      .highlightAction(true)
      .position(position);
    return $mdToast.show(toast);
  };

  return svc;
});<commit_msg>Fix console error<commit_after>angular.module('CS6310').factory('ToastService', function ($mdToast) {
  var svc = {};

  svc.showToast = function (text, action, position) {
    var toast = $mdToast.simple()
      .textContent(text)
      .action(action || 'OK')
      .highlightAction(true)
      .position(position);
    return $mdToast.show(toast);
  };

  return svc;
});<|endoftext|>


<commit_before>import { createAction as createActionCreator } from 'redux-actions'

//wraps default Action Creator factory to not have identity function be used
// when no payload is provided https://github.com/acdlite/redux-actions/issues/90
const makeActionCreator = (type, payloadCreator, metaCreator) =>
  createActionCreator(type, (payloadCreator || (() => {})), metaCreator)

const makeActionCreatorWithPayload = createActionCreator

/* actions should follow Flux Standard Action https://github.com/acdlite/flux-standard-action

An action MUST
  be a plain JavaScript object.
  have a type property.

An action MAY
  have a error property.
  have a payload property.
  have a meta property.

const fluxStandardAction = {
  type: 'SOME_ACTION',
  payload: {
    data: 'any data'
  },
  //if actions represents an error
  //An action whose error is true is analogous to a rejected Promise. By convention, the payload SHOULD be an error object.
  error: true/false,
  //The optional meta property MAY be any type of value. It is intended for any extra information that is not part of the payload.
  meta: {}
}
*/

// action creators

// debug related
export const toggleBaseline = makeActionCreator('Dbg.TOGGLE_BASELINE')
export const toggle3x3Grid = makeActionCreator('Dbg.TOGGLE_3X3_GRID')
export const toggleContainerEdges = makeActionCreator('Dbg.TOGGLE_CONTAINER_EDGES')

// calendar related
export const requestEventsFetch = makeActionCreatorWithPayload('Cal.REQUEST_EVENTS_FETCH')
export const calendarFetchSucceded = makeActionCreatorWithPayload('Cal.CALENDAR_FETCH_SUCCEDED')
export const calendarFetchFailed = makeActionCreatorWithPayload('Cal.CALENDAR_FETCH_FAILED')
export const toggleShowPastEvents = makeActionCreator('Cal.TOGGLE_PAST_EVENTS', (calendarId) => ({calendarId}))

// routing related
import { replace } from 'react-router-redux'

const getCurrentLocation = () => ({
  pathname: window.location.pathname,
  search: window.location.search,
})

export const openRoutedModal = ({path, hasPadding}) => replace({
  pathname: path,
  state: {
    // since react router would use it's own action it would be easier to just
    // differentiate it using those custom stings aka sub-actions
    subActionName: 'Modal.OPEN_ROUTED_MODAL',
    modalProps: { hasPadding: hasPadding },
    returnLocation: getCurrentLocation()
  }
})

export const closeRoutedModal = (returnLocation) => replace({
  pathname: returnLocation.pathname,
  search: returnLocation.search,
  state: {
    subActionName: 'Modal.CLOSE_ROUTED_MODAL',
    navigatedBackFromModal: true,
  }
})

export const replaceRoutedModal = ({path}) => replace({
  pathname: path,
  state: {
    subActionName: 'Modal.REPLACE_ROUTED_MODAL',
  }
})
<commit_msg>added comment<commit_after>import { createAction as createActionCreator } from 'redux-actions'

//wraps default Action Creator factory to not have identity function be used
// when no payload is provided https://github.com/acdlite/redux-actions/issues/90
const makeActionCreator = (type, payloadCreator, metaCreator) =>
  createActionCreator(type, (payloadCreator || (() => {})), metaCreator)

const makeActionCreatorWithPayload = createActionCreator

/* actions should follow Flux Standard Action https://github.com/acdlite/flux-standard-action

An action MUST
  be a plain JavaScript object.
  have a type property.

An action MAY
  have a error property.
  have a payload property.
  have a meta property.

const fluxStandardAction = {
  type: 'SOME_ACTION',
  payload: {
    data: 'any data'
  },
  //if actions represents an error
  //An action whose error is true is analogous to a rejected Promise. By convention, the payload SHOULD be an error object.
  error: true/false,
  //The optional meta property MAY be any type of value. It is intended for any extra information that is not part of the payload.
  meta: {}
}
*/

// action creators

// debug related
export const toggleBaseline = makeActionCreator('Dbg.TOGGLE_BASELINE')
export const toggle3x3Grid = makeActionCreator('Dbg.TOGGLE_3X3_GRID')
export const toggleContainerEdges = makeActionCreator('Dbg.TOGGLE_CONTAINER_EDGES')

// calendar related
export const requestEventsFetch = makeActionCreatorWithPayload('Cal.REQUEST_EVENTS_FETCH')
export const calendarFetchSucceded = makeActionCreatorWithPayload('Cal.CALENDAR_FETCH_SUCCEDED')
export const calendarFetchFailed = makeActionCreatorWithPayload('Cal.CALENDAR_FETCH_FAILED')
export const toggleShowPastEvents = makeActionCreator('Cal.TOGGLE_PAST_EVENTS', (calendarId) => ({calendarId}))

// routing related
import { replace } from 'react-router-redux'

const getCurrentLocation = () => ({
  pathname: window.location.pathname,
  search: window.location.search,
})

export const openRoutedModal = ({path, hasPadding}) => replace({
  pathname: path,
  state: {
    // since react router would use it's own action it would be easier to just
    // differentiate it using those custom stings aka sub-actions
    subActionName: 'Modal.OPEN_ROUTED_MODAL',
    modalProps: { hasPadding: hasPadding },
    returnLocation: getCurrentLocation()
  }
})

export const closeRoutedModal = (returnLocation) => replace({
  pathname: returnLocation.pathname,
  search: returnLocation.search,
  state: {
    subActionName: 'Modal.CLOSE_ROUTED_MODAL',
    // this is a required workaround for now, since pure-component-with-routed-modal expects this state
    // to be passed as part of location state and it's cumbersome to connect every component to redux-actions
    // store just to have this prop in props so that helper HOC could work
    navigatedBackFromModal: true,
  }
})

export const replaceRoutedModal = ({path}) => replace({
  pathname: path,
  state: {
    subActionName: 'Modal.REPLACE_ROUTED_MODAL',
  }
})
<|endoftext|>


<commit_before>import _ from 'lodash';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import {
  fetchRegion,
  fetchInitialRegions
} from '../actions/index';

class SearchBar extends Component {

  constructor(props) {
    super(props);

    this.state = { term: '' };
    this.onInputChange = this.onInputChange.bind(this);
    this.onFormSubmit = this.onFormSubmit.bind(this);
  }

  componentDidMount() {
    this.props.fetchInitialRegions();
  }

  onFormSubmit(event) {
    event.preventDefault();

    const nameIds = this.props.regionList.nameIds;
    let searchTerm = '',
        regionId = null,
        regId = null;

    // fetch region name and region id
    // 1. find if the term has 'kabupaten' on it
    // 2. convert 'kabupaten into kab.'
    searchTerm = this.state.term.replace(/kabupaten/i, 'kab.');

    // 3. based on this new term, find region id in the 'regionList'
    regionId = _.findIndex(nameIds, {nama: searchTerm.toUpperCase()});
    regId = nameIds[regionId].id;

    console.log(regId);

    // 4. dispatch 'getRegionDetails' action creator

    // fetch location
    this.props.fetchRegion(this.state.term);
    this.setState({ term: '' });
  }

  onInputChange(event) {
    this.setState({ term : event.target.value });
  }

  render() {
    return (

        <form className="input-group" onSubmit={this.onFormSubmit}>
          <input type="text" className="input-group-field"
            placeholder="Cari daerah pemilihan ..."
            value={this.state.term}
            onChange={this.onInputChange}
            />

            <input type="submit" className="button" value="Cari" />

        </form>

    );
  }
}

function mapDispatchToProps(dispatch) {
  return bindActionCreators({
    fetchRegion,
    fetchInitialRegions
  }, dispatch);
}

function mapStateToProps({regionList}) {
  return { regionList };
}

export default connect(mapStateToProps, mapDispatchToProps)(SearchBar);<commit_msg>refactored getRegionId<commit_after>import _ from 'lodash';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import {
  fetchRegion,
  fetchInitialRegions
} from '../actions/index';

class SearchBar extends Component {

  constructor(props) {
    super(props);

    this.state = { term: '' };
    this.onInputChange = this.onInputChange.bind(this);
    this.onFormSubmit = this.onFormSubmit.bind(this);
    this.getRegionId = this.getRegionId.bind(this);
  }

  componentDidMount() {
    this.props.fetchInitialRegions();
  }

  onFormSubmit(event) {
    event.preventDefault();

    let region = this.state.term,
        regionId = this.getRegionId();

    console.log(region, regionId);

    // 4. dispatch 'getRegionDetails' action creator
    this.props.fetchRegion(region);

    // remove the term from the search field
    this.setState({ term: '' });
  }

  getRegionId() {
    const nameIds = this.props.regionList.nameIds;
    let searchTerm = '',
        regionId = null;

    // fetch region name and region id
    // 1. find if the term has 'kabupaten' on it
    // 2. convert 'kabupaten into kab.'
    searchTerm = this.state.term.replace(/kabupaten/i, 'kab.');

    // 3. based on this new term, find region id in the 'regionList'
    regionId = _.findIndex(nameIds, {nama: searchTerm.toUpperCase()});

    return nameIds[regionId].id;
  }

  onInputChange(event) {
    this.setState({ term : event.target.value });
  }

  render() {
    return (

        <form className="input-group" onSubmit={this.onFormSubmit}>
          <input type="text" className="input-group-field"
            placeholder="Cari daerah pemilihan ..."
            value={this.state.term}
            onChange={this.onInputChange}
            />

            <input type="submit" className="button" value="Cari" />

        </form>

    );
  }
}

function mapDispatchToProps(dispatch) {
  return bindActionCreators({
    fetchRegion,
    fetchInitialRegions
  }, dispatch);
}

function mapStateToProps({regionList}) {
  return { regionList };
}

export default connect(mapStateToProps, mapDispatchToProps)(SearchBar);<|endoftext|>


<commit_before>/**
* @author       Richard Davey <rich@photonstorm.com>
* @copyright    2016 Photon Storm Ltd.
* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/

/**
* 2D Transformation Component.
*
* @class
*/
Phaser.Component.Transform = function (gameObject, x, y, scaleX, scaleY)
{
    if (x === undefined) { x = 0; }
    if (y === undefined) { y = 0; }
    if (scaleX === undefined) { scaleX = 1; }
    if (scaleY === undefined) { scaleY = 1; }

    this.game = gameObject.game;

    this.gameObject = gameObject;

    //  Local Transform
    //  a = scale X
    //  b = shear Y
    //  c = shear X
    //  d = scale Y
    //  tx / ty = translation
    // this.local = { a: scaleX, b: 0, c: 0, d: scaleY, tx: x, ty: y };

    //  World Transform
    this.world = { a: scaleX, b: 0, c: 0, d: scaleY, tx: x, ty: y };

    //  Cached Transform Calculations
    this.cache = { a: 1, b: 0, c: 0, d: 1, sr: 0, cr: 0 };

    this.hasLocalRotation = false;

    //  Private value holders, accessed via the getters and setters
    this._posX = x;
    this._posY = y;
    this._scaleX = scaleX;
    this._scaleY = scaleY;
    this._rotation = 0;
    this._pivotX = 0;
    this._pivotY = 0;
    this._anchorX = 0;
    this._anchorY = 0;

    this._worldRotation = 0;
    this._worldScaleX = scaleX;
    this._worldScaleY = scaleY;

    this._dirty = false;

    //  The parent Transform (NOT the parent GameObject, although very often they are related)
    this.parent = null;

    //  Any child Tranforms of this one - note that they don't have to belong to Game Objects
    //  that are children of the owner of this Transform
    this.children = [];

    // if (parent)
    // {
    //     parent.children.add(this);
    // }
};

Phaser.Component.Transform.prototype.constructor = Phaser.Component.Transform;

Phaser.Component.Transform.prototype = {

    add: function (child)
    {
        return this.addAt(child, this.children.length);
    },

    addAt: function (child, index)
    {
        //  Invalid child?
        if (child === this || child.parent === this || index < 0 || index > this.children.length)
        {
            return child;
        }

        //  Child already parented? Remove it
        if (child.parent)
        {
            child.parent.remove(child);
        }

        child.parent = this;

        this.children.splice(index, 0, child);

        this.dirty = true;

        this.updateAncestors();

        return child;
    },

    remove: function (child)
    {
        //  Invalid child?
        if (child === this || child.parent !== this)
        {
            return child;
        }

        var index = this.children.indexOf(child);

        if (index !== -1)
        {
            return this.removeAt(index);
        }
    },

    removeAt: function (index)
    {
        //  Valid index?
        if (index >= 0 && index < this.children.length)
        {
            var child = this.children.splice(index, 1);

            if (child[0])
            {
                child[0].parent = null;

                return child[0];
            }
        }
    },

    setPosition: function (x, y)
    {
        if (y === undefined) { y = x; }

        this._posX = x;
        this._posY = y;

        return this.update();
    },

    setScale: function (x, y)
    {
        if (y === undefined) { y = x; }

        this._scaleX = x;
        this._scaleY = y;

        this.updateCache();

        return this.update();
    },

    setPivot: function (x, y)
    {
        if (y === undefined) { y = x; }

        this._pivotX = x;
        this._pivotY = y;

        return this.update();
    },

    setAnchor: function (x, y)
    {
        if (y === undefined) { y = x; }

        this._anchorX = x;
        this._anchorY = y;

        return this.update();
    },

    setRotation: function (rotation)
    {
        this.rotation = rotation;

        return this.update();
    },

    //  Updates the Transform.world object, ready for rendering
    //  Assuming this Transform is a root node (i.e. no transform parent)
    updateFromRoot: function ()
    {
        if (this.hasLocalRotation)
        {
            // console.log(this.name, 'Transform.updateFromRoot');

            this.world.a = this.cache.a;
            this.world.b = this.cache.b;
            this.world.c = this.cache.c;
            this.world.d = this.cache.d;
            this.world.tx = this._posX - (this._pivotX * this.cache.a + this._pivotY * this.cache.c);
            this.world.ty = this._posY - (this._pivotX * this.cache.b + this._pivotY * this.cache.d);

            this._worldRotation = Math.atan2(-this.cache.c, this.cache.d);
        }
        else
        {
            // console.log(this.name, 'Transform.updateFromRoot FAST');

            this.world.a = this._scaleX;
            this.world.b = 0;
            this.world.c = 0;
            this.world.d = this._scaleY;
            this.world.tx = this._posX - (this._pivotX * this._scaleX);
            this.world.ty = this._posY - (this._pivotY * this._scaleY);

            this._worldRotation = 0;
        }

        this._worldScaleX = this._scaleX;
        this._worldScaleY = this._scaleY;

        return this;
    },

    updateFromParent: function ()
    {
        var parent = this.parent.world;
        var tx = 0;
        var ty = 0;

        if (this.hasLocalRotation)
        {
            // console.log(this.name, 'Transform.updateFromParent', this.parent.name);

            var a = this.cache.a;
            var b = this.cache.b;
            var c = this.cache.c;
            var d = this.cache.d;

            tx = this._posX - ((this._pivotX * a) + (this._pivotY * c));
            ty = this._posY - ((this._pivotX * b) + (this._pivotY * d));

            this.world.a = (a * parent.a) + (b * parent.c);
            this.world.b = (a * parent.b) + (b * parent.d);
            this.world.c = (c * parent.a) + (d * parent.c);
            this.world.d = (c * parent.b) + (d * parent.d);
        }
        else
        {
            // console.log(this.name, 'Transform.updateFromParent FAST', this.parent.name);

            tx = this._posX - (this._pivotX * this._scaleX);
            ty = this._posY - (this._pivotY * this._scaleY);

            this.world.a = this._scaleX * parent.a;
            this.world.b = this._scaleX * parent.b;
            this.world.c = this._scaleY * parent.c;
            this.world.d = this._scaleY * parent.d;
        }

        this._worldRotation = Math.atan2(-this.world.c, this.world.d);

        this.world.tx = (tx * parent.a) + (ty * parent.c) + parent.tx;
        this.world.ty = (tx * parent.b) + (ty * parent.d) + parent.ty;

        this._worldScaleX = this._scaleX * Math.sqrt((this.world.a * this.world.a) + (this.world.c * this.world.c));
        this._worldScaleY = this._scaleY * Math.sqrt((this.world.b * this.world.b) + (this.world.d * this.world.d));

        return this;
    },

    updateAncestors: function ()
    {
        //  No parent? Then just update the children and leave, our job is done
        if (!this.parent)
        {
            this.updateFromRoot();
            this.updateChildren();
            this.dirty = false;

            return this;
        }

        // console.log(this.name, 'updateAncestors');

        //  Gets all parent nodes, starting from this Transform.
        //  Then updates from the top, down, but only on the ancestors,
        //  not any other children - will give us accurate worldX etc properties

        var node = this.parent;
        var nodes = [];

        do
        {
            nodes.push(node);
            node = node.parent;
        }
        while (node);

        //  We've got all the ancestors in the 'nodes' array, let's loop it

        while (nodes.length)
        {
            node = nodes.pop();

            if (node.parent)
            {
                node.updateFromParent();
            }
            else
            {
                node.updateFromRoot();
            }
        }

        //  By this point all of this Transforms ancestors have been
        //  updated, in the correct order, so we can now do this one
        //  and any of its children too

        return this.update();
    },

    updateChildren: function ()
    {
        for (var i = 0; i < this.children.length; i++)
        {
            this.children[i].update();
        }

        return this;
    },

    update: function ()
    {
        // console.log('Transform.update', this.gameObject.name, this.dirty);

        if (!this._dirty)
        {
            return this;
        }

        //  If we got this far then this Transform is dirty
        //  so we need to update it from its parent
        //  and then force the update to all children

        if (this.parent)
        {
            this.updateFromParent();
        }
        else
        {
            this.updateFromRoot();
        }

        var len = this.children.length;

        if (len)
        {
            for (var i = 0; i < len; i++)
            {
                this.children[i].update();
            }
        }

        this._dirty = false;

        return this;
    },

    updateCache: function ()
    {
        this.cache.a = this.cache.cr * this._scaleX;
        this.cache.b = this.cache.sr * this._scaleX;
        this.cache.c = -this.cache.sr * this._scaleY;
        this.cache.d = this.cache.cr * this._scaleY;
    }

};

Object.defineProperties(Phaser.Component.Transform.prototype, {

    dirty: {

        enumerable: true,

        get: function ()
        {
            return this._dirty;
        },

        set: function (value)
        {
            if (value)
            {
                if (!this._dirty)
                {
                    this.game.transforms.add(this);
                }

                this._dirty = true;
            }
            else
            {
                this._dirty = false;
            }
        }

    },

    //  GLOBAL read-only properties from here on
    //  Need *all* parents taken into account to get the correct values

    worldRotation: {

        enumerable: true,

        get: function ()
        {
            this.updateAncestors();

            return this._worldRotation;
        }

    },

    worldScaleX: {

        enumerable: true,

        get: function ()
        {
            this.updateAncestors();

            return this._worldScaleX;
        }

    },

    worldScaleY: {

        enumerable: true,

        get: function ()
        {
            this.updateAncestors();

            return this._worldScaleY;
        }

    },

    worldX: {

        enumerable: true,

        get: function ()
        {
            this.updateAncestors();

            return this.world.tx;
        }

    },

    worldY: {

        enumerable: true,

        get: function ()
        {
            this.updateAncestors();

            return this.world.ty;
        }

    }

});
<commit_msg>Added updateFromDirtyParent.<commit_after>/**
* @author       Richard Davey <rich@photonstorm.com>
* @copyright    2016 Photon Storm Ltd.
* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/

/**
* 2D Transformation Component.
*
* @class
*/
Phaser.Component.Transform = function (gameObject, x, y, scaleX, scaleY)
{
    if (x === undefined) { x = 0; }
    if (y === undefined) { y = 0; }
    if (scaleX === undefined) { scaleX = 1; }
    if (scaleY === undefined) { scaleY = 1; }

    this.game = gameObject.game;

    this.gameObject = gameObject;

    //  Local Transform
    //  a = scale X
    //  b = shear Y
    //  c = shear X
    //  d = scale Y
    //  tx / ty = translation
    // this.local = { a: scaleX, b: 0, c: 0, d: scaleY, tx: x, ty: y };

    //  World Transform
    this.world = { a: scaleX, b: 0, c: 0, d: scaleY, tx: x, ty: y };

    //  Cached Transform Calculations
    this.cache = { a: 1, b: 0, c: 0, d: 1, sr: 0, cr: 0 };

    this.hasLocalRotation = false;

    //  Private value holders, accessed via the getters and setters
    this._posX = x;
    this._posY = y;
    this._scaleX = scaleX;
    this._scaleY = scaleY;
    this._rotation = 0;
    this._pivotX = 0;
    this._pivotY = 0;
    this._anchorX = 0;
    this._anchorY = 0;

    this._worldRotation = 0;
    this._worldScaleX = scaleX;
    this._worldScaleY = scaleY;

    this._dirty = false;

    //  The parent Transform (NOT the parent GameObject, although very often they are related)
    this.parent = null;

    //  Any child Tranforms of this one - note that they don't have to belong to Game Objects
    //  that are children of the owner of this Transform
    this.children = [];

    // if (gameObject.parent && gameObject.parent.transform)
    // {
    //     gameObject.parent.transform.add(this);
    // }
};

Phaser.Component.Transform.prototype.constructor = Phaser.Component.Transform;

Phaser.Component.Transform.prototype = {

    add: function (child)
    {
        return this.addAt(child, this.children.length);
    },

    addAt: function (child, index)
    {
        //  Invalid child?
        if (child === this || child.parent === this || index < 0 || index > this.children.length)
        {
            return child;
        }

        //  Child already parented? Remove it
        if (child.parent)
        {
            child.parent.remove(child);
        }

        child.parent = this;

        this.children.splice(index, 0, child);

        this.dirty = true;

        this.updateAncestors();

        return child;
    },

    remove: function (child)
    {
        //  Invalid child?
        if (child === this || child.parent !== this)
        {
            return child;
        }

        var index = this.children.indexOf(child);

        if (index !== -1)
        {
            return this.removeAt(index);
        }
    },

    removeAt: function (index)
    {
        //  Valid index?
        if (index >= 0 && index < this.children.length)
        {
            var child = this.children.splice(index, 1);

            if (child[0])
            {
                child[0].parent = null;

                return child[0];
            }
        }
    },

    setPosition: function (x, y)
    {
        if (y === undefined) { y = x; }

        this._posX = x;
        this._posY = y;

        return this.update();
    },

    setScale: function (x, y)
    {
        if (y === undefined) { y = x; }

        this._scaleX = x;
        this._scaleY = y;

        this.updateCache();

        return this.update();
    },

    setPivot: function (x, y)
    {
        if (y === undefined) { y = x; }

        this._pivotX = x;
        this._pivotY = y;

        return this.update();
    },

    setAnchor: function (x, y)
    {
        if (y === undefined) { y = x; }

        this._anchorX = x;
        this._anchorY = y;

        return this.update();
    },

    setRotation: function (rotation)
    {
        this.rotation = rotation;

        return this.update();
    },

    //  Updates the Transform.world object, ready for rendering
    //  Assuming this Transform is a root node (i.e. no transform parent)
    updateFromRoot: function ()
    {
        if (this.hasLocalRotation)
        {
            // console.log(this.name, 'Transform.updateFromRoot');

            this.world.a = this.cache.a;
            this.world.b = this.cache.b;
            this.world.c = this.cache.c;
            this.world.d = this.cache.d;
            this.world.tx = this._posX - (this._pivotX * this.cache.a + this._pivotY * this.cache.c);
            this.world.ty = this._posY - (this._pivotX * this.cache.b + this._pivotY * this.cache.d);

            this._worldRotation = Math.atan2(-this.cache.c, this.cache.d);
        }
        else
        {
            // console.log(this.name, 'Transform.updateFromRoot FAST');

            this.world.a = this._scaleX;
            this.world.b = 0;
            this.world.c = 0;
            this.world.d = this._scaleY;
            this.world.tx = this._posX - (this._pivotX * this._scaleX);
            this.world.ty = this._posY - (this._pivotY * this._scaleY);

            this._worldRotation = 0;
        }

        this._worldScaleX = this._scaleX;
        this._worldScaleY = this._scaleY;

        return this;
    },

    updateFromParent: function ()
    {
        var parent = this.parent.world;
        var tx = 0;
        var ty = 0;

        if (this.hasLocalRotation)
        {
            // console.log(this.name, 'Transform.updateFromParent', this.parent.name);

            var a = this.cache.a;
            var b = this.cache.b;
            var c = this.cache.c;
            var d = this.cache.d;

            tx = this._posX - ((this._pivotX * a) + (this._pivotY * c));
            ty = this._posY - ((this._pivotX * b) + (this._pivotY * d));

            this.world.a = (a * parent.a) + (b * parent.c);
            this.world.b = (a * parent.b) + (b * parent.d);
            this.world.c = (c * parent.a) + (d * parent.c);
            this.world.d = (c * parent.b) + (d * parent.d);
        }
        else
        {
            // console.log(this.name, 'Transform.updateFromParent FAST', this.parent.name);

            tx = this._posX - (this._pivotX * this._scaleX);
            ty = this._posY - (this._pivotY * this._scaleY);

            this.world.a = this._scaleX * parent.a;
            this.world.b = this._scaleX * parent.b;
            this.world.c = this._scaleY * parent.c;
            this.world.d = this._scaleY * parent.d;
        }

        this._worldRotation = Math.atan2(-this.world.c, this.world.d);

        this.world.tx = (tx * parent.a) + (ty * parent.c) + parent.tx;
        this.world.ty = (tx * parent.b) + (ty * parent.d) + parent.ty;

        this._worldScaleX = this._scaleX * Math.sqrt((this.world.a * this.world.a) + (this.world.c * this.world.c));
        this._worldScaleY = this._scaleY * Math.sqrt((this.world.b * this.world.b) + (this.world.d * this.world.d));

        return this;
    },

    updateAncestors: function ()
    {
        //  No parent? Then just update the children and leave, our job is done
        if (!this.parent)
        {
            this.updateFromRoot();
            this.updateChildren();
            this.dirty = false;

            return this;
        }

        // console.log(this.name, 'updateAncestors');

        //  Gets all parent nodes, starting from this Transform.
        //  Then updates from the top, down, but only on the ancestors,
        //  not any other children - will give us accurate worldX etc properties

        var node = this.parent;
        var nodes = [];

        do
        {
            nodes.push(node);
            node = node.parent;
        }
        while (node);

        //  We've got all the ancestors in the 'nodes' array, let's loop it

        while (nodes.length)
        {
            node = nodes.pop();

            if (node.parent)
            {
                node.updateFromParent();
            }
            else
            {
                node.updateFromRoot();
            }
        }

        //  By this point all of this Transforms ancestors have been
        //  updated, in the correct order, so we can now do this one
        //  and any of its children too

        this.update();
    },

    updateChildren: function ()
    {
        for (var i = 0; i < this.children.length; i++)
        {
            this.children[i].update();
        }
    },

    updateFromDirtyParent: function ()
    {
        this.updateFromParent();

        if (this.children.length)
        {
            for (var i = 0; i < this.children.length; i++)
            {
                this.children[i].updateFromDirtyParent();
            }
        }

        this._dirty = false;
    },

    update: function ()
    {
        // console.log('Transform.update', this.gameObject.name, this.dirty);

        if (!this._dirty)
        {
            return;
        }

        //  If we got this far then this Transform is dirty
        //  so we need to update it from its parent
        //  and then force the update to all children

        if (this.parent)
        {
            this.updateFromParent();
        }
        else
        {
            this.updateFromRoot();
        }

        var len = this.children.length;

        if (len)
        {
            for (var i = 0; i < len; i++)
            {
                this.children[i].updateFromDirtyParent();
            }
        }

        this._dirty = false;
    },

    updateCache: function ()
    {
        this.cache.a = this.cache.cr * this._scaleX;
        this.cache.b = this.cache.sr * this._scaleX;
        this.cache.c = -this.cache.sr * this._scaleY;
        this.cache.d = this.cache.cr * this._scaleY;
    }

};

Object.defineProperties(Phaser.Component.Transform.prototype, {

    dirty: {

        enumerable: true,

        get: function ()
        {
            return this._dirty;
        },

        set: function (value)
        {
            if (value)
            {
                if (!this._dirty)
                {
                    this.game.transforms.add(this);
                }

                this._dirty = true;
            }
            else
            {
                this._dirty = false;
            }
        }

    },

    //  GLOBAL read-only properties from here on
    //  Need *all* parents taken into account to get the correct values

    worldRotation: {

        enumerable: true,

        get: function ()
        {
            this.updateAncestors();

            return this._worldRotation;
        }

    },

    worldScaleX: {

        enumerable: true,

        get: function ()
        {
            this.updateAncestors();

            return this._worldScaleX;
        }

    },

    worldScaleY: {

        enumerable: true,

        get: function ()
        {
            this.updateAncestors();

            return this._worldScaleY;
        }

    },

    worldX: {

        enumerable: true,

        get: function ()
        {
            this.updateAncestors();

            return this.world.tx;
        }

    },

    worldY: {

        enumerable: true,

        get: function ()
        {
            this.updateAncestors();

            return this.world.ty;
        }

    }

});
<|endoftext|>


<commit_before>'use strict';

import React from 'react';
import TextField from 'material-ui/TextField';
import store from '../redux/store';
import { Editor } from '../redux/actions';
import { textStyle } from '../styles';

export default React.createClass({
  propTypes: {
    id: React.PropTypes.string,
    hint: React.PropTypes.string,
    value: React.PropTypes.array
  },

  handleChange(event, value) {
    store.dispatch(Editor.change(this.props.id, value.split(',')));
  },

  render() {
    let { value } = this.props;

    return (
      <TextField
        id={this.props.id}
        key={this.props.id}
        hintText={this.props.hint}
        value={value.toString()}
        onChange={this.handleChange}
        style={textStyle}
      />
    );
  }
});
<commit_msg>investigating a way to merge ArrayText and Text using reselect<commit_after>'use strict';

import React from 'react';
import TextField from 'material-ui/TextField';
import { connect } from 'react-redux';
import { Editor } from '../redux/actions';
import { textStyle } from '../styles';
import { createSelector } from 'reselect';

let ArrayText = React.createClass({
  render() {
    console.log(this.props);
    return (<TextField {...this.props} style={textStyle} />);
  }
});

const mapStateToProps = (state, props) => props;

const mapDispatchToProps = {
  change: Editor.change
};

const mergeProps = createSelector(
  props => props,
  (state, actions) => actions.change,
  (props, change) => ({
    id: props.id,
    key: props.id,
    hintText: props.hint,
    value: props.value.toString(),
    onChange: (event, value) => change(props.id, value.split(','))
  })
);

export default connect(mapStateToProps, mapDispatchToProps, mergeProps)(ArrayText);
<|endoftext|>


<commit_before>import React, { Component } from 'react';
import ReactGridLayout from 'react-grid-layout';
import Users from './users';
import Widget from './widget';

class Dashboard extends Component {

	render() {
		var layout = [
    	  	{i: 'a', x: 0, y: 0, w: 7, h: 21},
    	  	{i: 'b', x: 1, y: 0, w: 3, h: 3},
      		{i: 'c', x: 4, y: 0, w: 2, h: 2}
	    ];

		return (
			<ReactGridLayout className="layout" layout={layout} cols={12} rowHeight={20} width={1400}>

              <Widget title="Users" onRefresh={ () => alert('refresh 3') }>
                <Users />
              </Widget>

              <Widget  title="Test2">

b

              </Widget>

              <Widget  title="test3">
              </Widget>

      		</ReactGridLayout>
      	);
	}
}
export default Dashboard;<commit_msg>Update dashboard.js<commit_after>import React, { Component } from 'react';
import ReactGridLayout from 'react-grid-layout';
import Users from './users';
import Widget from './widget';

class Dashboard extends Component {
	render() {
		var layout = [
  	  	{i: 'a', x: 0, y: 0, w: 7, h: 21},
  	  	{i: 'b', x: 1, y: 0, w: 3, h: 3},
    		{i: 'c', x: 4, y: 0, w: 2, h: 2}
		];

		return (
			<ReactGridLayout className="layout" layout={layout} cols={12} rowHeight={20} width={1400}>

          <Widget title="Users" onRefresh={ () => alert('refresh 3') }>
            <Users />
          </Widget>

          <Widget  title="Test2">

b

          </Widget>

          <Widget  title="test3">
          </Widget>

  		</ReactGridLayout>
  	);
	}
}
export default Dashboard;
<|endoftext|>


<commit_before>/**
 * adopted extension of https://github.com/cure53/DOMPurify
 */
import {attrs} from '../aria';
import dompurify from 'dompurify';
import PropTypes from "prop-types";
import React, {Component} from 'react';

export default class DomPurify extends Component {

  constructor(props, context) {
    super(props, context);
    this.displayName = 'components/DomPurify';
    this.state = { domPurifyOptions: this.props.domPurifyOptions || { ADD_ATTR: attrs } };
  };

  render() {
    return ( );
  }

}

DomPurify.propTypes = {
  content: PropTypes.string.required,
  className: PropTypes.string,
  domPurifyOptions: PropTypes.shape({
    ADD_ATTR: PropTypes.arrayOf(PropTypes.string)
  })
};
<commit_msg>Added Documents to DomPurify tag<commit_after>/**
 * adopted extension of https://github.com/cure53/DOMPurify
 */
import {attrs} from '../aria';
import dompurify from 'dompurify';
import PropTypes from "prop-types";
import React, {Component} from 'react';

/**
 * DomPurify uses https://www.npmjs.com/package/dompurify to sanctify html suitable for ReactJS
 * @class
 */
export default class DomPurify extends Component {

  constructor(props, context) {
    super(props, context);
    this.displayName = 'components/DomPurify';
    this.state = { domPurifyOptions: this.props.domPurifyOptions || { ADD_ATTR: attrs } };
  };

  render() {
    return ( );
  }

}

/**
 * @type {{content, className: *, domPurifyOptions: *}}
 */
DomPurify.propTypes = {
  content: PropTypes.string.required,
  className: PropTypes.string,
  domPurifyOptions: PropTypes.shape({
    ADD_ATTR: PropTypes.arrayOf(PropTypes.string)
  })
};
<|endoftext|>


<commit_before><commit_msg>FIO-2747: fix conditional appearance of a nested wizard<commit_after><|endoftext|>


<commit_before>import React from "react";
import { withStyles } from "@material-ui/core/styles";

const s = {};

class Hamberger extends React.Component {
  render() {
    console.log(this.ref);
    return (
      <React.Fragment>

ぽ

      </React.Fragment>
    );
  }
}
export default withStyles(s)(Hamberger);
<commit_msg>hamberが変化<commit_after>import React from "react";
import { withStyles } from "@material-ui/core/styles";

const s = {};

class Hamberger extends React.Component {
  constructor(props) {
    super(props);
    this.state = { isOpen: false };
  }
  onClick = e => {
    this.setState({ isOpen: !this.state.isOpen });
    this.props.onClick(this.state.isOpen);
  };
  render() {
    console.log(this.ref);
    return (
      <React.Fragment>

{this.state.isOpen ? "x" : "三"}

      </React.Fragment>
    );
  }
}
export default withStyles(s)(Hamberger);
<|endoftext|>