Dodanie biblioteki jquery.resizable.js pozwalającej na zmianę wielkości paska boczneg...
[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() - 100);
22                 $('#images-wrap, #toggle-sidebar').height($(window).height() - 100);
23                 $('#images-wrap').width($('#sidebar').width() - 8);
24             }
25             
26             $('#toggle-sidebar').toggle(function() {
27                 $('#images-wrap').width(480);
28                 $('#sidebar').width(488);
29                 $('#images-wrap').data('lazyload:lastCheckedScrollTop', -10000);
30                 resizePanels();
31             }, function() {
32                 $('#images-wrap').width(0);
33                 $('#sidebar').width(8);
34                 resizePanels();
35             })
36             
37             $(window).resize(function() {
38                 resizePanels();
39             })
40             
41             var editor = CodeMirror.fromTextArea("id_text", {
42                 parserfile: 'parsexml.js',
43                 path: "/static/js/codemirror/",
44                 stylesheet: "/static/css/xmlcolors.css",
45                 parserConfig: {useHTMLKludges: false},
46                 initCallback: function() {
47                     $('#images').autoscroll('iframe');
48                     $('.toggleAutoscroll').toggle(function() {
49                         $(this).html('Synchronizuj przewijanie');
50                         $('#images').disableAutoscroll();
51                     }, function() {
52                         $(this).html('Nie synchronizuj przewijania');
53                         $('#images').enableAutoscroll();
54                     })
55                     
56                     // Toolbar
57                     $('#toolbar-tabs li').click(function() {
58                         var id = $(this).attr('p:button-list');
59                         $('#toolbar-tabs li').removeClass('active');
60                         $(this).addClass('active');
61                         if (!$('#' + id).is(':visible')) {
62                             $('#toolbar-buttons ol').not('#' + id).hide();
63                             $('#' + id).show();
64                         }
65                     })
66
67                     var keys = {};
68                     $('#toolbar-buttons li').each(function() {
69                         var tag = $(this).attr('p:tag');
70                         var handler = function() {
71                             var text = editor.selection();
72                             editor.replaceSelection('<' + tag + '>' + text + '</' + tag + '>');
73                             if (text.length == 0) {
74                                 var pos = editor.cursorPosition();
75                                 editor.selectLines(pos.line, pos.character + tag.length + 2);
76                             }
77                         }
78                         if ($(this).attr('p:key')) {
79                             keys[$(this).attr('p:key')] = handler;
80                         }
81                         $(this).click(handler)
82                     });
83                     
84                     editor.grabKeys(function(event) { 
85                         if (keys[event.keyCode]) {
86                             keys[event.keyCode]();
87                         }
88                     }, function(event) {
89                         return event.ctrlKey && keys[event.keyCode];
90                     });
91
92                     // $('#sidebar').bind('resizable:resize', resizePanels).resizable('#toggle-sidebar');
93                     
94                     resizePanels();
95                 }
96             });
97             
98             $('#toolbar-buttons li').wTooltip({
99                 delay: 1000, 
100                 style: {
101                     border: "1px solid #7F7D67",
102                     opacity: 0.9, 
103                     background: "#FBFBC6", 
104                     padding: "1px",
105                     fontSize: "12px",
106                 }});
107             
108             $('#images-wrap').lazyload('.image-box', {threshold: 640 * 10, scrollTreshold: 640 * 5});
109         });
110
111     </script>
112 {% endblock extrahead %}
113
114 {% block breadcrumbs %}<a href="{% url file_list %}">Platforma Redakcyjna</a> ❯ plik {{ hash }}{% endblock breadcrumbs %}
115
116 {% block maincontent %}
117     {% toolbar %}
118     
119     <form action="." method="post" accept-charset="utf-8">
120         <div id="panels">
121             <div id="sidebar">
122                 <div id="images-wrap">
123                     <div id="images">
124                         <p>Aby zobaczyć obrazki wybierz folder poniżej:</p>
125                         <p>{{ image_folders_form.folders }}</p>
126                     </div>
127                 </div>
128                 <div id="toggle-sidebar"></div>
129             </div>
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 %}