- Dodanie panelu z galerią skanów.
})
+# ===============
+# = Panel views =
+# ===============
+def xmleditor_panel(request, path):
+ form = forms.BookForm()
+ text = repo.get_file(path).data()
+
+ return direct_to_template(request, 'explorer/panels/xmleditor.html', extra_context={
+ 'text': text,
+ })
+
+
+def gallery_panel(request, path):
+ return direct_to_template(request, 'explorer/panels/gallery.html', extra_context={
+ 'form': forms.ImageFoldersForm(),
+ })
+
+
def file_html(request, path):
return direct_to_template(request, 'explorer/file_html.html', extra_context={
'object': html.transform(repo.get_file(path).data(), is_file=False),
'hash': path,
'image_folders_form': forms.ImageFoldersForm(),
})
-
+
+
def folder_images(request, folder):
return direct_to_template(request, 'explorer/folder_images.html', extra_context={
'images': models.get_images_from_folder(folder),
/* = Panels = */
/* ========== */
.panel-wrap {
- position: relative;
overflow: hidden;
}
background-color: #999;
cursor: col-resize;
}
+
+/* ================= */
+/* = Gallery panel = */
+/* ================= */
+.images-wrap {
+ overflow-x: hidden;
+ overflow-y: scroll;
+}
+
url: url,
dataType: 'html',
success: function(data, textStatus) {
+ console.log(target, 'ajax success');
$(target).html(data);
+ console.log(target, 'triggering panel:load');
$(document).trigger('panel:load', target);
// panel(target);
},
unloadHandler = function(event, panel) {
if (self && self == panel) {
- $(document).unbind('panel:unload.' + eventId, unloadHandler);
+ console.log('Panel', panel, 'unloading');
+ $(document).unbind('panel:unload.' + eventId);
+ $(panel).html('');
unload(event, panel);
+ console.log('Panel', panel, 'unloaded');
+ return false;
}
};
$(document).one('panel:load', function(event, panel) {
self = panel;
+ console.log('Panel', panel, 'loading');
$(document).bind('panel:unload.' + eventId, unloadHandler);
load(event, panel);
+ console.log('Panel', panel, 'loaded');
});
}
// ========================
function resizePanels() {
$('.panel').height($(window).height() - $('.panel').position().top);
+ $('.panel-contents').height($(window).height() - $('.panel-contents').position().top);
$('#right-panel-wrap').width($(window).width() - $('#left-panel-wrap').outerWidth());
}
<div id="left-panel-toolbar" class="panel-toolbar">
<label for="select-left-panel">Lewy panel:</label>
<select name="select-left-panel" id="select-left-panel">
- <option value="{% url xmleditor %}">Edytor XML</option>
- <option value="panel2">Panel 2</option>
+ <option value="{% url xmleditor_panel hash %}">Edytor XML</option>
+ <option value="{% url gallery_panel hash %}">Galeria skanów</option>
</select>
</div>
<div id="left-panel-contents" class="panel-contents">
<div id="right-panel-toolbar" class="panel-toolbar">
<label for="select-right-panel">Prawy panel:</label>
<select name="select-right-panel" id="select-right-panel">
- <option value="{% url xmleditor %}">Edytor XML</option>
- <option value="panel2">Panel 2</option>
+ <option value="{% url xmleditor_panel hash %}">Edytor XML</option>
+ <option value="{% url gallery_panel hash %}">Galeria skanów</option>
</select>
</div>
<div id="right-panel-contents" class="panel-contents">
--- /dev/null
+<div class="panel">
+ <div class="images-wrap">
+ <div class="images">
+ <p>Aby zobaczyć obrazki wybierz folder poniżej:</p>
+ <p><select name="folders" class="id_folders">
+ <option value="" selected="selected">-- Wybierz folder z obrazkami --</option>
+ <option value="andersen_basnie">andersen_basnie</option>
+ </select></p>
+ </div>
+ </div>
+</div>
+<script type="text/javascript" charset="utf-8">
+ (function() {
+ function resizeEditor(event, panel) {
+ var panel = panel || event.data.panel;
+ $('.images-wrap', panel).height($(panel).height());
+ }
+
+ panel(function(event, panel) {
+ $('.id_folders', panel).change(function() {
+ $('.images', panel).load('{% url folder_image_ajax %}' + $('.id_folders', panel).val() + '/', function() {
+ $('.images-wrap', panel).data('lazyload:lastCheckedScrollTop', -10000);
+ });
+ });
+ $('.images-wrap', panel).lazyload('.image-box', {threshold: 640 * 10, scrollTreshold: 640 * 5});
+
+ $(window).bind('resize', {'panel': panel}, resizeEditor);
+ resizeEditor(null, panel);
+ }, function(event, panel) {
+ console.log('unloaded gallery panel', panel);
+ });
+ })()
+</script>
<div class="panel">
- <textarea name="text" width="480px"><ala><ma></ma></ala></textarea>
+ <textarea name="text" width="480px">{{ text }}</textarea>
</div>
<script type="text/javascript" charset="utf-8">
- panel(function(event, panel) {
- console.log('loading panel', panel);
- var textareaId = 'xmleditor-' + Math.ceil(Math.random() * 1000000000);
- $('textarea', panel).attr('id', textareaId);
- var editor = CodeMirror.fromTextArea(textareaId, {
- parserfile: 'parsexml.js',
- path: "/static/js/codemirror/",
- stylesheet: "/static/css/xmlcolors.css",
- parserConfig: {useHTMLKludges: false},
- initCallback: function() {}
+ (function() {
+ function resizeEditor(event, panel) {
+ var panel = panel || event.data.panel;
+ $('iframe', panel).height($(panel).height());
+ }
+
+ panel(function(event, panel) {
+ console.log('loading panel', panel);
+ var textareaId = 'xmleditor-' + Math.ceil(Math.random() * 1000000000);
+ $('textarea', panel).attr('id', textareaId);
+ var editor = CodeMirror.fromTextArea(textareaId, {
+ parserfile: 'parsexml.js',
+ path: "/static/js/codemirror/",
+ stylesheet: "/static/css/xmlcolors.css",
+ parserConfig: {useHTMLKludges: false},
+ initCallback: function() {}
+ })
+ $(window).bind('resize', {'panel': panel}, resizeEditor);
+ resizeEditor(null, panel);
+ }, function(event, panel) {
+ console.log('unloaded xmleditor panel', panel);
})
- }, function(event, panel) {
- console.log('unloaded panel', panel);
- })
+ })();
</script>
url(r'^images/(?P<folder>[^/]+)/$', 'explorer.views.folder_images', name='folder_image'),
url(r'^images/$', 'explorer.views.folder_images', {'folder': '.'}, name='folder_image_ajax'),
- url(r'^panels/xmleditor$', 'django.views.generic.simple.direct_to_template',
- {'template': 'explorer/panels/xmleditor.html'}, name='xmleditor'),
+ # Editor panels
+ url(r'^editor/(?P<path>[^/]+)/panels/xmleditor$', 'explorer.views.xmleditor_panel', name='xmleditor_panel'),
+ url(r'^editor/(?P<path>[^/]+)/panels/gallery$', 'explorer.views.gallery_panel', name='gallery_panel'),
+
# Admin panel
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/(.*)', admin.site.root),