Last active
August 29, 2015 14:06
-
-
Save watert/1cbd997252ab7c3764ee to your computer and use it in GitHub Desktop.
util.js / coffee without libs
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
View = do -> | |
extend = (obj,objs...)-> | |
while o = objs.shift() | |
obj[k] = o[k] for k of o | |
return obj | |
class BaseView | |
constructor:(o={})-> | |
@el = o.el | |
@$el = $(o.el) | |
@initialize?() | |
BaseView.extend = (props,statics)-> | |
class NewClass extends @ | |
extend NewClass.prototype,props | |
extend NewClass, statics | |
return NewClass | |
return BaseView |
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
/* Extracts Logics from Backbonejs */ | |
var View = (function($){ | |
var View = function(options){ | |
if(options.el){ | |
var el = this.el = options.el; | |
if($){ this.$el = $(el); } | |
} | |
if(this.initialize)this.initialize.apply(this, arguments); | |
}; | |
View.extend = function(protoProps) { | |
var parent = this; | |
var child; | |
child = function(){ return parent.apply(this, arguments); }; | |
for(var k in protoProps){ | |
child.prototype[k] = protoProps[k]; | |
} | |
child.__super__ = parent.prototype; | |
return child; | |
}; | |
return View; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment