From 896adeb1668da2986621cac1b24f2c73f3c840f8 Mon Sep 17 00:00:00 2001 From: "David Humphrey (:humph) david.humphrey@senecacollege.ca" Date: Tue, 9 May 2017 18:46:07 -0400 Subject: [PATCH] Revert "Fix: #1675 - Console User Interface (work by @raygervais) (#752)" This reverts commit ca4f169ee270d5972ee9ca790a4124cf3f9466aa. There are changes in here not related to the PR. --- locales/en-US/editor.properties | 8 - src/extensions/bramble-extensions.json | 3 - .../default/bramble/htmlContent/console.html | 8 - .../bramble/lib/ConsoleInterfaceManager.js | 153 ---------- .../default/bramble/lib/ConsoleManager.js | 12 +- .../bramble/lib/ConsoleManagerRemote.js | 33 +-- .../bramble/lib/PostMessageTransport.js | 4 +- src/extensions/default/bramble/lib/UI.js | 8 + .../bramble/stylesheets/consoleTheme.less | 279 ------------------ src/styles/images/icons/close-icon-dark.svg | 1 - src/styles/images/icons/close-icon-light.svg | 1 - src/styles/images/icons/console-icon-dark.svg | 1 - .../images/icons/console-icon-light.svg | 1 - 13 files changed, 19 insertions(+), 493 deletions(-) delete mode 100644 src/extensions/default/bramble/htmlContent/console.html delete mode 100644 src/extensions/default/bramble/lib/ConsoleInterfaceManager.js delete mode 100644 src/extensions/default/bramble/stylesheets/consoleTheme.less delete mode 100644 src/styles/images/icons/close-icon-dark.svg delete mode 100644 src/styles/images/icons/close-icon-light.svg delete mode 100644 src/styles/images/icons/console-icon-dark.svg delete mode 100644 src/styles/images/icons/console-icon-light.svg diff --git a/locales/en-US/editor.properties b/locales/en-US/editor.properties index bb24b220a0d..63dcacb5009 100644 --- a/locales/en-US/editor.properties +++ b/locales/en-US/editor.properties @@ -193,11 +193,3 @@ ERROR_MOVING_FILE_DIALOG_HEADER=Move Error UNEXPECTED_ERROR_MOVING_FILE=An unexpected error occurred when attempting to move {0} to {1} # {0} is the name of the file/folder being moved and {1} is the name of the folder it is being moved to ERROR_MOVING_FILE_SAME_NAME=A file or folder with the name {0} already exists in {1}. Consider renaming either one to continue. - -# extensions/default/bramble/console -CONSOLE_TITLE=Console -CONSOLE_TOOLTIP=Open the JavaScript Console -CONSOLE_CLEAR=Clear -CONSOLE_CLEAR_TOOLTIP=Clear the Console -CONSOLE_CLOSE_TOOLTIP=Close the Console -CONSOLE_EMPTY_STRING=Empty String diff --git a/src/extensions/bramble-extensions.json b/src/extensions/bramble-extensions.json index 2f613f62959..61ed958b303 100644 --- a/src/extensions/bramble-extensions.json +++ b/src/extensions/bramble-extensions.json @@ -84,9 +84,6 @@ "dist/extensions/default/bramble/stylesheets/style.css": [ "src/extensions/default/bramble/stylesheets/style.less" ], - "dist/extensions/default/bramble/stylesheets/consoleTheme.css": [ - "src/extensions/default/bramble/stylesheets/consoleTheme.less" - ], "dist/extensions/default/bramble/stylesheets/lightTheme.css": [ "src/extensions/default/bramble/stylesheets/lightTheme.less" ], diff --git a/src/extensions/default/bramble/htmlContent/console.html b/src/extensions/default/bramble/htmlContent/console.html deleted file mode 100644 index fa7311e61ee..00000000000 --- a/src/extensions/default/bramble/htmlContent/console.html +++ /dev/null @@ -1,8 +0,0 @@ -
-
- {{CONSOLE_TITLE}} - - -
-
-
diff --git a/src/extensions/default/bramble/lib/ConsoleInterfaceManager.js b/src/extensions/default/bramble/lib/ConsoleInterfaceManager.js deleted file mode 100644 index d7402251c72..00000000000 --- a/src/extensions/default/bramble/lib/ConsoleInterfaceManager.js +++ /dev/null @@ -1,153 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 Alexandru Ghiura - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * / - -/*jslint vars: true, plusplus: true, nomen: true */ -/*global define, console, brackets, $, Mustache */ - -define(function (require, exports, module) { - "use strict"; - - var AppInit = brackets.getModule("utils/AppInit"), - WorkspaceManager = brackets.getModule("view/WorkspaceManager"), - ExtensionUtils = brackets.getModule("utils/ExtensionUtils"), - PreferencesManager = brackets.getModule("preferences/PreferencesManager"), - panelHTML = require("text!htmlContent/console.html"), - Mustache = brackets.getModule("thirdparty/mustache/mustache"), - Strings = brackets.getModule("strings"); - - var panel, - showConsoleTab = null, - livePreviewOnly = false, - wasClosedByUser = false, - unreadCount = 0, - consoleEl = null, - maxLogs = 30; - - function clear() { - consoleEl.html(""); - unreadCount = 0; - } - - function showPanel(){ - unreadCount = 0; - panel.show(); - showConsoleTab.removeClass("has-unseen-logs"); - $("#editor-holder").addClass("console-open"); - panel.$panel.find(".console").animate({ scrollTop: consoleEl[0].scrollHeight }, 10); - } - - function hidePanel(){ - panel.hide(); - $("#editor-holder").removeClass("console-open"); - panel.$panel.find(".console div").removeClass("new-log"); - } - - function addLine(type, item) { - var $element = $("
"); - - if(typeof item === "object") { - item = JSON.stringify(item); - } else { - // Force non-strings to show as string. - item = "" + item; - } - - if(!item.length) { - item = Strings.CONSOLE_EMPTY_STRING; - $element.addClass("empty-string"); - } - - $element.text(item); - - if(panel.isVisible()) { - $element.addClass("new-log"); - } - - consoleEl.append($element); - - var logCount = consoleEl.find("div").length; - if(logCount > maxLogs) { - consoleEl.find(":first-child").remove(); - } - - consoleEl.animate({ scrollTop: consoleEl[0].scrollHeight }, 10); - } - - function add(type, args) { - // Display the console when user code triggers console.* functions, - // but only if the console was not already closed by the user. - if(!panel.isVisible() && !wasClosedByUser) { - showPanel(); - } - - if(!panel.isVisible()) { - unreadCount++; - } - - if(unreadCount > 0) { - showConsoleTab.removeClass("has-unseen-logs").width(showConsoleTab.width()); - showConsoleTab.addClass("has-unseen-logs"); - } - - args.forEach(function(arg) { - addLine(type, arg); - }); - } - - function togglePanel() { - if (panel.isVisible()) { - hidePanel(); - } else { - showPanel(); - wasClosedByUser = false; - } - } - - AppInit.htmlReady(function () { - ExtensionUtils.loadStyleSheet(module, "../stylesheets/consoleTheme.less"); - - // Localization & Creation of HTMl Elements - panelHTML = Mustache.render(panelHTML, Strings); - panel = WorkspaceManager.createBottomPanel("console.panel", $(panelHTML)); - - var iconString = "
"; - showConsoleTab = $(Mustache.render(iconString, Strings)); - showConsoleTab.appendTo($("#editor-holder")); - - consoleEl = panel.$panel.find(".console"); - - panel.$panel.find("#clearConsole").on("click", function () { - clear(); - }); - - panel.$panel.find(".close").on("click", function () { - hidePanel(); - wasClosedByUser = true; - }); - - showConsoleTab.on("click", togglePanel); - }); - - exports.add = add; -}); diff --git a/src/extensions/default/bramble/lib/ConsoleManager.js b/src/extensions/default/bramble/lib/ConsoleManager.js index 4471b54239f..529eac68b2d 100644 --- a/src/extensions/default/bramble/lib/ConsoleManager.js +++ b/src/extensions/default/bramble/lib/ConsoleManager.js @@ -1,8 +1,7 @@ define(function (require, exports, module) { "use strict"; - var ConsoleInterfaceManager = require("lib/ConsoleInterfaceManager"), - ConsoleManagerRemote = require("text!lib/ConsoleManagerRemote.js"); + var ConsoleManagerRemote = require("text!lib/ConsoleManagerRemote.js"); function getRemoteScript() { return "\n"; @@ -16,13 +15,8 @@ define(function (require, exports, module) { var args = data.args; var type = data.type || "log"; - if (type === "time" || type === "timeEnd"){ - args[0] = type + ": " + args[0]; - } - - if (args) { - ConsoleInterfaceManager.add(type, args); - } + // TODO: Show this in Custom Console UI, see issue #1675 in Thimble + console[type].apply(console, args); } exports.getRemoteScript = getRemoteScript; diff --git a/src/extensions/default/bramble/lib/ConsoleManagerRemote.js b/src/extensions/default/bramble/lib/ConsoleManagerRemote.js index cd73984bf24..4aa6a57c443 100644 --- a/src/extensions/default/bramble/lib/ConsoleManagerRemote.js +++ b/src/extensions/default/bramble/lib/ConsoleManagerRemote.js @@ -1,11 +1,11 @@ (function(transport, console) { "use strict"; - - function transportSend(type, args) { + + function transportSend(type, args) { var data = {args: args, type: type}; transport.send("bramble-console", data); } - + // Implement standard console.* functions ["log", "warn", @@ -18,37 +18,16 @@ "timeEnd"].forEach(function(type) { console[type] = function() { var args = Array.prototype.slice.call(arguments); - var data = []; - - // Flatten data to send, deal with Error objects - args.forEach(function(arg) { - if(arg instanceof Error) { - data.push(arg.message); - data.push(arg.stack); - } else { - data.push(arg); - } - }); - - transportSend(type, data); + transportSend(type, args); }; }); - - // Implements global error handler for top-level errors - window.addEventListener("error", function(messageOrEvents) { - var message = messageOrEvents.message; - var error = messageOrEvents.error || {}; - var stack = error.stack || "Error Interpretting Stack"; - - transportSend("error", [ message, stack ]); - }, false); - + console.assert = function() { var args = Array.prototype.slice.call(arguments); var expr = args.shift(); if (!expr) { args[0] = "Assertion Failed: " + args[0]; - transportSend("error", args); + transportSend(args, "error"); } }; }(window._Brackets_LiveDev_Transport, window.console)); diff --git a/src/extensions/default/bramble/lib/PostMessageTransport.js b/src/extensions/default/bramble/lib/PostMessageTransport.js index c21deae2e5a..d2c3b5755bf 100644 --- a/src/extensions/default/bramble/lib/PostMessageTransport.js +++ b/src/extensions/default/bramble/lib/PostMessageTransport.js @@ -96,8 +96,8 @@ define(function (require, exports, module) { ConsoleManager.handleConsoleRequest(msgObj.data); return; } - - // Trigger message event + + // Trigger message event module.exports.trigger("message", [connId, msgObj.message]); } else if (msgObj.type === "connect") { Browser.setListener(); diff --git a/src/extensions/default/bramble/lib/UI.js b/src/extensions/default/bramble/lib/UI.js index cd105c672aa..65457405dd0 100644 --- a/src/extensions/default/bramble/lib/UI.js +++ b/src/extensions/default/bramble/lib/UI.js @@ -90,6 +90,14 @@ define(function (require, exports, module) { PreferencesManager.set("wordWrap", wordWrap); } + var autoCloseTags = BrambleStartupState.ui("autoCloseTags") || { whenOpening: true, whenClosing: true, indentTags: [] }; + PreferencesManager.set("closeTags", autoCloseTags); + + var openSVGasXML = BrambleStartupState.ui("openSVGasXML"); + if(typeof openSVGasXML === "boolean") { + PreferencesManager.set("openSVGasXML", openSVGasXML); + } + var allowJavaScript = BrambleStartupState.ui("allowJavaScript"); if(typeof allowJavaScript === "boolean") { PreferencesManager.set("allowJavaScript", allowJavaScript); diff --git a/src/extensions/default/bramble/stylesheets/consoleTheme.less b/src/extensions/default/bramble/stylesheets/consoleTheme.less deleted file mode 100644 index 46ff2cd896f..00000000000 --- a/src/extensions/default/bramble/stylesheets/consoleTheme.less +++ /dev/null @@ -1,279 +0,0 @@ -#editor-console { - position: relative; -} - -#editor-console .console { - overflow-x: hidden; - max-height: inherit; - height: calc(100% - 44px) !important; - box-sizing: border-box; -} - -#editor-console .log-entry { - width: 100%; - padding: 6px 15px; - background: none; - border: 0; - outline: none; - box-shadow: none; - display: block; - font-size: 15px; - font-family: 'Menlo Regular', Consolas, Inconsolata, 'Vera Sans', 'Lucida Console', Courier, monospace, fixed; - user-select: text; - color: black; - transform-origin: 15% 50%; - white-space: pre-line; -} - -.dark #editor-console .log-entry { - color: white; -} - -#editor-console .log-entry.empty-string { - color: rgba(0,0,0,.6); - font-style: italic; -} - -.dark #editor-console .log-entry.empty-string { - color: rgba(255,255,255,.6); - font-style: italic; -} - -#editor-console .log-entry.new-log { - animation: newLogFlash 1.5s ease-out, consolePop .2s ease-out; -} - - -@keyframes newLogFlash { - 0% { - opacity: 1; - background-color: rgba(13,142,204,.2); - } - 70% { - opacity: 1; - background-color: rgba(13,142,204,.2); - } - 100% { - opacity: .7; - background-color: transparent; - } -} - -@keyframes newLogPop { - 0% { transform: scale(1.03); } - 100% { transform: scale(1); } -} - -#editor-console .console .error { - color: #ED488B; -} - -#editor-console .console .warn { - color: #707000; -} - -#editor-console .console .time { - color: #5BA87E; -} -#editor-console .console .timeEnd { - color: #A0779F; -} - -#editor-console .console .debug { - color: #8ACDEA; -} - -#editor-console .title { - font-weight: 600; - font-family: "Open Sans", "Helvetica Neue", Arial, sans-serif; - font-size: 16px; - color: rgba(0,0,0,.3); - text-transform: uppercase; -} - -.dark #editor-console .title { - color: rgba(255,255,255,.4); -} - -#editor-console .badge { - text-shadow: none; - margin-left: 4px; - margin-bottom: -1px; - margin-right: -6px; -} - -#editor-console #filterBtns .btn { - border-radius: 0; - background: inherit; - border: none; - box-shadow: none; - padding: 10px 15px; -} - -/* Tab at the bottom of the page that shows the console when it's closed */ - -.show-console-tab { - position: absolute; - background-color: rgba(0,0,0,.2); - bottom: -2px; - right: 15px; - color: #222; - height: 30px; - width: 36px; - background-image: url(/src/styles/images/icons/console-icon-dark.svg); - background-position: center 7px; - background-size: 17px; - background-repeat: no-repeat; - border-radius: 2px 2px 0 0; - opacity: .5; - transition: all .2s ease-out; - cursor: pointer; -} - -.dark .show-console-tab { - background-color: rgba(0,0,0,.9); - background-image: url(/src/styles/images/icons/console-icon-light.svg); -} - -.show-console-tab.has-unseen-logs, -.dark .show-console-tab.has-unseen-logs { - background-image: url(/src/styles/images/icons/console-icon-light.svg); - background-color: #0d8ecc; - animation: consoleTabPop .2s ease-out; - transform-origin: bottom; - opacity: .8; -} - -@keyframes consoleTabPop { - 0% { transform: scaleY(1.2); } - 100% { transform: scale(1); } -} - -.show-console-tab:hover { - transform: translateY(-2px); - opacity: 1; -} - -/* Hide the console tab when the console is open */ - -.console-open .show-console-tab { - display: none; -} - -/* Basic styles for the console */ - -#editor-console, -.dark #editor-console { - border-top: none; - background: #EEE; -} - -.dark #editor-console { - background: #222; -} - -#editor-console .toolbar, -.dark #editor-console .toolbar { - box-shadow: none; - border: none; - padding: 10px 15px; -} - -#editor-console .toolbar { - background: #CCCCCB; -} - -.dark #editor-console .toolbar { - background: #3F3F3F; -} - -/* Vertical resizer overrides */ - -#editor-console .vert-resizer { - height: 10px; - background: rgba(0, 0, 0, .08); -} - -.dark #editor-console .vert-resizer { - background: rgba(255, 255, 255, .08); -} - -#editor-console .vert-resizer:hover, -#editor-console .vert-resizer.active { - opacity: 1; -} - -/* Close button in the console header bar */ - -#editor-console .close { - display: block; - width: 32px; - height: 32px; - background-position: center; - background-repeat: no-repeat; - background-image: url(/src/styles/images/icons/close-icon-dark.svg); - background-size: 14px; - top: 16px; - border-radius: 50%; - opacity: .6; - outline: none; - box-shadow: none; -} - -.dark #editor-console .close { - background-image: url(/src/styles/images/icons/close-icon-light.svg); -} - -#editor-console .close:hover { - opacity: .8; - background-color: rgba(255,255,255,.35); -} - -.dark #editor-console .close:hover { - background-image: url(/src/styles/images/icons/close-icon-light.svg); - background-color: rgba(0,0,0,.2); -} - -#editor-console .close:active { - background-color: rgba(255,255,255,.5); -} - -.dark #editor-console .close:active { - background-image: url(/src/styles/images/icons/close-icon-light.svg); - background-color: rgba(0,0,0,.75); -} - -/* Clear button in console header */ - -#editor-console .clear-button { - font-family: "Open Sans", sans-serif; - margin: 0 0 0 12px; - outline: none; - padding: 3px 8px; - border: none; - font-weight: 600; - border-radius: 12px; - background: rgba(255,255,255,.5); - color: rgba(0,0,0,.4); -} - -.dark #editor-console .clear-button { - background: #222; - color: rgba(255,255,255,.5); -} - -#editor-console .clear-button:hover { - color: rgba(0,0,0,.7); -} - -.dark #editor-console .clear-button:hover { - color: rgba(255,255,255,.8); -} - -#editor-console .clear-button:active { - background: rgba(255,255,255,1); -} - -.dark #editor-console .clear-button:active { - background: #1b1b1b; -} diff --git a/src/styles/images/icons/close-icon-dark.svg b/src/styles/images/icons/close-icon-dark.svg deleted file mode 100644 index 298d7a3560f..00000000000 --- a/src/styles/images/icons/close-icon-dark.svg +++ /dev/null @@ -1 +0,0 @@ -close-icon-white \ No newline at end of file diff --git a/src/styles/images/icons/close-icon-light.svg b/src/styles/images/icons/close-icon-light.svg deleted file mode 100644 index 7cfe03858c1..00000000000 --- a/src/styles/images/icons/close-icon-light.svg +++ /dev/null @@ -1 +0,0 @@ -close-icon-white \ No newline at end of file diff --git a/src/styles/images/icons/console-icon-dark.svg b/src/styles/images/icons/console-icon-dark.svg deleted file mode 100644 index 28f4d23bbb0..00000000000 --- a/src/styles/images/icons/console-icon-dark.svg +++ /dev/null @@ -1 +0,0 @@ -console-icon-dark \ No newline at end of file diff --git a/src/styles/images/icons/console-icon-light.svg b/src/styles/images/icons/console-icon-light.svg deleted file mode 100644 index 547ba570816..00000000000 --- a/src/styles/images/icons/console-icon-light.svg +++ /dev/null @@ -1 +0,0 @@ -console-icon-light \ No newline at end of file