Skip to content

Commit

Permalink
Update verstion to v0.1.0. Build v0.1.0 dist version. Add Jasmine to …
Browse files Browse the repository at this point in the history
…devDependencies.
  • Loading branch information
pazguille committed Dec 11, 2013
1 parent 46dd370 commit 59320bb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 169 deletions.
14 changes: 12 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = function (grunt) {
'banner': '<%= banner.full %>'
},
'src': ['./src/Q.js', './src/EventEmitter.js', './src/Component.js'],
'dest': './dist/<%= pkg.name %>.js'
'dest': './dist/Q.js'
}
},

Expand All @@ -46,7 +46,7 @@ module.exports = function (grunt) {

'js': {
'src': ['<%= concat.js.dest %>'],
'dest': './dist/<%= pkg.name %>.min.js'
'dest': './dist/Q.min.js'
}

},
Expand All @@ -73,6 +73,14 @@ module.exports = function (grunt) {
'private': false
}
}
},

'jasmine': {
'src': ['dist/Q.js'],
'options': {
'specs': ['tests/extend/spec.js'],
'version': '1.3.1'
}
}
});

Expand All @@ -81,9 +89,11 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-jslint');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-contrib-jasmine');

// Resgister task(s).
grunt.registerTask('default', []);
grunt.registerTask('test', ['concat', 'jasmine']);
grunt.registerTask('lint', ['concat', 'jslint']);
grunt.registerTask('doc', ['concat', 'jsdoc']);
grunt.registerTask('dev', ['concat']);
Expand Down
164 changes: 1 addition & 163 deletions dist/Q.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Balloons.js v0.0.1
* Balloons.js v0.1.0
* http://balloonsjs.com/
*
* Copyright (c) 2013, MercadoLibre.com
Expand Down Expand Up @@ -82,168 +82,6 @@

window.Q = Q;
}(this));
(function (Q) {
'use strict';

/**
* Event Emitter Class for the browser.
* @memberof ch
* @constructor
* @returns {Object} Returns a new instance of EventEmitter.
* @example
* // Create a new instance of EventEmitter.
* var emitter = new EventEmitter();
* @example
* // Inheriting from EventEmitter.
* inherits(Component, EventEmitter);
*/
function EventEmitter() {
return this;
}

/**
* Adds a listener to the collection for a specified event.
* @memberof! EventEmitter.prototype
* @function
* @param {String} event The event name to subscribe.
* @param {Function} listener Listener function.
* @param {Boolean} once Indicate if a listener function will be called only one time.
* @example
* // Will add an event listener to 'ready' event.
* emitter.on('ready', listener);
*/
EventEmitter.prototype.on = function (event, listener, once) {

this._eventsCollection = this._eventsCollection || {};

listener.once = once || false;

if (this._eventsCollection[event]) {
this._eventsCollection[event] = [];
}

this._eventsCollection[event].push(listener);

return this;
};

/**
* Adds a listener to the collection for a specified event to will execute only once.
* @memberof! EventEmitter.prototype
* @function
* @param {String} event Event name.
* @param {Function} listener Listener function.
* @returns {Object}
* @example
* // Will add an event handler to 'contentLoad' event once.
* widget.once('contentLoad', listener);
*/
EventEmitter.prototype.once = function (event, listener) {

this.on(event, listener, true);

return this;
};

/**
* Removes a listener from the collection for a specified event.
* @memberof! EventEmitter.prototype
* @function
* @param {String} event Event name.
* @param {Function} listener Listener function.
* @returns {Object}
* @example
* // Will remove event listener to 'ready' event.
* widget.off('ready', listener);
*/
EventEmitter.prototype.off = function (event, listener) {

if (this._eventsCollection) {
return this;
}

var listeners = this._eventsCollection[event],
i = 0,
len;

if (listeners !== undefined) {
len = listeners.length;
for (i; i < len; i += 1) {
if (listeners[i] === listener) {
listeners.splice(i, 1);
break;
}
}
}

return this;
};

/**
* Returns all listeners from the collection for a specified event.
* @memberof! EventEmitter.prototype
* @function
* @param {String} event The event name.
* @returns {Array}
* @example
* // Returns listeners from 'ready' event.
* widget.getListeners('ready');
*/
EventEmitter.prototype.getListeners = function (event) {

return this._eventsCollection[event];
};

/**
* Execute each item in the listener collection in order with the specified data.
* @memberof! EventEmitter.prototype
* @function
* @param {String} event The name of the event you want to emit.
* @param {...Object} var_args Data to pass to the listeners.
* @example
* // Will emit the 'ready' event with 'param1' and 'param2' as arguments.
* widget.emit('ready', 'param1', 'param2');
*/
EventEmitter.prototype.emit = function () {

var args = Array.prototype.slice.call(arguments, 0), // converted to array
event = args.shift(), // Store and remove events from args
listeners,
i = 0,
len;

if (typeof event === 'string') {
event = {'type': event};
}

if (!event.target) {
event.target = this;
}

if (this._eventsCollection !== undefined && this._eventsCollection[event.type] !== undefined) {
listeners = this._eventsCollection[event.type];
len = listeners.length;

for (i; i < len; i += 1) {
listeners[i].apply(this, args);

if (listeners[i].once) {
this.off(event.type, listeners[i]);
len -= 1;
i -= 1;
}
}
}

return this;
};

Q.observable = function (component) {
Q.inherits(component, EventEmitter);
return Q;
};

}(this.Q));
(function (window, Q) {
'use strict';

Expand Down
2 changes: 1 addition & 1 deletion dist/Q.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Q",
"version": "0.0.1",
"name": "balloons",
"version": "0.1.0",
"description": "An event-based JavaScript library to build front-end components or widgets.",
"author": "<[email protected]>",
"contributors": [
Expand All @@ -27,11 +27,12 @@
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-jasmine": "~0.5.2",
"grunt-jslint": "0.2.6",
"grunt-contrib-concat": "0.3.0",
"grunt-contrib-uglify": "0.2.2",
"grunt-jsdoc": "~0.4.0"
},
"license": "MIT",
"engine": "node >= 0.8.6"
}
}

0 comments on commit 59320bb

Please sign in to comment.