Permalink
Browse files

Initial checkin

  • Loading branch information...
1 parent 310b11b commit 1a8ea74e7219bed18f46049f30c01470374cca6f @gcpantazis committed Jul 1, 2012
Showing with 166 additions and 1 deletion.
  1. +22 −0 LICENSE-MIT
  2. +9 −1 README.md
  3. +95 −0 classreset.js
  4. +1 −0 index.js
  5. +39 −0 package.json
View
@@ -0,0 +1,22 @@
+Copyright (c) 2012 George Pantazis
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
View
@@ -1,4 +1,12 @@
node-backbone
=============
-Experimental package to give (very very) basic Backbone structures to node projects.
+Experimental package to give (very very) basic Backbone structures to node projects.
+
+##Changelog
+
+* v0.1.0 Initial release
+
+## License
+Copyright (c) 2012 George Pantazis
+Licensed under the MIT license.
View
@@ -0,0 +1,95 @@
+
+var Backbone = require('backbone'),
+ _ = require('underscore');
+
+// Reset functionality of Backbone.View
+
+var View = Backbone.View = function(options) {
+ this.cid = _.uniqueId('View');
+ this._configure(options || {});
+
+ if (!this.route) {
+ console.log('Error: When instantiating a new View, route was not provided.');
+ return;
+ }
+
+ this.initialize.apply(this, arguments);
+};
+
+var viewOptions = ['route'];
+
+_.extend(View.prototype, null, {
+
+ initialize: function(){},
+
+ _configure: function(options) {
+ if (this.options) options = _.extend({}, this.options, options);
+ for (var i = 0, l = viewOptions.length; i < l; i++) {
+ var attr = viewOptions[i];
+ if (options[attr]) this[attr] = options[attr];
+ }
+ this.options = options;
+ }
+
+});
+
+// Reset functionality of Backbone.Router
+
+var Router = Backbone.Router = function(options) {
+ this.cid = _.uniqueId('Router');
+ this._configure(options || {});
+ this.initialize.apply(this, arguments);
+};
+
+var routerOptions = ['attributes'];
+
+_.extend(Router.prototype, null, {
+
+ initialize: function(){},
+
+ _configure: function(options) {
+ if (this.options) options = _.extend({}, this.options, options);
+ for (var i = 0, l = routerOptions.length; i < l; i++) {
+ var attr = routerOptions[i];
+ if (options[attr]) this[attr] = options[attr];
+ }
+ this.options = options;
+ }
+
+});
+
+// Shared Extension Functions
+
+var extend = function (protoProps, classProps) {
+ var child = inherits(this, protoProps, classProps);
+ child.extend = this.extend;
+ return child;
+};
+
+View.extend = Router.extend = extend;
+
+var ctor = function(){};
+
+var inherits = function(parent, protoProps, staticProps) {
+
+ var child;
+
+ if (protoProps && protoProps.hasOwnProperty('constructor')) {
+ child = protoProps.constructor;
+ } else {
+ child = function(){ parent.apply(this, arguments); };
+ }
+
+ _.extend(child, parent);
+
+ ctor.prototype = parent.prototype;
+ child.prototype = new ctor();
+
+ if (protoProps) _.extend(child.prototype, protoProps);
+ if (staticProps) _.extend(child, staticProps);
+
+ child.prototype.constructor = child;
+ child.__super__ = parent.prototype;
+
+ return child;
+};
View
@@ -0,0 +1 @@
+module.exports = require('./classreset');
View
@@ -0,0 +1,39 @@
+{
+ "name": "node-backbone",
+ "description": "Experimental package to give (very very) basic Backbone structures to node projects",
+ "version": "0.1.0",
+ "homepage": "https://github.com/gcpantazis/node-backbone",
+ "author": {
+ "name": "George Pantazis",
+ "email": "gcpantazis@gmail.com"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/gcpantazis/node-backbone.git"
+ },
+ "bugs": {
+ "url": "https://github.com/gcpantazis/node-backbone/issues"
+ },
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "https://github.com/gcpantazis/node-backbone/blob/master/LICENSE-MIT"
+ }
+ ],
+ "main": "index.js",
+ "engines": {
+ "node": ">=0.6.14"
+ },
+ "dependencies": {
+ "underscore": ">=1.3.1",
+ "backbone": ">=0.9.2"
+ },
+ "devDependencies": {},
+ "_id": "node-backbone@0.1.0",
+ "optionalDependencies": {},
+ "_engineSupported": true,
+ "_npmVersion": "1.1.15",
+ "_nodeVersion": "v0.6.14",
+ "_defaultsLoaded": true,
+ "_from": "node-backbone@>= 0.1.0"
+}

0 comments on commit 1a8ea74

Please sign in to comment.