1/*! 2 * klass: a classical JS OOP façade 3 * https://github.com/ded/klass 4 * License MIT (c) Dustin Diaz & Jacob Thornton 2012 5 * 6 * Eric, latest version from github 7 */ 8 9!function (name, definition) { 10 if (typeof define == 'function') define(definition) 11 else if (typeof module != 'undefined') module.exports = definition() 12 else this[name] = definition() 13}('klass', function () { 14 var context = this 15 , old = context.klass 16 , f = 'function' 17 , fnTest = /xyz/.test(function () {xyz}) ? /\bsupr\b/ : /.*/ 18 , proto = 'prototype' 19 20 function klass(o) { 21 return extend.call(isFn(o) ? o : function () {}, o, 1) 22 } 23 24 function isFn(o) { 25 return typeof o === f 26 } 27 28 function wrap(k, fn, supr) { 29 return function () { 30 var tmp = this.supr 31 this.supr = supr[proto][k] 32 var undef = {}.fabricatedUndefined 33 var ret = undef 34 try { 35 ret = fn.apply(this, arguments) 36 } finally { 37 this.supr = tmp 38 } 39 return ret 40 } 41 } 42 43 function process(what, o, supr) { 44 for (var k in o) { 45 if (o.hasOwnProperty(k)) { 46 what[k] = isFn(o[k]) 47 && isFn(supr[proto][k]) 48 && fnTest.test(o[k]) 49 ? wrap(k, o[k], supr) : o[k] 50 } 51 } 52 } 53 54 function extend(o, fromSub) { 55 // must redefine noop each time so it doesn't inherit from previous arbitrary classes 56 function noop() {} 57 noop[proto] = this[proto] 58 var supr = this 59 , prototype = new noop() 60 , isFunction = isFn(o) 61 , _constructor = isFunction ? o : this 62 , _methods = isFunction ? {} : o 63 function fn() { 64 if (this.initialize) this.initialize.apply(this, arguments) 65 else { 66 fromSub || isFunction && supr.apply(this, arguments) 67 _constructor.apply(this, arguments) 68 } 69 } 70 71 fn.methods = function (o) { 72 process(prototype, o, supr) 73 fn[proto] = prototype 74 return this 75 } 76 77 fn.methods.call(fn, _methods).prototype.constructor = fn 78 79 fn.extend = arguments.callee 80 fn[proto].implement = fn.statics = function (o, optFn) { 81 o = typeof o == 'string' ? (function () { 82 var obj = {} 83 obj[o] = optFn 84 return obj 85 }()) : o 86 process(this, o, supr) 87 return this 88 } 89 90 return fn 91 } 92 93 klass.noConflict = function () { 94 context.klass = old 95 return this 96 } 97 context.klass = klass 98 99 return klass 100});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.