From: Łukasz Rekucki Date: Tue, 29 Sep 2009 14:13:49 +0000 (+0200) Subject: Merge branch 'master' of stigma:platforma X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/927a991b71d9876995dd2beadee8d9ff16175a50?hp=-c Merge branch 'master' of stigma:platforma --- 927a991b71d9876995dd2beadee8d9ff16175a50 diff --combined project/static/js/models.js index d0de300e,75720a05..62d1c783 --- a/project/static/js/models.js +++ b/project/static/js/models.js @@@ -104,6 -104,7 +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 +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); @@@ -172,48 -174,6 +174,48 @@@ }); +Editor.ImageGalleryModel = Editor.Model.extend({ + _className: 'Editor.ImageGalleryModel', + serverURL: null, + state: 'empty', + + init: function(serverURL) { + this._super(); + this.set('state', 'empty'); + this.serverURL = serverURL; + // olewać data + this.pages = [] + }, + + load: function() { + if (this.get('state') == 'empty') { + this.set('state', 'loading'); + $.ajax({ + url: this.serverURL, + dataType: 'json', + success: this.loadingSucceeded.bind(this) + }); + } + }, + + loadingSucceeded: function(data) { + if (this.get('state') != 'loading') { + alert('erroneous state:', this.get('state')); + } + + this.set('pages', data.pages) + this.set('state', 'synced'); + }, + + set: function(property, value) { + if (property == 'state') { + console.log(this.description(), ':', property, '=', value); + } + return this._super(property, value); + } +}); + + Editor.DocumentModel = Editor.Model.extend({ _className: 'Editor.DocumentModel', data: null, // name, text_url, latest_rev, latest_shared_rev, parts_url, dc_url, size @@@ -243,8 -203,7 +245,8 @@@ this.set('state', 'synced'); this.contentModels = { 'xml': new Editor.XMLModel(data.text_url), - 'html': new Editor.HTMLModel(data.html_url) + 'html': new Editor.HTMLModel(data.html_url), + 'gallery': new Editor.ImageGalleryModel(data.gallery_url) }; for (var key in this.contentModels) { this.contentModels[key].addObserver(this, 'state', this.contentModelStateChanged.bind(this)); @@@ -253,22 -212,47 +255,47 @@@ 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'); + } + } } }, - quickSave: function(message) { + saveDirtyContentModel: function(message) { for (var key in this.contentModels) { if (this.contentModels[key].get('state') == 'dirty') { this.contentModels[key].update(message); break; } } + }, + + update: function() { + + }, + + merge: function() { + + }, + + // For debbuging + set: function(property, value) { + if (property == 'state') { + console.log(this.description(), ':', property, '=', value); + } + return this._super(property, value); } }); diff --combined project/templates/explorer/editor.html index 7cb23a7b,3a64e8d3..de1e2420 --- a/project/templates/explorer/editor.html +++ b/project/templates/explorer/editor.html @@@ -1,12 -1,16 +1,16 @@@ {% extends "base.html" %} {% block extrahead %} + + - + {# Libraries #} + + {# Scriptlets #} @@@ -18,7 -22,6 +22,7 @@@ + @@@ -44,26 -47,6 +48,26 @@@
+ +