kopia lustrzana https://github.com/c9/core
Merge pull request +9147 from c9/salesforce-update
Fixes/improvements for Salesforcepull/134/merge
commit
00b5935b2e
|
@ -258,6 +258,7 @@ module.exports = function(options) {
|
||||||
"plugins/c9.ide.dialog.common/filechange",
|
"plugins/c9.ide.dialog.common/filechange",
|
||||||
"plugins/c9.ide.dialog.common/fileoverwrite",
|
"plugins/c9.ide.dialog.common/fileoverwrite",
|
||||||
"plugins/c9.ide.dialog.common/fileremove",
|
"plugins/c9.ide.dialog.common/fileremove",
|
||||||
|
"plugins/c9.ide.dialog.common/info",
|
||||||
"plugins/c9.ide.dialog.common/question",
|
"plugins/c9.ide.dialog.common/question",
|
||||||
{
|
{
|
||||||
packagePath: "plugins/c9.ide.dialog.common/error",
|
packagePath: "plugins/c9.ide.dialog.common/error",
|
||||||
|
|
|
@ -31,6 +31,10 @@
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
}
|
}
|
||||||
|
.infolabel.errorlabel div{
|
||||||
|
background: @dialog-background-color;
|
||||||
|
color: @label-color;
|
||||||
|
}
|
||||||
.errorlabel.fade-in div{
|
.errorlabel.fade-in div{
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ define(function(require, exports, module) {
|
||||||
var lastCookie = 0;
|
var lastCookie = 0;
|
||||||
var offset = 0;
|
var offset = 0;
|
||||||
var error, hideTimeout, disconnect;
|
var error, hideTimeout, disconnect;
|
||||||
|
var lastClassname;
|
||||||
|
|
||||||
var DISCONNECTDELAY = 1000;
|
var DISCONNECTDELAY = 1000;
|
||||||
|
|
||||||
|
@ -85,17 +86,19 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function show(message, timeout) {
|
function show(message, timeout) {
|
||||||
metrics.increment("dialog.error");
|
|
||||||
|
|
||||||
// Error message container
|
// Error message container
|
||||||
if (!error) {
|
if (!error) {
|
||||||
error = document.body.appendChild(document.createElement("div"));
|
error = document.body.appendChild(document.createElement("div"));
|
||||||
error.className = "errorlabel";
|
|
||||||
error.addEventListener("mouseup", function(e) {
|
error.addEventListener("mouseup", function(e) {
|
||||||
if (e.target.tagName == "U")
|
if (e.target.tagName == "U")
|
||||||
hide();
|
hide();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
error.className = "errorlabel "
|
||||||
|
+ (message.className ? message.className : "");
|
||||||
|
|
||||||
|
if (!message.noError) {
|
||||||
|
metrics.increment("dialog.error");
|
||||||
|
|
||||||
if (!message) {
|
if (!message) {
|
||||||
console.trace();
|
console.trace();
|
||||||
|
@ -104,6 +107,7 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
console.error("Error:",
|
console.error("Error:",
|
||||||
message.stack || message.html || message.message || message);
|
message.stack || message.html || message.message || message);
|
||||||
|
}
|
||||||
|
|
||||||
hide(function() {
|
hide(function() {
|
||||||
var messageString;
|
var messageString;
|
||||||
|
@ -127,8 +131,10 @@ define(function(require, exports, module) {
|
||||||
error.firstChild.style.marginLeft = Math.max(0, (getCenterX() - (error.firstChild.offsetWidth / 2))) + "px";
|
error.firstChild.style.marginLeft = Math.max(0, (getCenterX() - (error.firstChild.offsetWidth / 2))) + "px";
|
||||||
|
|
||||||
// Start anim
|
// Start anim
|
||||||
|
lastClassname = message.className;
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
error.className = "errorlabel anim " + (offset > 0 ? "fade-in" : "");
|
error.className = "errorlabel anim " + (offset > 0 ? "fade-in" : "")
|
||||||
|
+ " " + (message.className || "");
|
||||||
error.style.top = (offset + topPx) + "px";
|
error.style.top = (offset + topPx) + "px";
|
||||||
error.style.opacity = 1;
|
error.style.opacity = 1;
|
||||||
}, 10);
|
}, 10);
|
||||||
|
@ -150,7 +156,8 @@ define(function(require, exports, module) {
|
||||||
if (!error || error.style.display === "none")
|
if (!error || error.style.display === "none")
|
||||||
return callback && callback();
|
return callback && callback();
|
||||||
|
|
||||||
error.className = "errorlabel anim " + (offset > 0 ? "fade-in" : "");
|
error.className = "errorlabel anim " + (offset > 0 ? "fade-in " : " ")
|
||||||
|
+ (lastClassname ? lastClassname : "");
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
error.style.opacity = 0;
|
error.style.opacity = 0;
|
||||||
else
|
else
|
||||||
|
@ -258,6 +265,10 @@ define(function(require, exports, module) {
|
||||||
get vfs(){ throw new Error("Permission Denied"); },
|
get vfs(){ throw new Error("Permission Denied"); },
|
||||||
set vfs(v){ initDisconnectEvents(v); },
|
set vfs(v){ initDisconnectEvents(v); },
|
||||||
|
|
||||||
|
get visible() {
|
||||||
|
return error && error.style.display !== "none" && error.className;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -271,11 +282,15 @@ define(function(require, exports, module) {
|
||||||
/**
|
/**
|
||||||
* Displays an error message in the main error reporting UI.
|
* Displays an error message in the main error reporting UI.
|
||||||
* @param {String} message The message to display.
|
* @param {String} message The message to display.
|
||||||
|
* @param {Number} [timeout] A custom timeout for this error to hide, or -1 for no hiding.
|
||||||
|
* @returns a cookie for use with hide()
|
||||||
*/
|
*/
|
||||||
show: show,
|
show: show,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hides the main error reporting UI.
|
* Hides the main error reporting UI.
|
||||||
|
*
|
||||||
|
* @param [cookie] A cookie indicating the popup to hide
|
||||||
*/
|
*/
|
||||||
hide: hide,
|
hide: hide,
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
define(function(require, exports, module) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
main.consumes = ["Plugin", "ui", "metrics", "dialog.error"];
|
||||||
|
main.provides = ["dialog.info"];
|
||||||
|
return main;
|
||||||
|
|
||||||
|
function main(options, imports, register) {
|
||||||
|
var Plugin = imports.Plugin;
|
||||||
|
var plugin = new Plugin("Ajax.org", main.consumes);
|
||||||
|
var error = imports["dialog.error"];
|
||||||
|
|
||||||
|
function show(message, timeout) {
|
||||||
|
var visible = error.visible;
|
||||||
|
if (visible && visible.indexOf("infolabel") === -1) {
|
||||||
|
return -1; // already showing error instead
|
||||||
|
}
|
||||||
|
|
||||||
|
var options = typeof message === "string"
|
||||||
|
? { message: message }
|
||||||
|
: message;
|
||||||
|
options.className = "infolabel";
|
||||||
|
options.noError = true;
|
||||||
|
return error.show(options, timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show error messages to the user
|
||||||
|
*
|
||||||
|
* This plugin provides a way to display error messages to the user.
|
||||||
|
*
|
||||||
|
* @singleton
|
||||||
|
**/
|
||||||
|
plugin.freezePublicAPI({
|
||||||
|
/**
|
||||||
|
* Displays an info message in the main info reporting UI.
|
||||||
|
* @param {String} message The message to display.
|
||||||
|
* @param {Number} [timeout] A custom timeout for this error to hide, or -1 for no hiding.
|
||||||
|
* @returns a cookie for use with hide()
|
||||||
|
*/
|
||||||
|
show: show,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hides the main error reporting UI.
|
||||||
|
*
|
||||||
|
* @param [cookie] A cookie indicating the popup to hide
|
||||||
|
*/
|
||||||
|
hide: error.hide.bind(error),
|
||||||
|
});
|
||||||
|
|
||||||
|
register(null, { "dialog.info" : plugin });
|
||||||
|
}
|
||||||
|
});
|
Ładowanie…
Reference in New Issue