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

implement document creation

fix some displaying bugs
parent 50fddeab
/*
Document : table
Created on : 16 juin 2011, 15:37:09
Author : floz
Description:
Purpose of the stylesheet follows.
*/
/*
TODO customize this sample style
Syntax recommendation http://www.w3.org/TR/REC-CSS2/
*/
root {
display: block;
}
...@@ -9,6 +9,12 @@ body { ...@@ -9,6 +9,12 @@ body {
font-weight:normal; font-weight:normal;
overflow-x: hidden; overflow-x: hidden;
} }
/* widget fields */
fieldset.widget {
border: 0 none;
}
/* hide legends */ /* hide legends */
div.field label, span.headline, a.listbox_title, div.actions, div.actions, div.field label, span.headline, a.listbox_title, div.actions, div.actions,
legend.group_title, fieldset.left { legend.group_title, fieldset.left {
...@@ -102,13 +108,25 @@ a#left_message, a#right_message { ...@@ -102,13 +108,25 @@ a#left_message, a#right_message {
/* header */ /* header */
iframe#svgframe, fieldset.widget { div.header {
border: 0 none; height: 3.5em;
width: 100%;
}
div#wrapper_header {
width: 100%;
height: 100%;
display: inline-block;
} }
/* left */ /* left */
div.header-left { div.header-left {
margin-left: 1px;
margin-top: -4px; margin-top: -4px;
min-width: 32em;
width: 40%;
position: absolute;
}
div.header-left h2 {
font-size: 14pt;
} }
/* logo UNG */ /* logo UNG */
a#loading_message { a#loading_message {
...@@ -120,16 +138,102 @@ div.logo-area { ...@@ -120,16 +138,102 @@ div.logo-area {
} }
a.ung_docs img { a.ung_docs img {
border:0 none; border:0 none;
left:-7px;
position:relative; position:relative;
top:9px; top:9px;
} }
/* document title & state */
div#wrapper_header div.field a[name="document_title"] {
color: #060605;
padding-left: 1em;
padding-right: 1em;
text-decoration: none;
}
div#wrapper_header div.field a[name="document_title"], div#wrapper_header div.field a[name="document_state"] {
font-size: 15px;
margin-left: 22px;
}
div#wrapper_header div.field a[name="document_title"]:hover {
background: none repeat scroll 0 0 #FFFFD6;
border: 1px solid #AAAAAA;
}
/* right */
div.header-right{
margin-right: 10em;
position: relative;
float: right;
}
div.header-right fieldset.widget {
padding: 0;
}
/* last modification & author */
div.header-right div.input {
margin-top: 1em;
}
div.header-right div.input div{
float: right;
position: relative;
}
div.header-right div.input a {
color: #A7A2A2;
font-size: 13px;
}
.action_menu {
float:right;
position: absolute;
margin-left: 3em;
z-index: 200;
}
.action_menu ul {
padding: 0;
}
.action_menu ul li {
list-style: none inside none;
}
.action_menu a#change_state {
background-image: url("../images/ung/button_background.png");
border: 1px solid #D1D1D1;
color: #333333;
padding: 2px;
}
.action_menu ul#change_state_list>li:hover {
color: #000000;
text-decoration: none;
cursor:pointer;
margin-right: -3em;
}
.action_menu li:hover ul {
display: block;
}
.action_menu ul li ul {
background: none repeat scroll 0 0 #FFFFFF;
border: 1px solid #D1D1D1;
display: none;
}
.action_menu ul li ul hover {
display: block;
}
.action_menu ul li ul li:hover {
background: none repeat scroll 0 0 #F3F3F3;
}
.action_menu ul li ul li {
text-align: center;
}
.action_menu ul li ul li h6 {
color: #333333;
font-size: 12px;
font-weight: lighter;
padding: 0.5em;
margin: 0;
}
/* main */ /* main */
div.main { div.main {
height: auto; height: auto;
margin-top: 0.5em; margin-top: 0.5em;
} }
/***************** UNG main page ********************/
/* left */ /* left */
div.main-left { div.main-left {
border-right: 4px solid #BBCCFF; border-right: 4px solid #BBCCFF;
...@@ -254,7 +358,7 @@ div.listbox-domain-tree-container select { ...@@ -254,7 +358,7 @@ div.listbox-domain-tree-container select {
} }
/* gadgets */ /* gadgets */
/* right */ /* right */
div.main-right { div.main-right {
height: 100%; height: 100%;
...@@ -415,3 +519,139 @@ div.listbox-content a img, div.main-content a img { ...@@ -415,3 +519,139 @@ div.listbox-content a img, div.main-content a img {
border: 0 none; border: 0 none;
} }
/**********************************************************
******************* editor page ***********************/
/* content */
div.content {
/*background: none repeat scroll 0 0 #DAE6F6;*/
width:100%;
border-bottom: 4px solid #BBCCFF;
border-top: 4px solid #BBCCFF;
}
fieldset.bottom {
border: 0 none;
width:100%;
list-style: none outside none;
padding: 0;
position: relative;
}
/* SVG-edit */
iframe#svgframe {
width: 100%;
border: 0 none;
overflow: hidden;
}
/**********************************************************
******************* login page ************************/
/* welcome message */
div#advertisement b {
font-size: 12px;
}
div#advertisement img{
position: absolute;
margin-top: 3em;
height: 10em;
}
/* login table */
table#field_table, table#new-account-table, table#create-new-user {
border: 1px solid #C3D9FF;
width: 78%;
}
table#field_table tbody, table#new-account-table tbody, table#create-new-user tbody {
background: none repeat scroll 0 0 #E8EEFA;
}
table#field_table tbody label {
float: right;
font-size: 10pt;
white-space: nowrap;
}
/* new user table */
table#create-new-user {
display: none;
margin-top: -22px;
}
table#new-account-table table td, table#create-new-user td {
font-size: 10pt;
}
td#form-message {
color: #EC1D1D;
display: none;
}
form#create-user table tbody tr:last-child td a{
color: #2200CC;
cursor: pointer;
font-size: 8pt;
text-decoration: underline;
}
/* new account "button" */
td#new-account-form {
color: #0000CC;
cursor: pointer;
font-weight: bold;
text-decoration: underline;
}
/* footer */
div.footer {
font-size: 10pt;
margin-top: 40px;
text-align: center;
}
div.footer a {
margin-left: 0.5em;
margin-right: 0.5em;
}
/**********************************************************
******************* dialog box ************************/
div.ui-dialog {
background: none repeat scroll 0 0 #C1D9FF;
}
fieldset#edit_document {
border: 0 none;
height: 72px;
margin-left: -1em;
margin-top: -0.5em;
width: 379px;
}
div.ui-dialog-titlebar {
background: none repeat scroll 0 0 #E0EDFE;
border: 0 none;
border-radius: 1px 1px 1px 1px;
height: 15px;
}
div.ui-dialog-titlebar {
height: 15px;
}
span#ui-dialog-title-edit_document, span#ui-dialog-title-upload_document, span#ui-dialog-title-gadget-listbox {
color: #222222 !important;
font: bold 12pt Arial,Sans-serif;
margin-left: -8px;
margin-top: -3px;
}
div#edit_document.ui-dialog-content {
background-color: #FFFFFF;
}
div#edit_document {
height: 80px;
overflow: hidden;
width: 368px;
}
.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset {
float: none !important;
height: 21px;
margin-top: -10px;
width: 104px;
}
.ui-dialog .ui-dialog-buttonpane button {
margin: 0 0.4em 0.5em 0 !important;
}
.ui-button .ui-button-text {
line-height: 1em !important;
}
.ui-button-text-only .ui-button-text {
padding: 0.2em 0.3em !important;
}
span.ui-button-text {
font-size: 12px;
}
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title></title> <title></title>
<script text="javascript"> function reloc(url) {window.location = url;}</script> <script type="text/javascript"> function reloc(url) {window.location = url;}</script>
</head> </head>
<body onload="reloc('ung.html');"> <body onload="reloc('ung.html');">
......
...@@ -38,6 +38,7 @@ var JSONIllustrationDocument = function() { ...@@ -38,6 +38,7 @@ var JSONIllustrationDocument = function() {
JSONIllustrationDocument.prototype = new JSONDocument();//inherits methods from JSONDocument JSONIllustrationDocument.prototype = new JSONDocument();//inherits methods from JSONDocument
JSONIllustrationDocument.prototype.saveEdition = function(content) { JSONIllustrationDocument.prototype.saveEdition = function(content) {
this.setLastUser(getCurrentUser());
this.setContent(content); this.setContent(content);
this.setLastModification(currentTime()); this.setLastModification(currentTime());
this.setAsCurrentDocument(); this.setAsCurrentDocument();
...@@ -46,7 +47,7 @@ JSONIllustrationDocument.prototype.setAsCurrentDocument = function() { ...@@ -46,7 +47,7 @@ JSONIllustrationDocument.prototype.setAsCurrentDocument = function() {
getCurrentPage().displayDocumentTitle(this); getCurrentPage().displayDocumentTitle(this);
getCurrentPage().displayDocumentState(this); getCurrentPage().displayDocumentState(this);
getCurrentPage().displayDocumentContent(this); getCurrentPage().displayDocumentContent(this);
getCurrentPage().displayAuthorName(this); getCurrentPage().displayLastUserName(this);
getCurrentPage().displayLastModification(this); getCurrentPage().displayLastModification(this);
setCurrentDocument(this); setCurrentDocument(this);
} }
......
...@@ -37,6 +37,7 @@ JSONSheetDocument.prototype.load({ ...@@ -37,6 +37,7 @@ JSONSheetDocument.prototype.load({
//save process //save process
saveEdition: function(content) { saveEdition: function(content) {
this.setLastUser(getCurrentUser());
this.setContent(content); this.setContent(content);
this.setLastModification(currentTime()); this.setLastModification(currentTime());
this.setAsCurrentDocument(); this.setAsCurrentDocument();
...@@ -47,7 +48,7 @@ JSONSheetDocument.prototype.load({ ...@@ -47,7 +48,7 @@ JSONSheetDocument.prototype.load({
getCurrentPage().displayDocumentTitle(this); getCurrentPage().displayDocumentTitle(this);
//getCurrentPage().displayDocumentContent(this); //getCurrentPage().displayDocumentContent(this);
getCurrentPage().displayDocumentState(this); getCurrentPage().displayDocumentState(this);
getCurrentPage().displayAuthorName(this); getCurrentPage().displayLastUserName(this);
getCurrentPage().displayLastModification(this); getCurrentPage().displayLastModification(this);
setCurrentDocument(this); setCurrentDocument(this);
} }
......
...@@ -45,6 +45,7 @@ var JSONTextDocument = function() { ...@@ -45,6 +45,7 @@ var JSONTextDocument = function() {
JSONTextDocument.prototype = new JSONDocument();//inherits methods from JSONDocument JSONTextDocument.prototype = new JSONDocument();//inherits methods from JSONDocument
JSONTextDocument.prototype.saveEdition = function(content) { JSONTextDocument.prototype.saveEdition = function(content) {
this.setLastUser(getCurrentUser());
this.setContent(content); this.setContent(content);
this.setLastModification(currentTime()); this.setLastModification(currentTime());
this.setAsCurrentDocument(); this.setAsCurrentDocument();
...@@ -53,7 +54,7 @@ JSONTextDocument.prototype.setAsCurrentDocument = function() { ...@@ -53,7 +54,7 @@ JSONTextDocument.prototype.setAsCurrentDocument = function() {
getCurrentPage().displayDocumentTitle(this); getCurrentPage().displayDocumentTitle(this);
getCurrentPage().displayDocumentState(this); getCurrentPage().displayDocumentState(this);
getCurrentPage().displayDocumentContent(this); getCurrentPage().displayDocumentContent(this);
getCurrentPage().displayAuthorName(this); getCurrentPage().displayLastUserName(this);
getCurrentPage().displayLastModification(this); getCurrentPage().displayLastModification(this);
setCurrentDocument(this); setCurrentDocument(this);
} }
......
...@@ -61,7 +61,6 @@ Page.prototype = { ...@@ -61,7 +61,6 @@ Page.prototype = {
case "text-editor": case "text-editor":
editor = new Xinha(); editor = new Xinha();
doc=new JSONTextDocument(); doc=new JSONTextDocument();
saveAdresse = "dav/temp.json";
break; break;
case "table-editor": case "table-editor":
editor = new SheetEditor(); editor = new SheetEditor();
...@@ -70,7 +69,6 @@ Page.prototype = { ...@@ -70,7 +69,6 @@ Page.prototype = {
case "image-editor": case "image-editor":
editor = new SVGEditor(); editor = new SVGEditor();
doc=new JSONIllustrationDocument(); doc=new JSONIllustrationDocument();
saveAdresse = "dav/temp2.json";
break; break;
default://renvoie à la page d'accueil default://renvoie à la page d'accueil
window.location = "ung.html"; window.location = "ung.html";
...@@ -125,7 +123,7 @@ Page.prototype = { ...@@ -125,7 +123,7 @@ Page.prototype = {
displayUserName: function(user) {$("a#userName").html(user.getName());}, displayUserName: function(user) {$("a#userName").html(user.getName());},
//document information //document information
displayAuthorName: function(doc) {$("a#author").html(doc.getAuthor());}, displayLastUserName: function(doc) {$("a#author").html(doc.getAuthor());},
displayLastModification: function(doc) {$("a#last_update").html(doc.getLastModification());}, displayLastModification: function(doc) {$("a#last_update").html(doc.getLastModification());},
displayDocumentTitle: function(doc) {$("a#document_title").html(doc.getTitle());}, displayDocumentTitle: function(doc) {$("a#document_title").html(doc.getTitle());},
displayDocumentContent: function(doc) {this.getEditor().loadContentFromDocument(doc);}, displayDocumentContent: function(doc) {this.getEditor().loadContentFromDocument(doc);},
...@@ -144,7 +142,7 @@ setCurrentPage = function(page) {currentPage = page;} ...@@ -144,7 +142,7 @@ setCurrentPage = function(page) {currentPage = page;}
*/ */
var User = function(details) { var User = function(details) {
this.name = "unknown"; this.name = "unknown";
this.language = "fr"; this.language = "en";
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";
this.displayPreferences = 15;//number of displayed document in the list this.displayPreferences = 15;//number of displayed document in the list
...@@ -190,6 +188,7 @@ var JSONDocument = function() { ...@@ -190,6 +188,7 @@ var JSONDocument = function() {
this.version = null; this.version = null;
this.author=getCurrentUser().getName(); this.author=getCurrentUser().getName();
this.lastUser=getCurrentUser().getName();
this.title="Untitled"; this.title="Untitled";
this.content=""; this.content="";
this.creation=currentTime(); this.creation=currentTime();
...@@ -201,6 +200,7 @@ JSONDocument.prototype = new UngObject();//inherits from UngObject ...@@ -201,6 +200,7 @@ JSONDocument.prototype = new UngObject();//inherits from UngObject
JSONDocument.prototype.load({//add methods thanks to the UngObject.load method JSONDocument.prototype.load({//add methods thanks to the UngObject.load method
//type //type
getType: function() {return this.type;}, getType: function() {return this.type;},
setType: function(newType) {this.type = newType;},
//version //version
getVersion: function() {return this.version;}, getVersion: function() {return this.version;},
...@@ -221,6 +221,8 @@ JSONDocument.prototype.load({//add methods thanks to the UngObject.load method ...@@ -221,6 +221,8 @@ JSONDocument.prototype.load({//add methods thanks to the UngObject.load method
//author //author
getAuthor:function() {return this.author;}, getAuthor:function() {return this.author;},
setAuthor:function(userName) {this.author=userName;}, setAuthor:function(userName) {this.author=userName;},
getLastUser:function() {return this.lastUser;},
setLastUser:function(user) {this.lastUser = user;},
//dates //dates
getCreation:function() {return this.creation;}, getCreation:function() {return this.creation;},
...@@ -235,7 +237,10 @@ JSONDocument.prototype.load({//add methods thanks to the UngObject.load method ...@@ -235,7 +237,10 @@ JSONDocument.prototype.load({//add methods thanks to the UngObject.load method
setCurrentDocument(this); setCurrentDocument(this);
}, },
save: function() {} save: function(instruction) {
var doc = this;
saveFile(getDocumentAddress(this), doc, instruction);
}
}); });
JSONDocument.prototype.states = { JSONDocument.prototype.states = {
draft:{"fr":"Brouillon","en":"Draft"}, draft:{"fr":"Brouillon","en":"Draft"},
...@@ -248,21 +253,20 @@ getCurrentDocument = function() { ...@@ -248,21 +253,20 @@ getCurrentDocument = function() {
return doc; return doc;
} }
setCurrentDocument = function(doc) {localStorage.setItem("currentDocument",JSON.stringify(doc));} setCurrentDocument = function(doc) {localStorage.setItem("currentDocument",JSON.stringify(doc));}
getDocumentList = function() {
var list = new DocumentList();
list.load(JSON.parse(localStorage.getItem("documentList")));
return 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"} undefined:{editorPage:null,icon:"images/icons/other.gif"}
} }
getDocumentAddress = function(doc) {return "dav/"+doc.getCreation();}
/* /*************************************************
* actions ****************** actions ******************
*************************************************/
/**
* open a dialog box to edit document information
*/ */
editDocumentSettings = function() { editDocumentSettings = function() {
loadFile("xml/xmlElements.xml", "html", function(data) { loadFile("xml/xmlElements.xml", "html", function(data) {
...@@ -277,6 +281,7 @@ editDocumentSettings = function() { ...@@ -277,6 +281,7 @@ editDocumentSettings = function() {
doc.setTitle($(this).find("#name").attr("value")); doc.setTitle($(this).find("#name").attr("value"));
doc.setLanguage($(getCurrentDocument()).find("#language").attr("value")); doc.setLanguage($(getCurrentDocument()).find("#language").attr("value"));
doc.setVersion($(getCurrentDocument()).find("#version").attr("value")); doc.setVersion($(getCurrentDocument()).find("#version").attr("value"));
saveCurrentDocument();
doc.setAsCurrentDocument();//diplay modifications doc.setAsCurrentDocument();//diplay modifications
$(this).dialog("close"); $(this).dialog("close");
}, },
...@@ -290,11 +295,31 @@ editDocumentSettings = function() { ...@@ -290,11 +295,31 @@ editDocumentSettings = function() {
saveCurrentDocument = function() { saveCurrentDocument = function() {
getCurrentPage().getEditor().saveEdition(); getCurrentPage().getEditor().saveEdition();
saveXHR(saveAdresse); getCurrentDocument().save();
//saveJIO(); : JIO function
} }
changeLanguage = function(language) { /**
* start an editor to edit the document
* @param doc : the document to edit
*/
var startDocumentEdition = function(doc) {
loadFile(getDocumentAddress(doc),"json",function(data) {
doc.load(data);
setCurrentDocument(doc);
if(supportedDocuments[doc.getType()].editorPage) {window.location = "theme.html";}
else alert("no editor available for this document");
});
}
var stopDocumentEdition = function() {
saveCurrentDocument();
window.location = "ung.html";
}
/**
* change the language of the user and reload the web page
* @param language : the new language
*/
var changeLanguage = function(language) {
var user = getCurrentUser(); var user = getCurrentUser();
user.setLanguage(language); user.setLanguage(language);
setCurrentUser(user); setCurrentUser(user);
......
...@@ -45,7 +45,12 @@ var List = function(arg) { ...@@ -45,7 +45,12 @@ var List = function(arg) {
List.prototype = new UngObject(); List.prototype = new UngObject();
List.prototype.load ({ List.prototype.load ({
size: function() {return this.length;}, size: function() {return this.length;},
add: function(element) {this.content[this.size()]=element; this.length++;}, put: function(key,value) {
if(!this.content[key]) {this.length=this.length+1;}
alert(""+this.length+this.content[key]);
this.content[key]=value;
},
add: function(element) {this.put(this.size(),element);},
get: function(i) {return this.content[i];}, get: function(i) {return this.content[i];},
concat: function(list) {while(!list.isEmpty()) {this.add(list.pop())}}, concat: function(list) {while(!list.isEmpty()) {this.add(list.pop())}},
remove: function(i) {delete this.content[i];this.length--;}, remove: function(i) {delete this.content[i];this.length--;},
...@@ -56,9 +61,22 @@ List.prototype.load ({ ...@@ -56,9 +61,22 @@ List.prototype.load ({
var element = this.get(this.size()-1); var element = this.get(this.size()-1);
this.remove(this.size()-1); this.remove(this.size()-1);
return element; return element;
} },
recursiveCall: function(instruction) {
var list = new List();
list.load(this);
if(list.isEmpty()) {return false;}
var result = instruction(list.pop());
return result ? result : list.recursiveCall(instruction);
},
find: function(object) {
for(var i = 0; i<this.length; i++) {if(this.get(i)===object) {return i;}}
return -1;
},
contains: function(object) { return (find(object)!=-1); }
}); });
/** /**
* returns the current date * returns the current date
*/ */
...@@ -82,35 +100,37 @@ saveXHR = function(address) { ...@@ -82,35 +100,37 @@ saveXHR = function(address) {
}); });
}; };
/**
* load a public file with a basic ajax request
* @param address : the address of the document
* @param type : the type of the document content
* @param instruction : a function to execute when getting the document
*/
loadFile = function(address, type, instruction) { loadFile = function(address, type, instruction) {
$.ajax({ $.ajax({
url: address, url: address,
type: "GET", type: "GET",
dataType: type, dataType: type,
success: instruction success: instruction,
error: function(type) {t=type;alert("er");}
}); });
} }
// load methode, used for testing // save
//(Francois) saveFile = function(address, content, instruction) {
loadTest = function(address) {
$.ajax({ $.ajax({
url: address, url: address,
type: "GET", type: "PUT",
dataType: "json", dataType: "json",
/*headers: { data: JSON.stringify(content),
Authorization: "Basic "+"nom:test"}, headers: { Authorization: "Basic "+btoa("smik:asdf")},
fields: { fields: { withCredentials: "true" },
withCredentials: "true" success: instruction,
},*/ error: function(type) {
success: function(data){ if(type.status==201) {instruction();}//ajax thinks that 201 is an error...
var list = getDocumentList(); }
var doc = new JSONDocument();
doc.load(data);
list.add(doc);
}
}); });
} };
// load // load
loadXHR = function(address) { loadXHR = function(address) {
...@@ -164,8 +184,11 @@ tryUntilSucceed = function(func) { ...@@ -164,8 +184,11 @@ tryUntilSucceed = function(func) {
} }
/** /**
* Resize the right part of ung * Resize the right part of ung main page
* could be developed to implement more beautiful resizments
*/ */
var resize = function() { var resize = function() {
$("div.main-right").width($(window).width()-$("div.main-left").width()); $("div.main-right").width($(window).width()-$("div.main-left").width());
} }
\ No newline at end of file
...@@ -2,41 +2,102 @@ ...@@ -2,41 +2,102 @@
* This file provides the javascript used to display the list of user's documents * This file provides the javascript used to display the list of user's documents
*/ */
/* global variable */
/* the last modified document */
getCurrentDocumentID = function() {return localStorage.getItem("currentDocumentID");}
setCurrentDocumentID = function(ID) {return localStorage.setItem("currentDocumentID",ID);}
/** /**
* 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
*/ */
var DocumentList = function() {List.call(this);} var DocumentList = function() {
List.call(this);
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) { get: function(i) {
var doc = new JSONDocument(); var doc = new JSONDocument();
doc.load(this.content[i]); doc.load(this.content[i]);
return doc; return doc;
}, },
add: function(doc) { /* override : put an element at the specified position */
this.content[this.size()]=doc; put: function(i, doc) {
this.length++; this.content[i]=doc;
setDocumentList(this) if(!this.content[i]) {this.length++;}
setDocumentList(this);
}, },
display: function() {
var n = getDocumentList().size(); getSelectionList: function() {
var list = new List();
list.load(this.selectionList);
return list;
},
resetSelectionList: function() {
this.selectionList = new List();
for(var i=0; i<this.length; i++) {
$("tr td.listbox-table-select-cell input#"+i).attr("checked",false);
}
setDocumentList(this);
},
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);
}
setDocumentList(this);
},
getDisplayedPage: function() {return this.displayedPage;},
setDisplayedPage: function(index) {this.displayedPage = index;},
/* display the list of documents in the web page */
displayContent: function() {
var n = this.size();
for(var i=0;i<n;i++) { for(var i=0;i<n;i++) {
var ligne = new Line(getDocumentList().get(i),0); var ligne = new Line(this.get(i),i);
ligne.updateHTML(); ligne.updateHTML();
ligne.display(); ligne.display();
} }
} },
}) displayListInformation: function() {
if(this.size()>0) {
/* initialize the list */ $("div.listbox-number-of-records").css("display","inline");
//current lines are just for testing var step = getCurrentUser().getDisplayPreferences();
setDocumentList(new List()); var first = (this.getDisplayedPage()-1)*step + 1;
loadTest("dav/temp.json"); var last = (this.size()<first+step) ? this.size() : first+step-1;
loadTest("dav/temp2.json"); $("span#page_start_number").html(first);
getDocumentList().add(new JSONDocument()); $("span#page_stop_number").html(last);
$("span#total_row_number a").html(this.size());
$("span#selected_row_number a").html(this.getSelectionList().size());
}
else {$("div.listbox-number-of-records").css("display","none");}
},
display: function() {
this.displayContent();
this.displayListInformation();
},
/* update the ith document information */
update: function(i) {
var line = this;
var doc = line.get(i);
loadFile(getDocumentAddress(doc),"json",function(data) {
doc.load(data);//todo : replace by data.header
doc.setContent("");//
line.put(i,doc);
});
}
});
getDocumentList = function() {
var list = new DocumentList();
list.load(JSON.parse(localStorage.getItem("documentList")));
return list;
}
setDocumentList = function(list) {localStorage.setItem("documentList",JSON.stringify(list));}
/** /**
...@@ -56,16 +117,38 @@ Line.prototype = { ...@@ -56,16 +117,38 @@ Line.prototype = {
getHTML: function() {return this.html;}, getHTML: function() {return this.html;},
setHTML: function(newHTML) {this.html = newHTML;}, setHTML: function(newHTML) {this.html = newHTML;},
isSelected: function() { isSelected: function() {
return $("tr td.listbox-table-select-cell input#"+this.ID).attr("checked"); return $("tr td.listbox-table-select-cell input#"+this.getID()).attr("checked");
},
addToSelection: function() {
var list = getDocumentList();
list.getSelectionList().put(this.getID(),this);
setDocumentList(list);
},
removeFromSelection: function() {
var list = getDocumentList();
list.getSelectionList().remove(this.getID());
setDocumentList(list);
},
changeState: function() {
this.isSelected() ? this.addToSelection() : this.removeFromSelection();
test = getDocumentList().getSelectionList();
$("span#selected_row_number a").html(getDocumentList().getSelectionList().size());
}, },
/* 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; 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())//ID
.click(function() {line.changeState();})//clic on a checkbox
.end()
.find("td.listbox-table-data-cell") .find("td.listbox-table-data-cell")
.click(function() {line.startEdition(line.getDocument())})//clic .click(function() {//clic on a line
setCurrentDocumentID(line.getID());
startDocumentEdition(line.getDocument())
})
.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
...@@ -77,14 +160,7 @@ Line.prototype = { ...@@ -77,14 +160,7 @@ Line.prototype = {
.end()); .end());
}, },
/* 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 */
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 */ /* load the html code of a default line */
Line.loadHTML = function() { Line.loadHTML = function() {
...@@ -93,3 +169,22 @@ Line.loadHTML = function() { ...@@ -93,3 +169,22 @@ 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;}
/**
* create a new document and start an editor to edit it
* @param type : the type of the document to create
*/
var createNewDocument = function(type) {
var newDocument = new JSONDocument();
newDocument.setType(type);
newDocument.save(function() {
getDocumentList().add(newDocument);
startDocumentEdition(newDocument);
});
}
var deleteSelectedDocuments = function() {
}
\ No newline at end of file
This diff is collapsed.
...@@ -32,15 +32,18 @@ ...@@ -32,15 +32,18 @@
<script type="text/javascript"> <script type="text/javascript">
var initUser = function() { var initUser = function() {
var user = getCurrentUser(); var user = getCurrentUser();
if(!user) { user = new User();}
user.setAsCurrentUser(); user.setAsCurrentUser();
} }
var init = function() { var init = function() {
setCurrentPage(new Page()); setCurrentPage(new Page());//provide methods on the page
initUser(); initUser();//initialize the user
waitBeforeSucceed(
function(){return Line.loadHTML()},getDocumentList().display if(getCurrentDocumentID()) {getDocumentList().update(getCurrentDocumentID());}//update the list of documents
waitBeforeSucceed(//display the list of documents
function(){return Line.loadHTML()},function() {
getDocumentList().resetSelectionList();
getDocumentList().display();}
); );
resize(); resize();
...@@ -52,13 +55,8 @@ ...@@ -52,13 +55,8 @@
<body> <body>
<form id="main_form" class="main_form" <form id="main_form" class="main_form"
onsubmit="changed=false; return true" onsubmit="changed=false; return true"
action="none"
method="post"> method="post">
<fieldset id="hidden_fieldset" class="hidden_fieldset">
<input type="hidden" name="cancel_url" value="http://10.0.112.141:12001/erp5/web_site_module/ung/view" />
</fieldset>
<div class="container"> <div class="container">
<div class="navigation"> <div class="navigation">
...@@ -75,7 +73,7 @@ ...@@ -75,7 +73,7 @@
<div class="input"><div > <div class="input"><div >
<a class="email" href="/ung/mail">Email</a> <a class="email" href="/ung/mail">Email</a>
<a class="document" href="/web_site_module/ung">Documents</a> <a class="document" href="#" onclick="window.location.reload()">Documents</a>
<a class="calendar" href="/ung/calendar">Calendar</a> <a class="calendar" href="/ung/calendar">Calendar</a>
</div></div> </div></div>
</div> </div>
...@@ -153,7 +151,7 @@ ...@@ -153,7 +151,7 @@
<div class="input"><div > <div class="input"><div >
<a class="ung_docs" href="#" onclick="javascript:window.location.reload()"> <a class="ung_docs" href="#" onclick="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>
...@@ -199,19 +197,19 @@ ...@@ -199,19 +197,19 @@
</a> </a>
<ul> <ul>
<li> <li>
<a href="web_illustration_template"> <a href="#" onclick="createNewDocument('illustration')">
<img src="images/icons/svg.png" alt=""/> <img src="images/icons/svg.png" alt=""/>
<span>Web Illustration</span> <span>Web Illustration</span>
</a> </a>
</li> </li>
<li> <li>
<a href="web_table_template"> <a href="#" onclick="createNewDocument('table')">
<img src="images/icons/table.png" alt=""/> <img src="images/icons/table.png" alt=""/>
<span>Web Table</span> <span>Web Table</span>
</a> </a>
</li> </li>
<li> <li>
<a href="web_page_template"> <a href="#" onclick="createNewDocument('text')">
<img src="images/icons/document.png"/> <img src="images/icons/document.png"/>
<span>Web Page</span> <span>Web Page</span>
</a> </a>
...@@ -511,17 +509,17 @@ ...@@ -511,17 +509,17 @@
<!-- listbox start - stop number --> <!-- listbox start - stop number -->
<span id="page_start_number" class="listbox-current-page-start-number">1</span> - <span id="page_start_number" class="listbox-current-page-start-number">1</span> -
<span id="page_stop_number" class="listbox-current-page-stop-number">6</span> <span id="page_stop_number" class="listbox-current-page-stop-number">...</span>
<span>of</span> <span>of</span>
<!-- listbox total rows number --> <!-- listbox total rows number -->
<span id="total_row_number" class="listbox-current-page-total-number your_listbox-current-page-total-number"> <span id="total_row_number" class="listbox-current-page-total-number your_listbox-current-page-total-number">
6 records <a>?</a> records
</span> </span>
<!-- listbox selected rows number --> <!-- listbox selected rows number -->
<span id="selected_row_number" class="your_listbox-current-item-number"> <span id="selected_row_number" class="your_listbox-current-item-number">
- 0 items selected - <a>0</a> items selected
</span> </span>
</div> </div>
...@@ -549,6 +547,7 @@ ...@@ -549,6 +547,7 @@
name="your_listbox_checkAll:method" name="your_listbox_checkAll:method"
value="1" alt="Check All" value="1" alt="Check All"
title="Check All" title="Check All"
onclick="getDocumentList().checkAll()"
src="images/icons/checkall.png" /> src="images/icons/checkall.png" />
&nbsp; &nbsp;
...@@ -557,6 +556,7 @@ ...@@ -557,6 +556,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()"
src="images/icons/decheckall.png" /> src="images/icons/decheckall.png" />
</th> </th>
......
...@@ -11,6 +11,5 @@ ...@@ -11,6 +11,5 @@
</content> </content>
<dependencies> <dependencies>
<scriptfile>js/image-editor.js</scriptfile> <scriptfile>js/image-editor.js</scriptfile>
<stylefile>css/jquery-ui.css</stylefile>
</dependencies> </dependencies>
</root> </root>
This diff is collapsed.
...@@ -2,13 +2,10 @@ ...@@ -2,13 +2,10 @@
<root> <root>
<rename> <rename>
<form action="#"> <form action="#">
<fieldset> <fieldset id="edit_document">
<label for="name">Insert a new name:</label> <label for="name">Insert a new name:</label>
<input type="text" class="title" id="name" name="name" value=""/><br/> <input type="text" class="title" id="name" name="name" value=""/><br/>
<div id="more_property"> <div id="more_property">
<label for="short_title">Short Title:</label>
<input type="text" class="short_title" id="short_title" name="short_title" value=""/><br/>
<label for="version">Version:</label> <label for="version">Version:</label>
<input type="text" class="version" id="version" name="version" value=""/><br/> <input type="text" class="version" id="version" name="version" value=""/><br/>
<label for="language">Language:</label> <label for="language">Language:</label>
......
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