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