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