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

rewriting JSONSheetDocument class

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