diff options
author | Nivesh Rajbhandari | 2012-02-20 11:14:44 -0800 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-02-20 11:14:44 -0800 |
commit | abf78e2d7a97d295ce5a1c425fd359d47379137e (patch) | |
tree | d08c91bd2aef31e6325e0b499b2ffc390018bec6 /js/io/ui/cloudpopup.reel/cloudpopup.js | |
parent | e80a79bff57fecf3aa9b869d8ed2de5fd815287c (diff) | |
parent | e23708721a71ca4c71365f5f8e8ac7d6113926db (diff) | |
download | ninja-abf78e2d7a97d295ce5a1c425fd359d47379137e.tar.gz |
Merge branch 'refs/heads/ninja-internal' into ToolFixes
Diffstat (limited to 'js/io/ui/cloudpopup.reel/cloudpopup.js')
-rwxr-xr-x | js/io/ui/cloudpopup.reel/cloudpopup.js | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/js/io/ui/cloudpopup.reel/cloudpopup.js b/js/io/ui/cloudpopup.reel/cloudpopup.js new file mode 100755 index 00000000..a2283d46 --- /dev/null +++ b/js/io/ui/cloudpopup.reel/cloudpopup.js | |||
@@ -0,0 +1,140 @@ | |||
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 | // | ||
9 | var Montage = require("montage/core/core").Montage, | ||
10 | Component = require("montage/ui/component").Component; | ||
11 | //////////////////////////////////////////////////////////////////////// | ||
12 | // | ||
13 | exports.CloudPopup = Montage.create(Component, { | ||
14 | //////////////////////////////////////////////////////////////////// | ||
15 | // | ||
16 | hasTemplate: { | ||
17 | value: true | ||
18 | }, | ||
19 | //////////////////////////////////////////////////////////////////// | ||
20 | // | ||
21 | _os: { | ||
22 | value: null | ||
23 | }, | ||
24 | //////////////////////////////////////////////////////////////////// | ||
25 | // | ||
26 | components: { | ||
27 | enumerable: false, | ||
28 | value: {test_btn: null, ok_btn: null, cancel_btn: null, download_btn: null, status: null, url: null} | ||
29 | }, | ||
30 | //////////////////////////////////////////////////////////////////// | ||
31 | // | ||
32 | prepareForDraw: { | ||
33 | enumerable: false, | ||
34 | value: function () { | ||
35 | // | ||
36 | this.components.test_btn = this.element.getElementsByClassName('btn_test nj-skinned')[0]; | ||
37 | this.components.ok_btn = this.element.getElementsByClassName('btn_ok nj-skinned')[0]; | ||
38 | this.components.cancel_btn = this.element.getElementsByClassName('btn_cancel nj-skinned')[0]; | ||
39 | this.components.status = this.element.getElementsByClassName('status')[0]; | ||
40 | this.components.url = this.element.getElementsByClassName('cloud_url')[0]; | ||
41 | this.components.download_btn = this.element.getElementsByClassName('btn_download nj-skinned')[0]; | ||
42 | } | ||
43 | }, | ||
44 | //////////////////////////////////////////////////////////////////// | ||
45 | // | ||
46 | willDraw: { | ||
47 | enumerable: false, | ||
48 | value: function() { | ||
49 | // | ||
50 | if (navigator.appVersion.indexOf("Win")!=-1) { | ||
51 | this._os = 'windows'; | ||
52 | } else if (navigator.appVersion.indexOf("Mac")!=-1) { | ||
53 | this._os = 'mac'; | ||
54 | } else { | ||
55 | //Alternate message for no OS detected (probably Linux) | ||
56 | this.element.getElementsByTagName('section')[0].style.display = 'none'; | ||
57 | } | ||
58 | } | ||
59 | }, | ||
60 | //////////////////////////////////////////////////////////////////// | ||
61 | // | ||
62 | draw: { | ||
63 | enumerable: false, | ||
64 | value: function() { | ||
65 | // | ||
66 | this.testConnection(); | ||
67 | if (this.application.ninja.coreIoApi.cloudAvailable()) { | ||
68 | this.closeDialog(); | ||
69 | } | ||
70 | } | ||
71 | }, | ||
72 | //////////////////////////////////////////////////////////////////// | ||
73 | // | ||
74 | didDraw: { | ||
75 | enumerable: false, | ||
76 | value: function() { | ||
77 | // | ||
78 | this.components.download_btn.addEventListener('click', this.downloadCloudApp.bind(this), false); | ||
79 | // | ||
80 | this.components.test_btn.addEventListener('click', this.testConnection.bind(this), false); | ||
81 | // | ||
82 | this.components.ok_btn.addEventListener('click', this.closeDialog.bind(this), false); | ||
83 | this.components.cancel_btn.addEventListener('click', this.cancelDialog.bind(this), false); | ||
84 | } | ||
85 | }, | ||
86 | //////////////////////////////////////////////////////////////////// | ||
87 | // | ||
88 | downloadCloudApp: { | ||
89 | enumerable: false, | ||
90 | value: function() { | ||
91 | if(this._os === 'mac') { | ||
92 | location.href = '/ninja_localcloud_for_mac.zip'; | ||
93 | } else if (this._os === 'windows') { | ||
94 | location.href = '/ninja_localcloud_for_windows.zip'; | ||
95 | } else { | ||
96 | alert('Your operating system is not supported by the Ninja Local Cloud App.'); | ||
97 | } | ||
98 | } | ||
99 | }, | ||
100 | //////////////////////////////////////////////////////////////////// | ||
101 | // | ||
102 | testConnection: { | ||
103 | enumerable: false, | ||
104 | value: function() { | ||
105 | // | ||
106 | this.application.ninja.coreIoApi.rootUrl = this.components.url.value; | ||
107 | // | ||
108 | if (this.application.ninja.coreIoApi.cloudAvailable()) { | ||
109 | this.components.status.style.color = '#77FF00'; | ||
110 | this.components.status.innerHTML = 'Connected to '+this.application.ninja.coreIoApi.cloudData.name; | ||
111 | } else { | ||
112 | this.components.status.style.color = '#FF3A3A'; | ||
113 | this.components.status.innerHTML = 'Disconnected'; | ||
114 | } | ||
115 | } | ||
116 | }, | ||
117 | //////////////////////////////////////////////////////////////////// | ||
118 | // | ||
119 | closeDialog: { | ||
120 | enumerable: false, | ||
121 | value: function() { | ||
122 | // | ||
123 | this.application.ninja.coreIoApi.hideCloudDialog(); | ||
124 | } | ||
125 | }, | ||
126 | //////////////////////////////////////////////////////////////////// | ||
127 | // | ||
128 | cancelDialog: { | ||
129 | enumerable: false, | ||
130 | value: function() { | ||
131 | // | ||
132 | this.application.ninja.coreIoApi.rootUrl = null; | ||
133 | this.application.ninja.coreIoApi.hideCloudDialog(); | ||
134 | } | ||
135 | } | ||
136 | //////////////////////////////////////////////////////////////////// | ||
137 | //////////////////////////////////////////////////////////////////// | ||
138 | }); | ||
139 | //////////////////////////////////////////////////////////////////////// | ||
140 | //////////////////////////////////////////////////////////////////////// \ No newline at end of file | ||