2
2
* @fileOverview Contains the "MessageConsole" class definition.
3
* @author <a href="mailto:keith.hughitt@nasa.gov">Keith Hughitt</a>
3
* @author <a href="mailto:keith.hughitt@gmail.com">Keith Hughitt</a>
5
/*jslint browser: true, white: true, onevar: true, undef: true, nomen: false, eqeqeq: true, plusplus: true,
6
bitwise: true, regexp: true, strict: true, newcap: true, immed: true, maxlen: 120, sub: true */
7
/*global document, $, Class, window */
9
var MessageConsole = Class.extend(
10
/** @lends MessageConsole.prototype */
5
/*global document, UIElement, Effect, $, Class, Element, Event, window */
6
var MessageConsole = Class.create(UIElement ,
7
/** @lends MessageConsole.prototype */
14
11
* @description Creates a new MessageConsole.<br><br>
15
12
* MessageConsole Provides a mechanism for displayed useful information to the user.
16
* For ease of use, the class provides methods comparable to Firebug's for outputting
17
* messages of different natures: "log" for generic unstyled messages, or for debbuging
18
* use, "info" to inform the user of some interesting change or event, and "warning" and
19
* "error" for getting the user's attention.
13
* For ease of use, the class provides methods comparable to Firebug's for outputting
14
* messages of different natures: "log" for generic unstyled messages, or for debbuging
15
* use, "info" to inform the user of some interesting change or event, and "warning" and
16
* "error" for getting the user's attention.
20
17
* @param {Object} controller A reference to the Helioviewer (controller)
18
* @param {String} container The id of the container for messages to be displayed in
19
* @param {String} viewport The id of the viewport container
22
init: function (controller) {
21
initialize: function (controller, container, viewport) {
23
22
this.controller = controller;
23
this.console = $(container);
24
this.viewportId = viewport;
27
* @description Logs a message to the message-console
28
* @param {String} msg Message to display
28
* @description Logs a message to the message-console
29
* @param {String} msg Message to display
30
31
log: function (msg) {
35
* @description Makes a jGrowl notification and allows options to modify the notification
37
* @param {Object} options
39
info: function (msg, options) {
40
$.jGrowl(msg, options);
44
progress: function (msg) {
49
* @description Displays a warning message in the message console
50
* @param {String} msg Message to display
32
this.console.update(new Element('p', {style: 'color: #6495ED; font-weight: bold;'}).insert(msg));
34
trash = new Effect.Appear(this.console, { duration: 3.0 });
36
//Hide the message after several seconds have passed
37
window.setTimeout(function () {
38
var trash = new Effect.Fade(self.console, { duration: 3.0 });
42
//info: function (msg) {
46
* @description Displays a warning message in the message console
47
* @param {String} msg Message to display
52
49
warn: function (msg) {
50
this.console.update(new Element('p', {style: 'color: yellow; font-weight: bolder;'}).insert(msg));
52
trash = new Effect.Appear(this.console, { duration: 3.0 });
54
//Hide the message after several seconds have passed
55
window.setTimeout(function () {
56
var trash = new Effect.Fade(self.console, { duration: 3.0 });
57
* @description Displays an error message in the message console
58
* @param {String} msg Message to display
61
* @description Displays an error message in the message console
62
* @param {String} msg Message to display
60
64
error: function (msg) {
62
$("#helioviewer-viewport-container-outer").effect("shake", { times: 1 });
65
this.console.update(new Element('p', {style: 'color: red'}).insert(msg));
67
trash = new Effect.Shake(this.viewportId, {distance: 15, duration: 0.1});
68
trash = new Effect.Appear(this.console, { duration: 3.0 });
70
//Hide the message after several seconds have passed
71
window.setTimeout(function () {
72
var trash = new Effect.Fade(self.console, { duration: 3.0 });
66
* @description Displays message along with a hyperlink in the message console
67
* @param {String} msg Message to display
68
* @param {String} Hyperlink text
69
* Note: Event-handler should be used to handle hyperlink clicks. The link address thus is set to "#".
77
* @description Displays message along with a hyperlink in the message console
78
* @param {String} msg Message to display
79
* @param {String} Hyperlink text (Note: Event-handler should be used to handle hyperlink clicks. The link address thus is set to "#")
71
81
link: function (msg, linkText) {
74
// Generate a temporary id
75
linkId = 'link-' + this.controller.date.getTime() / 1000;
78
html = "<a href='#' id='" + linkId + "' class='message-console-link'>" + linkText + "</a>" + msg;
80
$.jGrowl(html, {sticky: true});
83
linkId, wrapper, link, trash;
85
// Generate a temporary id
86
linkId = 'link-' + this.controller.date.getTime() / 1000;
89
wrapper = new Element('span');
90
link = new Element('a', {href: '#', id: linkId, 'class': 'message-console-link'}).update(linkText);
94
this.console.update(new Element('p', {style: 'color: #6495ED;'}).insert(wrapper));
95
trash = new Effect.Appear(this.console, { duration: 2.0 });
97
//For downloads, leave the message up until the user clicks on the link provided.
98
//Note: another possibility is to add a "close" option.
99
Event.observe(linkId, 'click', function () {