From: Ɓukasz Rekucki Date: Fri, 2 Oct 2009 12:13:53 +0000 (+0200) Subject: Little js fixes. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/17ea853baef7703291df8ae230a2aa433f8f5656?ds=inline Little js fixes. --- diff --git a/project/static/js/app.js b/project/static/js/app.js index 2210654b..9de3c7f0 100644 --- a/project/static/js/app.js +++ b/project/static/js/app.js @@ -181,5 +181,4 @@ Editor.Object = Class.extend({ Editor.Object._lastGuid = 0; - var panels = []; diff --git a/project/static/js/models.js b/project/static/js/models.js index 5c6b36d4..0b00c7ce 100644 --- a/project/static/js/models.js +++ b/project/static/js/models.js @@ -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); }); diff --git a/project/static/js/views/editor.js b/project/static/js/views/editor.js index e9e62e99..10c77f63 100644 --- a/project/static/js/views/editor.js +++ b/project/static/js/views/editor.js @@ -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) { diff --git a/project/static/js/views/gallery.js b/project/static/js/views/gallery.js index fe54b933..74493444 100644 --- a/project/static/js/views/gallery.js +++ b/project/static/js/views/gallery.js @@ -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); diff --git a/project/static/js/views/panel_container.js b/project/static/js/views/panel_container.js index af067a3d..6dbddd98 100644 --- a/project/static/js/views/panel_container.js +++ b/project/static/js/views/panel_container.js @@ -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); } }, diff --git a/project/static/js/views/view.js b/project/static/js/views/view.js index bc8266c1..e9ff938e 100644 --- a/project/static/js/views/view.js +++ b/project/static/js/views/view.js @@ -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 - || $('
' + message + '
') - .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 + || $('
' + message + '
') + .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(''); + } });