Commit d1d0521a authored by François Billioud's avatar François Billioud

rewriting JSONSheetDocument class

parent 4ae73e5a
......@@ -10,25 +10,29 @@ var JSONSheetDocument = function() {
JSONSheetDocument.prototype = new JSONDocument();//inheritance
//accessors
JSONSheetDocument.prototype.getWidth = function() {return this.width;}
JSONSheetDocument.prototype.setWidth = function(newWidth) {this.width = newWidth;}
JSONSheetDocument.prototype.getHeight = function() {return this.height;}
JSONSheetDocument.prototype.setHeight = function(newHeight) {this.height = newHeight;}
//save process
JSONSheetDocument.prototype.saveEdition = function(content) {
JSONSheetDocument.prototype.load({
getWidth: function() {return this.width;},
setWidth: function(newWidth) {this.width = newWidth;},
getHeight: function() {return this.height;},
setHeight: function(newHeight) {this.height = newHeight;},
//save process
saveEdition: function(content) {
this.setContent(content);
this.setLastModification(currentTime());
this.setAsCurrentDocument();
}
//display document information
JSONSheetDocument.prototype.setAsCurrentDocument = function() {
},
//display document information
setAsCurrentDocument: function() {
getCurrentPage().displayDocumentTitle(this);
getCurrentPage().displayDocumentState(this);
getCurrentPage().displayAuthorName(this);
getCurrentPage().displayLastModification(this);
setCurrentDocument(this);
}
}
});
getCurrentDocument = function() {
var doc = new JSONTextDocument();
doc.load(JSON.parse(localStorage.getItem("currentDocument")));
......
......@@ -51,8 +51,8 @@ Page.prototype = {
this.displayPageTitle();
this.displayPageContent();
var dependencies = this.getDependencies();
$(dependencies).find("scriptfile").each(function() {currentPage.include($(this).text(),"script");});//includes js
$(dependencies).find("linkfile").each(function() {currentPage.include($(this).text(),"link");});//includes css
$(dependencies).find("scriptfile").each(function() {currentPage.include($(this).text(),"script");});//includes js
switch(this.name) {
case "editor":
this.editor = new Xinha();
......@@ -77,8 +77,7 @@ Page.prototype = {
break;
}
var head = this.getHTML().getElementsByTagName("head");
$(head[0]).append(object);
var head = $(this.getHTML()).find("head").append(object);
},
//printers
......@@ -132,7 +131,8 @@ var User = function() {
this.storage = "http://www.unhosted-dav.com";
this.identityProvider = "http://www.webfinger.com";
}
User.prototype = {
User.prototype = new UngObject();
User.prototype.load({
getName: function() {return this.name;},
setName: function(newName) {this.name = newName;},
getLanguage: function() {return this.language;},
......@@ -147,7 +147,7 @@ User.prototype = {
getCurrentPage().displayLanguages(this);
setCurrentUser(this);
}
}
});
getCurrentUser = function() {
var user = new User();
......@@ -175,7 +175,9 @@ var JSONDocument = function() {
this.lastModification=currentTime();
this.state=Document.states.draft;
}
JSONDocument.prototype = {
JSONDocument.prototype = new UngObject();
JSONDocument.prototype.load({
//type
getType: function() {return this.type;},
......@@ -213,7 +215,7 @@ JSONDocument.prototype = {
},
save: function() {}
}
});
Document.states = {
draft:{"fr":"Brouillon","en":"Draft"},
saved:{"fr":"Enregistré","en":"Saved"},
......@@ -231,13 +233,14 @@ setCurrentDocument = function(doc) {localStorage.setItem("currentDocument",JSON.
* actions
*/
editDocumentSettings = function() {
$("#edit_document").dialog({
autoOpen: false,
autoOpen: true,
height: 131,
width: 389,
modal: true,
buttons: {
"Save": function(){
'Save': function(){
/*getCurrentDocument().setTitle($(getCurrentDocument()).find("#name").attr("value"));
//var new_short_title = $("input#short_title.short_title").attr("value");
getCurrentDocument().setLanguage($(getCurrentDocument()).find("#language").attr("value"));
......@@ -246,10 +249,10 @@ editDocumentSettings = function() {
//var new_subject_list = $("textarea#keyword_list").attr("value").replace(/\n+/g, ",");
getCurrentDocument().setAsCurrentDocument();//diplay modifications
//save_button.click();*/
$(this).dialog("close");
$(this).dialog('close');
},
Cancel: function() {
$(this).dialog("close");
'Cancel': function() {
$(this).dialog('close');
}
}
});
......
......@@ -30,6 +30,7 @@
<script type="text/javascript">
// initialize
init = function() {
setCurrentPage("editor");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment