render: function() {
		var props = this.props;
		var className = props.classBase + (this.state.isActive ? '-active' : '-inactive');

		if (props.className) {
			className += ' ' + props.className;
		}

		var style = {};
		extend(style, this.touchStyles(), props.style);

		var newComponentProps = extend({}, props, {
			style: style,
			className: className,
			disabled: props.disabled,
			handlers: this.handlers
		}, this.handlers());

		delete newComponentProps.onTap;
		delete newComponentProps.onPress;
		delete newComponentProps.onPinchStart;
		delete newComponentProps.onPinchMove;
		delete newComponentProps.onPinchEnd;
		delete newComponentProps.moveThreshold;
		delete newComponentProps.pressDelay;
		delete newComponentProps.pressMoveThreshold;
		delete newComponentProps.preventDefault;
		delete newComponentProps.stopPropagation;
		delete newComponentProps.component;

		return React.createElement(props.component, newComponentProps, props.children);
	}
  makeEditable: function(content, style) {
    if (!this.state.editing) {
      return content;
    }

    var inputStyle = this.formInputStyle(style);

    var sizerstyle = assign({}, inputStyle);
    assign(sizerstyle, {
      opacity: 0,
      visibility: "hidden",
      background: "transparent",
      color: "transparent",
      zIndex: -1,
      width: "auto",
      height: "auto",
      position: "fixed",
      padding: "0 2px",
    });

    if(this.refs.sizer) {
      var sizer = this.refs.sizer.getDOMNode();
      inputStyle.width = sizer.scrollWidth;
    }

    return [
      this.state.initialload ? false : <input ref="input" style={inputStyle} hidden={this.state.initialload} onClick={this.killEvent} onKeyDown={this.checkForStop} onChange={this.onTextUpdate} value={content} />,
      <span ref="sizer" style={this.state.initialload ? inputStyle : sizerstyle}>{ content }</span>
    ];
  },
Beispiel #3
0
  render: function () {
    var rawImage;
    var imageStyle = assign({}, this.props.style);
    var style = assign({}, this.props.style);
    var backgroundStyle = assign({}, this.props.style);
    var useBackingStore = this.state.loaded ? this.props.useBackingStore : false;

    // Hide the image until loaded.
    imageStyle.alpha = this.state.imageAlpha;

    // Hide opaque background if image loaded so that images with transparent
    // do not render on top of solid color.
    style.backgroundColor = imageStyle.backgroundColor = null;
    backgroundStyle.alpha = clamp(1 - this.state.imageAlpha, 0, 1);

    return (
      React.createElement(Group, {ref: 'main', style: style},
        React.createElement(Layer, {ref: 'background', style: backgroundStyle}),
        React.createElement(RawImage, 
          assign(
            {}, 
            this.props, 
            {ref: 'image', src: this.props.src, style: imageStyle, useBackingStore: useBackingStore}))
      )
    );
  },
Beispiel #4
0
 formInputStyle: function(style) {
   var inputStyle = assign({}, style);
   assign(inputStyle, {
     display: "inline-block",
     background: "transparent",
     border: "none",
     height: "100%",
     whiteSpace: "pre"
   });
   return inputStyle;
 },
Beispiel #5
0
function buildProps(props) {
  let propsSeed = {
    className: props.className || '',
    style: props.style ? assign({}, props.style) : {}
  }
  return applyStyles(propsSeed, props.styles)
}
Beispiel #6
0
  /**
   * Constructs a Store object, extends it with EventEmitter and supplied
   * methods parameter,  and creates a mixin property for use in components.
   *
   * @param {object} methods Public methods for Store instance.
   * @constructor
   */
  constructor(methods) {

    var self = this;

    invariant(!methods.dispatcherToken, '"dispatcherToken" is a reserved name and cannot be used as a method name.');
    invariant(!methods.Mixin, '"Mixin" is a reserved name and cannot be used as a method name.');

    assign(this, EventEmitter.prototype, methods);

    this.dispatcherToken = null;

    /**
     * Base functionality for every Store constructor. Mixed into the
     * `Store` prototype, but exposed statically for easy access.
     */
    this.Mixin = {

      componentDidMount: function() {
        self.addChangeListener(this.onChange);
      },

      componentWillUnmount: function() {
        self.removeChangeListener(this.onChange);
      }

    };
  }
    describe("when calling with key",function(){
        var initialstate = "DEFAULTDATA",
            triggerdata = "TRIGGERDATA",
            key = "KEY",
            listenable = {
                listen: sinon.spy(),
                getInitialState: sinon.stub().returns(initialstate)
            },
            context = {setState: sinon.spy()},
            result = assign(context, Reflux.ListenerMixin, connect(listenable, key));

        it("should pass initial state to state correctly",function(){
            assert.deepEqual({KEY:initialstate},context.getInitialState());
        });

        result.componentWillMount();

        it("should call listen on the listenable correctly",function(){
            assert.equal(1,listenable.listen.callCount);
            assert.isFunction(listenable.listen.firstCall.args[0]);
            assert.equal(context,listenable.listen.firstCall.args[1]);
        });

        it("should send listenable callback which calls setState correctly",function(){
            listenable.listen.firstCall.args[0](triggerdata);
            assert.deepEqual([_.object([key],[triggerdata])],context.setState.firstCall.args);
        });
    });
Beispiel #8
0
  var server = (function startup() {
    var child = cp.fork('build/server.js', {
      env: assign({
        NODE_ENV: 'development'
      }, process.env)
    });
    child.once('message', function(message) {

      if (message.match(/^online$/)) {

        if (browserSync) {
          browserSync.reload();
        }

        if (!started) {
          started = true;
          gulp.watch(src.server, function() {
            $.util.log('Restarting development server.');
            server.kill('SIGTERM');
            server = startup();
          });
          cb();
        }
      }
    });
    return child;
  })();
Beispiel #9
0
 render: function () {
   var props = assign({}, this.props, {
     href: this.props.to,
     onClick: this.handleClick
   });
   return React.createElement('a', props);
 }
Beispiel #10
0
  render: function () {
    var props = assign({}, this.props, {
      onClick: this.onClick
    });

    return React.DOM.input(props, this.props.children);
  }
    render() {
        let cursor = 'ew-resize';
        let readOnly = true;
        let value = this.props.value;
        if(this.state.startEditing) {
            cursor = 'auto';
            readOnly = false;
        }

        if(!this.state.startEditing) {
            value = Number(value).toFixed(this.props.decimals);
        }

        return (
            <input
                type="text"
                className={this.props.className}
                readOnly={readOnly}
                value={value}
                style={objectAssign(this.props.style, { cursor })}
                onKeyDown={this._onKeyDown}
                onDoubleClick={this._onDoubleClick}
                onChange={this._onChange}
                onBlur={this._onBlur}
            />
        );
    }
Beispiel #12
0
gulp.task('build:webpack', function (callback) {
  var config = assign({}, webpackConfig, {
    devtool: 'source-map'
  })

  webpack(config, webpackHandler('build:webpack', callback));
});
 render: function() {
   return (
     ReactTransitionGroup(
       assign({}, this.props, {childFactory: this._wrapChild})
     )
   );
 }
Beispiel #14
0
api.signUp = function (options, callback) {
  if (!options) {
    return callback(new Error('You must supply options.json to sign up'));
  }

  var json = assign({
    client_id: 'wm_id_zIPGbkEDB5Cv9dCzo7nS'
  }, options.json);

  xhr({
    method: 'POST',
    uri: api.SIGN_UP_URI,
    body: jsonToFormEncoded(json),
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  }, function (err, resp, body) {
    if (err || resp.statusCode !== 200) {
      return callback(parseJSON(body));
    }
    body = parseJSON(body);
    // Cool, let's authenticate now
    api.authenticate({
      user: body,
      json: {
        uid: body.username,
        password: json.password
      }
    }, callback);
  });
};
var update = (updates) => {
  var key = updates.url;
  if(state.builds.hasOwnProperty(key)) {
    state.builds[key] = assign({}, state.builds[key], updates.job);
    events.emit(CHANGE_EVENT);
  }
};
    describe("when calling without key",function(){
        var initialstate = "DEFAULTDATA",
            listenable = {
                listen: sinon.spy(),
                getInitialState: sinon.stub().returns(initialstate)
            },
            context = {setState: sinon.spy()},
            result = assign(context, Reflux.ListenerMixin, connect(listenable));

        it("should add getInitialState and componentWillMount and WillUnmount",function(){
            assert.isFunction(context.getInitialState);
            assert.isFunction(context.componentWillMount);
            assert.isFunction(context.componentWillUnmount);
            assert.equal(context.componentWillUnmount,Reflux.ListenerMethods.stopListeningToAll);
        });

        it("should pass initial state to state",function(){
            assert.deepEqual(initialstate,context.getInitialState());
        });

        result.componentWillMount();

        it("should call listen on the listenable correctly",function(){
            assert.equal(1,listenable.listen.callCount);
            assert.equal(context.setState,listenable.listen.firstCall.args[0]);
            assert.equal(context,listenable.listen.firstCall.args[1]);
        });

        it("should store the subscription object correctly",function(){
            assert.equal(listenable,context.subscriptions[0].listenable);
        });

    });
var PureRenderClassConstructor = function (newClass) {
  var classDef = assign(
    {},
    {mixins: [ReactComponentWithPureRenderMixin]},
    newClass
  );
  return React.createClass(classDef);
}
Beispiel #18
0
 value: function createRedirect(options) {
   return Route.createRoute(assign({}, options, {
     path: options.path || options.from || "*",
     onEnter: function onEnter(transition, params, query) {
       transition.redirect(options.to, options.params || params, options.query || query);
     }
   }));
 },
 beforeEach(function () {
     anotherAction = Reflux.createAction();
     Component = function() {
         this.listenTo(storeAll, this.trigger);
         this.listenTo(anotherAction);
     };
     assign(Component.prototype, Reflux.ListenerMixin);
 });
Beispiel #20
0
/**
 * A <DefaultRoute> component is a special kind of <Route> that
 * renders when its parent matches but none of its siblings do.
 * Only one such route may be used at any given level in the
 * route hierarchy.
 */
function DefaultRoute(props) {
  return Route(
    objectAssign({}, props, {
      path: null,
      isDefault: true
    })
  );
}
Beispiel #21
0
  intlDataFor: function(lang) {
    // we need to make sure we transform the given locale to the right format first
    // so we can access the right locale in our dictionary for example: pt-br should be transformed to pt-BR
    var locale = lang.split('-');
    locale = locale[1] ? `${locale[0]}-${locale[1].toUpperCase()}` : lang;
    var strings = messages[locale] ? messages[locale] : messages['en-US'];

    return {locales: [locale], messages: assign(messages['en-US'], strings)};
  }
Beispiel #22
0
	m : function() {
		var res = {};
		for (var i = 0; i < arguments.length; ++i) {
			if (arguments[i]) {
				assign(res, arguments[i]);
			}
		}
		return res;	
	},
Beispiel #23
0
  render: function () {
    var props = assign({}, this.props, {
      href: this.getHref(),
      className: this.getClassName(),
      onClick: this.handleClick
    });

    return React.DOM.a(props, this.props.children);
  }
Beispiel #24
0
 function renderComponent(spec, props) {
   function Component() {
     RxReactComponent.apply(this, arguments);
   }
   Component.prototype = Object.create(RxReactComponent.prototype);
   assign(Component.prototype, spec);
   Component.prototype.constructor = Component;
   Component.__proto__ = RxReactComponent;
   return testUtils.render(React.createElement(Component, props));
 }
function createRouteOptions(props) {
  var options = assign({}, props);
  var handler = options.handler;

  if (handler) {
    options.onEnter = handler.willTransitionTo;
    options.onLeave = handler.willTransitionFrom;
  }

  return options;
}
Beispiel #26
0
  getStyle: function () {
    if (this.state.left != null && this.state.top != null) {
      var compound = {
        position: 'absolute',
        left: this.state.left,
        top: this.state.top
      }
    }

    return assign(cssStyles, compound);
  },
Beispiel #27
0
  render: function render() {
    var props = assign({}, this.props, {
      href: this.getHref(),
      className: this.getClassName(),
      onClick: this.handleClick
    });

    if (props.activeStyle && this.getActiveState()) props.style = props.activeStyle;

    return React.DOM.a(props, this.props.children);
  }
    describe("when calling with action",function() {
        var listenable = {
                listen: sinon.spy()
            },
            context = {setState: sinon.spy()};
        assign(context,connect(listenable));

        it("should pass empty object to state",function(){
            assert.deepEqual({},context.getInitialState());
        });
    });
 describe("when calling with falsy key",function(){
     var triggerdata = "TRIGGERDATA",
         key = 0,
         listenable = {listen: sinon.spy()},
         context = {setState: sinon.spy()},
         result = assign(context, Reflux.ListenerMixin, connect(listenable, key));
     result.componentWillMount();
     it("should send listenable callback which calls setState correctly",function(){
         listenable.listen.firstCall.args[0](triggerdata);
         assert.deepEqual([_.object([key],[triggerdata])],context.setState.firstCall.args);
     });
 });
Beispiel #30
0
  render: function () {
    /*
     * Not sure if should allow more then one property?
     */

    var className = this.props.className || "";
    
    var props = assign({}, this.props, {
      className: this.props.className
    });

    return React.DOM.div(props, this.props.children);
  }