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 {
background-color: #DAE6F6;
height: 100%;
margin-left: -4px;
width: 18%;
width: 12em;
margin-top: -0.6em;
overflow:auto;
float:left;
......@@ -257,7 +257,6 @@ div.listbox-domain-tree-container select {
/* right */
div.main-right {
width: 82%;
height: 100%;
margin-top: -0.6em;
float:right;
......@@ -331,11 +330,12 @@ a.your_listbox_title {
/* records displayer */
div.listbox-header-box {
height: 0;
float: right;
}
div.listbox-number-of-records {
float: right;
font-size: 12px;
margin-right: 12em;
margin-right: 5em;
margin-top: -18px;
min-width: 30%;
}
......
......@@ -5,7 +5,7 @@
<title></title>
<script text="javascript"> function reloc(url) {window.location = url;}</script>
</head>
<body onload="reloc('theme.html');">
<textarea id="errors" name="errors" style="width:100%; height:100px; background:silver;"></textarea>
<body onload="reloc('ung.html');">
</body>
</html>
......@@ -60,23 +60,25 @@ Page.prototype = {
switch(this.name) {
case "text-editor":
editor = new Xinha();
if(!doc) {doc=new JSONTextDocument();}
doc=new JSONTextDocument();
break;
case "table-editor":
editor = new SheetEditor();
if(!doc) {doc=new JSONSheetDocument();}
doc=new JSONSheetDocument();
break;
case "image-editor":
editor = new SVGEditor();
if(!doc) {doc=new JSONIllustrationDocument();}
doc=new JSONIllustrationDocument();
break;
default://renvoie à la page d'accueil
window.location = "ung.html";
return;
break;
}
setCurrentDocument(doc);
doc.load(getCurrentDocument());
this.setEditor(editor);
doc.setAsCurrentDocument();
},
/* include a javascript or a css file */
......@@ -188,7 +190,6 @@ setCurrentUser = function(user) {localStorage.setItem("currentUser", JSON.string
/* JSON document */
var JSONDocument = function() {
this.type = "table";//test
this.language = getCurrentUser().getLanguage();
this.version = null;
......@@ -252,44 +253,43 @@ getCurrentDocument = function() {
}
setCurrentDocument = function(doc) {localStorage.setItem("currentDocument",JSON.stringify(doc));}
getDocumentList = function() {
var list = localStorage.getItem("documentList");
return list ? list : new List();
var list = new DocumentList();
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"},
"illustration":{editorPage:"image-editor",icon:"images/icons/svg.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
*/
editDocumentSettings = function() {
$("#edit_document").dialog({
autoOpen: true,
height: 131,
width: 389,
modal: true,
buttons: {
"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"));
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
//save_button.click();*/
$(this).dialog("close");
},
Cancel: function() {
$(this).dialog("close");
}
}
});
}
loadFile("xml/xmlElements.xml", "html", function(data) {
$("rename", data).dialog({
autoOpen: true,
height: 131,
width: 389,
modal: true,
buttons: {
"Save": function(){
getCurrentDocument().setTitle($(getCurrentDocument()).find("#name").attr("value"));
getCurrentDocument().setLanguage($(getCurrentDocument()).find("#language").attr("value"));
getCurrentDocument().setVersion($(getCurrentDocument()).find("#version").attr("value"));
getCurrentDocument().setAsCurrentDocument();//diplay modifications
$(this).dialog("close");
},
Cancel: function() {
$(this).dialog("close");
}
}
});
}
)}
saveCurrentDocument = function() {
getCurrentPage().getEditor().saveEdition();
......
......@@ -42,7 +42,8 @@ var List = function(arg) {
if(arg) {this.content = arg;}
this.length = this.content.length;
}
List.prototype = {
List.prototype = new UngObject();
List.prototype.load ({
size: function() {return this.length;},
add: function(element) {this.content[this.size()]=element; this.length++;},
get: function(i) {return this.content[i];},
......@@ -56,7 +57,7 @@ List.prototype = {
this.remove(this.size()-1);
return element;
}
}
});
/**
* returns the current date
......@@ -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
loadXHR = function(address) {
$.ajax({
......@@ -139,4 +161,11 @@ tryUntilSucceed = function(func) {
nb*=nb;
}
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());
documentList.add(new JSONDocument());
documentList.add(new JSONDocument());
/**
* This file provides the javascript used to display the list of user's documents
*/
/**
* 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 i : ID of the line (number)
*/
......@@ -25,11 +61,11 @@ Line.prototype = {
/* load the document information in the html of a default line */
updateHTML: function() {
var line = this;
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-data-cell a").attr("onclick",this.startEdition).end()//clic
.find("td.listbox-table-data-cell")
.click(this.startEdition)//clic
.click(function() {line.startEdition(line.getDocument())})//clic
.find("a.listbox-document-icon")
.find("img")
.attr("src",supportedDocuments[this.getType()].icon)//icon
......@@ -43,10 +79,12 @@ Line.prototype = {
/* add the line in the table */
display: function() {$("table.listbox tbody").append($(this.getHTML()));},
/* edit the document if clicked */
startEdition: function() {
setCurrentDocument(this.document);
window.location = "theme.html";
startEdition: function(doc) {
setCurrentDocument(doc);
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 */
Line.loadHTML = function() {
......@@ -55,15 +93,3 @@ Line.loadHTML = function() {
}
/* return the html code of a default line */
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 @@
<link rel="shortcut icon" type="image/x-icon"
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>
<body>
<form id="main_form" class="main_form"
......@@ -84,10 +103,10 @@
<div id="select_language">
<ul><li>
<span id="available_language">en</span>
<span id="current_language">en</span>
<img src="images/ung/arrow_20C.png"/>
<ul>
<li><span onclick="changeLanguage(this.innerHTML)" id="fr">fr</span></li>
<ul id="available_languages">
<li></li>
</ul>
</li></ul>
......@@ -104,7 +123,7 @@
<a id="right_message">Not Implemented yet</a>
<div id="preference_dialog" title="UNG Preferences"></div>
<a>zope</a>
<a id="userName">Unknown</a>
| <a id="settings" href="#">Settings</a>
| <a id="help" href="#">Help</a>
| <a href="..WebSite_logout">Sign out</a>
......@@ -134,7 +153,7 @@
<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"/>
</a>
<a id="loading_message">Loading...</a>
......@@ -431,7 +450,7 @@
<div class="favorite">
<a class="domain_selected"></a>
<a href="...">Refresh</a>
<a href="#" onclick="javascript:window.location.reload()">Refresh</a>
</div>
</div></div>
......
......@@ -10,7 +10,7 @@
</div></div>
</content>
<dependencies>
<scriptfile>js/illustration.js</scriptfile>
<scriptfile>js/image-editor.js</scriptfile>
<stylefile>css/jquery-ui.css</stylefile>
</dependencies>
</root>
......@@ -111,7 +111,7 @@
<scriptfile>js/jquery/plugin/colorpicker/jquery.colorPicker.min.js</scriptfile>
<scriptfile>js/jquery/plugin/elastic/jquery.elastic.min.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>css/table.css</stylefile>
<stylefile>js/jquery/plugin/colorpicker/jquery.colorPicker.css</stylefile>
......
......@@ -12,7 +12,7 @@
</div>
</content>
<dependencies>
<scriptfile>js/editor.js</scriptfile>
<scriptfile>js/text-editor.js</scriptfile>
<stylefile>css/jquery-ui.css</stylefile>
</dependencies>
</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