src/n13.js
/**
             * Do main job - makes a child class
             * @param {Function} parent Parent class
             * @param {String} childNs Namespace of child class. e.g.: App.view.Widget -> 'App.view'
             * @param {String} childStr Name of child class. e.g.: 'Widget'
             * @return {Function} Updated child class
             */
Do main job - makes a child class
@param {Function} parent Parent class
@param {String} childNs Namespace of child class.
Do main job - makes a child class @param { Function } parent Parent class @param { String } childNs Namespace of child class .
function inherit(parent, childNs, childStr) {
                var parentName;
                if (isString(parent)) {
                    parentName = parent;
                    parent     = ns(parent, false);
                    if (parent === false) {
                        throw new Error('Child class (' + (childNs ? childNs + '.' : '') + childStr + ') has undefined parent class (' + parentName + ').');
                    }
                }
                 Classical inheritance: child extends parent.
                ns(childNs || global)[childStr] = child = extend(parent, child, props);
                /**
                 * Add callParent() method. It will be used for calling of method from parent class. Example:
                 *
                 *   N13.define('App.Parent', {
                 *       init: function () {
                 *           console.log('Parent');
                 *       }
                 *   });
                 *   N13.define('App.Child', {
                 *       extend : 'App.Parent',
                 *       init   : function () {
                 *           console.log('Child');
                 *           this.callParent(arguments);
                 *       }
                 *   });
                 *
                 *   var ch = new App.Child(); Child\nParent
                 *
                 * @param {Array=} args Array of arguments
                 * @return {Object|undefined} Depends on parent method
                 */
                child.prototype.callParent = function callParent(args) {
                    noinspection JSHint
                    var caller = arguments.callee.caller;
                    if (caller.base) {
                        if (caller.base[caller.fn]) {
                            noinspection JSHint
                            return caller.base[caller.fn].apply(this, args);
                        } else {
                            parent = caller.fn && caller.base.parent || caller.base.parent && caller.base.parent.init || caller.base.constructor;
                            if (parent) {
                                return parent.apply(this, args);
                            }
                        }
                    }
                    return undefined;
                };
                /**
                 *   N13.define('App.Mixin', {
                 *       init: function () {
                 *           console.log('Mixin');
                 *       }
                 *   });
                 *   N13.define('App.Class', {
                 *       mixins: {mix: 'App.Mixin'},
                 *       init  : function () {
                 *           console.log('Child');
                 *           this.callMixin('mix');
                 *       }
                 *   });
                 *
                 *   var cl = new App.Class();  Child\nMixin
                 *
                 * @param {String} mixin Name of the mixin's shortcut
                 * @param {String|Array=} method Name of the method within mixin class. undefined if call
                 * the same method. Array if call the same method with this array as arguments.
                 * @param {Array=} args Array of arguments or undefined if no arguments
                 * @return {Object} method related value
                 */
                child.prototype.callMixin = function callMixin(mixin, method, args) {
                    noinspection JSHint
                    var caller  = arguments.callee.caller;
                    var mix     = caller.cl.mixins[mixin];
                     In case if method or args is arguments, then converts it to array
                    method = isArguments(method) ? [].slice.call(method) : method;
                    args   = isArguments(args) ? [].slice.call(args) : args;
                    args   = isArray(args) ? args : isArray(method) ? method : [];
                    method = isString(method) ? method : caller.fn;
                     It's possible, that mixin or method is(are) undefined
                    if (!mix) {
                        throw new Error('Invalid mixin "' + mixin + '" in method callMixin() in class "' + this.className + '"');
                    }
                    if (!mix[method]) {
                        throw new Error('Invalid method "' + method + '" of mixin: "' + mixin + '" in class "' + this.className + '"');
                    }
                    return mix[method].apply(this, args);
                };
                return child;
            }
function inherit ( parent , childNs , childStr ) { var parentName ; if ( isString ( parent ) ) { parentName = parent ; parent = ns ( parent , false ) ; if ( parent === false ) { throw new Error ( 'Child class (' + ( childNs ? childNs + '.' : '' ) + childStr + ') has undefined parent class (' + parentName + ').' ) ; } } ns ( childNs || global ) [ childStr ] = child = extend ( parent , child , props ) ; child . prototype . callParent = function callParent ( args ) { var caller = arguments . callee . caller ; if ( caller . base ) { if ( caller . base [ caller . fn ] ) { return caller . base [ caller . fn ] . apply ( this , args ) ; } else { parent = caller . fn && caller . base . parent || caller . base . parent && caller . base . parent . init || caller . base . constructor ; if ( parent ) { return parent . apply ( this , args ) ; } } } return undefined ; } ; child . prototype . callMixin = function callMixin ( mixin , method , args ) { var caller = arguments . callee . caller ; var mix = caller . cl . mixins [ mixin ] ; method = isArguments ( method ) ? [ ] . slice . call ( method ) : method ; args = isArguments ( args ) ? [ ] . slice . call ( args ) : args ; args = isArray ( args ) ? args : isArray ( method ) ? method : [ ] ; method = isString ( method ) ? method : caller . fn ; if ( ! mix ) { throw new Error ( 'Invalid mixin "' + mixin + '" in method callMixin() in class "' + this . className + '"' ) ; } if ( ! mix [ method ] ) { throw new Error ( 'Invalid method "' + method + '" of mixin: "' + mixin + '" in class "' + this . className + '"' ) ; } return mix [ method ] . apply ( this , args ) ; } ; return child ; }
Do main job - makes a child class
 @param {Function} parent Parent class
 @param {String} childNs Namespace of child class.
Do main job - makes a child class @param { Function } parent Parent class @param { String } childNs Namespace of child class .
// // Classical inheritance: child extends parent. // /**
                 * Add callParent() method. It will be used for calling of method from parent class. Example:
                 *
                 *   N13.define('App.Parent', {
                 *       init: function () {
                 *           console.log('Parent');
                 *       }
                 *   });
                 *   N13.define('App.Child', {
                 *       extend : 'App.Parent',
                 *       init   : function () {
                 *           console.log('Child');
                 *           this.callParent(arguments);
                 *       }
                 *   });
                 *
                 *   var ch = new App.Child(); //Child\nParent
                 *
                 * @param {Array=} args Array of arguments
                 * @return {Object|undefined} Depends on parent method
                 */ //noinspection JSHint //noinspection JSHint /**
                 *   N13.define('App.Mixin', {
                 *       init: function () {
                 *           console.log('Mixin');
                 *       }
                 *   });
                 *   N13.define('App.Class', {
                 *       mixins: {mix: 'App.Mixin'},
                 *       init  : function () {
                 *           console.log('Child');
                 *           this.callMixin('mix');
                 *       }
                 *   });
                 *
                 *   var cl = new App.Class(); // Child\nMixin
                 *
                 * @param {String} mixin Name of the mixin's shortcut
                 * @param {String|Array=} method Name of the method within mixin class. undefined if call
                 * the same method. Array if call the same method with this array as arguments.
                 * @param {Array=} args Array of arguments or undefined if no arguments
                 * @return {Object} method related value
                 */ //noinspection JSHint // // In case if method or args is arguments, then converts it to array // // // It's possible, that mixin or method is(are) undefined //