5bad3c4a0954deb15cf0f9bc9eb9d30e603808c2
[redakcja.git] / project / templates / explorer / file_xml.html
1 {% extends "base.html" %}
2
3 {% block extrahead %}
4     <script src="/static/js/jquery.fieldselection.js" type="text/javascript" charset="utf-8"></script>
5     <script src="/static/js/jquery.lazyload.js" type="text/javascript" charset="utf-8"></script>
6     <script src="/static/js/codemirror/codemirror.js" type="text/javascript" charset="utf-8"></script>
7     <script src="/static/js/jquery.autoscroll.js" type="text/javascript" charset="utf-8"></script>
8     <script type="text/javascript" charset="utf-8">
9         function addEditorButton(label, fn) {
10             $('<button type="button">' + label + '</button>').click(function(event) {
11                 var text = $('#id_text').getSelection().text;
12                 $('#id_text').replaceSelection(fn(text));
13                 event.preventDefault();
14             }).appendTo('#buttons');
15         }
16         
17         $(function() {
18             $('#id_folders').change(function() {
19                 $('#images').load('/images/' + $('#id_folders').val() + '/', function() {
20                     $('#images').data('lastScroll', -1000);
21                 });
22             });
23             
24             function resizePanels() {
25                 $('iframe').width($(window).width() - $('#sidebar').outerWidth());
26                 $('iframe').height($(window).height() - 100);
27                 $('#images-wrap, #toggle-sidebar').height($(window).height() - 100);
28             }
29             
30             $('#toggle-sidebar').toggle(function() {
31                 $('#images-wrap').width(480);
32                 $('#sidebar').width(488);
33                 resizePanels();
34             }, function() {
35                 $('#images-wrap').width(0);
36                 $('#sidebar').width(8);
37                 resizePanels();
38             })
39             
40             $(window).resize(function() {
41                 resizePanels();
42             })
43             
44             var editor = CodeMirror.fromTextArea("id_text", {
45                 parserfile: 'parsexml.js',
46                 path: "/static/js/codemirror/",
47                 stylesheet: "/static/css/xmlcolors.css",
48                 parserConfig: {useHTMLKludges: false}
49             });
50             
51             $('iframe').load(function() {
52                 $('#images').autoscroll('iframe');
53                 
54                 setTimeout(function() {resizePanels();}, 10);
55             })
56             
57             addEditorButton('utwór', function(text) { return '<utwor>' + text + '</utwor>'; });
58             addEditorButton('akap', function(text) { return '<akap>' + text + '</akap>'; });
59             
60             $('#images-wrap').lazyload('.image-box', {threshold: 640 * 10, scrollTreshold: 640 * 5});
61         });
62
63     </script>
64 {% endblock extrahead %}
65
66 {% block breadcrumbs %}<a href="{% url file_list %}">Platforma Redakcyjna</a> ❯ plik {{ hash }}{% endblock breadcrumbs %}
67
68 {% block maincontent %}
69     <div id="tabs"><a href="{% url file_xml hash %}" class="active">Źródło</a><a href="{% url file_html hash %}">HTML</a><div style="clear: both; height: 0; width: 0">&nbsp;</div></div>    
70     
71     <form action="." method="post" accept-charset="utf-8">
72         <div id="panels">
73             <div id="sidebar">
74                 <div id="images-wrap">
75                     <div id="images">
76                         <p>Aby zobaczyć obrazki wybierz folder poniżej:</p>
77                         <p>{{ image_folders_form.folders }}</p>
78                     </div>
79                 </div>
80                 <div id="toggle-sidebar"></div>
81             </div>
82             <textarea id="id_text" name="text" width="480px">{{ form.text.field.initial }}</textarea>
83         </div>
84         
85         <div id="status-bar">
86             {{ form.user.errors }} {{ form.commit_message.errors }}
87             <p>Użytkownik: {{ form.user }} Opis zmian: {{ form.commit_message }} <input type="submit" value="Zapisz"/></p>
88         </div>
89     </form>
90 {% endblock maincontent %}