Merge branch 'master' of git@stigma:platforma
[redakcja.git] / project / templates / explorer / file_xml.html
1 {% extends "base.html" %}
2 {% load toolbar_tags %}
3
4 {% block extrahead %}
5     <script src="/static/js/jquery.fieldselection.js" type="text/javascript" charset="utf-8"></script>
6     <script src="/static/js/jquery.lazyload.js" type="text/javascript" charset="utf-8"></script>
7     <script src="/static/js/codemirror/codemirror.js" type="text/javascript" charset="utf-8"></script>
8     <script src="/static/js/jquery.autoscroll.js" type="text/javascript" charset="utf-8"></script>
9     <script type="text/javascript" charset="utf-8">        
10         $(function() {
11             $('#id_folders').change(function() {
12                 $('#images').load('{% url folder_image_ajax %}' + $('#id_folders').val() + '/', function() {
13                     $('#images').data('lastScroll', -1000);
14                 });
15             });
16             
17             function resizePanels() {
18                 $('iframe').width($(window).width() - $('#sidebar').outerWidth());
19                 $('iframe').height($(window).height() - 100);
20                 $('#images-wrap, #toggle-sidebar').height($(window).height() - 100);
21             }
22             
23             $('#toggle-sidebar').toggle(function() {
24                 $('#images-wrap').width(480);
25                 $('#sidebar').width(488);
26                 resizePanels();
27             }, function() {
28                 $('#images-wrap').width(0);
29                 $('#sidebar').width(8);
30                 resizePanels();
31             })
32             
33             $(window).resize(function() {
34                 resizePanels();
35             })
36             
37             var editor = CodeMirror.fromTextArea("id_text", {
38                 parserfile: 'parsexml.js',
39                 path: "/static/js/codemirror/",
40                 stylesheet: "/static/css/xmlcolors.css",
41                 parserConfig: {useHTMLKludges: false},
42                 initCallback: function() {
43                     $('#images').autoscroll('iframe');
44                     $('.toggleAutoscroll').toggle(function() {
45                         $(this).html('Synchronizuj przewijanie');
46                         $('#images').disableAutoscroll();
47                     }, function() {
48                         $(this).html('Nie synchronizuj przewijania');
49                         $('#images').enableAutoscroll();
50                     })
51                     
52                     // Toolbar
53                     $('#toolbar-tabs li').click(function() {
54                         var id = $(this).attr('p:button-list');
55                         $('#toolbar-tabs li').removeClass('active');
56                         $(this).addClass('active');
57                         if (!$('#' + id).is(':visible')) {
58                             $('#toolbar-buttons ol').not('#' + id).hide();
59                             $('#' + id).show();
60                         }
61                     })
62
63                     var keys = {};
64                     $('#toolbar-buttons li').each(function() {
65                         var tag = $(this).attr('p:tag');
66                         var handler = function() {
67                             var text = editor.selection();
68                             editor.replaceSelection('<' + tag + '>' + text + '</' + tag + '>');
69                             if (text.length == 0) {
70                                 var pos = editor.cursorPosition();
71                                 editor.selectLines(pos.line, pos.character + tag.length + 2);
72                             }
73                         }
74                         if ($(this).attr('p:key')) {
75                             keys[$(this).attr('p:key')] = handler;
76                         }
77                         $(this).click(handler)
78                     });
79                     
80                     editor.grabKeys(function(event) { 
81                         console.log('handle', event, event.keyCode)
82                         if (keys[event.keyCode]) {
83                             keys[event.keyCode]();
84                         }
85                     }, function(event) { return event.ctrlKey && event.keyCode != 17; });
86
87                     resizePanels();
88                 }
89             });
90             
91             $('#images-wrap').lazyload('.image-box', {threshold: 640 * 10, scrollTreshold: 640 * 5});
92         });
93
94     </script>
95 {% endblock extrahead %}
96
97 {% block breadcrumbs %}<a href="{% url file_list %}">Platforma Redakcyjna</a> ❯ plik {{ hash }}{% endblock breadcrumbs %}
98
99 {% block maincontent %}
100     {% toolbar %}
101     
102     <form action="." method="post" accept-charset="utf-8">
103         <div id="panels">
104             <div id="sidebar">
105                 <div id="images-wrap">
106                     <div id="images">
107                         <p>Aby zobaczyć obrazki wybierz folder poniżej:</p>
108                         <p>{{ image_folders_form.folders }}</p>
109                     </div>
110                 </div>
111                 <div id="toggle-sidebar"></div>
112             </div>
113             <textarea id="id_text" name="text" width="480px">{{ form.text.field.initial }}</textarea>
114         </div>
115         
116         <div id="status-bar">
117             {{ form.user.errors }} {{ form.commit_message.errors }}
118             <p>
119                 Użytkownik: {{ form.user }}
120                 Opis zmian: {{ form.commit_message }}
121                 <input type="submit" value="Zapisz"/>
122                 <a href="#" class="toggleAutoscroll" style="float: right">Nie synchronizuj przewijania</a>
123             </p>
124         </div>
125     </form>
126 {% endblock maincontent %}