Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
baseClassName -> simpleClassName
Browse files Browse the repository at this point in the history
Moved $log support into LegacyLogMixin
  • Loading branch information
jdillon committed Feb 11, 2013
1 parent 284fe93 commit 3e2b5f7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 29 deletions.
29 changes: 29 additions & 0 deletions nexus-webapp/src/main/webapp/js/lib/classes/NX/LegacyLogMixin.js
@@ -0,0 +1,29 @@
/*
* Sonatype Nexus (TM) Open Source Version
* Copyright (c) 2007-2012 Sonatype, Inc.
* All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
*
* This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
* which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
*
* Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
* Eclipse Foundation. All other trademarks are the property of their respective owners.
*/

/**
* Legacy $log() mixin.
*
* @since 2.4
*/
NX.define('NX.LegacyLogMixin', {

/**
* @deprecated
*/
'$log': function(message) {
NX.log.debug(this.$className + ': ' + message);
NX.log.warn('[DEPRECATED]', this.$className + '.$log() is deprecated; use NX.LogAwareMixin instead');
}

});
40 changes: 11 additions & 29 deletions nexus-webapp/src/main/webapp/js/lib/nx.define.js
Expand Up @@ -52,7 +52,7 @@ NX.define = function (className, data, createdFn) {

var i,
nameSpace,
baseClassName,
simpleClassName,
superName,
type,
requireSuper,
Expand All @@ -71,10 +71,10 @@ NX.define = function (className, data, createdFn) {
i = className.lastIndexOf('.');
if (i !== -1) {
nameSpace = className.substring(0, i);
baseClassName = className.substring(i + 1);
simpleClassName = className.substring(i + 1);
}
else {
baseClassName = className;
simpleClassName = className;
}

requireSuper = data.requireSuper;
Expand Down Expand Up @@ -137,15 +137,15 @@ NX.define = function (className, data, createdFn) {
moduleName = className.replaceAll('.', '/');

if (requiredModulePaths.length !== 0) {
NX.log.debug('Defining module: ', moduleName, ' depends: ', requiredModulePaths);
NX.log.debug('Defining module:', moduleName, 'depends:', requiredModulePaths);
}
else {
NX.log.debug('Defining module: ', moduleName);
NX.log.debug('Defining module:', moduleName);
}

define(moduleName, requiredModulePaths, function()
{
NX.log.debug('Defining class: ', className, ' super: ', superName);
NX.log.debug('Defining class:', className, 'super:', superName);

// Sanity check required classes exist
Ext.each(requiredClassNames, function(className) {
Expand All @@ -171,11 +171,11 @@ NX.define = function (className, data, createdFn) {
// Create the sub-class
type = Ext.extend(superClass, data);

// Remember class name
// Remember class name (full and simple)
type.$className = className;
type.$simpleClassName = baseClassName;
type.$simpleClassName = simpleClassName;
type.prototype.$className = className;
type.prototype.$simpleClassName = baseClassName;
type.prototype.$simpleClassName = simpleClassName;

// replace toString if its the default Object.toString
if (type.prototype.toString === Object.prototype.toString) {
Expand All @@ -188,30 +188,12 @@ NX.define = function (className, data, createdFn) {
if (mixins !== undefined) {
for(i=0; i<mixins.length; i++) {
mixin = mixins[i]; // name
NX.log.debug('Applying mixin: ', mixin);
NX.log.debug('Applying mixin:', mixin);
mixin = NX.obj(mixin); // class ref
Ext.applyIf(type.prototype, mixin.prototype);
}
}

// FIXME: Remove this and use a LogAwareMixin instead
Ext.apply(type, {
/**
* @deprecated
*/
'$log': function(message) {
NX.log.debug(className + ': ' + message);
}
});
Ext.apply(type.prototype, {
/**
* @deprecated
*/
'$log': function(message) {
NX.log.debug(className + ': ' + message);
}
});

// Apply any static members
if (statics !== undefined) {
Ext.apply(type, statics);
Expand All @@ -228,7 +210,7 @@ NX.define = function (className, data, createdFn) {
}

// Assign to global namespace
NX.obj(nameSpace)[baseClassName] = type;
NX.obj(nameSpace)[simpleClassName] = type;

// Call post-define hook
if (createdFn !== undefined) {
Expand Down

0 comments on commit 3e2b5f7

Please sign in to comment.