aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage-user/ui/popup/notifier.reel/notifier.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/montage-user/ui/popup/notifier.reel/notifier.js')
-rwxr-xr-xnode_modules/montage-user/ui/popup/notifier.reel/notifier.js121
1 files changed, 121 insertions, 0 deletions
diff --git a/node_modules/montage-user/ui/popup/notifier.reel/notifier.js b/node_modules/montage-user/ui/popup/notifier.reel/notifier.js
new file mode 100755
index 00000000..6346cd19
--- /dev/null
+++ b/node_modules/montage-user/ui/popup/notifier.reel/notifier.js
@@ -0,0 +1,121 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6
7/**
8 @module "montage/ui/popup/notifier.reel"
9 @requires montage/core/core
10 @requires montage/ui/component
11 @requires "montage/ui/popup/popup.reel"
12*/
13var Montage = require("montage").Montage;
14var Component = require("ui/component").Component;
15var Popup = require("ui/popup/popup.reel").Popup;
16
17/**
18 @class module:"montage/ui/popup/notifier.reel".Notifier
19 @extends module:montage/ui/component.Component
20 */
21
22var Notifier = exports.Notifier = Montage.create(Component, /** @lends module:"montage/ui/popup/notifier.reel".Notifier# */ {
23 hasTemplate: {value: true},
24
25 _msgEl: {value: null},
26/**
27 Description TODO
28 @private
29*/
30 _msg: {value: null},
31/**
32 Description TODO
33 @type {Function}
34 @default null
35 */
36 msg: {
37 get: function() {
38 return this._msg;
39 },
40 set: function(value) {
41 if (this._msg !== value) {
42 this._msg = value;
43 this.needsDraw = true;
44 }
45 }
46 },
47/**
48 Description TODO
49 @type {Property}
50 @default {String} null
51 */
52 details: {
53 value: null
54 },
55/**
56 Description TODO
57 @function
58 */
59 draw: {
60 value: function() {
61 this._msgEl.textContent = this.msg;
62 }
63 },
64
65 // Static method to show a Notify dialog
66 /**
67 Displays a small Growl-like notification in a pop-up dialog. The notification can have a timeout that determines how long it appears before being hidden automatically.
68 You can also specify the location of the notification in the browser window (top-left corner, by default).
69 @function
70 @param {String} msg A message to display in the notification.
71 @param {Number} timeout The number of milliseconds to display the notification before it is hidden.
72 @param {Object} Contains two properties named top and left that specify top and left coordinates of the notifiction. By default, notifications are positioned at the top-left corner of the window.
73 */
74 show: {
75 value: function(msg, timeout, position) {
76 var popup = this.application._notifyPopup, notifier;
77 if(!popup) {
78 popup = Popup.create();
79 this.popup = popup;
80 popup.type = 'notify';
81 popup.boxed = false;
82 this.application._notifyPopup = popup;
83
84 notifier = Notifier.create();
85 popup.content = notifier;
86 }
87 notifier = popup.content;
88 //popup.modal = !!modal;
89 notifier.msg = msg;
90
91 if (!position) {
92 // position at the top by default
93 var viewportWidth = window.innerWidth;
94 position = {
95 top: 1,
96 right: 10
97 };
98 }
99 popup.position = position;
100
101 if(timeout) {
102 timeout = parseInt(timeout, 10) || 3000;
103 popup.autoDismiss = timeout;
104 }
105
106 popup.show();
107
108
109 }
110 },
111
112 hide: {
113 value: function() {
114 var popup = this.application._notifyPopup;
115 if(popup) {
116 popup.hide();
117 }
118 }
119 }
120
121});