Path: blob/master/extensions/admin_ui/media/javascript/esapi/Class.create.js
1154 views
/*1* Copyright (c) 2006-2025 Wade Alcorn - [email protected]2* Browser Exploitation Framework (BeEF) - https://beefproject.com3* See the file 'doc/COPYING' for copying permission4*/56/* Simple JavaScript Inheritance7* By John Resig http://ejohn.org/8* MIT Licensed.9*/10// Inspired by base2 and Prototype11(function(){12var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;1314// The base Class implementation (does nothing)15this.Class = function(){};1617// Create a new Class that inherits from this class18Class.extend = function(prop) {19var _super = this.prototype;2021// Instantiate a base class (but only create the instance,22// don't run the init constructor)23initializing = true;24var prototype = new this();25initializing = false;2627// Copy the properties over onto the new prototype28for (var name in prop) {29// Check if we're overwriting an existing function30prototype[name] = typeof prop[name] == "function" &&31typeof _super[name] == "function" && fnTest.test(prop[name]) ?32(function(name, fn){33return function() {34var tmp = this._super;3536// Add a new ._super() method that is the same method37// but on the super-class38this._super = _super[name];3940// The method only need to be bound temporarily, so we41// remove it when we're done executing42var ret = fn.apply(this, arguments);43this._super = tmp;4445return ret;46};47})(name, prop[name]) :48prop[name];49}5051// The dummy class constructor52function Class() {53// All construction is actually done in the init method54if ( !initializing && this.init )55this.init.apply(this, arguments);56}5758// Populate our constructed prototype object59Class.prototype = prototype;6061// Enforce the constructor to be what we expect62Class.constructor = Class;6364// And make this class extendable65Class.extend = arguments.callee;6667return Class;68};69})();707172