サーバ側、Railsシステム本体
Revisão | bf0efe3f0a96ec6aead9381cbd330863050c2d11 (tree) |
---|---|
Hora | 2012-03-25 06:21:23 |
Autor | itozyun <itozyun@git....> |
Commiter | itozyun |
working uploader.
@@ -217,7 +217,9 @@ version: 2.7.0 | ||
217 | 217 | --------------------------------------------------------------------------------------*/ |
218 | 218 | .button { |
219 | 219 | border: 1px solid; |
220 | - background: -moz-linear-gradient(center top , #F9F9F9, #E3E3E3) repeat scroll 0 0 transparent; | |
220 | + background: #E3E3E3; | |
221 | + background: -moz-linear-gradient(center top , #F9F9F9, #E3E3E3); | |
222 | + background: -webkit-gradient(linear, left top, left bottom, from(#F9F9F9), to(#E3E3E3)); | |
221 | 223 | border-color: #ccc #bbb #aaa; |
222 | 224 | color: #666; |
223 | 225 | font-weight: bold; |
@@ -236,12 +238,12 @@ version: 2.7.0 | ||
236 | 238 | /* Loading |
237 | 239 | --------------------------------------------------------------------------------------*/ |
238 | 240 | .loading { |
239 | - background-image: url( ../images/loading.gif); | |
241 | + background-image: url( loading.gif); | |
240 | 242 | background-position: 50% 50%; |
241 | 243 | background-repeat: no-repeat; |
242 | 244 | } |
243 | 245 | .error { |
244 | - background-image: url( ../images/error.png); | |
246 | + background-image: url( error.png); | |
245 | 247 | background-position: 50% 50%; |
246 | 248 | background-repeat: no-repeat; |
247 | 249 | } |
@@ -6,9 +6,13 @@ | ||
6 | 6 | * version 0.4.1 |
7 | 7 | * |
8 | 8 | */ |
9 | + #entrance, #backyard, #debug { | |
10 | + padding: 20px 10px; | |
11 | + } | |
12 | + | |
9 | 13 | |
10 | 14 | /* View Container |
11 | - --------------------------------------------------------------------------------------*/ | |
15 | + --------------------------------------------------------------------------------------*/ | |
12 | 16 | #editor { |
13 | 17 | display: none; |
14 | 18 | position: absolute; |
@@ -36,18 +40,18 @@ | ||
36 | 40 | overflow: hidden; |
37 | 41 | } |
38 | 42 | #overlay-shadow { |
39 | - background-color: #000; | |
43 | + background: #000; | |
40 | 44 | opacity: 0.5; |
41 | 45 | -moz-opacity: 0.5; |
42 | 46 | -khtml-opacity: 0.5; |
43 | 47 | } |
44 | - .pettanr-ActiveX-Enabled #overlay-shadow { | |
48 | + .pettanr-ActiveX-enabled #overlay-shadow { | |
45 | 49 | filter: alpha(opacity=50); |
46 | 50 | -ms-filter: alpha(opacity=50); |
47 | 51 | } |
48 | 52 | .pettanr-ActiveX-disabled #overlay-shadow { |
49 | - background: transparent url( black-50pct.png) repeat 0 0; | |
50 | - _background: #000; | |
53 | + background: transparent url( black_50pct.png) repeat 0 0; | |
54 | + _background: url( black_50pct.gif) repeat 0 0; | |
51 | 55 | } |
52 | 56 | |
53 | 57 | #overlay-close-button { |
@@ -86,7 +90,107 @@ | ||
86 | 90 | border: 1px outset #ccc; |
87 | 91 | outline: 1px; |
88 | 92 | } |
89 | - | |
93 | + /* Comic Console | |
94 | + --------------------------------------------------------------------------------------*/ | |
95 | + #comic-console-wrapper { | |
96 | + position: absolute; | |
97 | + width: 320px; | |
98 | + height: 300px; | |
99 | + background-color: #fff; | |
100 | + } | |
101 | + #comic-console { | |
102 | + padding: 20px; | |
103 | + } | |
104 | + .comic-console-label { | |
105 | + display: inline-block; | |
106 | + width: 120px; | |
107 | + line-height: 22px; | |
108 | + color: #666; | |
109 | + cursor: pointer; | |
110 | + } | |
111 | + .comic-console-value { | |
112 | + width: 40px; | |
113 | + text-align: right; | |
114 | + } | |
115 | + .comic-console-line { | |
116 | + margin: 10px 0; | |
117 | + padding-bottom: 5px; | |
118 | + border-bottom: 1px solid #ccc; | |
119 | + } | |
120 | + #comic-console-title, | |
121 | + #comic-console-height, | |
122 | + #comic-console-width, | |
123 | + #comic-console-editable, | |
124 | + #comic-console-visible {} | |
125 | + #comic-console-title-value { width: 140px; text-align:left;} | |
126 | + #comic-console-height-value {} | |
127 | + #comic-console-width-value {} | |
128 | + #comic-console-editable-value {} | |
129 | + #comic-console-visible-value {} | |
130 | + | |
131 | + #comic-console-button-container { | |
132 | + margin-top: 20px; | |
133 | + position: relative; | |
134 | + } | |
135 | + | |
136 | + #comic-console-post-button { | |
137 | + width: 100px; | |
138 | + position: absolute; | |
139 | + left: 20px; | |
140 | + top: 0; | |
141 | + } | |
142 | + #comic-console-cancel-button { | |
143 | + width: 100px; | |
144 | + position: absolute; | |
145 | + left: 160px; | |
146 | + top: 0; | |
147 | + } | |
148 | + | |
149 | + /* Upload Console | |
150 | + --------------------------------------------------------------------------------------*/ | |
151 | + #upload-console-wrapper { | |
152 | + position: absolute; | |
153 | + width: 320px; | |
154 | + height: 300px; | |
155 | + background-color: #fff; | |
156 | + } | |
157 | + #upload-console { | |
158 | + padding: 20px; | |
159 | + } | |
160 | + .upload-console-label { | |
161 | + display: inline-block; | |
162 | + width: 120px; | |
163 | + line-height: 22px; | |
164 | + color: #666; | |
165 | + cursor: pointer; | |
166 | + } | |
167 | + .upload-console-value { | |
168 | + width: 40px; | |
169 | + text-align: right; | |
170 | + } | |
171 | + .upload-console-line { | |
172 | + margin: 10px 0; | |
173 | + padding-bottom: 5px; | |
174 | + border-bottom: 1px solid #ccc; | |
175 | + } | |
176 | + #upload-console-button-container { | |
177 | + margin-top: 20px; | |
178 | + position: relative; | |
179 | + height: 40px; | |
180 | + } | |
181 | + | |
182 | + #upload-console-post-button { | |
183 | + width: 100px; | |
184 | + position: absolute; | |
185 | + left: 20px; | |
186 | + top: 0; | |
187 | + } | |
188 | + #upload-console-cancel-button { | |
189 | + width: 100px; | |
190 | + position: absolute; | |
191 | + left: 160px; | |
192 | + top: 0; | |
193 | + } | |
90 | 194 | /*-------------------------------------------------------------------------------------- |
91 | 195 | * |
92 | 196 | * home |
@@ -174,8 +278,8 @@ | ||
174 | 278 | width: 100%; |
175 | 279 | height: 30px; |
176 | 280 | } |
177 | - | |
178 | 281 | |
282 | + | |
179 | 283 | /* MenuBar |
180 | 284 | --------------------------------------------------------------------------------------*/ |
181 | 285 | #menu-bar { |
@@ -315,7 +419,7 @@ | ||
315 | 419 | -ms-filter: alpha(opacity=70); |
316 | 420 | } |
317 | 421 | .pettanr-ActiveX-disabled #whiteGlass-container div { |
318 | - background: transparent url( white-70pct.png) repeat 0 0; | |
422 | + background: transparent url( white_70pct.png) repeat 0 0; | |
319 | 423 | _background: #fff; |
320 | 424 | } |
321 | 425 |
@@ -540,7 +644,7 @@ | ||
540 | 644 | height: 25px; |
541 | 645 | line-height: 25px; |
542 | 646 | float: left; |
543 | - background-image: url('../images/sprite.gif'); | |
647 | + background-image: url('sprite.gif'); | |
544 | 648 | background-repeat: no-repeat; |
545 | 649 | background-position: 0 0; |
546 | 650 | cursor: pointer; |
@@ -692,7 +796,7 @@ | ||
692 | 796 | position: absolute; |
693 | 797 | top: 0; |
694 | 798 | right: 0; |
695 | - background-image: url('../images/sprite.gif'); | |
799 | + background-image: url('sprite.gif'); | |
696 | 800 | background-repeat: no-repeat; |
697 | 801 | background-position: -70px -60px; |
698 | 802 | width: 20px; |
@@ -1059,14 +1163,14 @@ | ||
1059 | 1163 | background-repeat: no-repeat; |
1060 | 1164 | } |
1061 | 1165 | .finder-icon-thumbnail { |
1062 | - background-image: url(sprite.gif); | |
1166 | + background-image: url('sprite.gif'); | |
1063 | 1167 | } |
1064 | 1168 | |
1065 | 1169 | .finder-icon .file-type-folder { |
1066 | 1170 | background-position: 0 -80px; |
1067 | 1171 | } |
1068 | 1172 | .finder-icon .file-type-album { |
1069 | - background-image: url('../images/folder_album.png'); | |
1173 | + background-image: url('folder_album.png'); | |
1070 | 1174 | } |
1071 | 1175 | .finder-icon .file-type-author { |
1072 | 1176 | background-position: -70px -80px; |
@@ -1090,14 +1194,14 @@ | ||
1090 | 1194 | background-position: -70px -290px; |
1091 | 1195 | } |
1092 | 1196 | .has-thumbnail { |
1093 | - background-image: url('../images/folder_album.png'); | |
1197 | + background-image: url('folder_album.png'); | |
1094 | 1198 | } |
1095 | 1199 | /* |
1096 | 1200 | * http://www.iconfinder.com/icondetails/18336/64/folder_image_photo_icon |
1097 | 1201 | * http://www.iconfinder.com/icondetails/27849/48/folder_yellow_icon |
1098 | 1202 | * http://www.iconfinder.com/icondetails/45347/64/cabinet_icon |
1099 | 1203 | * http://www.iconfinder.com/icondetails/3659/64/broken_file_icon |
1100 | - * http://www.iconfinder.com/icondetails/44733/64/address_book_icon | |
1204 | + * http://www.iconfinder.com/icondetails/44733/64/address_book_icon | |
1101 | 1205 | */ |
1102 | 1206 | .finder-icon-filename { |
1103 | 1207 | position: absolute; |
@@ -24,66 +24,72 @@ | ||
24 | 24 | |
25 | 25 | <div id="inner-wrapper" class="base-content-width"> |
26 | 26 | |
27 | - <!-- home --> | |
28 | - <div id="entrance" class="console-page main" style="display:block;"> | |
29 | - <%= yield %> | |
30 | - </div> | |
27 | + <!-- home --> | |
28 | + <div id="entrance" class="console-page main" style="display:block;"> | |
29 | + <%= yield %> | |
30 | + <h3>クイックアクセス</h3> | |
31 | + <p>新しいコミックをつくる</p> | |
32 | + <p><a href="#" onclick="pettanr.view.show('editor');return false;">新しいコマを描く</a></p> | |
33 | + <p><a href="#" onclick="pettanr.comicConsole._quickAccessShow();return false;">コミックの新規作成</a></p> | |
34 | + <p><a href="#" onclick="pettanr.uploadConsole._quickAccessShow();return false;">画像のアップロード</a></p> | |
35 | + <h3>座長からのお知らせ</h3> | |
36 | + <p>メンテナンスについて</p> | |
37 | + </div> | |
31 | 38 | |
32 | - <!-- setting --> | |
33 | - <div id="backyard" class="console-page main"></div> | |
39 | + | |
40 | + <!-- setting --> | |
41 | + <div id="backyard" class="console-page main"></div> | |
34 | 42 | |
35 | - <!-- debug--> | |
36 | - <div id="debug" class="console-page main"> | |
37 | - <h2>Environment</h2> | |
38 | - <dl id="useragent" class="dl-table clearfix"></dl> | |
43 | + <!-- debug--> | |
44 | + <div id="debug" class="console-page main"> | |
45 | + <h2>Environment</h2> | |
46 | + <dl id="useragent" class="dl-table clearfix"></dl> | |
39 | 47 | |
40 | - <h2>Boot console in debug mode</h2> | |
41 | - <dl class="dl-table clearfix"> | |
42 | - <dt>xdomain json</dt> | |
43 | - <dd><a href="work.html?view=2&exjson=false">use same domain json</a></dd> | |
44 | - </dl> | |
45 | - | |
46 | - <h2>Boot editor in debug mode</h2> | |
47 | - <dl class="dl-table clearfix"> | |
48 | - <dt>General Boot</dt> | |
49 | - <dd><a href="work.html?view=editor">Boot Editor</a></dd> | |
50 | - <dt>Reversible Image test</dt> | |
51 | - <dd><a href="work.html?view=editor&rimg=CSS3">Backend is CSS3</a></dd> | |
52 | - <dd><a href="work.html?view=editor&rimg=VML">Backend is VML</a></dd> | |
53 | - <dd><a href="work.html?view=editor&rimg=ActiveX">Backend is ActiveX</a></dd> | |
54 | - <dt>Balloon test</dt> | |
55 | - <dd><a href="work.html?view=editor&vector=false">Vector Disabled</a></dd> | |
56 | - <dt>ActiveX test</dt> | |
57 | - <dd><a href="work.html?ActiveX=true">ActiveX Enabled</a></dd> | |
58 | - <dd><a href="work.html?ActiveX=false">ActiveX Disabled</a></dd> | |
59 | - <dt>Debug mode</dt> | |
60 | - <dd><a href="work.html?debug=true">Debug Enabled</a></dd> | |
61 | - <dd><a href="work.html?debug=false">Debug Disabled</a></dd> | |
62 | - </dl> | |
63 | - | |
64 | - <h2>XML + XSLT pages</h2> | |
65 | - | |
66 | - <dl class="dl-table clearfix"> | |
67 | - <dt>help documents</dt> | |
68 | - <dd><a href="help/jp.xml">jp.xml</a></dd> | |
69 | - <dt>xml test</dt> | |
70 | - <dd><a href="diary/itozyun.xml">itozyn's diary</a></dd> | |
71 | - <dt>other</dt> | |
72 | - <dd><a href="sitemap/sitemap.xml">sitemap.xml</a></dd> | |
73 | - </dl> | |
74 | - </div> | |
75 | - </div> | |
48 | + <h2>Boot console in debug mode</h2> | |
49 | + <dl class="dl-table clearfix"> | |
50 | + <dt>xdomain json</dt> | |
51 | + <dd><a href="work.html?view=2&exjson=false">use same domain json</a></dd> | |
52 | + </dl> | |
76 | 53 | |
77 | - <!-- comic list --> | |
78 | - <div id="cabinet" class="console-page"> | |
79 | - <div id="cabinet-container" class="finder-container"></div> | |
54 | + <h2>Boot editor in debug mode</h2> | |
55 | + <dl class="dl-table clearfix"> | |
56 | + <dt>General Boot</dt> | |
57 | + <dd><a href="work.html?view=editor">Boot Editor</a></dd> | |
58 | + <dt>Reversible Image test</dt> | |
59 | + <dd><a href="work.html?view=editor&rimg=CSS3">Backend is CSS3</a></dd> | |
60 | + <dd><a href="work.html?view=editor&rimg=VML">Backend is VML</a></dd> | |
61 | + <dd><a href="work.html?view=editor&rimg=ActiveX">Backend is ActiveX</a></dd> | |
62 | + <dt>Balloon test</dt> | |
63 | + <dd><a href="work.html?view=editor&vector=false">Vector Disabled</a></dd> | |
64 | + <dt>ActiveX test</dt> | |
65 | + <dd><a href="work.html?ActiveX=true">ActiveX Enabled</a></dd> | |
66 | + <dd><a href="work.html?ActiveX=false">ActiveX Disabled</a></dd> | |
67 | + <dt>Debug mode</dt> | |
68 | + <dd><a href="work.html?debug=true">Debug Enabled</a></dd> | |
69 | + <dd><a href="work.html?debug=false">Debug Disabled</a></dd> | |
70 | + </dl> | |
71 | + | |
72 | + <h2>XML + XSLT pages</h2> | |
73 | + | |
74 | + <dl class="dl-table clearfix"> | |
75 | + <dt>help documents</dt> | |
76 | + <dd><a href="help/jp.xml">jp.xml</a></dd> | |
77 | + <dt>xml test</dt> | |
78 | + <dd><a href="diary/itozyun.xml">itozyn's diary</a></dd> | |
79 | + <dt>other</dt> | |
80 | + <dd><a href="sitemap/sitemap.xml">sitemap.xml</a></dd> | |
81 | + </dl> | |
80 | 82 | </div> |
83 | + </div> | |
81 | 84 | |
82 | - <!-- image list --> | |
83 | - <div id="gallery" class="console-page"></div> | |
84 | - | |
85 | + <!-- comic list --> | |
86 | + <div id="cabinet" class="console-page"> | |
87 | + <div id="cabinet-container" class="finder-container"></div> | |
85 | 88 | </div> |
86 | 89 | |
90 | + <!-- image list --> | |
91 | + <div id="gallery" class="console-page"></div> | |
92 | + | |
87 | 93 | <!-- Editor --> |
88 | 94 | <div id="editor" class="view-container"> |
89 | 95 | <p id="key-event-log" style="margin-top: 5em;"></p> |
@@ -282,22 +288,67 @@ | ||
282 | 288 | <div id="overlay-shadow"></div> |
283 | 289 | |
284 | 290 | <!-- アウトプットコンソール --> |
285 | - <div id="output-console-wrapper"> | |
291 | + <div id="output-console-wrapper" style="display: none;"> | |
286 | 292 | <textarea id="output-area" readonly></textarea> |
287 | 293 | </div> |
288 | 294 | |
289 | 295 | <!-- テキスト エディタ --> |
290 | - <div id="speach-editor-wrapper"> | |
296 | + <div id="speach-editor-wrapper" style="display: none;"> | |
291 | 297 | <textarea id="speach-editor"></textarea> |
292 | 298 | <div id="speach-edit-complete-button" class="button">OK</div> |
293 | 299 | </div> |
294 | 300 | |
295 | 301 | <!-- 画像グループから画像を選択 --> |
296 | - <div id="image-gruop-wrapper"> | |
302 | + <div id="image-gruop-wrapper" style="display: none;"> | |
297 | 303 | <div id="image-icon-container"></div> |
298 | 304 | <div id="gruop-name-display">Group Name</div> |
299 | 305 | <div id="image-gruop-button" class="button">cancel</div> |
300 | 306 | </div> |
307 | + | |
308 | + <!-- 画像のアップロード--> | |
309 | + <div id="upload-console-wrapper" style="display: none;"> | |
310 | + <div id="upload-console-header">Upload Picture</div> | |
311 | + <div id="upload-console"> | |
312 | + <div id="uploader"></div> | |
313 | + <div id="upload-console-button-container"> | |
314 | + <div id="upload-console-post-button" class="button">upload</div> | |
315 | + <div id="upload-console-cancel-button" class="button">cancel</div> | |
316 | + </div> | |
317 | + <div id="upload-console-progress"></div> | |
318 | + </div> | |
319 | + </div> | |
320 | + | |
321 | + <!-- コミックの新規作成・編集・削除 --> | |
322 | + <div id="comic-console-wrapper" style="display: none;"> | |
323 | + <div id="comic-console-header">Create New Comic</div> | |
324 | + <div id="comic-console"> | |
325 | + <div id="comic-console-title" class="comic-console-line"> | |
326 | + <span class="comic-console-label">Title:</span> | |
327 | + <span id="comic-console-title-value" class="comic-console-value editable-value">No Title</span> | |
328 | + </div> | |
329 | + <div id="comic-console-width" class="comic-console-line"> | |
330 | + <span class="comic-console-label">Default Width:</span> | |
331 | + <span id="comic-console-width-value" class="comic-console-value editable-value">300</span> | |
332 | + </div> | |
333 | + <div id="comic-console-height" class="comic-console-line"> | |
334 | + <span class="comic-console-label">Default Height:</span> | |
335 | + <span id="comic-console-height-value" class="comic-console-value editable-value">200</span> | |
336 | + </div> | |
337 | + <div id="comic-console-visible" class="comic-console-line"> | |
338 | + <span class="comic-console-label">Visible:</span> | |
339 | + <span id="comic-console-visible-value" class="comic-console-value editable-value">1</span> | |
340 | + </div> | |
341 | + <div id="comic-console-editable" class="comic-console-line"> | |
342 | + <span class="comic-console-label">Editable:</span> | |
343 | + <span id="comic-console-editable-value" class="comic-console-value editable-value">1</span> | |
344 | + </div> | |
345 | + <div id="comic-console-button-container"> | |
346 | + <div id="comic-console-post-button" class="button">post(update)</div> | |
347 | + <div id="comic-console-cancel-button" class="button">cancel</div> | |
348 | + </div> | |
349 | + <div id="comic-console-progress"></div> | |
350 | + </div> | |
351 | + </div> | |
301 | 352 | |
302 | 353 | <div id="overlay-close-button">x</div> |
303 | 354 | </div> |
@@ -332,6 +383,7 @@ | ||
332 | 383 | </div> |
333 | 384 | |
334 | 385 | </div> |
386 | + | |
335 | 387 | <%= javascript_include_tag "common" %> |
336 | 388 | <%= javascript_include_tag "jquery-162_min" %> |
337 | 389 | <%if current_author %> |
@@ -143,16 +143,24 @@ pettanr.util = ( function(){ | ||
143 | 143 | nodeNoscript = noscript = null; |
144 | 144 | |
145 | 145 | function cleanCommnetNode( _targetElm){ |
146 | - _targetElm = _targetElm || document; | |
147 | - var _nodes = _targetElm.all || _targetElm.getElementsByTagName( '*'), | |
148 | - _array = [], | |
149 | - _elm; | |
150 | - for(var i=0, l = _nodes.length; i<l; ++i){ | |
151 | - _array.push( _nodes[ i]); | |
152 | - } | |
153 | - for( i=0; i<l; ++i){ | |
154 | - _elm = _array[ i]; | |
155 | - _elm.nodeType === 8 && _elm.parentNode && _elm.parentNode.removeChild( _elm); | |
146 | + search( _targetElm || document.body ); | |
147 | + | |
148 | + function search( _elm){ | |
149 | + if( !_elm) return; | |
150 | + if( _elm.nodeType === 8){ | |
151 | + _elm.parentNode.removeChild( _elm); | |
152 | + return; | |
153 | + } | |
154 | + var i, l, _children = _elm.childNodes, _array = []; | |
155 | + if( _children && typeof _children.length === 'number'){ | |
156 | + // liveNode > array | |
157 | + for( i=0, l=_children.length; i<l; ++i){ | |
158 | + _array.push( _children[ i ] ); | |
159 | + } | |
160 | + while( _array.length !== 0 ){ | |
161 | + search( _array.shift()); | |
162 | + } | |
163 | + } | |
156 | 164 | } |
157 | 165 | } |
158 | 166 | return { |
@@ -227,7 +235,9 @@ pettanr.util = ( function(){ | ||
227 | 235 | displayNone = img.style.display === 'none'; |
228 | 236 | if( displayNone === true) img.style.display = ''; |
229 | 237 | IMG_SIZE_GETTER.appendChild( img); |
238 | + | |
230 | 239 | var size = getActualDimension( img); |
240 | + | |
231 | 241 | IMG_SIZE_GETTER.removeChild( img); |
232 | 242 | if( displayNone === true) img.style.display = 'none'; |
233 | 243 | if( nextElm){ |
@@ -268,20 +278,6 @@ pettanr.util = ( function(){ | ||
268 | 278 | run.width = mem.w; // restore |
269 | 279 | run.height = mem.h; |
270 | 280 | } else { // for Opera and Other |
271 | - /* | |
272 | - function fn() { | |
273 | - w = image.width; | |
274 | - h = image.height; | |
275 | - } | |
276 | - mem = { w: image.width, h: image.height }; // keep current style | |
277 | - image.removeAttribute("width"); | |
278 | - image.addEventListener("DOMAttrModified", fn, false); | |
279 | - image.removeAttribute("height"); | |
280 | - // call fn | |
281 | - image.removeEventListener("DOMAttrModified", fn, false); | |
282 | - image.width = mem.w; // restore | |
283 | - image.height = mem.h; | |
284 | - */ | |
285 | 281 | mem = { w: image.width, h: image.height }; // keep current style |
286 | 282 | image.removeAttribute("width"); |
287 | 283 | image.removeAttribute("height"); |
@@ -533,6 +529,36 @@ pettanr.util = ( function(){ | ||
533 | 529 | } |
534 | 530 | } |
535 | 531 | return randomKey; |
532 | + }, | |
533 | + createIframe: function( id, callback){ | |
534 | + var ua = pettanr.ua; | |
535 | + var el = document.createElement( ua.isIE ? '<iframe name="' + id + '" frameborder="0" scrolling="no">' : 'iframe'); | |
536 | + | |
537 | + document.body.appendChild( el); | |
538 | + el.id = el.name = id; | |
539 | + el.setAttribute( 'name', id); | |
540 | + el.style.cssText = 'width:1px;height:1px;visibility:hidden;position:absolute;top:1px;left:1px;'; | |
541 | + // http://d.hatena.ne.jp/onozaty/20070830/p1 | |
542 | + // [JavaScript]IE6ではJavaScriptで動的に作成したiframeに対してsubmitできない(IE7は未確認) ->解決 | |
543 | + el.contentWindow.name = id; | |
544 | + | |
545 | + window[id] = el; | |
546 | + | |
547 | + if( ua.isIE){ | |
548 | + el.onreadystatechange = detect; | |
549 | + } else { | |
550 | + setTimeout( onLoad, 0); | |
551 | + } | |
552 | + function detect(){ | |
553 | + if ( this.readyState == "complete") { | |
554 | + this.onreadystatechange = new Function(); | |
555 | + this.onreadystatechange = null; | |
556 | + onLoad(); | |
557 | + } | |
558 | + } | |
559 | + function onLoad(){ | |
560 | + callback( el); | |
561 | + } | |
536 | 562 | } |
537 | 563 | } |
538 | 564 | })(); |
@@ -586,7 +612,7 @@ pettanr.ua = ( function(){ | ||
586 | 612 | if( pettanr.util.hasClassName( b, ns + disabled) === true) return false; |
587 | 613 | x = document.createElement('div'); |
588 | 614 | b.appendChild(x); |
589 | - x.style.cssText = 'width:1px;height:1px;filter:progid:DXImageTransform.Microsoft.Shadow()'; | |
615 | + x.style.cssText = 'width:1px;height:1px;line-height:1px;filter:progid:DXImageTransform.Microsoft.Shadow()'; | |
590 | 616 | ret = x.offsetHeight > 1; |
591 | 617 | b.removeChild(x); |
592 | 618 | } |
@@ -664,14 +690,17 @@ pettanr.ua = ( function(){ | ||
664 | 690 | pettanr.CONST = ( function(){ |
665 | 691 | var isLocal = pettanr.LOCAL === true || pettanr.URL_PARAMS.exjson === false, |
666 | 692 | isLocalhost = document.location.href.indexOf( 'http:\/\/localhost:3000\/' ) === 0, |
667 | - RETTANR_ROOT_PATH = isLocalhost === true ? 'http:\/\/localhost:3000\/' : 'http:\/\/pettanr.heroku.com\/'; | |
693 | + PETTANR_ROOT_PATH = isLocalhost === true ? 'http:\/\/localhost:3000\/' : 'http:\/\/pettanr.heroku.com\/'; | |
668 | 694 | |
669 | 695 | return { |
670 | - PETTANR_ROOT_PATH: RETTANR_ROOT_PATH, | |
671 | - URL_ORIGINAL_PICTURES_JSON: ( isLocal === true ? 'json\/' : RETTANR_ROOT_PATH) + 'original_pictures.json', | |
672 | - URL_PANELS_JSON: ( isLocal === true ? 'json\/' : RETTANR_ROOT_PATH) + 'panels.json', | |
696 | + PETTANR_ROOT_PATH: PETTANR_ROOT_PATH, | |
697 | + URL_ORIGINAL_PICTURES_JSON: ( isLocal === true ? 'json\/' : PETTANR_ROOT_PATH) + 'original_pictures.json', | |
698 | + URL_PANELS_JSON: ( isLocal === true ? 'json\/' : PETTANR_ROOT_PATH) + 'panels.json', | |
673 | 699 | NS_PETTANR_COMIC: 'pettanr-comic', |
674 | - RESOURCE_PICTURE_PATH: ( isLocal === true ? pettanr.ROOT_PATH : RETTANR_ROOT_PATH) + 'resource_pictures\/' | |
700 | + RESOURCE_PICTURE_PATH: ( isLocal === true ? pettanr.ROOT_PATH : PETTANR_ROOT_PATH) + 'resource_pictures\/', | |
701 | + CREATE_COMIC_JS: ( isLocal === true ? 'js\/' : PETTANR_ROOT_PATH) + 'comics_new.js', | |
702 | + UPLOAD_PICTURE_JS: isLocal === true ? 'js\/upload_picture.js' : PETTANR_ROOT_PATH + 'original_pictures\/new.js', | |
703 | + JQUERY_URL: isLocal === true ? 'javascripts\/jquery-1.6.2.min.js' : PETTANR_ROOT_PATH + 'assets\/jquery-162_min.js' | |
675 | 704 | } |
676 | 705 | })(); |
677 | 706 |
@@ -787,7 +816,7 @@ pettanr.view = ( function(){ | ||
787 | 816 | origin.href = '#'; |
788 | 817 | for(var i=0; i<l; ++i){ |
789 | 818 | item = origin.cloneNode( true); |
790 | - item.innerHTML = items[ i]; | |
819 | + item.appendChild( document.createTextNode( items[ i]) ); | |
791 | 820 | item.onclick = LoginUserNavi.show; |
792 | 821 | navi.appendChild( item); |
793 | 822 | } |
@@ -867,6 +896,16 @@ pettanr.view = ( function(){ | ||
867 | 896 | typeof currentView.onOpen === 'function' && currentView.onOpen(); |
868 | 897 | setTimeout( onWindowResize, 0); |
869 | 898 | } |
899 | + | |
900 | + var AbstractBasicPane = function(){ | |
901 | + this.UID = '', // element の ID と一致 | |
902 | + this.onOpen = function(){}; | |
903 | + this.onClose = function(){}; | |
904 | + this.onPaneResize = function( _w, _h){}; | |
905 | + this.MIN_WIDTH = 0; | |
906 | + this.MIN_HEIGHT = 0; | |
907 | + } | |
908 | + | |
870 | 909 | return { |
871 | 910 | init: function( _funcArray){ |
872 | 911 | funcArray = _funcArray; |
@@ -900,6 +939,13 @@ pettanr.view = ( function(){ | ||
900 | 939 | } |
901 | 940 | alert( _viewID); |
902 | 941 | }, |
942 | + resisterAsBasicPane: function( _basicPane){ | |
943 | + if( pettanr.view.isBasicPaneInstance( _basicPane ) === true ) return; | |
944 | + _basicPane.prototype = new AbstractBasicPane(); | |
945 | + }, | |
946 | + isBasicPaneInstance: function( _basicPane){ | |
947 | + return _basicPane instanceof AbstractBasicPane; | |
948 | + }, | |
903 | 949 | currentID: currentID, |
904 | 950 | HOME: HOME_ID, |
905 | 951 | COMICS: VIEW_ID_ARRAY[ 1], |
@@ -918,221 +964,6 @@ pettanr.overlay = ( function(){ | ||
918 | 964 | visible = false, |
919 | 965 | windowW, windowH; |
920 | 966 | |
921 | - | |
922 | - var IMAGE_GROUP_EXPROLER = ( function(){ | |
923 | - var ICON_ARRAY = [], | |
924 | - WHEEL_DELTA = 64, | |
925 | - containerW, containerH, wrapX, | |
926 | - jqWrap, jqContainer, jqItemOrigin, | |
927 | - itemW, itemH, | |
928 | - jqName, jqButton, buttonW, | |
929 | - folder, onUpdateFunction, | |
930 | - winW, | |
931 | - onEnterInterval = null; | |
932 | - | |
933 | - var BASE_PATH = pettanr.LOCAL === false ? 'http://pettan.heroku.com/images/' : 'images/', | |
934 | - THUMB_PATH = BASE_PATH, // + 'thumbnail/', | |
935 | - LIMIT_FILESIZE = 1024 * 10; // 10KB | |
936 | - var IMAGE_DATA = 0; | |
937 | - | |
938 | - var ImageGroupIconClass = function( INDEX, data){ | |
939 | - var JQ_ICON_WRAP = jqItemOrigin.clone( true), | |
940 | - SRC = [ BASE_PATH, data.id, '.', data.ext].join( ''), | |
941 | - LOW_SRC = data.filesize && data.filesize > LIMIT_FILESIZE ? [ THUMB_PATH, data.id, '.', data.ext].join( '') : null, | |
942 | - reversibleImage = null, | |
943 | - actualW, actualH, | |
944 | - onEnterFlag = false; | |
945 | - JQ_ICON_WRAP.children( 'div').eq( 0).html( data.filesize + 'bytes'); | |
946 | - jqContainer.append( JQ_ICON_WRAP.css( { left: INDEX * itemW})); | |
947 | - | |
948 | - function onLoad( url, _imgW, _imgH){ | |
949 | - if( reversibleImage === null) { | |
950 | - alert( url); | |
951 | - return; | |
952 | - } | |
953 | - actualW = _imgW || 64; | |
954 | - actualH = _imgH || 64; | |
955 | - JQ_ICON_WRAP.children( 'div').eq( 1).html( actualW +'x' +actualH); | |
956 | - var zoom = 128 /( actualW > actualH ? actualW : actualH), | |
957 | - _h = Math.floor( actualH *zoom), | |
958 | - _w = Math.floor( actualW *zoom); | |
959 | - reversibleImage.elm.style.width = _w +'px'; | |
960 | - reversibleImage.elm.style.height = _h +'px'; | |
961 | - reversibleImage.elm.style.margin = Math.floor( itemH /2 -_h /2)+'px 0 0'; | |
962 | - reversibleImage.resize( _w, _h); | |
963 | - JQ_ICON_WRAP.click( onClick); | |
964 | - } | |
965 | - | |
966 | - function onClick( e){ | |
967 | - pettanr.overlay.hide(); | |
968 | - if (onUpdateFunction) { | |
969 | - if( LOW_SRC === null){ | |
970 | - onUpdateFunction( SRC, actualW, actualH); | |
971 | - } else { | |
972 | - onCloseUpdate( onUpdateFunction); // close()で値が消えるので、クロージャに保持 | |
973 | - } | |
974 | - } | |
975 | - close(); | |
976 | - } | |
977 | - | |
978 | - function onCloseUpdate( onUpdate){ | |
979 | - pettanr.util.loadImage( SRC, | |
980 | - function( _abspath, imgW, imgH){ | |
981 | - onUpdate( SRC, imgW, imgH); | |
982 | - onUpdate = null; | |
983 | - }, | |
984 | - function( _abspath){ | |
985 | - onUpdate( SRC, data.width || 64, data.height || 64); | |
986 | - onUpdate = null; | |
987 | - } | |
988 | - ); | |
989 | - } | |
990 | - | |
991 | - return { | |
992 | - onEnter: function(){ | |
993 | - if( onEnterFlag === true) return; | |
994 | - reversibleImage = pettanr.image.createReversibleImage( LOW_SRC || SRC, itemW, itemH, onLoad); | |
995 | - JQ_ICON_WRAP.children( 'img').replaceWith( reversibleImage.elm); | |
996 | - onEnterFlag = true; | |
997 | - }, | |
998 | - destroy: function(){ | |
999 | - reversibleImage && reversibleImage.destroy(); | |
1000 | - JQ_ICON_WRAP.remove(); | |
1001 | - reversibleImage = JQ_ICON_WRAP = null; | |
1002 | - delete this.destroy; | |
1003 | - } | |
1004 | - } | |
1005 | - } | |
1006 | - | |
1007 | - function close(){ | |
1008 | - jqContainer.stop().animate( { | |
1009 | - height: 0, | |
1010 | - top: Math.floor( windowH /2) | |
1011 | - }, function(){ | |
1012 | - jqWrap.hide() | |
1013 | - }); | |
1014 | - while( ICON_ARRAY.length > 0){ | |
1015 | - ICON_ARRAY.shift().destroy(); | |
1016 | - } | |
1017 | - onEnterInterval !== null && window.clearTimeout( onEnterInterval); | |
1018 | - onUpdateFunction = onEnterInterval = null; | |
1019 | - } | |
1020 | - function onEnterShowImage(){ | |
1021 | - var l = ICON_ARRAY.length, | |
1022 | - _start = -wrapX /itemW -1, | |
1023 | - _end = _start + winW /itemW +1; | |
1024 | - for( var i=0; i<l; ++i){ | |
1025 | - _start < i && i < _end && ICON_ARRAY[ i].onEnter(); | |
1026 | - } | |
1027 | - onEnterInterval !== null && window.clearTimeout( onEnterInterval); | |
1028 | - onEnterInterval = null; | |
1029 | - } | |
1030 | - function onCloseClick(){ | |
1031 | - pettanr.overlay.hide(); | |
1032 | - // onUpdateFunction && onUpdateFunction( textElement); | |
1033 | - close(); | |
1034 | - } | |
1035 | - function onMouseWheel( e, delta){ | |
1036 | - if( winW < containerW){ | |
1037 | - wrapX += delta *WHEEL_DELTA; | |
1038 | - wrapX = wrapX > 0 ? 0 : wrapX < winW -containerW ? winW -containerW : wrapX; | |
1039 | - jqContainer.css( { left: wrapX}); | |
1040 | - | |
1041 | - onEnterInterval !== null && window.clearTimeout( onEnterInterval); | |
1042 | - onEnterInterval = window.setTimeout( onEnterShowImage, 500); | |
1043 | - } | |
1044 | - //e.stopPropagation(); | |
1045 | - return false; | |
1046 | - } | |
1047 | - return { | |
1048 | - init: function(){ | |
1049 | - this.jqWrap = jqWrap = $( '#image-gruop-wrapper').hide(); | |
1050 | - jqContainer = $( '#image-icon-container').mousewheel( onMouseWheel); | |
1051 | - containerH = pettanr.util.getElementSize( jqContainer.get( 0)).height; | |
1052 | - jqItemOrigin = $( $( '#imageGruopItemTemplete').remove().html()); | |
1053 | - var itemSize = pettanr.util.getElementSize( jqItemOrigin.get( 0)); | |
1054 | - itemW = itemSize.width; | |
1055 | - itemH = itemSize.height; | |
1056 | - jqName = $( '#gruop-name-display'); | |
1057 | - jqButton = $( '#image-gruop-button').click( onCloseClick); | |
1058 | - buttonW = pettanr.util.getElementSize( jqButton.get( 0)).width; | |
1059 | - | |
1060 | - delete IMAGE_GROUP_EXPROLER.init; | |
1061 | - }, | |
1062 | - jqWrap: null, | |
1063 | - show: function( _folder, _onUpdateFunction){ | |
1064 | - this.init !== undefined && this.init(); | |
1065 | - | |
1066 | - folder = _folder; | |
1067 | - onUpdateFunction = _onUpdateFunction; | |
1068 | - pettanr.overlay.show( this); | |
1069 | - | |
1070 | - var l = _folder.getChildFileLength(); | |
1071 | - for( var i=0; i<l; ++i){ | |
1072 | - ICON_ARRAY.push( new ImageGroupIconClass( i, _folder.getChildFileByIndex( i))); | |
1073 | - } | |
1074 | - wrapX = 0; | |
1075 | - containerW = l * itemW; | |
1076 | - | |
1077 | - winW = windowW; | |
1078 | - var w = winW > containerW ? winW : containerW, | |
1079 | - h = windowH > containerH ? containerH : windowH; | |
1080 | - | |
1081 | - jqWrap.show(); | |
1082 | - jqContainer.css( { | |
1083 | - width: w, | |
1084 | - height: 0, | |
1085 | - left: 0, | |
1086 | - top: Math.floor( windowH /2) | |
1087 | - }).stop().animate( { | |
1088 | - height: h, | |
1089 | - top: Math.floor( windowH /2 -h /2) | |
1090 | - }); | |
1091 | - | |
1092 | - jqButton.css( { | |
1093 | - left: Math.floor( winW /2 -buttonW /2), | |
1094 | - top: Math.floor( windowH /2 +containerH /2 +10) | |
1095 | - }); | |
1096 | - | |
1097 | - onEnterShowImage(); | |
1098 | - }, | |
1099 | - onWindowResize: function( _windowW, _windowH){ | |
1100 | - var w = _windowW > containerW ? _windowW : containerW, | |
1101 | - h = _windowH > containerH ? containerH : _windowH, | |
1102 | - offsetW = Math.floor( _windowW /2 -winW /2); | |
1103 | - winW = _windowW; | |
1104 | - if( offsetW <= 0){ // smaller | |
1105 | - jqContainer.css( { | |
1106 | - left: offsetW, | |
1107 | - width: w | |
1108 | - }).animate( { | |
1109 | - left: 0, | |
1110 | - top: Math.floor( _windowH /2 -h /2) | |
1111 | - }); | |
1112 | - } else { | |
1113 | - jqContainer.css( { // bigger | |
1114 | - left: 0, | |
1115 | - width: w, | |
1116 | - borderLeftWidth: offsetW | |
1117 | - }).animate( { | |
1118 | - top: Math.floor( _windowH /2 -h /2), | |
1119 | - borderLeftWidth: 0 | |
1120 | - }); | |
1121 | - } | |
1122 | - jqButton.css( { | |
1123 | - left: Math.floor( _windowW /2 -buttonW /2), | |
1124 | - top: Math.floor( _windowH /2 +containerH /2 +10) | |
1125 | - }); | |
1126 | - onEnterShowImage(); | |
1127 | - }, | |
1128 | - onClose: close, | |
1129 | - ID: 'imageGroupExproler' | |
1130 | - } | |
1131 | - })(); | |
1132 | - /* | |
1133 | - * | |
1134 | - */ | |
1135 | - | |
1136 | 967 | function close(){ |
1137 | 968 | currentOverlay && currentOverlay.onClose && currentOverlay.onClose(); |
1138 | 969 | pettanr.overlay.hide(); |
@@ -1186,6 +1017,24 @@ pettanr.overlay = ( function(){ | ||
1186 | 1017 | windowH = _windowH; |
1187 | 1018 | // 先にeditorのcanvasを確定する。 |
1188 | 1019 | currentOverlay && currentOverlay.onWindowResize && setTimeout( asyncResize, 0); |
1020 | + }, | |
1021 | + resisterOverlay: function( _basicPane){ | |
1022 | + pettanr.view.resisterAsBasicPane( _basicPane); | |
1023 | + // OverlayAPI | |
1024 | + return { | |
1025 | + show: function( _basicPane ){ | |
1026 | + | |
1027 | + }, | |
1028 | + hide: function( _basciPane ){ | |
1029 | + | |
1030 | + }, | |
1031 | + isCurrent: function( _basicPane ){ | |
1032 | + | |
1033 | + } | |
1034 | + } | |
1035 | + }, | |
1036 | + isOverlay: function( _basicPane ){ | |
1037 | + | |
1189 | 1038 | } |
1190 | 1039 | } |
1191 | 1040 | })(); |
@@ -1434,6 +1283,63 @@ pettanr.form = ( function(){ | ||
1434 | 1283 | } |
1435 | 1284 | } |
1436 | 1285 | |
1286 | + var FileInputClass = function( WRAPPER_ELM, ON_UPDATE_FUNCTION, GROUP_ID, validater, elmFileInput){ | |
1287 | + validater = typeof validater === 'function' ? validater : null; | |
1288 | + | |
1289 | + var elmFilePath = pettanr.util.getElementsByClassName( WRAPPER_ELM, 'file-path')[ 0], | |
1290 | + value, | |
1291 | + index = GROUP_ID ? FORM_GROUP_TABLE[ GROUP_ID].length : -1, | |
1292 | + instance, | |
1293 | + focus = false, | |
1294 | + visible = true, | |
1295 | + enabled = true, | |
1296 | + elmFileInput = WRAPPER_ELM.getElementsByTagName('input')[0] || elmFileInput || document.createElement( 'input'); | |
1297 | + elmFileInput.type = 'file'; | |
1298 | + elmFileInput.style.visivility = 'hidden'; | |
1299 | + | |
1300 | + WRAPPER_ELM.onclick = onClick; | |
1301 | + elmFileInput.onchenge = onChange; | |
1302 | + | |
1303 | + function onClick( e){ | |
1304 | + focus = true; | |
1305 | + start( instance); | |
1306 | + elmFileInput.click(); | |
1307 | + return false; | |
1308 | + } | |
1309 | + | |
1310 | + function onChange(){ | |
1311 | + elmFilePath.innerHTML = elmFileInput.value; | |
1312 | + } | |
1313 | + return { | |
1314 | + init: function(){ | |
1315 | + instance = this; | |
1316 | + delete this.init; | |
1317 | + }, | |
1318 | + start: function(){ | |
1319 | + onClick(); | |
1320 | + }, | |
1321 | + finish: function( keep){ | |
1322 | + focus = false; | |
1323 | + }, | |
1324 | + enabled: function(){ | |
1325 | + return enabled; | |
1326 | + }, | |
1327 | + visible: function( _visible){ | |
1328 | + if( _visible === true){ | |
1329 | + WRAPPER_ELM.style.display = ''; | |
1330 | + visible = true; | |
1331 | + } else | |
1332 | + if( _visible === false){ | |
1333 | + WRAPPER_ELM.style.display = 'none'; | |
1334 | + visible = false; | |
1335 | + } | |
1336 | + return visible; | |
1337 | + }, | |
1338 | + index : index, | |
1339 | + groupID: GROUP_ID | |
1340 | + } | |
1341 | + } | |
1342 | + | |
1437 | 1343 | |
1438 | 1344 | function start( _currentItem){ |
1439 | 1345 | currentItem !== _currentItem && currentItem && currentItem.finish(); |
@@ -1488,6 +1394,15 @@ pettanr.form = ( function(){ | ||
1488 | 1394 | _groupID && FORM_GROUP_TABLE[ _groupID].push( ret); |
1489 | 1395 | return ret; |
1490 | 1396 | }, |
1397 | + createFileInput: function( _elm, _onUpdate, _groupID, _validater, _elmFileInput){ | |
1398 | + if( typeof _groupID === 'string' && !FORM_GROUP_TABLE[ _groupID]){ | |
1399 | + FORM_GROUP_TABLE[ _groupID] = []; | |
1400 | + } | |
1401 | + var ret = FileInputClass( _elm, _onUpdate, _groupID, _validater, _elmFileInput); | |
1402 | + ret.init(); | |
1403 | + _groupID && FORM_GROUP_TABLE[ _groupID].push( ret); | |
1404 | + return ret; | |
1405 | + }, | |
1491 | 1406 | createCheckBox: function(){ |
1492 | 1407 | |
1493 | 1408 | }, |
@@ -94,111 +94,120 @@ pettanr.file = ( function(){ | ||
94 | 94 | |
95 | 95 | |
96 | 96 | |
97 | - var FILE_CONTROLER = ( function(){ | |
98 | - | |
99 | - return { | |
100 | - createTree: function( _rootFileData){ | |
101 | - var _tree = new TreeClass( _rootFileData); | |
102 | - _tree.init(); | |
103 | - TREE_ARRAY.push( _tree); | |
104 | - return _tree; | |
105 | - }, | |
106 | - getFileData: function( UIDorFILEorFILEDATA){ | |
107 | - var _access = FILE_CONTROLER.getFileDataAccess( UIDorFILEorFILEDATA); | |
108 | - return _access !== null ? _access.DATA : null; | |
109 | - }, | |
110 | - getChildren: function( UIDorFILEorFILEDATA){ | |
111 | - var _data = FILE_CONTROLER.getFileData( UIDorFILEorFILEDATA); | |
112 | - return _data !== null ? _data.children || null : null; | |
113 | - }, | |
114 | - getFileDataAccess: function( UIDorFILEorFILEDATA){ | |
115 | - var _uid, _data, _access; | |
116 | - | |
117 | - if( typeof UIDorFILEorFILEDATA === 'number'){ | |
118 | - _data = FILEDATA_RESITER[ UIDorFILEorFILEDATA] || null; | |
119 | - } else | |
120 | - if( UIDorFILEorFILEDATA instanceof FileClass){ | |
121 | - _uid = UIDorFILEorFILEDATA.getUID(); | |
122 | - _data = FILEDATA_RESITER[ _uid] || null; | |
123 | - } else { | |
124 | - _data = UIDorFILEorFILEDATA || null; | |
125 | - } | |
126 | - | |
127 | - if( _data === null || !_data) return null; | |
128 | - for( var i=0, l = FILEDATA_ACCESS.length; i<l; ++i){ | |
129 | - _access = FILEDATA_ACCESS[ i]; | |
130 | - if( _access.DATA === _data) return _access; | |
131 | - } | |
132 | - return null; | |
133 | - }, | |
134 | - getDriver: function( _file){ | |
135 | - var _data = FILE_CONTROLER.getFileData( _file); | |
136 | - return _data !== null && _data.driver ? ( _data.driver || FileDriverBase) : null; | |
137 | - }, | |
138 | - getUID: function ( _filedata){ | |
139 | - var l = FILEDATA_RESITER.length; | |
140 | - for( var i=0; i<l; ++i){ | |
141 | - if( FILEDATA_RESITER[ i] === _filedata) return i; | |
142 | - } | |
143 | - return -1; | |
144 | - }, | |
145 | - getSeqentialFiles: function( _file){ | |
146 | - var _driver = FILE_CONTROLER.getDriver( _file); | |
147 | - if( _driver !== null && typeof _driver.getSeqentialFiles === 'function'){ | |
148 | - _driver.getSeqentialFiles( _file); | |
149 | - } | |
150 | - }, | |
151 | - updateFileAttribute: function( _uid, key, _value, _opt_callback){ | |
152 | - var _data = FILE_CONTROLER.getFileDataAccess( _uid), | |
153 | - _type = _data.TYPE; | |
154 | - | |
155 | - }, | |
156 | - getFileAttribute: function( _uid, KEYorKEYARRAY){ | |
157 | - var _fileData = FILE_CONTROLER.getFileDataAccess( _uid), | |
158 | - _type = _fileData.TYPE; | |
159 | - }, | |
160 | - move: function( _prentUID, _targetfile, _newFolder, _newIndex, _opt_callback){ | |
161 | - var _parentData = FILE_CONTROLER.getFileDataAccess( _prentUID), | |
162 | - _parentType = _parentData.TYPE, | |
163 | - _targetData = FILE_CONTROLER.getFileDataAccess( _targetfile), | |
164 | - _targetType = _targetData.TYPE; | |
165 | - }, | |
166 | - replace: function( _uid, _file, _newIndex){ | |
97 | + var FILE_CONTROLER = { | |
98 | + createTree: function( _rootFileData){ | |
99 | + var _tree = new TreeClass( _rootFileData); | |
100 | + _tree.init(); | |
101 | + TREE_ARRAY.push( _tree); | |
102 | + return _tree; | |
103 | + }, | |
104 | + getFileData: function( UIDorFILEorFILEDATA){ | |
105 | + var _access = FILE_CONTROLER.getFileDataAccess( UIDorFILEorFILEDATA); | |
106 | + return _access !== null ? _access.DATA : null; | |
107 | + }, | |
108 | + getChildren: function( UIDorFILEorFILEDATA){ | |
109 | + var _data = FILE_CONTROLER.getFileData( UIDorFILEorFILEDATA); | |
110 | + return _data !== null ? _data.children || null : null; | |
111 | + }, | |
112 | + getFileDataAccess: function( UIDorFILEorFILEDATA){ | |
113 | + var _uid, _data, _access; | |
114 | + | |
115 | + if( typeof UIDorFILEorFILEDATA === 'number'){ | |
116 | + _data = FILEDATA_RESITER[ UIDorFILEorFILEDATA] || null; | |
117 | + } else | |
118 | + if( UIDorFILEorFILEDATA instanceof FileClass){ | |
119 | + _uid = UIDorFILEorFILEDATA.getUID(); | |
120 | + _data = FILEDATA_RESITER[ _uid] || null; | |
121 | + } else { | |
122 | + _data = UIDorFILEorFILEDATA || null; | |
123 | + } | |
124 | + | |
125 | + if( _data === null || typeof _data !== 'object') return null; | |
126 | + for( var i=0, l = FILEDATA_ACCESS.length; i<l; ++i){ | |
127 | + _access = FILEDATA_ACCESS[ i]; | |
128 | + if( _access.DATA === _data) return _access; | |
129 | + } | |
130 | + return null; | |
131 | + }, | |
132 | + getDriver: function( _file){ | |
133 | + var _data = FILE_CONTROLER.getFileData( _file); | |
134 | + return _data !== null && _data.driver ? _data.driver : FileDriverBase; | |
135 | + }, | |
136 | + getUpdateFlag: function( _file, _bit){ | |
137 | + var _driver = FILE_CONTROLER.getFileData( _file), | |
138 | + _policy; | |
139 | + if( typeof _driver.getUpdatePolicy === 'function'){ | |
140 | + _policy = _driver.getUpdatePolicy( _file ); | |
167 | 141 | |
168 | - }, | |
169 | - addEventListener: function( FILEorNULL, _eventType, _callback){ | |
170 | - var _uid = FILEorNULL instanceof FileClass ? FILEorNULL.getUID() : FILEorNULL; | |
171 | - EVENT_LISTENER_RESISTER.push( new FileEventTicketClass( _uid, _eventType, _callback)); | |
172 | - }, | |
173 | - removeEventListener: function( FILEorNULL, _eventType, _callback){ | |
174 | - var _uid = FILEorNULL instanceof FileClass ? FILEorNULL.getUID() : FILEorNULL, | |
175 | - _ticket; | |
176 | - for(var i=0, l = EVENT_LISTENER_RESISTER.length; i<l; ++i){ | |
177 | - _ticket = EVENT_LISTENER_RESISTER[i]; | |
178 | - if( _ticket.fileUID === _uid && _ticket.eventType === _eventType && _ticket.callBack === _callback){ | |
179 | - EVENT_LISTENER_RESISTER.splice( i, 1); | |
180 | - _ticket.destroy(); | |
181 | - } | |
142 | + } | |
143 | + if( typeof _policy !== 'number') { | |
144 | + _policy = FileDriverBase.getUpdatePolicy( _file ) | |
145 | + } | |
146 | + return _policy % ( _bit * 2) >= _bit; | |
147 | + }, | |
148 | + getUID: function ( _filedata){ | |
149 | + var l = FILEDATA_RESITER.length; | |
150 | + for( var i=0; i<l; ++i){ | |
151 | + if( FILEDATA_RESITER[ i] === _filedata) return i; | |
152 | + } | |
153 | + return -1; | |
154 | + }, | |
155 | + getSeqentialFiles: function( _file){ | |
156 | + var _driver = FILE_CONTROLER.getDriver( _file); | |
157 | + if( _driver !== null && typeof _driver.getSeqentialFiles === 'function'){ | |
158 | + _driver.getSeqentialFiles( _file); | |
159 | + } | |
160 | + }, | |
161 | + updateFileAttribute: function( _uid, key, _value, _opt_callback){ | |
162 | + var _data = FILE_CONTROLER.getFileDataAccess( _uid), | |
163 | + _type = _data.TYPE; | |
164 | + | |
165 | + }, | |
166 | + getFileAttribute: function( _uid, KEYorKEYARRAY){ | |
167 | + var _fileData = FILE_CONTROLER.getFileDataAccess( _uid), | |
168 | + _type = _fileData.TYPE; | |
169 | + }, | |
170 | + move: function( _prentUID, _targetfile, _newFolder, _newIndex, _opt_callback){ | |
171 | + var _parentData = FILE_CONTROLER.getFileDataAccess( _prentUID), | |
172 | + _parentType = _parentData.TYPE, | |
173 | + _targetData = FILE_CONTROLER.getFileDataAccess( _targetfile), | |
174 | + _targetType = _targetData.TYPE; | |
175 | + }, | |
176 | + replace: function( _uid, _file, _newIndex){ | |
177 | + | |
178 | + }, | |
179 | + addEventListener: function( FILEorNULL, _eventType, _callback){ | |
180 | + var _uid = FILEorNULL instanceof FileClass ? FILEorNULL.getUID() : FILEorNULL; | |
181 | + EVENT_LISTENER_RESISTER.push( new FileEventTicketClass( _uid, _eventType, _callback)); | |
182 | + }, | |
183 | + removeEventListener: function( FILEorNULL, _eventType, _callback){ | |
184 | + var _uid = FILEorNULL instanceof FileClass ? FILEorNULL.getUID() : FILEorNULL, | |
185 | + _ticket; | |
186 | + for(var i=0, l = EVENT_LISTENER_RESISTER.length; i<l; ++i){ | |
187 | + _ticket = EVENT_LISTENER_RESISTER[i]; | |
188 | + if( _ticket.fileUID === _uid && _ticket.eventType === _eventType && _ticket.callBack === _callback){ | |
189 | + EVENT_LISTENER_RESISTER.splice( i, 1); | |
190 | + _ticket.destroy(); | |
182 | 191 | } |
183 | - }, | |
184 | - fileEventRellay: function( _targetFile, _targetTree, _event){ | |
185 | - var _uid = _targetTree.getUID(), | |
186 | - _access = TREE_ACCESS_ARRAY[ _uid], | |
187 | - l = TREE_ARRAY.length, | |
188 | - _tree, _currentFile; | |
189 | - _access !== undefined && _access.dispatchFileEvent( _event); | |
190 | - for(var i=0; i<l; ++i){ | |
191 | - if( i !== _uid){ | |
192 | - _tree = TREE_ARRAY[i]; | |
193 | - _currentFile = _tree.getCurrentFile(); | |
194 | - if( FILE_CONTROLER.getFileData( _currentFile) === _access.DATA){ | |
195 | - TREE_ACCESS_ARRAY[ _tree.getUID()].dispatchFileEvent( _event); | |
196 | - } | |
192 | + } | |
193 | + }, | |
194 | + fileEventRellay: function( _targetFile, _targetTree, _event){ | |
195 | + var _uid = _targetTree.getUID(), | |
196 | + _access = TREE_ACCESS_ARRAY[ _uid], | |
197 | + l = TREE_ARRAY.length, | |
198 | + _tree, _currentFile; | |
199 | + _access !== undefined && _access.dispatchFileEvent( _event); | |
200 | + for(var i=0; i<l; ++i){ | |
201 | + if( i !== _uid){ | |
202 | + _tree = TREE_ARRAY[i]; | |
203 | + _currentFile = _tree.getCurrentFile(); | |
204 | + if( FILE_CONTROLER.getFileData( _currentFile) === _access.DATA){ | |
205 | + TREE_ACCESS_ARRAY[ _tree.getUID()].dispatchFileEvent( _event); | |
197 | 206 | } |
198 | 207 | } |
199 | 208 | } |
200 | 209 | } |
201 | - })(); | |
210 | + } | |
202 | 211 | |
203 | 212 | var TreeClass = function( ROOTFILE_DATA){ |
204 | 213 | var UID = TREE_ACCESS_ARRAY.length, |
@@ -321,12 +330,7 @@ pettanr.file = ( function(){ | ||
321 | 330 | if( !data.children){ |
322 | 331 | data.children = []; |
323 | 332 | } |
324 | - var TYPE = data.type, | |
325 | - name = null, | |
326 | - driver = data.driver || FileDriverBase, | |
327 | - thumbnail = null, | |
328 | - uid = FILE_CONTROLER.getUID( data), | |
329 | - CHILDREN = data.children, | |
333 | + var uid = FILE_CONTROLER.getUID( data), | |
330 | 334 | instance = this; |
331 | 335 | |
332 | 336 | if( uid === -1){ |
@@ -336,17 +340,12 @@ pettanr.file = ( function(){ | ||
336 | 340 | |
337 | 341 | FILEDATA_ACCESS.push( |
338 | 342 | { |
339 | - TYPE: TYPE, | |
340 | 343 | DATA: data, |
341 | - destroy: destroy, | |
342 | 344 | updateParent: updateParent, |
343 | 345 | dispatchFileEvent: dispatchEvent |
344 | 346 | } |
345 | 347 | ); |
346 | - function destroy(){ | |
347 | - name = thumbnail = parentFile = data = CHILDREN = driver = null; | |
348 | - | |
349 | - } | |
348 | + | |
350 | 349 | function updateParent( _parent){ |
351 | 350 | parentFile = _parent; |
352 | 351 | } |
@@ -356,32 +355,18 @@ pettanr.file = ( function(){ | ||
356 | 355 | |
357 | 356 | /* grobal Methods */ |
358 | 357 | this.init = function(){ |
359 | - //instance = this; | |
360 | 358 | delete this.init; |
361 | 359 | } |
362 | - this.getType = function(){ | |
363 | - return TYPE; | |
364 | - } | |
365 | - this.getName = function(){ | |
366 | - if( name !== null) return name; | |
367 | - if( typeof driver.getName === 'function'){ | |
368 | - name = driver.getName( instance); | |
369 | - } | |
370 | - return name; | |
371 | - } | |
372 | - this.getThumbnail = function(){ | |
373 | - if( thumbnail !== null) return thumbnail; | |
374 | - if( typeof driver.getThumbnail === 'function'){ | |
375 | - thumbnail = driver.getThumbnail( instance); | |
376 | - } | |
377 | - return thumbnail || null; | |
378 | - } | |
379 | 360 | this.getUID = function(){ |
380 | 361 | return uid; |
381 | 362 | } |
363 | + /* | |
364 | + * ファイル構造は TRON のような ハイパーリンク方式 だが、文脈上の 親ファイルが存在する場合がある. | |
365 | + */ | |
382 | 366 | this.getChildFileByIndex = function( _index){ |
383 | - if( typeof _index !== 'number' || _index < 0 || typeof CHILDREN.length !== 'number' || _index >= CHILDREN.length) return null; | |
384 | - _file = new FileClass( TREE, this, CHILDREN[ _index]); | |
367 | + var _children = FILE_CONTROLER.getChildren( instance ); | |
368 | + if( typeof _index !== 'number' || _index < 0 || typeof _children.length !== 'number' || _index >= _children.length) return null; | |
369 | + var _file = new FileClass( TREE, this, _children[ _index]); | |
385 | 370 | _file.init(); |
386 | 371 | return _file; |
387 | 372 | } |
@@ -392,7 +377,12 @@ pettanr.file = ( function(){ | ||
392 | 377 | TREE.replace( parentFile, UID, _newIndex, opt_callback); |
393 | 378 | } |
394 | 379 | this.destroy = function(){ |
395 | - | |
380 | + var _access = FILE_CONTROLER.getFileDataAccess( instance ); | |
381 | + _index = getChildIndex( FILEDATA_ACCESS, _access ); | |
382 | + if( _index === -1 || _access === null) return; | |
383 | + FILEDATA_ACCESS.splice( _index, 1); | |
384 | + TREE = parentFile = data = null; | |
385 | + delete _access.DATA, _access.updateParent, _access.dispatchFileEvent; | |
396 | 386 | } |
397 | 387 | }; |
398 | 388 | FileClass.prototype = { |
@@ -409,24 +399,73 @@ pettanr.file = ( function(){ | ||
409 | 399 | FILE_CONTROLER.removeEventListener( this, _eventType, _callback); |
410 | 400 | }, |
411 | 401 | getChildFileLength: function(){ |
412 | - var CHILDREN = FILE_CONTROLER.getChildren( this); | |
413 | - return CHILDREN && typeof CHILDREN.length === 'number' ? CHILDREN.length : 0; | |
402 | + var children = FILE_CONTROLER.getChildren( this); | |
403 | + return children !== null && typeof children.length === 'number' ? children.length : 0; | |
414 | 404 | }, |
415 | 405 | getChildFileIndex: function( _FILEorFILEDATA){ |
416 | - var CHILDREN = FILE_CONTROLER.getChildren( this); | |
406 | + var children = FILE_CONTROLER.getChildren( this); | |
417 | 407 | |
418 | - if( !CHILDREN || typeof CHILDREN.length !== 'number') return -1; | |
419 | - var l = CHILDREN.length, | |
408 | + if( children === null || typeof children.length !== 'number') return -1; | |
409 | + var l = children.length, | |
420 | 410 | _fileData = FILE_CONTROLER.getFileData( _FILEorFILEDATA); |
421 | 411 | if( _fileData === null) return -1; |
422 | 412 | for(var i=0; i<l; ++i){ |
423 | - if( CHILDREN[ i] === _fileData) return i; | |
413 | + if( children[ i] === _fileData) return i; | |
424 | 414 | } |
425 | 415 | return -1; |
426 | 416 | }, |
417 | + getName: function(){ | |
418 | + var driver = FILE_CONTROLER.getDriver( this ); | |
419 | + if( typeof driver.getName === 'function'){ | |
420 | + return driver.getName( this ); | |
421 | + } | |
422 | + return FileDriverBase.getName( this); | |
423 | + }, | |
424 | + getThumbnail: function(){ | |
425 | + var driver = FILE_CONTROLER.getDriver( this); | |
426 | + if( typeof driver.getThumbnail === 'function'){ | |
427 | + return driver.getThumbnail( this); | |
428 | + } | |
429 | + return FileDriverBase.getThumbnail( this); | |
430 | + }, | |
431 | + getType: function(){ | |
432 | + var _data = FILE_CONTROLER.getFileData( this); | |
433 | + return typeof _data.type === 'number' ? _data.type : pettanr.file.FILE_TYPE.UNKNOWN; | |
434 | + }, | |
427 | 435 | getState: function(){ |
428 | 436 | var _data = FILE_CONTROLER.getFileData( this); |
429 | - return _data.state !== undefined ? _data.state : pettanr.file.FILE_STATE.OK; | |
437 | + return typeof _data.state === 'number' ? _data.state : pettanr.file.FILE_STATE.OK; | |
438 | + }, | |
439 | + isWritable: function(){ | |
440 | + return FILE_CONTROLER.getUpdateFlag( this, pettanr.file.FILE_UPDATE_POLICY.WRITE); | |
441 | + }, | |
442 | + isSortable: function(){ | |
443 | + return FILE_CONTROLER.getUpdateFlag( this, pettanr.file.FILE_UPDATE_POLICY.SORT); | |
444 | + }, | |
445 | + isCreatable: function(){ | |
446 | + return FILE_CONTROLER.getUpdateFlag( this, pettanr.file.FILE_UPDATE_POLICY.CREATE); | |
447 | + }, | |
448 | + isRenamable: function(){ | |
449 | + return FILE_CONTROLER.getUpdateFlag( this, pettanr.file.FILE_UPDATE_POLICY.RENAME); | |
450 | + }, | |
451 | + read: function(){ | |
452 | + // simpleDeepCopy | |
453 | + return false; | |
454 | + }, | |
455 | + write: function( _newName, _newData){ | |
456 | + return false; | |
457 | + }, | |
458 | + create: function(){ | |
459 | + | |
460 | + }, | |
461 | + sort: function(){ | |
462 | + | |
463 | + }, | |
464 | + onCopy: function(){ | |
465 | + | |
466 | + }, | |
467 | + onDelete: function(){ | |
468 | + | |
430 | 469 | } |
431 | 470 | } |
432 | 471 |
@@ -470,14 +509,9 @@ pettanr.file = ( function(){ | ||
470 | 509 | className: ' file-type-' + _className |
471 | 510 | } |
472 | 511 | }, |
473 | - isWritable: function( _file){ | |
474 | - return false; | |
475 | - }, | |
476 | - isSortable: function( _file){ | |
477 | - return false; | |
478 | - }, | |
479 | - isCreatable: function( _file){ | |
480 | - return false; | |
512 | + getUpdatePolicy: function( _file){ | |
513 | + // debug用 全てのメニューを許可 | |
514 | + return pettanr.file.FILE_UPDATE_POLICY.SRWC; | |
481 | 515 | }, |
482 | 516 | read: function(){ |
483 | 517 | return false; |
@@ -555,6 +589,7 @@ pettanr.file = ( function(){ | ||
555 | 589 | return _file instanceof FileClass; |
556 | 590 | }, |
557 | 591 | FILE_TYPE: { |
592 | + UNKNOWN: 0, | |
558 | 593 | FOLDER: FILE_TYPE_IS_FOLDER, |
559 | 594 | IMAGE: createFileTypeID(), |
560 | 595 | TEXT: createFileTypeID(), |
@@ -570,6 +605,28 @@ pettanr.file = ( function(){ | ||
570 | 605 | ERROR: 3, |
571 | 606 | BROKEN: 4 |
572 | 607 | }, |
608 | + FILE_UPDATE_POLICY: { | |
609 | + ____: parseInt( '0000', 2), | |
610 | + ___C: parseInt( '0001', 2), // hasCreateMenu | |
611 | + __W_: parseInt( '0010', 2), // isWritable | |
612 | + __WC: parseInt( '0011', 2), // isWritable | |
613 | + _R__: parseInt( '0000', 2), // isRenamable | |
614 | + _R_C: parseInt( '0101', 2), // hasCreateMenu | |
615 | + _RW_: parseInt( '0110', 2), // isWritable | |
616 | + _RWC: parseInt( '0111', 2), // isWritable | |
617 | + S___: parseInt( '1000', 2), // childrenIsSortable | |
618 | + S__C: parseInt( '1001', 2), | |
619 | + S_W_: parseInt( '1010', 2), | |
620 | + S_WC: parseInt( '1011', 2), | |
621 | + SR__: parseInt( '1000', 2), | |
622 | + SR_C: parseInt( '1101', 2), | |
623 | + SRW_: parseInt( '1110', 2), | |
624 | + SRWC: parseInt( '1111', 2), | |
625 | + CREATE: 1, | |
626 | + WRAITE: 2, | |
627 | + RENAME: 4, | |
628 | + SORT: 8 | |
629 | + }, | |
573 | 630 | TREE_EVENT: { |
574 | 631 | UPDATE: 'onTreeUpdate' |
575 | 632 | }, |
@@ -880,10 +937,10 @@ pettanr.driver = ( function(){ | ||
880 | 937 | return [ _data.t, ':', _data.comic.name || _data.comic.title ].join( ''); |
881 | 938 | } else |
882 | 939 | if( _type === pettanr.driver.FILE_TYPE.ARTIST){ |
883 | - return _data.name + '先生'; | |
884 | - } else | |
940 | + return [ _data.id , ':', _data.name, '画伯' ].join( ''); | |
941 | + } else | |
885 | 942 | if( _type === pettanr.driver.FILE_TYPE.AUTHOR){ |
886 | - return _data.name + '先生'; | |
943 | + return [ _data.id , ':', _data.name, '先生' ].join( ''); | |
887 | 944 | } |
888 | 945 | return _data.name || _data.title; |
889 | 946 | }, |
@@ -1048,9 +1105,10 @@ pettanr.driver = ( function(){ | ||
1048 | 1105 | if( _parent === FILE_DATA_COMIC_ROOT){ |
1049 | 1106 | if( _data.comic && _data.author){ |
1050 | 1107 | var _comic = getFolderData( _data, 'comic', FILE_DATA_COMIC_ROOT), |
1051 | - _comics = getFolderData( _data, 'author', FILE_DATA_AUTHOR_ROOT).children; | |
1108 | + _comicList = getFolderData( _data, 'author', FILE_DATA_AUTHOR_ROOT); | |
1052 | 1109 | _comic.children.push( _data); |
1053 | - pettanr.util.getIndex( _comics, _comic) === -1 && _comics.push( _comic); | |
1110 | + pettanr.util.getIndex( _comicList.children, _comic) === -1 && _comicList.children.push( _comic); | |
1111 | + _comicList.id === MyAuthorID && pettanr.util.getIndex( FILE_DATA_MY_COMICS_ROOT.children, _comic) === -1 && FILE_DATA_MY_COMICS_ROOT.children.push( _comic); | |
1054 | 1112 | } |
1055 | 1113 | // picture data をファイルに取り出し |
1056 | 1114 | var _elements = _data.panel_elements || [], |
@@ -1066,7 +1124,11 @@ pettanr.driver = ( function(){ | ||
1066 | 1124 | } |
1067 | 1125 | } else |
1068 | 1126 | if( _parent === FILE_DATA_PICTURE_ROOT){ |
1069 | - _data.artist && getFolderData( _data, 'artist', FILE_DATA_ARTIST_ROOT).children.push( _data); | |
1127 | + if( _data.artist){ | |
1128 | + var _pictureList = getFolderData( _data, 'artist', FILE_DATA_ARTIST_ROOT); | |
1129 | + pettanr.util.getIndex( _pictureList.children, _data) === -1 && _pictureList.children.push( _data); | |
1130 | + _pictureList.id === MyArtistID && pettanr.util.getIndex( FILE_DATA_MY_PICTURES_ROOT.children, _data) === -1 && FILE_DATA_MY_PICTURES_ROOT.children.push( _data); | |
1131 | + } | |
1070 | 1132 | } |
1071 | 1133 | |
1072 | 1134 | return _data; |
@@ -1092,7 +1154,7 @@ pettanr.driver = ( function(){ | ||
1092 | 1154 | } |
1093 | 1155 | return _data[ _key ] = __data;// このタイミングで参照が切れるので注意!! |
1094 | 1156 | } |
1095 | - | |
1157 | + // 以下は folder がなく 新規に作られる場合. | |
1096 | 1158 | _ret = _array[ _id ] = _data[ _key ]; |
1097 | 1159 | if( _ret.title){ |
1098 | 1160 | _ret.name = _ret.title; |
@@ -1103,11 +1165,9 @@ pettanr.driver = ( function(){ | ||
1103 | 1165 | |
1104 | 1166 | if( _parentData === FILE_DATA_AUTHOR_ROOT){ |
1105 | 1167 | _ret.type = pettanr.driver.FILE_TYPE.AUTHOR; |
1106 | - _id === MyAuthorID && FILE_DATA_MY_COMICS_ROOT.children.push( _ret); | |
1107 | 1168 | } else |
1108 | 1169 | if( _parentData === FILE_DATA_ARTIST_ROOT){ |
1109 | 1170 | _ret.type = pettanr.driver.FILE_TYPE.ARTIST; |
1110 | - _id === MyArtistID && FILE_DATA_MY_PICTURES_ROOT.children.push( _ret); | |
1111 | 1171 | } else |
1112 | 1172 | if( _parentData === FILE_DATA_COMIC_ROOT){ |
1113 | 1173 | _ret.type = pettanr.driver.FILE_TYPE.COMIC; |
@@ -1131,8 +1191,12 @@ pettanr.driver = ( function(){ | ||
1131 | 1191 | createServiceTree: function(){ |
1132 | 1192 | return pettanr.file.createTree( FILE_DATA_SERVICE_ROOT); |
1133 | 1193 | }, |
1134 | - isPettanrFile: function( _file){ | |
1135 | - | |
1194 | + isPettanrFileInstance: function( _file){ | |
1195 | + if( pettanr.file.isPettanFileInstance( _file) === true){ | |
1196 | + var _data = FileAPI.getFileData( _file); | |
1197 | + return _data !== null && _data.driver === Driver; | |
1198 | + } | |
1199 | + return false; | |
1136 | 1200 | }, |
1137 | 1201 | FILE_TYPE: { |
1138 | 1202 | COMIC: FileAPI.createFileTypeID(), |
@@ -1212,7 +1276,11 @@ pettanr.fn( pettanr.view); | ||
1212 | 1276 | pettanr.fn( pettanr.overlay); |
1213 | 1277 | pettanr.fn( pettanr.key); |
1214 | 1278 | pettanr.fn( pettanr.balloon); |
1279 | + | |
1215 | 1280 | pettanr.fn( pettanr.editor); |
1281 | +pettanr.fn( pettanr.comicConsole); | |
1282 | +pettanr.fn( pettanr.uploadConsole); | |
1283 | + | |
1216 | 1284 | pettanr.fn( pettanr.file); |
1217 | 1285 | pettanr.fn( pettanr.finder); |
1218 | 1286 | pettanr.fn( pettanr.gallery); |
@@ -3482,3 +3482,314 @@ pettanr.editor = ( function(){ | ||
3482 | 3482 | MIN_HEIGHT: 320 |
3483 | 3483 | } |
3484 | 3484 | })(); |
3485 | + | |
3486 | +// create hidden iframe | |
3487 | +// write script | |
3488 | +// setInterval | |
3489 | +pettanr.proxy = ( function(){ | |
3490 | + | |
3491 | + function FormProxy( formJsUrl, callback){ | |
3492 | + var timer = null, | |
3493 | + iWin, idoc; | |
3494 | + | |
3495 | + pettanr.util.createIframe( 'id00000', onCreateIframe); | |
3496 | + | |
3497 | + function onCreateIframe( _iframe){ | |
3498 | + iWin = _iframe.contentWindow; | |
3499 | + idoc = _iframe.contentWindow.document; | |
3500 | + | |
3501 | + idoc.open(); | |
3502 | + idoc.write( '<body>'); | |
3503 | + idoc.writeln( '<script type="text\/javascript" src="' + pettanr.CONST.JQUERY_URL+ '"><\/script>'); | |
3504 | + idoc.close(); | |
3505 | + | |
3506 | + timer = window.setInterval( detect, 250 ); | |
3507 | + } | |
3508 | + function detect(){ | |
3509 | + if( iWin.jQuery){ | |
3510 | + window.clearInterval( timer ); | |
3511 | + //callback( idoc); | |
3512 | + iWin.jQuery( iWin).ready( onJQueryReady ); | |
3513 | + } | |
3514 | + } | |
3515 | + function onJQueryReady(){ | |
3516 | + callback( idoc); | |
3517 | + } | |
3518 | + } | |
3519 | + | |
3520 | + return { | |
3521 | + createFormProxy: function( _formJsUrl, _callback){ | |
3522 | + new FormProxy( _formJsUrl, _callback); | |
3523 | + } | |
3524 | + } | |
3525 | + | |
3526 | +})(); | |
3527 | + | |
3528 | + | |
3529 | +pettanr.comicConsole = ( function(){ | |
3530 | + var COMIC_CONSOLE = ( function(){ | |
3531 | + var jqWrap, | |
3532 | + ID = 'comicConsole', | |
3533 | + elmProgress = document.getElementById( 'comic-console-progress'), | |
3534 | + inputTitle, inputW, inputH, inputVisible, inputEditable, | |
3535 | + elmUploader = null; | |
3536 | + //pettanr.key.addKeyDownEvent( ID, 69, false, false, clickOK); | |
3537 | + | |
3538 | + function clickOK(){ | |
3539 | + // clickCancel(); | |
3540 | + // pettanr.proxy.createFormProxy( pettanr.CONST.UPLOAD_PICTURE_JS, onCreateForm); | |
3541 | + elmProgress.innerHTML = '■'; | |
3542 | + // set values | |
3543 | + // submit | |
3544 | + } | |
3545 | + function onCreateForm( iDocument){ | |
3546 | + var div = iDocument.createElement( 'div'); | |
3547 | + div.id = "uploader"; | |
3548 | + iDocument.body.appendChild( div); | |
3549 | + | |
3550 | + var script = iDocument.createElement( 'script'); | |
3551 | + script.type = 'text\/javascript'; | |
3552 | + script.src = pettanr.CONST.UPLOAD_PICTURE_JS; | |
3553 | + iDocument.body.appendChild( script); | |
3554 | + | |
3555 | + elmProgress.innerHTML = '■■'; | |
3556 | + | |
3557 | + var form = iDocument.forms[ 0 ]; | |
3558 | + | |
3559 | + } | |
3560 | + | |
3561 | + function clickCancel(){ | |
3562 | + pettanr.overlay.hide(); | |
3563 | + COMIC_CONSOLE.onClose(); | |
3564 | + } | |
3565 | + | |
3566 | + return { | |
3567 | + init: function(){ | |
3568 | + this.jqWrap = jqWrap = $( '#comic-console-wrapper').hide(); | |
3569 | + $( '#comic-console-post-button').click( clickOK ); | |
3570 | + $( '#comic-console-cancel-button').click( clickCancel ); | |
3571 | + | |
3572 | + var CREATER = pettanr.form.createInputText;//pettanr.key.createEditableText; | |
3573 | + inputTitle = CREATER( document.getElementById( 'comic-console-title'), null, ID); | |
3574 | + inputW = CREATER( document.getElementById( 'comic-console-width'), null, ID); | |
3575 | + inputH = CREATER( document.getElementById( 'comic-console-height'), null, ID); | |
3576 | + inputVisible = CREATER( document.getElementById( 'comic-console-visible'), null, ID); | |
3577 | + inputEditable = CREATER( document.getElementById( 'comic-console-editable'), null, ID); | |
3578 | + | |
3579 | + delete COMIC_CONSOLE.init; | |
3580 | + }, | |
3581 | + jqWrap: null, | |
3582 | + show: function( w, h){ | |
3583 | + jqWrap.show(); | |
3584 | + | |
3585 | + pettanr.overlay.show( COMIC_CONSOLE ); | |
3586 | + | |
3587 | + inputTitle.start(); | |
3588 | + COMIC_CONSOLE.onWindowResize( w, h); | |
3589 | + }, | |
3590 | + onWindowResize: function( _windowW, _windowH){ | |
3591 | + jqWrap.css( | |
3592 | + { | |
3593 | + left: Math.floor( ( _windowW -jqWrap.width()) /2), | |
3594 | + top: Math.floor( ( _windowH -jqWrap.height()) /2) | |
3595 | + } | |
3596 | + ); | |
3597 | + }, | |
3598 | + onClose: function(){ | |
3599 | + jqWrap.hide(); | |
3600 | + }, | |
3601 | + ID: ID | |
3602 | + } | |
3603 | + })(); | |
3604 | + | |
3605 | + return { | |
3606 | + init: function(){ | |
3607 | + COMIC_CONSOLE.init(); | |
3608 | + delete pettanr.comicConsole.init; | |
3609 | + }, | |
3610 | + onOpen: function( _file){ | |
3611 | + if( pettanr.driver.isPettanrFileInstance( _file ) === true && _file.getType() === pettanr.driver.FILE_TYPE.COMIC){ | |
3612 | + // _data = _file.read(); | |
3613 | + } | |
3614 | + }, | |
3615 | + onClose: function(){ | |
3616 | + | |
3617 | + }, | |
3618 | + onWindowResize: function( _windowW, _windowH){ | |
3619 | + }, | |
3620 | + _quickAccessShow: function(){ | |
3621 | + jqWindow = pettanr.jqWindow(); | |
3622 | + var w = jqWindow.width(), | |
3623 | + h = jqWindow.height(); | |
3624 | + COMIC_CONSOLE.show( w, h); | |
3625 | + } | |
3626 | + } | |
3627 | +})(); | |
3628 | + | |
3629 | +pettanr.uploadConsole = ( function(){ | |
3630 | + var UPLOAD_CONSOLE = ( function(){ | |
3631 | + var jqWrap, | |
3632 | + ID = 'uploadConsole', | |
3633 | + TARGET_FRAME_NAME = 'targetFrame', | |
3634 | + elmContainer = document.getElementById( 'uploader'), | |
3635 | + elmProgress = document.getElementById( 'upload-console-progress'), | |
3636 | + timer = null, | |
3637 | + elmForm = null, | |
3638 | + elmFile = null, | |
3639 | + elmIframe = null, | |
3640 | + isUploading = false; | |
3641 | + /* | |
3642 | + * upload ボタンが押されたらまず iframe をつくる. | |
3643 | + */ | |
3644 | + function clickOK(){ | |
3645 | + if( !elmForm || elmFile.value.length === 0) return false; | |
3646 | + pettanr.util.createIframe( TARGET_FRAME_NAME, onCreateIframe); | |
3647 | + elmProgress.innerHTML = 'uploading.'; | |
3648 | + isUploading = true; | |
3649 | + return false; | |
3650 | + } | |
3651 | + /* | |
3652 | + * form の target に iframe を指定したのち submit(); | |
3653 | + */ | |
3654 | + function onCreateIframe( iframe ){ | |
3655 | + elmContainer.appendChild( iframe ); | |
3656 | + elmForm.target = iframe.name; | |
3657 | + | |
3658 | + try { | |
3659 | + elmForm.submit(); | |
3660 | + } catch( e){ | |
3661 | + elmProgress.innerHTML = 'submit() err..'; | |
3662 | + isUploading = false; | |
3663 | + setTimeout( clickCancel , 3000); | |
3664 | + return; | |
3665 | + } | |
3666 | + | |
3667 | + if( pettanr.ua.isIE){ | |
3668 | + iframe.onreadystatechange = detectIframe; | |
3669 | + } else { | |
3670 | + iframe.onload = onIframeUpdate; | |
3671 | + } | |
3672 | + elmIframe = iframe; | |
3673 | + elmProgress.innerHTML = 'uploading..'; | |
3674 | + } | |
3675 | + /* | |
3676 | + * ie の 場合、readyState をチェック. | |
3677 | + */ | |
3678 | + function detectIframe(){ | |
3679 | + if ( elmIframe.readyState === 'complete') { | |
3680 | + elmIframe.onreadystatechange = new Function(); | |
3681 | + elmIframe.onreadystatechange = null; | |
3682 | + onIframeUpdate(); | |
3683 | + } | |
3684 | + } | |
3685 | + function onIframeUpdate(){ | |
3686 | + elmIframe.onload = null; | |
3687 | + ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow ).close(); | |
3688 | + elmIframe = null; | |
3689 | + elmProgress.innerHTML = 'success!'; | |
3690 | + setTimeout( clickCancel , 1000); | |
3691 | + isUploading = false; | |
3692 | + } | |
3693 | + | |
3694 | + function detectForm(){ | |
3695 | + elmForm = elmContainer.getElementsByTagName( 'form')[ 0 ]; | |
3696 | + if( elmForm){ | |
3697 | + var _inputList = elmForm.getElementsByTagName( 'input'), | |
3698 | + _input; | |
3699 | + for( var i=0, l= _inputList.length; i<l; ++i){ | |
3700 | + _input = _inputList[ i ]; | |
3701 | + if( _input.type === 'file'){ | |
3702 | + elmFile = _input; | |
3703 | + } | |
3704 | + if( _input.type === 'submit'){ | |
3705 | + _input.style.display = 'none'; | |
3706 | + } | |
3707 | + } | |
3708 | + window.clearInterval( timer); | |
3709 | + timer = null; | |
3710 | + } | |
3711 | + } | |
3712 | + /* | |
3713 | + * | |
3714 | + */ | |
3715 | + function clickCancel(){ | |
3716 | + if( isUploading === true) return false; | |
3717 | + pettanr.overlay.hide(); | |
3718 | + UPLOAD_CONSOLE.onClose(); | |
3719 | + return false; | |
3720 | + } | |
3721 | + | |
3722 | + return { | |
3723 | + init: function(){ | |
3724 | + this.jqWrap = jqWrap = $( '#upload-console-wrapper').hide(); | |
3725 | + $( '#upload-console-post-button').click( clickOK ); | |
3726 | + $( '#upload-console-cancel-button').click( clickCancel ); | |
3727 | + | |
3728 | + delete UPLOAD_CONSOLE.init; | |
3729 | + }, | |
3730 | + jqWrap: null, | |
3731 | + show: function( w, h){ | |
3732 | + jqWrap.show(); | |
3733 | + | |
3734 | + pettanr.overlay.show( UPLOAD_CONSOLE ); | |
3735 | + | |
3736 | + var script = document.createElement( 'script'); | |
3737 | + script.type = 'text\/javascript'; | |
3738 | + script.src = pettanr.CONST.UPLOAD_PICTURE_JS; | |
3739 | + elmContainer.appendChild( script); | |
3740 | + | |
3741 | + if( timer === null){ | |
3742 | + timer = window.setInterval( detectForm, 250); | |
3743 | + } | |
3744 | + | |
3745 | + elmProgress.innerHTML = ''; | |
3746 | + | |
3747 | + //inputFile.start(); | |
3748 | + UPLOAD_CONSOLE.onWindowResize( w, h); | |
3749 | + }, | |
3750 | + onWindowResize: function( _windowW, _windowH){ | |
3751 | + jqWrap.css( | |
3752 | + { | |
3753 | + left: Math.floor( ( _windowW -jqWrap.width()) /2), | |
3754 | + top: Math.floor( ( _windowH -jqWrap.height()) /2) | |
3755 | + } | |
3756 | + ); | |
3757 | + }, | |
3758 | + onClose: function(){ | |
3759 | + elmForm !== null && $( elmContainer.children ).remove(); | |
3760 | + elmForm = elmFile = null; | |
3761 | + isUploading = false; | |
3762 | + | |
3763 | + if( timer !== null){ | |
3764 | + window.clearInterval( timer); | |
3765 | + timer = null; | |
3766 | + } | |
3767 | + jqWrap.hide(); | |
3768 | + }, | |
3769 | + ID: ID | |
3770 | + } | |
3771 | + })(); | |
3772 | + | |
3773 | + return { | |
3774 | + init: function(){ | |
3775 | + UPLOAD_CONSOLE.init(); | |
3776 | + delete pettanr.comicConsole.init; | |
3777 | + }, | |
3778 | + onOpen: function( _file){ | |
3779 | + if( pettanr.driver.isPettanrFileInstance( _file ) === true && _file.getType() === pettanr.driver.FILE_TYPE.COMIC){ | |
3780 | + // _data = _file.read(); | |
3781 | + } | |
3782 | + }, | |
3783 | + onClose: function(){ | |
3784 | + | |
3785 | + }, | |
3786 | + onWindowResize: function( _windowW, _windowH){ | |
3787 | + }, | |
3788 | + _quickAccessShow: function(){ | |
3789 | + jqWindow = pettanr.jqWindow(); | |
3790 | + var w = jqWindow.width(), | |
3791 | + h = jqWindow.height(); | |
3792 | + UPLOAD_CONSOLE.show( w, h); | |
3793 | + } | |
3794 | + } | |
3795 | +})(); | |
\ No newline at end of file |