OSDN Git Service

9e9542ea03c21f25312447c54cb76ef5d3828ecd
[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         <link rel="stylesheet" type="text/css" href="./yui/build/menu/assets/skins/sam/menu.css" />
7         <link rel="stylesheet" type="text/css" href="./yui/build/button/assets/skins/sam/button.css" />
8         <link rel="stylesheet" type="text/css" href="./yui/build/fonts/fonts-min.css" />
9         <link rel="stylesheet" type="text/css" href="./yui/build/container/assets/skins/sam/container.css" />
10         <link rel="stylesheet" type="text/css" href="./yui/build/editor/assets/skins/sam/editor.css" />
11         <script type="text/javascript" src="./yui/build/yahoo-dom-event/yahoo-dom-event.js">
12         </script>
13         <script type="text/javascript" src="./yui/build/animation/animation-min.js">
14         </script>
15         <script type="text/javascript" src="./yui/build/element/element-min.js">
16         </script>
17         <script type="text/javascript" src="./yui/build/container/container-min.js">
18         </script>
19         <script type="text/javascript" src="./yui/build/menu/menu-min.js">
20         </script>
21         <script type="text/javascript" src="./yui/build/button/button-min.js">
22         </script>
23         <script type="text/javascript" src="./yui/build/editor/editor-min.js">
24         </script>
25         <script>
26             (function(){
27                 var Dom = YAHOO.util.Dom, Event = YAHOO.util.Event;
28                 
29                 var myConfig = {
30                     height: '400px',
31                     width: '100%',
32                     animate: true,
33                     dompath: true,
34                     focusAtStart: true,
35                     handleSubmit: true
36                 };
37                 
38                 var state = 'off';
39                 YAHOO.log('Set state to off..', 'info', 'example');
40                 
41                 YAHOO.log('Create the Editor..', 'info', 'example');
42                 var myEditor = new YAHOO.widget.Editor('contenteditor', myConfig);
43                 myEditor.on('toolbarLoaded', function(){
44                     var codeConfig = {
45                         type: 'push',
46                         label: 'Edit HTML Code',
47                         value: 'editcode'
48                     };
49                     YAHOO.log('Create the (editcode) Button', 'info', 'example');
50                     this.toolbar.addButtonToGroup(codeConfig, 'insertitem');
51                     
52                     this.toolbar.on('editcodeClick', function(){
53                         var ta = this.get('element'), iframe = this.get('iframe').get('element');
54                         
55                         if (state == 'on') {
56                             state = 'off';
57                             this.toolbar.set('disabled', false);
58                             YAHOO.log('Show the Editor', 'info', 'example');
59                             YAHOO.log('Inject the HTML from the textarea into the editor', 'info', 'example');
60                             this.setEditorHTML(ta.value);
61                             if (!this.browser.ie) {
62                                 this._setDesignMode('on');
63                             }
64                             
65                             Dom.removeClass(iframe, 'editor-hidden');
66                             Dom.addClass(ta, 'editor-hidden');
67                             this.show();
68                             this._focusWindow();
69                         }
70                         else {
71                             state = 'on';
72                             YAHOO.log('Show the Code Editor', 'info', 'example');
73                             this.cleanHTML();
74                             YAHOO.log('Save the Editors HTML', 'info', 'example');
75                             Dom.addClass(iframe, 'editor-hidden');
76                             Dom.removeClass(ta, 'editor-hidden');
77                             this.toolbar.set('disabled', true);
78                             this.toolbar.getButtonByValue('editcode').set('disabled', false);
79                             this.toolbar.selectButton('editcode');
80                             this.dompath.innerHTML = 'Editing HTML Code';
81                             this.hide();
82                         }
83                         return false;
84                     }, this, true);
85                     
86                     this.on('cleanHTML', function(ev){
87                         YAHOO.log('cleanHTML callback fired..', 'info', 'example');
88                         this.get('element').value = ev.html;
89                     }, this, true);
90                     
91                     this.on('afterRender', function(){
92                         var wrapper = this.get('editor_wrapper');
93                         wrapper.appendChild(this.get('element'));
94                         this.setStyle('width', '100%');
95                         this.setStyle('height', '100%');
96                         this.setStyle('visibility', '');
97                         this.setStyle('top', '');
98                         this.setStyle('left', '');
99                         this.setStyle('position', '');
100                         
101                         this.addClass('editor-hidden');
102                     }, this, true);
103                 }, myEditor, true);
104                 myEditor.render();
105                 
106             })();
107             
108             function switchsubmit(form, action){
109                 document.getElementsByName("action").item(0).value = action;
110                 form.submit();
111             }
112         </script>
113         <style>
114             .yui-skin-sam .yui-toolbar-container .yui-toolbar-editcode span.yui-toolbar-icon {
115                 background-image: url( ./yui/assets/html_editor.gif );
116                 background-position: 0 1px;
117                 left: 5px;
118             }
119             
120             .yui-skin-sam .yui-toolbar-container .yui-button-editcode-selected span.yui-toolbar-icon {
121                 background-image: url( ./yui/assets/html_editor.gif );
122                 background-position: 0 1px;
123                 left: 5px;
124             }
125             
126             .editor-hidden {
127                 visibility: hidden;
128                 top: -9999px;
129                 left: -9999px;
130                 position: absolute;
131             }
132             
133             textarea {
134                 border: 0;
135                 margin: 0;
136                 padding: 0;
137             }
138         </style>
139     </head>
140     <body class="yui-skin-sam">
141         <br>
142         <%= menu %>
143         <br>
144         <div class="divstyle" style="width: <%= TABLEWIDTH %>px;">
145             <form action="<%= cgi.script_name %>" method="POST">
146                 <input type="hidden" name="target_filepath" value="<%= session["target_filepath"] %>"><% case params["action"]
147                 when "confirm" %>
148                 <table align="center" style="width: <%= (TABLEWIDTH - 20) %>px;">
149                     <tbody>
150                         <tr>
151                             <td colspan="2" class="formheader">
152                                 ■ 入力内容を確認してください
153                             </td>
154                         </tr>
155                         <% db.transaction do
156                         entry = db["newentry"]
157                         entry.paramlist.each do |val| %>
158                         <tr style="display: <%= entry.display[val] %>;">
159                             <td class="formnavi" style="width: 140px;">
160                                 <%= entry.name[val] %>
161                             </td>
162                             <td class="forminput">
163                                 <input type="hidden" name="<%= val %>" value="<%= entry.send(val) %>"><% if val != "content" %><%= entry.send(val) %><% else %><%= entry.content_for_view %><% end %>
164                             </td>
165                         </tr><% end %>
166                         <% end %>
167                     </tbody>
168                 </table>
169                 <br>
170                 <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" %>
171                 <table align="center" style="width: <%= (TABLEWIDTH - 20) %>px;">
172                     <tbody>
173                         <tr>
174                             <td class="forminput" style="text-align: center;">
175                                 記事の書き込みが完了しました。
176                             </td>
177                         </tr>
178                     </tbody>
179                 </table>
180                 <br>
181                 <a href="<%= cgi.script_name %>">メニューに戻る</a>
182                 <% when "back" %>
183                 <table style="width: <%= (TABLEWIDTH - 20) %>px;">
184                     <tbody>
185                         <tr>
186                             <td colspan="2" class="formheader">
187                                 ■ 新規作成
188                                 <br>
189                             </td>
190                         </tr>
191                         <% db.transaction do
192                         if cgi["action"] == "back"
193                         entry = db["newentry"]
194                         else
195                         entry = Entry.new({})
196                         end
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                                 <input type="text" name="<%= val %>" value="<%= entry.send(val) %>" style="width: 100%"><% else %>
205                                 <textarea name="<%= val %>" rows="10" style="width: 100%" id="contenteditor">
206                                     <%= entry.content_for_generator %>
207                                 </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">
240                                     <% if entry.content.empty? %>
241                                     <p><br></p>
242                                     <% else %>
243                                     <%= entry.content_for_generator %>
244                                     <% end %>
245                                 </textarea>
246                                 <% elsif val == "entryid" %>
247                                 <input type="text" name="<%= val %>" value="<%= db["feed"].feedid %>?<%= date %>" style="width: 100%"><% elsif val == "updated" || val == "published" %>
248                                 <input type="text" name="<%= val %>" value="<%= date %>" style="width: 100%"><% elsif val == "url" %>
249                                 <input type="text" name="<%= val %>" value="<%= db["feed"].url %>#<%= db["feed"].feedid %>?<%= date %>" style="width: 100%"><% else %>
250                                 <input type="text" name="<%= val %>" value="<%= entry.send(val) %>" style="width: 100%"><% end %>
251                             </td>
252                         </tr><% end %>
253                         <% end %>
254                     </tbody>
255                 </table>
256                 <br>
257                 <input type="hidden" name="mode" value="newentry"><input type="hidden" name="action" value="confirm"><input type="submit" class="wymupdate" value="確認"><% end %>
258             </form>
259         </div>
260         <br>
261         <div class="divstyle" style="border: none;">
262             <%= APPVERSION %>
263         </div>
264     </body>
265 </html>