1 {% extends "base.html" %}
2 {% load toolbar_tags %}
5 <link rel="stylesheet" href="{{STATIC_URL}}css/html.css" type="text/css" media="screen" charset="utf-8">
6 <script src="{{STATIC_URL}}js/lib/codemirror/codemirror.js" type="text/javascript" charset="utf-8"></script>
7 <script src="{{STATIC_URL}}js/lib/jquery.splitter.js" type="text/javascript" charset="utf-8"></script>
8 <script src="{{STATIC_URL}}js/lib/jquery.form.js" type="text/javascript" charset="utf-8"></script>
9 <script src="{{STATIC_URL}}js/button_scripts.js" type="text/javascript" charset="utf-8"></script>
10 <script type="text/javascript" charset="utf-8">
12 function serialize(element) {
13 if (element.nodeType == 3) { // tekst
14 return [$.trim(element.nodeValue)];
15 } else if (element.nodeType != 1) { // pomijamy węzły nie będące elementami XML ani tekstem
20 var hasContent = false;
23 result.push(element.tagName);
25 // Mozilla nie uważa deklaracji namespace za atrybuty
26 var ns = element.tagName.indexOf(':');
27 if (ns != -1 && $.browser.mozilla) {
28 result.push(' xmlns:');
29 result.push(element.tagName.substring(0, ns));
31 result.push(element.namespaceURI);
35 if (element.attributes) {
36 for (var i=0; i < element.attributes.length; i++) {
37 var attr = element.attributes[i];
39 result.push(attr.name);
41 result.push(attr.value);
47 if (element.childNodes.length == 0) {
52 for (var i=0; i < element.childNodes.length; i++) {
53 result = result.concat(serialize(element.childNodes[i]));
57 result.push(element.tagName);
61 if (element.tagName == 'akap' || element.tagName == 'akap_dialog' || element.tagName == 'akap_cd') {
62 result.push('\n\n\n');
63 } else if (element.tagName == 'rdf:RDF') {
64 result.push('\n\n\n\n\n');
65 } else if (element.tagName.indexOf('dc:') != -1) {
74 var editor = CodeMirror.fromTextArea('id_text', {
75 parserfile: 'parsexml.js',
76 path: "{{ STATIC_URL }}js/lib/codemirror/",
77 stylesheet: "{{ STATIC_URL }}css/xmlcolors.css",
86 $('#splitter').splitter({
95 $(window).resize(function() {
96 $('iframe').height($(window).height() - $('#tabs').outerHeight());
101 $('.vsplitbar').dblclick(function() {
102 if ($('#sidebar').width() == 0) {
103 $('#splitter').trigger('resize', [$(window).width() - 480]);
105 $('#splitter').trigger('resize', [$(window).width()]);
109 loadSuccess = function() {
110 if (this.get('state') != 'loading') {
111 alert('erroneous state:', this.get('state'));
117 messageCenter.addMessage('success', 'xmlload', 'Wczytałem HTML :-)');
120 function createXSLT(xsl) {
121 var p = new XSLTProcessor();
122 p.importStylesheet(xsl);
126 function transform() {
128 url: '{{ STATIC_URL }}xsl/wl2html_client.xsl',
130 success: function(data) {
132 var parser = new DOMParser();
133 var serializer = new XMLSerializer();
134 var htmlXSL = createXSLT(data);
136 doc = editor.getCode().replace(/\/\s+/g, '<br />');
137 doc = parser.parseFromString(doc, 'text/xml');
138 console.log('xml', doc);
139 doc = htmlXSL.transformToFragment(doc, document);
140 console.log('after transform', doc);
141 $('#simple-editor').html(doc.firstChild);
143 error: function() {alert('Error loading XSL!')}
147 function reverseTransform () {
149 url: '{{ STATIC_URL }}xsl/html2wl_client.xsl',
151 success: function(data) {
153 var parser = new DOMParser();
154 var serializer = new XMLSerializer();
155 var xsl = createXSLT(data);
157 doc = serializer.serializeToString($('#simple-editor div').get(0))
158 doc = parser.parseFromString(doc, 'text/xml');
159 console.log('xml',doc, doc.documentElement);
160 // TODO: Sprawdzenie błędów
161 doc = xsl.transformToDocument(doc);
162 console.log('after transform', doc, doc.documentElement);
163 doc = serialize(doc.documentElement).join('');
164 // doc = serializer.serializeToString(doc.documentElement)
167 error: function() {alert('Error loading XSL!')}
171 $('#save-button').click(function(event) {
172 event.preventDefault();
173 console.log(editor.getCode(), $('form input[name=text]').get(0));
174 $('form textarea[name=text]').val(editor.getCode());
175 $('form').ajaxSubmit(function() {
180 $('#simple-view-tab').click(function() {
181 if ($(this).hasClass('active')) {
184 $(this).addClass('active');
185 $('#source-view-tab').removeClass('active');
186 $('#source-editor').hide();
187 $('#simple-editor').show();
191 $('#source-view-tab').click(function() {
192 if ($(this).hasClass('active')) {
195 $(this).addClass('active');
196 $('#simple-view-tab').removeClass('active');
197 $('#simple-editor').hide();
198 $('#source-editor').show();
202 $('.toolbar button').click(function(event) {
203 event.preventDefault();
204 var params = eval("(" + $(this).attr('ui:action-params') + ")");
205 scriptletCenter.scriptlets[$(this).attr('ui:action')](editor, params);
208 $('.toolbar select').change(function() {
209 var slug = $(this).val();
211 $('.toolbar-buttons-container').hide().filter('[data-group=' + slug + ']').show();
214 $('.toolbar-buttons-container').hide();
215 $('.toolbar select').change();
219 <style type="text/css" media="screen">
230 background: #EEE url(/static/img/gallery.png) no-repeat scroll center center;
231 border-left: 1px solid #999;
236 background-color: #DDD;
252 background-color: #C1C1C1;
253 background-image: -webkit-gradient(linear, left top, left bottom, from(#C1C1C1), color-stop(0.9, #A2A2A2));
254 font: 11px Helvetica, Verdana, sans-serif;
261 font: 17px Helvetica, Verdana, sans-serif;
264 padding: 3px 6px 2px 6px;
276 border-bottom: 1px solid #777;
280 -webkit-user-select: none;
284 padding: 5px 12px 3px 12px;
285 border: 1px solid #999;
286 -webkit-border-radius: 4px;
287 -webkit-border-bottom-left-radius: 0;
288 -webkit-border-bottom-right-radius: 0;
291 /* text-shadow: #CCC 1px 1px 1px;*/
293 background-color: #C1C1C1;
294 -webkit-box-shadow: 1px -1px 2px rgba(127, 127, 127, 0.25);
300 background-color: #FEFCDF;
301 background-image: none;
302 /* background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0.25, #C1C1C1), to(#FFFFFF)); */
303 border-bottom: 1px solid #FEFCDF;
307 border-bottom: 1px solid #777;
308 background-color: #FEFCDF;
315 margin: 2px 5px 2px 0;
317 border: 1px solid #999;
325 padding: 0 5px 2px 5px;
334 .toolbar button:hover, .toolbar button:active {
337 -webkit-border-radius: 10px;
338 -moz-border-radius: 10px;
342 /* Remove extra padding in Firefox */
343 button::-moz-focus-inner {
352 {% block maincontent %}
353 <form action="{% url wiki.views.document_detail document.name|urlencode %}" method="post" accept-charset="utf-8">
355 <div id="tools" style="float: right;">Wersja: {{ document.revision }}<button style="margin-left: 6px" id="save-button">Zapisz</button></div>
356 <h1>{{ document.name }}</h1>
358 <li id="simple-view-tab">Widok prosty</li>
359 <li id="source-view-tab" class="active">Widok zaawansowany</li>
361 <div style="clear: both"></div>
365 <div id="source-editor">
368 <input type="hidden" name="name" value="{{ document.name }}" />
369 <input type="hidden" name="author" value="annonymous" />
370 <input type="hidden" name="comment" value="no comment" />
371 <input type="hidden" name="revision" value="{{ document.revision }}" />
373 <div id="simple-editor" class="htmlview" style="display: none">
377 <div id="sidebar" style="width: 200px">
378 <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
379 <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>