Little js fixes.
authorŁukasz Rekucki <lrekucki@gmail.com>
Fri, 2 Oct 2009 12:13:53 +0000 (14:13 +0200)
committerŁukasz Rekucki <lrekucki@gmail.com>
Fri, 2 Oct 2009 12:13:53 +0000 (14:13 +0200)
project/static/js/app.js
project/static/js/models.js
project/static/js/views/editor.js
project/static/js/views/gallery.js
project/static/js/views/panel_container.js
project/static/js/views/view.js

index 2210654..9de3c7f 100644 (file)
@@ -181,5 +181,4 @@ Editor.Object = Class.extend({
 
 Editor.Object._lastGuid = 0;
 
-
 var panels = [];
index 5c6b36d..0b00c7c 100644 (file)
@@ -406,10 +406,12 @@ $(function()
   toolbarUrl = $('#api-toolbar-url').text();
 
   doc = new Editor.DocumentModel();
-  var editor = new EditorView('#body-wrap', doc);
+  var editor = new EditorView('#body-wrap', doc);  
   editor.freeze();
+
   var flashView = new FlashView('#flashview', messageCenter);
   var splitView = new SplitView('#splitview', doc);
+
   leftPanelView = new PanelContainerView('#left-panel-container', doc);
-  rightPanelContainer = new PanelContainerView('#right-panel-container', doc);
+  rightPanelContainer = new PanelContainerView('#right-panel-container', doc); 
 });
index e9e62e9..10c77f6 100644 (file)
@@ -7,7 +7,6 @@ var EditorView = View.extend({
   
   init: function(element, model, template) {
     this._super(element, model, template);
-    this.model.load();
     
     this.quickSaveButton = $('#action-quick-save', this.element).bind('click.editorview', this.quickSave.bind(this));
     this.commitButton = $('#action-commit', this.element).bind('click.editorview', this.commit.bind(this));
@@ -16,7 +15,7 @@ var EditorView = View.extend({
     
     this.model.addObserver(this, 'state', this.modelStateChanged.bind(this));
     this.modelStateChanged('state', this.model.get('state'));
-    
+      
     // Inicjalizacja okien jQuery Modal
     $('#commit-dialog', this.element).
     jqm({
@@ -34,6 +33,8 @@ var EditorView = View.extend({
     //      onShow: $.fbind(self, self.loadSplitDialog)
     //  }).
     //  jqmAddClose('button.dialog-close-button');
+    
+    this.model.load();
   },
   
   quickSave: function(event) {
index fe54b93..7449344 100644 (file)
@@ -12,6 +12,8 @@ var ImageGalleryView = View.extend({
     console.log("init for gallery");
     this._super(element, model, template);
     this.parent = parent;
+
+    console.log("galley model", this.model);
        
     this.model
       .addObserver(this, 'data', this.modelDataChanged.bind(this))
@@ -207,7 +209,7 @@ var ImageGalleryView = View.extend({
 
   render: function() 
   {
-      console.log('rendering:', this._className);
+      if(!this.model) return;            
       
       /* first unbind all */    
       if(this.$nextButton) this.$nextButton.unbind();
@@ -220,7 +222,7 @@ var ImageGalleryView = View.extend({
       if(this.$zoomResetButton) this.$zoomResetButton.unbind();
 
       /* render */
-      this.element.html(render_template(this.template, this));
+      this._super();
 
       /* fetch important parts */
       this.$pageListRoot = $('.image-gallery-page-list', this.element);
index af067a3..6dbddd9 100644 (file)
@@ -19,6 +19,7 @@ var PanelContainerView = View.extend({
   selectChanged: function(event) {
     var value = $('select', this.element.get(0)).val();
     var klass = panels[value];
+
     if (this.contentView) {
       this.contentView.dispose();
       this.contentView = null;
@@ -27,7 +28,7 @@ var PanelContainerView = View.extend({
     if( value != 'empty') {
     this.contentView = new klass($('.content-view', 
       this.element.get(0)), this.model.contentModels[value], this);
-    $('.panel-main-toolbar .refresh', this.element.get(0)).attr('disabled', null);
+    $('.panel-main-toolbar .refresh', this.element.get(0)).attr('disabled', null);    
     }
   },
   
index bc8266c..e9ff938 100644 (file)
@@ -1,89 +1,90 @@
 /*globals Editor render_template*/
 var View = Editor.Object.extend({
-  _className: 'View',
-  element: null,
-  model: null,
-  template: null,
-  overlayClass: 'view-overlay',
-  overlay: null,
+    _className: 'View',
+    element: null,
+    model: null,
+    template: null,
+    overlayClass: 'view-overlay',
+    overlay: null,
   
-  init: function(element, model, template) 
-  {
-    console.log("init for view");
-    this.element = $(element);
-    this.model = model;
-    this.template = template || this.template;
+    init: function(element, model, template)
+    {
+        console.log("init for view");
+        this.element = $(element);
+        this.model = model;
+        this.template = template || this.template;
     
-    if (this.template) this.render();
+        if (this.template) this.render();
     
-    this._resizeHandler = this.resized.bind(this);
-    $(window).bind('resize', this._resizeHandler);
-    $(this.element).bind('resize', this._resizeHandler);
-  },
+        this._resizeHandler = this.resized.bind(this);
+        $(window).bind('resize', this._resizeHandler);
+        $(this.element).bind('resize', this._resizeHandler);
+    },
 
-  render: function() {
-      console.log('rendering:', this._className);
-      this.element.html(render_template(this.template, this));
-  },
+    render: function() {
+        console.log('rendering:', this._className);
+        this.element.html(render_template(this.template, this));
+    },
   
-  frozen: function() {
-    return !!this.overlay;
-  },
+    frozen: function() {
+        return !!this.overlay;
+    },
   
-  freeze: function(message) {
-    if (this.frozen()) {
-      this.unfreeze();
-    }
-    this.overlay = this.overlay 
-      || $('<div><div>' + message + '</div></div>')
-            .addClass(this.overlayClass)
-            .css({
-              position: 'absolute',
-              width: this.element.width(),
-              height: this.element.height(),
-              top: this.element.position().top,
-              left: this.element.position().left,
-              'user-select': 'none',
-              '-webkit-user-select': 'none',
-              '-khtml-user-select': 'none',
-              '-moz-user-select': 'none',
-              overflow: 'hidden'
-            })
-            .attr('unselectable', 'on')
-            .appendTo(this.element.parent());
+    freeze: function(message) {
+        if (this.frozen()) {
+            this.unfreeze();
+        }
+        this.overlay = this.overlay
+        || $('<div><div>' + message + '</div></div>')
+        .addClass(this.overlayClass)
+        .css({
+            position: 'absolute',
+            width: this.element.width(),
+            height: this.element.height(),
+            top: this.element.position().top,
+            left: this.element.position().left,
+            'user-select': 'none',
+            '-webkit-user-select': 'none',
+            '-khtml-user-select': 'none',
+            '-moz-user-select': 'none',
+            overflow: 'hidden'
+        })
+        .attr('unselectable', 'on')
+        .appendTo(this.element.parent());
             
-    this.overlay.children('div').css({
-      position: 'relative',
-      top: this.overlay.height() / 2 - 20
-    });
-  },
+        this.overlay.children('div').css({
+            position: 'relative',
+            top: this.overlay.height() / 2 - 20
+        });
+    },
   
-  unfreeze: function() {
-    if (this.frozen()) {
-      this.overlay.remove();
-      this.overlay = null;      
-    }
-  },
+    unfreeze: function() {
+        if (this.frozen()) {
+            this.overlay.remove();
+            this.overlay = null;
+        }
+    },
 
-  resized: function(event) {
-    if (this.frozen()) {
-      this.overlay.css({
-        position: 'absolute',
-        width: this.element.width(),
-        height: this.element.height(),
-        top: this.element.position().top,
-        left: this.element.position().left
-      }).children('div').css({
-        position: 'relative',
-        top: this.overlay.height() / 2 - 20
-      });
-    }
-  },
+    resized: function(event) {
+        if (this.frozen()) {
+            this.overlay.css({
+                position: 'absolute',
+                width: this.element.width(),
+                height: this.element.height(),
+                top: this.element.position().top,
+                left: this.element.position().left
+            }).children('div').css({
+                position: 'relative',
+                top: this.overlay.height() / 2 - 20
+            });
+        }
+    },
   
-  dispose: function() {
-    $(window).unbind('resize', this._resizeHandler);
-    $(this.element).unbind('resize', this._resizeHandler);
-    this.unfreeze();
-    this.element.contents().remove();
-  }
+    dispose: function() {
+        console.log('disposing:', this._className);
+        $(window).unbind('resize', this._resizeHandler);
+        $(this.element).unbind('resize', this._resizeHandler);
+        this.unfreeze();
+        this.element.html('');
+    }
 });