示例#1
0
文件: board.js 项目: dmolin/tictactoe
    initialize: function(options) {
        this.options = options;
        this.player = this.options.player;

        //listen for cell events and delegate to Game service (here implemented locally)
        Backbone.on("cell:ticked", this._checkMove, this);
    },
示例#2
0
		constructor(app) {

			super();

			this.app = app;
			
			app.addRegions({
				containerRegion: "#container",
				modalRegion: "#modal-container"
			});
			
			//register client events
			Backbone.on('show:audioplayer',this.showPlayer, this);

			//register socket events
			var socket = SIO(Config.web_socket_url);
            socket.on('interview:changed', function(data) {
            	Backbone.trigger('interview:changed',data);
            });
            socket.on('interview:new', function(data) {
            	Backbone.trigger('interview:new',data);
            });
            socket.on('interview:removed', function(data) {
            	Backbone.trigger('interview:new',data);
            });

            //load mainview
            this.mainView = new MainView();
            this.app.containerRegion.show(this.mainView);
			
		}
示例#3
0
文件: cell.js 项目: dmolin/tictactoe
    initialize: function(options) {
        this.options = options;
        this.model = this.options.model || new CellModel();

        this.model.on('change', this.render, this);
        Backbone.on("cells:winning", this.checkAgainstWinningCells, this);
    },
示例#4
0
            initialize: function () {
                

                Backbone.on('baoliao:search', function(param) {
                    console.log("controller receive search event from baoliao");
                    console.log(param);
                    //service layer pull remote data and update BaoliaoView
                    //currentView.updateTable(data);
                });
            },
示例#5
0
 initialize: function() {
     Backbone.on('login', function(credentials) {
         this.save(credentials, {
             complete: function(resp) {
                 if(resp.status === 200 && resp.responseJSON.status === 'success') {
                     window.location = resp.getResponseHeader('location');
                 }
             }
         });
     }.bind(this));
 },
    constructor() {
        super();

        this.model = MessageModel;

        IOSocket.on('message', (res) => {
            this.add({message: res.message, user: res.user});
        });

        Backbone.on('RoomChanged', this.reset, this);

    }
示例#7
0
 it('triggers event', function() {
   var courseRef;
   Backbone.on('course_add', function(model) {
     courseRef = model;
   });
   var course = new Course({
     "teacherName": "Mr. Ferrigno",
     "period": 4,
     "className": "Gym"
   });
   expect(courseRef.id).toEqual("4|Mr. Ferrigno");
 })
示例#8
0
文件: tip.js 项目: kressi/keeweb
Tip.prototype.show = function() {
    if (!Tip.enabled && !this.force) {
        return;
    }
    Backbone.on('page-geometry', this.hide);
    if (this.tipEl) {
        this.tipEl.remove();
        if (this.hideTimeout) {
            clearTimeout(this.hideTimeout);
            this.hideTimeout = null;
        }
    }
    const tipEl = this.tipEl = $('<div></div>').addClass('tip').appendTo('body').html(this.title);
    const rect = this.el[0].getBoundingClientRect();
    const tipRect = this.tipEl[0].getBoundingClientRect();
    const placement = this.placement || this.getAutoPlacement(rect, tipRect);
    tipEl.addClass('tip--' + placement);
    if (this.fast) {
        tipEl.addClass('tip--fast');
    }
    let top,
        left;
    const offset = 10;
    const sideOffset = 10;
    switch (placement) {
        case 'top':
            top = rect.top - tipRect.height - offset;
            left = rect.left + rect.width / 2 - tipRect.width / 2;
            break;
        case 'top-left':
            top = rect.top - tipRect.height - offset;
            left = rect.left + rect.width / 2 - tipRect.width + sideOffset;
            break;
        case 'bottom':
            top = rect.bottom + offset;
            left = rect.left + rect.width / 2 - tipRect.width / 2;
            break;
        case 'left':
            top = rect.top + rect.height / 2 - tipRect.height / 2;
            left = rect.left - tipRect.width - offset;
            break;
        case 'right':
            top = rect.top + rect.height / 2 - tipRect.height / 2;
            left = rect.right + offset;
            break;
    }
    tipEl.css({ top: top, left: left });
};
示例#9
0
	initialize: function (options) {
		var _this = this;

		// clear the battle-region
		Backbone.on('battle:reset', this.resetBattle.bind(this));

		// create a new search view and battleview
		this.searchView = new SearchView();
		this.battleView = new BattleView();

		// both detail views created initially
		this.details = [
			this.createDetailView(),
			this.createDetailView()
		];
	},
示例#10
0
 _oauthAuthorize: function(callback) {
     if (this._oauthToken && !this._oauthToken.expired) {
         return callback();
     }
     const opts = this._getOAuthConfig();
     const oldToken = this.runtimeData.get(this.name + 'OAuthToken');
     if (oldToken && !oldToken.expired) {
         this._oauthToken = oldToken;
         callback();
         return;
     }
     const url = opts.url + '?client_id={cid}&scope={scope}&response_type=token&redirect_uri={url}'
         .replace('{cid}', encodeURIComponent(opts.clientId))
         .replace('{scope}', encodeURIComponent(opts.scope))
         .replace('{url}', encodeURIComponent(this._getOauthRedirectUrl()));
     this.logger.debug('OAuth popup opened');
     if (!this._openPopup(url, 'OAuth', opts.width, opts.height)) {
         callback('cannot open popup');
     }
     const popupClosed = () => {
         Backbone.off('popup-closed', popupClosed);
         window.removeEventListener('message', windowMessage);
         this.logger.error('OAuth error', 'popup closed');
         callback('popup closed');
     };
     const windowMessage = e => {
         if (!e.data) {
             return;
         }
         Backbone.off('popup-closed', popupClosed);
         window.removeEventListener('message', windowMessage);
         const token = this._oauthMsgToToken(e.data);
         if (token.error) {
             this.logger.error('OAuth error', token.error, token.errorDescription);
             callback(token.error);
         } else {
             this._oauthToken = token;
             this.runtimeData.set(this.name + 'OAuthToken', token);
             this.logger.debug('OAuth success');
             callback();
         }
     };
     Backbone.on('popup-closed', popupClosed);
     window.addEventListener('message', windowMessage);
 },
示例#11
0
                    complete(err);
                    complete = null;
                }
            });
            if (config.data) {
                ps.stdin.write(config.data);
                ps.stdin.end();
            }
            return ps;
        },
        platform: function() {
            return process.platform;
        }
    };
    Backbone.on('launcher-exit-request', function() {
        setTimeout(function() { Launcher.exit(); }, 0);
    });
    Backbone.on('launcher-minimize', function() {
        setTimeout(function() { Backbone.trigger('app-minimized'); }, 0);
    });
    window.launcherOpen = function(path) {
        Backbone.trigger('launcher-open-file', path);
    };
    if (window.launcherOpenedFile) {
        console.log('Open file request', window.launcherOpenedFile);
        Backbone.trigger('launcher-open-file', window.launcherOpenedFile);
        delete window.launcherOpenedFile;
    }
}

module.exports = Launcher;
示例#12
0
		bindListeners: function(){
			Backbone.on('scoreboard:minutes', this.onMinutesChanged);
			Backbone.on('match:period-end', this.onHalfTime);
			Backbone.once('match:ticker-state', this.currentPeriod);
		},
示例#13
0
文件: view.js 项目: ioPanda/erp
import {ItemView} from 'backbone.marionette';
import template from './template.hbs';
import Backbone from 'backbone';
import Util from '../../../util.js';
import {history} from 'backbone';

export default ItemView.extend({
	template:template,
	className:'stepThree',
	initialize(options={}){
		this.step = options.step;
		this.model = [];
		Backbone.on('req',this.reqFun,this);
		Backbone.trigger('Step',this.step);//nav sync
		Backbone.trigger('req');
    },

    serializeData () {
    	return {
    		"users":this.model
    	}
    },

    changeRender () {
    	this.render();
    },

    reqFun () {
    	Util.ajax(
    		'POST',
    		' /erp/advertisement/allUserAdvertisementStatus.do',
示例#14
0
文件: index.js 项目: hoojao/keeweb
const logger = new Logger('auto-type');
const clearTextAutoTypeLog = localStorage.autoTypeDebug;

const AutoType = {
    helper: AutoTypeHelperFactory.create(),
    enabled: !!(Launcher && Launcher.autoTypeSupported),
    selectEntryView: false,
    pendingEvent: null,
    running: false,

    init(appModel) {
        if (!this.enabled) {
            return;
        }
        this.appModel = appModel;
        Backbone.on('auto-type', this.handleEvent, this);
        Backbone.on('main-window-blur main-window-will-close', this.resetPendingEvent, this);
    },

    handleEvent(e) {
        const entry = e && e.entry || null;
        logger.debug('Auto type event', entry);
        if (this.running) {
            logger.debug('Already running, skipping event');
            return;
        }
        if (entry) {
            this.hideWindow(() => { this.runAndHandleResult({ entry }); });
        } else {
            if (this.selectEntryView) {
                return;
示例#15
0
'use strict';

const Backbone = require('backbone');
const AppSettingsModel = require('../models/app-settings-model');

let IdleTracker = {
    actionTime: Date.now(),
    init: function() {
        setInterval(this.checkIdle.bind(this), 1000 * 60);
    },
    checkIdle: function() {
        let idleMinutes = (Date.now() - this.actionTime) / 1000 / 60;
        let maxIdleMinutes = AppSettingsModel.instance.get('idleMinutes');
        if (maxIdleMinutes && idleMinutes > maxIdleMinutes) {
            Backbone.trigger('user-idle');
        }
    },
    regUserAction: function() {
        this.actionTime = Date.now();
    }
};

Backbone.on('power-monitor-resume', IdleTracker.checkIdle, IdleTracker);

module.exports = IdleTracker;
示例#16
0
文件: view.js 项目: ioPanda/erp
import {ItemView} from 'backbone.marionette';
import template from './template.hbs';
import $ from 'jquery';
import _ from 'lodash';
import Backbone from 'backbone';
import Util from '../../../util.js';

export default ItemView.extend({
	template:template,
    className:'_content',

    initialize(options={}){
        this.collection=options.collection;
        Backbone.on('append',this.append,this);
        this.listenTo(this.collection, 'add', this.changeRneder);
    },

    changeRneder () {
        this.render();
        
    },
    
    append (model) {
        this.collection.add(model);
    },

    serializeData () {
    	return {
    		"developingMarket": _.invoke(this.collection, 'toJSON')
    	}
    },
示例#17
0
define(function (require) {

    'use strict';

    var $                   = require('jquery'),
        _                   = require('underscore'),
        Backbone            = require('backbone'),
        logError            = require('app/utils/error'),
        SongTpl             = require('text!tpl/song.html'),
        Controls            = require('app/utils/controls'),
        Fader               = require('app/utils/fader'),

        $songWrap           = $('#song'),
        $settings           = $('#settings'),
        $controls           = $('#controls'),
        $playBtn            = $('#play'),
        $incrementBtn       = $('#increment'),
        $decrementBtn       = $('#decrement'),
        $fontSizeEl         = $('#font-size'),

        songTpl             = _.template(SongTpl),
        options             = {speed: 1},

        songWrapHeight, $song, songHeight, deltaHeight, playTick, delayedStop;

    var play = function () {
        var that        = this,
            scrollTop   = $songWrap.scrollTop(),
            speed       = options.speed;

        if (scrollTop < deltaHeight) {
            if (delayedStop) clearTimeout(delayedStop);
            $songWrap.scrollTop(scrollTop + 1);
            playTick = setTimeout(function () { play(); }, 180 / speed);
        } else {
            Backbone.trigger('stop');
        }
    },

    stop = function () {
        clearTimeout(playTick);
    },

    calcSongHeight = function () {
        songWrapHeight  = songWrapHeight ? songWrapHeight : $songWrap.height();
        $song           = $song ? $song : $songWrap.find('pre');
        songHeight      = songHeight ? songHeight : $song.height();
        deltaHeight     = songHeight - songWrapHeight;
    };

    Controls.init(options);
    Fader.init($fontSizeEl[0]);

    Backbone.on('faderChange', function (value) {
        $songWrap[0].className = 'fontSize' + value;
    });

    Backbone.on('drawFile', function (that) {
        calcSongHeight();
    });

    Backbone.on('play', function (speed) {
        $playBtn.removeClass('paused');
        options.speed = speed;
        play();
    });

    Backbone.on('stop', function () {
        $playBtn.addClass('paused');
        stop();
    });

    document.addEventListener("pause", function () {
        Backbone.trigger('stop');
    }, false);

    Backbone.on('speedChanged', function (speed) {
        options.speed = speed;
    });

    return Backbone.View.extend({
        initialize: function (item) {
            var that        = this,
                rootPath    = Backbone.app.rootPath,
                item        = item || {},
                path        = item.path ? (rootPath + item.path) : rootPath;

            path = path.replace(/\|/g, '/');

            this.render(path);
        },

        drawFile: function (entry) {
            var that = this;

            entry.file(function (file) {
                var reader = new FileReader();

                reader.onloadend = function (e) {
                    $songWrap.html(songTpl({
                        song: {
                            text: e.target.result
                        }
                    }));
                    Backbone.trigger('drawFile', that);
                }
                reader.readAsText(file);
            }, logError);
        },

        render: function (path) {
            var that = this;

            window.resolveLocalFileSystemURL(path, function (entry) {
                that.drawFile(entry);
            }, logError);
        }
    });
});
示例#18
0
 initialize: function() {
   var studentSelect = method(this, 'studentSelect')
   Backbone.on('student_select', studentSelect);
 },
示例#19
0
文件: view.js 项目: ioPanda/erp
import {ItemView} from 'backbone.marionette';
import template from './template.hbs';
import Backbone from 'backbone';
import $ from 'jquery';

export default ItemView.extend({
	template:template,
	className:'ads-nav',
    initialize(options={}){
    	Backbone.on('Step',this.stepFun,this);
    },
    classNameArr(OneClass,TwoClass,tOneClass,tTwoClass,thOneClass){
    	let Arr = [],
    		i,
    		len = arguments.length;
    	for( i = 0;i < len; i++){
    		Arr.push(arguments[i]);
    	}
    	return Arr;
    },


    One (objOne,objTwo,classList,step) {
    	objOne.eq(step-1).addClass(classList[0]);
    	objTwo.eq(step-1).addClass(classList[1]);
    },

    Two (objOne,objTwo,classList,step){
    	this.One(objOne,objTwo,classList,step);
    	objOne.eq(step-2).addClass(classList[2]);
    	objTwo.eq(step-2).addClass(classList[3]);
示例#20
0
        'click button[name=cancel]': 'switchBack',
        'change textarea.code-content-editor': 'updatePreview',
        'keyup textarea.code-content-editor': 'updatePreview',
        'paste textarea.code-content-editor': 'updatePreview',
        'change input.code_lang': 'updateLang',
        'keyup input.code_lang': 'updateLang',
        'paste input.code_lang': 'updateLang'
    },

    initialize() {
        var $section = this.$el.closest('section.HtmlBlock');
        var $sortingButtons = jQuery('button.lower', $section);
        $sortingButtons = $sortingButtons.add(jQuery('button.raise', $section));
        $sortingButtons.addClass('no-sorting');

        Backbone.on('beforemodeswitch', this.onModeSwitch, this);
        Backbone.on('beforenavigate', this.onNavigate, this);
    },

    onNavigate(event) {
        if (!jQuery('section .block-content button[name=save]').length) {
            return;
        }
        if (event.isUserInputHandled) {
            return;
        }
        event.isUserInputHandled = true;
        Backbone.trigger('preventnavigateto', !confirm('Es gibt nicht gespeicherte Änderungen. Möchten Sie die Seite trotzdem verlassen?'));
    },

    render() {
示例#21
0
文件: view.js 项目: ioPanda/erp
import {ItemView} from 'backbone.marionette';
import template from './template.hbs';
import Backbone from 'backbone';
import Collection from './collection';
import Util from '../../../util.js';
import _ from 'lodash';

export default ItemView.extend({
	template:template,
	className:'stepTwo',
	initialize(options={}){
		this.step = options.step;
		this.model = [];
		Backbone.trigger('Step',this.step);
		Backbone.on('check',this.checkFun,this);
		Backbone.trigger('check');
		this.collection = new Collection();
	},
	serializeData () {
		console.log(this.model);
		return {
			"orders": this.model
		}
	},

	changeRender () {
		this.render();
	},

	checkFun () {
		Util.ajax(