source: trunk/skins/lemill/wysiwym_visual.pt @ 236

Revision 236, 6.6 KB checked in by tarmo, 13 years ago (diff)

Merged renaming-branch to trunk. From now on, you need to rename
the checkout folder to Products/LeMill? (not Toolbox!) and create
new instances (old ones certainly won't work).
Closes #333, spent 1h.

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="plone">
6
7      <head><title></title>
8
9      </head>
10
11  <body>
12
13    <!-- TextArea Widgets -->
14
15    <metal:view_macro define-macro="view" tal:replace="structure accessor" />
16
17    <metal:define define-macro="area_edit">
18    <script>
19    addEventHandler(window, 'load', function(){editMode();}, document);
20    var form = document.getElementsByName('edit_form');
21    addEventHandler(form[0], 'submit', function(){setBody();}, document);
22   
23function editMode() {
24    frame.document.designMode="On";
25};
26
27function change(command) {
28    frame.document.execCommand(command, false, null);
29};
30
31function addLink(){
32    url = prompt("URL", "");
33    frame.document.execCommand('CreateLink', false, url);
34
35};
36
37function addImage(){
38    image = prompt("Image", "");
39    frame.document.execCommand('InsertImage', false, image);
40};
41
42function addTag(tag){
43    frame.document.execCommand('FormatBlock', false, tag);
44};
45
46function setBody(){
47    doc = frame.document.body.innerHTML;
48    document.getElementById('hidden_input').value=doc;
49};
50
51function getBody(){
52    alert(frame.document.body.innerHTML);
53    alert(document.getElementById('hidden_input').value);
54};
55
56    </script>
57      <tal:define
58          define="base python:hasattr(value, 'isUnit');
59                  binary python:base and value.isBinary() or here.isBinary(fieldName);
60                  content python: not not base and value.getRaw() or value;
61                  content python: not binary and content or '';
62                  content_length python:len(content);
63                  append_only python: getattr(widget, 'append_only', None);">
64                  <div>
65                      <!--input type="button" name="edit_mode" value="Content" onClick="javascript:setBody();" /-->
66                      <img border="0" alt="Bold" src="buttons_bo.png" onClick="javascript:change('Bold');" />
67                      <img border="0" alt="Italic" src="buttons_it.png" onClick="javascript:change('Italic');" />
68                      <img border="0" alt="Link" src="buttons_li.png" onClick="javascript:addLink();" />
69                      <img border="0" alt="Image" src="buttons_im.png" onClick="javascript:addImage();" />
70                      <img border="0" alt="Bulleted list" src="buttons_bl.png" onClick="javascript:change('InsertUnorderedList');" />
71                      <img border="0" alt="Numbered list" src="buttons_nl.png" onClick="javascript:change('InsertOrderedList');" />
72                      <img border="0" alt="Code" src="buttons_co.png" onClick="javascript:addTag('code');" />
73              </div>
74              <iframe style="border:1px solid green; top:10px;left:10px" id="frame" name="frame" border="1" width="100%" height="300" src="" tal:define="content python:here.absolute_url()+'/getBody'" tal:attributes="src content"></iframe>
75              <input type="hidden" id="hidden_input" name="" value=""
76              tal:attributes="name fieldName;
77                              cols widget/cols;
78                            rows widget/rows;
79                            tabindex tabindex/next;"/>
80           
81            <!-- WYSIWYM Editor -->
82
83            <fieldset tal:condition="append_only">
84              <legend i18n:translate=""
85                      tal:define="label widget/label"
86                      tal:content="string:HISTORY: ${label}">
87                label
88              </legend>
89              <span i18n:translate=""
90                    tal:condition="python:(content_length &lt; 333)"
91                    tal:content="structure accessor">content</span>
92                    <textarea readonly="readonly" i18n:translate=""
93                              tal:condition="python:(content_length &gt;= 333)"
94                              tal:content="content"
95                              tal:attributes="cols widget/cols;
96                                              rows widget/rows;">
97                      content
98                    </textarea>
99            </fieldset>
100
101      </tal:define>
102    </metal:define>
103
104    <metal:define define-macro="area_format">
105      <tal:define
106          define="field_text_format string:${fieldName}_text_format;
107                  contentType python:request.get(field_text_format, here.getContentType(fieldName));
108                  allowable_ct python:getattr(field, 'allowable_content_types', ());
109                  mimetypes python:[t for t in allowable_ct if t.startswith('text/')];
110                  contenttype python:hasattr(field, 'getContentType') and field.getContentType(here) or ''">
111
112        <tal:condition condition="python:len(mimetypes) &gt; 1">
113        <div style="text-align: right; margin-right: 0.75em;">
114          <label i18n:translate="label_format">Format</label>
115          <select tal:attributes="id string:${fieldName}_text_format;
116                                  name string:${fieldName}_text_format;
117                                  tabindex tabindex/next">
118            <option selected="selected"
119                    value=""
120                    tal:attributes="value contentType"
121                    tal:condition="python:contenttype not in mimetypes">
122              (no change)
123            </option>
124            <option tal:repeat="item mimetypes"
125                    tal:content="python:here.lookupMime(item)"
126                    tal:attributes="value item;
127                                    selected python:test(here.checkSelected(item, contenttype, contenttypes=1), 'selected', None);"
128                    />
129          </select>
130        </div>
131        </tal:condition>
132        <tal:condition condition="python:len(mimetypes) == 1">
133          <input type="hidden"
134                 name=""
135                 value=""
136                 tal:attributes="name field_text_format;
137                                 value python:mimetypes[0]"
138                 />
139        </tal:condition>
140      </tal:define>
141    </metal:define>
142
143    <metal:define define-macro="edit">
144       <metal:use use-macro="field_macro | here/widgets/field/macros/edit">
145        <metal:fill fill-slot="widget_body">
146          <metal:block use-macro="here/wysiwym/macros/area_edit" />
147          <metal:block use-macro="here/wysiwym/macros/area_format" />
148        </metal:fill>
149      </metal:use>
150    </metal:define>
151
152    <metal:define define-macro="search">
153      <metal:use use-macro="here/widgets/field/macros/edit">
154        <metal:fill fill-slot="widget_body">
155
156          <metal:block use-macro="here/wysiwym/macros/area_edit" />
157
158        </metal:fill>
159      </metal:use>
160    </metal:define>
161
162  </body>
163
164</html>
Note: See TracBrowser for help on using the repository browser.