OSDN Git Service

e03229c5d2c5ef496df71a2dfcf183c3bce5fe29
[feedblog/feedgenerator.git] / erbtemp / newentry.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                 <table align="center" style="width: <%= (TABLEWIDTH - 20) %>px;">
151                     <tbody>
152                         <tr>
153                             <td colspan="2" class="formheader">
154                                 ■ 入力内容を確認してください
155                             </td>
156                         </tr>
157                         <% db.transaction do
158                         entry = db["newentry"]
159                         entry.paramlist.each do |val| %>
160                         <tr style="display: <%= entry.display[val] %>;">
161                             <td class="formnavi" style="width: 140px;">
162                                 <%= entry.name[val] %>
163                             </td>
164                             <td class="forminput">
165                                 <input type="hidden" name="<%= val %>" value="<%= entry.send(val) %>"><% if val != "content" %><%= entry.send(val) %><% else %><%= entry.content_for_view %><% end %>
166                             </td>
167                         </tr><% end %>
168                         <% end %>
169                     </tbody>
170                 </table>
171                 <br>
172                 <input type="hidden" name="mode" value="newentry"><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" %>
173                 <table align="center" style="width: <%= (TABLEWIDTH - 20) %>px;">
174                     <tbody>
175                         <tr>
176                             <td class="forminput" style="text-align: center;">
177                                 記事の書き込みが完了しました。
178                             </td>
179                         </tr>
180                     </tbody>
181                 </table>
182                 <br>
183                 <a href="<%= cgi.script_name %>">メニューに戻る</a>
184                 <% when "back" %>
185                 <table style="width: <%= (TABLEWIDTH - 20) %>px;">
186                     <tbody>
187                         <tr>
188                             <td colspan="2" class="formheader">
189                                 ■ 新規作成
190                                 <br>
191                             </td>
192                         </tr>
193                         <% db.transaction do
194                         if cgi["action"] == "back"
195                         entry = db["newentry"]
196                         else
197                         entry = Entry.new({})
198                         end
199                         entry.paramlist.each do |val| %>
200                         <tr style="display: <%= entry.display[val] %>;">
201                             <td class="formnavi" style="width: 140px;">
202                                 <%= entry.name[val] %>
203                             </td>
204                             <td class="forminput">
205                                 <% if val != "content" %>
206                                 <input type="text" name="<%= val %>" value="<%= entry.send(val) %>" style="width: 100%"><% else %>
207                                 <textarea name="<%= val %>" rows="10" style="width: 100%" id="contenteditor"><%= entry.content_for_generator %></textarea>
208                                 <% end %>
209                             </td>
210                         </tr>
211                         <% end %>
212                         <% end %>
213                     </tbody>
214                 </table>
215                 <br>
216                 <input type="hidden" name="mode" value="newentry"><input type="hidden" name="action" value="confirm"><input type="submit" value="確認"><% else %>
217                 <table align="center" style="width: <%= (TABLEWIDTH - 20) %>px;">
218                     <tbody>
219                         <tr>
220                             <td colspan="2" class="formheader">
221                                 ■ 新規作成
222                                 <br>
223                             </td>
224                         </tr>
225                         <% db.transaction do
226                         if cgi["action"] == "back"
227                         entry = db["newentry"]
228                         else
229                         entry = Entry.new({})
230                         end
231                         entry.paramlist.each do |val| %>
232                         <tr style="display: <%= entry.display[val] %>;">
233                             <td class="formnavi" style="width: 140px;">
234                                 <%= entry.name[val] %>
235                             </td>
236                             <td class="forminput">
237                                 <% date = Time.now.iso8601 %>
238                                 <% if val == "content" %>
239                                 <textarea name="<%= val %>" rows="10" style="width: 100%" id="contenteditor"><% if entry.content.empty? %><p><br></p><% else %><%= entry.content_for_generator %><% end %></textarea>
240                                 <% elsif val == "entryid" %>
241                                 <input type="text" name="<%= val %>" value="<%= db["feed"].feedid %>?<%= date %>" style="width: 100%"><% elsif val == "updated" || val == "published" %>
242                                 <input type="text" name="<%= val %>" value="<%= date %>" style="width: 100%"><% elsif val == "url" %>
243                                 <input type="text" name="<%= val %>" value="<%= db["feed"].url %>#<%= db["feed"].feedid %>?<%= date %>" style="width: 100%"><% else %>
244                                 <input type="text" name="<%= val %>" value="<%= entry.send(val) %>" style="width: 100%"><% end %>
245                             </td>
246                         </tr><% end %>
247                         <% end %>
248                     </tbody>
249                 </table>
250                 <br>
251                 <input type="hidden" name="mode" value="newentry"><input type="hidden" name="action" value="confirm"><input type="submit" class="wymupdate" value="確認"><% end %>
252             </form>
253         </div>
254         <br>
255         <div class="divstyle" style="border: none;">
256             <%= APPVERSION %>
257         </div>
258     </body>
259 </html>