Naprawione galerie.
authorŁukasz Rekucki <lrekucki@gmail.com>
Fri, 16 Oct 2009 11:23:46 +0000 (13:23 +0200)
committerŁukasz Rekucki <lrekucki@gmail.com>
Fri, 16 Oct 2009 11:23:46 +0000 (13:23 +0200)
apps/api/handlers/library_handlers.py
platforma/static/js/models.js
platforma/static/js/views/gallery.js

index 607ac95..f533d0e 100644 (file)
@@ -363,7 +363,7 @@ class DocumentGalleryHandler(BaseHandler):
 #            gallery['pages'].sort()
             galleries.append(gallery)
 
-        return galleries                      
+        return galleries
 
 #
 # Document Text View
index fe42e89..c57f4f0 100644 (file)
@@ -347,7 +347,7 @@ Editor.ImageGalleryModel = Editor.Model.extend({
     data: [],
     state: 'empty',
 
-    init: function(serverURL) {
+    init: function(document, serverURL) {
         this._super();
         this.set('state', 'empty');
         this.serverURL = serverURL;
@@ -357,16 +357,22 @@ Editor.ImageGalleryModel = Editor.Model.extend({
 
     load: function(force) {
         if (force || this.get('state') == 'empty') {
+            console.log("setting state");
             this.set('state', 'loading');
+            console.log("going ajax");
             $.ajax({
                 url: this.serverURL,
                 dataType: 'json',
-                success: this.loadingSucceeded.bind(this)
+                success: this.loadingSucceeded.bind(this),
+                error: this.loadingFailed.bind(this)
             });
         }
     },
 
-    loadingSucceeded: function(data) {
+    loadingSucceeded: function(data) 
+    {
+        console.log("success");        
+        
         if (this.get('state') != 'loading') {
             alert('erroneous state:', this.get('state'));
         }
@@ -382,6 +388,16 @@ Editor.ImageGalleryModel = Editor.Model.extend({
         this.set('state', 'synced');
     },
 
+    loadingFailed: function(data) {
+        console.log("failed");
+
+        if (this.get('state') != 'loading') {
+            alert('erroneous state:', this.get('state'));
+        }       
+
+        this.set('state', 'error');
+    },
+
     set: function(property, value) {
         if (property == 'state') {
             console.log(this.description(), ':', property, '=', value);
index 7449344..e0e3dc7 100644 (file)
@@ -13,7 +13,7 @@ var ImageGalleryView = View.extend({
     this._super(element, model, template);
     this.parent = parent;
 
-    console.log("galley model", this.model);
+    console.log("gallery model", this.model);
        
     this.model
       .addObserver(this, 'data', this.modelDataChanged.bind(this))
@@ -85,9 +85,9 @@ var ImageGalleryView = View.extend({
   
   modelStateChanged: function(property, value) {   
     if (value == 'loading') {
-      this.parent.freeze('Ładowanie...');
+      // this.freeze('Ładowanie...');
     } else {
-      this.parent.unfreeze();
+      this.unfreeze();
     }
   },
 
@@ -102,8 +102,7 @@ var ImageGalleryView = View.extend({
     $page.hide();
     $('img', $page).unbind();
     
-    $page.empty();
-    
+    $page.empty();    
     this.setPageViewOffset($page, {x:0, y:0});
   },