fnp
/
redakcja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Dodanie restartowania serwera do fabfile.
[redakcja.git]
/
project
/
static
/
js
/
models.js
diff --git
a/project/static/js/models.js
b/project/static/js/models.js
index
c333a97
..
3cd98f6
100644
(file)
--- a/
project/static/js/models.js
+++ b/
project/static/js/models.js
@@
-1,7
+1,4
@@
/*globals Editor fileId SplitView PanelContainerView EditorView FlashView messageCenter*/
/*globals Editor fileId SplitView PanelContainerView EditorView FlashView messageCenter*/
-var documentsUrl = '/api/documents/';
-
-
Editor.Model = Editor.Object.extend({
synced: false,
data: null
Editor.Model = Editor.Object.extend({
synced: false,
data: null
@@
-9,8
+6,7
@@
Editor.Model = Editor.Object.extend({
Editor.ToolbarButtonsModel = Editor.Model.extend({
Editor.ToolbarButtonsModel = Editor.Model.extend({
- _className: 'Editor.ToolbarButtonsModel',
- serverURL: '/api/toolbar/buttons',
+ className: 'Editor.ToolbarButtonsModel',
buttons: {},
init: function() {
buttons: {},
init: function() {
@@
-20,7
+16,7
@@
Editor.ToolbarButtonsModel = Editor.Model.extend({
load: function() {
if (!this.get('buttons').length) {
$.ajax({
load: function() {
if (!this.get('buttons').length) {
$.ajax({
- url: t
his.serverURL
,
+ url: t
oolbarUrl
,
dataType: 'json',
success: this.loadSucceeded.bind(this)
});
dataType: 'json',
success: this.loadSucceeded.bind(this)
});
@@
-56,9
+52,10
@@
Editor.XMLModel = Editor.Model.extend({
this.addObserver(this, 'data', this.dataChanged.bind(this));
},
this.addObserver(this, 'data', this.dataChanged.bind(this));
},
- load: function() {
- if (this.get('state') == 'empty') {
+ load: function(
force
) {
+ if (
force ||
this.get('state') == 'empty') {
this.set('state', 'loading');
this.set('state', 'loading');
+ messageCenter.addMessage('info', 'Wczytuję XML...');
$.ajax({
url: this.serverURL,
dataType: 'text',
$.ajax({
url: this.serverURL,
dataType: 'text',
@@
-77,6
+74,7
@@
Editor.XMLModel = Editor.Model.extend({
}
this.set('data', data);
this.set('state', 'synced');
}
this.set('data', data);
this.set('state', 'synced');
+ messageCenter.addMessage('success', 'Wczytałem XML :-)');
},
loadingFailed: function() {
},
loadingFailed: function() {
@@
-85,11
+83,13
@@
Editor.XMLModel = Editor.Model.extend({
}
this.set('error', 'Nie udało się załadować panelu');
this.set('state', 'error');
}
this.set('error', 'Nie udało się załadować panelu');
this.set('state', 'error');
+ messageCenter.addMessage('error', 'Nie udało mi się wczytać XML. Spróbuj ponownie :-(');
},
update: function(message) {
if (this.get('state') == 'dirty') {
this.set('state', 'updating');
},
update: function(message) {
if (this.get('state') == 'dirty') {
this.set('state', 'updating');
+ messageCenter.addMessage('info', 'Zapisuję XML...');
var payload = {
contents: this.get('data'),
var payload = {
contents: this.get('data'),
@@
-118,13
+118,14
@@
Editor.XMLModel = Editor.Model.extend({
}
this.set('revision', data.revision);
this.set('state', 'updated');
}
this.set('revision', data.revision);
this.set('state', 'updated');
+ messageCenter.addMessage('success', 'Zapisałem XML :-)');
},
updatingFailed: function() {
if (this.get('state') != 'updating') {
alert('erroneous state:', this.get('state'));
}
},
updatingFailed: function() {
if (this.get('state') != 'updating') {
alert('erroneous state:', this.get('state'));
}
- messageCenter.addMessage('error', '
Uaktualnienie nie powiodło się', 'Uaktualnienie nie powiodło się
');
+ messageCenter.addMessage('error', '
Nie udało mi się zapisać XML. Spróbuj ponownie :-(
');
this.set('state', 'dirty');
},
this.set('state', 'dirty');
},
@@
-162,9
+163,10
@@
Editor.HTMLModel = Editor.Model.extend({
this.serverURL = serverURL;
},
this.serverURL = serverURL;
},
- load: function() {
- if (this.get('state') == 'empty') {
+ load: function(
force
) {
+ if (
force ||
this.get('state') == 'empty') {
this.set('state', 'loading');
this.set('state', 'loading');
+ messageCenter.addMessage('info', 'Wczytuję HTML...');
$.ajax({
url: this.serverURL,
dataType: 'text',
$.ajax({
url: this.serverURL,
dataType: 'text',
@@
-181,6
+183,7
@@
Editor.HTMLModel = Editor.Model.extend({
}
this.set('data', data);
this.set('state', 'synced');
}
this.set('data', data);
this.set('state', 'synced');
+ messageCenter.addMessage('success', 'Wczytałem HTML :-)');
},
loadingFailed: function() {
},
loadingFailed: function() {
@@
-189,6
+192,7
@@
Editor.HTMLModel = Editor.Model.extend({
}
this.set('error', 'Nie udało się załadować panelu');
this.set('state', 'error');
}
this.set('error', 'Nie udało się załadować panelu');
this.set('state', 'error');
+ messageCenter.addMessage('error', 'Nie udało mi się wczytać HTML. Spróbuj ponownie :-(');
},
// For debbuging
},
// For debbuging
@@
-215,8
+219,8
@@
Editor.ImageGalleryModel = Editor.Model.extend({
this.pages = [];
},
this.pages = [];
},
- load: function() {
- if (this.get('state') == 'empty') {
+ load: function(
force
) {
+ if (
force ||
this.get('state') == 'empty') {
this.set('state', 'loading');
$.ajax({
url: this.serverURL,
this.set('state', 'loading');
$.ajax({
url: this.serverURL,
@@
-267,6
+271,7
@@
Editor.DocumentModel = Editor.Model.extend({
load: function() {
if (this.get('state') == 'empty') {
this.set('state', 'loading');
load: function() {
if (this.get('state') == 'empty') {
this.set('state', 'loading');
+ messageCenter.addMessage('info', 'Ładuję dane dokumentu...');
$.ajax({
cache: false,
url: documentsUrl + fileId,
$.ajax({
cache: false,
url: documentsUrl + fileId,
@@
-287,6
+292,7
@@
Editor.DocumentModel = Editor.Model.extend({
for (var key in this.contentModels) {
this.contentModels[key].addObserver(this, 'state', this.contentModelStateChanged.bind(this));
}
for (var key in this.contentModels) {
this.contentModels[key].addObserver(this, 'state', this.contentModelStateChanged.bind(this));
}
+ messageCenter.addMessage('success', 'Dane dokumentu zostały załadowane :-)');
},
contentModelStateChanged: function(property, value, contentModel) {
},
contentModelStateChanged: function(property, value, contentModel) {
@@
-303,8
+309,6
@@
Editor.DocumentModel = Editor.Model.extend({
if (this.contentModels[key].guid() == contentModel.guid()) {
this.contentModels[key].set('state', 'synced');
this.data.user_revision = this.contentModels[key].get('revision');
if (this.contentModels[key].guid() == contentModel.guid()) {
this.contentModels[key].set('state', 'synced');
this.data.user_revision = this.contentModels[key].get('revision');
- messageCenter.addMessage('info', 'Uaktualnienie dokumentu do wersji ' + this.data.user_revision,
- 'Uaktualnienie dokumentu do wersji ' + this.data.user_revision);
}
}
for (key in this.contentModels) {
}
}
for (key in this.contentModels) {
@@
-327,6
+331,7
@@
Editor.DocumentModel = Editor.Model.extend({
update: function() {
this.set('state', 'loading');
update: function() {
this.set('state', 'loading');
+ messageCenter.addMessage('info', 'Uaktualniam dokument...');
$.ajax({
url: this.data.merge_url,
dataType: 'json',
$.ajax({
url: this.data.merge_url,
dataType: 'json',
@@
-350,9
+355,14
@@
Editor.DocumentModel = Editor.Model.extend({
this.contentModels[key].set('revision', this.data.user_revision);
this.contentModels[key].set('state', 'empty');
}
this.contentModels[key].set('revision', this.data.user_revision);
this.contentModels[key].set('state', 'empty');
}
+ messageCenter.addMessage('success', 'Uaktualniłem dokument do najnowszej wersji :-)');
} else if (xhr.status == 202) { // Wygenerowano PullRequest (tutaj?)
} else if (xhr.status == 204) { // Nic nie zmieniono
} else if (xhr.status == 202) { // Wygenerowano PullRequest (tutaj?)
} else if (xhr.status == 204) { // Nic nie zmieniono
+ messageCenter.addMessage('info', 'Nic się nie zmieniło od ostatniej aktualizacji. Po co mam uaktualniać?');
} else if (xhr.status == 409) { // Konflikt podczas operacji
} else if (xhr.status == 409) { // Konflikt podczas operacji
+ messageCenter.addMessage('error', 'Wystąpił konflikt podczas aktualizacji. Pędź po programistów! :-(');
+ } else if (xhr.status == 500) {
+ messageCenter.addMessage('critical', 'Błąd serwera. Pędź po programistów! :-(');
}
this.set('state', 'synced');
this.set('updateData', null);
}
this.set('state', 'synced');
this.set('updateData', null);
@@
-360,6
+370,7
@@
Editor.DocumentModel = Editor.Model.extend({
merge: function(message) {
this.set('state', 'loading');
merge: function(message) {
this.set('state', 'loading');
+ messageCenter.addMessage('info', 'Scalam dokument z głównym repozytorium...');
$.ajax({
url: this.data.merge_url,
type: 'post',
$.ajax({
url: this.data.merge_url,
type: 'post',
@@
-382,11
+393,15
@@
Editor.DocumentModel = Editor.Model.extend({
this.contentModels[key].set('revision', this.data.user_revision);
this.contentModels[key].set('state', 'empty');
}
this.contentModels[key].set('revision', this.data.user_revision);
this.contentModels[key].set('state', 'empty');
}
- messageCenter.addMessage('info', 'Uaktualnienie dokumentu do wersji ' + this.get('mergeData').revision,
- 'Uaktualnienie dokumentu do wersji ' + this.get('mergeData').revision);
+ messageCenter.addMessage('success', 'Scaliłem dokument z głównym repozytorium :-)');
} else if (xhr.status == 202) { // Wygenerowano PullRequest
} else if (xhr.status == 202) { // Wygenerowano PullRequest
+ messageCenter.addMessage('success', 'Wysłałem prośbę o scalenie dokumentu z głównym repozytorium.');
} else if (xhr.status == 204) { // Nic nie zmieniono
} else if (xhr.status == 204) { // Nic nie zmieniono
+ messageCenter.addMessage('info', 'Nic się nie zmieniło od ostatniego scalenia. Po co mam scalać?');
} else if (xhr.status == 409) { // Konflikt podczas operacji
} else if (xhr.status == 409) { // Konflikt podczas operacji
+ messageCenter.addMessage('error', 'Wystąpił konflikt podczas scalania. Pędź po programistów! :-(');
+ } else if (xhr.status == 500) {
+ messageCenter.addMessage('critical', 'Błąd serwera. Pędź po programistów! :-(');
}
this.set('state', 'synced');
this.set('mergeData', null);
}
this.set('state', 'synced');
this.set('mergeData', null);
@@
-404,12
+419,18
@@
Editor.DocumentModel = Editor.Model.extend({
var leftPanelView, rightPanelContainer, doc;
var leftPanelView, rightPanelContainer, doc;
-$(function() {
+$(function()
+{
+ documentsUrl = $('#api-base-url').text() + '/';
+ toolbarUrl = $('#api-toolbar-url').text();
+
doc = new Editor.DocumentModel();
doc = new Editor.DocumentModel();
- var editor = new EditorView('#body-wrap', doc);
+ var editor = new EditorView('#body-wrap', doc);
editor.freeze();
editor.freeze();
+
var flashView = new FlashView('#flashview', messageCenter);
var splitView = new SplitView('#splitview', doc);
var flashView = new FlashView('#flashview', messageCenter);
var splitView = new SplitView('#splitview', doc);
+
leftPanelView = new PanelContainerView('#left-panel-container', doc);
leftPanelView = new PanelContainerView('#left-panel-container', doc);
- rightPanelContainer = new PanelContainerView('#right-panel-container', doc);
+ rightPanelContainer = new PanelContainerView('#right-panel-container', doc);
});
});