source: trunk/skins/lemill/widget_chapter.pt @ 3086

Revision 3086, 15.8 KB checked in by jukka, 9 years ago (diff)

Fixes for exercise editing

Line 
1<html xmlns="http://www.w3.org/1999/xhtml"
2      xmlns:tal="http://xml.zope.org/namespaces/tal"
3      xmlns:metal="http://xml.zope.org/namespaces/metal"
4      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
5      i18n:domain="lemill">
6  <head><title></title></head>
7  <body>
8
9<!-- Main view macro -->
10
11<metal:view_macro define-macro="view" tal:define="value accessor"> 
12    <tal:chapters repeat="chapter value">           
13        <tal:defs tal:define="text chapter/text;
14            type chapter/type;
15            index repeat/chapter/index;">
16            <metal:view_block use-macro="python:path('here/widget_chapter/macros/view_'+type)" />
17        </tal:defs>
18    </tal:chapters>
19</metal:view_macro>
20
21<!-- view macros, called from Main view macro and these can be used by other widgets too -->
22
23<metal:view_text_block define-macro="view_text_block">
24<div tal:replace="structure text" />
25</metal:view_text_block>
26
27<metal:view_media_piece define-macro="view_media_piece">
28<tal:piece_defs define="piece python:field.getObjectByUID(context, chapter.get('uid',''));
29    piece_url piece/absolute_url | nothing;
30    piece_type piece/getPiece_type | nothing;
31    macro_mapping python:{'image':'here/piece_macros/macros/image',
32        'audio':'here/macros_audioplayer/macros/audioplayer',
33        'flash':'here/piece_macros/macros/swf_macro',
34        'flv-video':'here/macros_flowplayer/macros/flowplayer_chapter_view',
35        'kml':'here/piece_macros/macros/kml_macro',
36        'video':'here/macros_flowplayer/macros/flowplayer_chapter_view'}">   
37        <tal:we_got_piece condition="python:piece and not piece.isDeleted()">
38            <metal:view use-macro="python:path(macro_mapping[piece_type])" />
39        </tal:we_got_piece>
40</tal:piece_defs>
41</metal:view_media_piece>
42
43<metal:view_embed_block define-macro="view_embed_block">
44<div class="embed_content" tal:content="structure chapter/embed | python:''" ></div>
45</metal:view_embed_block>
46
47<!-- Main edit macro -->
48
49<metal:define define-macro="edit">
50 <metal:use use-macro="field_macro | here/field/macros/edit">
51  <metal:fill fill-slot="widget_body">
52   <metal:chapter_editor_block define-macro="chapter_editor">
53  <tal:define define="edit_chapter request/chapter_edited | python:0;
54              edit_chapter python: int(edit_chapter);
55              translation translation | python:0;
56              chapter_count python:len(value);
57              edit_chapter python: test(edit_chapter&lt;chapter_count, edit_chapter, chapter_count-1);           
58              cleaned_chapters here/getBodyText;
59              macro_mapping python:{'text_block':'here/widget_chapter/macros/%s_text_block',
60                'guidelines':'here/widget_exercise/macros/%s_guidelines',
61                'media_piece':'here/widget_chapter/macros/%s_media_piece',
62                'embed_block':'here/widget_chapter/macros/%s_embed_block',
63                'choice':'here/widget_exercise/macros/%s_choice',
64                'multiple_choices':'here/widget_exercise/macros/%s_multiple_choices',
65                'poll':'here/widget_exercise/macros/%s_poll',
66                'fill_in_the_blanks':'here/widget_exercise/macros/%s_fill_in_the_blanks',
67                'open_ended':'here/widget_exercise/macros/%s_open_ended',
68                'exercise':'here/widget_exercise/macros/%s_exercise'};
69              chapter_names field/getChapterNames;">
70    <input type="hidden" name="chapter_count" id="chapter_count" value="1" tal:attributes="value chapter_count"/>
71    <input type="hidden" name="chapter_edited" id="chapter_edited" value="0" tal:attributes="value edit_chapter"/>
72    <input type="hidden" name="chapter_last_edited" id="chapter_last_edited" value="0" tal:attributes="value edit_chapter"/>
73    <input type="hidden" name="chapter_type" id="chapter_type" tal:attributes="value python:value[edit_chapter]['type']"/>
74   <div class="sortable">
75   <tal:chapters repeat="chapter value">
76    <tal:definitions define="index repeat/chapter/index;
77      text chapter/text;
78      type chapter/type;
79      cleaned_chapter python:cleaned_chapters[index];
80       ">       
81     <a name="#" tal:attributes="name index"></a>
82     <div class="sortable_row">       
83     <fieldset class="edit_box">   
84       <metal:legend define-macro="legendbuttons">
85            <div class="handle">
86                <img src="images/pattern.png" tal:attributes="src string:${portal_url}/images/pattern.png" alt="" width="18" height="10" style="padding-top:4px;padding-left:4px" />
87                <input class="editChapter "
88                    type="submit"
89                    name="editChapter"
90                    value="Edit" i18n:domain="plone"
91                    tal:condition="python:index!=edit_chapter"
92                    i18n:attributes="value label_edit;"
93                    tal:attributes="tabindex tabindex/next;
94                    onClick python:'''javascript:document.getElementById('chapter_edited').value=%s''' %  index"/>                   
95                <input class="saveChapter"
96                    tabindex=""
97                    type="submit"
98                    name="saveChapter"
99                    value="Save" i18n:domain="plone"
100                    tal:condition="python:index==edit_chapter"
101                    i18n:attributes="value label_save;"
102                    tal:attributes="tabindex tabindex/next;"
103                    onClick="$('chapter_edited').val('-1')"/>
104                <span tal:content="python:chapter_names[type]" i18n:translate="" class="discreet">text chapter</span>
105
106                <input class="right deleteButton"
107                    type="button"
108                    name="deleteButton"
109                    value="Delete" i18n:domain="plone"
110                    i18n:attributes="value;"
111                    tal:attributes="tabindex tabindex/next;"
112                    onClick="deleteChapter(this);" />
113                <input type="button"
114                    name="undeleteButton"
115                    class="right undeleteButton"
116                    value="Undelete"
117                    i18n:attributes="value;"
118                    tal:attributes="tabindex tabindex/next;"
119                    style="display:none"
120                    onClick="undeleteChapter(this);"/>
121                <input type="hidden"
122                    tal:attributes="id string:chapter_deleted_$index; name string:chapter_deleted_$index"
123                    class="deletionkeeper"
124                    value="0" />
125                <input type="hidden"
126                    class="orderkeeper"
127                    tal:attributes="name string:chapter_order_$index; id string:chapter_order_$index; value index" />       
128            </div>
129        </metal:legend>
130        <tal:view_mode condition="python:index!=edit_chapter">
131           <div class="inner_box">
132            <metal:block use-macro="python:path(macro_mapping[type] % 'edit_view')" />
133           </div>             
134        </tal:view_mode>
135      <tal:edit_mode condition="python:index==edit_chapter">
136           <a name="edit"></a>
137           <metal:block use-macro="python:path(macro_mapping[type] % 'edit')" />               
138      </tal:edit_mode>
139     </fieldset>
140     </div>
141     </tal:definitions>
142   </tal:chapters>
143   </div>
144   </tal:define>
145   </metal:chapter_editor_block>
146   <tal:buttons>
147       <input class="context"
148           tabindex=""
149           type="submit"
150           name="add_media_piece"
151           value="Add media piece"
152           i18n:attributes="value label_add_media_piece;"
153           tal:attributes="tabindex tabindex/next"
154           />               
155       <input class="context"
156           tabindex=""
157           type="submit"
158           name="add_text_block"
159           value="Add text block"
160           i18n:attributes="value label_add_textarea;"
161           tal:attributes="tabindex tabindex/next"
162           />
163       <input class="context"
164           tabindex=""
165           type="submit"
166           name="add_embed_block"
167           value="Add an embedded section"
168           i18n:attributes="value label_add_embed_block;"
169           tal:attributes="tabindex tabindex/next"
170           />
171   </tal:buttons>
172 </metal:fill>
173</metal:use>
174</metal:define>
175
176
177<!-- edit/view macros,  called from Main edit macros if chapter is not the one that is edited -->
178
179<metal:edit_view_text_block define-macro="edit_view_text_block">
180<div tal:replace="structure cleaned_chapter/text" />
181</metal:edit_view_text_block>
182
183<tal:edit_view_media_piece metal:define-macro="edit_view_media_piece">    
184    <tal:defs define="piece python:field.getObjectByUID(context, chapter['uid']);
185        deleted piece/isDeleted | python:True;
186        piece_url piece/absolute_url | nothing;
187        piece_type piece/getPiece_type | nothing;
188        macro_mapping python:{'image':'here/piece_macros/macros/image',
189            'audio':'here/macros_audioplayer/macros/audioplayer',
190            'flash':'here/piece_macros/macros/swf_macro',
191            'flv-video':'here/macros_flowplayer/macros/flowplayer_chapter_area_edit',
192            'kml':'here/piece_macros/macros/kml_macro'}">   
193        <tal:we_got_piece condition="python:piece and not piece.isDeleted()">
194            <metal:view use-macro="python:path(macro_mapping[piece_type])" />
195        </tal:we_got_piece>
196    </tal:defs>
197</tal:edit_view_media_piece>
198
199<metal:edit_view_embed_block define-macro="edit_view_embed_block">
200<div tal:replace="structure cleaned_chapter/embed | python:''" />
201</metal:edit_view_embed_block>
202
203<!-- edit macros, called from Main edit macro for chapter that is open to editing -->
204
205<metal:original_text define-macro="original_text">
206<label i18n:translate="label_original_field">Original<span i18n:name="field" >:</span></label>
207<div class="text_to_translate">
208   <span tal:replace="structure chapter/translation_source"/>           
209</div>
210</metal:original_text>
211
212
213<tal:edit_text_block metal:define-macro="edit_text_block">    
214<div class="translatedText" tal:condition="translation"><metal:tra use-macro="here/widget_chapter/macros/original_text" /></div>
215<tal:def define="inputvalue text;
216    fieldName python:'chapter_textarea';
217    inputname fieldName;
218    height python:'260px';
219    rows python:18">     
220        <metal:block metal:use-macro="here/wysiwyg_support/macros/wysiwygEditorBox" />
221</tal:def>
222</tal:edit_text_block>
223
224<tal:edit_embed_block metal:define-macro="edit_embed_block">    
225<div class="formHelp" i18n:translate="embed_block_helptext">Paste embed code here.</div>      
226<textarea rows="3" style="width:95%" id="embed_textarea" name="embed_textarea" tal:content="chapter/embed | python:''"></textarea>    
227</tal:edit_embed_block>
228
229<metal:edit_media_piece define-macro="edit_media_piece">
230    <tal:def_search_type tal:define="piece_type python:'All'; piece_edit python:True">
231        <metal:block metal:use-macro="here/widget_chapter/macros/piece_chooser" />   
232    </tal:def_search_type>
233</metal:edit_media_piece>
234
235<metal:define define-macro="piece_chooser">
236  <tal:defines define="piece_uid chapter/uid;
237                        piece python: field.getObjectByUID(context, piece_uid);
238                        piece_url piece/absolute_url | nothing;
239                        deleted piece/isDeleted | python:True;
240                        isImage piece/isImage | python:0;
241                        isAudio piece/isAudio | python:0;
242                        isFLVVideo piece/isFLVVideo | python:0;
243                        coverImage piece/getCoverImage | nothing;">
244    <div id="piece-edit-box" tal:attributes="style python:test(piece_url, 'background-image:url(%s/image_large)' % piece_url, 'background-image:none')">
245    <div style="display:inline-block">
246        <div style="height:20px" class="visualClear">&nbsp;</div>
247        <div id="piece-edit-controls" tal:attributes="class python:test(piece and isImage, 'contrast','')"><tal:block tal:condition="python: piece_type=='image'" i18n:translate="label_upload_image_file">Upload image file</tal:block>
248        <tal:block tal:condition="python: piece_type=='audio'" i18n:translate="label_upload_audio">Upload audio file</tal:block>
249        <tal:block tal:condition="python: piece_type not in ['audio','image']" i18n:translate="label_upload_a_file">Upload a file</tal:block>...
250        <input type="hidden" value="0" name="piece_uid" id="piece_uid" tal:attributes="value piece_uid | nothing;"  />
251        <input type="hidden" value="" name="piece_type" id="piece_type" tal:attributes="value piece_type | string:image;" />
252        <input id="file"  type="file" value="" name="file" />
253        <input id="uploadFile"  type="submit"  name="uploadFile" value="Upload file" i18n:attributes="value label_upload_file;" /></div>
254        <div style="height:20px" class="visualClear">&nbsp;</div>
255    </div>
256    <div id="piece-view-controls"  style="display:inline-block">
257        <div id="piece-media-box">
258         <div style="display:inline-block;vertical-align:middle;">
259          <tal:not_image condition="python:piece and not isImage">
260            <a href="" tal:attributes="href piece_url">                       
261            <tal:coverimage condition="coverImage" replace="structure coverImage" />
262            <img tal:condition="python: isAudio and not coverImage" src="images/default_soundclip.png" />
263            <img tal:condition="python: not (isAudio or coverImage)" src="images/default_movieclip.png" />
264            </a>
265          </tal:not_image>
266         </div>
267        <div style="display:inline-block;vertical-align:middle;" tal:condition="python: isAudio and not deleted">
268         <metal:block metal:use-macro="here/macros_audioplayer/macros/audioplayer" />
269        </div>
270        </div>
271    </div>
272    <div id="tab_spacer" style="height:300px" tal:attributes="class python:test(not piece, 'hidden', '')">&nbsp;</div>
273    <div>
274    <div class="tab" id="tab_search" tal:attributes="class python:test(not piece, 'tab selected_tab', 'tab')" i18n:translate="label_or_search_from_pieces" onclick="clickedTab(this,'tab_sheet_search')">... or search from media pieces</div>
275    <div class="tab" id="tab_pieces" i18n:translate="label_browse_your_media" onclick="clickedTab(this,'tab_sheet_pieces')">browse your media</div>
276    <div class="tab" id="tab_collections" i18n:translate="label_browse_from_your_collections" onclick="clickedTab(this,'tab_sheet_collections')">browse from your collections</div>
277
278    <div class="tab_sheet" id="tab_sheet_search" tal:attributes="class python:test(not piece, 'tab_sheet selected_tab_sheet', 'tab_sheet')">
279    <p>
280    <input id="piece-search"
281            type="text"
282            value=""
283            name="piece-search"
284            onkeypress="if(event.keyCode==13) { document.getElementById('piece-searchbutton').onclick(); return false; }" />
285    <input id="piece-searchbutton"
286            type="button"
287            value="Search"
288            name="piece-searchbutton"
289            i18n:attributes="value label_search;" i18n:domain="plone"
290            onclick="search_for_pieces(this, event);"/>
291    </p>
292     <div class="tab_sheet_results">
293        <b class="message" style="display:none;">Query result message</b>
294        <div style="height:20px" class="visualClear">&nbsp;</div>
295        <div class="piece_chooser" style="display:none">Results go here</div>                                       
296    </div>
297    </div>
298   
299    <div class="tab_sheet" id="tab_sheet_pieces">
300     <div class="tab_sheet_results">
301        <b class="message" style="display:none;">Query result message</b>
302        <div style="height:20px" class="visualClear">&nbsp;</div>
303        <div class="piece_chooser" style="display:none"></div>                                       
304    </div>
305   </div>
306   <div class="tab_sheet" id="tab_sheet_collections">
307     <div class="tab_sheet_results">
308        <b class="message" style="display:none;">Query result message</b>
309        <div style="height:20px" class="visualClear">&nbsp;</div>
310        <div class="piece_chooser" style="display:none"></div>                                       
311    </div>
312  </div>
313
314    </div>
315    </div>
316
317     </tal:defines>
318</metal:define>
319
320  </body>
321</html>
Note: See TracBrowser for help on using the repository browser.