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

Revision 3074, 15.7 KB checked in by jukka, 9 years ago (diff)

Exercises seem to be working now.

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