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

implement the document selection

create List object and methods
implement basic rename function
parent 34732c78
...@@ -136,7 +136,7 @@ div.main-left { ...@@ -136,7 +136,7 @@ div.main-left {
background-color: #DAE6F6; background-color: #DAE6F6;
height: 100%; height: 100%;
margin-left: -4px; margin-left: -4px;
width: 18%; width: 12em;
margin-top: -0.6em; margin-top: -0.6em;
overflow:auto; overflow:auto;
float:left; float:left;
...@@ -257,7 +257,6 @@ div.listbox-domain-tree-container select { ...@@ -257,7 +257,6 @@ div.listbox-domain-tree-container select {
/* right */ /* right */
div.main-right { div.main-right {
width: 82%;
height: 100%; height: 100%;
margin-top: -0.6em; margin-top: -0.6em;
float:right; float:right;
...@@ -331,11 +330,12 @@ a.your_listbox_title { ...@@ -331,11 +330,12 @@ a.your_listbox_title {
/* records displayer */ /* records displayer */
div.listbox-header-box { div.listbox-header-box {
height: 0; height: 0;
float: right;
} }
div.listbox-number-of-records { div.listbox-number-of-records {
float: right; float: right;
font-size: 12px; font-size: 12px;
margin-right: 12em; margin-right: 5em;
margin-top: -18px; margin-top: -18px;
min-width: 30%; min-width: 30%;
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<title></title> <title></title>
<script text="javascript"> function reloc(url) {window.location = url;}</script> <script text="javascript"> function reloc(url) {window.location = url;}</script>
</head> </head>
<body onload="reloc('theme.html');"> <body onload="reloc('ung.html');">
<textarea id="errors" name="errors" style="width:100%; height:100px; background:silver;"></textarea>
</body> </body>
</html> </html>
...@@ -60,23 +60,25 @@ Page.prototype = { ...@@ -60,23 +60,25 @@ Page.prototype = {
switch(this.name) { switch(this.name) {
case "text-editor": case "text-editor":
editor = new Xinha(); editor = new Xinha();
if(!doc) {doc=new JSONTextDocument();} doc=new JSONTextDocument();
break; break;
case "table-editor": case "table-editor":
editor = new SheetEditor(); editor = new SheetEditor();
if(!doc) {doc=new JSONSheetDocument();} doc=new JSONSheetDocument();
break; break;
case "image-editor": case "image-editor":
editor = new SVGEditor(); editor = new SVGEditor();
if(!doc) {doc=new JSONIllustrationDocument();} doc=new JSONIllustrationDocument();
break; break;
default://renvoie à la page d'accueil default://renvoie à la page d'accueil
window.location = "ung.html"; window.location = "ung.html";
return; return;
break; break;
} }
setCurrentDocument(doc);
doc.load(getCurrentDocument());
this.setEditor(editor); this.setEditor(editor);
doc.setAsCurrentDocument();
}, },
/* include a javascript or a css file */ /* include a javascript or a css file */
...@@ -188,7 +190,6 @@ setCurrentUser = function(user) {localStorage.setItem("currentUser", JSON.string ...@@ -188,7 +190,6 @@ setCurrentUser = function(user) {localStorage.setItem("currentUser", JSON.string
/* JSON document */ /* JSON document */
var JSONDocument = function() { var JSONDocument = function() {
this.type = "table";//test
this.language = getCurrentUser().getLanguage(); this.language = getCurrentUser().getLanguage();
this.version = null; this.version = null;
...@@ -252,36 +253,34 @@ getCurrentDocument = function() { ...@@ -252,36 +253,34 @@ getCurrentDocument = function() {
} }
setCurrentDocument = function(doc) {localStorage.setItem("currentDocument",JSON.stringify(doc));} setCurrentDocument = function(doc) {localStorage.setItem("currentDocument",JSON.stringify(doc));}
getDocumentList = function() { getDocumentList = function() {
var list = localStorage.getItem("documentList"); var list = new DocumentList();
return list ? list : new List(); list.load(JSON.parse(localStorage.getItem("documentList")));
return list;
} }
setDocumentList = function() {localStorage.setItem("documentList",list);} setDocumentList = function(list) {localStorage.setItem("documentList",JSON.stringify(list));}
supportedDocuments = {"text":{editorPage:"text-editor",icon:"images/icons/document.png"}, supportedDocuments = {"text":{editorPage:"text-editor",icon:"images/icons/document.png"},
"illustration":{editorPage:"image-editor",icon:"images/icons/svg.png"}, "illustration":{editorPage:"image-editor",icon:"images/icons/svg.png"},
"table":{editorPage:"table-editor",icon:"images/icons/table.png"}, "table":{editorPage:"table-editor",icon:"images/icons/table.png"},
"other":{editorPage:null,icon:"images/icons/other.gif"} "other":{editorPage:null,icon:"images/icons/other.gif"},
undefined:{editorPage:null,icon:"images/icons/other.gif"}
} }
/* /*
* actions * actions
*/ */
editDocumentSettings = function() { editDocumentSettings = function() {
loadFile("xml/xmlElements.xml", "html", function(data) {
$("#edit_document").dialog({ $("rename", data).dialog({
autoOpen: true, 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");
getCurrentDocument().setLanguage($(getCurrentDocument()).find("#language").attr("value")); getCurrentDocument().setLanguage($(getCurrentDocument()).find("#language").attr("value"));
getCurrentDocument().setVersion($(getCurrentDocument()).find("#version").attr("value")); getCurrentDocument().setVersion($(getCurrentDocument()).find("#version").attr("value"));
//var new_int_index = $("input#sort_index.sort_index").attr("value");
//var new_subject_list = $("textarea#keyword_list").attr("value").replace(/\n+/g, ",");
getCurrentDocument().setAsCurrentDocument();//diplay modifications getCurrentDocument().setAsCurrentDocument();//diplay modifications
//save_button.click();*/
$(this).dialog("close"); $(this).dialog("close");
}, },
Cancel: function() { Cancel: function() {
...@@ -289,7 +288,8 @@ editDocumentSettings = function() { ...@@ -289,7 +288,8 @@ editDocumentSettings = function() {
} }
} }
}); });
} }
)}
saveCurrentDocument = function() { saveCurrentDocument = function() {
getCurrentPage().getEditor().saveEdition(); getCurrentPage().getEditor().saveEdition();
......
...@@ -42,7 +42,8 @@ var List = function(arg) { ...@@ -42,7 +42,8 @@ var List = function(arg) {
if(arg) {this.content = arg;} if(arg) {this.content = arg;}
this.length = this.content.length; this.length = this.content.length;
} }
List.prototype = { List.prototype = new UngObject();
List.prototype.load ({
size: function() {return this.length;}, size: function() {return this.length;},
add: function(element) {this.content[this.size()]=element; this.length++;}, add: function(element) {this.content[this.size()]=element; this.length++;},
get: function(i) {return this.content[i];}, get: function(i) {return this.content[i];},
...@@ -56,7 +57,7 @@ List.prototype = { ...@@ -56,7 +57,7 @@ List.prototype = {
this.remove(this.size()-1); this.remove(this.size()-1);
return element; return element;
} }
} });
/** /**
* returns the current date * returns the current date
...@@ -90,6 +91,27 @@ loadFile = function(address, type, instruction) { ...@@ -90,6 +91,27 @@ loadFile = function(address, type, instruction) {
}); });
} }
// load methode, used for testing
//(Francois)
loadTest = function(address) {
$.ajax({
url: address,
type: "GET",
dataType: "json",
/*headers: {
Authorization: "Basic "+"nom:test"},
fields: {
withCredentials: "true"
},*/
success: function(data){
var list = getDocumentList();
var doc = new JSONDocument();
doc.load(data);
list.add(doc);
}
});
}
// load // load
loadXHR = function(address) { loadXHR = function(address) {
$.ajax({ $.ajax({
...@@ -140,3 +162,10 @@ tryUntilSucceed = function(func) { ...@@ -140,3 +162,10 @@ tryUntilSucceed = function(func) {
} }
execute(); execute();
} }
/**
* Resize the right part of ung
*/
var resize = function() {
$("div.main-right").width($(window).width()-$("div.main-left").width());
}
\ No newline at end of file
var documentList = getDocumentList(); /**
documentList.add(new JSONDocument()); * This file provides the javascript used to display the list of user's documents
documentList.add(new JSONDocument()); */
documentList.add(new JSONDocument());
/** /**
* create a ligne representing a document in the main table * class DocumentList
* This class provides methods to manipulate the list of documents of the current user
*/
var DocumentList = function() {List.call(this);}
DocumentList.prototype = new List();
DocumentList.prototype.load({
get: function(i) {
var doc = new JSONDocument();
doc.load(this.content[i]);
return doc;
},
add: function(doc) {
this.content[this.size()]=doc;
this.length++;
setDocumentList(this)
},
display: function() {
var n = getDocumentList().size();
for(var i=0;i<n;i++) {
var ligne = new Line(getDocumentList().get(i),0);
ligne.updateHTML();
ligne.display();
}
}
})
/* initialize the list */
//current lines are just for testing
setDocumentList(new List());
loadTest("dav/temp.json");
loadTest("dav/temp2.json");
getDocumentList().add(new JSONDocument());
/**
* create a line representing a document in the main table
* @param doc : document to represent * @param doc : document to represent
* @param i : ID of the line (number) * @param i : ID of the line (number)
*/ */
...@@ -25,11 +61,11 @@ Line.prototype = { ...@@ -25,11 +61,11 @@ Line.prototype = {
/* load the document information in the html of a default line */ /* load the document information in the html of a default line */
updateHTML: function() { updateHTML: function() {
var line = this;
this.setHTML($(this.getHTML()).attr("class",this.getType()) this.setHTML($(this.getHTML()).attr("class",this.getType())
.find("td.listbox-table-select-cell input").attr("id",this.getID()).end()//ID .find("td.listbox-table-select-cell input").attr("id",this.getID()).end()//ID
//.find("td.listbox-table-data-cell a").attr("onclick",this.startEdition).end()//clic
.find("td.listbox-table-data-cell") .find("td.listbox-table-data-cell")
.click(this.startEdition)//clic .click(function() {line.startEdition(line.getDocument())})//clic
.find("a.listbox-document-icon") .find("a.listbox-document-icon")
.find("img") .find("img")
.attr("src",supportedDocuments[this.getType()].icon)//icon .attr("src",supportedDocuments[this.getType()].icon)//icon
...@@ -43,10 +79,12 @@ Line.prototype = { ...@@ -43,10 +79,12 @@ Line.prototype = {
/* add the line in the table */ /* add the line in the table */
display: function() {$("table.listbox tbody").append($(this.getHTML()));}, display: function() {$("table.listbox tbody").append($(this.getHTML()));},
/* edit the document if clicked */ /* edit the document if clicked */
startEdition: function() { startEdition: function(doc) {
setCurrentDocument(this.document); setCurrentDocument(doc);
window.location = "theme.html"; if(supportedDocuments[doc.getType()].editorPage) {window.location = "theme.html";}
else alert("no editor available for this document");
} }
} }
/* load the html code of a default line */ /* load the html code of a default line */
Line.loadHTML = function() { Line.loadHTML = function() {
...@@ -55,15 +93,3 @@ Line.loadHTML = function() { ...@@ -55,15 +93,3 @@ Line.loadHTML = function() {
} }
/* return the html code of a default line */ /* return the html code of a default line */
Line.getOriginalHTML = function() {return Line.originalHTML;} Line.getOriginalHTML = function() {return Line.originalHTML;}
/* load the table */
waitBeforeSucceed(
function(){return Line.loadHTML()},
function() {
for(var i=0;i<documentList.size();i++) {
var ligne = new Line(documentList.get(i),0);
ligne.updateHTML();
ligne.display();
}
}
);
\ No newline at end of file
...@@ -29,6 +29,25 @@ ...@@ -29,6 +29,25 @@
<link rel="shortcut icon" type="image/x-icon" <link rel="shortcut icon" type="image/x-icon"
href="images/ung/favicon.ico" /> href="images/ung/favicon.ico" />
<script type="text/javascript">
var initUser = function() {
var user = getCurrentUser();
if(!user) { user = new User();}
user.setAsCurrentUser();
}
var init = function() {
setCurrentPage(new Page());
initUser();
waitBeforeSucceed(
function(){return Line.loadHTML()},getDocumentList().display
);
resize();
}
$(window).resize(resize);
$(document).ready(init);
</script>
</head> </head>
<body> <body>
<form id="main_form" class="main_form" <form id="main_form" class="main_form"
...@@ -84,10 +103,10 @@ ...@@ -84,10 +103,10 @@
<div id="select_language"> <div id="select_language">
<ul><li> <ul><li>
<span id="available_language">en</span> <span id="current_language">en</span>
<img src="images/ung/arrow_20C.png"/> <img src="images/ung/arrow_20C.png"/>
<ul> <ul id="available_languages">
<li><span onclick="changeLanguage(this.innerHTML)" id="fr">fr</span></li> <li></li>
</ul> </ul>
</li></ul> </li></ul>
...@@ -104,7 +123,7 @@ ...@@ -104,7 +123,7 @@
<a id="right_message">Not Implemented yet</a> <a id="right_message">Not Implemented yet</a>
<div id="preference_dialog" title="UNG Preferences"></div> <div id="preference_dialog" title="UNG Preferences"></div>
<a>zope</a> <a id="userName">Unknown</a>
| <a id="settings" href="#">Settings</a> | <a id="settings" href="#">Settings</a>
| <a id="help" href="#">Help</a> | <a id="help" href="#">Help</a>
| <a href="..WebSite_logout">Sign out</a> | <a href="..WebSite_logout">Sign out</a>
...@@ -134,7 +153,7 @@ ...@@ -134,7 +153,7 @@
<div class="input"><div > <div class="input"><div >
<a class="ung_docs" href="javascript:window.location.reload()"> <a class="ung_docs" href="#" onclick="javascript:window.location.reload()">
<img src="images/ung/ung-logo.gif"/> <img src="images/ung/ung-logo.gif"/>
</a> </a>
<a id="loading_message">Loading...</a> <a id="loading_message">Loading...</a>
...@@ -431,7 +450,7 @@ ...@@ -431,7 +450,7 @@
<div class="favorite"> <div class="favorite">
<a class="domain_selected"></a> <a class="domain_selected"></a>
<a href="...">Refresh</a> <a href="#" onclick="javascript:window.location.reload()">Refresh</a>
</div> </div>
</div></div> </div></div>
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</div></div> </div></div>
</content> </content>
<dependencies> <dependencies>
<scriptfile>js/illustration.js</scriptfile> <scriptfile>js/image-editor.js</scriptfile>
<stylefile>css/jquery-ui.css</stylefile> <stylefile>css/jquery-ui.css</stylefile>
</dependencies> </dependencies>
</root> </root>
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
<scriptfile>js/jquery/plugin/colorpicker/jquery.colorPicker.min.js</scriptfile> <scriptfile>js/jquery/plugin/colorpicker/jquery.colorPicker.min.js</scriptfile>
<scriptfile>js/jquery/plugin/elastic/jquery.elastic.min.js</scriptfile> <scriptfile>js/jquery/plugin/elastic/jquery.elastic.min.js</scriptfile>
<scriptfile>js/jquery/plugin/sheet/jquery.sheet.js</scriptfile> <scriptfile>js/jquery/plugin/sheet/jquery.sheet.js</scriptfile>
<scriptfile>js/table.js</scriptfile> <scriptfile>js/table-editor.js</scriptfile>
<stylefile>js/jquery/plugin/sheet/jquery.sheet.css</stylefile> <stylefile>js/jquery/plugin/sheet/jquery.sheet.css</stylefile>
<stylefile>css/table.css</stylefile> <stylefile>css/table.css</stylefile>
<stylefile>js/jquery/plugin/colorpicker/jquery.colorPicker.css</stylefile> <stylefile>js/jquery/plugin/colorpicker/jquery.colorPicker.css</stylefile>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</div> </div>
</content> </content>
<dependencies> <dependencies>
<scriptfile>js/editor.js</scriptfile> <scriptfile>js/text-editor.js</scriptfile>
<stylefile>css/jquery-ui.css</stylefile> <stylefile>css/jquery-ui.css</stylefile>
</dependencies> </dependencies>
</root> </root>
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