Skip to content

Commit

Permalink
use bulk-require tool to bundle all json lang files in config/languag…
Browse files Browse the repository at this point in the history
…eFiles dir
  • Loading branch information
Jeoffrey Mendez committed Oct 26, 2016
1 parent 329ec3e commit 15cb588
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
3 changes: 2 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var gulp = require('gulp'),
browserify = require('browserify'),
watchify = require('watchify'),
reactify = require('reactify'),
bulkify = require('bulkify'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
gutil = require('gulp-util'),
Expand Down Expand Up @@ -42,7 +43,7 @@ function buildJS(file, hash, watch, ugly, sourcemap, debug, externalReact) {
var props ={
entries: ['./js/controller.js'],
debug: debug,
transform: [[reactify, {}]],
transform: [reactify, bulkify],
cache: {},
packageCache: {}
};
Expand Down
16 changes: 4 additions & 12 deletions js/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ var React = require('react'),
AccessibilityControls = require('./components/accessibilityControls'),
Fullscreen = require('screenfull'),
Skin = require('./skin'),
SkinJSON = require('../config/skin');
SkinJSON = require('../config/skin'),
Bulk = require('bulk-require'),
Localization = Bulk('./config', ['languageFiles/*.json']);

OO.plugin("Html5Skin", function (OO, _, $, W) {
//Check if the player is at least v4. If not, the skin cannot load.
Expand Down Expand Up @@ -228,20 +230,10 @@ OO.plugin("Html5Skin", function (OO, _, $, W) {
$.extend(true, SkinJSON, params.skin.inline);
//override state settings with defaults from skin config and possible local storage settings
$.extend(true, this.state.closedCaptionOptions, SkinJSON.closedCaptionOptions, settings.closedCaptionOptions);

//load language jsons
var tmpLocalizableStrings = {};
SkinJSON.localization.availableLanguageFile.forEach(function(languageObj){
$.getJSON(languageObj.languageFile, _.bind(function(data) {
tmpLocalizableStrings[languageObj.language] = data;
this.renderSkin();
}, this));
}, this);

this.state.config = SkinJSON;

this.skin = ReactDOM.render(
React.createElement(Skin, {skinConfig: SkinJSON, localizableStrings: tmpLocalizableStrings, language: Utils.getLanguageToUse(SkinJSON), controller: this, closedCaptionOptions: this.state.closedCaptionOptions, pauseAnimationDisabled: this.state.pauseAnimationDisabled}), document.querySelector("#" + this.state.elementId + " .oo-player-skin")
React.createElement(Skin, {skinConfig: SkinJSON, localizableStrings: Localization.languageFiles, language: Utils.getLanguageToUse(SkinJSON), controller: this, closedCaptionOptions: this.state.closedCaptionOptions, pauseAnimationDisabled: this.state.pauseAnimationDisabled}), document.querySelector("#" + this.state.elementId + " .oo-player-skin")
);
var accessibilityControls = new AccessibilityControls(this); //keyboard support
this.state.configLoaded = true;
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
},
"devDependencies": {
"browserify": "13.0.0",
"bulk-require": "^1.0.0",
"bulkify": "^1.4.2",
"git-rev": "0.2.1",
"graceful-fs": "*",
"gulp": "3.9.1",
Expand Down

0 comments on commit 15cb588

Please sign in to comment.