* enough to make sure I can build react stuff
This commit is contained in:
parent
2864b751f7
commit
5b25c5b3aa
|
|
@ -94,7 +94,9 @@ gem 'react-rails', '~> 1.0'
|
|||
gem "browserify-rails", "~> 0.7"
|
||||
|
||||
source 'https://rails-assets.org' do
|
||||
gem 'rails-assets-fluxxor'
|
||||
#gem 'rails-assets-fluxxor'
|
||||
gem 'rails-assets-es5-shim'
|
||||
gem 'rails-assets-reflux'
|
||||
end
|
||||
|
||||
group :development, :test do
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@
|
|||
//= require jquery.exists
|
||||
//= require jquery.payment
|
||||
//= require jquery.visible
|
||||
//= require fluxxor
|
||||
//= require react-components
|
||||
//= require es5-shim
|
||||
//= require reflux
|
||||
//= require howler.core.js
|
||||
//= require jstz
|
||||
//= require class
|
||||
|
|
@ -52,6 +52,7 @@
|
|||
//= require utils
|
||||
//= require subscription_utils
|
||||
//= require custom_controls
|
||||
//= require react-components
|
||||
//= require web/signup_helper
|
||||
//= require web/signin_helper
|
||||
//= require web/signin
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ $ = jQuery
|
|||
context = window
|
||||
context.JK ||= {};
|
||||
|
||||
broadcastActions = BroadcastNotificationActions # require('./react-components/actions/BroadcastNotificationActions')
|
||||
|
||||
context.JK.ClientInit = class ClientInit
|
||||
constructor: () ->
|
||||
@logger = context.JK.logger
|
||||
|
|
@ -14,5 +16,14 @@ context.JK.ClientInit = class ClientInit
|
|||
if context.gon.isNativeClient
|
||||
this.nativeClientInit()
|
||||
|
||||
setTimeout(this.checkBroadcastNotification, 3000)
|
||||
|
||||
checkBroadcastNotification: () =>
|
||||
console.log("broadcastActions", broadcastActions)
|
||||
broadcastActions.load.triggerPromise()
|
||||
|
||||
|
||||
nativeClientInit: () =>
|
||||
@gearUtils.bootstrapDefaultPlaybackProfile();
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1939,9 +1939,7 @@
|
|||
this.createAlert = createAlert;
|
||||
this.signup = signup;
|
||||
this.portOverCarts = portOverCarts;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
})(window,jQuery);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,5 @@
|
|||
|
||||
React = require('react');
|
||||
|
||||
// note that this is a global assignment, it will be discussed further below
|
||||
DemoComponent = require('./components/DemoComponent');
|
||||
|
||||
// //= require_tree ./react-components
|
||||
BroadcastNotificationActions = require('./react-components/actions/BroadcastNotificationActions')
|
||||
BroadcastNotification = require('./react-components/BroadcastNotification')
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
var React = require('react');
|
||||
|
||||
var BroadcastNotificationStore = require('./stores/BroadcastNotificationStore');
|
||||
|
||||
var BroadcastNotification = React.createClass({displayName: 'Broadcast Notification',
|
||||
mixins: [Reflux.connect(BroadcastNotificationStore, 'notification')],
|
||||
render: function() {
|
||||
if(!this.state.notification) {
|
||||
return <div>HAHAHAAH</div>
|
||||
}
|
||||
|
||||
return <div className="broadcast-notification">
|
||||
<div className="message" dangerouslySetInnerHTML={this.state.notification.message}/>
|
||||
<div className="actions">
|
||||
<a className="button-orange"
|
||||
href={this.state.notification.button_url}>{this.state.notification.button_label}</a>
|
||||
<a className="not-now" href="#">not now, thanks</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// each file will export exactly one component
|
||||
module.exports = BroadcastNotification;
|
||||
8
web/app/assets/javascripts/react-components/actions/BroadcastNotificationActions.js
vendored
Normal file
8
web/app/assets/javascripts/react-components/actions/BroadcastNotificationActions.js
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
//var rest = context.JK.Rest()
|
||||
|
||||
var BroadcastNotificationActions = Reflux.createActions({
|
||||
load: {asyncResult: true}
|
||||
})
|
||||
|
||||
module.exports = BroadcastNotificationActions
|
||||
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
$ = jQuery
|
||||
context = window
|
||||
logger = context.JK.logger
|
||||
broadcastActions = BroadcastNotificationActions # require('../actions/BroadcastNotificationActions')
|
||||
|
||||
rest = context.JK.Rest()
|
||||
|
||||
# see if this shows up elsewhere
|
||||
broadcastActions.blah = 'hahah'
|
||||
|
||||
broadcastActions.load.listenAndPromise(rest.getBroadcastNotification);
|
||||
|
||||
console.log("broadcastActions!!", broadcastActions)
|
||||
BroadcastNotificationStore = Reflux.createStore(
|
||||
{
|
||||
listenables: broadcastActions
|
||||
|
||||
init: () =>
|
||||
logger.debug("broadcast notification store init")
|
||||
#this.listenTo(broadcastActions.load, 'onSync')
|
||||
|
||||
onLoad: () =>
|
||||
logger.debug("loading broadcast notification...")
|
||||
|
||||
onLoadCompleted: () =>
|
||||
logger.debug("broadcast notification sync completed")
|
||||
|
||||
onLoadFailed: () =>
|
||||
logger.error("broadcast notification sync failed")
|
||||
}
|
||||
)
|
||||
|
||||
module.exports = BroadcastNotificationStore
|
||||
|
||||
|
|
@ -81,8 +81,7 @@
|
|||
<%= render 'dialogs/dialogs' %>
|
||||
<div id="fb-root"></div>
|
||||
|
||||
<h1>/app/views/pages/index.html.erb</h1>
|
||||
<%= react_component 'DemoComponent', {} %>
|
||||
<%= react_component 'BroadcastNotification', {} %>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue