Example #1
0
 _setListeners: function() {
   this.status.on('change:layer', _.bind(this._activeLayer, this));
   this.status.on('change:zoom', _.bind(this._updateMapZoom, this));
   this.status.on('change:lat', _.bind(this._updateMapCenter, this));
   this.status.on('change:lng', _.bind(this._updateMapCenter, this));
   Backbone.Events.on('dashboard:change', _.bind(this._refreshMap, this))
 },
Example #2
0
    componentWillMount: function(){
        Backbone.Events.on('yearChange', (payload)=>{
            this.setState({
                currentYear: payload
            })
        })

    },
    componentWillMount: function(){

    	var updater = () => {
    		this.setState({
                taskColl: this.state.taskColl

            })

		}
        
        this.props.taskColl.on('update', updater)
		Backbone.Events.on ('changeTaskList', updater)
        Backbone.Events.on('updateTaskView', (taskViewType) => {
			this.setState({
        		taskViewType: taskViewType
        	})
        })
    },
Example #4
0
		initialize: function(options) {
			this.view = options.view;

			$("#app").html(this.el);

			Backbone.Events.on("change:labels", this.render, this);
			this.listenTo(this.collection, 'add', this.addOne);
			this.listenTo(this.collection, 'reset', this.render);
			this.render();
		},
  componentDidMount: function(){
    var self = this

    console.log('Favs.regrettablesColl: ', this.props.regrettablesColl)
    Backbone.Events.on('newRegret',function(x){
      console.log('new regret!')
      console.log('payload = ', x)

      console.log(self.props.regrettablesColl)
      self.props.regrettablesColl.add({title: x.get('title')})
      console.log(self.props.regrettablesColl)

    })

    this.props.regrettablesColl.on("add", function(){
      console.log('ADDkk on regrettables heard!!')
      self.forceUpdate() 
    })
  },
Example #6
0
		componentWillMount: function(){
			//console.log('this is currentYear on State':, this.state.currentYear)
			var currentYearCopy = this.state.currentYear
			var self = this
			var decreaseYear = function(){
				//var currentYearCopy = this.state.currentYear,
					currentYearCopy -= 1
					
					self.setState({
						currentYear: currentYearCopy
					})
			}

			var increaseYear = function(){
				//var currentYearCopy = this.state.currentYear,
					currentYearCopy += 1
					self.setState({
						currentYear: currentYearCopy
					})
			}

			var freezeYear = function(){
				console.log('I stopped')
				//var currentYearCopy = this.state.currentYear
				self.setState({
					clickedButton: currentYearCopy
				})
				
			}

			Backbone.Events.on('button-clicked', (clickedButton) => {
				console.log('this is backbone receiving clickedButton:', clickedButton)

				clearInterval(pastIntervalRef)
				clearInterval(futureIntervalRef)

				if(clickedButton === 'past'){
					pastIntervalRef = setInterval(decreaseYear, 500)
					this.setState({
						background: 'url(https://s19.postimg.org/pi47y0nkj/The_Time_Machine_Past.jpg) 0 0 no-repeat'
					})
					
				} 
				
				else if(clickedButton === 'future'){
					futureIntervalRef = setInterval(increaseYear, 500)
					this.setState({
						background: 'url(https://s19.postimg.org/i8e21kjmb/Electronic_Room.jpg) 0 0 no-repeat'
					})
				}

				else if(clickedButton === 'stop'){
					console.log('I stopped')
					var currentYearCopy = this.state.currentYear
						this.setState({
							clickedButton: currentYearCopy
						})
					
				}
			})
		},
define('chiropractor/models/auth',['require','backbone','jquery','underscore','jquery.cookie'],function(require) {
    

    var Backbone = require('backbone'),
        $ = require('jquery'),
        _ = require('underscore'),
        tokenCookie = 'wttoken',
        expirationWarningMinutes = 2,
        expirationWarningActive = false,
        expirationTimeoutId, expirationWarning,
        activeToken, getToken, setToken, clearToken;

    require('jquery.cookie');

    expirationWarning = function() {
        Backbone.Events.trigger('authentication:expiration');
        expirationWarningActive = true;

        expirationTimeoutId = setTimeout(
            function() {
                Backbone.Events.trigger('authentication:failure');
            },
            expirationWarningMinutes * 60 * 1000
        );
    };

    getToken = function() {
        if (typeof(activeToken) === 'undefined') {
            activeToken = $.cookie(tokenCookie);
        }
        return activeToken;
    };

    setToken = function(token) {
        var tokenComponents = token.split('::'),
            serverTime = tokenComponents[1],
            expireTime = tokenComponents[2],
            // We want an expiration alert to happen two minutes before the
            // token is going to expire.
            expirationTimeout = Math.max(
                0,
                expireTime - serverTime - (expirationWarningMinutes * 60)
            ) * 1000;

        activeToken = token;
        $.cookie(tokenCookie, token);

        if (expirationTimeoutId) {
            clearTimeout(expirationTimeoutId);
        }

        if (expirationWarningActive) {
            Backbone.Events.trigger('authentication:renewal');
            expirationWarningActive = false;
        }

        expirationTimeoutId = setTimeout(expirationWarning, expirationTimeout);
    };

    clearToken = function() {
        activeToken = undefined;
        $.removeCookie(tokenCookie);

        if (expirationTimeoutId) {
            clearTimeout(expirationTimeoutId);
        }
    };

    Backbone.Events.on(
        'authentication:logout authentication:failure',
        clearToken
    );

    return {
        sync: function(method, model, options) {
            var beforeSend = options.beforeSend,
                onError = options.error,
                onSuccess = options.success,
                self = this,
                opts = _(options).clone();

            options.success = function(model, data, xhr) {
                var token = xhr.getResponseHeader('Authorization');
                if (token) {
                    setToken(token);
                }
                return onSuccess.apply(self, arguments);
            };

            // This is a jQuery error handler.
            options.error = function(xhr, statusText, error) {
                if (xhr.status === 400) {
                    // TODO: add logic to only trigger unauthenticated if the
                    // bad request is due to malformed token
                    Backbone.Events.trigger('authentication:failure', self, xhr);
                }
                if (xhr.status === 401) {
                    Backbone.Events.trigger('authentication:failure', self, xhr);

                    self.listenToOnce(
                        Backbone.Events,
                        'authentication:success',
                        function() {
                            self.sync(method, model, opts);
                        }
                    );
                }

                // Call the original onError handler.
                if (onError) {
                    return onError.apply(self, arguments);
                }
            };

            options.beforeSend = function(xhr) {
                var token = getToken();
                if (!self.disableAuthToken && token) {
                    xhr.setRequestHeader(
                        'Authorization',
                        token
                    );
                }

                if (beforeSend) {
                    return beforeSend.apply(this, arguments);
                }
            };
        },
        cleanup: clearToken
    };
});
Example #8
0
		}

	},

	componentWillMount(){

		window.matrix = this.matrix
		//this listener will pick up on the paint color on the Box component, placing it on the 
		//matrix: Array(2000) at the top of this component for its fill color
		Backbone.Events.on('paint',(boxFillObj) => {     //put this on the store.js
			let row = boxFillObj.rowIndex,
				col = boxFillObj.colIndex

			this.matrix[row][col] = boxFillObj.fill
			console.log('top level clear state???',  this.state.nuclearClear)
			
			if (this.state.nuclearClear) {
				console.log('resetting nuclear clear....')
				this.setState({
					nuclearClear: false
				})
			}
		})

		Backbone.Events.on('modifyAppState', (stateObj)=>{
			this.setState(stateObj)
		})

		Backbone.Events.on('resetCanvas', ()=> {
			this.matrix = Array(40).fill(null).map((val) => Array(50).fill('white'))
			this.setState({
				nuclearClear: true,