Last active
August 29, 2015 14:05
-
-
Save wesleytodd/9b2d7bc52c427f460dff to your computer and use it in GitHub Desktop.
Example of a very basic module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Export for Angular | |
if (angular) { | |
angular.module('vube.video', []) | |
.factory([function() { | |
return VideoSingle; | |
}]); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Requirements | |
var gulp = require('gulp'), | |
build = require('../../build'), | |
// Create the default config | |
var config = module.exports = build.DefaultModuleConfig(__dirname); | |
// The build prefix and suffix files | |
config.prefix = config.paths.r('prefix.js'); | |
config.suffix = config.paths.r('suffix.js'); | |
// The module files | |
config.addFiles([ | |
config.paths.r('video-single.js'), | |
]); | |
// The module deps | |
config.addDependencies([ | |
build.loadModuleShortcut('util'), | |
]); | |
// Set the default task | |
config.default = [ | |
config.taskName('jshint'), | |
config.taskName('watch'), | |
'serve', | |
]; | |
// Sets up the tasks for this module | |
build.setupModule(config.moduleName, config, ['karma', 'jsdoc', 'jshint', 'watch']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.vube = window.vube || {}; | |
vube.VideoSingle = (function(angular, vube) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Export for vube namespace | |
return VideoSingle; | |
})(window.angular, window.vube); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @file Video Single Model | |
* @version 1.0 | |
* @module video | |
*/ | |
/* exports VideoSingle */ | |
/** | |
* Video Single Model | |
* | |
* This represents the data and functionality for a single video instance | |
* | |
* @constructs module:video.VideoSingle | |
* @memberof module:video | |
* @extends module:util.EventEmitter | |
* @param {object} options - The video single options | |
* | |
* @requires module:vube.util.extend | |
* @requires module:vube.util.EventEmitter | |
*/ | |
var VideoSingle = function(options) { | |
this.options = vube.util.extend({}, options, VideoSingle.defaultOptions); | |
}; | |
util.extend(VideoSingle.prototype, vube.util.EventEmitter); | |
/** | |
* The default options for a `VideoSingle` | |
* | |
* @var defaultOptions | |
* @memberof module:video.VideoSingle | |
* @static | |
*/ | |
VideoSingle.defaultOptions = { | |
singleApi: '/t-api/video/' | |
}; | |
/** | |
* Gets a single video from the api | |
* | |
* @function get | |
* @memberof module:video.VideoSingle | |
* @instance | |
* @param {string} urlId - The url id to get form the api | |
* @returns {module:xhr.XHR} - The xhr instance | |
*/ | |
VideoSingle.prototype.get = function(urlId) { | |
return vube.http({ | |
url: this.options.singleApi + urlId | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
EDIT: The
jshint ignore: start|end
stuff was un-necessary because those files are not specified in the files array, so jshint should not be run on them.