diff options
author | Pierre Frisch | 2011-12-22 07:25:50 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-01-27 11:18:17 -0800 |
commit | b89a7ee8b956c96a1dcee995ea840feddc5d4b27 (patch) | |
tree | 0f3136ab0ecdbbbed6a83576581af0a53124d6f1 /js/components/layout/document-bar.reel/document-bar.js | |
parent | 2401f05d1f4b94d45e4568b81fc73e67b969d980 (diff) | |
download | ninja-b89a7ee8b956c96a1dcee995ea840feddc5d4b27.tar.gz |
First commit of Ninja to ninja-internal
Signed-off-by: Valerio Virgillito <rmwh84@motorola.com>
Diffstat (limited to 'js/components/layout/document-bar.reel/document-bar.js')
-rw-r--r-- | js/components/layout/document-bar.reel/document-bar.js | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/js/components/layout/document-bar.reel/document-bar.js b/js/components/layout/document-bar.reel/document-bar.js new file mode 100644 index 00000000..3eece273 --- /dev/null +++ b/js/components/layout/document-bar.reel/document-bar.js | |||
@@ -0,0 +1,101 @@ | |||
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 | var Montage = require("montage/core/core").Montage; | ||
8 | var Component = require("montage/ui/component").Component; | ||
9 | |||
10 | exports.DocumentBar = Montage.create(Component, { | ||
11 | |||
12 | designView: { value: null, enumerable: false}, | ||
13 | codeView: { value: null, enumerable: false}, | ||
14 | zoomControl: { value: null, enumerable: false }, | ||
15 | _type: { enumerable: false, value: null }, | ||
16 | |||
17 | type: { | ||
18 | enumerable: false, | ||
19 | get: function() { return this._type; }, | ||
20 | set: function(value) { | ||
21 | if (this._type === value) { | ||
22 | return; | ||
23 | } | ||
24 | |||
25 | this._type = value; | ||
26 | this.needsDraw = true; | ||
27 | |||
28 | } | ||
29 | }, | ||
30 | |||
31 | _currentView: { value: null, enumerable: false }, | ||
32 | |||
33 | currentView: { | ||
34 | get: function() { return this._currentView}, | ||
35 | set: function(value) { | ||
36 | if (this._currentView === value) { | ||
37 | return; | ||
38 | } | ||
39 | |||
40 | this._currentView = value; | ||
41 | this.needsDraw = true; | ||
42 | } | ||
43 | }, | ||
44 | |||
45 | _zoomFactor: { value: 100, enumerable: false }, | ||
46 | |||
47 | zoomFactor: { | ||
48 | get: function() { return this._zoomFactor; }, | ||
49 | |||
50 | set: function(value) | ||
51 | { | ||
52 | if(value !== this._zoomFactor) | ||
53 | { | ||
54 | this._zoomFactor = value; | ||
55 | if (!this._firstDraw) | ||
56 | { | ||
57 | var viewUtils = this.application.ninja.stage.viewUtils; | ||
58 | this.application.ninja.stage.setZoom(value); | ||
59 | } | ||
60 | } | ||
61 | } | ||
62 | }, | ||
63 | |||
64 | draw: { | ||
65 | value: function() { | ||
66 | if(this.type === "htm" || this.type === "html") { | ||
67 | this.designView.classList.add("active"); | ||
68 | this.codeView.classList.add("active"); | ||
69 | |||
70 | if(this.currentView === "design") { | ||
71 | this.designView.classList.add("selected"); | ||
72 | if(this.codeView.classList.contains("selected")) this.codeView.classList.toggle("selected"); | ||
73 | } else { | ||
74 | this.codeView.classList.add("selected"); | ||
75 | if(this.designView.classList.contains("selected")) this.designView.classList.toggle("selected"); | ||
76 | } | ||
77 | |||
78 | } else if(this.type) { | ||
79 | this.designView.classList.remove("active"); | ||
80 | } | ||
81 | |||
82 | } | ||
83 | }, | ||
84 | |||
85 | prepareForDraw: { | ||
86 | value: function() { | ||
87 | this.designView.addEventListener("click", this, false); | ||
88 | this.codeView.addEventListener("click", this, false); | ||
89 | |||
90 | } | ||
91 | }, | ||
92 | |||
93 | handleClick: { | ||
94 | value: function(event) { | ||
95 | if(event._event.target.id === this.currentView) return; | ||
96 | |||
97 | this.currentView = event._event.target.id; | ||
98 | documentManagerModule.DocumentManager.switchViews(); | ||
99 | } | ||
100 | } | ||
101 | }); | ||