Oddzielny szablon dla pustej galerii.
authorzuber <marek@stepniowski.com>
Thu, 5 Nov 2009 13:22:48 +0000 (14:22 +0100)
committerzuber <marek@stepniowski.com>
Thu, 5 Nov 2009 13:22:48 +0000 (14:22 +0100)
platforma/static/js/views/gallery.js
platforma/static/js/views/view.js
platforma/templates/explorer/editor.html

index 176b0ab..1808ea1 100644 (file)
@@ -25,12 +25,15 @@ var ImageGalleryView = View.extend({
   },
   
   modelDataChanged: function(property, value) 
   },
   
   modelDataChanged: function(property, value) 
-  {    
-    if( property == 'data')
-    {
-        this.render();
-        this.gotoPage(this.currentPage);        
-    }   
+  {   
+    console.log(this.model.get('state'), value, value.length);
+    if ((this.model.get('state') == 'synced') && (value.length == 0)) {
+      console.log('tutaj');
+      this.render('image-gallery-empty-template');
+    } else {
+      this.render();
+      this.gotoPage(this.currentPage);
+    }
   },
 
   gotoPage: function(index) 
   },
 
   gotoPage: function(index) 
@@ -85,8 +88,11 @@ var ImageGalleryView = View.extend({
   
   modelStateChanged: function(property, value) {   
     if (value == 'loading') {
   
   modelStateChanged: function(property, value) {   
     if (value == 'loading') {
-      // this.freeze('Ładowanie...');
+      this.freeze('Ładowanie...');
     } else {
     } else {
+      if ((value == 'synced') && (this.model.get('data').length == 0)) {
+        this.render('image-gallery-empty-template');
+      }
       this.unfreeze();
     }
   },
       this.unfreeze();
     }
   },
@@ -210,7 +216,7 @@ var ImageGalleryView = View.extend({
         mousedown(this.pageDragStart.bind(this));    
   },
 
         mousedown(this.pageDragStart.bind(this));    
   },
 
-  render: function() 
+  render: function(template
   {
       if(!this.model) return;            
       
   {
       if(!this.model) return;            
       
@@ -225,7 +231,7 @@ var ImageGalleryView = View.extend({
       if(this.$zoomResetButton) this.$zoomResetButton.unbind();
 
       /* render */
       if(this.$zoomResetButton) this.$zoomResetButton.unbind();
 
       /* render */
-      this._super();
+      this._super(template);
 
       /* fetch important parts */
       this.$pageListRoot = $('.image-gallery-page-list', this.element);
 
       /* fetch important parts */
       this.$pageListRoot = $('.image-gallery-page-list', this.element);
index d0c6d17..9441fc5 100644 (file)
@@ -21,9 +21,9 @@ var View = Editor.Object.extend({
         $(this.element).bind('resize', this._resizeHandler);
     },
 
         $(this.element).bind('resize', this._resizeHandler);
     },
 
-    render: function() {
+    render: function(template) {
         console.log('rendering:', this._className);
         console.log('rendering:', this._className);
-        this.element.html(render_template(this.template, this));
+        this.element.html(render_template(template || this.template, this));
     },
   
     frozen: function() {
     },
   
     frozen: function() {
index 2458e8e..7bc9c61 100755 (executable)
         </div>
        </script>
        
         </div>
        </script>
        
+       <script type="text/html" charset="utf-8" id="image-gallery-empty-template">
+           <div class="image-gallery-empty-template">
+            Galeria jest pusta
+        </div>
+       </script>
+       
        <script type="text/html" charset="utf-8" id="button-toolbar-view-template">
                <div class="buttontoolbarview panel-toolbar">
                        <div class="buttontoolbarview-tabs toolbar-tabs-container toolbar-buttons-container">
        <script type="text/html" charset="utf-8" id="button-toolbar-view-template">
                <div class="buttontoolbarview panel-toolbar">
                        <div class="buttontoolbarview-tabs toolbar-tabs-container toolbar-buttons-container">