Galeria nie wypisuję, że jest nieaktualna, bo zawsze jest aktualna.
authorŁukasz Rekucki <lrekucki@gmail.com>
Fri, 28 Aug 2009 09:43:15 +0000 (11:43 +0200)
committerŁukasz Rekucki <lrekucki@gmail.com>
Fri, 28 Aug 2009 09:43:15 +0000 (11:43 +0200)
apps/explorer/views.py
project/static/css/master.css
project/static/js/editor.js
project/static/js/jquery.hpanel.js
project/templates/explorer/editor.html
project/templates/explorer/panels/dceditor.html
project/templates/explorer/panels/gallery.html
project/templates/explorer/panels/xmleditor.html

index ea03121..896ed09 100644 (file)
@@ -76,7 +76,7 @@ def file_dc(request, path, repo):
 # Display the main editor view
 def display_editor(request, path):
     return direct_to_template(request, 'explorer/editor.html', extra_context={
-        'hash': path,
+        'hash': path, 'panel_list': ['lewy', 'prawy'],
     })
 
 # ===============
index e665a61..1b428fd 100644 (file)
@@ -144,6 +144,10 @@ label {
        right: 0px;
 }
 
+.panel-wrap.last-panel .panel-slider {
+    display: none;
+}
+
 /* Toolbars with select box to change panel contents*/
 .panel-toolbar {
     position: absolute;
index b732810..05232b2 100644 (file)
@@ -19,13 +19,19 @@ function Panel(panelWrap) {
        });
 }
 
-Panel.prototype.callHook = function(hookName) {
+Panel.prototype.callHook = function() {
+    args = $.makeArray(arguments)
+    var hookName = args.splice(0,1)[0]
+    var noHookAction = args.splice(0,1)[0]
+
+       $.log('calling hook: ', hookName, 'with args: ', args);
        if(this.hooks && this.hooks[hookName])
-       {       
-//             arguments.shift();
-               $.log('calling hook: ', hookName, 'with args: ', arguments);
-               return this.hooks[hookName].apply(this, arguments);
+       {               
+               return this.hooks[hookName].apply(this, args);
        }
+    else if (noHookAction instanceof Function)
+        return noHookAction(args);
+    else return false;
 }
 
 Panel.prototype.load = function (url) {
@@ -63,16 +69,20 @@ Panel.prototype.unload = function(event, data) {
 }
 
 Panel.prototype.refresh = function(event, data) {
-       $('.change-notification', this.wrap).fadeOut();
-       $.log('refreshing view for panel ', this.current_url);
-       this.load(this.current_url);
-//     if( this.callHook('refresh') )
+    reload = function() {
+       $.log('hard reload for panel ', this.current_url);
+       this.load(this.current_url);
+        return true;
+    }
+
+    if( this.callHook('refresh', reload) )
+       $('.change-notification', this.wrap).fadeOut();
 } 
 
 Panel.prototype.otherPanelChanged = function(other) {
        $.log('panel ', other, ' changed.');
-       $('.change-notification', this.wrap).fadeIn();
-       this.callHook('dirty');
+       if(!this.callHook('dirty'))
+        $('.change-notification', this.wrap).fadeIn();
 }      
 
 Panel.prototype.markChanged = function () {
@@ -90,7 +100,7 @@ Panel.prototype.unmarkChanged = function () {
 
 Panel.prototype.saveInfo = function() {
        var saveInfo = {};
-       this.callHook('saveInfo', saveInfo);
+       this.callHook('saveInfo', null, saveInfo);
        return saveInfo;
 }
 
@@ -105,6 +115,8 @@ Editor.prototype.setupUI = function() {
        var self = this;
        var panelRoot = $('#panels');
        self.rootDiv = panelRoot;
+    
+    $('*.panel-wrap:last', panelRoot).addClass('last-panel');       
 
     // Set panel widths from options.panelRatios
     if (self.options && self.options.panelRatios) {
@@ -150,6 +162,11 @@ Editor.prototype.setupUI = function() {
         $.log($.toJSON(self.options));
         $.cookie('options', $.toJSON(self.options), { expires: 7, path: '/'});
     });
+
+       $(document).bind('panel:contentChanged', function(event, data) {
+        $('#toolbar-button-save').removeAttr('disabled');
+       });
+
 }
 
 Editor.prototype.loadConfig = function() {
@@ -188,6 +205,7 @@ Editor.prototype.saveToBranch = function() {
                                $.log('save errors: ', data.errors)
                        else 
                                self.refreshPanels(changed_panel);
+            $('#toolbar-button-save').attr('disabled', 'disabled');
                },
                error: function(rq, tstat, err) {
                        $.log('save error', rq, tstat, err);
index abb7a5b..bec82e0 100644 (file)
@@ -43,7 +43,6 @@
     $.fn.makeHorizPanel = function(options) 
        {
                var root = $(this)
-               var all_panels = $('.panel-wrap', root)
 
                /* create an overlay */
                var overlay_root = $("<div class='panel-overlay'></div>");
 
                var prev = null;
 
-               all_panels.each(function(i) {
+               $('*.panel-wrap', root).each( function() 
+        {
                        var panel = $(this);
                        var handle = $('.panel-slider', panel);
-                       var overlay = $("<div class='panel-content-overlay panel-wrap'><p>Panel #"+i+"</p></div>");
+                       var overlay = $("<div class='panel-content-overlay panel-wrap'>&nbsp;</div>");
                        overlay_root.append(overlay);
                        overlay.data('panel', panel);
                        overlay.data('next', null);
 
+                       if (prev) prev.next = overlay;
+
                        if( panel.hasClass('last-panel') )                              
+            {
                                overlay.css({'left': panel.css('left'), 'right': panel.css('right')});
-                       else
+            }
+                       else {
                                overlay.css({'left': panel.css('left'), 'width': panel.css('width')});
-
-                       if (prev) prev.next = overlay;
-
-                       if(handle.length != 0) {
-                               $.log('Has handle: ' + panel.attr('id') );
+                               $.log('Has handle: ' + panel.attr('id'));
                                overlay.append(handle.clone());
                                /* attach the trigger */
                                handle.mousedown(function(event) {
                                        (handle.outerWidth() || 10) + 'px');
                                $('.panel-content-overlay', panel).css('right',
                                        (handle.outerWidth() || 10) + 'px');
-                       }
-                               
+                       };                              
+
                        prev = overlay;
         });
 
-       root.bind('hpanel:panel-resize-start', $.hpanel.resize_start);
+       root.bind('hpanel:panel-resize-start', $.hpanel.resize_start);
     };
 })(jQuery);
 
index 1e0cf30..6632046 100644 (file)
 {% block breadcrumbs %}<a href="{% url file_list %}">Platforma Redakcyjna</a> ❯ plik {{ hash }}{% endblock breadcrumbs %}
 
 {% block header-toolbar %}
-       <button type="button" class="toolbar-button" id="toolbar-button-save">Zapisz</button>
+       <button type="button" class="toolbar-button" id="toolbar-button-save" disabled="disabled">Zapisz</button>
 {% endblock %}
 {% block maincontent %}
         <div id="panels">
-            <div id="left-panel-wrap" class="panel-wrap">
-               <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">
+            {% for n in panel_list %}
+            <div class="panel-wrap" id="panel-{{n}}">
+                <div class="panel-toolbar">
+                    <label for="select-left-panel">{{n|capfirst}} panel:</label>
+                    <select name="select-left-panel" id="panel-{{n}}-select">
                         <option value="{% url xmleditor_panel hash %}">Edytor XML</option>
                         <option value="{% url htmleditor_panel hash %}">Edytor HTML</option>
                         <option value="{% url gallery_panel hash %}">Galeria skanów</option>
                     </select>
                     <strong class="change-notification" style="display: none">Widok nieaktualny!</strong>
                </div>
-               <div id="left-panel-content" class="panel-content"></div>
-               <button type="button" class="panel-slider" id="slider01"></button>
-            </div>
-            <div id="right-panel-wrap" class="panel-wrap last-panel">
-                <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_panel hash %}">Edytor XML</option>
-                        <option value="{% url htmleditor_panel hash %}">Edytor HTML</option>
-                        <option value="{% url gallery_panel hash %}">Galeria skanów</option>
-                        <option value="{% url dceditor_panel hash %}">Edytor DublinCore</option>
-                    </select>
-                    <strong class="change-notification" style="display: none">Widok nieaktualny!</strong>
-                 </div>
-                 <div id="right-panel-content" class="panel-content"></div>
+               <div id="panel-{{n}}-content" class="panel-content"></div>
+               <button type="button" class="panel-slider"></button>
             </div>
+            {% endfor %}
         </div>
 {% endblock maincontent %}    
index 2ca14d4..a82f796 100644 (file)
@@ -16,7 +16,7 @@ panel_hooks = {
                        });
                });
        },
-       saveInfo: function(hn, saveInfo) {
+       saveInfo: function(saveInfo) {
                var myInfo = {
                        url: "{% url file_dc fpath %}", 
                        postData: $('form', this.contentDiv).serialize() 
index 4f5ea91..30c1c83 100644 (file)
@@ -24,6 +24,12 @@ panel_hooks = {
                $('.images-wrap', contentDiv).lazyload('.image-box', 
                        {threshold: 640 * 10, scrollTreshold: 640 * 5}
                );
-       }
+       },
+    refresh: function() {
+        return true; // gallery is always fresh
+    },
+    dirty: function() {
+        return true; // and it doesn't get dirty 
+    }
 };
 </script>
index 2803b6a..7651ffb 100644 (file)
@@ -82,12 +82,11 @@ panel_hooks = {
        },
 
 
-       refresh: function(hn) {
-               // TODO
-               return true;
+       refresh: function() {
+               return false;
        },
 
-       saveInfo: function(hn, saveInfo) {
+       saveInfo: function(saveInfo) {
                var myInfo = {
                        url: "{% url file_xml fpath %}", 
                        postData: {