Skip to content

Commit

Permalink
[PBW-CommonJS] converted Alice to CommonJS compliant modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeoffrey Mendez committed Sep 2, 2015
1 parent 68675bf commit 736a7b2
Show file tree
Hide file tree
Showing 35 changed files with 1,968 additions and 1,824 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
build
coverage
.idea
.idea
.DS_Store
53 changes: 30 additions & 23 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,48 @@
// For dev, initiate watch by executing either `gulp` or `gulp watch`

var gulp = require('gulp'),
concat = require('gulp-concat'),
browserify = require('browserify'),
reactify = require('reactify'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
gutil = require('gulp-util'),
sourcemaps = require('gulp-sourcemaps'),
uglify = require('gulp-uglify'),
jshint = require('gulp-jshint'),
react = require('gulp-react');
shell = require('gulp-shell');

var path = {
scripts: ['./js/include/header.js', './js/components/*.js', './js/*.js', './js/include/footer.js'],
scripts: ['./js/components/*.js', './js/constants/*.js', './js/styles/*.js', './js/views/*.js', './js/*.js'],
css: ['./css/*.css'],
};

// Build All
gulp.task('build', ['buildScript', 'buildCss']);

// Build JS
gulp.task('buildScript', function() {
gulp.src(path.scripts)
.pipe(concat('html5-skin.js'))
.pipe(react())
.pipe(jshint())
.pipe(jshint.reporter())
//.pipe(uglify())
.pipe(gulp.dest('build'));
gulp.task('build', ['browserify', 'buildCss']);

// Browserify JS
gulp.task('browserify', function () {
// set up the browserify instance on a task basis
var b = browserify({
entries: './js/controller.js',
debug: true,
// defining transforms here will avoid crashing your stream
transform: [reactify]
});

return b.bundle()
.pipe(source('html5-skin.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
// Add transformation tasks to the pipeline here.
.pipe(uglify())
.on('error', gutil.log)
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./build/'));
});

// Build CSS
gulp.task('buildCss', function() {
gulp.src(path.css)
.pipe(concat('html5-skin.css'))
//.pipe(concat('html5-skin.css'))
.pipe(gulp.dest('build'));
});

Expand All @@ -40,14 +53,8 @@ gulp.task('test', shell.task(['npm test']));

// Initiate a watch
gulp.task('watch', function() {
gulp.watch(path.scripts, ['concat', 'buildScript']);
gulp.watch(path.scripts, ['browserify']);
});

// Just concat the files
gulp.task('concat', function() {
gulp.src(path.scripts)
.pipe(concat('html5-skin-concat.js'))
.pipe(gulp.dest('build'));
});
// The default task (called when you run `gulp` from cli)
gulp.task('default', ['build', 'watch']);
330 changes: 0 additions & 330 deletions js/closedCaptionPanel.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var CONSTANTS = require('./../constants/constants');

var AccessibilityControls = function (controller) {
this.controller = controller;
this.state = {
Expand All @@ -13,14 +15,14 @@ AccessibilityControls.prototype = {
var newPlayheadTime;
var newVolume;

if (e.keyCode === KEYCODES.SPACE_KEY){
if (e.keyCode === CONSTANTS.KEYCODES.SPACE_KEY){
this.controller.togglePlayPause();
}

else if ((e.keyCode === KEYCODES.DOWN_ARROW_KEY && this.controller.state.volumeState.volume > 0) || (e.keyCode === KEYCODES.UP_ARROW_KEY && this.controller.state.volumeState.volume < 1)){
else if ((e.keyCode === CONSTANTS.KEYCODES.DOWN_ARROW_KEY && this.controller.state.volumeState.volume > 0) || (e.keyCode === CONSTANTS.KEYCODES.UP_ARROW_KEY && this.controller.state.volumeState.volume < 1)){
var deltaVolumeSign = 1; // positive 1 for volume increase, negative for decrease

if (e.keyCode === KEYCODES.DOWN_ARROW_KEY){
if (e.keyCode === CONSTANTS.KEYCODES.DOWN_ARROW_KEY){
deltaVolumeSign = -1;
}
else {
Expand All @@ -31,7 +33,7 @@ AccessibilityControls.prototype = {
this.controller.setVolume(newVolume);
}

else if (e.keyCode === KEYCODES.RIGHT_ARROW_KEY || e.keyCode === KEYCODES.LEFT_ARROW_KEY){
else if (e.keyCode === CONSTANTS.KEYCODES.RIGHT_ARROW_KEY || e.keyCode === CONSTANTS.KEYCODES.LEFT_ARROW_KEY){
var shiftSign = 1; // positive 1 for fast forward, negative for rewind back

var shiftSeconds = 1;
Expand All @@ -49,7 +51,7 @@ AccessibilityControls.prototype = {
}

this.state.lastKeyDownTime = currentTime;
if (e.keyCode === KEYCODES.RIGHT_ARROW_KEY){
if (e.keyCode === CONSTANTS.KEYCODES.RIGHT_ARROW_KEY){
shiftSign = 1;
}
else {
Expand Down
31 changes: 18 additions & 13 deletions js/adPanel.js → js/components/adPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
* @class AdPanel
* @constructor
*/
var React = require('react'),
CONSTANTS = require('../constants/constants'),
InlineStyle = require('../styles/inlineStyle'),
Utils = require('./utils');

var AdPanelTopBarItem = React.createClass({
render: function() {
Expand All @@ -19,10 +23,10 @@ var AdPanelTopBarItem = React.createClass({
var AdPanel = React.createClass({
componentDidMount: function(){
if (Utils.isSafari()){
adScreenStyle.topBarStyle.display = "-webkit-flex";
InlineStyle.adScreenStyle.topBarStyle.display = "-webkit-flex";
}
else {
adScreenStyle.topBarStyle.display = "flex";
InlineStyle.adScreenStyle.topBarStyle.display = "flex";
}
},

Expand Down Expand Up @@ -51,12 +55,12 @@ var AdPanel = React.createClass({
var adTitle = this.props.currentAdsInfo.currentAdItem.name;
// AMC puts "Unknown" in the name field if ad name unavailable
if (this.isValidAdPlaybackInfo(adTitle) && this.props.controlBarWidth > 560) {
var adTitleDiv = <AdPanelTopBarItem key="AdTitle" style={adScreenStyle.adPanelTopBarTextStyle} data={adTitle} itemClassName="adTitle"/>;
var adTitleDiv = <AdPanelTopBarItem key="AdTitle" style={InlineStyle.adScreenStyle.adPanelTopBarTextStyle} data={adTitle} itemClassName="adTitle"/>;
adTopBarItems.push(adTitleDiv);
}

// Ad playback Info
var adPlaybackInfo = Utils.getLocalizedString(this.props.language, SKIN_TEXT.AD, this.props.localizableStrings);
var adPlaybackInfo = Utils.getLocalizedString(this.props.language, CONSTANTS.SKIN_TEXT.AD, this.props.localizableStrings);
var currentAdIndex = this.props.currentAdsInfo.currentAdItem.indexInPod;
var totalNumberOfAds = this.props.currentAdsInfo.numberOfAds;
if (this.isValidAdPlaybackInfo(currentAdIndex) && this.isValidAdPlaybackInfo(totalNumberOfAds)) {
Expand All @@ -66,24 +70,24 @@ var AdPanel = React.createClass({
var remainingTime = Utils.formatSeconds(parseInt(this.props.currentAdsInfo.currentAdItem.duration - this.props.currentPlayhead));
adPlaybackInfo = adPlaybackInfo + " - " + remainingTime;

var adPlaybackInfoDiv = <AdPanelTopBarItem key="adPlaybackInfo" style={adScreenStyle.adPanelTopBarTextStyle} data={adPlaybackInfo} itemClassName="adPlaybackInfo"/>;
var adPlaybackInfoDiv = <AdPanelTopBarItem key="adPlaybackInfo" style={InlineStyle.adScreenStyle.adPanelTopBarTextStyle} data={adPlaybackInfo} itemClassName="adPlaybackInfo"/>;
adTopBarItems.push(adPlaybackInfoDiv);

// Flexible space
var flexibleSpaceDiv = <AdPanelTopBarItem key="flexibleSpace" style={adScreenStyle.flexibleSpace} itemClassName="flexibleSpace"/>;
var flexibleSpaceDiv = <AdPanelTopBarItem key="flexibleSpace" style={InlineStyle.adScreenStyle.flexibleSpace} itemClassName="flexibleSpace"/>;
adTopBarItems.push(flexibleSpaceDiv);

// Learn more
if (this.props.currentAdsInfo.currentAdItem !== null && this.isValidAdPlaybackInfo(this.props.currentAdsInfo.currentAdItem.clickUrl)) {
var learnMoreText = Utils.getLocalizedString(this.props.language, SKIN_TEXT.LEARN_MORE, this.props.localizableStrings);
var learnMoreButtonDiv = <AdPanelTopBarItem key="learnMoreButton" onLearnMoreButtonClicked={this.handleLearnMoreButtonClick} style={adScreenStyle.learnMoreButtonStyle} data={learnMoreText} itemClassName="learnMore"/>;
var learnMoreText = Utils.getLocalizedString(this.props.language, CONSTANTS.SKIN_TEXT.LEARN_MORE, this.props.localizableStrings);
var learnMoreButtonDiv = <AdPanelTopBarItem key="learnMoreButton" onLearnMoreButtonClicked={this.handleLearnMoreButtonClick} style={InlineStyle.adScreenStyle.learnMoreButtonStyle} data={learnMoreText} itemClassName="learnMore"/>;
adTopBarItems.push(learnMoreButtonDiv);
}

// Skip
if (this.props.currentAdsInfo.currentAdItem.skippable) {
var skipButtonText = Utils.getLocalizedString(this.props.language, SKIN_TEXT.SKIP_AD, this.props.localizableStrings);
var skipButtonDiv = <AdPanelTopBarItem key="skipButton" style={adScreenStyle.skipButtonStyle} data={skipButtonText} itemClassName="skip"/>;
var skipButtonText = Utils.getLocalizedString(this.props.language, CONSTANTS.SKIN_TEXT.SKIP_AD, this.props.localizableStrings);
var skipButtonDiv = <AdPanelTopBarItem key="skipButton" style={InlineStyle.adScreenStyle.skipButtonStyle} data={skipButtonText} itemClassName="skip"/>;
adTopBarItems.push(skipButtonDiv);
}
return adTopBarItems;
Expand All @@ -93,11 +97,12 @@ var AdPanel = React.createClass({
render: function() {
var adTopBarItems = this.populateAdTopBar();
return (
<div style={adScreenStyle.panelStyle}>
<div className="adTopBar" style={adScreenStyle.topBarStyle}>
<div style={InlineStyle.adScreenStyle.panelStyle}>
<div className="adTopBar" style={InlineStyle.adScreenStyle.topBarStyle}>
{adTopBarItems}
</div>
</div>
);
}
});
});
module.exports = AdPanel;
Loading

0 comments on commit 736a7b2

Please sign in to comment.