X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/d1a48c87f0060e3d644e85b0471c82d629241d35..ce89530aa0db752e169adb914938d7f5f9f0ed5a:/platforma/templates/wiki/document_details.html?ds=inline diff --git a/platforma/templates/wiki/document_details.html b/platforma/templates/wiki/document_details.html index 34458028..ad71c847 100644 --- a/platforma/templates/wiki/document_details.html +++ b/platforma/templates/wiki/document_details.html @@ -2,353 +2,36 @@ {% load toolbar_tags %} {% block extrahead %} - <link rel="stylesheet" href="{{STATIC_URL}}css/html.css" type="text/css" media="screen" charset="utf-8"> - <script src="{{STATIC_URL}}js/lib/codemirror/codemirror.js" type="text/javascript" charset="utf-8"></script> - <script src="{{STATIC_URL}}js/lib/jquery.splitter.js" type="text/javascript" charset="utf-8"></script> - <script src="{{STATIC_URL}}js/lib/jquery.form.js" type="text/javascript" charset="utf-8"></script> - <script src="{{STATIC_URL}}js/button_scripts.js" type="text/javascript" charset="utf-8"></script> + <link rel="stylesheet" href="{{STATIC_URL}}css/master.css" type="text/css" media="screen" charset="utf-8" /> + <link rel="stylesheet" href="{{STATIC_URL}}css/html.css" type="text/css" media="screen" charset="utf-8" /> + <link rel="stylesheet" href="{{STATIC_URL}}css/jquery.autocomplete.css" type="text/css" media="screen" title="no title" charset="utf-8"> <script type="text/javascript" charset="utf-8"> - - function serialize(element) { - if (element.nodeType == 3) { // tekst - return [$.trim(element.nodeValue)]; - } else if (element.nodeType != 1) { // pomijamy wÄzÅy nie bÄdÄ ce elementami XML ani tekstem - return []; - } - - var result = []; - var hasContent = false; - - result.push('<'); - result.push(element.tagName); - - // Mozilla nie uważa deklaracji namespace za atrybuty - var ns = element.tagName.indexOf(':'); - if (ns != -1 && $.browser.mozilla) { - result.push(' xmlns:'); - result.push(element.tagName.substring(0, ns)); - result.push('="'); - result.push(element.namespaceURI); - result.push('"'); - } - - if (element.attributes) { - for (var i=0; i < element.attributes.length; i++) { - var attr = element.attributes[i]; - result.push(' '); - result.push(attr.name); - result.push('="'); - result.push(attr.value); - result.push('"'); - hasContent = true; - } - } - - if (element.childNodes.length == 0) { - result.push(' />'); - } else { - result.push('>'); - - for (var i=0; i < element.childNodes.length; i++) { - result = result.concat(serialize(element.childNodes[i])); - } - - result.push('</'); - result.push(element.tagName); - result.push('>'); - } - - if (element.tagName == 'akap' || element.tagName == 'akap_dialog') { - result.push('\n\n\n'); - } else if (element.tagName == 'rdf:RDF') { - result.push('\n\n\n\n\n'); - } else if (element.tagName.indexOf('dc:') != -1) { - result.push('\n'); - } - - return result; - }; - - - $(function() { - var editor = CodeMirror.fromTextArea('id_text', { - parserfile: 'parsexml.js', - path: "{{ STATIC_URL }}js/lib/codemirror/", - stylesheet: "{{ STATIC_URL }}css/xmlcolors.css", - parserConfig: { - useHTMLKludges: false - }, - textWrapping: true, - tabMode: 'spaces', - indentUnit: 0, - }); - - $('#splitter').splitter({ - type: "v", - outline: true, - minLeft: 480, - sizeRight: 0, - anchorToWindow: true, - resizeToWidth: true, - }); - - $(window).resize(function() { - $('iframe').height($(window).height() - $('#tabs').outerHeight()); - }); - - $(window).resize(); - - $('.vsplitbar').dblclick(function() { - if ($('#sidebar').width() == 0) { - $('#splitter').trigger('resize', [$(window).width() - 480]); - } else { - $('#splitter').trigger('resize', [$(window).width()]); - } - }); - - loadSuccess = function() { - if (this.get('state') != 'loading') { - alert('erroneous state:', this.get('state')); - } - - // prepare text - var doc = null; - - messageCenter.addMessage('success', 'xmlload', 'WczytaÅem HTML :-)'); - } - - function createXSLT(xsl) { - var p = new XSLTProcessor(); - p.importStylesheet(xsl); - return p; - } - - function transform() { - $.ajax({ - url: '{{ STATIC_URL }}xsl/wl2html_client.xsl', - dataType: 'xml', - success: function(data) { - var doc = null; - var parser = new DOMParser(); - var serializer = new XMLSerializer(); - var htmlXSL = createXSLT(data); - - doc = editor.getCode().replace(/\/\s+/g, '<br />'); - doc = parser.parseFromString(doc, 'text/xml'); - console.log('xml', doc); - doc = htmlXSL.transformToFragment(doc, document); - console.log('after transform', doc); - $('#simple-editor').html(doc.firstChild); - }, - error: function() {alert('Error loading XSL!')} - }); - }; - - function reverseTransform () { - $.ajax({ - url: '{{ STATIC_URL }}xsl/html2wl_client.xsl', - dataType: 'xml', - success: function(data) { - var doc = null; - var parser = new DOMParser(); - var serializer = new XMLSerializer(); - var xsl = createXSLT(data); - - doc = serializer.serializeToString($('#simple-editor div').get(0)) - doc = parser.parseFromString(doc, 'text/xml'); - console.log('xml',doc, doc.documentElement); - // TODO: Sprawdzenie bÅÄdów - doc = xsl.transformToDocument(doc); - console.log('after transform', doc, doc.documentElement); - doc = serialize(doc.documentElement).join(''); - // doc = serializer.serializeToString(doc.documentElement) - editor.setCode(doc); - }, - error: function() {alert('Error loading XSL!')} - }); - }; - - $('#save-button').click(function(event) { - event.preventDefault(); - console.log(editor.getCode(), $('form input[name=text]').get(0)); - $('form textarea[name=text]').val(editor.getCode()); - $('form').ajaxSubmit(function() { - alert('UdaÅo siÄ!'); - }); - }); - - $('#simple-view-tab').click(function() { - if ($(this).hasClass('active')) { - return; - } - $(this).addClass('active'); - $('#source-view-tab').removeClass('active'); - $('#source-editor').hide(); - $('#simple-editor').show(); - transform(); - }); - - $('#source-view-tab').click(function() { - if ($(this).hasClass('active')) { - return; - } - $(this).addClass('active'); - $('#simple-view-tab').removeClass('active'); - $('#simple-editor').hide(); - $('#source-editor').show(); - reverseTransform(); - }); - - $('.toolbar button').click(function(event) { - event.preventDefault(); - var params = eval("(" + $(this).attr('ui:action-params') + ")"); - scriptletCenter.scriptlets[$(this).attr('ui:action')](editor, params); - }); - - $('.toolbar select').change(function() { - var slug = $(this).val(); - - $('.toolbar-buttons-container').hide().filter('[data-group=' + slug + ']').show(); - }); - - $('.toolbar-buttons-container').hide(); - $('.toolbar select').change(); - }); + var STATIC_URL = '{{STATIC_URL}}'; </script> - - <style type="text/css" media="screen"> - - body { - margin: 0; - overflow: hidden; - padding: 0; - } - - .vsplitbar { - width: 14px; - background: #EEE url(/static/img/gallery.png) no-repeat scroll center center; - border-left: 1px solid #999; - cursor: col-resize; - } - - .active { - background-color: #DDD; - } - - #simple-editor { - overflow: auto; - height: 100%; - } - - #sidebar { - overflow: auto; -/* padding: 5px; */ - } - - #header { - margin: 0; - padding: 0; - background-color: #C1C1C1; - background-image: -webkit-gradient(linear, left top, left bottom, from(#C1C1C1), color-stop(0.9, #A2A2A2)); - font: 11px Helvetica, Verdana, sans-serif; - font-weight: bold; - } - - #header h1 { - margin: 0; - padding: 0; - font: 17px Helvetica, Verdana, sans-serif; - font-weight: bold; - float: left; - padding: 3px 6px 2px 6px; - color: #222; - } - - #tabs { - margin: 0; - padding: 0; - - width: 100%; - height: 22px; - padding-top: 2px; - border-bottom: 1px solid #777; - } - - #tabs li { - -webkit-user-select: none; - cursor: default; - display: block; - float: left; - padding: 5px 12px 3px 12px; - border: 1px solid #999; - -webkit-border-radius: 4px; - -webkit-border-bottom-left-radius: 0; - -webkit-border-bottom-right-radius: 0; - font-weight: bold; - color: #222; -/* text-shadow: #CCC 1px 1px 1px;*/ - height: 13px; - background-color: #C1C1C1; - -webkit-box-shadow: 1px -1px 2px rgba(127, 127, 127, 0.25); - margin-left: 4px; - margin-bottom: -1px; - } - - #tabs li.active { - background-color: #FEFCDF; - background-image: none; -/* background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0.25, #C1C1C1), to(#FFFFFF)); */ - border-bottom: 1px solid #FEFCDF; - } - - .toolbar { - border-bottom: 1px solid #777; - background-color: #FEFCDF; - margin: 0; - padding: 2px; - } - - .toolbar select { - float: left; - margin: 2px 5px 2px 0; - background: none; - border: 1px solid #999; - padding: 1px; - } - - .toolbar button { - display: block; - float: left; - margin: 4px 0 2px 0; - padding: 0 5px 2px 5px; - border: none; - background: none; - } - - .toolbar-end { - clear: both; - } - - .toolbar button:hover, .toolbar button:active { - background: #A2A2A2; - color: #FFF; - -webkit-border-radius: 10px; - -moz-border-radius: 10px; - border-radius: 10px; - } - - p { margin: 0;} - </style> + <script src="{{STATIC_URL}}js/lib/codemirror/codemirror.js" type="text/javascript" charset="utf-8"></script> + <script src="{{STATIC_URL}}js/jquery.blockui.js" type="text/javascript" charset="utf-8"></script> + <script src="{{STATIC_URL}}js/jquery.autocomplete.js" type="text/javascript" charset="utf-8"></script> + <script src="{{STATIC_URL}}js/jquery.elastic.js" type="text/javascript" charset="utf-8"></script> + <script src="{{STATIC_URL}}js/button_scripts.js" type="text/javascript" charset="utf-8"></script> + <script src="{{STATIC_URL}}js/xslt.js" type="text/javascript" charset="utf-8"></script> + <script src="{{STATIC_URL}}js/main.js" type="text/javascript" charset="utf-8"></script> {% endblock %} {% block maincontent %} - <form action="{% url wiki.views.document_detail document.name|urlencode %}" method="post" accept-charset="utf-8"> + <div id="loading-overlay"> + <div id="loading-message"><img src="{{STATIC_URL}}img/spinner.gif" /><p>Åadowanie</p></div> + </div> + <div id="document-meta" style="display:none"> + {% for k, v in document.meta.items %} + <div class="{{ k }}">{{ v}}</div> + {% endfor %} + </div> <div id="header"> - <div id="tools" style="float: right;">Wersja: {{ document.revision }}<button style="margin-left: 6px" id="save-button">Zapisz</button></div> - <h1>{{ document.name }}</h1> + <div id="tools" style="float: right;">Wersja: <span id="document-revision">{{ document.revision }}</span> <button style="margin-left: 6px" id="save-button">Zapisz</button></div> + <h1>Platforma</h1> <ol id="tabs"> - <li id="simple-view-tab">Widok prosty</li> - <li id="source-view-tab" class="active">Widok zaawansowany</li> + <li id="simple-view-tab"><span id="document-name">{{ document.name }}</span></li> + <li id="source-view-tab" class="active">Kod źródÅowy</li> </ol> <div style="clear: both"></div> </div> @@ -356,20 +39,46 @@ <div id="editor"> <div id="source-editor"> {% toolbar %} - {{ form.text }} + <textarea name="text" id="id_text">{{ document.plain_text }}</textarea> <input type="hidden" name="name" value="{{ document.name }}" /> <input type="hidden" name="author" value="annonymous" /> <input type="hidden" name="comment" value="no comment" /> <input type="hidden" name="revision" value="{{ document.revision }}" /> </div> - <div id="simple-editor" class="htmlview" style="display: none"> + <div id="simple-editor" style="display: none"> + <div class="toolbar"> + <button id="insert-theme-button">Wstaw motyw</button> <button id="insert-annotation-button">Wstaw przypis</button> + <div class="toolbar-end"> </div> + </div> + <div id="html-view" class="htmlview"> + </div> </div> </div> - - <div id="sidebar" style="width: 200px"> - <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> - <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> + <div class="vsplitbar"> </div> + <div id="sidebar"> + <div class="toolbar"> + <button class="previous-page">â½ Poprzednia</button> + <input type="text" size="3" maxlength="3" value="1" class="page-number" /> + <button class="next-page">NastÄpna â¾</button> + <button class="zoom-in">PowiÄksz</button> + <button class="zoom-out">Pomniejsz</button> + <button class="change-gallery">ZmieÅ galeriÄ</button> + <div class="toolbar-end"> </div> + </div> + <div class="toolbar" id="change-gallery-toolbar"> + <input type="text" value="" class="chosen-gallery" /> + <button class="change-gallery-ok">ZmieÅ galeriÄ</button> + <button class="change-gallery-cancel">Anuluj</button> + <div class="toolbar-end"> </div> + </div> + <div class="gallery-image"> + <img src="" /> + </div> </div> </div> - </form> + <div id="save-dialog" style="display: none; text-align: left"> + <label for="komentarz" style="display: block">Opis zmian:</label> + <textarea name="komentarz" id="komentarz" style="display: block; width: 100%"></textarea> + <button id="save-ok">Zapisz</button> <button id="save-cancel">Anuluj</button> + </div> {% endblock %} \ No newline at end of file