diff --git a/core-js/pom.xml b/core-js/pom.xml index af3ef427..cf7c2fe1 100644 --- a/core-js/pom.xml +++ b/core-js/pom.xml @@ -50,13 +50,11 @@ ${basedir}/target/tmp/header-min.js ${basedir}/target/tmp/Functions-min.js - ${basedir}/target/tmp/log4js-min.js ${basedir}/target/tmp/Monitor-min.js ${basedir}/target/tmp/Point-min.js ${basedir}/target/tmp/Utils-min.js ${basedir}/target/tmp/WaitDialog-min.js ${basedir}/target/tmp/footer-min.js - ${basedir}/target/tmp/Executor-min.js diff --git a/core-js/src/main/javascript/Executor.js b/core-js/src/main/javascript/Executor.js deleted file mode 100644 index 00be08aa..00000000 --- a/core-js/src/main/javascript/Executor.js +++ /dev/null @@ -1,55 +0,0 @@ -/* -* Copyright [2011] [wisemapping] -* -* Licensed under WiseMapping Public License, Version 1.0 (the "License"). -* It is basically the Apache License, Version 2.0 (the "License") plus the -* "powered by wisemapping" text requirement on every single page; -* you may not use this file except in compliance with the License. -* You may obtain a copy of the license at -* -* http://www.wisemapping.org/license -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. - */ - -/** - * I need this class to clean up things after loading has finished. Without this, async functions at startup are a - * nightmare. - */ - -core.Executor = new Class({ - options:{ - isLoading:true - }, - initialize:function(options){ - this._pendingFunctions=[]; - }, - setLoading:function(isLoading){ - this.options.isLoading = isLoading; - if(!isLoading){ - this._pendingFunctions.forEach(function(item){ - var result = item.fn.attempt(item.args, item.bind); - $assert(result!=false, "execution failed"); - }); - this._pendingFunctions=[]; - } - }, - isLoading:function(){ - return this.options.isLoading; - }, - delay:function(fn, delay, bind, args){ - if(this.options.isLoading){ - this._pendingFunctions.push({fn:fn, bind:bind, args:args}); - } - else{ - fn.delay(delay, bind, args); - } - } - -}); - -core.Executor.instance = new core.Executor(); \ No newline at end of file diff --git a/core-js/src/main/javascript/Point.js b/core-js/src/main/javascript/Point.js index 13ffceb5..5e63eed6 100644 --- a/core-js/src/main/javascript/Point.js +++ b/core-js/src/main/javascript/Point.js @@ -1,44 +1,43 @@ /* -* Copyright [2011] [wisemapping] -* -* Licensed under WiseMapping Public License, Version 1.0 (the "License"). -* It is basically the Apache License, Version 2.0 (the "License") plus the -* "powered by wisemapping" text requirement on every single page; -* you may not use this file except in compliance with the License. -* You may obtain a copy of the license at -* -* http://www.wisemapping.org/license -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright [2011] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -core.Point = function(x, y) -{ - this.x = x; - this.y = y; -}; +core.Point = new Class({ + initialize : function(x, y) { + this.x = x; + this.y = y; + }, -core.Point.prototype.setValue = function(x, y) -{ - this.x = x; - this.y = y; -}; + setValue : function(x, y) { + this.x = x; + this.y = y; + }, -core.Point.prototype.inspect = function() -{ - return "{x:" + this.x + ",y:" + this.y + "}"; -}; + inspect : function() { + return "{x:" + this.x + ",y:" + this.y + "}"; + }, -core.Point.prototype.clone = function() -{ - return new core.Point(this.x, this.y); -}; + clone : function() { + return new core.Point(this.x, this.y); + }, -core.Point.fromString = function(point) { - var values = point.split(','); - return new core.Point(values[0], values[1]); -}; + fromString : + function(point) { + var values = point.split(','); + return new core.Point(values[0], values[1]); + } +}); diff --git a/core-js/src/main/javascript/log4js.js b/core-js/src/main/javascript/log4js.js deleted file mode 100644 index 7f86e7ee..00000000 --- a/core-js/src/main/javascript/log4js.js +++ /dev/null @@ -1,2505 +0,0 @@ -/* - * Copyright [2011] [wisemapping] -* -* Licensed under WiseMapping Public License, Version 1.0 (the "License"). -* It is basically the Apache License, Version 2.0 (the "License") plus the -* "powered by wisemapping" text requirement on every single page; -* you may not use this file except in compliance with the License. -* You may obtain a copy of the license at -* -* http://www.wisemapping.org/license -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. - */ - -/*jsl:option explicit*/ - -/** - * @fileoverview log4js is a library to log in JavaScript in similar manner - * than in log4j for Java. The API should be nearly the same. - * - * This file contains all log4js code and is the only file required for logging. - * - *

Example:

- *
- *  var log = new Log4js.getLogger("some-category-name"); //create logger instance
- *  log.setLevel(Log4js.Level.TRACE); //set the Level
- *  log.addAppender(new ConsoleAppender(log, false)); // console that launches in new window
- 
- *  // if multiple appenders are set all will log
- *  log.addAppender(new ConsoleAppender(log, true)); // console that is in-line in the page
- *  log.addAppender(new FileAppender("C:\\somefile.log")); // file appender logs to C:\\somefile.log
- * 
- *  ...
- * 
- *  //call the log
- *  log.trace("trace me" );
- * 
- * - * @version 0.3 - * @author Stephan Strittmatter - http://jroller.com/page/stritti - * @author Seth Chisamore - http://www.chisamore.com - * @since 2005-05-20 - * Website: http://log4js.berlios.de - */ -var Log4js = { - - /** - * Current version of log4js. - * @static - * @final - */ - version: "1.0", - - /** - * Date of logger initialized. - * @static - * @final - */ - applicationStartDate: new Date(), - - /** - * Hashtable of loggers. - * @static - * @final - * @private - */ - loggers: {}, - - /** - * Get a logger instance. Instance is cached on categoryName level. - * @param {String} categoryName name of category to log to. - * @return {Logger} instance of logger for the category - * @static - */ - getLogger: function(categoryName) { - - // Use default logger if categoryName is not specified or invalid - if (!(typeof categoryName == "string")) { - categoryName = "[default]"; - } - - if (!Log4js.loggers[categoryName]) { - // Create the logger for this name if it doesn't already exist - Log4js.loggers[categoryName] = new Log4js.Logger(categoryName); - } - - return Log4js.loggers[categoryName]; - }, - - /** - * Get the default logger instance. - * @return {Logger} instance of default logger - * @static - */ - getDefaultLogger: function() { - return Log4js.getLogger("[default]"); - }, - - /** - * Atatch an observer function to an elements event browser independent. - * - * @param element element to attach event - * @param name name of event - * @param observer observer method to be called - * @private - */ - attachEvent: function (element, name, observer) { - if (element.addEventListener) { //DOM event model - element.addEventListener(name, observer, false); - } else if (element.attachEvent) { //M$ event model - element.attachEvent('on' + name, observer); - } - } - - /** - * Load a JS-script dynamically. - * @param {String} src - */ -/* $import: function (src) { - var documentScripts = document.getElementsByTagName("script"); - - for (index = 0; index < documentScripts.length; ++index) - { - var documentScript = documentScripts[index]; - if (documentScript.src == src) { - return false; - } - } - - var script = document.createElement('script'); - script.type = 'text/javascript'; - script.src = src; - document.getElementsByTagName('head')[0].appendChild(script); - - return true; - } - */ -}; - -/** - * Internal object extension (OO) methods. - * - * @private - * @ignore - */ -Log4js.extend = function(destination, source) { - for (property in source) { - destination[property] = source[property]; - } - return destination; -} - -/** - * Functions taken from Prototype library, - * didn't want to require for just few functions. - * More info at {@link http://prototype.conio.net/} - * @private - */ -Log4js.bind = function(fn, object) { - return function() { - return fn.apply(object, arguments); - }; -}; - -/** - * Log4js.Level Enumeration. Do not use directly. Use static objects instead. - * @constructor - * @param {Number} level number of level - * @param {String} levelString String representation of level - * @private - */ -Log4js.Level = function(level, levelStr) { - this.level = level; - this.levelStr = levelStr; -}; - -Log4js.Level.prototype = { - /** - * converts given String to corresponding Level - * @param {String} sArg String value of Level - * @param {Log4js.Level} defaultLevel default Level, if no String representation - * @return Level object - * @type Log4js.Level - */ - toLevel: function(sArg, defaultLevel) { - - if(sArg === null) { - return defaultLevel; - } - - if(typeof sArg == "string") { - var s = sArg.toUpperCase(); - if(s == "ALL") {return Log4js.Level.ALL;} - if(s == "DEBUG") {return Log4js.Level.DEBUG;} - if(s == "INFO") {return Log4js.Level.INFO;} - if(s == "WARN") {return Log4js.Level.WARN;} - if(s == "ERROR") {return Log4js.Level.ERROR;} - if(s == "FATAL") {return Log4js.Level.FATAL;} - if(s == "OFF") {return Log4js.Level.OFF;} - if(s == "TRACE") {return Log4js.Level.TRACE;} - return defaultLevel; - } else if(typeof sArg == "number") { - switch(sArg) { - case ALL_INT: return Log4js.Level.ALL; - case DEBUG_INT: return Log4js.Level.DEBUG; - case INFO_INT: return Log4js.Level.INFO; - case WARN_INT: return Log4js.Level.WARN; - case ERROR_INT: return Log4js.Level.ERROR; - case FATAL_INT: return Log4js.Level.FATAL; - case OFF_INT: return Log4js.Level.OFF; - case TRACE_INT: return Log4js.Level.TRACE; - default: return defaultLevel; - } - } else { - return defaultLevel; - } - }, - /** - * @return converted Level to String - * @type String - */ - toString: function() { - return this.levelStr; - }, - /** - * @return internal Number value of Level - * @type Number - */ - valueOf: function() { - return this.level; - } -}; - -// Static variables -/** - * @private - */ -Log4js.Level.OFF_INT = Number.MAX_VALUE; -/** - * @private - */ -Log4js.Level.FATAL_INT = 50000; -/** - * @private - */ -Log4js.Level.ERROR_INT = 40000; -/** - * @private - */ -Log4js.Level.WARN_INT = 30000; -/** - * @private - */ -Log4js.Level.INFO_INT = 20000; -/** - * @private - */ -Log4js.Level.DEBUG_INT = 10000; -/** - * @private - */ -Log4js.Level.TRACE_INT = 5000; -/** - * @private - */ -Log4js.Level.ALL_INT = Number.MIN_VALUE; - -/** - * Logging Level OFF - all disabled - * @type Log4js.Level - * @static - */ -Log4js.Level.OFF = new Log4js.Level(Log4js.Level.OFF_INT, "OFF"); -/** - * Logging Level Fatal - * @type Log4js.Level - * @static - */ -Log4js.Level.FATAL = new Log4js.Level(Log4js.Level.FATAL_INT, "FATAL"); -/** - * Logging Level Error - * @type Log4js.Level - * @static - */ -Log4js.Level.ERROR = new Log4js.Level(Log4js.Level.ERROR_INT, "ERROR"); -/** - * Logging Level Warn - * @type Log4js.Level - * @static - */ -Log4js.Level.WARN = new Log4js.Level(Log4js.Level.WARN_INT, "WARN"); -/** - * Logging Level Info - * @type Log4js.Level - * @static - */ -Log4js.Level.INFO = new Log4js.Level(Log4js.Level.INFO_INT, "INFO"); -/** - * Logging Level Debug - * @type Log4js.Level - * @static - */ -Log4js.Level.DEBUG = new Log4js.Level(Log4js.Level.DEBUG_INT, "DEBUG"); -/** - * Logging Level Trace - * @type Log4js.Level - * @static - */ -Log4js.Level.TRACE = new Log4js.Level(Log4js.Level.TRACE_INT, "TRACE"); -/** - * Logging Level All - All traces are enabled - * @type Log4js.Level - * @static - */ -Log4js.Level.ALL = new Log4js.Level(Log4js.Level.ALL_INT, "ALL"); - -/** - * Log4js CustomEvent - * @constructor - * @author Corey Johnson - original code in Lumberjack (http://gleepglop.com/javascripts/logger/) - * @author Seth Chisamore - adapted for Log4js - * @private - */ -Log4js.CustomEvent = function() { - this.listeners = []; -}; - -Log4js.CustomEvent.prototype = { - - /** - * @param method method to be added - */ - addListener : function(method) { - this.listeners.push(method); - }, - - /** - * @param method method to be removed - */ - removeListener : function(method) { - var foundIndexes = this.findListenerIndexes(method); - - for(var i = 0; i < foundIndexes.length; i++) { - this.listeners.splice(foundIndexes[i], 1); - } - }, - - /** - * @param handler - */ - dispatch : function(handler) { - for(var i = 0; i < this.listeners.length; i++) { - try { - this.listeners[i](handler); - } - catch (e) { - log4jsLogger.warn("Could not run the listener " + this.listeners[i] + ". \n" + e); - } - } - }, - - /** - * @private - * @param method - */ - findListenerIndexes : function(method) { - var indexes = []; - for(var i = 0; i < this.listeners.length; i++) { - if (this.listeners[i] == method) { - indexes.push(i); - } - } - - return indexes; - } -}; - -/** - * Models a logging event. - * @constructor - * @param {String} categoryName name of category - * @param {Log4js.Level} level level of message - * @param {String} message message to log - * @param {Log4js.Logger} logger the associated logger - * @author Seth Chisamore - */ -Log4js.LoggingEvent = function(categoryName, level, message, exception, logger) { - /** - * the timestamp of the Logging Event - * @type Date - * @private - */ - this.startTime = new Date(); - /** - * category of event - * @type String - * @private - */ - this.categoryName = categoryName; - /** - * the logging message - * @type String - * @private - */ - this.message = message; - /** - * the logging exception - * @type Exception - * @private - */ - this.exception = exception; - /** - * level of log - * @type Log4js.Level - * @private - */ - this.level = level; - /** - * reference to logger - * @type Log4js.Logger - * @private - */ - this.logger = logger; -}; - -Log4js.LoggingEvent.prototype = { - /** - * get the timestamp formatted as String. - * @return {String} formatted timestamp - * @see Log4js#setDateFormat() - */ - getFormattedTimestamp: function() { - if(this.logger) { - return this.logger.getFormattedTimestamp(this.startTime); - } else { - return this.startTime.toGMTString(); - } - } -}; - -/** - * Logger to log messages to the defined appender.

- * Default appender is Appender, which is ignoring all messages. Please - * use setAppender() to set a specific appender (e.g. WindowAppender). - * use {@see Log4js#getLogger(String)} to get an instance. - * @constructor - * @param name name of category to log to - * @author Stephan Strittmatter - */ -Log4js.Logger = function(name) { - this.loggingEvents = []; - this.appenders = []; - /** category of logger */ - this.category = name || ""; - /** level to be logged */ - this.level = Log4js.Level.FATAL; - - this.dateformat = Log4js.DateFormatter.DEFAULT_DATE_FORMAT; - this.dateformatter = new Log4js.DateFormatter(); - - this.onlog = new Log4js.CustomEvent(); - this.onclear = new Log4js.CustomEvent(); - - /** appender to write in */ - this.appenders.push(new Log4js.Appender(this)); - - // if multiple log objects are instantiated this will only log to the log - // object that is declared last can't seem to get the attachEvent method to - // work correctly - try { - window.onerror = this.windowError.bind(this); - } catch (e) { - //log4jsLogger.fatal(e); - } -}; - -Log4js.Logger.prototype = { - - /** - * add additional appender. DefaultAppender always is there. - * @param appender additional wanted appender - */ - addAppender: function(appender) { - if (appender instanceof Log4js.Appender) { - appender.setLogger(this); - this.appenders.push(appender); - } else { - throw "Not instance of an Appender: " + appender; - } - }, - - /** - * set Array of appenders. Previous Appenders are cleared and removed. - * @param {Array} appenders Array of Appenders - */ - setAppenders: function(appenders) { - //clear first all existing appenders - for(var i = 0; i < this.appenders.length; i++) { - this.appenders[i].doClear(); - } - - this.appenders = appenders; - - for(var j = 0; j < this.appenders.length; j++) { - this.appenders[j].setLogger(this); - } - }, - - /** - * Set the Loglevel default is LogLEvel.TRACE - * @param level wanted logging level - */ - setLevel: function(level) { - this.level = level; - }, - - /** - * main log method logging to all available appenders - * @private - */ - log: function(logLevel, message, exception) { - var loggingEvent = new Log4js.LoggingEvent(this.category, logLevel, - message, exception, this); - this.loggingEvents.push(loggingEvent); - this.onlog.dispatch(loggingEvent); - }, - - /** clear logging */ - clear : function () { - try{ - this.loggingEvents = []; - this.onclear.dispatch(); - } catch(e){} - }, - /** checks if Level Trace is enabled */ - isTraceEnabled: function() { - if (this.level.valueOf() <= Log4js.Level.TRACE.valueOf()) { - return true; - } - return false; - }, - /** - * Trace messages - * @param message {Object} message to be logged - */ - trace: function(message) { - if (this.isTraceEnabled()) { - this.log(Log4js.Level.TRACE, message, null); - } - }, - /** checks if Level Debug is enabled */ - isDebugEnabled: function() { - if (this.level.valueOf() <= Log4js.Level.DEBUG.valueOf()) { - return true; - } - return false; - }, - /** - * Debug messages - * @param message {Object} message to be logged - */ - debug: function(message) { - if (this.isDebugEnabled()) { - this.log(Log4js.Level.DEBUG, message, null); - } - }, - /** - * Debug messages - * @param {Object} message message to be logged - * @param {Throwable} throwable - */ - debug: function(message, throwable) { - if (this.isDebugEnabled()) { - this.log(Log4js.Level.DEBUG, message, throwable); - } - }, - /** checks if Level Info is enabled */ - isInfoEnabled: function() { - if (this.level.valueOf() <= Log4js.Level.INFO.valueOf()) { - return true; - } - return false; - }, - /** - * logging info messages - * @param {Object} message message to be logged - */ - info: function(message) { - if (this.isInfoEnabled()) { - this.log(Log4js.Level.INFO, message, null); - } - }, - /** - * logging info messages - * @param {Object} message message to be logged - * @param {Throwable} throwable - */ - info: function(message, throwable) { - if (this.isInfoEnabled()) { - this.log(Log4js.Level.INFO, message, throwable); - } - }, - /** checks if Level Warn is enabled */ - isWarnEnabled: function() { - if (this.level.valueOf() <= Log4js.Level.WARN.valueOf()) { - return true; - } - return false; - }, - - /** logging warn messages */ - warn: function(message) { - if (this.isWarnEnabled()) { - this.log(Log4js.Level.WARN, message, null); - } - }, - /** logging warn messages */ - warn: function(message, throwable) { - if (this.isWarnEnabled()) { - this.log(Log4js.Level.WARN, message, throwable); - } - }, - /** checks if Level Error is enabled */ - isErrorEnabled: function() { - if (this.level.valueOf() <= Log4js.Level.ERROR.valueOf()) { - return true; - } - return false; - }, - /** logging error messages */ - error: function(message) { - if (this.isErrorEnabled()) { - this.log(Log4js.Level.ERROR, message, null); - } - }, - /** logging error messages */ - error: function(message, throwable) { - if (this.isErrorEnabled()) { - this.log(Log4js.Level.ERROR, message, throwable); - } - }, - /** checks if Level Fatal is enabled */ - isFatalEnabled: function() { - if (this.level.valueOf() <= Log4js.Level.FATAL.valueOf()) { - return true; - } - return false; - }, - /** logging fatal messages */ - fatal: function(message) { - if (this.isFatalEnabled()) { - this.log(Log4js.Level.FATAL, message, null); - } - }, - /** logging fatal messages */ - fatal: function(message, throwable) { - if (this.isFatalEnabled()) { - this.log(Log4js.Level.FATAL, message, throwable); - } - }, - /** - * Capture main window errors and log as fatal. - * @private - */ - windowError: function(msg, url, line){ - var message = "Error in (" + (url || window.location) + ") on line "+ line +" with message (" + msg + ")"; - this.log(Log4js.Level.FATAL, message, null); - }, - - /** - * Set the date format of logger. Following switches are supported: - * - * @param {String} format format String for the date - * @see #getTimestamp - */ - setDateFormat: function(format) { - this.dateformat = format; - }, - - /** - * Generates a timestamp using the format set in {Log4js.setDateFormat}. - * @param {Date} date the date to format - * @see #setDateFormat - * @return A formatted timestamp with the current date and time. - */ - getFormattedTimestamp: function(date) { - return this.dateformatter.formatDate(date, this.dateformat); - } -}; - -/** - * Abstract base class for other appenders. - * It is doing nothing. - * - * @constructor - * @param {Log4js.Logger} logger log4js instance this appender is attached to - * @author Stephan Strittmatter - */ -Log4js.Appender = function () { - /** - * Reference to calling logger - * @type Log4js.Logger - * @private - */ - this.logger = null; -}; - -Log4js.Appender.prototype = { - /** - * appends the given loggingEvent appender specific - * @param {Log4js.LoggingEvent} loggingEvent loggingEvent to append - */ - doAppend: function(loggingEvent) { - return; - }, - /** - * clears the Appender - */ - doClear: function() { - return; - }, - - /** - * Set the Layout for this appender. - * @param {Log4js.Layout} layout Layout for formatting loggingEvent - */ - setLayout: function(layout){ - this.layout = layout; - }, - /** - * Set reference to the logger. - * @param {Log4js.Logger} the invoking logger - */ - setLogger: function(logger){ - // add listener to the logger methods - logger.onlog.addListener(Log4js.bind(this.doAppend, this)); - logger.onclear.addListener(Log4js.bind(this.doClear, this)); - - this.logger = logger; - } -}; - -/** - * Interface for Layouts. - * Use this Layout as "interface" for other Layouts. It is doing nothing. - * - * @constructor - * @author Stephan Strittmatter - */ -Log4js.Layout = function(){return;}; -Log4js.Layout.prototype = { - /** - * Implement this method to create your own layout format. - * @param {Log4js.LoggingEvent} loggingEvent loggingEvent to format - * @return formatted String - * @type String - */ - format: function(loggingEvent) { - return ""; - }, - /** - * Returns the content type output by this layout. - * @return The base class returns "text/plain". - * @type String - */ - getContentType: function() { - return "text/plain"; - }, - /** - * @return Returns the header for the layout format. The base class returns null. - * @type String - */ - getHeader: function() { - return null; - }, - /** - * @return Returns the footer for the layout format. The base class returns null. - * @type String - */ - getFooter: function() { - return null; - }, - - /** - * @return Separator between events - * @type String - */ - getSeparator: function() { - return ""; - } -}; - -/** - * Console Appender writes the logs to a console. If "inline" is - * set to "false" the console launches in another window otherwise - * the window is inline on the page and toggled on and off with "Alt-D". - * Note: At FireFox &gb; 2.0 the keystroke is little different now: "SHIFT+ALT+D". - * - * @constructor - * @extends Log4js.Appender - * @param {boolean} isInline boolean value that indicates whether the console be placed inline, default is to launch in new window - * - * @author Corey Johnson - original console code in Lumberjack (http://gleepglop.com/javascripts/logger/) - * @author Seth Chisamore - adapted for use as a log4js appender - */ -Log4js.ConsoleAppender = function(isInline) { - - /** - * @type Log4js.Layout - * @private - */ - this.layout = new Log4js.PatternLayout(Log4js.PatternLayout.TTCC_CONVERSION_PATTERN); - /** - * @type boolean - * @private - */ - this.inline = isInline; - - /** - * @type String - * @private - */ - this.accesskey = "d"; - - /** - * @private - */ - this.tagPattern = null; - - this.commandHistory = []; - this.commandIndex = 0; - - /** - * true if popup is blocked. - */ - this.popupBlocker = false; - - /** - * current output div-element. - */ - this.outputElement = null; - - this.docReference = null; - this.winReference = null; - - if(this.inline) { - Log4js.attachEvent(window, 'load', Log4js.bind(this.initialize, this)); - } -}; - -Log4js.ConsoleAppender.prototype = Log4js.extend(new Log4js.Appender(), { - - /** - * Set the access key to show/hide the inline console (default "e;d"e;) - * @param key access key to show/hide the inline console - */ - setAccessKey : function(key) { - this.accesskey = key; - }, - - /** - * @private - */ - initialize : function() { - - if(!this.inline) { - var doc = null; - var win = null; - window.top.consoleWindow = window.open("", this.logger.category, - "left=0,top=0,width=700,height=700,scrollbars=no,status=no,resizable=yes;toolbar=no"); - window.top.consoleWindow.opener = self; - win = window.top.consoleWindow; - - if (!win) { - this.popupBlocker=true; - alert("Popup window manager blocking the Log4js popup window to bedisplayed.\n\n" - + "Please disabled this to properly see logged events."); - } else { - - doc = win.document; - doc.open(); - doc.write("\n\n"); - doc.write("Log4js - " + this.logger.category + "\n"); - doc.write("\n"); - win.blur(); - win.focus(); - } - - this.docReference = doc; - this.winReference = win; - } else { - this.docReference = document; - this.winReference = window; - } - - this.outputCount = 0; - this.tagPattern = ".*"; - - // I hate writing javascript in HTML... but what's a better alternative - this.logElement = this.docReference.createElement('div'); - this.docReference.body.appendChild(this.logElement); - this.logElement.style.display = 'none'; - - this.logElement.style.position = "absolute"; - this.logElement.style.left = '0px'; - this.logElement.style.width = '100%'; - - this.logElement.style.textAlign = "left"; - this.logElement.style.fontFamily = "lucida console"; - this.logElement.style.fontSize = "100%"; - this.logElement.style.backgroundColor = 'darkgray'; - this.logElement.style.opacity = 0.9; - this.logElement.style.zIndex = 2000; - - // Add toolbarElement - this.toolbarElement = this.docReference.createElement('div'); - this.logElement.appendChild(this.toolbarElement); - this.toolbarElement.style.padding = "0 0 0 2px"; - - // Add buttons - this.buttonsContainerElement = this.docReference.createElement('span'); - this.toolbarElement.appendChild(this.buttonsContainerElement); - - if(this.inline) { - var closeButton = this.docReference.createElement('button'); - closeButton.style.cssFloat = "right"; - closeButton.style.styleFloat = "right"; // IE dom bug...doesn't understand cssFloat - closeButton.style.color = "black"; - closeButton.innerHTML = "close"; - closeButton.onclick = Log4js.bind(this.toggle, this); - this.buttonsContainerElement.appendChild(closeButton); - } - - var clearButton = this.docReference.createElement('button'); - clearButton.style.cssFloat = "right"; - clearButton.style.styleFloat = "right"; // IE dom bug...doesn't understand cssFloat - clearButton.style.color = "black"; - clearButton.innerHTML = "clear"; - clearButton.onclick = Log4js.bind(this.logger.clear, this.logger); - this.buttonsContainerElement.appendChild(clearButton); - - - //Add CategoryName and Level Filter - this.tagFilterContainerElement = this.docReference.createElement('span'); - this.toolbarElement.appendChild(this.tagFilterContainerElement); - this.tagFilterContainerElement.style.cssFloat = 'left'; - - this.tagFilterContainerElement.appendChild(this.docReference.createTextNode("Log4js - " + this.logger.category)); - this.tagFilterContainerElement.appendChild(this.docReference.createTextNode(" | Level Filter: ")); - - this.tagFilterElement = this.docReference.createElement('input'); - this.tagFilterContainerElement.appendChild(this.tagFilterElement); - this.tagFilterElement.style.width = '200px'; - this.tagFilterElement.value = this.tagPattern; - this.tagFilterElement.setAttribute('autocomplete', 'off'); // So Firefox doesn't flip out - - Log4js.attachEvent(this.tagFilterElement, 'keyup', Log4js.bind(this.updateTags, this)); - Log4js.attachEvent(this.tagFilterElement, 'click', Log4js.bind( function() {this.tagFilterElement.select();}, this)); - - // Add outputElement - this.outputElement = this.docReference.createElement('div'); - this.logElement.appendChild(this.outputElement); - this.outputElement.style.overflow = "auto"; - this.outputElement.style.clear = "both"; - this.outputElement.style.height = (this.inline) ? ("200px"):("650px"); - this.outputElement.style.width = "100%"; - this.outputElement.style.backgroundColor = 'black'; - - this.inputContainerElement = this.docReference.createElement('div'); - this.inputContainerElement.style.width = "100%"; - this.logElement.appendChild(this.inputContainerElement); - - this.inputElement = this.docReference.createElement('input'); - this.inputContainerElement.appendChild(this.inputElement); - this.inputElement.style.width = '100%'; - this.inputElement.style.borderWidth = '0px'; // Inputs with 100% width always seem to be too large (I HATE THEM) they only work if the border, margin and padding are 0 - this.inputElement.style.margin = '0px'; - this.inputElement.style.padding = '0px'; - this.inputElement.value = 'Type command here'; - this.inputElement.setAttribute('autocomplete', 'off'); // So Firefox doesn't flip out - - Log4js.attachEvent(this.inputElement, 'keyup', Log4js.bind(this.handleInput, this)); - Log4js.attachEvent(this.inputElement, 'click', Log4js.bind( function() {this.inputElement.select();}, this)); - - if(this.inline){ - window.setInterval(Log4js.bind(this.repositionWindow, this), 500); - this.repositionWindow(); - // Allow acess key link - var accessElement = this.docReference.createElement('button'); - accessElement.style.position = "absolute"; - accessElement.style.top = "-100px"; - accessElement.accessKey = this.accesskey; - accessElement.onclick = Log4js.bind(this.toggle, this); - this.docReference.body.appendChild(accessElement); - } else { - this.show(); - } - }, - /** - * shows/hide an element - * @private - * @return true if shown - */ - toggle : function() { - if (this.logElement.style.display == 'none') { - this.show(); - return true; - } else { - this.hide(); - return false; - } - }, - /** - * @private - */ - show : function() { - this.logElement.style.display = ''; - this.outputElement.scrollTop = this.outputElement.scrollHeight; // Scroll to bottom when toggled - this.inputElement.select(); - }, - /** - * @private - */ - hide : function() { - this.logElement.style.display = 'none'; - }, - /** - * @private - * @param message - * @style - */ - output : function(message, style) { - - // If we are at the bottom of the window, then keep scrolling with the output - var shouldScroll = (this.outputElement.scrollTop + (2 * this.outputElement.clientHeight)) >= this.outputElement.scrollHeight; - - this.outputCount++; - style = (style ? style += ';' : ''); - style += 'padding:1px;margin:0 0 5px 0'; - - if (this.outputCount % 2 === 0) { - style += ";background-color:#101010"; - } - - message = message || "undefined"; - message = message.toString(); - - this.outputElement.innerHTML += "
" + message + "
"; - - if (shouldScroll) { - this.outputElement.scrollTop = this.outputElement.scrollHeight; - } - }, - - /** - * @private - */ - updateTags : function() { - - var pattern = this.tagFilterElement.value; - - if (this.tagPattern == pattern) { - return; - } - - try { - new RegExp(pattern); - } catch (e) { - return; - } - - this.tagPattern = pattern; - - this.outputElement.innerHTML = ""; - - // Go through each log entry again - this.outputCount = 0; - for (var i = 0; i < this.logger.loggingEvents.length; i++) { - this.doAppend(this.logger.loggingEvents[i]); - } - }, - - /** - * @private - */ - repositionWindow : function() { - var offset = window.pageYOffset || this.docReference.documentElement.scrollTop || this.docReference.body.scrollTop; - var pageHeight = self.innerHeight || this.docReference.documentElement.clientHeight || this.docReference.body.clientHeight; - this.logElement.style.top = (offset + pageHeight - this.logElement.offsetHeight) + "px"; - }, - - /** - * @param loggingEvent event to be logged - * @see Log4js.Appender#doAppend - */ - doAppend : function(loggingEvent) { - - if(this.popupBlocker) { - //popup blocked, we return in this case - return; - } - - if ((!this.inline) && (!this.winReference || this.winReference.closed)) { - this.initialize(); - } - - if (this.tagPattern !== null && - loggingEvent.level.toString().search(new RegExp(this.tagPattern, 'igm')) == -1) { - return; - } - - var style = ''; - - if (loggingEvent.level.toString().search(/ERROR/) != -1) { - style += 'color:red'; - } else if (loggingEvent.level.toString().search(/FATAL/) != -1) { - style += 'color:red'; - } else if (loggingEvent.level.toString().search(/WARN/) != -1) { - style += 'color:orange'; - } else if (loggingEvent.level.toString().search(/DEBUG/) != -1) { - style += 'color:green'; - } else if (loggingEvent.level.toString().search(/INFO/) != -1) { - style += 'color:white'; - } else { - style += 'color:yellow'; - } - - this.output(this.layout.format(loggingEvent), style); - }, - - /** - * @see Log4js.Appender#doClear - */ - doClear : function() { - this.outputElement.innerHTML = ""; - }, - /** - * @private - * @param e - */ - handleInput : function(e) { - if (e.keyCode == 13 ) { - var command = this.inputElement.value; - - switch(command) { - case "clear": - this.logger.clear(); - break; - - default: - var consoleOutput = ""; - - try { - consoleOutput = eval(this.inputElement.value); - } catch (e) { - this.logger.error("Problem parsing input <" + command + ">" + e.message); - break; - } - - this.logger.trace(consoleOutput); - break; - } - - if (this.inputElement.value !== "" && this.inputElement.value !== this.commandHistory[0]) { - this.commandHistory.unshift(this.inputElement.value); - } - - this.commandIndex = 0; - this.inputElement.value = ""; - } else if (e.keyCode == 38 && this.commandHistory.length > 0) { - this.inputElement.value = this.commandHistory[this.commandIndex]; - - if (this.commandIndex < this.commandHistory.length - 1) { - this.commandIndex += 1; - } - } else if (e.keyCode == 40 && this.commandHistory.length > 0) { - if (this.commandIndex > 0) { - this.commandIndex -= 1; - } - - this.inputElement.value = this.commandHistory[this.commandIndex]; - } else { - this.commandIndex = 0; - } - }, - - /** - * toString - */ - toString: function() { - return "Log4js.ConsoleAppender[inline=" + this.inline + "]"; - } -}); - -/** - * Metatag Appender writing the logs to meta tags - * - * @extends Log4js.Appender - * @constructor - * @param logger log4js instance this appender is attached to - * @author Stephan Strittmatter - */ -Log4js.MetatagAppender = function() { - this.currentLine = 0; -}; -Log4js.MetatagAppender.prototype = Log4js.extend(new Log4js.Appender(), { - /** - * @param loggingEvent event to be logged - * @see Log4js.Appender#doAppend - */ - doAppend: function(loggingEvent) { - var now = new Date(); - var lines = loggingEvent.message.split("\n"); - var headTag = document.getElementsByTagName("head")[0]; - - for (var i = 1; i <= lines.length; i++) { - var value = lines[i - 1]; - if (i == 1) { - value = loggingEvent.level.toString() + ": " + value; - } else { - value = "> " + value; - } - - var metaTag = document.createElement("meta"); - metaTag.setAttribute("name", "X-log4js:" + this.currentLine); - metaTag.setAttribute("content", value); - headTag.appendChild(metaTag); - this.currentLine += 1; - } - }, - - /** - * toString - */ - toString: function() { - return "Log4js.MetatagAppender"; - } -}); - -/** - * AJAX Appender sending {@link Log4js.LoggingEvent}s asynchron via - * XMLHttpRequest to server.
- * The {@link Log4js.LoggingEvent} is POSTed as response content and is - * formatted by the accociated layout. Default layout is {@link Log4js.XMLLayout}. - * The threshold defines when the logs - * should be send to the server. By default every event is sent on its - * own (threshold=1). If it is set to 10, then the events are send in groups of - * 10 events. - * - * @extends Log4js.Appender - * @constructor - * @param {Log4js.Logger} logger log4js instance this appender is attached to - * @param {String} loggingUrl url where appender will post log messages to - * @author Stephan Strittmatter - */ -Log4js.AjaxAppender = function(loggingUrl) { - - /** - * is still esnding data to server - * @type boolean - * @private - */ - this.isInProgress = false; - - /** - * @type String - * @private - */ - this.loggingUrl = loggingUrl || "logging.log4js"; - - /** - * @type Integer - * @private - */ - this.threshold = 1; - - /** - * timeout when request is aborted. - * @private - */ - this.timeout = 2000; - - /** - * List of LoggingEvents which should be send after threshold is reached. - * @type Map - * @private - */ - this.loggingEventMap = new Log4js.FifoBuffer(); - - /** - * @type Log4js.Layout - * @private - */ - this.layout = new Log4js.XMLLayout(); - /** - * @type XMLHttpRequest - * @private - */ - this.httpRequest = null; -}; - -Log4js.AjaxAppender.prototype = Log4js.extend(new Log4js.Appender(), { - /** - * sends the logs to the server - * @param loggingEvent event to be logged - * @see Log4js.Appender#doAppend - */ - doAppend: function(loggingEvent) { - log4jsLogger.trace("> AjaxAppender.append"); - - if (this.loggingEventMap.length() <= this.threshold || this.isInProgress === true) { - this.loggingEventMap.push(loggingEvent); - } - - if(this.loggingEventMap.length() >= this.threshold && this.isInProgress === false) { - //if threshold is reached send the events and reset current threshold - this.send(); - } - - log4jsLogger.trace("< AjaxAppender.append"); - }, - - /** @see Appender#doClear */ - doClear: function() { - log4jsLogger.trace("> AjaxAppender.doClear" ); - if(this.loggingEventMap.length() > 0) { - this.send(); - } - log4jsLogger.trace("< AjaxAppender.doClear" ); - }, - - /** - * Set the threshold when logs have to be send. Default threshold is 1. - * @praram {int} threshold new threshold - */ - setThreshold: function(threshold) { - log4jsLogger.trace("> AjaxAppender.setThreshold: " + threshold ); - this.threshold = threshold; - log4jsLogger.trace("< AjaxAppender.setThreshold" ); - }, - - /** - * Set the timeout in milli seconds until sending request is aborted. - * Default is 2000 ms. - * @param {int} milliseconds the new timeout - */ - setTimeout: function(milliseconds) { - this.timeout = milliseconds; - }, - - /** - * send the request. - */ - send: function() { - if(this.loggingEventMap.length() >0) { - - log4jsLogger.trace("> AjaxAppender.send"); - - - this.isInProgress = true; - var a = []; - - for(var i = 0; i < this.loggingEventMap.length() && i < this.threshold; i++) { - a.push(this.layout.format(this.loggingEventMap.pull())); - } - - var content = this.layout.getHeader(); - content += a.join(this.layout.getSeparator()); - content += this.layout.getFooter(); - - var appender = this; - if(this.httpRequest === null){ - this.httpRequest = this.getXmlHttpRequest(); - } - this.httpRequest.onreadystatechange = function() { - appender.onReadyStateChanged.call(appender); - }; - - this.httpRequest.open("POST", this.loggingUrl, true); - // set the request headers. - //this.httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - this.httpRequest.setRequestHeader("Content-type", this.layout.getContentType()); - //REFERER will be the top-level - // URI which may differ from the location of the error if - // it occurs in an included .js file - this.httpRequest.setRequestHeader("REFERER", location.href); - this.httpRequest.setRequestHeader("Content-length", content.length); - this.httpRequest.setRequestHeader("Connection", "close"); - this.httpRequest.send( content ); - - appender = this; - - try { - window.setTimeout(function(){ - log4jsLogger.trace("> AjaxAppender.timeout"); - appender.httpRequest.onreadystatechange = function(){return;}; - appender.httpRequest.abort(); - //this.httpRequest = null; - appender.isInProgress = false; - - if(appender.loggingEventMap.length() > 0) { - appender.send(); - } - log4jsLogger.trace("< AjaxAppender.timeout"); - }, this.timeout); - } catch (e) { - log4jsLogger.fatal(e); - } - log4jsLogger.trace("> AjaxAppender.send"); - } - }, - - /** - * @private - */ - onReadyStateChanged: function() { - log4jsLogger.trace("> AjaxAppender.onReadyStateChanged"); - var req = this.httpRequest; - if (this.httpRequest.readyState != 4) { - log4jsLogger.trace("< AjaxAppender.onReadyStateChanged: readyState " + req.readyState + " != 4"); - return; - } - - var success = ((typeof req.status === "undefined") || req.status === 0 || (req.status >= 200 && req.status < 300)); - - if (success) { - log4jsLogger.trace(" AjaxAppender.onReadyStateChanged: success"); - - //ready sending data - this.isInProgress = false; - - } else { - var msg = " AjaxAppender.onReadyStateChanged: XMLHttpRequest request to URL " + this.loggingUrl + " returned status code " + this.httpRequest.status; - log4jsLogger.error(msg); - } - - log4jsLogger.trace("< AjaxAppender.onReadyStateChanged: readyState == 4"); - }, - /** - * Get the XMLHttpRequest object independent of browser. - * @private - */ - getXmlHttpRequest: function() { - log4jsLogger.trace("> AjaxAppender.getXmlHttpRequest"); - - var httpRequest = false; - - try { - if (window.XMLHttpRequest) { // Mozilla, Safari, IE7... - httpRequest = new XMLHttpRequest(); - if (httpRequest.overrideMimeType) { - httpRequest.overrideMimeType(this.layout.getContentType()); - } - } else if (window.ActiveXObject) { // IE - try { - httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); - } catch (e) { - httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); - } - } - } catch (e) { - httpRequest = false; - } - - if (!httpRequest) { - log4jsLogger.fatal("Unfortunatelly your browser does not support AjaxAppender for log4js!"); - } - - log4jsLogger.trace("< AjaxAppender.getXmlHttpRequest"); - return httpRequest; - }, - - /** - * toString - */ - toString: function() { - return "Log4js.AjaxAppender[loggingUrl=" + this.loggingUrl + ", threshold=" + this.threshold + "]"; - } -}); - -/** - * File Appender writing the logs to a text file. - * PLEASE NOTE - Only works in IE and Mozilla - * use ActiveX to write file on IE - * use XPCom components to write file on Mozilla - * - * @extends Log4js.Appender - * @constructor - * @param logger log4js instance this appender is attached to - * @param file file log messages will be written to - * @author Seth Chisamore - * @author Nicolas Justin njustin@idealx.com - * @author Gregory Kokanosky gkokanosky@idealx.com - */ -Log4js.FileAppender = function(file) { - - this.layout = new Log4js.SimpleLayout(); - this.isIE = 'undefined'; - - this.file = file || "log4js.log"; - - try{ - this.fso = new ActiveXObject("Scripting.FileSystemObject"); - this.isIE = true; - } catch(e){ - try { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - this.fso = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); - this.isIE = false; //mozilla & co - } catch (e) { - log4jsLogger.error(e); - } - } -}; - -Log4js.FileAppender.prototype = Log4js.extend(new Log4js.Appender(), { - /** - * @param loggingEvent event to be logged - * @see Log4js.Appender#doAppend - */ - doAppend: function(loggingEvent) { - try { - var fileHandle = null; - - if( this.isIE === 'undefined') { - log4jsLogger.error("Unsupported ") - } - else if( this.isIE ){ - // try opening existing file, create if needed - fileHandle = this.fso.OpenTextFile(this.file, 8, true); - // write out our data - fileHandle.WriteLine(this.layout.format(loggingEvent)); - fileHandle.close(); - } else { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - this.fso.initWithPath(this.file); - if(!this.fso.exists()) { - //create file if needed - this.fso.create(0x00, 0600); - } - - fileHandle = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream); - fileHandle.init( this.fso, 0x04 | 0x08 | 0x10, 064, 0); - var line = this.layout.format(loggingEvent); - fileHandle.write(line, line.length); //write data - fileHandle.close(); - } - } catch (e) { - log4jsLogger.error(e); - } - }, - /* - * @see Log4js.Appender#doClear - */ - doClear: function() { - try { - if( this.isIE ){ - var fileHandle = this.fso.GetFile(this.file); - fileHandle.Delete(); - } else { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - this.fso.initWithPath(this.file); - if(this.fso.exists()) { - this.fso.remove(false); - } - } - } catch (e) { - log4jsLogger.error(e); - } - }, - - /** - * toString - */ - toString: function() { - return "Log4js.FileAppender[file=" + this.file + "]"; - } -}); - -/** - * Windows Event Appender writes the logs to the Windows Event log. - * PLEASE NOTE - Only works in IE..uses ActiveX to write to Windows Event log - * - * @extends Log4js.Appender - * @constructor - * @param logger log4js instance this appender is attached to - * @author Seth Chisamore - */ -Log4js.WindowsEventAppender = function() { - - this.layout = new Log4js.SimpleLayout(); - - try { - this.shell = new ActiveXObject("WScript.Shell"); - } catch(e) { - log4jsLogger.error(e); - } -}; - -Log4js.WindowsEventAppender.prototype = Log4js.extend(new Log4js.Appender(), { - /** - * @param loggingEvent event to be logged - * @see Log4js.Appender#doAppend - */ - doAppend: function(loggingEvent) { - var winLevel = 4; - - // Map log level to windows event log level. - // Windows events: - SUCCESS: 0, ERROR: 1, WARNING: 2, INFORMATION: 4, AUDIT_SUCCESS: 8, AUDIT_FAILURE: 16 - switch (loggingEvent.level) { - case Log4js.Level.FATAL: - winLevel = 1; - break; - case Log4js.Level.ERROR: - winLevel = 1; - break; - case Log4js.Level.WARN: - winLevel = 2; - break; - default: - winLevel = 4; - break; - } - - try { - this.shell.LogEvent(winLevel, this.level.format(loggingEvent)); - } catch(e) { - log4jsLogger.error(e); - } - }, - - /** - * toString - */ - toString: function() { - return "Log4js.WindowsEventAppender"; - } -}); - -/** - * JS Alert Appender writes the logs to the JavaScript alert dialog box - * @constructor - * @extends Log4js.Appender - * @param logger log4js instance this appender is attached to - * @author Sébastien LECACHEUR - */ -Log4js.JSAlertAppender = function() { - - this.layout = new Log4js.SimpleLayout(); -}; - -Log4js.JSAlertAppender.prototype = Log4js.extend(new Log4js.Appender(), { - /** - * @see Log4js.Appender#doAppend - */ - doAppend: function(loggingEvent) { - alert(this.layout.getHeader() + this.layout.format(loggingEvent) + this.layout.getFooter()); - }, - - /** - * toString - */ - toString: function() { - return "Log4js.JSAlertAppender"; - } -}); - -/** - * Appender writes the logs to the JavaScript console of Mozilla browser - * More infos: http://kb.mozillazine.org/index.php?title=JavaScript_Console&redirect=no - * PLEASE NOTE - Only works in Mozilla browser - * @constructor - * @extends Log4js.Appender - * @param logger log4js instance this appender is attached to - * @author Stephan Strittmatter - */ -Log4js.MozillaJSConsoleAppender = function() { - this.layout = new Log4js.SimpleLayout(); - try { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - this.jsConsole = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService); - this.scriptError = Components.classes["@mozilla.org/scripterror;1"].createInstance(Components.interfaces.nsIScriptError); - } catch (e) { - log4jsLogger.error(e); - } -}; - -Log4js.MozillaJSConsoleAppender.prototype = Log4js.extend(new Log4js.Appender(), { - /** - * @see Log4js.Appender#doAppend - */ - doAppend: function(loggingEvent) { - try { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - this.scriptError.init(this.layout.format(loggingEvent), null, null, null, null, this.levelCode(loggingEvent), loggingEvent.categoryName); - this.jsConsole.logMessage(this.scriptError); - } catch (e) { - log4jsLogger.error(e); - } - }, - - /** - * toString - */ - toString: function() { - return "Log4js.MozillaJSConsoleAppender"; - }, - - /** - * Map Log4js.Level to jsConsole Flags: - * - * @private - */ - levelCode: function(loggingEvent) - { - var retval; - switch (loggingEvent.level) { - case Log4js.Level.FATAL: - retval = 2;//nsIScriptError.exceptionFlag = 2 - break; - case Log4js.Level.ERROR: - retval = 0;//nsIScriptError.errorFlag - break; - case Log4js.Level.WARN: - retval = 1;//nsIScriptError.warningFlag = 1 - break; - default: - retval = 1;//nsIScriptError.warningFlag = 1 - break; - } - - return retval; - } -}); - -/** - * Appender writes the logs to the JavaScript console of Opera browser - * PLEASE NOTE - Only works in Opera browser - * @constructor - * @extends Log4js.Appender - * @param logger log4js instance this appender is attached to - * @author Stephan Strittmatter - */ -Log4js.OperaJSConsoleAppender = function() { - this.layout = new Log4js.SimpleLayout(); -}; - -Log4js.OperaJSConsoleAppender.prototype = Log4js.extend(new Log4js.Appender(), { - /** - * @see Log4js.Appender#doAppend - */ - doAppend: function(loggingEvent) { - opera.postError(this.layout.format(loggingEvent)); - }, - - /** - * toString - */ - toString: function() { - return "Log4js.OperaJSConsoleAppender"; - } -}); - -/** - * Appender writes the logs to the JavaScript console of Safari browser - * PLEASE NOTE - Only works in Safari browser - * @constructor - * @extends Log4js.Appender - * @param logger log4js instance this appender is attached to - * @author Stephan Strittmatter - */ -Log4js.SafariJSConsoleAppender = function() { - this.layout = new Log4js.SimpleLayout(); -}; - -Log4js.SafariJSConsoleAppender.prototype = Log4js.extend(new Log4js.Appender(), { - /** - * @see Log4js.Appender#doAppend - */ - doAppend: function(loggingEvent) { - window.console.log(this.layout.format(loggingEvent)); - }, - - /** - * toString - */ - toString: function() { - return "Log4js.SafariJSConsoleAppender"; - } -}); - -/** - * JavaScript Console Appender which is browser independent. - * It checks internally for the current browser and adds delegate to - * specific JavaScript Console Appender of the browser. - * - * @author Stephan Strittmatter - * @since 1.0 - */ -Log4js.BrowserConsoleAppender = function() { - /** - * Delegate for browser specific implementation - * @type Log4js.Appender - * @private - */ - this.consoleDelegate = null; - - if (window.console) { - this.consoleDelegate = new Log4js.SafariJSConsoleAppender(); - } - else if (window.opera) { - this.consoleDelegate = new Log4js.OperaJSConsoleAppender(); - } - else if(netscape) { - this.consoleDelegate = new Log4js.MozillaJSConsoleAppender(); - } - else { - //@todo - log4jsLogger.error("Unsupported Browser"); - } -}; - -Log4js.BrowserConsoleAppender.prototype = Log4js.extend(new Log4js.Appender(), { - /** - * @see Log4js.Appender#doAppend - */ - doAppend: function(loggingEvent) { - this.consoleDelegate.doAppend(loggingEvent); - }, - /** - * @see Log4js.Appender#doClear - */ - doClear: function() { - this.consoleDelegate.doClear(); - }, - /** - * @see Log4js.Appender#setLayout - */ - setLayout: function(layout){ - this.consoleDelegate.setLayout(layout); - }, - - /** - * toString - */ - toString: function() { - return "Log4js.BrowserConsoleAppender: " + this.consoleDelegate.toString(); - } -}); - -/** - * SimpleLayout consists of the level of the log statement, followed by " - " - * and then the log message itself. For example, - * DEBUG - Hello world - * - * @constructor - * @extends Log4js.Layout - * @extends Layout - * @author Stephan Strittmatter - */ -Log4js.SimpleLayout = function() { - this.LINE_SEP = "\n"; - this.LINE_SEP_LEN = 1; -}; - -Log4js.SimpleLayout.prototype = Log4js.extend(new Log4js.Layout(), { - /** - * Implement this method to create your own layout format. - * @param {Log4js.LoggingEvent} loggingEvent loggingEvent to format - * @return formatted String - * @type String - */ - format: function(loggingEvent) { - return loggingEvent.level.toString() + " - " + loggingEvent.message + this.LINE_SEP; - }, - /** - * Returns the content type output by this layout. - * @return The base class returns "text/plain". - * @type String - */ - getContentType: function() { - return "text/plain"; - }, - /** - * @return Returns the header for the layout format. The base class returns null. - * @type String - */ - getHeader: function() { - return ""; - }, - /** - * @return Returns the footer for the layout format. The base class returns null. - * @type String - */ - getFooter: function() { - return ""; - } -}); - -/** - * BasicLayout is a simple layout for storing the loggs. The loggs are stored - * in following format: - *
- * categoryName~startTime [logLevel] message\n
- * 
- * - * @constructor - * @extends Log4js.Layout - * @author Stephan Strittmatter - */ -Log4js.BasicLayout = function() { - this.LINE_SEP = "\n"; -}; - -Log4js.BasicLayout.prototype = Log4js.extend(new Log4js.Layout(), { - /** - * Implement this method to create your own layout format. - * @param {Log4js.LoggingEvent} loggingEvent loggingEvent to format - * @return formatted String - * @type String - */ - format: function(loggingEvent) { - return loggingEvent.categoryName + "~" + loggingEvent.startTime.toLocaleString() + " [" + loggingEvent.level.toString() + "] " + loggingEvent.message + this.LINE_SEP; - }, - /** - * Returns the content type output by this layout. - * @return The base class returns "text/plain". - * @type String - */ - getContentType: function() { - return "text/plain"; - }, - /** - * @return Returns the header for the layout format. The base class returns null. - * @type String - */ - getHeader: function() { - return ""; - }, - /** - * @return Returns the footer for the layout format. The base class returns null. - * @type String - */ - getFooter: function() { - return ""; - } -}); - -/** - * HtmlLayout write the logs in Html format. - * - * @constructor - * @extends Log4js.Layout - * @author Stephan Strittmatter - */ -Log4js.HtmlLayout = function() {return;}; - -Log4js.HtmlLayout.prototype = Log4js.extend(new Log4js.Layout(), { - /** - * Implement this method to create your own layout format. - * @param {Log4js.LoggingEvent} loggingEvent loggingEvent to format - * @return formatted String - * @type String - */ - format: function(loggingEvent) { - return "
" + loggingEvent.getFormattedTimestamp() + " - " + loggingEvent.level.toString() + " - " + loggingEvent.message + "
\n"; - }, - /** - * Returns the content type output by this layout. - * @return The base class returns "text/html". - * @type String - */ - getContentType: function() { - return "text/html"; - }, - /** - * @return Returns the header for the layout format. The base class returns null. - * @type String - */ - getHeader: function() { - return "log4js</head><body>"; - }, - /** - * @return Returns the footer for the layout format. The base class returns null. - * @type String - */ - getFooter: function() { - return "</body></html>"; - }, - - getStyle: function(loggingEvent) - { - var style; - if (loggingEvent.level.toString().search(/ERROR/) != -1) { - style = 'color:red'; - } else if (loggingEvent.level.toString().search(/FATAL/) != -1) { - style = 'color:red'; - } else if (loggingEvent.level.toString().search(/WARN/) != -1) { - style = 'color:orange'; - } else if (loggingEvent.level.toString().search(/DEBUG/) != -1) { - style = 'color:green'; - } else if (loggingEvent.level.toString().search(/INFO/) != -1) { - style = 'color:white'; - } else { - style = 'color:yellow'; - } - return style; - } -}); - -/** - * XMLLayout write the logs in XML format. - * Layout is simmilar to log4j's XMLLayout: - * <pre> - * <log4js:event category="category" level="Level" client="Client" referer="ref" timestam="Date"> - * <log4js:message>Logged message</log4js:message> - * </log4js:event> - * </pre> - * @constructor - * @extends Layout - * @author Stephan Strittmatter - */ -Log4js.XMLLayout = function(){return;}; -Log4js.XMLLayout.prototype = Log4js.extend(new Log4js.Layout(), { - /** - * Implement this method to create your own layout format. - * @param {Log4js.LoggingEvent} loggingEvent loggingEvent to format - * @return formatted String - * @type String - */ - format: function(loggingEvent) { - var useragent = "unknown"; - try { - useragent = navigator.userAgent; - } catch(e){ - useragent = "unknown"; - } - - var referer = "unknown"; - try { - referer = location.href; - } catch(e){ - referer = "unknown"; - } - - var content = "<log4js:event logger=\""; - content += loggingEvent.categoryName + "\" level=\""; - content += loggingEvent.level.toString() + "\" useragent=\""; - content += useragent + "\" referer=\""; - content += referer.replace(/&/g, "&") + "\" timestamp=\""; - content += loggingEvent.getFormattedTimestamp() + "\">\n"; - content += "\t<log4js:message><![CDATA[" + this.escapeCdata(loggingEvent.message) + "]]></log4js:message>\n"; - - if (loggingEvent.exception) { - content += this.formatException(loggingEvent.exception) ; - } - content += "</log4js:event>\n"; - - return content; - }, - /** - * Returns the content type output by this layout. - * @return The base class returns "text/xml". - * @type String - */ - getContentType: function() { - return "text/xml"; - }, - /** - * @return Returns the header for the layout format. The base class returns null. - * @type String - */ - getHeader: function() { - return "<log4js:eventSet version=\"" + Log4js.version + - "\" xmlns:log4js=\"http://log4js.berlios.de/2007/log4js/\">\n"; - }, - /** - * @return Returns the footer for the layout format. The base class returns null. - * @type String - */ - getFooter: function() { - return "</log4js:eventSet>\n"; - }, - - getSeparator: function() { - return "\n"; - }, - - /** - * better readable formatted Exceptions. - * @param ex {Exception} the exception to be formatted. - * @return {String} the formatted String representation of the exception. - * @private - */ - formatException: function(ex) { - if (ex) { - var exStr = "\t<log4js:throwable>"; - if (ex.message) { - exStr += "\t\t<log4js:message><![CDATA[" + this.escapeCdata(ex.message) + "]]></log4js:message>\n"; - } - if (ex.description) { - exStr += "\t\t<log4js:description><![CDATA[" + this.escapeCdata(ex.description) + "]]></log4js:description>\n"; - } - - exStr += "\t\t<log4js:stacktrace>"; - exStr += "\t\t\t<log4js:location fileName=\""+ex.fileName+"\" lineNumber=\""+ex.lineNumber+"\" />"; - exStr += "\t\t</log4js:stacktrace>"; - exStr = "\t</log4js:throwable>"; - return exStr; - } - return null; - }, - /** - * Escape Cdata messages - * @param str {String} message to escape - * @return {String} the escaped message - * @private - */ - escapeCdata: function(str) { - return str.replace(/\]\]>/, "]]>]]><![CDATA["); - } -}); - -/** - * JSONLayout write the logs in JSON format. - * JSON library is required to use this Layout. See also {@link http://www.json.org} - * @constructor - * @extends Log4js.Layout - * @author Stephan Strittmatter - */ -Log4js.JSONLayout = function() { - this.df = new Log4js.DateFormatter(); -}; -Log4js.JSONLayout.prototype = Log4js.extend(new Log4js.Layout(), { - /** - * Implement this method to create your own layout format. - * @param {Log4js.LoggingEvent} loggingEvent loggingEvent to format - * @return formatted String - * @type String - */ - format: function(loggingEvent) { - - var useragent = "unknown"; - try { - useragent = navigator.userAgent; - } catch(e){ - useragent = "unknown"; - } - - var referer = "unknown"; - try { - referer = location.href; - } catch(e){ - referer = "unknown"; - } - - var jsonString = "{\n \"LoggingEvent\": {\n"; - - jsonString += "\t\"logger\": \"" + loggingEvent.categoryName + "\",\n"; - jsonString += "\t\"level\": \"" + loggingEvent.level.toString() + "\",\n"; - jsonString += "\t\"message\": \"" + loggingEvent.message + "\",\n"; - jsonString += "\t\"referer\": \"" + referer + "\",\n"; - jsonString += "\t\"useragent\": \"" + useragent + "\",\n"; - jsonString += "\t\"timestamp\": \"" + this.df.formatDate(loggingEvent.startTime, "yyyy-MM-ddThh:mm:ssZ") + "\",\n"; - jsonString += "\t\"exception\": \"" + loggingEvent.exception + "\"\n"; - jsonString += "}}"; - - return jsonString; - }, - /** - * Returns the content type output by this layout. - * @return The base class returns "text/xml". - * @type String - */ - getContentType: function() { - return "text/json"; - }, - /** - * @return Returns the header for the layout format. The base class returns null. - * @type String - */ - getHeader: function() { - return "{\"Log4js\": [\n"; - }, - /** - * @return Returns the footer for the layout format. The base class returns null. - * @type String - */ - getFooter: function() { - return "\n]}"; - }, - - getSeparator: function() { - return ",\n"; - } -}); - -/** - * PatternLayout - */ -Log4js.PatternLayout = function(pattern) { - if (pattern) { - this.pattern = pattern; - } else { - this.pattern = Log4js.PatternLayout.DEFAULT_CONVERSION_PATTERN; - } -}; - -Log4js.PatternLayout.TTCC_CONVERSION_PATTERN = "%r %p %c - %m%n"; -Log4js.PatternLayout.DEFAULT_CONVERSION_PATTERN = "%m%n"; -Log4js.PatternLayout.ISO8601_DATEFORMAT = "yyyy-MM-dd HH:mm:ss,SSS"; -Log4js.PatternLayout.DATETIME_DATEFORMAT = "dd MMM YYYY HH:mm:ss,SSS"; -Log4js.PatternLayout.ABSOLUTETIME_DATEFORMAT = "HH:mm:ss,SSS"; - -Log4js.PatternLayout.prototype = Log4js.extend(new Log4js.Layout(), { - /** - * Returns the content type output by this layout. - * @return "text/plain". - * @type String - */ - getContentType: function() { - return "text/plain"; - }, - /** - * @return Returns the header for the layout format. - * @type String - */ - getHeader: function() { - return null; - }, - /** - * @return Returns the footer for the layout format. - * @type String - */ - getFooter: function() { - return null; - }, - - format: function(loggingEvent) { - var regex = /%(-?[0-9]+)?(\.?[0-9]+)?([cdmnpr%])(\{([^\}]+)\})?|([^%]+)/; - var formattedString = ""; - var result; - var searchString = this.pattern; - - // Cannot use regex global flag since it doesn't work in IE5 - while ((result = regex.exec(searchString))) { - var matchedString = result[0]; - var padding = result[1]; - var truncation = result[2]; - var conversionCharacter = result[3]; - var specifier = result[5]; - var text = result[6]; - - // Check if the pattern matched was just normal text - if (text) { - formattedString += "" + text; - } else { - // Create a raw replacement string based on the conversion - // character and specifier - var replacement = ""; - switch(conversionCharacter) { - case "c": - var loggerName = loggingEvent.categoryName; - if (specifier) { - var precision = parseInt(specifier, 10); - var loggerNameBits = loggingEvent.categoryName.split("."); - if (precision >= loggerNameBits.length) { - replacement = loggerName; - } else { - replacement = loggerNameBits.slice(loggerNameBits.length - precision).join("."); - } - } else { - replacement = loggerName; - } - break; - case "d": - var dateFormat = Log4js.PatternLayout.ISO8601_DATEFORMAT; - if (specifier) { - dateFormat = specifier; - // Pick up special cases - if (dateFormat == "ISO8601") { - dateFormat = Log4js.PatternLayout.ISO8601_DATEFORMAT; - } else if (dateFormat == "ABSOLUTE") { - dateFormat = Log4js.PatternLayout.ABSOLUTETIME_DATEFORMAT; - } else if (dateFormat == "DATE") { - dateFormat = Log4js.PatternLayout.DATETIME_DATEFORMAT; - } - } - // Format the date - replacement = (new Log4js.SimpleDateFormat(dateFormat)).format(loggingEvent.startTime); - break; - case "m": - replacement = loggingEvent.message; - break; - case "n": - replacement = "\n"; - break; - case "p": - replacement = loggingEvent.level.toString(); - break; - case "r": - replacement = "" + loggingEvent.startTime.toLocaleTimeString(); //TODO: .getDifference(Log4js.applicationStartDate); - break; - case "%": - replacement = "%"; - break; - default: - replacement = matchedString; - break; - } - // Format the replacement according to any padding or - // truncation specified - - var len; - - // First, truncation - if (truncation) { - len = parseInt(truncation.substr(1), 10); - replacement = replacement.substring(0, len); - } - // Next, padding - if (padding) { - if (padding.charAt(0) == "-") { - len = parseInt(padding.substr(1), 10); - // Right pad with spaces - while (replacement.length < len) { - replacement += " "; - } - } else { - len = parseInt(padding, 10); - // Left pad with spaces - while (replacement.length < len) { - replacement = " " + replacement; - } - } - } - formattedString += replacement; - } - searchString = searchString.substr(result.index + result[0].length); - } - return formattedString; - } -}); - -/** - * @private - * @ignore - */ -if (!Array.prototype.push) { - /** - * Functions taken from Prototype library, didn't want to require for just few - * functions. - * More info at {@link http:// - * prototype.conio.net/} - * @private - */ - Array.prototype.push = function() { - var startLength = this.length; - for (var i = 0; i < arguments.length; i++) { - this[startLength + i] = arguments[i]; - } - return this.length; - }; -} - -/** - * FIFO buffer - * @private - */ -Log4js.FifoBuffer = function() -{ - this.array = new Array(); -}; - -Log4js.FifoBuffer.prototype = { - - /** - * @param {Object} obj any object added to buffer - */ - push : function(obj) { - this.array[this.array.length] = obj; - return this.array.length; - }, - - /** - * @return first putted in Object - */ - pull : function() { - if (this.array.length > 0) { - var firstItem = this.array[0]; - for (var i = 0; i < this.array.length - 1; i++) { - this.array[i] = this.array[i + 1]; - } - this.array.length = this.array.length - 1; - return firstItem; - } - return null; - }, - - length : function() { - return this.array.length; - } -}; - - - -/** - * Date Formatter - * addZero() and formatDate() are courtesy of Mike Golding: - * http://www.mikezilla.com/exp0015.html - * @private - */ -Log4js.DateFormatter = function() { - return; -}; -/** - * default format of date (ISO-8601) - * @static - * @final - */ -Log4js.DateFormatter.DEFAULT_DATE_FORMAT = "yyyy-MM-ddThh:mm:ssO"; - - -Log4js.DateFormatter.prototype = { - /** - * Formats the given date by the given pattern.<br /> - * Following switches are supported: - * <ul> - * <li>yyyy: The year</li> - * <li>MM: the month</li> - * <li>dd: the day of month<li> - * <li>hh: the hour<li> - * <li>mm: minutes</li> - * <li>O: timezone offset</li> - * </ul> - * @param {Date} vDate the date to format - * @param {String} vFormat the format pattern - * @return {String} formatted date string - * @static - */ - formatDate : function(vDate, vFormat) { - var vDay = this.addZero(vDate.getDate()); - var vMonth = this.addZero(vDate.getMonth()+1); - var vYearLong = this.addZero(vDate.getFullYear()); - var vYearShort = this.addZero(vDate.getFullYear().toString().substring(3,4)); - var vYear = (vFormat.indexOf("yyyy")>-1?vYearLong:vYearShort); - var vHour = this.addZero(vDate.getHours()); - var vMinute = this.addZero(vDate.getMinutes()); - var vSecond = this.addZero(vDate.getSeconds()); - var vTimeZone = this.O(vDate); - var vDateString = vFormat.replace(/dd/g, vDay).replace(/MM/g, vMonth).replace(/y{1,4}/g, vYear); - vDateString = vDateString.replace(/hh/g, vHour).replace(/mm/g, vMinute).replace(/ss/g, vSecond); - vDateString = vDateString.replace(/O/g, vTimeZone); - return vDateString; - }, - - /** - * @private - * @static - */ - addZero : function(vNumber) { - return ((vNumber < 10) ? "0" : "") + vNumber; - }, - - /** - * Formates the TimeOffest - * Thanks to http://www.svendtofte.com/code/date_format/ - * @private - */ - O : function (date) { - // Difference to Greenwich time (GMT) in hours - var os = Math.abs(date.getTimezoneOffset()); - var h = String(Math.floor(os/60)); - var m = String(os%60); - h.length == 1? h = "0"+h:1; - m.length == 1? m = "0"+m:1; - return date.getTimezoneOffset() < 0 ? "+"+h+m : "-"+h+m; - } -}; - - -/** - * internal Logger to be used - * @private - */ -var log4jsLogger = Log4js.getLogger("Log4js"); -log4jsLogger.addAppender(new Log4js.ConsoleAppender()); -log4jsLogger.setLevel(Log4js.Level.ALL); \ No newline at end of file diff --git a/mindplot/pom.xml b/mindplot/pom.xml index 4248a45a..5b3d035a 100644 --- a/mindplot/pom.xml +++ b/mindplot/pom.xml @@ -318,7 +318,7 @@ <include>collaboration/frameworks/brix/BrixFramework-min.js</include> <include>widget/IconPanel-min.js</include> - <include>widget/ToolbarPanel-min.js</include> + <include>widget/ListToolbarPanel-min.js</include> <include>widget/FontFamilyPanel-min.js</include> <include>widget/FontSizePanel-min.js</include> <include>widget/TopicShapePanel-min.js</include> diff --git a/mindplot/src/main/javascript/ActionIcon.js b/mindplot/src/main/javascript/ActionIcon.js index ff8261ec..4e08f7bb 100644 --- a/mindplot/src/main/javascript/ActionIcon.js +++ b/mindplot/src/main/javascript/ActionIcon.js @@ -31,8 +31,8 @@ mindplot.ActionIcon = new Class({ this.getImage().setPosition(x - size.width / 2, y - size.height / 2); }, - addEventListener:function(event, fn) { - this.getImage().addEventListener(event, fn); + addEvent:function(event, fn) { + this.getImage().addEvent(event, fn); }, addToGroup:function(group) { diff --git a/mindplot/src/main/javascript/CentralTopic.js b/mindplot/src/main/javascript/CentralTopic.js index 1f399f63..928e3686 100644 --- a/mindplot/src/main/javascript/CentralTopic.js +++ b/mindplot/src/main/javascript/CentralTopic.js @@ -27,7 +27,7 @@ mindplot.CentralTopic = new Class({ this.parent(); // This disable the drag of the central topic. But solves the problem of deselecting the nodes when the screen is clicked. - this.addEventListener('mousedown', function(event) { + this.addEvent('mousedown', function(event) { event.stopPropagation(); }); }, diff --git a/mindplot/src/main/javascript/ControlPoint.js b/mindplot/src/main/javascript/ControlPoint.js index 59214bee..a2653db0 100644 --- a/mindplot/src/main/javascript/ControlPoint.js +++ b/mindplot/src/main/javascript/ControlPoint.js @@ -24,12 +24,12 @@ mindplot.ControlPoint = new Class({ new web2d.Line({strokeColor:"#6589de", strokeWidth:1, opacity:0.3})]; this._isBinded = false; - this._controlPointsController[0].addEventListener('mousedown', this._mouseDown.bindWithEvent(this, mindplot.ControlPoint.FROM)); - this._controlPointsController[0].addEventListener('click', this._mouseClick.bindWithEvent(this)); - this._controlPointsController[0].addEventListener('dblclick', this._mouseClick.bindWithEvent(this)); - this._controlPointsController[1].addEventListener('mousedown', this._mouseDown.bindWithEvent(this, mindplot.ControlPoint.TO)); - this._controlPointsController[1].addEventListener('click', this._mouseClick.bindWithEvent(this)); - this._controlPointsController[1].addEventListener('dblclick', this._mouseClick.bindWithEvent(this)); + this._controlPointsController[0].addEvent('mousedown', this._mouseDown.bindWithEvent(this, mindplot.ControlPoint.FROM)); + this._controlPointsController[0].addEvent('click', this._mouseClick.bindWithEvent(this)); + this._controlPointsController[0].addEvent('dblclick', this._mouseClick.bindWithEvent(this)); + this._controlPointsController[1].addEvent('mousedown', this._mouseDown.bindWithEvent(this, mindplot.ControlPoint.TO)); + this._controlPointsController[1].addEvent('click', this._mouseClick.bindWithEvent(this)); + this._controlPointsController[1].addEvent('dblclick', this._mouseClick.bindWithEvent(this)); }, @@ -77,9 +77,9 @@ mindplot.ControlPoint = new Class({ if (!this._isBinded) { this._isBinded = true; this._mouseMoveFunction = this._mouseMove.bindWithEvent(this, point); - this._workspace.getScreenManager().addEventListener('mousemove', this._mouseMoveFunction); + this._workspace.getScreenManager().addEvent('mousemove', this._mouseMoveFunction); this._mouseUpFunction = this._mouseUp.bindWithEvent(this, point); - this._workspace.getScreenManager().addEventListener('mouseup', this._mouseUpFunction); + this._workspace.getScreenManager().addEvent('mouseup', this._mouseUpFunction); } event.preventDefault(); event.stop(); @@ -111,8 +111,8 @@ mindplot.ControlPoint = new Class({ }, _mouseUp : function(event, point) { - this._workspace.getScreenManager().removeEventListener('mousemove', this._mouseMoveFunction); - this._workspace.getScreenManager().removeEventListener('mouseup', this._mouseUpFunction); + this._workspace.getScreenManager().removeEvent('mousemove', this._mouseMoveFunction); + this._workspace.getScreenManager().removeEvent('mouseup', this._mouseUpFunction); var actionDispatcher = mindplot.ActionDispatcher.getInstance(); actionDispatcher.moveControlPoint(this, point); diff --git a/mindplot/src/main/javascript/DesignerKeyboard.js b/mindplot/src/main/javascript/DesignerKeyboard.js index 00b9a8d4..d20c3915 100644 --- a/mindplot/src/main/javascript/DesignerKeyboard.js +++ b/mindplot/src/main/javascript/DesignerKeyboard.js @@ -186,7 +186,7 @@ mindplot.DesignerKeyboard = new Class({ var regex = /^(?:shift|control|ctrl|alt|meta)$/; var modifiers = ['shift', 'control', 'alt', 'meta']; - var excludes = ['esc','capslock','tab']; + var excludes = ['esc','capslock','tab','f3','f4','f5','f6','f7','f8','f9','10','11','12']; $(document).addEvent('keydown', function(event) { diff --git a/mindplot/src/main/javascript/DragManager.js b/mindplot/src/main/javascript/DragManager.js index 3c34a154..3af8d80d 100644 --- a/mindplot/src/main/javascript/DragManager.js +++ b/mindplot/src/main/javascript/DragManager.js @@ -58,7 +58,7 @@ mindplot.DragManager.prototype.add = function(node) window.document.body.style.cursor = 'move'; } }; - node.addEventListener('mousedown', mouseDownListener); + node.addEvent('mousedown', mouseDownListener); }; mindplot.DragManager.prototype.remove = function(node) @@ -154,7 +154,7 @@ mindplot.DragManager.prototype._buildMouseUpListener = function(workspace, node, * - dragging * - enddragging */ -mindplot.DragManager.prototype. addEventListener = function(type, listener) +mindplot.DragManager.prototype. addEvent = function(type, listener) { this._listeners[type] = listener; }; \ No newline at end of file diff --git a/mindplot/src/main/javascript/IconGroup.js b/mindplot/src/main/javascript/IconGroup.js index dc53b7e5..2634cd7b 100644 --- a/mindplot/src/main/javascript/IconGroup.js +++ b/mindplot/src/main/javascript/IconGroup.js @@ -55,7 +55,7 @@ mindplot.IconGroup = new Class({ }, addIcon : function(icon) { - $defined(icon,"icon is not defined"); + $defined(icon, "icon is not defined"); icon.setGroup(this); var newIcon = icon.getImage(); @@ -136,7 +136,6 @@ mindplot.IconGroup = new Class({ var iconSize = nativeImage.getSize(); var size = this.options.nativeElem.getSize(); var position = nativeImage.getPosition(); - var childs = this.options.nativeElem.removeChild(nativeImage); this.options.icons.each(function(icon, index) { var img = icon.getImage(); var pos = img.getPosition(); @@ -148,7 +147,7 @@ mindplot.IconGroup = new Class({ this.setSize(size.width, size.height); }, - getNativeElement : function() { + getNativeElement : function() { return this.options.nativeElem; }, @@ -157,22 +156,13 @@ mindplot.IconGroup = new Class({ }, registerListeners : function() { - this.options.nativeElem.addEventListener('click', function(event) { + this.options.nativeElem.addEvent('click', function(event) { // Avoid node creation ... - if ($defined(event.stopPropagation)) { - event.stopPropagation(true); - } else { - event.cancelBubble = true; - } + event.stopPropagation(); }); - this.options.nativeElem.addEventListener('dblclick', function(event) { - // Avoid node creation ... - if ($defined(event.stopPropagation)) { - event.stopPropagation(); - } else { - event.cancelBubble = true; - } + this.options.nativeElem.addEvent('dblclick', function(event) { + event.stopPropagation(); }); }, diff --git a/mindplot/src/main/javascript/ImageIcon.js b/mindplot/src/main/javascript/ImageIcon.js index 34d733be..6080eff8 100644 --- a/mindplot/src/main/javascript/ImageIcon.js +++ b/mindplot/src/main/javascript/ImageIcon.js @@ -52,7 +52,7 @@ mindplot.ImageIcon = new Class({ //Icon var image = this.getImage(); - image.addEventListener('click', function() { + image.addEvent('click', function() { var iconType = iconModel.getIconType(); var newIconType = this._getNextFamilyIconId(iconType); @@ -63,15 +63,15 @@ mindplot.ImageIcon = new Class({ }.bind(this)); - image.addEventListener('mouseover', function(event) { + image.addEvent('mouseover', function(event) { tip.open(event, container, this); }.bind(this)); - image.addEventListener('mouseout', function(event) { + image.addEvent('mouseout', function(event) { tip.close(event); }); - image.addEventListener('mousemove', function(event) { + image.addEvent('mousemove', function(event) { tip.updatePosition(event); }); diff --git a/mindplot/src/main/javascript/LinkIcon.js b/mindplot/src/main/javascript/LinkIcon.js index c1eb6409..bce71f96 100644 --- a/mindplot/src/main/javascript/LinkIcon.js +++ b/mindplot/src/main/javascript/LinkIcon.js @@ -138,13 +138,13 @@ mindplot.LinkIcon = new Class({ } var linkIcon = this; - image.addEventListener('mouseover', function(event) { + image.addEvent('mouseover', function(event) { bubbleTip.open(event, container, linkIcon); }); - image.addEventListener('mousemove', function(event) { + image.addEvent('mousemove', function(event) { bubbleTip.updatePosition(event); }); - image.addEventListener('mouseout', function(event) { + image.addEvent('mouseout', function(event) { bubbleTip.close(event); }); }, diff --git a/mindplot/src/main/javascript/LocalActionDispatcher.js b/mindplot/src/main/javascript/LocalActionDispatcher.js index 00331513..43a3d12f 100644 --- a/mindplot/src/main/javascript/LocalActionDispatcher.js +++ b/mindplot/src/main/javascript/LocalActionDispatcher.js @@ -118,7 +118,7 @@ mindplot.LocalActionDispatcher = new Class({ var result = topic.getFontFamily(); topic.setFontFamily(fontFamily, true); - core.Executor.instance.delay(topic.updateNode, 0, topic); + topic.updateNode.delay(0, topic); return result; }; @@ -179,7 +179,7 @@ mindplot.LocalActionDispatcher = new Class({ var result = topic.getFontSize(); topic.setFontSize(size, true); - core.Executor.instance.delay(topic.updateNode, 0, topic); + topic.updateNode.delay(0, topic); return result; }; @@ -209,11 +209,7 @@ mindplot.LocalActionDispatcher = new Class({ var weight = (result == "bold") ? "normal" : "bold"; topic.setFontWeight(weight, true); - core.Executor.instance.delay(topic.updateNode, 0, topic); - /*var updated = function() { - topic.updateNode(); - }; - updated.delay(0);*/ + topic.updateNode.delay(0, topic); return result; }; diff --git a/mindplot/src/main/javascript/MindmapDesigner.js b/mindplot/src/main/javascript/MindmapDesigner.js index 928a37fb..0432d2b3 100644 --- a/mindplot/src/main/javascript/MindmapDesigner.js +++ b/mindplot/src/main/javascript/MindmapDesigner.js @@ -64,7 +64,7 @@ mindplot.MindmapDesigner = new Class({ mindplot.DesignerKeyboard.register(this); // To prevent the user from leaving the page with changes ... - window.addEvent('beforeunload', function () { + $(window).addEvent('beforeunload', function () { if (this.needsSave()) { this.save(null, false) } @@ -123,7 +123,7 @@ mindplot.MindmapDesigner = new Class({ return topics[0]; }, - addEventListener : function(eventType, listener) { + addEvent : function(eventType, listener) { this._events[eventType] = listener; }, @@ -154,7 +154,7 @@ mindplot.MindmapDesigner = new Class({ this._layoutManager.registerListenersOnNode(topic); // If a node had gained focus, clean the rest of the nodes ... - topic.addEventListener('mousedown', function(event) { + topic.addEvent('mousedown', function(event) { this.onObjectFocusEvent(topic, event); }.bind(this)); } @@ -164,7 +164,6 @@ mindplot.MindmapDesigner = new Class({ if (isConnected) { // Improve this ... var targetTopicModel = model.getParent(); - var targetTopicId = targetTopicModel.getId(); var targetTopic = null; for (var i = 0; i < topics.length; i++) { @@ -295,7 +294,7 @@ mindplot.MindmapDesigner = new Class({ } , - addRelationShip2SelectedNode : function(event) { + addRelationShip : function(event) { var screen = this._workspace.getScreenManager(); var pos = screen.getWorkspaceMousePosition(event); var selectedTopics = this.getSelectedNodes(); @@ -456,10 +455,9 @@ mindplot.MindmapDesigner = new Class({ } var relationships = mindmapModel.getRelationships(); for (var j = 0; j < relationships.length; j++) { - var relationship = this._relationshipModelToRelationship(relationships[j]); + this._relationshipModelToRelationship(relationships[j]); } } - core.Executor.instance.setLoading(false); this._getTopics().forEach(function(topic) { delete topic.getModel()._finalPosition; }); @@ -578,7 +576,7 @@ mindplot.MindmapDesigner = new Class({ relationLine.setModel(model); //Add Listeners - relationLine.addEventListener('onfocus', function(event) { + relationLine.addEvent('onfocus', function(event) { elem.onObjectFocusEvent.attempt([relationLine, event], elem); }); @@ -624,7 +622,7 @@ mindplot.MindmapDesigner = new Class({ }, - setFont2SelectedNode : function(font) { + changeFontFamily : function(font) { var validSelectedObjects = this._getValidSelectedObjectsIds(); var topicsIds = validSelectedObjects.nodes; if (topicsIds.length > 0) { @@ -641,7 +639,8 @@ mindplot.MindmapDesigner = new Class({ } }, - setFontColor2SelectedNode : function(color) { + changeFontColor : function(color) { + $assert(color,"color can not be null"); var validSelectedObjects = this._getValidSelectedObjectsIds(); var topicsIds = validSelectedObjects.nodes; if (topicsIds.length > 0) { @@ -649,7 +648,7 @@ mindplot.MindmapDesigner = new Class({ } }, - setBackColor2SelectedNode : function(color) { + changeBackgroundColor : function(color) { var validateFunc = function(topic) { return topic.getShapeType() != mindplot.model.NodeModel.SHAPE_TYPE_LINE @@ -700,7 +699,7 @@ mindplot.MindmapDesigner = new Class({ return result; }, - setBorderColor2SelectedNode : function(color) { + changeBorderColor : function(color) { var validateFunc = function(topic) { return topic.getShapeType() != mindplot.model.NodeModel.SHAPE_TYPE_LINE }; @@ -713,7 +712,7 @@ mindplot.MindmapDesigner = new Class({ } }, - setFontSize2SelectedNode : function(size) { + changeFontSize : function(size) { var validSelectedObjects = this._getValidSelectedObjectsIds(); var topicsIds = validSelectedObjects.nodes; if (topicsIds.length > 0) { @@ -722,7 +721,7 @@ mindplot.MindmapDesigner = new Class({ } , - setShape2SelectedNode : function(shape) { + changeTopicShape : function(shape) { var validateFunc = function(topic) { return !(topic.getType() == mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE && shape == mindplot.model.NodeModel.SHAPE_TYPE_LINE) }; @@ -743,7 +742,7 @@ mindplot.MindmapDesigner = new Class({ } }, - addIconType2SelectedNode : function(iconType) { + addIconType : function(iconType) { var validSelectedObjects = this._getValidSelectedObjectsIds(); var topicsIds = validSelectedObjects.nodes; if (topicsIds.length > 0) { @@ -759,7 +758,7 @@ mindplot.MindmapDesigner = new Class({ } }, - addLink2SelectedNode : function() { + addLink : function() { var selectedTopics = this.getSelectedNodes(); var topic = null; if (selectedTopics.length > 0) { @@ -811,7 +810,7 @@ mindplot.MindmapDesigner = new Class({ } }, - addNote2SelectedNode : function() { + addNote : function() { var selectedTopics = this.getSelectedNodes(); var topic = null; if (selectedTopics.length > 0) { diff --git a/mindplot/src/main/javascript/NodeGraph.js b/mindplot/src/main/javascript/NodeGraph.js index 77a9e3fe..103c0259 100644 --- a/mindplot/src/main/javascript/NodeGraph.js +++ b/mindplot/src/main/javascript/NodeGraph.js @@ -52,9 +52,9 @@ mindplot.NodeGraph = new Class({ this._model.setPosition(point.x, point.y); }, - addEventListener : function(type, listener) { + addEvent : function(type, listener) { var elem = this.get2DElement(); - elem.addEventListener(type, listener); + elem.addEvent(type, listener); }, setMouseEventsEnabled : function(isEnabled) { diff --git a/mindplot/src/main/javascript/Note.js b/mindplot/src/main/javascript/Note.js index d702de2d..faee49bb 100644 --- a/mindplot/src/main/javascript/Note.js +++ b/mindplot/src/main/javascript/Note.js @@ -96,7 +96,7 @@ mindplot.Note = new Class({ } var note = this; - image.addEventListener('mouseover', function(event) { + image.addEvent('mouseover', function(event) { var text = textModel.getText(); text = unescape(text); text = text.replace(/\n/ig, "<br/>"); @@ -106,10 +106,10 @@ mindplot.Note = new Class({ bubbleTip.open(event, container, note); }.bind(this)); - image.addEventListener('mousemove', function(event) { + image.addEvent('mousemove', function(event) { bubbleTip.updatePosition(event); }); - image.addEventListener('mouseout', function(event) { + image.addEvent('mouseout', function(event) { bubbleTip.close(event); }); }, diff --git a/mindplot/src/main/javascript/RelationshipLine.js b/mindplot/src/main/javascript/RelationshipLine.js index 5c50c08a..65b71aa0 100644 --- a/mindplot/src/main/javascript/RelationshipLine.js +++ b/mindplot/src/main/javascript/RelationshipLine.js @@ -119,7 +119,7 @@ mindplot.RelationshipLine = new Class({ workspace.appendChild(this._focusShape); workspace.appendChild(this._controlPointsController); this._controlPointControllerListener = this._initializeControlPointController.bindWithEvent(this, workspace); - this._line2d.addEventListener('click', this._controlPointControllerListener); + this._line2d.addEvent('click', this._controlPointControllerListener); this._isInWorkspace = true; workspace.appendChild(this._startArrow); @@ -135,7 +135,7 @@ mindplot.RelationshipLine = new Class({ removeFromWorkspace : function(workspace) { workspace.removeChild(this._focusShape); workspace.removeChild(this._controlPointsController); - this._line2d.removeEventListener('click', this._controlPointControllerListener); + this._line2d.removeEvent('click', this._controlPointControllerListener); this._isInWorkspace = false; workspace.removeChild(this._startArrow); workspace.removeChild(this._endArrow); @@ -175,14 +175,14 @@ mindplot.RelationshipLine = new Class({ //this._focusShape.setDestControlPoint(ctrlPoints[1]); }, - addEventListener : function(type, listener) { + addEvent : function(type, listener) { // Translate to web 2d events ... if (type == 'onfocus') { type = 'mousedown'; } var line = this._line2d; - line.addEventListener(type, listener); + line.addEvent(type, listener); }, isOnFocus : function() { diff --git a/mindplot/src/main/javascript/ShrinkConnector.js b/mindplot/src/main/javascript/ShrinkConnector.js index ed8356d0..322ba142 100644 --- a/mindplot/src/main/javascript/ShrinkConnector.js +++ b/mindplot/src/main/javascript/ShrinkConnector.js @@ -24,7 +24,7 @@ mindplot.ShirinkConnector = new Class({ elipse.setFill('#f7f7f7'); elipse.setSize(mindplot.Topic.CONNECTOR_WIDTH, mindplot.Topic.CONNECTOR_WIDTH); - elipse.addEventListener('click', function(event) { + elipse.addEvent('click', function(event) { var model = topic.getModel(); var collapse = !model.areChildrenShrinked(); @@ -37,24 +37,25 @@ mindplot.ShirinkConnector = new Class({ }); - elipse.addEventListener('mousedown', function(event) { + elipse.addEvent('mousedown', function(event) { // Avoid node creation ... var e = new Event(event).stop(); e.preventDefault(); }); - elipse.addEventListener('dblclick', function(event) { + elipse.addEvent('dblclick', function(event) { // Avoid node creation ... event = new Event(event).stop(); event.preventDefault(); }); - elipse.addEventListener('mouseover', function(event) { - this.setFill('#009900'); + elipse.addEvent('mouseover', function(event) { + + this.setFill('rgb(153, 0, 255)'); }); - elipse.addEventListener('mouseout', function(event) { + elipse.addEvent('mouseout', function(event) { var color = topic.getBackgroundColor(); this.setFill(color); }); diff --git a/mindplot/src/main/javascript/TextEditor.js b/mindplot/src/main/javascript/TextEditor.js index ea3dc496..1c38f096 100644 --- a/mindplot/src/main/javascript/TextEditor.js +++ b/mindplot/src/main/javascript/TextEditor.js @@ -45,7 +45,7 @@ mindplot.TextEditor = new Class({ var inputText = new Element('input', {type:"text",tabindex:'-1', value:""}); inputText.setStyles({ border:"none", - background:"transparent" + background:"red" }); inputText.inject(inputContainer); diff --git a/mindplot/src/main/javascript/Topic.js b/mindplot/src/main/javascript/Topic.js index fd2b2e64..e30922a0 100644 --- a/mindplot/src/main/javascript/Topic.js +++ b/mindplot/src/main/javascript/Topic.js @@ -43,11 +43,11 @@ mindplot.Topic = new Class({ this.setMouseEventsEnabled(true); // Prevent click on the topics being propagated ... - this.addEventListener('click', function(event) { + this.addEvent('click', function(event) { event.stopPropagation(); }); - this.addEventListener('dblclick', function (event) { + this.addEvent('dblclick', function (event) { this._textEditor.show(); event.stopPropagation(true); }.bind(this)); @@ -83,7 +83,7 @@ mindplot.Topic = new Class({ if ($defined(dispatcher)) { for (var i = 1; i < dispatcher._listeners.length; i++) { - innerShape.addEventListener('mousedown', dispatcher._listeners[i]); + innerShape.addEvent('mousedown', dispatcher._listeners[i]); } } @@ -373,17 +373,8 @@ mindplot.Topic = new Class({ this._icon = null; } } - /*var elem = this; - var executor = function(editor) - { - return function() - { - elem.updateNode(); - }; - }; - setTimeout(executor(this), 0);*/ - core.Executor.instance.delay(this.updateNode, 0, this); + this.updateNode.delay(0, this); this._note = null; this._hasNote = false; }, @@ -414,7 +405,7 @@ mindplot.Topic = new Class({ if (!disableEventsListeners) { // Propagate mouse events ... var topic = this; - result.addEventListener('mousedown', function(event) { + result.addEvent('mousedown', function(event) { var eventDispatcher = topic.getInnerShape()._dispatcherByEventType['mousedown']; if ($defined(eventDispatcher)) { eventDispatcher.eventListener(event); @@ -466,7 +457,7 @@ mindplot.Topic = new Class({ var model = this.getModel(); model.setFontFamily(value); } - core.Executor.instance.delay(this.updateNode, 0, this, [updateModel]); + this.updateNode.delay(0, this, [updateModel]); }, setFontSize : function(value, updateModel) { @@ -476,7 +467,7 @@ mindplot.Topic = new Class({ var model = this.getModel(); model.setFontSize(value); } - core.Executor.instance.delay(this.updateNode, 0, this, [updateModel]); + this.updateNode.delay(0, this, [updateModel]); }, @@ -487,7 +478,7 @@ mindplot.Topic = new Class({ var model = this.getModel(); model.setFontStyle(value); } - core.Executor.instance.delay(this.updateNode, 0, this, [updateModel]); + this.updateNode.delay(0, this, [updateModel]); }, setFontWeight : function(value, updateModel) { @@ -561,7 +552,7 @@ mindplot.Topic = new Class({ _setText : function(text, updateModel) { var textShape = this.getTextShape(); textShape.setText(text); - core.Executor.instance.delay(this.updateNode, 0, this, [updateModel]); + this.updateNode.delay(0, this, [updateModel]); if ($defined(updateModel) && updateModel) { var model = this.getModel(); @@ -674,14 +665,14 @@ mindplot.Topic = new Class({ topic.handleMouseOver(event); } }; - elem.addEventListener('mouseover', mouseOver); + elem.addEvent('mouseover', mouseOver); var outout = function(event) { if (topic.isMouseEventsEnabled()) { topic.handleMouseOut(event); } }; - elem.addEventListener('mouseout', outout); + elem.addEvent('mouseout', outout); // Focus events ... var mouseDown = function(event) { @@ -693,7 +684,7 @@ mindplot.Topic = new Class({ } topic.setOnFocus(value); }.bind(this); - elem.addEventListener('mousedown', mouseDown); + elem.addEvent('mousedown', mouseDown); }, areChildrenShrinked : function() { @@ -937,23 +928,23 @@ mindplot.Topic = new Class({ * type: * onfocus */ - addEventListener : function(type, listener) { + addEvent : function(type, listener) { // Translate to web 2d events ... if (type == 'onfocus') { type = 'mousedown'; } var shape = this.get2DElement(); - shape.addEventListener(type, listener); + shape.addEvent(type, listener); }, - removeEventListener : function(type, listener) { + removeEvent : function(type, listener) { // Translate to web 2d events ... if (type == 'onfocus') { type = 'mousedown'; } var shape = this.get2DElement(); - shape.removeEventListener(type, listener); + shape.removeEvent(type, listener); }, @@ -1135,6 +1126,10 @@ mindplot.Topic = new Class({ if ($defined(targetTopic)) { result.connectTo(targetTopic); } + + // If a drag node is create for it, let's hide the editor. + this._textEditor.close(); + return result; }, diff --git a/mindplot/src/main/javascript/Workspace.js b/mindplot/src/main/javascript/Workspace.js index 15c0fc8a..89fe5d2c 100644 --- a/mindplot/src/main/javascript/Workspace.js +++ b/mindplot/src/main/javascript/Workspace.js @@ -87,12 +87,12 @@ mindplot.Workspace = new Class({ } }, - addEventListener: function(type, listener) { - this._workspace.addEventListener(type, listener); + addEvent: function(type, listener) { + this._workspace.addEvent(type, listener); }, - removeEventListener: function(type, listener) { - this._workspace.removeEventListener(type, listener); + removeEvent: function(type, listener) { + this._workspace.removeEvent(type, listener); }, getSize: function() { diff --git a/mindplot/src/main/javascript/layout/FreeMindLayoutManager.js b/mindplot/src/main/javascript/layout/FreeMindLayoutManager.js index babe155c..e5f44bc5 100644 --- a/mindplot/src/main/javascript/layout/FreeMindLayoutManager.js +++ b/mindplot/src/main/javascript/layout/FreeMindLayoutManager.js @@ -52,7 +52,7 @@ mindplot.layout.FreeMindLayoutManager = mindplot.layout.BaseLayoutManager.extend var id = topic.getId(); // Register node listeners ... var designer = this.getDesigner(); - topic.addEventListener('click', function(event) + topic.addEvent('click', function(event) { designer.onObjectFocusEvent.attempt([topic, event], designer); }); @@ -60,7 +60,7 @@ mindplot.layout.FreeMindLayoutManager = mindplot.layout.BaseLayoutManager.extend // Add drag behaviour ... if (topic.getType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) { - topic.addEventListener("mousedown",this._reconnectMouseDownListener.bindWithEvent(this,[topic])); + topic.addEvent("mousedown",this._reconnectMouseDownListener.bindWithEvent(this,[topic])); } }, @@ -97,11 +97,11 @@ mindplot.layout.FreeMindLayoutManager = mindplot.layout.BaseLayoutManager.extend // Register mouse move listener ... this._mouseMoveListenerInstance = this._mouseMoveListener.bindWithEvent(this,[topic]); - screen.addEventListener('mousemove', this._mouseMoveListenerInstance); + screen.addEvent('mousemove', this._mouseMoveListenerInstance); // Register mouse up listeners ... this._mouseUpListenerInstance = this._mouseUpListener.bindWithEvent(this,[topic]); - screen.addEventListener('mouseup', this._mouseUpListenerInstance); + screen.addEvent('mouseup', this._mouseUpListenerInstance); // Change cursor. window.document.body.style.cursor = 'move'; @@ -192,8 +192,8 @@ mindplot.layout.FreeMindLayoutManager = mindplot.layout.BaseLayoutManager.extend var screen = this._designer.getWorkSpace().getScreenManager(); // Remove all the events. - screen.removeEventListener('mousemove', this._mouseMoveListenerInstance); - screen.removeEventListener('mouseup', this._mouseUpListenerInstance); + screen.removeEvent('mousemove', this._mouseMoveListenerInstance); + screen.removeEvent('mouseup', this._mouseUpListenerInstance); delete this._mouseMoveListenerInstance; delete this._mouseUpListenerInstance; @@ -289,7 +289,7 @@ mindplot.layout.FreeMindLayoutManager = mindplot.layout.BaseLayoutManager.extend mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeMouseOverEvent,show); mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeMouseOutEvent,hide); node.addHelper(moveShape); - moveShape.addEventListener("mousedown",this._mousedownListener.bindWithEvent(this,[node])); + moveShape.addEvent("mousedown",this._mousedownListener.bindWithEvent(this,[node])); }, needsPrepositioning:function(){ @@ -320,10 +320,10 @@ mindplot.layout.FreeMindLayoutManager = mindplot.layout.BaseLayoutManager.extend topics[i].setMouseEventsEnabled(false); if(topics[i].getId()!=topic.getId()){ var overListener = this._reconnectMouseOverListener.bindWithEvent(topics[i],[this]); - topics[i].addEventListener('mouseover',overListener); + topics[i].addEvent('mouseover',overListener); this._mouseOverListeners.set(topics[i].getId(),overListener); var outListener = this._reconnectMouseOutListener.bindWithEvent(topics[i],[this]); - topics[i].addEventListener('mouseout',outListener); + topics[i].addEvent('mouseout',outListener); this._mouseOutListeners.set(topics[i].getId(),outListener); } } @@ -342,11 +342,11 @@ mindplot.layout.FreeMindLayoutManager = mindplot.layout.BaseLayoutManager.extend // Register mouse move listener ... this._mouseMoveListenerInstance = this._reconnectMouseMoveListener.bindWithEvent(this,[topic]); - screen.addEventListener('mousemove', this._mouseMoveListenerInstance); + screen.addEvent('mousemove', this._mouseMoveListenerInstance); // Register mouse up listeners ... this._mouseUpListenerInstance = this._reconnectMouseUpListener.bindWithEvent(this,[topic]); - screen.addEventListener('mouseup', this._mouseUpListenerInstance); + screen.addEvent('mouseup', this._mouseUpListenerInstance); // Change cursor. window.document.body.style.cursor = 'move'; @@ -390,8 +390,8 @@ mindplot.layout.FreeMindLayoutManager = mindplot.layout.BaseLayoutManager.extend _reconnectMouseUpListener:function(event, node){ var screen = this._designer.getWorkSpace().getScreenManager(); // Remove all the events. - screen.removeEventListener('mousemove', this._mouseMoveListenerInstance); - screen.removeEventListener('mouseup', this._mouseUpListenerInstance); + screen.removeEvent('mousemove', this._mouseMoveListenerInstance); + screen.removeEvent('mouseup', this._mouseUpListenerInstance); delete this._mouseMoveListenerInstance; delete this._mouseUpListenerInstance; @@ -402,9 +402,9 @@ mindplot.layout.FreeMindLayoutManager = mindplot.layout.BaseLayoutManager.extend topics[i].setMouseEventsEnabled(true); if(topics[i].getId()!=node.getId()){ var overListener = this._mouseOverListeners.get(topics[i].getId()); - topics[i].removeEventListener('mouseover',overListener); + topics[i].removeEvent('mouseover',overListener); var outListener = this._mouseOutListeners.get(topics[i].getId()); - topics[i].removeEventListener('mouseout',outListener); + topics[i].removeEvent('mouseout',outListener); } } diff --git a/mindplot/src/main/javascript/layout/OriginalLayoutManager.js b/mindplot/src/main/javascript/layout/OriginalLayoutManager.js index 03d49fb5..ecd849b2 100644 --- a/mindplot/src/main/javascript/layout/OriginalLayoutManager.js +++ b/mindplot/src/main/javascript/layout/OriginalLayoutManager.js @@ -83,19 +83,19 @@ mindplot.layout.OriginalLayoutManager = new Class({ var dragTopicPositioner = this.getDragTopicPositioner(); - dragger.addEventListener('startdragging', function(event, node) { + dragger.addEvent('startdragging', function(event, node) { // Enable all mouse events. for (var i = 0; i < topics.length; i++) { topics[i].setMouseEventsEnabled(false); } }); - dragger.addEventListener('dragging', function(event, dragTopic) { + dragger.addEvent('dragging', function(event, dragTopic) { // Update the state and connections of the topic ... dragTopicPositioner.positionateDragTopic(dragTopic); }); - dragger.addEventListener('enddragging', function(event, dragTopic) { + dragger.addEvent('enddragging', function(event, dragTopic) { // Enable all mouse events. for (var i = 0; i < topics.length; i++) { topics[i].setMouseEventsEnabled(true); diff --git a/mindplot/src/main/javascript/widget/Menu.js b/mindplot/src/main/javascript/widget/Menu.js index b4d47f9e..cba14e7f 100644 --- a/mindplot/src/main/javascript/widget/Menu.js +++ b/mindplot/src/main/javascript/widget/Menu.js @@ -56,7 +56,7 @@ mindplot.widget.Menu = new Class({ }, setValue: function(value) { - designer.setFont2SelectedNode(value); + designer.changeFontFamily(value); } }; @@ -77,7 +77,7 @@ mindplot.widget.Menu = new Class({ return result; }, setValue: function(value) { - designer.setFontSize2SelectedNode(value); + designer.changeFontSize(value); } }; this._toolbarElems.push(new mindplot.widget.FontSizePanel("fontSize", fontSizeModel)); @@ -97,7 +97,7 @@ mindplot.widget.Menu = new Class({ return result; }, setValue: function(value) { - designer.setShape2SelectedNode(value); + designer.changeTopicShape(value); } }; this._toolbarElems.push(new mindplot.widget.TopicShapePanel("topicShape", topicShapeModel)); @@ -108,7 +108,7 @@ mindplot.widget.Menu = new Class({ return null; }, setValue: function(value) { - designer.addIconType2SelectedNode(value); + designer.addIconType(value); } }; this._toolbarElems.push(new mindplot.widget.IconPanel('topicIcon', topicIconModel)); @@ -130,7 +130,7 @@ mindplot.widget.Menu = new Class({ return result; }, setValue : function (hex) { - designer.setBackColor2SelectedNode(hex); + designer.changeBackgroundColor(hex); } }; this._toolbarElems.push(new mindplot.widget.ColorPalettePanel('topicColor', topicColorModel, baseUrl)); @@ -152,7 +152,7 @@ mindplot.widget.Menu = new Class({ return result; }, setValue : function (hex) { - designer.setBorderColor2SelectedNode(hex); + designer.changeBorderColor(hex); } }; this._toolbarElems.push(new mindplot.widget.ColorPalettePanel('topicBorder', borderColorModel, baseUrl)); @@ -174,7 +174,7 @@ mindplot.widget.Menu = new Class({ return result; }, setValue : function (hex) { - designer.setFontColor2SelectedNode(hex); + designer.changeFontColor(hex); } }; this._toolbarElems.push(new mindplot.widget.ColorPalettePanel('fontColor', fontColorModel, baseUrl)); @@ -214,16 +214,16 @@ mindplot.widget.Menu = new Class({ $('topicLink').addEvent('click', function(event) { - designer.addLink2SelectedNode(); + designer.addLink(); }); $('topicRelation').addEvent('click', function(event) { - designer.addRelationShip2SelectedNode(event); + designer.addRelationShip(event); }); $('topicNote').addEvent('click', function(event) { - designer.addNote2SelectedNode(); + designer.addNote(); }); @@ -235,7 +235,7 @@ mindplot.widget.Menu = new Class({ designer.changeFontStyle(); }); - designer.addEventListener("modelUpdate", function(event) { + designer.addEvent("modelUpdate", function(event) { if (event.undoSteps > 0) { $("undoEdition").setStyle("background-image", "url(../images/file_undo.png)"); } else { diff --git a/mindplot/src/main/javascript/widget/colorPalette.html b/mindplot/src/main/javascript/widget/colorPalette.html index 0b9a6791..9e0b3554 100644 --- a/mindplot/src/main/javascript/widget/colorPalette.html +++ b/mindplot/src/main/javascript/widget/colorPalette.html @@ -114,20 +114,17 @@ <table class="palette-table" cellspacing="0" cellpadding="0" role="grid"> <tbody class="palette-body"> <tr class="palette-row"> - <td class="palette-cell" - > + <td class="palette-cell"> <div class="palette-colorswatch" style="background-color: rgb(244, 204, 204);" title="RGB (244, 204, 204)"></div> </td> - <td class="palette-cell" - > + <td class="palette-cell"> <div class="palette-colorswatch" style="background-color: rgb(252, 229, 205);" title="RGB (252, 229, 205)"></div> </td> - <td class="palette-cell" - > + <td class="palette-cell"> <div class="palette-colorswatch" style="background-color: rgb(255, 242, 204);" title="RGB (255, 242, 204)"></div> @@ -337,7 +334,7 @@ <td class="palette-cell" > <div class="palette-colorswatch" - style="background-color: #525c61;" + style="background-color: rgb(53, 28, 117)" title="RGB (53, 28, 117)"></div> </td> <td class="palette-cell" diff --git a/web2d/src/main/javascript/Element.js b/web2d/src/main/javascript/Element.js index 4ad27aeb..4cfc399f 100644 --- a/web2d/src/main/javascript/Element.js +++ b/web2d/src/main/javascript/Element.js @@ -93,7 +93,7 @@ web2d.Element.prototype._supportedEvents = ["click","dblclick","mousemove","mous * The following events types are supported: * */ -web2d.Element.prototype.addEventListener = function(type, listener) +web2d.Element.prototype.addEvent = function(type, listener) { if (!this._supportedEvents.include(type)) { @@ -106,7 +106,7 @@ web2d.Element.prototype.addEventListener = function(type, listener) this._dispatcherByEventType[type] = new web2d.EventDispatcher(this); var eventListener = this._dispatcherByEventType[type].eventListener; - this._peer.addEventListener(type, eventListener); + this._peer.addEvent(type, eventListener); } this._dispatcherByEventType[type].addListener(type, listener); @@ -122,7 +122,7 @@ web2d.Element.prototype.addEventListener = function(type, listener) * The listener parameter takes an interface implemented by the user which contains the methods to be called when the event occurs. * This interace will be invoked passing an event as argument and the 'this' referece in the function will be the element. */ -web2d.Element.prototype.removeEventListener = function(type, listener) +web2d.Element.prototype.removeEvent = function(type, listener) { var dispatcher = this._dispatcherByEventType[type]; if (dispatcher == null) @@ -134,7 +134,7 @@ web2d.Element.prototype.removeEventListener = function(type, listener) // If there is not listeners, EventDispatcher must be removed. if (dispatcher.getListenersCount() <= 0) { - this._peer.removeEventListener(type, dispatcher.eventListener); + this._peer.removeEvent(type, dispatcher.eventListener); this._dispatcherByEventType[type] = null; } }; diff --git a/web2d/src/main/javascript/peer/svg/ElementPeer.js b/web2d/src/main/javascript/peer/svg/ElementPeer.js index b974f897..e6ea083d 100644 --- a/web2d/src/main/javascript/peer/svg/ElementPeer.js +++ b/web2d/src/main/javascript/peer/svg/ElementPeer.js @@ -1,25 +1,23 @@ /* -* Copyright [2011] [wisemapping] -* -* Licensed under WiseMapping Public License, Version 1.0 (the "License"). -* It is basically the Apache License, Version 2.0 (the "License") plus the -* "powered by wisemapping" text requirement on every single page; -* you may not use this file except in compliance with the License. -* You may obtain a copy of the license at -* -* http://www.wisemapping.org/license -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright [2011] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -web2d.peer.svg.ElementPeer = function(svgElement) -{ +web2d.peer.svg.ElementPeer = function(svgElement) { this._native = svgElement; - this._dblClickListeners = new Hash(); this._size = {width:1,height:1}; this._changeListeners = {}; // http://support.adobe.com/devsup/devsup.nsf/docs/50493.htm @@ -28,34 +26,28 @@ web2d.peer.svg.ElementPeer = function(svgElement) web2d.peer.svg.ElementPeer.prototype.svgNamespace = 'http://www.w3.org/2000/svg'; web2d.peer.svg.ElementPeer.prototype.linkNamespace = 'http://www.w3.org/1999/xlink'; -web2d.peer.svg.ElementPeer.prototype.setChildren = function(children) -{ +web2d.peer.svg.ElementPeer.prototype.setChildren = function(children) { this._children = children; }; -web2d.peer.svg.ElementPeer.prototype.getChildren = function() -{ +web2d.peer.svg.ElementPeer.prototype.getChildren = function() { var result = this._children; - if (!$defined(result)) - { + if (!$defined(result)) { result = []; this._children = result; } return result; }; -web2d.peer.svg.ElementPeer.prototype.getParent = function() -{ +web2d.peer.svg.ElementPeer.prototype.getParent = function() { return this._parent; }; -web2d.peer.svg.ElementPeer.prototype.setParent = function(parent) -{ +web2d.peer.svg.ElementPeer.prototype.setParent = function(parent) { this._parent = parent; }; -web2d.peer.svg.ElementPeer.prototype.appendChild = function(elementPeer) -{ +web2d.peer.svg.ElementPeer.prototype.appendChild = function(elementPeer) { // Store parent and child relationship. elementPeer.setParent(this); var children = this.getChildren(); @@ -69,8 +61,7 @@ web2d.peer.svg.ElementPeer.prototype.appendChild = function(elementPeer) }; -web2d.peer.svg.ElementPeer.prototype.removeChild = function(elementPeer) -{ +web2d.peer.svg.ElementPeer.prototype.removeChild = function(elementPeer) { // Store parent and child relationship. elementPeer.setParent(null); var children = this.getChildren(); @@ -81,85 +72,34 @@ web2d.peer.svg.ElementPeer.prototype.removeChild = function(elementPeer) children.erase(elementPeer); var newLength = children.length; - if (newLength >= length) - { + if (newLength >= length) { throw "Could not remove the element."; } - /*var found = false; - children = children.reject(function(iter) - { - var equals = (iter._native == elementPeer._native); - if (equals) - { - found = true; - } - return equals; - }); - - // Could found the element ? - if (!found) - { - throw "Could not remove the element."; - }*/ - // Append element as a child. this._native.removeChild(elementPeer._native); }; /** * http://www.w3.org/TR/DOM-Level-3-Events/events.html - * http://developer.mozilla.org/en/docs/addEventListener + * http://developer.mozilla.org/en/docs/addEvent */ -web2d.peer.svg.ElementPeer.prototype.addEventListener = function(type, listener) -{ - if (type == 'dblclick') - { - // This is workaround to support double click... - var dblListener = function(e) - { - if (e.detail >= 2) - { - listener.call(this, e); - } - }; +web2d.peer.svg.ElementPeer.prototype.addEvent = function(type, listener) { + + this._native.addEventListener(type, listener, false); - this._dblClickListeners[listener] = dblListener; - this._native.addEventListener(type, dblListener, false); - } else - { - this._native.addEventListener(type, listener, false); - } }; -web2d.peer.svg.ElementPeer.prototype.removeEventListener = function(type, listener) -{ - if (type == 'dblclick') - { - // This is workaround to support double click... - var dblClickListener = this._dblClickListeners[listener]; - if (dblClickListener == null) - { - throw "Could not find listener to remove"; - } - type = 'click'; - this._native.removeEventListener(type, dblClickListener, false); - delete this._dblClickListeners[listener]; - } else - { - this._native.removeEventListener(type, listener, false); - } +web2d.peer.svg.ElementPeer.prototype.removeEvent = function(type, listener) { + this._native.removeEventListener(type, listener, false); }; -web2d.peer.svg.ElementPeer.prototype.setSize = function(width, height) -{ - if ($defined(width) && this._size.width != parseInt(width)) - { +web2d.peer.svg.ElementPeer.prototype.setSize = function(width, height) { + if ($defined(width) && this._size.width != parseInt(width)) { this._size.width = parseInt(width); this._native.setAttribute('width', parseInt(width)); } - if ($defined(height) && this._size.height != parseInt(height)) - { + if ($defined(height) && this._size.height != parseInt(height)) { this._size.height = parseInt(height); this._native.setAttribute('height', parseInt(height)); } @@ -167,32 +107,26 @@ web2d.peer.svg.ElementPeer.prototype.setSize = function(width, height) web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle"); }; -web2d.peer.svg.ElementPeer.prototype.getSize = function() -{ +web2d.peer.svg.ElementPeer.prototype.getSize = function() { return {width:this._size.width,height:this._size.height}; }; -web2d.peer.svg.ElementPeer.prototype.setFill = function(color, opacity) -{ - if ($defined(color)) - { +web2d.peer.svg.ElementPeer.prototype.setFill = function(color, opacity) { + if ($defined(color)) { this._native.setAttribute('fill', color); } - if ($defined(opacity)) - { + if ($defined(opacity)) { this._native.setAttribute('fill-opacity', opacity); } }; -web2d.peer.svg.ElementPeer.prototype.getFill = function() -{ +web2d.peer.svg.ElementPeer.prototype.getFill = function() { var color = this._native.getAttribute('fill'); var opacity = this._native.getAttribute('fill-opacity'); return {color:color, opacity:Number(opacity)}; }; -web2d.peer.svg.ElementPeer.prototype.getStroke = function() -{ +web2d.peer.svg.ElementPeer.prototype.getStroke = function() { var vmlStroke = this._native; var color = vmlStroke.getAttribute('stroke'); var dashstyle = this._stokeStyle; @@ -202,18 +136,14 @@ web2d.peer.svg.ElementPeer.prototype.getStroke = function() }; web2d.peer.svg.ElementPeer.prototype.__stokeStyleToStrokDasharray = {solid:[],dot:[1,3],dash:[4,3],longdash:[10,2],dashdot:[5,3,1,3]}; -web2d.peer.svg.ElementPeer.prototype.setStroke = function(width, style, color, opacity) -{ - if ($defined(width)) - { +web2d.peer.svg.ElementPeer.prototype.setStroke = function(width, style, color, opacity) { + if ($defined(width)) { this._native.setAttribute('stroke-width', width + "px"); } - if ($defined(color)) - { + if ($defined(color)) { this._native.setAttribute('stroke', color); } - if ($defined(style)) - { + if ($defined(style)) { // Scale the dash array in order to be equal to VML. In VML, stroke style doesn't scale. var dashArrayPoints = this.__stokeStyleToStrokDasharray[style]; var scale = 1 / web2d.peer.utils.TransformUtil.workoutScale(this).width; @@ -222,8 +152,7 @@ web2d.peer.svg.ElementPeer.prototype.setStroke = function(width, style, color, o strokeWidth = parseFloat(strokeWidth); var scaledPoints = []; - for (var i = 0; i < dashArrayPoints.length; i++) - { + for (var i = 0; i < dashArrayPoints.length; i++) { // VML scale the stroke based on the stroke width. scaledPoints[i] = dashArrayPoints[i] * strokeWidth; @@ -235,53 +164,43 @@ web2d.peer.svg.ElementPeer.prototype.setStroke = function(width, style, color, o this._stokeStyle = style; } - if ($defined(opacity)) - { + if ($defined(opacity)) { this._native.setAttribute('stroke-opacity', opacity); } }; /* -* style='visibility: visible' -*/ -web2d.peer.svg.ElementPeer.prototype.setVisibility = function(isVisible) -{ + * style='visibility: visible' + */ +web2d.peer.svg.ElementPeer.prototype.setVisibility = function(isVisible) { this._native.setAttribute('visibility', (isVisible) ? 'visible' : 'hidden'); }; -web2d.peer.svg.ElementPeer.prototype.isVisible = function() -{ +web2d.peer.svg.ElementPeer.prototype.isVisible = function() { var visibility = this._native.getAttribute('visibility'); return !(visibility == 'hidden'); }; -web2d.peer.svg.ElementPeer.prototype.updateStrokeStyle = function() -{ +web2d.peer.svg.ElementPeer.prototype.updateStrokeStyle = function() { var strokeStyle = this._stokeStyle; - if (this.getParent()) - { - if (strokeStyle && strokeStyle != 'solid') - { + if (this.getParent()) { + if (strokeStyle && strokeStyle != 'solid') { this.setStroke(null, strokeStyle); } } }; -web2d.peer.svg.ElementPeer.prototype.attachChangeEventListener = function(type, listener) -{ +web2d.peer.svg.ElementPeer.prototype.attachChangeEventListener = function(type, listener) { var listeners = this.getChangeEventListeners(type); - if (!$defined(listener)) - { + if (!$defined(listener)) { throw "Listener can not be null"; } listeners.push(listener); }; -web2d.peer.svg.ElementPeer.prototype.getChangeEventListeners = function(type) -{ +web2d.peer.svg.ElementPeer.prototype.getChangeEventListeners = function(type) { var listeners = this._changeListeners[type]; - if (!$defined(listeners)) - { + if (!$defined(listeners)) { listeners = []; this._changeListeners[type] = listeners; } @@ -291,20 +210,17 @@ web2d.peer.svg.ElementPeer.prototype.getChangeEventListeners = function(type) /** * Move element to the front */ -web2d.peer.svg.ElementPeer.prototype.moveToFront = function() -{ +web2d.peer.svg.ElementPeer.prototype.moveToFront = function() { this._native.parentNode.appendChild(this._native); }; /** * Move element to the back */ -web2d.peer.svg.ElementPeer.prototype.moveToBack = function() -{ +web2d.peer.svg.ElementPeer.prototype.moveToBack = function() { this._native.parentNode.insertBefore(this._native, this._native.parentNode.firstChild); }; -web2d.peer.svg.ElementPeer.prototype.setCursor = function(type) -{ +web2d.peer.svg.ElementPeer.prototype.setCursor = function(type) { this._native.style.cursor = type; }; diff --git a/web2d/src/test/javascript/jsUnit/ElementsTestSuite.html b/web2d/src/test/javascript/jsUnit/ElementsTestSuite.html index e2067789..d608cd45 100755 --- a/web2d/src/test/javascript/jsUnit/ElementsTestSuite.html +++ b/web2d/src/test/javascript/jsUnit/ElementsTestSuite.html @@ -239,8 +239,8 @@ function testElementEventHandling() var listener = function() { /* Dummy event listener */ }; - elem.addEventListener(eventType, listener); - elem.removeEventListener(eventType, listener); + elem.addEvent(eventType, listener); + elem.removeEvent(eventType, listener); }; testEventHandling(workspace, null, 'mouseover'); diff --git a/web2d/src/test/javascript/jsUnit/WorkspaceTestSuite.html b/web2d/src/test/javascript/jsUnit/WorkspaceTestSuite.html index 677d9857..120f996a 100755 --- a/web2d/src/test/javascript/jsUnit/WorkspaceTestSuite.html +++ b/web2d/src/test/javascript/jsUnit/WorkspaceTestSuite.html @@ -59,13 +59,13 @@ function testEventTest() alert("My Listener 2"); }; - workspace.addEventListener("click", firstListener); + workspace.addEvent("click", firstListener); // Handle gracefully invalid event types... var catchException = false try { - workspace.addEventListener("click2", firstListener); + workspace.addEvent("click2", firstListener); } catch(e) { catchException = true; @@ -77,7 +77,7 @@ function testEventTest() catchException = false try { - workspace.removeEventListener("click", secondListener); + workspace.removeEvent("click", secondListener); } catch(e) { catchException = true; @@ -85,13 +85,13 @@ function testEventTest() assert("Invalid remove operation seems to be broken", catchException); //// Remove a valid listener. - workspace.removeEventListener("click", firstListener); + workspace.removeEvent("click", firstListener); //// It has been removed? catchException = false; try { - workspace.removeEventListener("click", firstListener); + workspace.removeEvent("click", firstListener); } catch(e) { catchException = true; @@ -101,16 +101,16 @@ function testEventTest() // Check multiple registation of a type ... //// Add two listeners ... - workspace.addEventListener("dblclick", firstListener); - workspace.addEventListener("dblclick", secondListener); + workspace.addEvent("dblclick", firstListener); + workspace.addEvent("dblclick", secondListener); //// Remove it ... - workspace.removeEventListener("dblclick", firstListener); - workspace.removeEventListener("dblclick", secondListener); + workspace.removeEvent("dblclick", firstListener); + workspace.removeEvent("dblclick", secondListener); /// Check multiple registration on different types ... - workspace.addEventListener("click", firstListener); - workspace.addEventListener("mouseover", secondListener); + workspace.addEvent("click", firstListener); + workspace.addEvent("mouseover", secondListener); } diff --git a/web2d/src/test/javascript/render/events.html b/web2d/src/test/javascript/render/events.html index 3f3779e9..76fcdb95 100755 --- a/web2d/src/test/javascript/render/events.html +++ b/web2d/src/test/javascript/render/events.html @@ -73,10 +73,10 @@ this._enable = !this._enable; if (this._enable) { - this._element.addEventListener(this._type, this._listener); + this._element.addEvent(this._type, this._listener); } else { - this._element.removeEventListener(this._type, this._listener); + this._element.removeEvent(this._type, this._listener); } return this._enable; }; @@ -95,7 +95,7 @@ alert("Listener #:" + count); }; this._listeners.push(listener); - this._element.addEventListener(this._type, listener); + this._element.addEvent(this._type, listener); } @@ -109,7 +109,7 @@ if (this._listeners.length > 0) { var listener = this._listeners.pop(); - this._element.removeEventListener(this._type, listener); + this._element.removeEvent(this._type, listener); } } diff --git a/web2d/src/test/javascript/render/group.html b/web2d/src/test/javascript/render/group.html index ff116ad3..e788b656 100755 --- a/web2d/src/test/javascript/render/group.html +++ b/web2d/src/test/javascript/render/group.html @@ -135,9 +135,9 @@ var listener = function(e) { alert("Click event on:" + this.getType()) }; - group.addEventListener("click", listener); - elipseLeft.addEventListener("click", listener); - elipseRight.addEventListener("click", listener); + group.addEvent("click", listener); + elipseLeft.addEvent("click", listener); + elipseRight.addEvent("click", listener); workspace.addItAsChildTo($("groupEventsContainer")); } @@ -301,7 +301,7 @@ group.setSize(100, 100); group.setPosition(0, 0); group.setCoordSize(100, 100); - group.addEventListener("mouseover", function() { + group.addEvent("mouseover", function() { alert("Mouse Over Group"); }); workspace.appendChild(group); @@ -309,7 +309,7 @@ elipseOuter = new web2d.Elipse(); elipseOuter.setPosition(50, 50); elipseOuter.setSize(50, 50); - group.addEventListener("mouseover", function() { + group.addEvent("mouseover", function() { alert("Mouse Over elipseOuter"); }); group.appendChild(elipseOuter); diff --git a/web2d/src/test/javascript/render/prototype.html b/web2d/src/test/javascript/render/prototype.html index ad5ea126..a9dda573 100755 --- a/web2d/src/test/javascript/render/prototype.html +++ b/web2d/src/test/javascript/render/prototype.html @@ -112,17 +112,17 @@ workspace.appendChild(nodeGroup); // Add behaviour ... - inerRect.addEventListener("mouseover", function() { + inerRect.addEvent("mouseover", function() { outerRect.setVisibility(true); }); - inerRect.addEventListener("mouseout", function() { + inerRect.addEvent("mouseout", function() { if (!nodeGroup._drag) { outerRect.setVisibility(false); } }); - nodeGroup.addEventListener("mousedown", function(e) + nodeGroup.addEvent("mousedown", function(e) { var shadowGroup = new web2d.Group(); shadowGroup.setSize(200, 60); @@ -165,7 +165,7 @@ shadowGroup.setPosition(posx - 50, posy - 150); }; } - workspace.addEventListener("mousemove", workspace._moveFunction); + workspace.addEvent("mousemove", workspace._moveFunction); var mouseUp = function(e) { @@ -175,11 +175,11 @@ nodeGroup.setPosition(pos.x, pos.y); nodeGroup._drag = false; outerRect.setVisibility(true); - workspace.removeEventListener("mousemove", workspace._moveFunction); - workspace.removeEventListener("mouseup", mouseUp); + workspace.removeEvent("mousemove", workspace._moveFunction); + workspace.removeEvent("mouseup", mouseUp); }; - workspace.addEventListener("mouseup", mouseUp); + workspace.addEvent("mouseup", mouseUp); }); diff --git a/web2d/src/test/javascript/render/shapes.html b/web2d/src/test/javascript/render/shapes.html index af2c1de1..c42187ff 100755 --- a/web2d/src/test/javascript/render/shapes.html +++ b/web2d/src/test/javascript/render/shapes.html @@ -246,7 +246,7 @@ var rect = new web2d.Rect(0, rectAttributes); rect.setPosition(120, 20); workspace.appendChild(rect); - rect.addEventListener("mouseover", function() { + rect.addEvent("mouseover", function() { alert("Mouse Over"); }); diff --git a/web2d/src/test/javascript/render/web2dLibraryLoader.js b/web2d/src/test/javascript/render/web2dLibraryLoader.js index 12d4a33e..90640231 100644 --- a/web2d/src/test/javascript/render/web2dLibraryLoader.js +++ b/web2d/src/test/javascript/render/web2dLibraryLoader.js @@ -84,9 +84,9 @@ web2d.Loader = web2d.Loader.checkLoaded(filename); } - if(typeof(js.addEventListener) != 'undefined') { + if(typeof(js.addEvent) != 'undefined') { /* The FF, Chrome, Safari, Opera way */ - js.addEventListener('load',calltheCBcmn,false); + js.addEvent('load',calltheCBcmn,false); } else { /* The MS IE 8+ way (may work with others - I dunno)*/ diff --git a/wise-doc/bugs.txt b/wise-doc/bugs.txt index c7ba66e4..e14a1f8e 100644 --- a/wise-doc/bugs.txt +++ b/wise-doc/bugs.txt @@ -1,6 +1,7 @@ - Ver de que algunos de los colores de las paleta sean los utilizados. - Resize de la ventana ajuste el workspace - Fixiar metodo de drag del workspace... -- Cambiar el nodo on type -- f2 -- documentar el select and unselect all + +- documentar el select , unselect all y otros +- Implementar el f1 +- Ver como re-implementar el log4j para que vuelva loguear los errores en el server. Se borro por que pesa mucho. \ No newline at end of file diff --git a/wise-doc/src/main/webapp/html/editor.html b/wise-doc/src/main/webapp/html/editor.html index 1eed88d9..ce64f3f4 100644 --- a/wise-doc/src/main/webapp/html/editor.html +++ b/wise-doc/src/main/webapp/html/editor.html @@ -13,7 +13,7 @@ <!--<script type='text/javascript' src='../js/wiseLibrary.js'></script>--> - <script type='text/javascript' src='../js/mootools-core-1.3.2-full-compat.js'></script> + <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/mootools/1.3.2/mootools-yui-compressed.js'></script> <script type='text/javascript' src='../js/mootools-more-1.3.2.1-yui.js'></script> <!--<script type='text/javascript' src='../js/common.js'></script>--> diff --git a/wise-doc/src/main/webapp/js/core.js b/wise-doc/src/main/webapp/js/core.js index 99d2a3c8..4d76f477 100644 --- a/wise-doc/src/main/webapp/js/core.js +++ b/wise-doc/src/main/webapp/js/core.js @@ -68,7 +68,7 @@ return false }if(!Log4js.loggers[categoryName]){Log4js.loggers[categoryName]=new Log4js.Logger(categoryName) }return Log4js.loggers[categoryName] },getDefaultLogger:function(){return Log4js.getLogger("[default]") -},attachEvent:function(element,name,observer){if(element.addEventListener){element.addEventListener(name,observer,false) +},attachEvent:function(element,name,observer){if(element.addEvent){element.addEvent(name,observer,false) }else{if(element.attachEvent){element.attachEvent("on"+name,observer) }}}}; Log4js.extend=function(destination,source){for(property in source){destination[property]=source[property] diff --git a/wise-doc/src/main/webapp/js/jsapi.nocache.js b/wise-doc/src/main/webapp/js/jsapi.nocache.js index 3e21827b..a0c9e911 100644 --- a/wise-doc/src/main/webapp/js/jsapi.nocache.js +++ b/wise-doc/src/main/webapp/js/jsapi.nocache.js @@ -11,6 +11,6 @@ function C(){var b=document.getElementsByTagName(hb);for(var c=0,d=b.length;c<d; function D(a){var b=s[a];return b==null?null:b} function E(a,b){var c=v;for(var d=0,e=a.length-1;d<e;++d){c=c[a[d]]||(c[a[d]]=[])}c[a[e]]=b} function F(a){var b=u[a](),c=t[a];if(b in c){return b}var d=[];for(var e in c){d[c[e]]=e}if(y){y(a,d,b)}throw null} -u[tb]=function(){var c=navigator.userAgent.toLowerCase();var d=function(a){return parseInt(a[1])*1000+parseInt(a[2])};if(function(){return c.indexOf(ub)!=-1}())return ub;if(function(){return c.indexOf(vb)!=-1||function(){if(c.indexOf(wb)!=-1){return true}if(typeof window[xb]!=bb){try{var b=new ActiveXObject(yb);if(b){b.registerBhoIfNeeded();return true}}catch(a){}}return false}()}())return zb;if(function(){return c.indexOf(Ab)!=-1&&m.documentMode>=9}())return Bb;if(function(){return c.indexOf(Ab)!=-1&&m.documentMode>=8}())return Cb;if(function(){var a=/msie ([0-9]+)\.([0-9]+)/.exec(c);if(a&&a.length==3)return d(a)>=6000}())return Db;if(function(){return c.indexOf(Eb)!=-1}())return Fb;return Gb};t[tb]={gecko1_8:0,ie6:1,ie8:2,ie9:3,opera:4,safari:5};jsapi.onScriptLoad=function(a){jsapi.onScriptLoad=null;p=a;A()};if(z()){alert(Hb+Ib);return}C();B();n&&n({moduleName:M,sessionId:o,subSystem:N,evtGroup:O,millis:(new Date).getTime(),type:Jb});var G;try{E([Db],Kb);E([zb],Lb);E([ub],Mb);E([Fb],Nb);E([Cb],Ob);E([Bb],Pb);G=v[F(tb)];var H=G.indexOf(Qb);if(H!=-1){w=Number(G.substring(H+1));G=G.substring(0,H)}}catch(a){return}var I;function J(){if(!q){q=true;A();if(m.removeEventListener){m.removeEventListener(Rb,J,false)}if(I){clearInterval(I)}}} -if(m.addEventListener){m.addEventListener(Rb,function(){J()},false)}var I=setInterval(function(){if(/loaded|complete/.test(m.readyState)){J()}},50);n&&n({moduleName:M,sessionId:o,subSystem:N,evtGroup:O,millis:(new Date).getTime(),type:U});n&&n({moduleName:M,sessionId:o,subSystem:N,evtGroup:Sb,millis:(new Date).getTime(),type:P});var K=Tb+r+G+Ub;m.write(Vb+Wb+Xb+Yb+Zb+$b+_b+Yb+Zb+ac+bc+cc+K+dc+ec+fc+gc)} +u[tb]=function(){var c=navigator.userAgent.toLowerCase();var d=function(a){return parseInt(a[1])*1000+parseInt(a[2])};if(function(){return c.indexOf(ub)!=-1}())return ub;if(function(){return c.indexOf(vb)!=-1||function(){if(c.indexOf(wb)!=-1){return true}if(typeof window[xb]!=bb){try{var b=new ActiveXObject(yb);if(b){b.registerBhoIfNeeded();return true}}catch(a){}}return false}()}())return zb;if(function(){return c.indexOf(Ab)!=-1&&m.documentMode>=9}())return Bb;if(function(){return c.indexOf(Ab)!=-1&&m.documentMode>=8}())return Cb;if(function(){var a=/msie ([0-9]+)\.([0-9]+)/.exec(c);if(a&&a.length==3)return d(a)>=6000}())return Db;if(function(){return c.indexOf(Eb)!=-1}())return Fb;return Gb};t[tb]={gecko1_8:0,ie6:1,ie8:2,ie9:3,opera:4,safari:5};jsapi.onScriptLoad=function(a){jsapi.onScriptLoad=null;p=a;A()};if(z()){alert(Hb+Ib);return}C();B();n&&n({moduleName:M,sessionId:o,subSystem:N,evtGroup:O,millis:(new Date).getTime(),type:Jb});var G;try{E([Db],Kb);E([zb],Lb);E([ub],Mb);E([Fb],Nb);E([Cb],Ob);E([Bb],Pb);G=v[F(tb)];var H=G.indexOf(Qb);if(H!=-1){w=Number(G.substring(H+1));G=G.substring(0,H)}}catch(a){return}var I;function J(){if(!q){q=true;A();if(m.removeEvent){m.removeEvent(Rb,J,false)}if(I){clearInterval(I)}}} +if(m.addEvent){m.addEvent(Rb,function(){J()},false)}var I=setInterval(function(){if(/loaded|complete/.test(m.readyState)){J()}},50);n&&n({moduleName:M,sessionId:o,subSystem:N,evtGroup:O,millis:(new Date).getTime(),type:U});n&&n({moduleName:M,sessionId:o,subSystem:N,evtGroup:Sb,millis:(new Date).getTime(),type:P});var K=Tb+r+G+Ub;m.write(Vb+Wb+Xb+Yb+Zb+$b+_b+Yb+Zb+ac+bc+cc+K+dc+ec+fc+gc)} jsapi(); \ No newline at end of file diff --git a/wise-doc/src/main/webapp/js/mootools-core-1.3.2-full-compat.js b/wise-doc/src/main/webapp/js/mootools-core-1.3.2-full-compat.js index ba62ffc3..91bdd87f 100644 --- a/wise-doc/src/main/webapp/js/mootools-core-1.3.2-full-compat.js +++ b/wise-doc/src/main/webapp/js/mootools-core-1.3.2-full-compat.js @@ -1338,7 +1338,7 @@ if (document.execCommand) try { } catch (e){} /*<ltIE9>*/ -if (this.attachEvent && !this.addEventListener){ +if (this.attachEvent && !this.addEvent){ var unloadEvent = function(){ this.detachEvent('onunload', unloadEvent); document.head = document.html = document.window = null; @@ -3758,13 +3758,13 @@ Element.implement('hasChild', function(element){ } else { collected[$uid(this)] = this; } - if (this.addEventListener) this.addEventListener(type, fn, !!arguments[2]); + if (this.addEvent) this.addEvent(type, fn, !!arguments[2]); else this.attachEvent('on' + type, fn); return this; }, removeListener: function(type, fn){ - if (this.removeEventListener) this.removeEventListener(type, fn, !!arguments[2]); + if (this.removeEvent) this.removeEvent(type, fn, !!arguments[2]); else this.detachEvent('on' + type, fn); return this; }, @@ -3790,7 +3790,7 @@ Element.implement('hasChild', function(element){ }); /*<ltIE9>*/ -if (window.attachEvent && !window.addEventListener) window.addListener('unload', function(){ +if (window.attachEvent && !window.addEvent) window.addListener('unload', function(){ Object.each(collected, clean); if (window.CollectGarbage) CollectGarbage(); }); diff --git a/wise-doc/src/main/webapp/js/mootools-core-1.3.2-full-nocompat.js b/wise-doc/src/main/webapp/js/mootools-core-1.3.2-full-nocompat.js index cba97ef7..2ff24a50 100644 --- a/wise-doc/src/main/webapp/js/mootools-core-1.3.2-full-nocompat.js +++ b/wise-doc/src/main/webapp/js/mootools-core-1.3.2-full-nocompat.js @@ -1075,7 +1075,7 @@ if (document.execCommand) try { } catch (e){} /*<ltIE9>*/ -if (this.attachEvent && !this.addEventListener){ +if (this.attachEvent && !this.addEvent){ var unloadEvent = function(){ this.detachEvent('onunload', unloadEvent); document.head = document.html = document.window = null; @@ -3348,13 +3348,13 @@ if (!document.createElement('div').contains) Element.implement(contains); } else { collected[$uid(this)] = this; } - if (this.addEventListener) this.addEventListener(type, fn, !!arguments[2]); + if (this.addEvent) this.addEvent(type, fn, !!arguments[2]); else this.attachEvent('on' + type, fn); return this; }, removeListener: function(type, fn){ - if (this.removeEventListener) this.removeEventListener(type, fn, !!arguments[2]); + if (this.removeEvent) this.removeEvent(type, fn, !!arguments[2]); else this.detachEvent('on' + type, fn); return this; }, @@ -3380,7 +3380,7 @@ if (!document.createElement('div').contains) Element.implement(contains); }); /*<ltIE9>*/ -if (window.attachEvent && !window.addEventListener) window.addListener('unload', function(){ +if (window.attachEvent && !window.addEvent) window.addListener('unload', function(){ Object.each(collected, clean); if (window.CollectGarbage) CollectGarbage(); }); diff --git a/wise-webapp/src/main/webapp/js/nicEdit.js b/wise-webapp/src/main/webapp/js/nicEdit.js index 37f48733..132d5114 100644 --- a/wise-webapp/src/main/webapp/js/nicEdit.js +++ b/wise-webapp/src/main/webapp/js/nicEdit.js @@ -144,11 +144,11 @@ var bkLib = { isMSIE : (navigator.appVersion.indexOf("MSIE") != -1), addEvent : function(obj, type, fn) { - (obj.addEventListener) ? obj.addEventListener( type, fn, false ) : obj.attachEvent("on"+type, fn); + (obj.addEvent) ? obj.addEvent( type, fn, false ) : obj.attachEvent("on"+type, fn); }, removeEvent : function(obj, type, fn) { - (obj.removeEventListener) ? obj.removeEventListener( type, fn, false ) : obj.detachEvent("on"+type, fn); + (obj.removeEvent) ? obj.removeEvent( type, fn, false ) : obj.detachEvent("on"+type, fn); }, toArray : function(iterable) { @@ -194,8 +194,8 @@ var bkLib = { }, onDomLoaded : function(fireThis) { this.domLoad.push(fireThis); - if (document.addEventListener) { - document.addEventListener("DOMContentLoaded", bkLib.domLoaded, null); + if (document.addEvent) { + document.addEvent("DOMContentLoaded", bkLib.domLoaded, null); } else if(bkLib.isMSIE) { document.write("<style>.nicEdit-main p { margin: 0; }</style><scr"+"ipt id=__ie_onload defer " + ((location.protocol == "https:") ? "src='javascript:void(0)'" : "src=//0") + "><\/scr"+"ipt>"); $BK("__ie_onload").onreadystatechange = function() {