From: zuber Date: Sat, 22 Aug 2009 22:08:52 +0000 (+0200) Subject: Merge branch 'master' of git@stigma.nowoczesnapolska.org.pl:platforma X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/275dc6c6f5c92630c9a1fca0f1830ba543cd18b7?hp=3517c7fa3ec165a2650799a8d821d21116789c3b Merge branch 'master' of git@stigma.nowoczesnapolska.org.pl:platforma --- diff --git a/apps/explorer/views.py b/apps/explorer/views.py index 5134eed5..eeac7b65 100644 --- a/apps/explorer/views.py +++ b/apps/explorer/views.py @@ -41,13 +41,30 @@ def file_xml(request, path): }) -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(), +# =============== +# = 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 htmleditor_panel(request, path): + return direct_to_template(request, 'explorer/panels/htmleditor.html', extra_context={ + 'html': html.transform(repo.get_file(path).data(), is_file=False), + }) + + def folder_images(request, folder): return direct_to_template(request, 'explorer/folder_images.html', extra_context={ 'images': models.get_images_from_folder(folder), diff --git a/project/static/css/master.css b/project/static/css/master.css index e7dfb70b..5f567e00 100644 --- a/project/static/css/master.css +++ b/project/static/css/master.css @@ -85,26 +85,40 @@ label { overflow-y: scroll; } -#whatever { - float: left; +/* ========== */ +/* = Panels = */ +/* ========== */ +.panel-wrap { + overflow: hidden; } -#images-wrap { -/* width: 0px;*/ - height: 480px; - overflow-y: scroll; - overflow-x: hidden; - background-color: #fff; +#left-panel-wrap { float: left; + width: 8px; } -#sidebar { - float: left; - width: 8px; + +/* Toolbars with select box to change panel contents*/ +.panel-toolbar { + height: 20px; + padding: 0 0 2px 0; + border-top: 1px solid #AAA; + border-bottom: 1px solid #AAA; + font-size: 12px; + line-height: 20px; + background-color: #DDD; + white-space: nowrap; overflow: hidden; } -#toggle-sidebar { +.panel-toolbar label { + display: block; + float: left; + margin: 0 10px 0 2px; +} + +/* Slider between panels */ +#slider { border-left: 1px solid #999; border-right: 1px solid #999; background-color: #DDD; @@ -113,36 +127,23 @@ label { float: left; } -#toggle-sidebar:hover { +#slider:hover { background-color: #999; cursor: col-resize; } -#status-bar { - border-top: 1px solid #999; - background-color: #EEE; - padding: 2px 10px; -} - -.errorlist { - color: red; - margin: 0 20px 0 0; - padding: 0; - float: left; -} - -.errorlist:before { - content: ''; - clear: both; +/* ================= */ +/* = Gallery panel = */ +/* ================= */ +.images-wrap, .htmleditor { + overflow-x: hidden; + overflow-y: scroll; } -p { - margin: 0; -} -.image-box { - border-top: 1px solid #DDD; -} +/* ==================== */ +/* = XML Editor panel = */ +/* ==================== */ #toolbar { height: 48px; diff --git a/project/static/js/jquery.lazyload.js b/project/static/js/jquery.lazyload.js index 522250ff..c15167bd 100644 --- a/project/static/js/jquery.lazyload.js +++ b/project/static/js/jquery.lazyload.js @@ -23,6 +23,9 @@ } function checkScroll() { + if (container.data('lazyload:lastCheckedScrollTop') == undefined) { + return; + } if (Math.abs(container.scrollTop() - container.data('lazyload:lastCheckedScrollTop')) > settings.scrollThreshold) { container.data('lazyload:lastCheckedScrollTop', container.scrollTop()); diff --git a/project/static/js/jquery.resizable.js b/project/static/js/jquery.resizable.js index 44111ee9..c77c85b4 100644 --- a/project/static/js/jquery.resizable.js +++ b/project/static/js/jquery.resizable.js @@ -38,7 +38,9 @@ }; $(document).mousemove($.resizable.drag).mouseup($.resizable.stop); $('body').css('cursor', 'col-resize'); - }).bind('dragstart', function(event) { event.preventDefault() }); + }).bind('dragstart', function(event) { event.preventDefault(); }) + .bind('drag', function(event) { event.preventDefault(); }) + .bind('draggesture', function(event) { event.preventDefault(); }); }; })(jQuery); diff --git a/project/static/js/panels.js b/project/static/js/panels.js new file mode 100644 index 00000000..abbd2182 --- /dev/null +++ b/project/static/js/panels.js @@ -0,0 +1,143 @@ +function loadPanel(target, url) { + console.log('ajax', url, 'into', target); + $(document).trigger('panel:unload', target); + $.ajax({ + 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); + }, + error: function(request, textStatus, errorThrown) { + console.log('ajax', url, target, 'error:', textStatus, errorThrown); + } + }); +} + +// Funkcja do tworzenia nowych paneli +function panel(load, unload) { + var self = null; + var eventId = Math.ceil(Math.random() * 1000000000); + + unloadHandler = function(event, panel) { + if (self && self == panel) { + 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() { + // ======================== + // = Resizable panels = + // ======================== + 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()); + } + + $(window).resize(function() { + resizePanels(); + }) + + $('#left-panel-wrap').bind('resizable:stop', resizePanels) + .resizable('#slider', {minWidth: 8}); + + resizePanels(); + + $('.panel-toolbar select').change(function() { + loadPanel($('.panel-contents', $(this).parent().parent()), $(this).val()) + }); + // $('#id_folders').change(function() { + // $('#images').load('{% url folder_image_ajax %}' + $('#id_folders').val() + '/', function() { + // $('#images-wrap').data('lazyload:lastCheckedScrollTop', -10000); + // }); + // }); + // + // + + // var editor = CodeMirror.fromTextArea("id_text", { + // parserfile: 'parsexml.js', + // path: "/static/js/codemirror/", + // stylesheet: "/static/css/xmlcolors.css", + // parserConfig: {useHTMLKludges: false}, + // initCallback: function() { + // $('#images').autoscroll('iframe'); + // $('.toggleAutoscroll').toggle(function() { + // $(this).html('Synchronizuj przewijanie'); + // $('#images').disableAutoscroll(); + // }, function() { + // $(this).html('Nie synchronizuj przewijania'); + // $('#images').enableAutoscroll(); + // }) + // + // // Toolbar + // $('#toolbar-tabs li').click(function() { + // var id = $(this).attr('p:button-list'); + // $('#toolbar-tabs li').removeClass('active'); + // $(this).addClass('active'); + // if (!$('#' + id).is(':visible')) { + // $('#toolbar-buttons ol').not('#' + id).hide(); + // $('#' + id).show(); + // } + // }) + // + // var keys = {}; + // $('#toolbar-buttons li').each(function() { + // var tag = $(this).attr('p:tag'); + // var handler = function() { + // var text = editor.selection(); + // editor.replaceSelection('<' + tag + '>' + text + ''); + // if (text.length == 0) { + // var pos = editor.cursorPosition(); + // editor.selectLines(pos.line, pos.character + tag.length + 2); + // } + // } + // if ($(this).attr('p:key')) { + // keys[$(this).attr('p:key')] = handler; + // } + // $(this).click(handler) + // }); + // + // editor.grabKeys(function(event) { + // if (keys[event.keyCode]) { + // keys[event.keyCode](); + // } + // }, function(event) { + // return event.altKey && keys[event.keyCode]; + // }); + // } + // }); + + + + + + // $('#toolbar-buttons li').wTooltip({ + // delay: 1000, + // style: { + // border: "1px solid #7F7D67", + // opacity: 0.9, + // background: "#FBFBC6", + // padding: "1px", + // fontSize: "12px", + // }}); + + // $('#images-wrap').lazyload('.image-box', {threshold: 640 * 10, scrollTreshold: 640 * 5}); +}); diff --git a/project/templates/explorer/file_xml.html b/project/templates/explorer/file_xml.html index 53d536a1..093e3044 100644 --- a/project/templates/explorer/file_xml.html +++ b/project/templates/explorer/file_xml.html @@ -1,5 +1,4 @@ {% extends "base.html" %} -{% load toolbar_tags %} {% block extrahead %} @@ -7,136 +6,43 @@ - + {% endblock extrahead %} {% block breadcrumbs %}Platforma Redakcyjna ❯ plik {{ hash }}{% endblock breadcrumbs %} {% block maincontent %} -
-