diff options
Diffstat (limited to 'js/panels/css-panel/style-sheet.reel/style-sheet.js')
-rw-r--r-- | js/panels/css-panel/style-sheet.reel/style-sheet.js | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/js/panels/css-panel/style-sheet.reel/style-sheet.js b/js/panels/css-panel/style-sheet.reel/style-sheet.js new file mode 100644 index 00000000..4f9ad21f --- /dev/null +++ b/js/panels/css-panel/style-sheet.reel/style-sheet.js | |||
@@ -0,0 +1,107 @@ | |||
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 | Component = require("montage/ui/component").Component; | ||
9 | |||
10 | exports.StyleSheet = Montage.create(Component, { | ||
11 | _translateDistance: { | ||
12 | value: null | ||
13 | }, | ||
14 | |||
15 | willDraw : { | ||
16 | value: function() { | ||
17 | console.log("style sheet view - will draw"); | ||
18 | |||
19 | if(this.editing) { | ||
20 | document.body.addEventListener('mousedown', this, false); | ||
21 | this._translateDistance = this._element.offsetWidth - this.editButton._element.offsetWidth; | ||
22 | |||
23 | } else { | ||
24 | document.body.removeEventListener('mousedown', this, false); | ||
25 | } | ||
26 | } | ||
27 | }, | ||
28 | draw : { | ||
29 | value: function() { | ||
30 | var transStr = '-webkit-transform'; | ||
31 | console.log("styles sheet view - draw"); | ||
32 | |||
33 | this.mediaInput.value = this._source.media.mediaText; | ||
34 | |||
35 | if(this.editing) { | ||
36 | this.editView.classList.add('expanded'); | ||
37 | this.editView.style.setProperty(transStr, 'translate3d(-'+ this._translateDistance + 'px,0,0)'); | ||
38 | } else { | ||
39 | this.editView.classList.remove('expanded'); | ||
40 | this.editView.style.removeProperty(transStr); | ||
41 | } | ||
42 | } | ||
43 | }, | ||
44 | |||
45 | |||
46 | |||
47 | handleEditButtonAction: { | ||
48 | value: function(e) { | ||
49 | console.log('handle edit button action'); | ||
50 | this.editing = true; | ||
51 | } | ||
52 | }, | ||
53 | _editing : { | ||
54 | value: null | ||
55 | }, | ||
56 | editing : { | ||
57 | get: function() { | ||
58 | return this._editing; | ||
59 | }, | ||
60 | set: function(enterEditingMode) { | ||
61 | this._editing = enterEditingMode; | ||
62 | this.needsDraw = true; | ||
63 | } | ||
64 | }, | ||
65 | |||
66 | handleMousedown : { | ||
67 | value: function(e) { | ||
68 | console.log("handle mousedown"); | ||
69 | if(e.target !== this.editView && e.target !== this.editButton) { | ||
70 | this.editing = false; | ||
71 | } | ||
72 | } | ||
73 | }, | ||
74 | |||
75 | mediaInput: { | ||
76 | value: null | ||
77 | }, | ||
78 | |||
79 | _name: { | ||
80 | value: null | ||
81 | }, | ||
82 | name : { | ||
83 | get: function() { | ||
84 | return this._name; | ||
85 | }, | ||
86 | set: function(text) { | ||
87 | this._name = text; | ||
88 | } | ||
89 | }, | ||
90 | _source : { | ||
91 | value: null | ||
92 | }, | ||
93 | source : { | ||
94 | get: function() { | ||
95 | return this._source; | ||
96 | }, | ||
97 | set: function(sheet) { | ||
98 | console.log('sheet being set: ', sheet.ownerNode); | ||
99 | if(sheet.href) { | ||
100 | this.name = sheet.href.substring(sheet.href.lastIndexOf('/')+1); | ||
101 | } else { | ||
102 | this.name = 'Style Tag'; | ||
103 | } | ||
104 | this._source = sheet; | ||
105 | } | ||
106 | } | ||
107 | }); \ No newline at end of file | ||