Commit 77e4848b authored by François Billioud's avatar François Billioud

fix bugs with the getters of some complex elements

parent 2af60681
...@@ -121,8 +121,7 @@ div#wrapper_header { ...@@ -121,8 +121,7 @@ div#wrapper_header {
/* left */ /* left */
div.header-left { div.header-left {
margin-top: -4px; margin-top: -4px;
min-width: 32em; width: 32em;
width: 40%;
position: absolute; position: absolute;
} }
div.header-left h2 { div.header-left h2 {
...@@ -156,6 +155,11 @@ div#wrapper_header div.field a[name="document_title"]:hover { ...@@ -156,6 +155,11 @@ div#wrapper_header div.field a[name="document_title"]:hover {
background: none repeat scroll 0 0 #FFFFD6; background: none repeat scroll 0 0 #FFFFD6;
border: 1px solid #AAAAAA; border: 1px solid #AAAAAA;
} }
/* research bar */
div.input form {
margin-top: 0.5em;
float:right;
}
/* right */ /* right */
div.header-right{ div.header-right{
......
...@@ -25,14 +25,20 @@ SVGEditor = function() { ...@@ -25,14 +25,20 @@ SVGEditor = function() {
/** /**
* SVG documents * SVG documents
* editable documents must implements the following methods *
* getType : returns the type of a document * editable documents must implements the following arguments and methods
* type : a unique type ID
* saveEdition : set the argument as the new content of the document. Change last modification time and display the changes * saveEdition : set the argument as the new content of the document. Change last modification time and display the changes
* setAsCurrentDocument : set the document as currentDocument in the local storage and display its properties in the current page * setAsCurrentDocument : set the document as currentDocument in the local storage and display its properties in the current page
*
* @param arg : a json JSONTextDocument object to load
*/ */
var JSONIllustrationDocument = function() { var JSONIllustrationDocument = function(arg) {
JSONDocument.call(this);//inherits properties from JSONDocument JSONDocument.call(this,arg);//inherits properties from JSONDocument
this.type = "illustration"; if(arg) {this.load(arg);}
else {
this.type = "illustration";
}
} }
JSONIllustrationDocument.prototype = new JSONDocument();//inherits methods from JSONDocument JSONIllustrationDocument.prototype = new JSONDocument();//inherits methods from JSONDocument
...@@ -53,8 +59,6 @@ JSONIllustrationDocument.prototype.setAsCurrentDocument = function() { ...@@ -53,8 +59,6 @@ JSONIllustrationDocument.prototype.setAsCurrentDocument = function() {
} }
getCurrentDocument = function() { getCurrentDocument = function() {
var doc = new JSONIllustrationDocument(); return new JSONIllustrationDocument(JSON.parse(localStorage.getItem("currentDocument")));
doc.load(JSON.parse(localStorage.getItem("currentDocument")));
return doc;
} }
...@@ -31,15 +31,23 @@ var Xinha = function() { ...@@ -31,15 +31,23 @@ var Xinha = function() {
/** /**
* Text documents * Text documents
* editable documents must implements the following methods *
* getType : returns the type of a document * editable documents must implements the following arguments and methods
* type : a unique type ID
* saveEdition : set the argument as the new content of the document. Change last modification time and display the changes * saveEdition : set the argument as the new content of the document. Change last modification time and display the changes
* setAsCurrentDocument : set the document as currentDocument in the local storage and display its properties in the current page * setAsCurrentDocument : set the document as currentDocument in the local storage and display its properties in the current page
*/
var JSONTextDocument = function() {
JSONDocument.call(this);//inherits properties from JSONDocument /**
this.type = "text"; * class JSONTextDocument
* @param arg : a json JSONTextDocument object to load
*/
var JSONTextDocument = function(arg) {
JSONDocument.call(this,arg);//inherits properties from JSONDocument
if(arg) {this.load(arg);}
else {
this.type = "text";
}
} }
JSONTextDocument.prototype = new JSONDocument();//inherits methods from JSONDocument JSONTextDocument.prototype = new JSONDocument();//inherits methods from JSONDocument
...@@ -60,7 +68,5 @@ JSONTextDocument.prototype.setAsCurrentDocument = function() { ...@@ -60,7 +68,5 @@ JSONTextDocument.prototype.setAsCurrentDocument = function() {
} }
getCurrentDocument = function() { getCurrentDocument = function() {
var doc = new JSONTextDocument(); return new JSONTextDocument(JSON.parse(localStorage.getItem("currentDocument")));
doc.load(JSON.parse(localStorage.getItem("currentDocument")));
return doc;
} }
...@@ -36,18 +36,20 @@ UngObject.prototype.inherits = function(superClass) { ...@@ -36,18 +36,20 @@ UngObject.prototype.inherits = function(superClass) {
/** /**
* Class List * Class List
* this class provides usual API to manipulate list structure * this class provides usual API to manipulate list structure
* @param arg : a json list object
*/ */
var List = function(arg) { var List = function(arg) {
this.content = new Array(); if(arg) {this.load(arg);}
if(arg) {this.content = arg;} else {
this.length = this.content.length; this.content = new Array();
this.length = this.content.length;
}
} }
List.prototype = new UngObject(); List.prototype = new UngObject();
List.prototype.load ({ List.prototype.load ({
size: function() {return this.length;}, size: function() {return this.length;},
put: function(key,value) { put: function(key,value) {
if(!this.content[key]) {this.length=this.length+1;} if(!this.content[key]) {this.length++;}
alert(""+this.length+this.content[key]);
this.content[key]=value; this.content[key]=value;
}, },
add: function(element) {this.put(this.size(),element);}, add: function(element) {this.put(this.size(),element);},
......
...@@ -10,20 +10,26 @@ setCurrentDocumentID = function(ID) {return localStorage.setItem("currentDocumen ...@@ -10,20 +10,26 @@ setCurrentDocumentID = function(ID) {return localStorage.setItem("currentDocumen
/** /**
* class DocumentList * class DocumentList
* This class provides methods to manipulate the list of documents of the current user * This class provides methods to manipulate the list of documents of the current user
* As the list is stored in the localStorage, we are obliged to call "setDocumentList" after
* any content modification
* @param arg : a documentList json object to load
*/ */
var DocumentList = function() { var DocumentList = function(arg) {
List.call(this); List.call(this,arg);
this.displayedPage = 1; if(arg) {
this.selectionList = new List(); this.load(arg);
for(var i=0; i<this.size(); i++) {
this.content[i]=new JSONDocument(this.get(i));//load methods of documents
}
this.selectionList = new List(arg.selectionList);//load methods of selectionList
}
else {
this.displayedPage = 1;
this.selectionList = new List();
}
} }
DocumentList.prototype = new List(); DocumentList.prototype = new List();
DocumentList.prototype.load({ DocumentList.prototype.load({
/* override : returns the ith document */
get: function(i) {
var doc = new JSONDocument();
doc.load(this.content[i]);
return doc;
},
/* override : put an element at the specified position */ /* override : put an element at the specified position */
put: function(i, doc) { put: function(i, doc) {
this.content[i]=doc; this.content[i]=doc;
...@@ -31,11 +37,7 @@ DocumentList.prototype.load({ ...@@ -31,11 +37,7 @@ DocumentList.prototype.load({
setDocumentList(this); setDocumentList(this);
}, },
getSelectionList: function() { getSelectionList: function() { return this.selectionList; },
var list = new List();
list.load(this.selectionList);
return list;
},
resetSelectionList: function() { resetSelectionList: function() {
this.selectionList = new List(); this.selectionList = new List();
for(var i=0; i<this.length; i++) { for(var i=0; i<this.length; i++) {
...@@ -45,8 +47,8 @@ DocumentList.prototype.load({ ...@@ -45,8 +47,8 @@ DocumentList.prototype.load({
}, },
checkAll: function() { checkAll: function() {
for(var i=0; i<this.length; i++) { for(var i=0; i<this.length; i++) {
this.selectionList.put(i,this.get(i)); this.getSelectionList().put(i,this.get(i));
$("tr td.listbox-table-select-cell input#"+this.get(i).getID()).attr("checked",true); $("tr td.listbox-table-select-cell input#"+i).attr("checked",true);
} }
setDocumentList(this); setDocumentList(this);
}, },
...@@ -83,19 +85,17 @@ DocumentList.prototype.load({ ...@@ -83,19 +85,17 @@ DocumentList.prototype.load({
/* update the ith document information */ /* update the ith document information */
update: function(i) { update: function(i) {
var line = this; var list = this;
var doc = line.get(i); var doc = list.get(i);
loadFile(getDocumentAddress(doc),"json",function(data) { loadFile(getDocumentAddress(doc),"json",function(data) {
doc.load(data);//todo : replace by data.header doc.load(data);//todo : replace by data.header
doc.setContent("");// doc.setContent("");//
line.put(i,doc); list.put(i,doc);
}); });
} }
}); });
getDocumentList = function() { getDocumentList = function() {
var list = new DocumentList(); return new DocumentList(JSON.parse(localStorage.getItem("documentList")));
list.load(JSON.parse(localStorage.getItem("documentList")));
return list;
} }
setDocumentList = function(list) {localStorage.setItem("documentList",JSON.stringify(list));} setDocumentList = function(list) {localStorage.setItem("documentList",JSON.stringify(list));}
...@@ -120,19 +120,21 @@ Line.prototype = { ...@@ -120,19 +120,21 @@ Line.prototype = {
return $("tr td.listbox-table-select-cell input#"+this.getID()).attr("checked"); return $("tr td.listbox-table-select-cell input#"+this.getID()).attr("checked");
}, },
/* add the document of this line to the list of selected documents */
addToSelection: function() { addToSelection: function() {
var list = getDocumentList(); list = getDocumentList();
list.getSelectionList().put(this.getID(),this); list.getSelectionList().put(this.getID(),this);
setDocumentList(list); setDocumentList(list);
}, },
/* remove the document of this line from the list of selected documents */
removeFromSelection: function() { removeFromSelection: function() {
var list = getDocumentList(); var list = getDocumentList();
list.getSelectionList().remove(this.getID()); list.getSelectionList().remove(this.getID());
setDocumentList(list); setDocumentList(list);
}, },
/* check or uncheck the line */
changeState: function() { changeState: function() {
this.isSelected() ? this.addToSelection() : this.removeFromSelection(); this.isSelected() ? this.addToSelection() : this.removeFromSelection();
test = getDocumentList().getSelectionList();
$("span#selected_row_number a").html(getDocumentList().getSelectionList().size()); $("span#selected_row_number a").html(getDocumentList().getSelectionList().size());
}, },
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
var initUser = function() { var initUser = function() {
var user = getCurrentUser(); var user = getCurrentUser();
if(!user) { user = new User();}
user.setAsCurrentUser(); user.setAsCurrentUser();
} }
......
...@@ -53,10 +53,7 @@ ...@@ -53,10 +53,7 @@
</script> </script>
</head> </head>
<body> <body>
<form id="main_form" class="main_form" <div>
onsubmit="changed=false; return true"
method="post">
<div class="container"> <div class="container">
<div class="navigation"> <div class="navigation">
...@@ -556,7 +553,7 @@ ...@@ -556,7 +553,7 @@
name="your_listbox_uncheckAll:method" name="your_listbox_uncheckAll:method"
value="1" alt="Uncheck All" value="1" alt="Uncheck All"
title="Uncheck All" title="Uncheck All"
onclick="getDocuementList().resetSelectionList()" onclick="getDocumentList().resetSelectionList()"
src="images/icons/decheckall.png" /> src="images/icons/decheckall.png" />
</th> </th>
...@@ -632,6 +629,6 @@ ...@@ -632,6 +629,6 @@
</div> </div>
</div> </div>
</div></div> </div></div>
</form> </div>
</body> </body>
</html> </html>
\ No newline at end of file
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