From fb24d7c9a5fb050b1c4109ea9ffd908d68be3c7f Mon Sep 17 00:00:00 2001 From: Paulo Veiga Date: Tue, 9 Aug 2011 02:27:59 -0300 Subject: [PATCH] Remove UserAgent class. Use mootools. --- core-js/pom.xml | 1 - core-js/src/main/javascript/UserAgent.js | 135 ------------------ .../src/main/javascript/MindmapDesigner.js | 6 +- mindplot/src/main/javascript/Workspace.js | 2 +- mindplot/src/test/javascript/simpleTest.js | 2 +- .../src/test/javascript/static/palette.html | 2 +- 6 files changed, 6 insertions(+), 142 deletions(-) delete mode 100644 core-js/src/main/javascript/UserAgent.js diff --git a/core-js/pom.xml b/core-js/pom.xml index eb5e4d9d..b7c33ac3 100644 --- a/core-js/pom.xml +++ b/core-js/pom.xml @@ -54,7 +54,6 @@ ${basedir}/target/tmp/log4js-min.js ${basedir}/target/tmp/Monitor-min.js ${basedir}/target/tmp/Point-min.js - ${basedir}/target/tmp/UserAgent-min.js ${basedir}/target/tmp/Utils-min.js ${basedir}/target/tmp/WaitDialog-min.js ${basedir}/target/tmp/footer-min.js diff --git a/core-js/src/main/javascript/UserAgent.js b/core-js/src/main/javascript/UserAgent.js deleted file mode 100644 index 67c65d3b..00000000 --- a/core-js/src/main/javascript/UserAgent.js +++ /dev/null @@ -1,135 +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. -*/ - -core.UserAgent = { - isMozillaFamily: function() - { - return this.browser == "Netscape" || this.browser == "Firefox"; - }, - isIE: function() - { - return this.browser == "Explorer"; - }, - init: function () { - this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; - this.version = this.searchVersion(navigator.userAgent) - || this.searchVersion(navigator.appVersion) - || "an unknown version"; - this.OS = this.searchString(this.dataOS) || "an unknown OS"; - }, - searchString: function (data) { - for (var i = 0; i < data.length; i++) { - var dataString = data[i].string; - var dataProp = data[i].prop; - this.versionSearchString = data[i].versionSearch || data[i].identity; - if (dataString) { - if (dataString.indexOf(data[i].subString) != -1) - return data[i].identity; - } - else if (dataProp) - return data[i].identity; - } - }, - searchVersion: function (dataString) { - var index = dataString.indexOf(this.versionSearchString); - if (index == -1) return; - return parseFloat(dataString.substring(index + this.versionSearchString.length + 1)); - }, - dataBrowser: [ - { string: navigator.userAgent, - subString: "OmniWeb", - versionSearch: "OmniWeb/", - identity: "OmniWeb" - }, - { - string: navigator.vendor, - subString: "Apple", - identity: "Safari" - }, - { - string: navigator.vendor, - subString: "Google Inc.", - identity: "Chrome" - }, - { - prop: window.opera, - identity: "Opera" - }, - { - string: navigator.vendor, - subString: "iCab", - identity: "iCab" - }, - { - string: navigator.vendor, - subString: "KDE", - identity: "Konqueror" - }, - { - string: navigator.userAgent, - subString: "Firefox", - identity: "Firefox" - }, - { - string: navigator.vendor, - subString: "Camino", - identity: "Camino" - }, - { // for newer Netscapes (6+) - string: navigator.userAgent, - subString: "Netscape", - identity: "Netscape" - }, - { - string: navigator.userAgent, - subString: "MSIE", - identity: "Explorer", - versionSearch: "MSIE" - }, - { - string: navigator.userAgent, - subString: "Gecko", - identity: "Mozilla", - versionSearch: "rv" - }, - { // for older Netscapes (4-) - string: navigator.userAgent, - subString: "Mozilla", - identity: "Netscape", - versionSearch: "Mozilla" - } - ], - dataOS : [ - { - string: navigator.platform, - subString: "Win", - identity: "Windows" - }, - { - string: navigator.platform, - subString: "Mac", - identity: "Mac" - }, - { - string: navigator.platform, - subString: "Linux", - identity: "Linux" - } - ] -}; -core.UserAgent.init(); \ No newline at end of file diff --git a/mindplot/src/main/javascript/MindmapDesigner.js b/mindplot/src/main/javascript/MindmapDesigner.js index a85e614d..978d4c60 100644 --- a/mindplot/src/main/javascript/MindmapDesigner.js +++ b/mindplot/src/main/javascript/MindmapDesigner.js @@ -159,7 +159,7 @@ mindplot.MindmapDesigner = new Class({ var selectableObjects = this.getSelectedObjects(); // Disable all nodes on focus but not the current if Ctrl key isn't being pressed - if (!$defined(event) || event.ctrlKey == false) { + if (!$defined(event) || (event.ctrlKey == false && event.metaKey == false)) { selectableObjects.forEach(function(selectableObject) { if (selectableObject.isOnFocus() && selectableObject != currentObject) { selectableObject.setOnFocus(false); @@ -333,7 +333,7 @@ mindplot.MindmapDesigner = new Class({ this._actionRunner.markAsChangeBase(); }, - loadFromCollaborativeModel: function(collaborationManager){ + loadFromCollaborativeModel: function(collaborationManager) { var mindmap = collaborationManager.buildWiseModel(); this._loadMap(1, mindmap); @@ -745,7 +745,7 @@ mindplot.MindmapDesigner = new Class({ dialog.adopt(msg).show(); // IE doesn't like too much this focus action... - if (!core.UserAgent.isIE()) { + if (!Browser.ie) { urlInput.focus(); } } diff --git a/mindplot/src/main/javascript/Workspace.js b/mindplot/src/main/javascript/Workspace.js index 4a4852a7..31250991 100644 --- a/mindplot/src/main/javascript/Workspace.js +++ b/mindplot/src/main/javascript/Workspace.js @@ -171,7 +171,7 @@ mindplot.Workspace = new Class({ workspace.setCoordOrigin(coordOriginX, coordOriginY); // Change cursor. - if (core.UserAgent.isMozillaFamily()) { + if (Browser.firefox) { window.document.body.style.cursor = "-moz-grabbing"; } else { window.document.body.style.cursor = "move"; diff --git a/mindplot/src/test/javascript/simpleTest.js b/mindplot/src/test/javascript/simpleTest.js index c0e6d12b..f902b652 100644 --- a/mindplot/src/test/javascript/simpleTest.js +++ b/mindplot/src/test/javascript/simpleTest.js @@ -98,7 +98,7 @@ TestCase("Mindplot test",{ var fireNativeEvent = function(type, target, position){ var event; - if(core.UserAgent.isIE()){ + if(Browser.ie){ event = document.createEventObject(); event.screenX = position.x; event.screenY = position.y; diff --git a/mindplot/src/test/javascript/static/palette.html b/mindplot/src/test/javascript/static/palette.html index e58a815d..943322db 100644 --- a/mindplot/src/test/javascript/static/palette.html +++ b/mindplot/src/test/javascript/static/palette.html @@ -24,7 +24,7 @@ console.log("value:" + value); } }; - var palette = new mindplot.widget.ColorPalette('myButton', model,"/mindplot/src/main/javascript/widget"); + var palette = new mindplot.widget.ColorPalettePanel('myButton', model,"/mindplot/src/main/javascript/widget"); });