From 320fd24b68185b73f1180c425271e037331baa46 Mon Sep 17 00:00:00 2001 From: zuber Date: Tue, 29 Sep 2009 12:13:35 +0200 Subject: [PATCH] =?utf8?q?Usuni=C4=99cie=20niepotrzebnych=20console.log=20?= =?utf8?q?(teraz=20=C5=9Bledzimy=20tylko=20stany=20modeli)=20i=20dodanie?= =?utf8?q?=20wi=C4=99kszej=20ilo=C5=9Bci=20stan=C3=B3w=20do=20EditorModel.?= =?utf8?q?=20Ustawianie=20styl=C3=B3w=20przycisk=C3=B3w=20zgodnie=20ze=20s?= =?utf8?q?tanami=20EditorModel.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- project/static/js/models.js | 23 ++++++++++++++++-- project/static/js/views/editor.js | 40 +++++++++++++++++++++++++------ project/static/js/views/xml.js | 1 - 3 files changed, 54 insertions(+), 10 deletions(-) diff --git a/project/static/js/models.js b/project/static/js/models.js index 9542eac5..8ea488e1 100644 --- a/project/static/js/models.js +++ b/project/static/js/models.js @@ -104,6 +104,7 @@ Editor.XMLModel = Editor.Model.extend({ this.set('state', 'dirty'); }, + // For debbuging set: function(property, value) { if (property == 'state') { console.log(this.description(), ':', property, '=', value); @@ -162,7 +163,8 @@ Editor.HTMLModel = Editor.Model.extend({ this.set('data', data); this.set('state', 'synced'); }, - + + // For debbuging set: function(property, value) { if (property == 'state') { console.log(this.description(), ':', property, '=', value); @@ -210,12 +212,21 @@ Editor.DocumentModel = Editor.Model.extend({ contentModelStateChanged: function(property, value, contentModel) { if (value == 'dirty') { + this.set('state', 'dirty'); for (var key in this.contentModels) { if (this.contentModels[key].guid() != contentModel.guid()) { - // console.log(this.contentModels[key].description(), 'frozen'); this.contentModels[key].set('state', 'unsynced'); } } + } else if (value == 'updated') { + this.set('state', 'synced'); + for (key in this.contentModels) { + if (this.contentModels[key].guid() == contentModel.guid()) { + this.contentModels[key].set('state', 'synced'); + } else if (this.contentModels[key].get('state') == 'unsynced') { + this.contentModels[key].set('state', 'empty'); + } + } } }, @@ -226,6 +237,14 @@ Editor.DocumentModel = Editor.Model.extend({ break; } } + }, + + // For debbuging + set: function(property, value) { + if (property == 'state') { + console.log(this.description(), ':', property, '=', value); + } + return this._super(property, value); } }); diff --git a/project/static/js/views/editor.js b/project/static/js/views/editor.js index 27b17cbf..1e39ca56 100644 --- a/project/static/js/views/editor.js +++ b/project/static/js/views/editor.js @@ -9,29 +9,55 @@ var EditorView = View.extend({ this._super(element, model, template); this.model.load(); - $('#action-quick-save', this.element).bind('click.editorview', this.quickSave.bind(this)); - $('#action-commit', this.element).bind('click.editorview', this.commit.bind(this)); - $('#action-update', this.element).bind('click.editorview', this.update.bind(this)); - this.freeze('Ładowanie'); + 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)); + this.updateButton = $('#action-update', this.element).bind('click.editorview', this.update.bind(this)); + this.mergeButton = $('#action-merge', this.element).bind('click.editorview', this.merge.bind(this)); + + this.model.addObserver(this, 'state', this.modelStateChanged.bind(this)); + this.modelStateChanged('state', this.model.get('state')); }, quickSave: function(event) { - console.log('quickSave'); this.model.quickSave(); }, commit: function(event) { - console.log('commit'); }, update: function(event) { - console.log('update'); + }, + + merge: function(event) { + }, + + modelStateChanged: function(property, value) { + // Uaktualnia stan przycisków + if (value == 'dirty') { + this.quickSaveButton.attr('disabled', null); + this.commitButton.attr('disabled', null); + this.updateButton.attr('disabled', 'disabled'); + this.mergeButton.attr('disabled', 'disabled'); + } else if (value == 'synced') { + this.quickSaveButton.attr('disabled', 'disabled'); + this.commitButton.attr('disabled', 'disabled'); + this.updateButton.attr('disabled', null); + this.mergeButton.attr('disabled', null); + } else if (value == 'empty') { + this.quickSaveButton.attr('disabled', 'disabled'); + this.commitButton.attr('disabled', 'disabled'); + this.updateButton.attr('disabled', 'disabled'); + this.mergeButton.attr('disabled', 'disabled'); + } }, dispose: function() { $('#action-quick-save', this.element).unbind('click.editorview'); $('#action-commit', this.element).unbind('click.editorview'); $('#action-update', this.element).unbind('click.editorview'); + $('#action-merge', this.element).unbind('click.editorview'); + + this.model.removeObserver(this); this._super(); } }); diff --git a/project/static/js/views/xml.js b/project/static/js/views/xml.js index 6b7571a3..8af3c4d4 100644 --- a/project/static/js/views/xml.js +++ b/project/static/js/views/xml.js @@ -58,7 +58,6 @@ var XMLView = View.extend({ }, modelDataChanged: function(property, value) { - console.log('modelDataChanged'); if (this.editor.getCode() != value) { this.editor.setCode(value); } -- 2.20.1