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