OSDN Git Service

- Android mode fix.
[feedblog/feedgenerator.git] / erbtemp / editentry.html.erb
1 <html>
2     <head>
3         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
4         <title><%= APPTITLE %></title>
5         <link rel="stylesheet" href="./erbtemp/stylesheet.css" type="text/css">
6         <% unless cgi.user_agent =~ /(iPod|iPhone|iPad|Android)/ %>
7         <link rel="stylesheet" type="text/css" href="./yui/build/menu/assets/skins/sam/menu.css" />
8         <link rel="stylesheet" type="text/css" href="./yui/build/button/assets/skins/sam/button.css" />
9         <link rel="stylesheet" type="text/css" href="./yui/build/fonts/fonts-min.css" />
10         <link rel="stylesheet" type="text/css" href="./yui/build/container/assets/skins/sam/container.css" />
11         <link rel="stylesheet" type="text/css" href="./yui/build/editor/assets/skins/sam/editor.css" />
12         <script type="text/javascript" src="./yui/build/yahoo-dom-event/yahoo-dom-event.js">
13         </script>
14         <script type="text/javascript" src="./yui/build/animation/animation-min.js">
15         </script>
16         <script type="text/javascript" src="./yui/build/element/element-min.js">
17         </script>
18         <script type="text/javascript" src="./yui/build/container/container-min.js">
19         </script>
20         <script type="text/javascript" src="./yui/build/menu/menu-min.js">
21         </script>
22         <script type="text/javascript" src="./yui/build/button/button-min.js">
23         </script>
24         <script type="text/javascript" src="./yui/build/editor/editor-min.js">
25         </script>
26         <script>
27             (function(){
28                 var Dom = YAHOO.util.Dom, Event = YAHOO.util.Event;
29                 
30                 var myConfig = {
31                     height: '350px',
32                     width: '100%',
33                     animate: true,
34                     dompath: true,
35                     focusAtStart: true,
36                     handleSubmit: true
37                 };
38                 
39                 var state = 'off';
40                 YAHOO.log('Set state to off..', 'info', 'example');
41                 
42                 YAHOO.log('Create the Editor..', 'info', 'example');
43                 var myEditor = new YAHOO.widget.Editor('contenteditor', myConfig);
44                 myEditor.on('toolbarLoaded', function(){
45                     var codeConfig = {
46                         type: 'push',
47                         label: 'Edit HTML Code',
48                         value: 'editcode'
49                     };
50                     YAHOO.log('Create the (editcode) Button', 'info', 'example');
51                     this.toolbar.addButtonToGroup(codeConfig, 'insertitem');
52                     
53                     this.toolbar.on('editcodeClick', function(){
54                         var ta = this.get('element'), iframe = this.get('iframe').get('element');
55                         
56                         if (state == 'on') {
57                             state = 'off';
58                             this.toolbar.set('disabled', false);
59                             YAHOO.log('Show the Editor', 'info', 'example');
60                             YAHOO.log('Inject the HTML from the textarea into the editor', 'info', 'example');
61                             this.setEditorHTML(ta.value);
62                             if (!this.browser.ie) {
63                                 this._setDesignMode('on');
64                             }
65                             
66                             Dom.removeClass(iframe, 'editor-hidden');
67                             Dom.addClass(ta, 'editor-hidden');
68                             this.show();
69                             this._focusWindow();
70                         }
71                         else {
72                             state = 'on';
73                             YAHOO.log('Show the Code Editor', 'info', 'example');
74                             this.cleanHTML();
75                             YAHOO.log('Save the Editors HTML', 'info', 'example');
76                             Dom.addClass(iframe, 'editor-hidden');
77                             Dom.removeClass(ta, 'editor-hidden');
78                             this.toolbar.set('disabled', true);
79                             this.toolbar.getButtonByValue('editcode').set('disabled', false);
80                             this.toolbar.selectButton('editcode');
81                             this.dompath.innerHTML = 'Editing HTML Code';
82                             this.hide();
83                         }
84                         return false;
85                     }, this, true);
86                     
87                     this.on('cleanHTML', function(ev){
88                         YAHOO.log('cleanHTML callback fired..', 'info', 'example');
89                         this.get('element').value = ev.html;
90                     }, this, true);
91                     
92                     this.on('afterRender', function(){
93                         var wrapper = this.get('editor_wrapper');
94                         wrapper.appendChild(this.get('element'));
95                         this.setStyle('width', '100%');
96                         this.setStyle('height', '100%');
97                         this.setStyle('visibility', '');
98                         this.setStyle('top', '');
99                         this.setStyle('left', '');
100                         this.setStyle('position', '');
101                         
102                         this.addClass('editor-hidden');
103                     }, this, true);
104                 }, myEditor, true);
105                 myEditor.render();
106                 
107             })();
108             
109             function switchsubmit(form, action){
110                 document.getElementsByName("action").item(0).value = action;
111                 form.submit();
112             }
113         </script>
114         <style>
115             .yui-skin-sam .yui-toolbar-container .yui-toolbar-editcode span.yui-toolbar-icon {
116                 background-image: url( ./yui/assets/html_editor.gif );
117                 background-position: 0 1px;
118                 left: 5px;
119             }
120             
121             .yui-skin-sam .yui-toolbar-container .yui-button-editcode-selected span.yui-toolbar-icon {
122                 background-image: url( ./yui/assets/html_editor.gif );
123                 background-position: 0 1px;
124                 left: 5px;
125             }
126             
127             .editor-hidden {
128                 visibility: hidden;
129                 top: -9999px;
130                 left: -9999px;
131                 position: absolute;
132             }
133             
134             textarea {
135                 border: 0;
136                 margin: 0;
137                 padding: 0;
138             }
139         </style>
140         <% end %>
141     </head>
142     <body class="yui-skin-sam">
143         <br>
144         <%= menu %>
145         <br>
146         <div class="divstyle" style="width: <%= TABLEWIDTH %>px;">
147             <form action="<%= cgi.script_name %>" method="POST">
148                 <input type="hidden" name="target_filepath" value="<%= session["target_filepath"] %>"><% case params["action"]
149                 when "confirm" %>
150                 <input type="hidden" name="editid" value="<%= session["editid"] %>">
151                 <table align="center" style="width: <%= (TABLEWIDTH - 20) %>px;">
152                     <tbody>
153                         <tr>
154                             <td colspan="2" class="formheader">
155                                 ■ 入力内容を確認してください
156                             </td>
157                         </tr>
158                         <% db.transaction do
159                         entry = db["editentry"]
160                         entry.paramlist.each do |val| %>
161                         <tr style="display: <%= entry.display[val] %>;">
162                             <td class="formnavi" style="width: 140px;">
163                                 <%= entry.name[val] %>
164                             </td>
165                             <td class="forminput">
166                                 <input type="hidden" name="<%= val %>" value="<%= entry.send(val) %>"><% if val != "content" %><%= entry.send(val) %><% else %><%= entry.content_for_view %><% end %>
167                             </td>
168                         </tr><% end %>
169                         <% end %>
170                     </tbody>
171                 </table>
172                 <br>
173                 <input type="hidden" name="mode" value="editentry"><input type="hidden" name="action" value=""><input type="button" value="戻る" onclick="switchsubmit(this.form, 'back')"> <input type="button" value="確定" onclick="switchsubmit(this.form, 'exec')"><% when "exec" %>
174                 <table align="center" style="width: <%= (TABLEWIDTH - 20) %>px">
175                     <tbody>
176                         <tr>
177                             <td class="forminput" style="text-align: center;">
178                                 記事の編集が完了しました。
179                             </td>
180                         </tr>
181                     </tbody>
182                 </table>
183                 <br>
184                 <a href="<%= cgi.script_name %>">メニューに戻る</a>
185                 <% when "edit" %>
186                 <input type="hidden" name="editid" value="<%= session["editid"] %>">
187                 <table align="center" style="width: <%= (TABLEWIDTH - 20) %>px;">
188                     <tbody>
189                         <tr>
190                             <td colspan="2" class="formheader">
191                                 ■ 記事編集
192                                 <br>
193                             </td>
194                         </tr>
195                         <% db.transaction do
196                         entry = db["editentry"]
197                         entry.paramlist.each do |val| %>
198                         <tr style="display: <%= entry.display[val] %>;">
199                             <td class="formnavi" style="width: 140px;">
200                                 <%= entry.name[val] %>
201                             </td>
202                             <td class="forminput">
203                                 <% if val == "content" %>
204                                 <textarea name="<%= val %>" rows="10" style="width: 100%" id="contenteditor"><%= entry.content_for_generator %></textarea>
205                                 <% elsif val == "updated" %>
206                                 <input type="text" name="<%= val %>" value="<%= Time.now.iso8601 %>" style="width: 100%;"><% else %>
207                                 <input type="text" name="<%= val %>" value="<%= entry.send(val) %>" style="width: 100%;"><% end %>
208                             </td>
209                         </tr><% end %>
210                         <% end %>
211                     </tbody>
212                 </table>
213                 <br>
214                 <input type="hidden" name="mode" value="editentry"><input type="hidden" name="action" value="confirm"><input type="submit" value="確認"><% when "back" %>
215                 <input type="hidden" name="editid" value="<%= session["editid"] %>">
216                 <table align="center" style="width: <%= (TABLEWIDTH - 20) %>px;">
217                     <tbody>
218                         <tr>
219                             <td colspan="2" class="formheader">
220                                 ■ 記事内容
221                                 <br>
222                             </td>
223                         </tr>
224                         <% db.transaction do
225                         entry = db["editentry"]
226                         entry.paramlist.each do |val| %>
227                         <tr style="display: <%= entry.display[val] %>;">
228                             <td class="formnavi" style="width: 140px;">
229                                 <%= entry.name[val] %>
230                             </td>
231                             <td class="forminput">
232                                 <% if val == "content" %>
233                                 <textarea name="<%= val %>" rows="10" style="width: 100%" id="contenteditor"><%= entry.content_for_generator %></textarea>
234                                 <% else %>
235                                 <input type="text" name="<%= val %>" value="<%= entry.send(val) %>" style="width: 100%;"><% end %>
236                             </td>
237                         </tr><% end %>
238                         <% end %>
239                     </tbody>
240                 </table>
241                 <br>
242                 <input type="hidden" name="mode" value="editentry"><input type="hidden" name="action" value="confirm"><input type="submit" class="wymupdate" value="確認"><% else %>
243                 <% db.transaction do %>
244                 <table align="center" style="width: <%= (TABLEWIDTH - 20) %>px;">
245                     <tbody>
246                         <tr>
247                             <td class="formheader" colspan="3">
248                                 ■ 編集する記事を選択してください。
249                             </td>
250                         </tr>
251                         <tr>
252                             <td class="formheader">
253                                   
254                             </td>
255                             <td class="formheader" style="text-align: center;">
256                                 記事のタイトル
257                             </td>
258                             <td class="formheader" style="text-align: center;">
259                                 最終更新時間
260                             </td>
261                         </tr>
262                         <% db["entry"].each_with_index do |entry, i| %>
263                         <tr>
264                             <td class="forminput" style="width: 30px; text-align: center;">
265                                 <input type="radio" name="editid" value="<%= entry.send("entryid") %>">
266                             </td>
267                             <td class="forminput">
268                                 <%= entry.send("title") %>
269                             </td>
270                             <td class="forminput" style="width: 150px; text-align: center;">
271                                 <%= entry.send("published").gsub("+09:00", "").gsub("T", " ") %>
272                             </td>
273                         </tr>
274                         <% end %>
275                     </tbody>
276                 </table>
277                 <br>
278                 <% if db["entry"].length != 0 %>
279                 <input type="hidden" name="mode" value="editentry"><input type="hidden" name="action" value="edit"><input type="submit" value="編集"><% else %>
280                 編集対象となる記事が存在しません。
281                 <br>
282                 <br>
283                 <% end %>
284                 <% end %>
285                 <% end %>
286             </form>
287         </div>
288         <br>
289         <div class="divstyle" style="border: none;">
290             <%= APPVERSION %>
291         </div>
292     </body>
293 </html>