Dodanie możliwości ustalania skrótów klawiszowych (z CTRL) dla przycisków wstawiający...
[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() {
10             $('#id_folders').change(function() {
11                 $('#images').load('/images/' + $('#id_folders').val() + '/', function() {
12                     $('#images').data('lastScroll', -1000);
13                 });
14             });
15             
16             function resizePanels() {
17                 $('iframe').width($(window).width() - $('#sidebar').outerWidth());
18                 $('iframe').height($(window).height() - 100);
19                 $('#images-wrap, #toggle-sidebar').height($(window).height() - 100);
20             }
21             
22             $('#toggle-sidebar').toggle(function() {
23                 $('#images-wrap').width(480);
24                 $('#sidebar').width(488);
25                 resizePanels();
26             }, function() {
27                 $('#images-wrap').width(0);
28                 $('#sidebar').width(8);
29                 resizePanels();
30             })
31             
32             $(window).resize(function() {
33                 resizePanels();
34             })
35             
36             var editor = CodeMirror.fromTextArea("id_text", {
37                 parserfile: 'parsexml.js',
38                 path: "/static/js/codemirror/",
39                 stylesheet: "/static/css/xmlcolors.css",
40                 parserConfig: {useHTMLKludges: false},
41                 initCallback: function() {
42                     $('#images').autoscroll('iframe');
43                     $('.toggleAutoscroll').toggle(function() {
44                         $(this).html('Synchronizuj przewijanie');
45                         $('#images').disableAutoscroll();
46                     }, function() {
47                         $(this).html('Nie synchronizuj przewijania');
48                         $('#images').enableAutoscroll();
49                     })
50
51                     keys = {}
52                     
53                     function addEditorButton(editor, label, keyCode, fn) {
54                         var handler = function() {
55                             var text = editor.selection();
56                             editor.replaceSelection(fn(text));
57                         }
58                         
59                         keys[keyCode] = handler;
60                         
61                         $('<button type="button">' + label + '</button>').click(function(event) {
62                             event.preventDefault();
63                             handler();
64                         }).appendTo('#buttons');
65                     }
66                     
67                     addEditorButton(editor, 'utwór', 65, function(text) { return '<utwor>' + text + '</utwor>'; });
68                     addEditorButton(editor, 'akap', 83, function(text) { return '<akap>' + text + '</akap>'; });
69                     
70                     editor.grabKeys(function(event) { 
71                         // console.log('handle', event, event.keyCode)
72                         if (keys[event.keyCode]) {
73                             keys[event.keyCode]();
74                         }
75                     }, function(event) { return event.ctrlKey && event.keyCode != 17; });
76
77                     resizePanels();
78                 }
79             });
80
81             $('#images-wrap').lazyload('.image-box', {threshold: 640 * 10, scrollTreshold: 640 * 5});
82         });
83
84     </script>
85 {% endblock extrahead %}
86
87 {% block breadcrumbs %}<a href="{% url file_list %}">Platforma Redakcyjna</a> ❯ plik {{ hash }}{% endblock breadcrumbs %}
88
89 {% block maincontent %}
90     <div id="tabs">
91         <a href="{% url file_xml hash %}" class="active">Źródło</a>
92         <a href="{% url file_html hash %}">HTML</a>
93         <div style="float: left" id="buttons"></div>
94         <div style="clear: both; height: 0; width: 0">&nbsp;</div>
95     </div>
96     
97     <form action="." method="post" accept-charset="utf-8">
98         <div id="panels">
99             <div id="sidebar">
100                 <div id="images-wrap">
101                     <div id="images">
102                         <p>Aby zobaczyć obrazki wybierz folder poniżej:</p>
103                         <p>{{ image_folders_form.folders }}</p>
104                     </div>
105                 </div>
106                 <div id="toggle-sidebar"></div>
107             </div>
108             <textarea id="id_text" name="text" width="480px">{{ form.text.field.initial }}</textarea>
109         </div>
110         
111         <div id="status-bar">
112             {{ form.user.errors }} {{ form.commit_message.errors }}
113             <p>
114                 Użytkownik: {{ form.user }}
115                 Opis zmian: {{ form.commit_message }}
116                 <input type="submit" value="Zapisz"/>
117                 <a href="#" class="toggleAutoscroll" style="float: right">Nie synchronizuj przewijania</a>
118             </p>
119         </div>
120     </form>
121 {% endblock maincontent %}