JavaScriptを色々あれこれしようとするがひたすら失敗を繰り返している
リビジョン | 53 (tree) |
---|---|
日時 | 2016-12-18 06:29:39 |
作者 | ![]() |
・機能パレットのリファクタリング、動作面ではほぼ完了
・Save/Loadについては未対応
・まだ以前の実装が残っているため削除する必要がある(削除実施前にようやく動作するようになったので、念のためコミットしておく)
@@ -108,7 +108,7 @@ | ||
108 | 108 | margin: 0px; padding: 5px; |
109 | 109 | border: 1px solid transparent; |
110 | 110 | border-radius: 8px; |
111 | - background-color: #fff; | |
111 | +/* background-color: #fff; */ | |
112 | 112 | box-shadow: 16px 16px 19px -11px rgba(0, 0, 0, 0.21); |
113 | 113 | } |
114 | 114 | .pallegend { |
@@ -161,7 +161,6 @@ | ||
161 | 161 | .palflex { |
162 | 162 | display: flex; |
163 | 163 | flex-wrap: wrap; |
164 | - position: relative; | |
165 | 164 | overflow: scroll; |
166 | 165 | width: calc(100% - 20px); height: calc(100% - 40px); |
167 | 166 | margin: -5px 10px; padding: 15px; |
@@ -168,60 +167,37 @@ | ||
168 | 167 | background-color: gray; |
169 | 168 | box-shadow: 10px 10px 20px -4px #777 inset; |
170 | 169 | opacity: 0.6; |
171 | - text-decoration: none; | |
172 | 170 | justify-content: flex-start; |
173 | 171 | } |
174 | 172 | /* パレット要素の定義 */ |
175 | - .palbg, | |
176 | - .paltxtcol, | |
177 | - .palact, | |
178 | - .palset { | |
173 | + .palettebackground, | |
174 | + .palettestyle, | |
175 | + .paletteaction, | |
176 | + .palettesetting { | |
179 | 177 | display: inline-block; |
180 | - position: absolute; | |
181 | - width: 50px; height: 50px; | |
182 | - border-radius: 8px; | |
183 | - margin: 4px; padding: 0; | |
178 | + position: relative; | |
179 | + width: 60px; height: 60px; | |
180 | + margin: 7px 7px; padding: 0; | |
181 | + border-radius: 50%; | |
184 | 182 | text-align: center; |
185 | - font-size: 45px; line-height: 45px; | |
183 | + font-size: 55px; line-height: 55px; | |
184 | + transition: all 0.2s ease-out; | |
186 | 185 | } |
187 | - .palbg { | |
188 | - border: 1px solid rgba(0,0,0,0.2); | |
186 | + .palettebackground { | |
189 | 187 | background-color: rgba(27, 158, 131, 0.6); |
190 | - box-shadow: 10px 10px 20px -4px rgba(0,0,0,0.21); | |
191 | - /* ********************** */ | |
192 | - position: relative; | |
193 | - width: 60px; height: 60px; | |
194 | - margin: 7px 7px; padding: 0; | |
195 | 188 | } |
196 | - .paltxtcol { | |
197 | - border: 1px solid rgba(0,0,0,0.2); | |
189 | + .palettestyle { | |
198 | 190 | background-color: rgba(154,145,140,0.6); |
199 | - box-shadow: 10px 10px 20px -4px rgba(0,0,0,0.21); | |
200 | - /* ********************** */ | |
201 | - position: relative; | |
202 | - width: 60px; height: 60px; | |
203 | - margin: 7px 7px; padding: 0; | |
204 | 191 | } |
205 | - .palact { | |
206 | - border: 1px solid rgba(0,0,0,0.2); | |
192 | + .paletteaction { | |
207 | 193 | background-color: rgba(156, 165, 55, 0.6); |
208 | - box-shadow: 10px 10px 20px -4px rgba(0,0,0,0.21); | |
209 | - /* ********************** */ | |
210 | - position: relative; | |
211 | - width: 60px; height: 60px; | |
212 | - margin: 7px 7px; padding: 0; | |
213 | 194 | } |
214 | - .palset { | |
215 | - border: 1px solid rgba(0,0,0,0.2); | |
195 | + .palettesetting { | |
216 | 196 | background-color: rgba(27, 158, 131, 0.6); |
217 | - box-shadow: 10px 10px 20px -4px rgba(0,0,0,0.21); | |
218 | - /* ********************** */ | |
219 | - position: relative; | |
220 | - width: 60px; height: 60px; | |
221 | - margin: 7px 7px; padding: 0; | |
222 | 197 | } |
223 | 198 | |
224 | 199 | /* パレット内の個々のボタン Element */ |
200 | + /* ul liの上に動的に作成される */ | |
225 | 201 | .palbutton { |
226 | 202 | position: absolute; |
227 | 203 | left: 0; top: 0; |
@@ -228,8 +204,9 @@ | ||
228 | 204 | width: 100%; height: 100%; |
229 | 205 | margin: 0; padding: 0; |
230 | 206 | border: 1px solid black; |
207 | + border-radius: inherit; | |
231 | 208 | background-color: inherit; |
232 | - box-shadow: inherit; | |
209 | + box-shadow: 10px 10px 20px -4px rgba(0,0,0,0.21); | |
233 | 210 | } |
234 | 211 | |
235 | 212 | /* パレットサイズ変更用 Element */ |
@@ -21,138 +21,59 @@ | ||
21 | 21 | } |
22 | 22 | </style> |
23 | 23 | <!-- Palette --> |
24 | - <style id="stylepalbg"> | |
25 | - .palbg0 { | |
26 | - background-image: url(dummy.png); | |
27 | - } | |
28 | - | |
29 | - .palbg1 { | |
30 | - background-image: url(dummy.png); | |
31 | - } | |
32 | - | |
33 | - .palbg2 { | |
34 | - background-image: url(dummy.png); | |
35 | - } | |
36 | - | |
37 | - .palbg3 { | |
38 | - background-image: url(dummy.png); | |
39 | - } | |
40 | - | |
41 | - .palbg4 { | |
42 | - background-image: url(dummy.png); | |
43 | - } | |
24 | + <style id="styleBackground"> | |
25 | + .palbg0 { background-image: url(dummy.png); } | |
26 | + .palbg1 { background-image: url(dummy.png); } | |
27 | + .palbg2 { background-image: url(dummy.png); } | |
28 | + .palbg3 { background-image: url(dummy.png); } | |
29 | + .palbg4 { background-image: url(dummy.png); } | |
44 | 30 | </style> |
45 | - <style id="stylepaltxtcol"> | |
46 | - .paltxtcol0 { | |
47 | - color: black; | |
48 | - } | |
49 | - | |
50 | - .paltxtcol1 { | |
51 | - color: red; | |
52 | - } | |
53 | - | |
54 | - .paltxtcol2 { | |
55 | - color: blue; | |
56 | - } | |
57 | - | |
58 | - .paltxtcol3 { | |
59 | - color: green; | |
60 | - } | |
61 | - | |
62 | - .paltxtcol4 { | |
63 | - color: brown; | |
64 | - } | |
31 | + <style id="keyframeBackground"> | |
32 | + @keyframes animeact1 { to { color: black; } } | |
33 | + @keyframes animeact2 { to { color: black; } } | |
34 | + @keyframes animeact3 { to { color: black; } } | |
35 | + @keyframes animeact4 { to { color: black; } } | |
36 | + @keyframes animeact5 { to { color: black; } } | |
65 | 37 | </style> |
66 | - <style id="stylepalact"> | |
67 | - .palact0 { | |
68 | - animation: animeY1 0.5s ease-in 0.3s 1 normal; | |
69 | - } | |
70 | - | |
38 | + <style id="styleStyle"> | |
39 | + .paltxtcol0 { color: black; } | |
40 | + .paltxtcol1 { color: red; } | |
41 | + .paltxtcol2 { color: blue; } | |
42 | + .paltxtcol3 { color: green; } | |
43 | + .paltxtcol4 { color: brown; } | |
44 | + </style> | |
45 | + <style id="keyframeStyle"> | |
46 | + @keyframes animeact1 { to { color: black; } } | |
47 | + @keyframes animeact2 { to { color: black; } } | |
48 | + @keyframes animeact3 { to { color: black; } } | |
49 | + @keyframes animeact4 { to { color: black; } } | |
50 | + @keyframes animeact5 { to { color: black; } } | |
51 | + </style> | |
52 | + <style id="styleAction"> | |
53 | + .palact0 { animation: animeY1 0.5s ease-in 0.3s 1 normal; } | |
54 | + .palact1 { animation: animeact1 2s ease-in 0.3s 1 normal; } | |
55 | + .palact2 { animation: animeact2 2s ease-in 0.3s 1 normal; } | |
56 | + .palact3 { animation: animeact3 2s ease-in 0.3s 1 normal; } | |
57 | + .palact4 { animation: animeact4 2s ease-in 0.3s 1 normal; } | |
58 | + </style> | |
59 | + <style id="keyframeAction"> | |
71 | 60 | @keyframes animeY1 { |
72 | - 0% { | |
73 | - transform: translateY(-60px) translateX(-30px); | |
74 | - } | |
75 | - | |
76 | - 10% { | |
77 | - transform: translateY(20px) translateX(30px); | |
78 | - } | |
79 | - | |
80 | - 20% { | |
81 | - transform: translateY(-40px) translateX(-20px); | |
82 | - } | |
83 | - | |
84 | - 30% { | |
85 | - transform: translateY(50px) translateX(-10px); | |
86 | - } | |
87 | - | |
88 | - 40% { | |
89 | - transform: translateY(-40px) translateX(20px); | |
90 | - } | |
91 | - | |
92 | - 50% { | |
93 | - transform: translateY(30px) translateX(-15px); | |
94 | - } | |
95 | - | |
96 | - 60% { | |
97 | - transform: translateY(-25px) translateX(0px); | |
98 | - } | |
99 | - | |
100 | - 70% { | |
101 | - transform: translateY(15px) translateX(-15px); | |
102 | - } | |
103 | - | |
104 | - 80% { | |
105 | - transform: translateY(-10px) translateX(10px); | |
106 | - } | |
107 | - | |
108 | - 90% { | |
109 | - transform: translateY(0px) translateX(-5px); | |
110 | - } | |
111 | - | |
112 | - 100% { | |
113 | - transform: translateY(0px) translateX(0px); | |
114 | - } | |
61 | + 0% { transform: translateY(-60px) translateX(-30px); } | |
62 | + 10% { transform: translateY(20px) translateX(30px); } | |
63 | + 20% { transform: translateY(-40px) translateX(-20px); } | |
64 | + 30% { transform: translateY(50px) translateX(-10px); } | |
65 | + 40% { transform: translateY(-40px) translateX(20px); } | |
66 | + 50% { transform: translateY(30px) translateX(-15px); } | |
67 | + 60% { transform: translateY(-25px) translateX(0px); } | |
68 | + 70% { transform: translateY(15px) translateX(-15px); } | |
69 | + 80% { transform: translateY(-10px) translateX(10px); } | |
70 | + 90% { transform: translateY(0px) translateX(-5px); } | |
71 | + 100% { transform: translateY(0px) translateX(0px); } | |
115 | 72 | } |
116 | - | |
117 | - .palact1 { | |
118 | - animation: animeact1 2s ease-in 0.3s 1 normal; | |
119 | - } | |
120 | - | |
121 | - @keyframes animeact1 { | |
122 | - to { | |
123 | - color: black; | |
124 | - } | |
125 | - } | |
126 | - | |
127 | - .palact2 { | |
128 | - animation: animeact2 2s ease-in 0.3s 1 normal; | |
129 | - } | |
130 | - | |
131 | - @keyframes animeact2 { | |
132 | - to { | |
133 | - color: black; | |
134 | - } | |
135 | - } | |
136 | - | |
137 | - .palact3 { | |
138 | - animation: animeact3 2s ease-in 0.3s 1 normal; | |
139 | - } | |
140 | - | |
141 | - @keyframes animeact3 { | |
142 | - to { | |
143 | - color: black; | |
144 | - } | |
145 | - } | |
146 | - | |
147 | - .palact4 { | |
148 | - animation: animeact4 2s ease-in 0.3s 1 normal; | |
149 | - } | |
150 | - | |
151 | - @keyframes animeact4 { | |
152 | - to { | |
153 | - color: black; | |
154 | - } | |
155 | - } | |
73 | + @keyframes animeact1 { to { color: black; } } | |
74 | + @keyframes animeact2 { to { color: black; } } | |
75 | + @keyframes animeact3 { to { color: black; } } | |
76 | + @keyframes animeact4 { to { color: black; } } | |
156 | 77 | </style> |
157 | 78 | |
158 | 79 | <fieldset class="palgroup palgroup0" data-objid="palgroup0" style="width:400px; height:130px;" title="背景の色や画像を設定するパレットです"> |
@@ -161,11 +82,11 @@ | ||
161 | 82 | <span class="paldesc1">背景</span><span class="paldesc2">色 </span> |
162 | 83 | </div> |
163 | 84 | <ul class="palflex"> |
164 | - <li class="palbg palbg0" data-objid="palbg0" data-palid="0"></li> | |
165 | - <li class="palbg palbg1" data-objid="palbg1" data-palid="1"></li> | |
166 | - <li class="palbg palbg2" data-objid="palbg2" data-palid="2"></li> | |
167 | - <li class="palbg palbg3" data-objid="palbg3" data-palid="3"></li> | |
168 | - <li class="palbg palbg4" data-objid="palbg4" data-palid="4"></li> | |
85 | + <li class="palettebackground palbg0" data-objid="palbg0" data-palid="0"></li> | |
86 | + <li class="palettebackground palbg1" data-objid="palbg1" data-palid="1"></li> | |
87 | + <li class="palettebackground palbg2" data-objid="palbg2" data-palid="2"></li> | |
88 | + <li class="palettebackground palbg3" data-objid="palbg3" data-palid="3"></li> | |
89 | + <li class="palettebackground palbg4" data-objid="palbg4" data-palid="4"></li> | |
169 | 90 | </ul> |
170 | 91 | <div class="palsize"></div> |
171 | 92 | </fieldset> |
@@ -177,11 +98,11 @@ | ||
177 | 98 | <span class="paldesc1">外観</span><span class="paldesc2">見た</span> |
178 | 99 | </div> |
179 | 100 | <ul class="palflex"> |
180 | - <li class="paltxtcol paltxtcol0" data-objid="paltxtcol0" data-palid="0"></li> | |
181 | - <li class="paltxtcol paltxtcol1" data-objid="paltxtcol1" data-palid="1"></li> | |
182 | - <li class="paltxtcol paltxtcol2" data-objid="paltxtcol2" data-palid="2"></li> | |
183 | - <li class="paltxtcol paltxtcol3" data-objid="paltxtcol3" data-palid="3"></li> | |
184 | - <li class="paltxtcol paltxtcol4" data-objid="paltxtcol4" data-palid="4"></li> | |
101 | + <li class="palettestyle paltxtcol0" data-objid="paltxtcol0" data-palid="0"></li> | |
102 | + <li class="palettestyle paltxtcol1" data-objid="paltxtcol1" data-palid="1"></li> | |
103 | + <li class="palettestyle paltxtcol2" data-objid="paltxtcol2" data-palid="2"></li> | |
104 | + <li class="palettestyle paltxtcol3" data-objid="paltxtcol3" data-palid="3"></li> | |
105 | + <li class="palettestyle paltxtcol4" data-objid="paltxtcol4" data-palid="4"></li> | |
185 | 106 | </ul> |
186 | 107 | <div class="palsize"></div> |
187 | 108 | </fieldset> |
@@ -194,11 +115,11 @@ | ||
194 | 115 | <span class="paldesc1">動き</span><span class="paldesc2">流れ</span> |
195 | 116 | </div> |
196 | 117 | <ul class="palflex"> |
197 | - <li class="palact palact0" data-objid="palact0" data-palid="0"></li> | |
198 | - <li class="palact palact1" data-objid="palact1" data-palid="1"></li> | |
199 | - <li class="palact palact2" data-objid="palact2" data-palid="2"></li> | |
200 | - <li class="palact palact3" data-objid="palact3" data-palid="3"></li> | |
201 | - <li class="palact palact4" data-objid="palact4" data-palid="4"></li> | |
118 | + <li class="paletteaction palact0" data-objid="palact0" data-palid="0"></li> | |
119 | + <li class="paletteaction palact1" data-objid="palact1" data-palid="1"></li> | |
120 | + <li class="paletteaction palact2" data-objid="palact2" data-palid="2"></li> | |
121 | + <li class="paletteaction palact3" data-objid="palact3" data-palid="3"></li> | |
122 | + <li class="paletteaction palact4" data-objid="palact4" data-palid="4"></li> | |
202 | 123 | </ul> |
203 | 124 | <div class="palsize"></div> |
204 | 125 | </fieldset> |
@@ -209,11 +130,11 @@ | ||
209 | 130 | <span class="paldesc1">設定</span><span class="paldesc2">変更</span> |
210 | 131 | </div> |
211 | 132 | <ul class="palflex"> |
212 | - <li class="palset palset0" data-objid="palset0" data-palid="0"></li> | |
213 | - <li class="palset palset1" data-objid="palset1" data-palid="1"></li> | |
214 | - <li class="palset palset2" data-objid="palset2" data-palid="2"></li> | |
215 | - <li class="palset palset3" data-objid="palset3" data-palid="3"></li> | |
216 | - <li class="palset palset4" data-objid="palset4" data-palid="4"></li> | |
133 | + <li class="palettesetting palset0" data-objid="palset0" data-palid="0"></li> | |
134 | + <li class="palettesetting palset1" data-objid="palset1" data-palid="1"></li> | |
135 | + <li class="palettesetting palset2" data-objid="palset2" data-palid="2"></li> | |
136 | + <li class="palettesetting palset3" data-objid="palset3" data-palid="3"></li> | |
137 | + <li class="palettesetting palset4" data-objid="palset4" data-palid="4"></li> | |
217 | 138 | </ul> |
218 | 139 | <div class="palsize"></div> |
219 | 140 | </fieldset> |
@@ -440,6 +440,7 @@ | ||
440 | 440 | |
441 | 441 | |
442 | 442 | function prohibitDropHandler_dragStart(evt) { |
443 | + debuglog('prohibitDropHandler_dragStart'); | |
443 | 444 | evt.preventDefault(); |
444 | 445 | } |
445 | 446 | function prohibitDropHandler_dragOver(evt) { |
@@ -447,7 +448,7 @@ | ||
447 | 448 | evt.dataTransfer.dropEffect = "none"; |
448 | 449 | } |
449 | 450 | function prohibitDropHandler_drop(evt) { |
450 | - this.debuglog('prohibitDropHandler_drop'); | |
451 | + debuglog('prohibitDropHandler_drop'); | |
451 | 452 | evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) |
452 | 453 | evt.stopImmediatePropagation(); // 処理中要素の他のevent listenerを止める |
453 | 454 | evt.preventDefault(); // 要素既定のdefault動作を止める |
@@ -6,52 +6,120 @@ | ||
6 | 6 | // ・Target要素に自objidと同名のCSS class追加 |
7 | 7 | // ・外部からのDropによる text, image, css 読み込み |
8 | 8 | |
9 | -// パレットのCSS機能ボタンを押したときに実行する機能を提供する | |
9 | +// パレットのCSS機能ボタンをDropしたときに実行する機能を提供する | |
10 | 10 | // (保持中CSS class nameを対象Elementに付加, 削除) |
11 | 11 | // (Button instanceが自分の機能を意識しないようにするためのclass) |
12 | 12 | class PaletteApplyCSS { |
13 | 13 | constructor() { |
14 | - this.paletteRule = null; | |
15 | - this.dataScheme = null; | |
14 | +// this.paletteRule = null; | |
15 | + this.dataScheme = null; | |
16 | 16 | this.description = null; |
17 | + this.groupname = null; | |
18 | + this.num = -1; | |
19 | + this.eleStyle = null; | |
20 | + this.eleKeyframe = null; | |
17 | 21 | } |
22 | + initialize(eleStyle, eleKeyframe, groupname, num) { | |
18 | 23 | |
24 | + if (null == eleStyle || null == eleKeyframe) { | |
25 | + console.error('PaletteApplyCSS 作成失敗 引数要素異常\neleStyle = ' + eleStyle + ', eleKeyframe = ' + eleKeyframe); | |
26 | + return; | |
27 | + } | |
28 | + if (eleStyle.sheet.cssRules.length <= num | |
29 | + || eleKeyframe.sheet.cssRules.length <= num) { | |
30 | + console.error('PaletteApplyCSS 作成失敗 引数要素異常\nnum = ' + num + 'eleStyle.sheet.cssRules.length = ' + eleStyle.sheet.cssRules.length + ', eleKeyframe.sheet.cssRules.length = ' + eleKeyframe.sheet.cssRules.length); | |
31 | + return; | |
32 | + } | |
33 | + | |
34 | + // CSS 書き換え対象 Rule への参照を保持 | |
35 | + this.groupname = groupname; | |
36 | + this.num = num; | |
37 | + this.eleStyle = eleStyle; | |
38 | + this.eleKeyframe = eleKeyframe; | |
39 | + } | |
40 | + | |
41 | + | |
42 | + // 参照中のCSS Ruleを引数textで上書き | |
43 | + // CSS class名は変化しない。本文のみ上書き。 | |
44 | + registerCSSRule( | |
45 | + type, // 'Style' or 'Action' | |
46 | + description, // 説明内容テキスト | |
47 | + style, // CSS定義 本文のみ使用する | |
48 | + keyframe, // @keyframeを含むテキスト or null | |
49 | + picture // data scheme | |
50 | + ) { | |
51 | + this.removeDescription(); | |
52 | + this.removeImage(); | |
53 | + | |
54 | + this.registerDescription(description); | |
55 | + this.registerImage(picture); | |
56 | + this.replaceStyle(style); | |
57 | + if (null != keyframe) | |
58 | + this.replaceKeyframe(keyframe); | |
59 | + } | |
60 | + | |
19 | 61 | // 機能の登録・削除・実行 ------------------ |
20 | 62 | // 前提:既にCSS ruleはdocumentに登録されている |
21 | 63 | // CSS ruleへの参照を保持 |
22 | 64 | // 適用要求で対象Elementに保持ruleをadd class |
65 | + replaceStyle(text) { | |
66 | + // '{' ~ '}' の間を抽出 | |
67 | + let strStyle = text.match(/\{([\s\S]*)\}/)[1]; | |
68 | + // class名追加 | |
69 | + let cssStyle = '.' + this.groupname + this.num + '{' + strStyle + '}'; | |
23 | 70 | |
24 | - registerCSS(rule) { | |
25 | - if (null != this.paletteRule) { | |
26 | - console.error('パレット機能 上書き登録\n以前の機能 = ' + this.paletteRule + '\n今回の機能 = ' + rule); | |
27 | - // ひとまず処理継続 | |
28 | - } | |
29 | - this.paletteRule = rule; | |
71 | + this.removeStyle(); | |
72 | + this.registerStyle(cssStyle); | |
73 | + } | |
74 | + registerStyle(text) { | |
75 | + this.eleStyle.sheet.insertRule(text, this.num); | |
30 | 76 | return true; |
31 | 77 | } |
32 | - removeCSS() { | |
33 | - this.paletteRule = null; | |
78 | + removeStyle() { | |
79 | + this.eleStyle.sheet.deleteRule(this.num); | |
34 | 80 | } |
35 | - getCSS() { | |
36 | - return this.paletteRule; | |
81 | + getStyle() { | |
82 | + return this.eleStyle.sheet.cssRules[this.num]; | |
37 | 83 | } |
38 | 84 | getClassName() { |
39 | - return this.paletteRule.name; | |
85 | + return this.eleStyle.sheet.cssRules[this.num].selectorText; | |
40 | 86 | } |
87 | + // Target element へ CSS classを追加する | |
88 | + // 同じ種類のCSS class(Text color, BG imgなど)が既にある場合は上書き | |
89 | + replaceClassToElement( | |
90 | + CSSname, // 追加(上書き)する CSSclass名称文字列 | |
91 | + targetEle // 追加先 element | |
92 | + ) { | |
93 | + // Drag中の palette elementから 追加する CSS classを取得 (objidと同じ名前にしている) | |
94 | + let result = /[a-zA-Z]+/.exec(CSSname); // objid末の数字を除く | |
95 | + let DraggingPaletteType = result[0]; | |
96 | + | |
97 | + // Drop target elementに 同じ種類の CSS classがないかチェック | |
98 | + let reg = new RegExp(DraggingPaletteType + '[0-9]+'); // 数字は1回以上発生する。数字なしは別class | |
99 | + result = reg.exec(targetEle.className); | |
100 | + let DropEleOldClass = (null != result) ? result[0] : null; | |
101 | + | |
102 | + // 同じ種類の CSS classがあれば削除 | |
103 | + if (null != DropEleOldClass) | |
104 | + targetEle.classList.remove(DropEleOldClass); | |
105 | + | |
106 | + // Drop target elementに Drag elementの CSS class定義を追加 | |
107 | + targetEle.classList.add(DraggingPaletteType + this.num); | |
108 | + } | |
41 | 109 | // 保持中CSS class nameを引数ElementのclassListに追加 |
42 | - addClass(ele) { | |
110 | + addClassToElement(ele) { | |
43 | 111 | if (null == ele) { |
44 | 112 | console.error('CSS適用対象要素が指定されていません'); |
45 | 113 | return false; |
46 | 114 | } |
47 | - if (null == this.paletteRule) { | |
115 | + if (null == this.eleStyle) { | |
48 | 116 | console.error('CSSが未登録のまま 要素にCSSを追加しようとしました\nEle = ' + ele); |
49 | 117 | return false; |
50 | 118 | } |
51 | - ele.classList.add(this.paletteRule.name); | |
119 | + ele.classList.add(this.getClassName()); | |
52 | 120 | } |
53 | 121 | // 保持中CSS class nameを引数ElementのclassListから削除 |
54 | - removeClass(ele) { | |
122 | + removeClassToElement(ele) { | |
55 | 123 | if (null == ele) { |
56 | 124 | console.error('CSS適用対象要素が指定されていません'); |
57 | 125 | return false; |
@@ -60,9 +128,27 @@ | ||
60 | 128 | console.error('CSSが未登録のまま 要素にCSSを削除しようとしました\nEle = ' + ele); |
61 | 129 | return false; |
62 | 130 | } |
63 | - ele.classList.remove(this.paletteRule.name); | |
131 | + ele.classList.remove(this.getClassName()); | |
64 | 132 | } |
65 | 133 | |
134 | + replaceKeyframe(text) { | |
135 | + this.removeKeyframe(); | |
136 | + this.registerKeyframe(text); | |
137 | + } | |
138 | + registerKeyframe(text) { | |
139 | + this.eleKeyframe.sheet.insertRule(text, this.num); | |
140 | + return true; | |
141 | + } | |
142 | + removeKeyframe() { | |
143 | + this.eleKeyframe.sheet.deleteRule(this.num); | |
144 | + } | |
145 | + getKeyframe() { | |
146 | + return this.eleKeyframe.sheet.cssRules[this.num]; | |
147 | + } | |
148 | + getKeyframeName() { | |
149 | + return this.eleKeyframe.sheet.cssRules[this.num].name; | |
150 | + } | |
151 | + | |
66 | 152 | // 登録されたCSSの機能に関連した画像・説明文の 登録・取得 ------------ |
67 | 153 | registerImage(dataScheme) { |
68 | 154 | if (null != this.dataScheme) { |
@@ -346,7 +432,7 @@ | ||
346 | 432 | // ボタン Click で実行する機能を登録 |
347 | 433 | setPalettePressFunction(palfunc) { |
348 | 434 | if (null != this.palettePressFunction) { |
349 | - console.error('パレットボタン(PaletteShapeFunctionButton)への機能設定エラー 上書き登録\n以前の機能 = ' + this.palettePressFunction.getFunction.name + ', 今回の機能 = ' + palfunc.getFunction.name); | |
435 | + console.error('パレットボタン(PaletteShapeFunctionButton)への機能設定エラー 上書き登録\n以前の機能 = ' + this.palettePressFunction.getFunction.name + ', 今回の機能 = ' + palfunc.name); | |
350 | 436 | // ひとまず処理継続 |
351 | 437 | } |
352 | 438 | this.palettePressFunction = palfunc; |
@@ -403,14 +489,31 @@ | ||
403 | 489 | // PaletteShapeFunctionButtonとは機能が違うし使いまわし部分も少ないので分けてしまう |
404 | 490 | |
405 | 491 | // パレットのCSSボタン表示部分の定義class |
406 | -// DOM Elementの保持、ボタンdrag & dropでの実行機能との関連付け | |
492 | +// DOM Elementの保持、ボタンdrag & dropで呼び出す機能との関連付け | |
407 | 493 | // Input eventから必要機能の呼び出し |
408 | 494 | class PaletteShapeCSSButton { |
409 | 495 | constructor() { |
496 | + this.paletteType = null; | |
497 | + this.num = -1; | |
410 | 498 | this.DOMobject = null; |
411 | - this.paletteDropFunction = null; | |
499 | + this.paletteTextParser = null; | |
412 | 500 | } |
501 | + initialize(paletteType, num) { | |
413 | 502 | |
503 | + this.paletteType = paletteType; | |
504 | + this.num = num; | |
505 | + this.paletteTextParser = new PaletteCSSTextParser(); | |
506 | + | |
507 | + // paletteApplyCss に保持させるRuleへの参照を取得 | |
508 | + this.eleStyleArray = { 'Background': 'styleBackground', 'Style': 'styleStyle', 'Action': 'styleAction' }; // Setting paletteは CSSを使わない | |
509 | + this.eleKeyframeArray = { 'Background': 'keyframeBackground', 'Style': 'keyframeStyle', 'Action': 'keyframeAction' }; | |
510 | + | |
511 | + let eleStyle = document.getElementById(this.eleStyleArray[this.paletteType]); | |
512 | + let eleKeyframe = document.getElementById(this.eleKeyframeArray[this.paletteType]); | |
513 | + this.paletteApplyCss = new PaletteApplyCSS(); | |
514 | + this.paletteApplyCss.initialize(eleStyle, eleKeyframe, paletteType, num); | |
515 | + } | |
516 | + | |
414 | 517 | // 表示に使用するDOM要素を作成 |
415 | 518 | // DOM 要素を作成してこの Instance の表示要素として登録 |
416 | 519 | createButtonElement(parent) { |
@@ -451,23 +554,19 @@ | ||
451 | 554 | ele.appendChild(this.DOMobject); |
452 | 555 | return true; |
453 | 556 | } |
454 | - | |
557 | +/* | |
455 | 558 | // Paletteボタン対象Dropで実行する機能を登録 |
456 | - setPaletteDropFunction(dropcssfunc) { | |
457 | - if (null != this.paletteDropFunction) { | |
458 | - console.error('パレットボタン(PaletteShapeFunctionButton)への機能設定エラー 上書き登録\n以前の機能 = ' + this.paletteDropFunction.getFunction.name + ', 今回の機能 = ' + palfunc.getFunction.name); | |
559 | + setpaletteApplyCss(dropcssfunc) { | |
560 | + if (null != this.paletteApplyCss) { | |
561 | + console.error('パレットボタン(PaletteShapeFunctionButton)への機能設定エラー 上書き登録\n以前の機能 = ' + this.paletteApplyCss.getFunction.name + ', 今回の機能 = ' + dropcssfunc.name); | |
459 | 562 | // ひとまず処理継続 |
460 | 563 | } |
461 | - this.paletteDropFunction = palfunc; | |
564 | + this.paletteApplyCss = dropcssfunc; | |
462 | 565 | |
463 | - // 表示要素の更新 | |
464 | - this.DOMobject.title = this.palettePressFunction.getDescription(); | |
465 | - this.DOMobject.style.backgroundImage = 'url(' + this.palettePressFunction.getImage() + ')'; | |
466 | - this.DOMobject.style.backgroundSize = 'cover'; | |
467 | 566 | } |
468 | - | |
469 | - clearPaletteDropFunction() { | |
470 | - this.paletteDropFunction = null; | |
567 | +*/ | |
568 | + clearpaletteApplyCss() { | |
569 | + this.paletteApplyCss = null; | |
471 | 570 | this.DOMobject.title = null; |
472 | 571 | this.DOMobject.style.backgroundImage = 'none'; |
473 | 572 | } |
@@ -484,9 +583,9 @@ | ||
484 | 583 | this.DOMobject.addEventListener('touchstart', this.onMouseDownPaletteShapeCSSButton.bind(this), false); |
485 | 584 | // this.DOMobject.addEventListener('touchmove', this.onMouseMovePaletteShapeCSSButton.bind(this), false); |
486 | 585 | // this.DOMobject.addEventListener('touchend', this.onMouseUpPaletteShapeCSSButton.bind(this), false); |
487 | - this.DOMobject.addEventListener('dragstart', prohibitDropHandler_dragStart.bind(this), false); | |
488 | - this.DOMobject.addEventListener('dragover', prohibitDropHandler_dragOver.bind(this), false); | |
489 | - this.DOMobject.addEventListener('drop', prohibitDropHandler_drop.bind(this), false); | |
586 | + this.DOMobject.addEventListener('dragstart', this.onDragStartPaletteShapeCSSButton.bind(this), false); | |
587 | + this.DOMobject.addEventListener('dragover', this.onDragOverPaletteShapeCSSButton.bind(this), false); | |
588 | + this.DOMobject.addEventListener('drop', this.onDropPaletteShapeCSSButton.bind(this), false); | |
490 | 589 | } |
491 | 590 | |
492 | 591 |
@@ -502,7 +601,13 @@ | ||
502 | 601 | // Mouse/Touch event 差分 |
503 | 602 | let eleTarget = (null != evt.targetTouches) ? evt.targetTouches[0] : evt.target; |
504 | 603 | |
505 | - // Mouse eventをappAreaからCSSPalに渡してもらうように設定 (evt.targetは必ずpalette要素である前提。子要素なし。) | |
604 | + // ボタンにCSSが未登録なら、Userが drag 操作をする前に止める | |
605 | + if (null == this.paletteApplyCss) { | |
606 | + console.error('ボタンにCSSが登録されていません'); | |
607 | + return false; | |
608 | + } | |
609 | + | |
610 | + // Mouse eventをappAreaからCSSPalに渡してもらうように設定 | |
506 | 611 | window.appArea.setInputEventObj(eleTarget.dataset.objid, this.onMouseMovePaletteShapeCSSButton.bind(this), this.onMouseUpPaletteShapeCSSButton.bind(this)); |
507 | 612 | this.startMovingElement(evt); |
508 | 613 | } |
@@ -580,6 +685,9 @@ | ||
580 | 685 | } |
581 | 686 | |
582 | 687 | // Target element へ CSS classを追加する |
688 | + if (null != this.paletteApplyCss) { | |
689 | + this.paletteApplyCss.replaceClassToElement(this.paletteApplyCss.getClassName(), target.DOMobject); | |
690 | + } | |
583 | 691 | } |
584 | 692 | |
585 | 693 |
@@ -587,6 +695,7 @@ | ||
587 | 695 | // Applicationの外からFile Dropされたときに |
588 | 696 | // File内容情報を読み込み、CSSに反映させる |
589 | 697 | onDragStartPaletteShapeCSSButton(evt) { |
698 | + debuglog('onDragStartPaletteShapeCSSButton'); | |
590 | 699 | evt.preventDefault(); |
591 | 700 | evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) |
592 | 701 | } |
@@ -596,7 +705,7 @@ | ||
596 | 705 | evt.dataTransfer.dropEffect = "copy"; |
597 | 706 | } |
598 | 707 | onDropPaletteShapeCSSButton(evt) { |
599 | - this.debuglog('onDrop'); | |
708 | + debuglog('onDropPaletteShapeCSSButton'); | |
600 | 709 | evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) |
601 | 710 | evt.stopImmediatePropagation(); // 処理中要素の他のevent listenerを止める |
602 | 711 | evt.preventDefault(); // 要素既定のdefault動作を止める |
@@ -606,12 +715,29 @@ | ||
606 | 715 | } |
607 | 716 | |
608 | 717 | replaceCSSText(file) { |
609 | - let cssText = null; | |
610 | - cssText = this.paletteTextParser.readTextFile(file); | |
611 | - this.paletteTextParser.parseText(cssText); | |
612 | - let rule = this.paletteApplyCss.getCSS(); | |
613 | - this.paletteTextParser.replaceCSSRule(rule, cssText); | |
718 | + // File から定義内容の読み込み | |
719 | + this.paletteTextParser.readTextFile(file, this.readComplete.bind(this)); | |
614 | 720 | } |
721 | + readComplete(cssText) { | |
722 | + let ret = false; | |
723 | + // 読み込み文字列の解析 | |
724 | + ret = this.paletteTextParser.parseText(cssText); | |
725 | + if (false == ret) // 致命的なエラー | |
726 | + return false; | |
727 | + // 解析済み文字列取得 | |
728 | + let type = this.paletteTextParser.resultOfParsingType(); | |
729 | + let description = this.paletteTextParser.resultOfParsingDescription(); | |
730 | + let style = this.paletteTextParser.resultOfParsingRule(); | |
731 | + let keyframe = this.paletteTextParser.resultOfParsingKeyframe(); | |
732 | + let picture = this.paletteTextParser.resultOfParsingPicture(); | |
733 | + // CSS 定義上書き登録 | |
734 | + let rule = this.paletteApplyCss.registerCSSRule(type, description, style, keyframe, picture); | |
735 | + | |
736 | + // 表示要素の更新 | |
737 | + this.DOMobject.title = this.paletteApplyCss.getDescription(); | |
738 | + this.DOMobject.style.backgroundImage = 'url(' + this.paletteApplyCss.getImage() + ')'; | |
739 | + this.DOMobject.style.backgroundSize = 'cover'; | |
740 | + } | |
615 | 741 | parseImage(file) { |
616 | 742 | console.error('画像ファイルには未対応'); |
617 | 743 | return false; |
@@ -625,11 +751,22 @@ | ||
625 | 751 | // Text解析、CSS登録 |
626 | 752 | // CSSの汎用操作を扱うわけではない |
627 | 753 | // 解析後のTextやImageは保持しない |
628 | -// singletonにしたいがやり方がわからないので1つだけ作るようにする;´Д`)運用でカバー | |
629 | 754 | class PaletteCSSTextParser { |
630 | 755 | constructor() { |
631 | 756 | this.filename = null; |
632 | 757 | this.cssText = null; |
758 | + | |
759 | + // Parse text 用の定義 | |
760 | + this.startStrArray = ['\\[', ' Start\\]']; | |
761 | + this.endStrArray = ['\\[', ' End\\]']; | |
762 | + this.blockNameArray = ['Type', 'Description', 'Rule', 'Keyframe', 'Picture']; | |
763 | + this.blockRequired = [true, false, true, false, false]; | |
764 | + this.typeNameArray = ['Style', 'Action']; | |
765 | + // 分解後の文字列保持先連想配列の確保 | |
766 | + this.defineStrArray = []; | |
767 | + for (let cnt = 0; cnt < this.blockNameArray.length; cnt++) { | |
768 | + this.defineStrArray[this.blockNameArray[cnt]] = null; | |
769 | + } | |
633 | 770 | } |
634 | 771 | |
635 | 772 | // Drop file(CSS定義test)の内容読み込み(file, ele, num) |
@@ -659,26 +796,154 @@ | ||
659 | 796 | } |
660 | 797 | |
661 | 798 | // Stringの解析・解析結果を一旦内部保持 (解析実行ごとに上書き) |
662 | - // class name取得 | |
663 | - // 定義内容取得 | |
664 | - // description取得 | |
665 | - // data scheme取得 | |
666 | - // comment取得 | |
667 | 799 | parseText(str) { |
668 | - // Textを下記要素に分解する | |
669 | - // ・ | |
800 | + // ブロックごとに分解して内部変数に結果を保持 | |
801 | + this.parseTextBlocks(str); | |
802 | + // (定義チェック前に) 文字列前後の空白を削除 | |
803 | + this.parseTextClearBlankCharacters(); | |
804 | + // 必要な定義の存在チェック | |
805 | + let abnormalData, notRecommended, resultStr; | |
806 | + [abnormalData, notRecommended, resultStr] = this.parseTextCheckData(); | |
807 | + if (true == abnormalData) { | |
808 | + console.error(resultStr); | |
809 | + return false; | |
810 | + } | |
811 | + else if (true == notRecommended) { | |
812 | + console.error(resultStr); | |
813 | + } | |
814 | + | |
815 | + // 読みこんだ文字列を CSS 定義差し替えに使える形に調整 | |
816 | + let ret = false; | |
817 | +// ret = this.parseTextRule(); | |
818 | +// if (false == ret) | |
819 | +// return false; | |
820 | + this.parseTextKeyframe(); | |
821 | + | |
822 | + return true; | |
670 | 823 | } |
671 | 824 | |
672 | - // StringをStyle elementへadd - Ruleへの参照を返す | |
673 | - // Element指定は必須 | |
674 | - // StringをStyle elementへreplace - Ruleへの参照を返す | |
675 | - // Element指定は必須 | |
676 | - replaceCSSRule(rule, text) { | |
825 | + resultOfParsingType() { | |
826 | + return this.defineStrArray[this.blockNameArray[0]]; | |
677 | 827 | } |
828 | + resultOfParsingDescription() { | |
829 | + return this.defineStrArray[this.blockNameArray[1]]; | |
830 | + } | |
831 | + resultOfParsingRule() { | |
832 | + return this.defineStrArray[this.blockNameArray[2]]; | |
833 | + } | |
834 | + resultOfParsingKeyframe() { | |
835 | + return this.defineStrArray[this.blockNameArray[3]]; | |
836 | + } | |
837 | + resultOfParsingPicture() { | |
838 | + return this.defineStrArray[this.blockNameArray[4]]; | |
839 | + } | |
678 | 840 | |
679 | - // CSS class name指定でRuleへの参照を返す | |
680 | - // Element指定あり …… 指定Element内から検索 | |
681 | - // Element指定なし …… document全体から検索 | |
841 | + | |
842 | + | |
843 | + // Private 関数 ------------------------- | |
844 | + | |
845 | + parseTextBlocks(str) { | |
846 | + // ブロックごとに分解する | |
847 | + for (let cnt = 0; cnt < this.blockNameArray.length; cnt++) { | |
848 | + // Keyword 作成 | |
849 | + let strStart = this.startStrArray[0] + this.blockNameArray[cnt] + this.startStrArray[1]; | |
850 | + let strEnd = this.endStrArray[0] + this.blockNameArray[cnt] + this.endStrArray[1]; | |
851 | + let strReg = strStart + '(\[\\s\\S\]*?)' + strEnd; | |
852 | + let regKeyword = new RegExp(strReg); | |
853 | + // 目的箇所の取得 | |
854 | + let strDefine = str.match(regKeyword); | |
855 | + // 結果を保持 | |
856 | + if (null != strDefine) | |
857 | + this.defineStrArray[this.blockNameArray[cnt]] = (0 < strDefine.length) ? strDefine[1] : null; | |
858 | + } | |
859 | + } | |
860 | + // 文字列の前後にある空白を削除 | |
861 | + parseTextClearBlankCharacters() { | |
862 | + for (let cnt = 0; cnt < this.blockNameArray.length; cnt++) { | |
863 | + if (null != this.defineStrArray[this.blockNameArray[cnt]]) | |
864 | + this.defineStrArray[this.blockNameArray[cnt]] = this.defineStrArray[this.blockNameArray[cnt]].replace(/^\s+|\s+$/g, ""); | |
865 | + } | |
866 | + } | |
867 | + parseTextCheckData() { | |
868 | + let abnormalData = false; | |
869 | + let notRecommended = false; | |
870 | + let resultStr = "定義ファイルから下記のデータが正しく読み取れません。ファイルの内容に問題がないかご確認頂けないでしょうか。\n"; | |
871 | + for (let cnt = 0; cnt < this.blockNameArray.length; cnt++) { | |
872 | + // 存在しないデータがみつかった | |
873 | + if (null == this.defineStrArray[this.blockNameArray[cnt]]) { | |
874 | + // それは必須データ? | |
875 | + if (true == this.blockRequired[cnt]) { | |
876 | + abnormalData = true; | |
877 | + resultStr += "Must:" + this.blockNameArray[cnt] + " 定義\n"; | |
878 | + } | |
879 | + else { | |
880 | + notRecommended = true; | |
881 | + resultStr += "Should:" + this.blockNameArray[cnt] + " 定義\n"; | |
882 | + } | |
883 | + } | |
884 | + } | |
885 | + // Type データの型チェック | |
886 | + let ret = this.parseTextCheckType(this.defineStrArray[this.blockNameArray[0]]); | |
887 | + if (false == ret) { | |
888 | + abnormalData = true; | |
889 | + | |
890 | + let strTypeName = null; | |
891 | + let cnt = 0; | |
892 | + while(true) { | |
893 | + strTypeName += this.typeNameArray[cnt]; | |
894 | + if (++cnt < this.typeNameArray.length) | |
895 | + break; | |
896 | + strTypeName += ', '; | |
897 | + } | |
898 | + resultStr += this.blockNameArray[0] + "データとして設定する値は次のいずれかにしてください:" + strTypeName; | |
899 | + } | |
900 | + | |
901 | + return [abnormalData, notRecommended, resultStr]; | |
902 | + } | |
903 | + parseTextCheckType(strType) { | |
904 | + let result = false; | |
905 | + for (let cnt = 0; cnt < this.typeNameArray.length; cnt++) { | |
906 | + if (strType == this.typeNameArray[cnt]) { | |
907 | + result = true; | |
908 | + break; | |
909 | + } | |
910 | + } | |
911 | + return result; | |
912 | + } | |
913 | + | |
914 | + // 内部変数 this.defineStrArray[this.blockNameArray[2]] から CSS 定義部分を抽出 | |
915 | + parseTextRule() { | |
916 | + let strCSS = this.defineStrArray[this.blockNameArray[2]]; | |
917 | + let strRule = strCSS.match(/\{([\s\S]*)\}/); | |
918 | + if (strRule.length < 1) { | |
919 | + console.error('Rule定義内容が見つかりません\nRule = ' + strCSS); | |
920 | + return false; | |
921 | + } | |
922 | + // 定義の差し替えに使える形で上書き | |
923 | + this.defineStrArray[this.blockNameArray[2]] = strRule[1]; | |
924 | + } | |
925 | + | |
926 | + // 内部変数 this.defineStrArray[this.blockNameArray[3]] の内容チェック | |
927 | + parseTextKeyframe() { | |
928 | + let strCSS = this.defineStrArray[this.blockNameArray[3]]; | |
929 | + if (null == strCSS) { | |
930 | + console.log('keyframe定義なし'); | |
931 | + return true; | |
932 | + } | |
933 | + if (- 1 == strCSS.indexOf('@keyframe')) { | |
934 | + if (this.typeNameArray[1] == this.defineStrArray[this.blockNameArray[0]]) { | |
935 | + console.error('Keyframe定義が読み込めません\nkeyframe = ' +strCSS); | |
936 | + // 致命的エラーにはしない。Animation定義未使用の可能性があるため | |
937 | + this.defineStrArray[this.blockNameArray[3]] = null; | |
938 | + return false; | |
939 | + } | |
940 | + } | |
941 | + // keyframe dataはそのまま使うので特に加工しない | |
942 | + return true; | |
943 | + } | |
944 | + | |
945 | + | |
946 | + | |
682 | 947 | } |
683 | 948 | |
684 | 949 | class CSSPalette { |
@@ -692,16 +957,17 @@ | ||
692 | 957 | |
693 | 958 | initialize() { |
694 | 959 | // CSS 情報定義先を保持 |
695 | - this.stylebg = document.getElementById('stylepalbg'); | |
696 | - this.styletxtcol = document.getElementById('stylepaltxtcol'); | |
697 | - this.styleact = document.getElementById('stylepalact'); | |
960 | + this.stylebg = document.getElementById('styleBackground'); | |
961 | + this.styletxtcol = document.getElementById('styleStyle'); | |
962 | + this.styleact = document.getElementById('styleAction'); | |
698 | 963 | |
699 | 964 | // palette要素を保持 |
700 | 965 | // 背景設定パレット |
701 | - let elePalbg = document.getElementsByClassName('palbg'); | |
966 | + let elePalbg = document.getElementsByClassName('palettebackground'); | |
702 | 967 | this.palBackground = []; |
703 | 968 | for (let cnt = 0; cnt < elePalbg.length; cnt++) { |
704 | 969 | this.palBackground[cnt] = new PaletteShapeCSSButton(); |
970 | + this.palBackground[cnt].initialize('Background', cnt); | |
705 | 971 | this.palBackground[cnt].createButtonElement(elePalbg[cnt]); |
706 | 972 | // ボタンへの機能登録は 定義file drop か Save file 読み込みのとき |
707 | 973 | } |
@@ -720,10 +986,11 @@ | ||
720 | 986 | } |
721 | 987 | */ |
722 | 988 | // スタイルパレット |
723 | - let elePalstyle = document.getElementsByClassName('paltxtcol'); | |
989 | + let elePalstyle = document.getElementsByClassName('palettestyle'); | |
724 | 990 | this.palStyle = []; |
725 | 991 | for (let cnt = 0; cnt < elePalstyle.length; cnt++) { |
726 | 992 | this.palStyle[cnt] = new PaletteShapeCSSButton(); |
993 | + this.palStyle[cnt].initialize('Style', cnt); | |
727 | 994 | this.palStyle[cnt].createButtonElement(elePalstyle[cnt]); |
728 | 995 | // ボタンへの機能登録は 定義file drop か Save file 読み込みのとき |
729 | 996 | } |
@@ -742,10 +1009,11 @@ | ||
742 | 1009 | } |
743 | 1010 | */ |
744 | 1011 | // アクションパレット |
745 | - let elePalaction = document.getElementsByClassName('palact'); | |
1012 | + let elePalaction = document.getElementsByClassName('paletteaction'); | |
746 | 1013 | this.palAction = []; |
747 | 1014 | for (let cnt = 0; cnt < elePalaction.length; cnt++) { |
748 | 1015 | this.palAction[cnt] = new PaletteShapeCSSButton(); |
1016 | + this.palAction[cnt].initialize('Action', cnt); | |
749 | 1017 | this.palAction[cnt].createButtonElement(elePalaction[cnt]); |
750 | 1018 | // ボタンへの機能登録は 定義file drop か Save file 読み込みのとき |
751 | 1019 | } |
@@ -774,7 +1042,7 @@ | ||
774 | 1042 | paletteFunctionObjects.getItem(8), // Toggle Aspect ratio |
775 | 1043 | paletteFunctionObjects.getItem(10) // Toggle Scale font size |
776 | 1044 | ]; |
777 | - let elePalset = document.getElementsByClassName('palset'); // 土台 Element 取得 | |
1045 | + let elePalset = document.getElementsByClassName('palettesetting'); // 土台 Element 取得 | |
778 | 1046 | this.palSetting = []; // ボタン機能提供Elementを保持するClass Instance配列 |
779 | 1047 | for (let cnt = 0; cnt < elePalset.length; cnt++) { |
780 | 1048 | this.palSetting[cnt] = new PaletteShapeFunctionButton(); // ボタン機能Class Instance生成 |
@@ -108,7 +108,7 @@ | ||
108 | 108 | margin: 0px; padding: 5px; |
109 | 109 | border: 1px solid transparent; |
110 | 110 | border-radius: 8px; |
111 | - background-color: #fff; | |
111 | +/* background-color: #fff; */ | |
112 | 112 | box-shadow: 16px 16px 19px -11px rgba(0, 0, 0, 0.21); |
113 | 113 | } |
114 | 114 | .pallegend { |
@@ -161,7 +161,6 @@ | ||
161 | 161 | .palflex { |
162 | 162 | display: flex; |
163 | 163 | flex-wrap: wrap; |
164 | - position: relative; | |
165 | 164 | overflow: scroll; |
166 | 165 | width: calc(100% - 20px); height: calc(100% - 40px); |
167 | 166 | margin: -5px 10px; padding: 15px; |
@@ -168,60 +167,36 @@ | ||
168 | 167 | background-color: gray; |
169 | 168 | box-shadow: 10px 10px 20px -4px #777 inset; |
170 | 169 | opacity: 0.6; |
171 | - text-decoration: none; | |
172 | 170 | justify-content: flex-start; |
173 | 171 | } |
174 | 172 | /* パレット要素の定義 */ |
175 | - .palbg, | |
176 | - .paltxtcol, | |
177 | - .palact, | |
178 | - .palset { | |
173 | + .palettebackground, | |
174 | + .palettestyle, | |
175 | + .paletteaction, | |
176 | + .palettesetting { | |
179 | 177 | display: inline-block; |
180 | - position: absolute; | |
181 | - width: 50px; height: 50px; | |
182 | - border-radius: 8px; | |
183 | - margin: 4px; padding: 0; | |
178 | + position: relative; | |
179 | + width: 60px; height: 60px; | |
180 | + margin: 7px 7px; padding: 0; | |
181 | + border-radius: 50%; | |
184 | 182 | text-align: center; |
185 | - font-size: 45px; line-height: 45px; | |
183 | + font-size: 55px; line-height: 55px; | |
186 | 184 | } |
187 | - .palbg { | |
188 | - border: 1px solid rgba(0,0,0,0.2); | |
185 | + .palettebackground { | |
189 | 186 | background-color: rgba(27, 158, 131, 0.6); |
190 | - box-shadow: 10px 10px 20px -4px rgba(0,0,0,0.21); | |
191 | - /* ********************** */ | |
192 | - position: relative; | |
193 | - width: 60px; height: 60px; | |
194 | - margin: 7px 7px; padding: 0; | |
195 | 187 | } |
196 | - .paltxtcol { | |
197 | - border: 1px solid rgba(0,0,0,0.2); | |
188 | + .palettestyle { | |
198 | 189 | background-color: rgba(154,145,140,0.6); |
199 | - box-shadow: 10px 10px 20px -4px rgba(0,0,0,0.21); | |
200 | - /* ********************** */ | |
201 | - position: relative; | |
202 | - width: 60px; height: 60px; | |
203 | - margin: 7px 7px; padding: 0; | |
204 | 190 | } |
205 | - .palact { | |
206 | - border: 1px solid rgba(0,0,0,0.2); | |
191 | + .paletteaction { | |
207 | 192 | background-color: rgba(156, 165, 55, 0.6); |
208 | - box-shadow: 10px 10px 20px -4px rgba(0,0,0,0.21); | |
209 | - /* ********************** */ | |
210 | - position: relative; | |
211 | - width: 60px; height: 60px; | |
212 | - margin: 7px 7px; padding: 0; | |
213 | 193 | } |
214 | - .palset { | |
215 | - border: 1px solid rgba(0,0,0,0.2); | |
194 | + .palettesetting { | |
216 | 195 | background-color: rgba(27, 158, 131, 0.6); |
217 | - box-shadow: 10px 10px 20px -4px rgba(0,0,0,0.21); | |
218 | - /* ********************** */ | |
219 | - position: relative; | |
220 | - width: 60px; height: 60px; | |
221 | - margin: 7px 7px; padding: 0; | |
222 | 196 | } |
223 | 197 | |
224 | 198 | /* パレット内の個々のボタン Element */ |
199 | + /* ul liの上に動的に作成される */ | |
225 | 200 | .palbutton { |
226 | 201 | position: absolute; |
227 | 202 | left: 0; top: 0; |
@@ -228,8 +203,9 @@ | ||
228 | 203 | width: 100%; height: 100%; |
229 | 204 | margin: 0; padding: 0; |
230 | 205 | border: 1px solid black; |
206 | + border-radius: inherit; | |
231 | 207 | background-color: inherit; |
232 | - box-shadow: inherit; | |
208 | + box-shadow: 10px 10px 20px -4px rgba(0,0,0,0.21); | |
233 | 209 | } |
234 | 210 | |
235 | 211 | /* パレットサイズ変更用 Element */ |
@@ -21,138 +21,59 @@ | ||
21 | 21 | } |
22 | 22 | </style> |
23 | 23 | <!-- Palette --> |
24 | - <style id="stylepalbg"> | |
25 | - .palbg0 { | |
26 | - background-image: url(dummy.png); | |
27 | - } | |
28 | - | |
29 | - .palbg1 { | |
30 | - background-image: url(dummy.png); | |
31 | - } | |
32 | - | |
33 | - .palbg2 { | |
34 | - background-image: url(dummy.png); | |
35 | - } | |
36 | - | |
37 | - .palbg3 { | |
38 | - background-image: url(dummy.png); | |
39 | - } | |
40 | - | |
41 | - .palbg4 { | |
42 | - background-image: url(dummy.png); | |
43 | - } | |
24 | + <style id="styleBackground"> | |
25 | + .palbg0 { background-image: url(dummy.png); } | |
26 | + .palbg1 { background-image: url(dummy.png); } | |
27 | + .palbg2 { background-image: url(dummy.png); } | |
28 | + .palbg3 { background-image: url(dummy.png); } | |
29 | + .palbg4 { background-image: url(dummy.png); } | |
44 | 30 | </style> |
45 | - <style id="stylepaltxtcol"> | |
46 | - .paltxtcol0 { | |
47 | - color: black; | |
48 | - } | |
49 | - | |
50 | - .paltxtcol1 { | |
51 | - color: red; | |
52 | - } | |
53 | - | |
54 | - .paltxtcol2 { | |
55 | - color: blue; | |
56 | - } | |
57 | - | |
58 | - .paltxtcol3 { | |
59 | - color: green; | |
60 | - } | |
61 | - | |
62 | - .paltxtcol4 { | |
63 | - color: brown; | |
64 | - } | |
31 | + <style id="keyframeBackground"> | |
32 | + @keyframes animeact1 { to { color: black; } } | |
33 | + @keyframes animeact2 { to { color: black; } } | |
34 | + @keyframes animeact3 { to { color: black; } } | |
35 | + @keyframes animeact4 { to { color: black; } } | |
36 | + @keyframes animeact5 { to { color: black; } } | |
65 | 37 | </style> |
66 | - <style id="stylepalact"> | |
67 | - .palact0 { | |
68 | - animation: animeY1 0.5s ease-in 0.3s 1 normal; | |
69 | - } | |
70 | - | |
38 | + <style id="styleStyle"> | |
39 | + .paltxtcol0 { color: black; } | |
40 | + .paltxtcol1 { color: red; } | |
41 | + .paltxtcol2 { color: blue; } | |
42 | + .paltxtcol3 { color: green; } | |
43 | + .paltxtcol4 { color: brown; } | |
44 | + </style> | |
45 | + <style id="keyframeStyle"> | |
46 | + @keyframes animeact1 { to { color: black; } } | |
47 | + @keyframes animeact2 { to { color: black; } } | |
48 | + @keyframes animeact3 { to { color: black; } } | |
49 | + @keyframes animeact4 { to { color: black; } } | |
50 | + @keyframes animeact5 { to { color: black; } } | |
51 | + </style> | |
52 | + <style id="styleAction"> | |
53 | + .palact0 { animation: animeY1 0.5s ease-in 0.3s 1 normal; } | |
54 | + .palact1 { animation: animeact1 2s ease-in 0.3s 1 normal; } | |
55 | + .palact2 { animation: animeact2 2s ease-in 0.3s 1 normal; } | |
56 | + .palact3 { animation: animeact3 2s ease-in 0.3s 1 normal; } | |
57 | + .palact4 { animation: animeact4 2s ease-in 0.3s 1 normal; } | |
58 | + </style> | |
59 | + <style id="keyframeAction"> | |
71 | 60 | @keyframes animeY1 { |
72 | - 0% { | |
73 | - transform: translateY(-60px) translateX(-30px); | |
74 | - } | |
75 | - | |
76 | - 10% { | |
77 | - transform: translateY(20px) translateX(30px); | |
78 | - } | |
79 | - | |
80 | - 20% { | |
81 | - transform: translateY(-40px) translateX(-20px); | |
82 | - } | |
83 | - | |
84 | - 30% { | |
85 | - transform: translateY(50px) translateX(-10px); | |
86 | - } | |
87 | - | |
88 | - 40% { | |
89 | - transform: translateY(-40px) translateX(20px); | |
90 | - } | |
91 | - | |
92 | - 50% { | |
93 | - transform: translateY(30px) translateX(-15px); | |
94 | - } | |
95 | - | |
96 | - 60% { | |
97 | - transform: translateY(-25px) translateX(0px); | |
98 | - } | |
99 | - | |
100 | - 70% { | |
101 | - transform: translateY(15px) translateX(-15px); | |
102 | - } | |
103 | - | |
104 | - 80% { | |
105 | - transform: translateY(-10px) translateX(10px); | |
106 | - } | |
107 | - | |
108 | - 90% { | |
109 | - transform: translateY(0px) translateX(-5px); | |
110 | - } | |
111 | - | |
112 | - 100% { | |
113 | - transform: translateY(0px) translateX(0px); | |
114 | - } | |
61 | + 0% { transform: translateY(-60px) translateX(-30px); } | |
62 | + 10% { transform: translateY(20px) translateX(30px); } | |
63 | + 20% { transform: translateY(-40px) translateX(-20px); } | |
64 | + 30% { transform: translateY(50px) translateX(-10px); } | |
65 | + 40% { transform: translateY(-40px) translateX(20px); } | |
66 | + 50% { transform: translateY(30px) translateX(-15px); } | |
67 | + 60% { transform: translateY(-25px) translateX(0px); } | |
68 | + 70% { transform: translateY(15px) translateX(-15px); } | |
69 | + 80% { transform: translateY(-10px) translateX(10px); } | |
70 | + 90% { transform: translateY(0px) translateX(-5px); } | |
71 | + 100% { transform: translateY(0px) translateX(0px); } | |
115 | 72 | } |
116 | - | |
117 | - .palact1 { | |
118 | - animation: animeact1 2s ease-in 0.3s 1 normal; | |
119 | - } | |
120 | - | |
121 | - @keyframes animeact1 { | |
122 | - to { | |
123 | - color: black; | |
124 | - } | |
125 | - } | |
126 | - | |
127 | - .palact2 { | |
128 | - animation: animeact2 2s ease-in 0.3s 1 normal; | |
129 | - } | |
130 | - | |
131 | - @keyframes animeact2 { | |
132 | - to { | |
133 | - color: black; | |
134 | - } | |
135 | - } | |
136 | - | |
137 | - .palact3 { | |
138 | - animation: animeact3 2s ease-in 0.3s 1 normal; | |
139 | - } | |
140 | - | |
141 | - @keyframes animeact3 { | |
142 | - to { | |
143 | - color: black; | |
144 | - } | |
145 | - } | |
146 | - | |
147 | - .palact4 { | |
148 | - animation: animeact4 2s ease-in 0.3s 1 normal; | |
149 | - } | |
150 | - | |
151 | - @keyframes animeact4 { | |
152 | - to { | |
153 | - color: black; | |
154 | - } | |
155 | - } | |
73 | + @keyframes animeact1 { to { color: black; } } | |
74 | + @keyframes animeact2 { to { color: black; } } | |
75 | + @keyframes animeact3 { to { color: black; } } | |
76 | + @keyframes animeact4 { to { color: black; } } | |
156 | 77 | </style> |
157 | 78 | |
158 | 79 | <fieldset class="palgroup palgroup0" data-objid="palgroup0" style="width:400px; height:130px;" title="背景の色や画像を設定するパレットです"> |
@@ -161,11 +82,11 @@ | ||
161 | 82 | <span class="paldesc1">背景</span><span class="paldesc2">色 </span> |
162 | 83 | </div> |
163 | 84 | <ul class="palflex"> |
164 | - <li class="palbg palbg0" data-objid="palbg0" data-palid="0"></li> | |
165 | - <li class="palbg palbg1" data-objid="palbg1" data-palid="1"></li> | |
166 | - <li class="palbg palbg2" data-objid="palbg2" data-palid="2"></li> | |
167 | - <li class="palbg palbg3" data-objid="palbg3" data-palid="3"></li> | |
168 | - <li class="palbg palbg4" data-objid="palbg4" data-palid="4"></li> | |
85 | + <li class="palettebackground palbg0" data-objid="palbg0" data-palid="0"></li> | |
86 | + <li class="palettebackground palbg1" data-objid="palbg1" data-palid="1"></li> | |
87 | + <li class="palettebackground palbg2" data-objid="palbg2" data-palid="2"></li> | |
88 | + <li class="palettebackground palbg3" data-objid="palbg3" data-palid="3"></li> | |
89 | + <li class="palettebackground palbg4" data-objid="palbg4" data-palid="4"></li> | |
169 | 90 | </ul> |
170 | 91 | <div class="palsize"></div> |
171 | 92 | </fieldset> |
@@ -177,11 +98,11 @@ | ||
177 | 98 | <span class="paldesc1">外観</span><span class="paldesc2">見た</span> |
178 | 99 | </div> |
179 | 100 | <ul class="palflex"> |
180 | - <li class="paltxtcol paltxtcol0" data-objid="paltxtcol0" data-palid="0"></li> | |
181 | - <li class="paltxtcol paltxtcol1" data-objid="paltxtcol1" data-palid="1"></li> | |
182 | - <li class="paltxtcol paltxtcol2" data-objid="paltxtcol2" data-palid="2"></li> | |
183 | - <li class="paltxtcol paltxtcol3" data-objid="paltxtcol3" data-palid="3"></li> | |
184 | - <li class="paltxtcol paltxtcol4" data-objid="paltxtcol4" data-palid="4"></li> | |
101 | + <li class="palettestyle paltxtcol0" data-objid="paltxtcol0" data-palid="0"></li> | |
102 | + <li class="palettestyle paltxtcol1" data-objid="paltxtcol1" data-palid="1"></li> | |
103 | + <li class="palettestyle paltxtcol2" data-objid="paltxtcol2" data-palid="2"></li> | |
104 | + <li class="palettestyle paltxtcol3" data-objid="paltxtcol3" data-palid="3"></li> | |
105 | + <li class="palettestyle paltxtcol4" data-objid="paltxtcol4" data-palid="4"></li> | |
185 | 106 | </ul> |
186 | 107 | <div class="palsize"></div> |
187 | 108 | </fieldset> |
@@ -194,11 +115,11 @@ | ||
194 | 115 | <span class="paldesc1">動き</span><span class="paldesc2">流れ</span> |
195 | 116 | </div> |
196 | 117 | <ul class="palflex"> |
197 | - <li class="palact palact0" data-objid="palact0" data-palid="0"></li> | |
198 | - <li class="palact palact1" data-objid="palact1" data-palid="1"></li> | |
199 | - <li class="palact palact2" data-objid="palact2" data-palid="2"></li> | |
200 | - <li class="palact palact3" data-objid="palact3" data-palid="3"></li> | |
201 | - <li class="palact palact4" data-objid="palact4" data-palid="4"></li> | |
118 | + <li class="paletteaction palact0" data-objid="palact0" data-palid="0"></li> | |
119 | + <li class="paletteaction palact1" data-objid="palact1" data-palid="1"></li> | |
120 | + <li class="paletteaction palact2" data-objid="palact2" data-palid="2"></li> | |
121 | + <li class="paletteaction palact3" data-objid="palact3" data-palid="3"></li> | |
122 | + <li class="paletteaction palact4" data-objid="palact4" data-palid="4"></li> | |
202 | 123 | </ul> |
203 | 124 | <div class="palsize"></div> |
204 | 125 | </fieldset> |
@@ -209,11 +130,11 @@ | ||
209 | 130 | <span class="paldesc1">設定</span><span class="paldesc2">変更</span> |
210 | 131 | </div> |
211 | 132 | <ul class="palflex"> |
212 | - <li class="palset palset0" data-objid="palset0" data-palid="0"></li> | |
213 | - <li class="palset palset1" data-objid="palset1" data-palid="1"></li> | |
214 | - <li class="palset palset2" data-objid="palset2" data-palid="2"></li> | |
215 | - <li class="palset palset3" data-objid="palset3" data-palid="3"></li> | |
216 | - <li class="palset palset4" data-objid="palset4" data-palid="4"></li> | |
133 | + <li class="palettesetting palset0" data-objid="palset0" data-palid="0"></li> | |
134 | + <li class="palettesetting palset1" data-objid="palset1" data-palid="1"></li> | |
135 | + <li class="palettesetting palset2" data-objid="palset2" data-palid="2"></li> | |
136 | + <li class="palettesetting palset3" data-objid="palset3" data-palid="3"></li> | |
137 | + <li class="palettesetting palset4" data-objid="palset4" data-palid="4"></li> | |
217 | 138 | </ul> |
218 | 139 | <div class="palsize"></div> |
219 | 140 | </fieldset> |
@@ -440,6 +440,7 @@ | ||
440 | 440 | |
441 | 441 | |
442 | 442 | function prohibitDropHandler_dragStart(evt) { |
443 | + debuglog('prohibitDropHandler_dragStart'); | |
443 | 444 | evt.preventDefault(); |
444 | 445 | } |
445 | 446 | function prohibitDropHandler_dragOver(evt) { |
@@ -447,7 +448,7 @@ | ||
447 | 448 | evt.dataTransfer.dropEffect = "none"; |
448 | 449 | } |
449 | 450 | function prohibitDropHandler_drop(evt) { |
450 | - this.debuglog('prohibitDropHandler_drop'); | |
451 | + debuglog('prohibitDropHandler_drop'); | |
451 | 452 | evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) |
452 | 453 | evt.stopImmediatePropagation(); // 処理中要素の他のevent listenerを止める |
453 | 454 | evt.preventDefault(); // 要素既定のdefault動作を止める |
@@ -6,52 +6,120 @@ | ||
6 | 6 | // ・Target要素に自objidと同名のCSS class追加 |
7 | 7 | // ・外部からのDropによる text, image, css 読み込み |
8 | 8 | |
9 | -// パレットのCSS機能ボタンを押したときに実行する機能を提供する | |
9 | +// パレットのCSS機能ボタンをDropしたときに実行する機能を提供する | |
10 | 10 | // (保持中CSS class nameを対象Elementに付加, 削除) |
11 | 11 | // (Button instanceが自分の機能を意識しないようにするためのclass) |
12 | 12 | class PaletteApplyCSS { |
13 | 13 | constructor() { |
14 | - this.paletteRule = null; | |
15 | - this.dataScheme = null; | |
14 | +// this.paletteRule = null; | |
15 | + this.dataScheme = null; | |
16 | 16 | this.description = null; |
17 | + this.groupname = null; | |
18 | + this.num = -1; | |
19 | + this.eleStyle = null; | |
20 | + this.eleKeyframe = null; | |
17 | 21 | } |
22 | + initialize(eleStyle, eleKeyframe, groupname, num) { | |
18 | 23 | |
24 | + if (null == eleStyle || null == eleKeyframe) { | |
25 | + console.error('PaletteApplyCSS 作成失敗 引数要素異常\neleStyle = ' + eleStyle + ', eleKeyframe = ' + eleKeyframe); | |
26 | + return; | |
27 | + } | |
28 | + if (eleStyle.sheet.cssRules.length <= num | |
29 | + || eleKeyframe.sheet.cssRules.length <= num) { | |
30 | + console.error('PaletteApplyCSS 作成失敗 引数要素異常\nnum = ' + num + 'eleStyle.sheet.cssRules.length = ' + eleStyle.sheet.cssRules.length + ', eleKeyframe.sheet.cssRules.length = ' + eleKeyframe.sheet.cssRules.length); | |
31 | + return; | |
32 | + } | |
33 | + | |
34 | + // CSS 書き換え対象 Rule への参照を保持 | |
35 | + this.groupname = groupname; | |
36 | + this.num = num; | |
37 | + this.eleStyle = eleStyle; | |
38 | + this.eleKeyframe = eleKeyframe; | |
39 | + } | |
40 | + | |
41 | + | |
42 | + // 参照中のCSS Ruleを引数textで上書き | |
43 | + // CSS class名は変化しない。本文のみ上書き。 | |
44 | + registerCSSRule( | |
45 | + type, // 'Style' or 'Action' | |
46 | + description, // 説明内容テキスト | |
47 | + style, // CSS定義 本文のみ使用する | |
48 | + keyframe, // @keyframeを含むテキスト or null | |
49 | + picture // data scheme | |
50 | + ) { | |
51 | + this.removeDescription(); | |
52 | + this.removeImage(); | |
53 | + | |
54 | + this.registerDescription(description); | |
55 | + this.registerImage(picture); | |
56 | + this.replaceStyle(style); | |
57 | + if (null != keyframe) | |
58 | + this.replaceKeyframe(keyframe); | |
59 | + } | |
60 | + | |
19 | 61 | // 機能の登録・削除・実行 ------------------ |
20 | 62 | // 前提:既にCSS ruleはdocumentに登録されている |
21 | 63 | // CSS ruleへの参照を保持 |
22 | 64 | // 適用要求で対象Elementに保持ruleをadd class |
65 | + replaceStyle(text) { | |
66 | + // '{' ~ '}' の間を抽出 | |
67 | + let strStyle = text.match(/\{([\s\S]*)\}/)[1]; | |
68 | + // class名追加 | |
69 | + let cssStyle = '.' + this.groupname + this.num + '{' + strStyle + '}'; | |
23 | 70 | |
24 | - registerCSS(rule) { | |
25 | - if (null != this.paletteRule) { | |
26 | - console.error('パレット機能 上書き登録\n以前の機能 = ' + this.paletteRule + '\n今回の機能 = ' + rule); | |
27 | - // ひとまず処理継続 | |
28 | - } | |
29 | - this.paletteRule = rule; | |
71 | + this.removeStyle(); | |
72 | + this.registerStyle(cssStyle); | |
73 | + } | |
74 | + registerStyle(text) { | |
75 | + this.eleStyle.sheet.insertRule(text, this.num); | |
30 | 76 | return true; |
31 | 77 | } |
32 | - removeCSS() { | |
33 | - this.paletteRule = null; | |
78 | + removeStyle() { | |
79 | + this.eleStyle.sheet.deleteRule(this.num); | |
34 | 80 | } |
35 | - getCSS() { | |
36 | - return this.paletteRule; | |
81 | + getStyle() { | |
82 | + return this.eleStyle.sheet.cssRules[this.num]; | |
37 | 83 | } |
38 | 84 | getClassName() { |
39 | - return this.paletteRule.name; | |
85 | + return this.eleStyle.sheet.cssRules[this.num].selectorText; | |
40 | 86 | } |
87 | + // Target element へ CSS classを追加する | |
88 | + // 同じ種類のCSS class(Text color, BG imgなど)が既にある場合は上書き | |
89 | + replaceClassToElement( | |
90 | + CSSname, // 追加(上書き)する CSSclass名称文字列 | |
91 | + targetEle // 追加先 element | |
92 | + ) { | |
93 | + // Drag中の palette elementから 追加する CSS classを取得 (objidと同じ名前にしている) | |
94 | + let result = /[a-zA-Z]+/.exec(CSSname); // objid末の数字を除く | |
95 | + let DraggingPaletteType = result[0]; | |
96 | + | |
97 | + // Drop target elementに 同じ種類の CSS classがないかチェック | |
98 | + let reg = new RegExp(DraggingPaletteType + '[0-9]+'); // 数字は1回以上発生する。数字なしは別class | |
99 | + result = reg.exec(targetEle.className); | |
100 | + let DropEleOldClass = (null != result) ? result[0] : null; | |
101 | + | |
102 | + // 同じ種類の CSS classがあれば削除 | |
103 | + if (null != DropEleOldClass) | |
104 | + targetEle.classList.remove(DropEleOldClass); | |
105 | + | |
106 | + // Drop target elementに Drag elementの CSS class定義を追加 | |
107 | + targetEle.classList.add(DraggingPaletteType + this.num); | |
108 | + } | |
41 | 109 | // 保持中CSS class nameを引数ElementのclassListに追加 |
42 | - addClass(ele) { | |
110 | + addClassToElement(ele) { | |
43 | 111 | if (null == ele) { |
44 | 112 | console.error('CSS適用対象要素が指定されていません'); |
45 | 113 | return false; |
46 | 114 | } |
47 | - if (null == this.paletteRule) { | |
115 | + if (null == this.eleStyle) { | |
48 | 116 | console.error('CSSが未登録のまま 要素にCSSを追加しようとしました\nEle = ' + ele); |
49 | 117 | return false; |
50 | 118 | } |
51 | - ele.classList.add(this.paletteRule.name); | |
119 | + ele.classList.add(this.getClassName()); | |
52 | 120 | } |
53 | 121 | // 保持中CSS class nameを引数ElementのclassListから削除 |
54 | - removeClass(ele) { | |
122 | + removeClassToElement(ele) { | |
55 | 123 | if (null == ele) { |
56 | 124 | console.error('CSS適用対象要素が指定されていません'); |
57 | 125 | return false; |
@@ -60,9 +128,27 @@ | ||
60 | 128 | console.error('CSSが未登録のまま 要素にCSSを削除しようとしました\nEle = ' + ele); |
61 | 129 | return false; |
62 | 130 | } |
63 | - ele.classList.remove(this.paletteRule.name); | |
131 | + ele.classList.remove(this.getClassName()); | |
64 | 132 | } |
65 | 133 | |
134 | + replaceKeyframe(text) { | |
135 | + this.removeKeyframe(); | |
136 | + this.registerKeyframe(text); | |
137 | + } | |
138 | + registerKeyframe(text) { | |
139 | + this.eleKeyframe.sheet.insertRule(text, this.num); | |
140 | + return true; | |
141 | + } | |
142 | + removeKeyframe() { | |
143 | + this.eleKeyframe.sheet.deleteRule(this.num); | |
144 | + } | |
145 | + getKeyframe() { | |
146 | + return this.eleKeyframe.sheet.cssRules[this.num]; | |
147 | + } | |
148 | + getKeyframeName() { | |
149 | + return this.eleKeyframe.sheet.cssRules[this.num].name; | |
150 | + } | |
151 | + | |
66 | 152 | // 登録されたCSSの機能に関連した画像・説明文の 登録・取得 ------------ |
67 | 153 | registerImage(dataScheme) { |
68 | 154 | if (null != this.dataScheme) { |
@@ -346,7 +432,7 @@ | ||
346 | 432 | // ボタン Click で実行する機能を登録 |
347 | 433 | setPalettePressFunction(palfunc) { |
348 | 434 | if (null != this.palettePressFunction) { |
349 | - console.error('パレットボタン(PaletteShapeFunctionButton)への機能設定エラー 上書き登録\n以前の機能 = ' + this.palettePressFunction.getFunction.name + ', 今回の機能 = ' + palfunc.getFunction.name); | |
435 | + console.error('パレットボタン(PaletteShapeFunctionButton)への機能設定エラー 上書き登録\n以前の機能 = ' + this.palettePressFunction.getFunction.name + ', 今回の機能 = ' + palfunc.name); | |
350 | 436 | // ひとまず処理継続 |
351 | 437 | } |
352 | 438 | this.palettePressFunction = palfunc; |
@@ -403,14 +489,31 @@ | ||
403 | 489 | // PaletteShapeFunctionButtonとは機能が違うし使いまわし部分も少ないので分けてしまう |
404 | 490 | |
405 | 491 | // パレットのCSSボタン表示部分の定義class |
406 | -// DOM Elementの保持、ボタンdrag & dropでの実行機能との関連付け | |
492 | +// DOM Elementの保持、ボタンdrag & dropで呼び出す機能との関連付け | |
407 | 493 | // Input eventから必要機能の呼び出し |
408 | 494 | class PaletteShapeCSSButton { |
409 | 495 | constructor() { |
496 | + this.paletteType = null; | |
497 | + this.num = -1; | |
410 | 498 | this.DOMobject = null; |
411 | - this.paletteDropFunction = null; | |
499 | + this.paletteTextParser = null; | |
412 | 500 | } |
501 | + initialize(paletteType, num) { | |
413 | 502 | |
503 | + this.paletteType = paletteType; | |
504 | + this.num = num; | |
505 | + this.paletteTextParser = new PaletteCSSTextParser(); | |
506 | + | |
507 | + // paletteApplyCss に保持させるRuleへの参照を取得 | |
508 | + this.eleStyleArray = { 'Background': 'styleBackground', 'Style': 'styleStyle', 'Action': 'styleAction' }; // Setting paletteは CSSを使わない | |
509 | + this.eleKeyframeArray = { 'Background': 'keyframeBackground', 'Style': 'keyframeStyle', 'Action': 'keyframeAction' }; | |
510 | + | |
511 | + let eleStyle = document.getElementById(this.eleStyleArray[this.paletteType]); | |
512 | + let eleKeyframe = document.getElementById(this.eleKeyframeArray[this.paletteType]); | |
513 | + this.paletteApplyCss = new PaletteApplyCSS(); | |
514 | + this.paletteApplyCss.initialize(eleStyle, eleKeyframe, paletteType, num); | |
515 | + } | |
516 | + | |
414 | 517 | // 表示に使用するDOM要素を作成 |
415 | 518 | // DOM 要素を作成してこの Instance の表示要素として登録 |
416 | 519 | createButtonElement(parent) { |
@@ -451,23 +554,19 @@ | ||
451 | 554 | ele.appendChild(this.DOMobject); |
452 | 555 | return true; |
453 | 556 | } |
454 | - | |
557 | +/* | |
455 | 558 | // Paletteボタン対象Dropで実行する機能を登録 |
456 | - setPaletteDropFunction(dropcssfunc) { | |
457 | - if (null != this.paletteDropFunction) { | |
458 | - console.error('パレットボタン(PaletteShapeFunctionButton)への機能設定エラー 上書き登録\n以前の機能 = ' + this.paletteDropFunction.getFunction.name + ', 今回の機能 = ' + palfunc.getFunction.name); | |
559 | + setpaletteApplyCss(dropcssfunc) { | |
560 | + if (null != this.paletteApplyCss) { | |
561 | + console.error('パレットボタン(PaletteShapeFunctionButton)への機能設定エラー 上書き登録\n以前の機能 = ' + this.paletteApplyCss.getFunction.name + ', 今回の機能 = ' + dropcssfunc.name); | |
459 | 562 | // ひとまず処理継続 |
460 | 563 | } |
461 | - this.paletteDropFunction = palfunc; | |
564 | + this.paletteApplyCss = dropcssfunc; | |
462 | 565 | |
463 | - // 表示要素の更新 | |
464 | - this.DOMobject.title = this.palettePressFunction.getDescription(); | |
465 | - this.DOMobject.style.backgroundImage = 'url(' + this.palettePressFunction.getImage() + ')'; | |
466 | - this.DOMobject.style.backgroundSize = 'cover'; | |
467 | 566 | } |
468 | - | |
469 | - clearPaletteDropFunction() { | |
470 | - this.paletteDropFunction = null; | |
567 | +*/ | |
568 | + clearpaletteApplyCss() { | |
569 | + this.paletteApplyCss = null; | |
471 | 570 | this.DOMobject.title = null; |
472 | 571 | this.DOMobject.style.backgroundImage = 'none'; |
473 | 572 | } |
@@ -484,9 +583,9 @@ | ||
484 | 583 | this.DOMobject.addEventListener('touchstart', this.onMouseDownPaletteShapeCSSButton.bind(this), false); |
485 | 584 | // this.DOMobject.addEventListener('touchmove', this.onMouseMovePaletteShapeCSSButton.bind(this), false); |
486 | 585 | // this.DOMobject.addEventListener('touchend', this.onMouseUpPaletteShapeCSSButton.bind(this), false); |
487 | - this.DOMobject.addEventListener('dragstart', prohibitDropHandler_dragStart.bind(this), false); | |
488 | - this.DOMobject.addEventListener('dragover', prohibitDropHandler_dragOver.bind(this), false); | |
489 | - this.DOMobject.addEventListener('drop', prohibitDropHandler_drop.bind(this), false); | |
586 | + this.DOMobject.addEventListener('dragstart', this.onDragStartPaletteShapeCSSButton.bind(this), false); | |
587 | + this.DOMobject.addEventListener('dragover', this.onDragOverPaletteShapeCSSButton.bind(this), false); | |
588 | + this.DOMobject.addEventListener('drop', this.onDropPaletteShapeCSSButton.bind(this), false); | |
490 | 589 | } |
491 | 590 | |
492 | 591 |
@@ -502,7 +601,13 @@ | ||
502 | 601 | // Mouse/Touch event 差分 |
503 | 602 | let eleTarget = (null != evt.targetTouches) ? evt.targetTouches[0] : evt.target; |
504 | 603 | |
505 | - // Mouse eventをappAreaからCSSPalに渡してもらうように設定 (evt.targetは必ずpalette要素である前提。子要素なし。) | |
604 | + // ボタンにCSSが未登録なら、Userが drag 操作をする前に止める | |
605 | + if (null == this.paletteApplyCss) { | |
606 | + console.error('ボタンにCSSが登録されていません'); | |
607 | + return false; | |
608 | + } | |
609 | + | |
610 | + // Mouse eventをappAreaからCSSPalに渡してもらうように設定 | |
506 | 611 | window.appArea.setInputEventObj(eleTarget.dataset.objid, this.onMouseMovePaletteShapeCSSButton.bind(this), this.onMouseUpPaletteShapeCSSButton.bind(this)); |
507 | 612 | this.startMovingElement(evt); |
508 | 613 | } |
@@ -580,6 +685,9 @@ | ||
580 | 685 | } |
581 | 686 | |
582 | 687 | // Target element へ CSS classを追加する |
688 | + if (null != this.paletteApplyCss) { | |
689 | + this.paletteApplyCss.replaceClassToElement(this.paletteApplyCss.getClassName(), target.DOMobject); | |
690 | + } | |
583 | 691 | } |
584 | 692 | |
585 | 693 |
@@ -587,6 +695,7 @@ | ||
587 | 695 | // Applicationの外からFile Dropされたときに |
588 | 696 | // File内容情報を読み込み、CSSに反映させる |
589 | 697 | onDragStartPaletteShapeCSSButton(evt) { |
698 | + debuglog('onDragStartPaletteShapeCSSButton'); | |
590 | 699 | evt.preventDefault(); |
591 | 700 | evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) |
592 | 701 | } |
@@ -596,7 +705,7 @@ | ||
596 | 705 | evt.dataTransfer.dropEffect = "copy"; |
597 | 706 | } |
598 | 707 | onDropPaletteShapeCSSButton(evt) { |
599 | - this.debuglog('onDrop'); | |
708 | + debuglog('onDropPaletteShapeCSSButton'); | |
600 | 709 | evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる) |
601 | 710 | evt.stopImmediatePropagation(); // 処理中要素の他のevent listenerを止める |
602 | 711 | evt.preventDefault(); // 要素既定のdefault動作を止める |
@@ -606,12 +715,29 @@ | ||
606 | 715 | } |
607 | 716 | |
608 | 717 | replaceCSSText(file) { |
609 | - let cssText = null; | |
610 | - cssText = this.paletteTextParser.readTextFile(file); | |
611 | - this.paletteTextParser.parseText(cssText); | |
612 | - let rule = this.paletteApplyCss.getCSS(); | |
613 | - this.paletteTextParser.replaceCSSRule(rule, cssText); | |
718 | + // File から定義内容の読み込み | |
719 | + this.paletteTextParser.readTextFile(file, this.readComplete.bind(this)); | |
614 | 720 | } |
721 | + readComplete(cssText) { | |
722 | + let ret = false; | |
723 | + // 読み込み文字列の解析 | |
724 | + ret = this.paletteTextParser.parseText(cssText); | |
725 | + if (false == ret) // 致命的なエラー | |
726 | + return false; | |
727 | + // 解析済み文字列取得 | |
728 | + let type = this.paletteTextParser.resultOfParsingType(); | |
729 | + let description = this.paletteTextParser.resultOfParsingDescription(); | |
730 | + let style = this.paletteTextParser.resultOfParsingRule(); | |
731 | + let keyframe = this.paletteTextParser.resultOfParsingKeyframe(); | |
732 | + let picture = this.paletteTextParser.resultOfParsingPicture(); | |
733 | + // CSS 定義上書き登録 | |
734 | + let rule = this.paletteApplyCss.registerCSSRule(type, description, style, keyframe, picture); | |
735 | + | |
736 | + // 表示要素の更新 | |
737 | + this.DOMobject.title = this.paletteApplyCss.getDescription(); | |
738 | + this.DOMobject.style.backgroundImage = 'url(' + this.paletteApplyCss.getImage() + ')'; | |
739 | + this.DOMobject.style.backgroundSize = 'cover'; | |
740 | + } | |
615 | 741 | parseImage(file) { |
616 | 742 | console.error('画像ファイルには未対応'); |
617 | 743 | return false; |
@@ -625,11 +751,22 @@ | ||
625 | 751 | // Text解析、CSS登録 |
626 | 752 | // CSSの汎用操作を扱うわけではない |
627 | 753 | // 解析後のTextやImageは保持しない |
628 | -// singletonにしたいがやり方がわからないので1つだけ作るようにする;´Д`)運用でカバー | |
629 | 754 | class PaletteCSSTextParser { |
630 | 755 | constructor() { |
631 | 756 | this.filename = null; |
632 | 757 | this.cssText = null; |
758 | + | |
759 | + // Parse text 用の定義 | |
760 | + this.startStrArray = ['\\[', ' Start\\]']; | |
761 | + this.endStrArray = ['\\[', ' End\\]']; | |
762 | + this.blockNameArray = ['Type', 'Description', 'Rule', 'Keyframe', 'Picture']; | |
763 | + this.blockRequired = [true, false, true, false, false]; | |
764 | + this.typeNameArray = ['Style', 'Action']; | |
765 | + // 分解後の文字列保持先連想配列の確保 | |
766 | + this.defineStrArray = []; | |
767 | + for (let cnt = 0; cnt < this.blockNameArray.length; cnt++) { | |
768 | + this.defineStrArray[this.blockNameArray[cnt]] = null; | |
769 | + } | |
633 | 770 | } |
634 | 771 | |
635 | 772 | // Drop file(CSS定義test)の内容読み込み(file, ele, num) |
@@ -659,26 +796,154 @@ | ||
659 | 796 | } |
660 | 797 | |
661 | 798 | // Stringの解析・解析結果を一旦内部保持 (解析実行ごとに上書き) |
662 | - // class name取得 | |
663 | - // 定義内容取得 | |
664 | - // description取得 | |
665 | - // data scheme取得 | |
666 | - // comment取得 | |
667 | 799 | parseText(str) { |
668 | - // Textを下記要素に分解する | |
669 | - // ・ | |
800 | + // ブロックごとに分解して内部変数に結果を保持 | |
801 | + this.parseTextBlocks(str); | |
802 | + // (定義チェック前に) 文字列前後の空白を削除 | |
803 | + this.parseTextClearBlankCharacters(); | |
804 | + // 必要な定義の存在チェック | |
805 | + let abnormalData, notRecommended, resultStr; | |
806 | + [abnormalData, notRecommended, resultStr] = this.parseTextCheckData(); | |
807 | + if (true == abnormalData) { | |
808 | + console.error(resultStr); | |
809 | + return false; | |
810 | + } | |
811 | + else if (true == notRecommended) { | |
812 | + console.error(resultStr); | |
813 | + } | |
814 | + | |
815 | + // 読みこんだ文字列を CSS 定義差し替えに使える形に調整 | |
816 | + let ret = false; | |
817 | +// ret = this.parseTextRule(); | |
818 | +// if (false == ret) | |
819 | +// return false; | |
820 | + this.parseTextKeyframe(); | |
821 | + | |
822 | + return true; | |
670 | 823 | } |
671 | 824 | |
672 | - // StringをStyle elementへadd - Ruleへの参照を返す | |
673 | - // Element指定は必須 | |
674 | - // StringをStyle elementへreplace - Ruleへの参照を返す | |
675 | - // Element指定は必須 | |
676 | - replaceCSSRule(rule, text) { | |
825 | + resultOfParsingType() { | |
826 | + return this.defineStrArray[this.blockNameArray[0]]; | |
677 | 827 | } |
828 | + resultOfParsingDescription() { | |
829 | + return this.defineStrArray[this.blockNameArray[1]]; | |
830 | + } | |
831 | + resultOfParsingRule() { | |
832 | + return this.defineStrArray[this.blockNameArray[2]]; | |
833 | + } | |
834 | + resultOfParsingKeyframe() { | |
835 | + return this.defineStrArray[this.blockNameArray[3]]; | |
836 | + } | |
837 | + resultOfParsingPicture() { | |
838 | + return this.defineStrArray[this.blockNameArray[4]]; | |
839 | + } | |
678 | 840 | |
679 | - // CSS class name指定でRuleへの参照を返す | |
680 | - // Element指定あり …… 指定Element内から検索 | |
681 | - // Element指定なし …… document全体から検索 | |
841 | + | |
842 | + | |
843 | + // Private 関数 ------------------------- | |
844 | + | |
845 | + parseTextBlocks(str) { | |
846 | + // ブロックごとに分解する | |
847 | + for (let cnt = 0; cnt < this.blockNameArray.length; cnt++) { | |
848 | + // Keyword 作成 | |
849 | + let strStart = this.startStrArray[0] + this.blockNameArray[cnt] + this.startStrArray[1]; | |
850 | + let strEnd = this.endStrArray[0] + this.blockNameArray[cnt] + this.endStrArray[1]; | |
851 | + let strReg = strStart + '(\[\\s\\S\]*?)' + strEnd; | |
852 | + let regKeyword = new RegExp(strReg); | |
853 | + // 目的箇所の取得 | |
854 | + let strDefine = str.match(regKeyword); | |
855 | + // 結果を保持 | |
856 | + if (null != strDefine) | |
857 | + this.defineStrArray[this.blockNameArray[cnt]] = (0 < strDefine.length) ? strDefine[1] : null; | |
858 | + } | |
859 | + } | |
860 | + // 文字列の前後にある空白を削除 | |
861 | + parseTextClearBlankCharacters() { | |
862 | + for (let cnt = 0; cnt < this.blockNameArray.length; cnt++) { | |
863 | + if (null != this.defineStrArray[this.blockNameArray[cnt]]) | |
864 | + this.defineStrArray[this.blockNameArray[cnt]] = this.defineStrArray[this.blockNameArray[cnt]].replace(/^\s+|\s+$/g, ""); | |
865 | + } | |
866 | + } | |
867 | + parseTextCheckData() { | |
868 | + let abnormalData = false; | |
869 | + let notRecommended = false; | |
870 | + let resultStr = "定義ファイルから下記のデータが正しく読み取れません。ファイルの内容に問題がないかご確認頂けないでしょうか。\n"; | |
871 | + for (let cnt = 0; cnt < this.blockNameArray.length; cnt++) { | |
872 | + // 存在しないデータがみつかった | |
873 | + if (null == this.defineStrArray[this.blockNameArray[cnt]]) { | |
874 | + // それは必須データ? | |
875 | + if (true == this.blockRequired[cnt]) { | |
876 | + abnormalData = true; | |
877 | + resultStr += "Must:" + this.blockNameArray[cnt] + " 定義\n"; | |
878 | + } | |
879 | + else { | |
880 | + notRecommended = true; | |
881 | + resultStr += "Should:" + this.blockNameArray[cnt] + " 定義\n"; | |
882 | + } | |
883 | + } | |
884 | + } | |
885 | + // Type データの型チェック | |
886 | + let ret = this.parseTextCheckType(this.defineStrArray[this.blockNameArray[0]]); | |
887 | + if (false == ret) { | |
888 | + abnormalData = true; | |
889 | + | |
890 | + let strTypeName = null; | |
891 | + let cnt = 0; | |
892 | + while(true) { | |
893 | + strTypeName += this.typeNameArray[cnt]; | |
894 | + if (++cnt < this.typeNameArray.length) | |
895 | + break; | |
896 | + strTypeName += ', '; | |
897 | + } | |
898 | + resultStr += this.blockNameArray[0] + "データとして設定する値は次のいずれかにしてください:" + strTypeName; | |
899 | + } | |
900 | + | |
901 | + return [abnormalData, notRecommended, resultStr]; | |
902 | + } | |
903 | + parseTextCheckType(strType) { | |
904 | + let result = false; | |
905 | + for (let cnt = 0; cnt < this.typeNameArray.length; cnt++) { | |
906 | + if (strType == this.typeNameArray[cnt]) { | |
907 | + result = true; | |
908 | + break; | |
909 | + } | |
910 | + } | |
911 | + return result; | |
912 | + } | |
913 | + | |
914 | + // 内部変数 this.defineStrArray[this.blockNameArray[2]] から CSS 定義部分を抽出 | |
915 | + parseTextRule() { | |
916 | + let strCSS = this.defineStrArray[this.blockNameArray[2]]; | |
917 | + let strRule = strCSS.match(/\{([\s\S]*)\}/); | |
918 | + if (strRule.length < 1) { | |
919 | + console.error('Rule定義内容が見つかりません\nRule = ' + strCSS); | |
920 | + return false; | |
921 | + } | |
922 | + // 定義の差し替えに使える形で上書き | |
923 | + this.defineStrArray[this.blockNameArray[2]] = strRule[1]; | |
924 | + } | |
925 | + | |
926 | + // 内部変数 this.defineStrArray[this.blockNameArray[3]] の内容チェック | |
927 | + parseTextKeyframe() { | |
928 | + let strCSS = this.defineStrArray[this.blockNameArray[3]]; | |
929 | + if (null == strCSS) { | |
930 | + console.log('keyframe定義なし'); | |
931 | + return true; | |
932 | + } | |
933 | + if (- 1 == strCSS.indexOf('@keyframe')) { | |
934 | + if (this.typeNameArray[1] == this.defineStrArray[this.blockNameArray[0]]) { | |
935 | + console.error('Keyframe定義が読み込めません\nkeyframe = ' +strCSS); | |
936 | + // 致命的エラーにはしない。Animation定義未使用の可能性があるため | |
937 | + this.defineStrArray[this.blockNameArray[3]] = null; | |
938 | + return false; | |
939 | + } | |
940 | + } | |
941 | + // keyframe dataはそのまま使うので特に加工しない | |
942 | + return true; | |
943 | + } | |
944 | + | |
945 | + | |
946 | + | |
682 | 947 | } |
683 | 948 | |
684 | 949 | class CSSPalette { |
@@ -692,16 +957,17 @@ | ||
692 | 957 | |
693 | 958 | initialize() { |
694 | 959 | // CSS 情報定義先を保持 |
695 | - this.stylebg = document.getElementById('stylepalbg'); | |
696 | - this.styletxtcol = document.getElementById('stylepaltxtcol'); | |
697 | - this.styleact = document.getElementById('stylepalact'); | |
960 | + this.stylebg = document.getElementById('styleBackground'); | |
961 | + this.styletxtcol = document.getElementById('styleStyle'); | |
962 | + this.styleact = document.getElementById('styleAction'); | |
698 | 963 | |
699 | 964 | // palette要素を保持 |
700 | 965 | // 背景設定パレット |
701 | - let elePalbg = document.getElementsByClassName('palbg'); | |
966 | + let elePalbg = document.getElementsByClassName('palettebackground'); | |
702 | 967 | this.palBackground = []; |
703 | 968 | for (let cnt = 0; cnt < elePalbg.length; cnt++) { |
704 | 969 | this.palBackground[cnt] = new PaletteShapeCSSButton(); |
970 | + this.palBackground[cnt].initialize('Background', cnt); | |
705 | 971 | this.palBackground[cnt].createButtonElement(elePalbg[cnt]); |
706 | 972 | // ボタンへの機能登録は 定義file drop か Save file 読み込みのとき |
707 | 973 | } |
@@ -720,10 +986,11 @@ | ||
720 | 986 | } |
721 | 987 | */ |
722 | 988 | // スタイルパレット |
723 | - let elePalstyle = document.getElementsByClassName('paltxtcol'); | |
989 | + let elePalstyle = document.getElementsByClassName('palettestyle'); | |
724 | 990 | this.palStyle = []; |
725 | 991 | for (let cnt = 0; cnt < elePalstyle.length; cnt++) { |
726 | 992 | this.palStyle[cnt] = new PaletteShapeCSSButton(); |
993 | + this.palStyle[cnt].initialize('Style', cnt); | |
727 | 994 | this.palStyle[cnt].createButtonElement(elePalstyle[cnt]); |
728 | 995 | // ボタンへの機能登録は 定義file drop か Save file 読み込みのとき |
729 | 996 | } |
@@ -742,10 +1009,11 @@ | ||
742 | 1009 | } |
743 | 1010 | */ |
744 | 1011 | // アクションパレット |
745 | - let elePalaction = document.getElementsByClassName('palact'); | |
1012 | + let elePalaction = document.getElementsByClassName('paletteaction'); | |
746 | 1013 | this.palAction = []; |
747 | 1014 | for (let cnt = 0; cnt < elePalaction.length; cnt++) { |
748 | 1015 | this.palAction[cnt] = new PaletteShapeCSSButton(); |
1016 | + this.palAction[cnt].initialize('Action', cnt); | |
749 | 1017 | this.palAction[cnt].createButtonElement(elePalaction[cnt]); |
750 | 1018 | // ボタンへの機能登録は 定義file drop か Save file 読み込みのとき |
751 | 1019 | } |
@@ -774,7 +1042,7 @@ | ||
774 | 1042 | paletteFunctionObjects.getItem(8), // Toggle Aspect ratio |
775 | 1043 | paletteFunctionObjects.getItem(10) // Toggle Scale font size |
776 | 1044 | ]; |
777 | - let elePalset = document.getElementsByClassName('palset'); // 土台 Element 取得 | |
1045 | + let elePalset = document.getElementsByClassName('palettesetting'); // 土台 Element 取得 | |
778 | 1046 | this.palSetting = []; // ボタン機能提供Elementを保持するClass Instance配列 |
779 | 1047 | for (let cnt = 0; cnt < elePalset.length; cnt++) { |
780 | 1048 | this.palSetting[cnt] = new PaletteShapeFunctionButton(); // ボタン機能Class Instance生成 |
@@ -7,7 +7,7 @@ | ||
7 | 7 | Items |
8 | 8 | [Section] [Data] [Regex Key] [Times] |
9 | 9 | Comment Text "Comment" many times |
10 | - Types "Style"/"Action" "Types" only once | |
10 | + Type "Style"/"Action" "Type" only once | |
11 | 11 | Description Text "Description" only once |
12 | 12 | Rule Text "Rule" only once |
13 | 13 | Keyframe Text "Keyframe" only once |
@@ -22,9 +22,9 @@ | ||
22 | 22 | [<Regex Key> End] |
23 | 23 | |
24 | 24 | 例: |
25 | - [Types Start] | |
25 | + [Type Start] | |
26 | 26 | Style |
27 | - [Types End] | |
27 | + [Type End] | |
28 | 28 | [Description Start] |
29 | 29 | 定義ファイルの内容説明文章 |
30 | 30 | [Description End] |
@@ -43,7 +43,7 @@ | ||
43 | 43 | |
44 | 44 | |
45 | 45 | Keyframe定義について |
46 | - Types が Action の場合のみ有効 | |
46 | + Type が Action の場合のみ有効 | |
47 | 47 | |
48 | 48 | 例 |
49 | 49 | [Keyframe Start] |