Skip to content

Instantly share code, notes, and snippets.

var __extends = require('dotmvc/lib/util/extends');
var __mixin = require('dotmvc/lib/util/mixin');
var KendoChart = require('./KendoChart.js');
var KendoColumnSparkline = require('./KendoColumnSparkline.js');
// Configs
var SeriesDefaults = require('./config/SeriesDefaults.js');
var AxisDefaults = require('./config/AxisDefaults.js');
var CategoryAxis = require('./config/CategoryAxis.js');
var Tooltip = require('./config/Tooltip.js');
// in the listening view (could be HeroWidgetContainer.js or any view)
// 'someView' could be DashboardView, Footprint, or any View obj
this.listenTo(someView, 'walkthroughEvent1', this.startWalkthrough);
// in someView (that will be emitting events)
this.trigger('walkthroughEvent1');
// if you need to stop listening to an obj's event
this.stopListening(someView, 'walkthroughEvent1');
@zxqx
zxqx / main.js
Last active August 29, 2015 14:01
var $ = require('jquery');
var Q = require('q');
var moment = require('moment');
// iCal date parser
// --------------------------------------
function ICalDateParser(d)
{
this._date = d;
this.parsedDate = null;
function normalize(array, field, max)
{
var highValue = getHighValue(array, field);
var divisor = highValue / max;
return array.map(function(x) {
x[field] = x[field] / divisor;
return x;
});
}
// -------------------------------------
// Box View Model
module.exports = Box;
/**
* Box view model
* @property {object} position A list of spacial coordinates
* @property {number} width
* @property {number} height
* @constructor
Package Management
npm
https://www.npmjs.org/
need to add a package?
npm install underscore --save
bam
Bundling require, module.exports, and other node-isms down to browser-usable JS
Browserify
/**
* Set up container view
* Set up container subviews
*/
StreamController.prototype.start = function()
{
this.container = this.setupCommunityStream();
this.setupHeader();
this.setupNavigationBar();
module.exports = CSTransport;
var Promise = require('bluebird');
var HttpTransport = require('http-transport');
var jsonpClient = require('jsonp-client');
var path = require('path');
var urlUtil = require('url');
function CSTransport()
{
/**
* Display loading indicator while view model data is being synced
* Set up container view and its subviews
* Fade in container
* @return {Promise}
*/
StreamController.prototype.start = function()
{
this.container = this.setupCommunityStream();
this.loadingIndicator = this.setupLoadingIndicator();
/**
* @param {GainNode} gainAmount
*/
_turnMusicUp(gainAmount)
{
var music = this.sound.getCurrentMusic();
var currentGain = this.sound.getGainValue(music);
this.sound.fadeIn(music, 1000, currentGain, gainAmount);
}