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

Implement button to change language

parent 00469f12
/* /*
* global variables * global variables
*/ */
var languages = ["fr","en"]; languages = ["fr","en"];
var availableLanguages = window.document.getElementById("available_languages"); var availableLanguages = window.document.getElementById("available_languages");
currentPage = null; currentPage = null;
...@@ -86,10 +86,12 @@ Page.prototype = { ...@@ -86,10 +86,12 @@ Page.prototype = {
/* display the list of availaible languages */ /* display the list of availaible languages */
displayLanguages: function(user) { displayLanguages: function(user) {
var avLang = ""; var avLang = "";
for (var l in languages) {
for (var i = 0; i<languages.length; i++) {
var l = languages[i];
if(l==user.getLanguage()) {this.getHTML().getElementById("current_language").innerHTML = l;} if(l==user.getLanguage()) {this.getHTML().getElementById("current_language").innerHTML = l;}
else { else {
avLang = avLang + "<li><span onclick='getCurrentUser.setLanguage(this.innerHTML)' id="+l+">"+l+"</span></li>\n" avLang = avLang + "<li><span onclick='changeLanguage(this.innerHTML)' id='" +l+ "'>"+l+"</span></li>\n"
} }
} }
this.getHTML().getElementById("available_languages").innerHTML = avLang; this.getHTML().getElementById("available_languages").innerHTML = avLang;
...@@ -136,17 +138,13 @@ User.prototype = { ...@@ -136,17 +138,13 @@ User.prototype = {
getName: function() {return this.name;}, getName: function() {return this.name;},
setName: function(newName) {this.name = newName;}, setName: function(newName) {this.name = newName;},
getLanguage: function() {return this.language;}, getLanguage: function() {return this.language;},
setLanguage:function(language) { setLanguage:function(language) {this.language = language;},
this.language = language;
getCurrentPage().displayLanguages();
},
getStorageLocation: function() {return this.storage;}, getStorageLocation: function() {return this.storage;},
setStorageLocation: function(storage) {this.storage = storage;}, setStorageLocation: function(storage) {this.storage = storage;},
getIdentityProvider: function() {return this.identityProvider;}, getIdentityProvider: function() {return this.identityProvider;},
setIdentityProvider: function(IDProv) {this.identityProvider = IDProv;}, setIdentityProvider: function(IDProv) {this.identityProvider = IDProv;},
setAsCurrentUser: function() { setAsCurrentUser: function() {
getCurrentPage().displayUserName(this); getCurrentPage().displayUserName(this);
getCurrentPage().displayLanguages(this); getCurrentPage().displayLanguages(this);
setCurrentUser(this); setCurrentUser(this);
...@@ -169,6 +167,9 @@ setCurrentUser = function(user) {localStorage.setItem("currentUser", JSON.string ...@@ -169,6 +167,9 @@ setCurrentUser = function(user) {localStorage.setItem("currentUser", JSON.string
/* JSON document */ /* JSON document */
var JSONDocument = function() { var JSONDocument = function() {
this.type = "text"; this.type = "text";
this.language = getCurrentUser().getLanguage();
this.version = null;
this.author=getCurrentUser().getName(); this.author=getCurrentUser().getName();
this.title="Untitled"; this.title="Untitled";
this.content=""; this.content="";
...@@ -182,6 +183,14 @@ JSONDocument.prototype = { ...@@ -182,6 +183,14 @@ JSONDocument.prototype = {
//type //type
getType: function() {return this.type;}, getType: function() {return this.type;},
//version
getVersion: function() {return this.version;},
setVersion: function(version) {this.version = version;},
//language
getLanguage: function() {return this.language;},
setLanguage: function(language) {this.language = language;},
//content //content
getContent:function() {return this.content;}, getContent:function() {return this.content;},
setContent:function(content) {this.content=content;}, setContent:function(content) {this.content=content;},
...@@ -223,13 +232,40 @@ setCurrentDocument = function(doc) {localStorage.setItem("currentDocument",JSON. ...@@ -223,13 +232,40 @@ setCurrentDocument = function(doc) {localStorage.setItem("currentDocument",JSON.
/* /*
* tools * actions
*/ */
currentTime = function() {return (new Date()).toUTCString();} editDocumentSettings = function() {
$("#edit_document").dialog({
autoOpen: false,
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");
}
}
});
}
changeLanguage = function(language) {
var user = getCurrentUser();
user.setLanguage(language);
setCurrentUser(user);
getCurrentPage().displayLanguages(user);
}
cancel_sharing = function() {alert("cancel");} cancel_sharing = function() {alert("cancel");}
translate = function() {alert("translate");} translate = function() {alert("translate");}
submit = function() {alert("submit");} submit = function() {alert("submit");}
share = function() {alert("share");} share = function() {alert("share");}
//test = new User();
\ No newline at end of file
...@@ -33,7 +33,8 @@ ...@@ -33,7 +33,8 @@
// initialize // initialize
init = function() { init = function() {
setCurrentPage("editor"); setCurrentPage("editor");
new User(); alert(getCurrentUser());
if(getCurrentUser()==null) {new User();}
doc = new JSONTextDocument();//load the document (it's just for testing) doc = new JSONTextDocument();//load the document (it's just for testing)
doc.setAsCurrentDocument(); doc.setAsCurrentDocument();
} }
...@@ -141,7 +142,7 @@ ...@@ -141,7 +142,7 @@
</a> </a>
<a id="loading_message" lang="en">Loading...</a> <a id="loading_message" lang="en">Loading...</a>
<a id="document_title" name="document_title" onclick="javascript:rename()">Untitled</a> <a id="document_title" name="document_title" onclick="javascript:editDocumentSettings()">Untitled</a>
<a id="document_state" name="document_state">...</a> <a id="document_state" name="document_state">...</a>
<div id="edit_document" title="Rename Document"> <div id="edit_document" title="Rename Document">
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<div class="input"> <div class="input">
<link rel="stylesheet" href="js/jquery/plugin/sheet/jquery.sheet.css" type="text/css" /> <link rel="stylesheet" href="js/jquery/plugin/sheet/jquery.sheet.css" type="text/css" />
<link rel="stylesheet" href="jquery.sheet.erp5.css" type="text/css" /> <link rel="stylesheet" href="jquery_sheet_editor/jquery.sheet.erp5.css" type="text/css" />
<link rel="stylesheet" href="js/jquery/plugin/colorpicker/jquery.colorPicker.css" type="text/css" /> <link rel="stylesheet" href="js/jquery/plugin/colorpicker/jquery.colorPicker.css" type="text/css" />
<link rel="stylesheet" href="js/jquery/plugin/colorpicker/menu.css" type="text/css" /> <link rel="stylesheet" href="js/jquery/plugin/colorpicker/menu.css" type="text/css" />
...@@ -67,88 +67,88 @@ ...@@ -67,88 +67,88 @@
<span id="inlineMenu" style="display: none;"> <span id="inlineMenu" style="display: none;">
<span> <span>
<a href="#" onclick="sheetInstance.controlFactory.addRow(); return false;" title="Insert Row After Selected"> <a href="#" onclick="sheetInstance.controlFactory.addRow(); return false;" title="Insert Row After Selected">
<img alt="Insert Row After Selected" src="jquery_sheet_image/sheet_row_add.png" /> <img alt="Insert Row After Selected" src="jquery_sheet_editor/jquery_sheet_image/sheet_row_add.png" />
</a> </a>
<a href="#" onclick="sheetInstance.controlFactory.addRow(null, true); return false;" title="Insert Row Before Selected"> <a href="#" onclick="sheetInstance.controlFactory.addRow(null, true); return false;" title="Insert Row Before Selected">
<img alt="Insert Row Before Selected" src="jquery_sheet_image/sheet_row_add.png" /> <img alt="Insert Row Before Selected" src="jquery_sheet_editor/jquery_sheet_image/sheet_row_add.png" />
</a> </a>
<a href="#" onclick="sheetInstance.controlFactory.addRow(null, null, ':last'); return false;" title="Add Row At End"> <a href="#" onclick="sheetInstance.controlFactory.addRow(null, null, ':last'); return false;" title="Add Row At End">
<img alt="Add Row" src="jquery_sheet_image/sheet_row_add.png" /> <img alt="Add Row" src="jquery_sheet_editor/jquery_sheet_image/sheet_row_add.png" />
</a> </a>
<a href="#" onclick="sheetInstance.controlFactory.addRowMulti(); return false;" title="Add Multi-Rows"> <a href="#" onclick="sheetInstance.controlFactory.addRowMulti(); return false;" title="Add Multi-Rows">
<img alt="Add Multi-Rows" src="jquery_sheet_image/sheet_row_add_multi.png" /> <img alt="Add Multi-Rows" src="jquery_sheet_editor/jquery_sheet_image/sheet_row_add_multi.png" />
</a> </a>
<a href="#" onclick="sheetInstance.deleteRow(); return false;" title="Delete Row"> <a href="#" onclick="sheetInstance.deleteRow(); return false;" title="Delete Row">
<img alt="Delete Row" src="jquery_sheet_image/sheet_row_delete.png" /> <img alt="Delete Row" src="jquery_sheet_editor/jquery_sheet_image/sheet_row_delete.png" />
</a> </a>
<a href="#" onclick="sheetInstance.controlFactory.addColumn(); return false;" title="Insert Column After Selected"> <a href="#" onclick="sheetInstance.controlFactory.addColumn(); return false;" title="Insert Column After Selected">
<img alt="Insert Column After Selected" src="jquery_sheet_image/sheet_col_add.png" /> <img alt="Insert Column After Selected" src="jquery_sheet_editor/jquery_sheet_image/sheet_col_add.png" />
</a> </a>
<a href="#" onclick="sheetInstance.controlFactory.addColumn(null, true); return false;" title="Insert Column Before Selected"> <a href="#" onclick="sheetInstance.controlFactory.addColumn(null, true); return false;" title="Insert Column Before Selected">
<img alt="Insert Column Before Selected" src="jquery_sheet_image/sheet_col_add.png" /> <img alt="Insert Column Before Selected" src="jquery_sheet_editor/jquery_sheet_image/sheet_col_add.png" />
</a> </a>
<a href="#" onclick="sheetInstance.controlFactory.addColumn(null, null, ':last'); return false;" title="Add Column At End"> <a href="#" onclick="sheetInstance.controlFactory.addColumn(null, null, ':last'); return false;" title="Add Column At End">
<img alt="Add Column At End" src="jquery_sheet_image/sheet_col_add.png" /> <img alt="Add Column At End" src="jquery_sheet_editor/jquery_sheet_image/sheet_col_add.png" />
</a> </a>
<a href="#" onclick="sheetInstance.controlFactory.addColumnMulti(); return false;" title="Insert Multi-Columns"> <a href="#" onclick="sheetInstance.controlFactory.addColumnMulti(); return false;" title="Insert Multi-Columns">
<img alt="Add Multi-Columns" src="jquery_sheet_image/sheet_col_add_multi.png" /> <img alt="Add Multi-Columns" src="jquery_sheet_editor/jquery_sheet_image/sheet_col_add_multi.png" />
</a> </a>
<a href="#" onclick="sheetInstance.deleteColumn(); return false;" title="Delete Column"> <a href="#" onclick="sheetInstance.deleteColumn(); return false;" title="Delete Column">
<img alt="Delete Column" src="jquery_sheet_image/sheet_col_delete.png" /> <img alt="Delete Column" src="jquery_sheet_editor/jquery_sheet_image/sheet_col_delete.png" />
</a> </a>
<a href="#" onclick="sheetInstance.getTdRange(null, sheetInstance.obj.formula().val()); return false;" title="Get Cell Range"> <a href="#" onclick="sheetInstance.getTdRange(null, sheetInstance.obj.formula().val()); return false;" title="Get Cell Range">
<img alt="Get Cell Range" src="jquery_sheet_image/sheet_get_range.png" /> <img alt="Get Cell Range" src="jquery_sheet_editor/jquery_sheet_image/sheet_get_range.png" />
</a> </a>
<a href="#" onclick="sheetInstance.deleteSheet(); return false;" title="Delete Current Sheet"> <a href="#" onclick="sheetInstance.deleteSheet(); return false;" title="Delete Current Sheet">
<img alt="Delete Current Sheet" src="jquery_sheet_image/table_delete.png" /> <img alt="Delete Current Sheet" src="jquery_sheet_editor/jquery_sheet_image/table_delete.png" />
</a> </a>
<a href="#" onclick="sheetInstance.calc(sheetInstance.i); return false;" title="Refresh Calculations"> <a href="#" onclick="sheetInstance.calc(sheetInstance.i); return false;" title="Refresh Calculations">
<img alt="Refresh Calculations" src="jquery_sheet_image/arrow_refresh.png" /> <img alt="Refresh Calculations" src="jquery_sheet_editor/jquery_sheet_image/arrow_refresh.png" />
</a> </a>
<a href="#" onclick="sheetInstance.cellFind(); return false;" title="Find"> <a href="#" onclick="sheetInstance.cellFind(); return false;" title="Find">
<img alt="Find" src="jquery_sheet_image/find.png" /> <img alt="Find" src="jquery_sheet_editor/jquery_sheet_image/find.png" />
</a> </a>
<a href="#" onclick="sheetInstance.cellStyleToggle('styleBold'); return false;" title="Bold"> <a href="#" onclick="sheetInstance.cellStyleToggle('styleBold'); return false;" title="Bold">
<img alt="Bold" src="jquery_sheet_image/text_bold.png" /> <img alt="Bold" src="jquery_sheet_editor/jquery_sheet_image/text_bold.png" />
</a> </a>
<a href="#" onclick="sheetInstance.cellStyleToggle('styleItalics'); return false;" title="Italic"> <a href="#" onclick="sheetInstance.cellStyleToggle('styleItalics'); return false;" title="Italic">
<img alt="Italic" src="jquery_sheet_image/text_italic.png" /> <img alt="Italic" src="jquery_sheet_editor/jquery_sheet_image/text_italic.png" />
</a> </a>
<a href="#" onclick="sheetInstance.cellStyleToggle('styleUnderline', 'styleLineThrough'); return false;" title="Underline"> <a href="#" onclick="sheetInstance.cellStyleToggle('styleUnderline', 'styleLineThrough'); return false;" title="Underline">
<img alt="Underline" src="jquery_sheet_image/text_underline.png" /> <img alt="Underline" src="jquery_sheet_editor/jquery_sheet_image/text_underline.png" />
</a> </a>
<a href="#" onclick="sheetInstance.cellStyleToggle('styleLineThrough', 'styleUnderline'); return false;" title="Strikethrough"> <a href="#" onclick="sheetInstance.cellStyleToggle('styleLineThrough', 'styleUnderline'); return false;" title="Strikethrough">
<img alt="Strikethrough" src="jquery_sheet_image/text_strikethrough.png" /> <img alt="Strikethrough" src="jquery_sheet_editor/jquery_sheet_image/text_strikethrough.png" />
</a> </a>
<a href="#" onclick="sheetInstance.cellStyleToggle('styleLeft', 'styleCenter styleRight'); return false;" title="Align Left"> <a href="#" onclick="sheetInstance.cellStyleToggle('styleLeft', 'styleCenter styleRight'); return false;" title="Align Left">
<img alt="Align Left" src="jquery_sheet_image/text_align_left.png" /> <img alt="Align Left" src="jquery_sheet_editor/jquery_sheet_image/text_align_left.png" />
</a> </a>
<a href="#" onclick="sheetInstance.cellStyleToggle('styleCenter', 'styleLeft styleRight'); return false;" title="Align Center"> <a href="#" onclick="sheetInstance.cellStyleToggle('styleCenter', 'styleLeft styleRight'); return false;" title="Align Center">
<img alt="Align Center" src="jquery_sheet_image/text_align_center.png" /> <img alt="Align Center" src="jquery_sheet_editor/jquery_sheet_image/text_align_center.png" />
</a> </a>
<a href="#" onclick="sheetInstance.cellStyleToggle('styleRight', 'styleLeft styleCenter'); return false;" title="Align Right"> <a href="#" onclick="sheetInstance.cellStyleToggle('styleRight', 'styleLeft styleCenter'); return false;" title="Align Right">
<img alt="Align Right" src="jquery_sheet_image/text_align_right.png" /> <img alt="Align Right" src="jquery_sheet_editor/jquery_sheet_image/text_align_right.png" />
</a> </a>
<a href="#" onclick="sheetInstance.fillUpOrDown(); return false;" title="Fill Down"> <a href="#" onclick="sheetInstance.fillUpOrDown(); return false;" title="Fill Down">
<img alt="Fill Down" src="jquery_sheet_image/arrow_down.png" /> <img alt="Fill Down" src="jquery_sheet_editor/jquery_sheet_image/arrow_down.png" />
</a> </a>
<a href="#" onclick="sheetInstance.fillUpOrDown(true); return false;" title="Fill Up"> <a href="#" onclick="sheetInstance.fillUpOrDown(true); return false;" title="Fill Up">
<img alt="Fill Up" src="jquery_sheet_image/arrow_up.png" /> <img alt="Fill Up" src="jquery_sheet_editor/jquery_sheet_image/arrow_up.png" />
</a> </a>
<span class="colorPickers"> <span class="colorPickers">
<input title="Foreground color" class="colorPickerFont" style="background-image: url('jquery_sheet_image/palette.png') ! important; width: 16px; height: 16px;" /> <input title="Foreground color" class="colorPickerFont" style="background-image: url('jquery_sheet_editor/jquery_sheet_image/palette.png') ! important; width: 16px; height: 16px;" />
<input title="Background Color" class="colorPickerCell" style="background-image: url('jquery_sheet_image/palette_bg.png') ! important; width: 16px; height: 16px;" /> <input title="Background Color" class="colorPickerCell" style="background-image: url('jquery_sheet_editor/jquery_sheet_image/palette_bg.png') ! important; width: 16px; height: 16px;" />
</span> </span>
<a href="#" onclick="sheetInstance.obj.formula().val('=HYPERLINK(\'' + prompt('Enter Web Address', 'http://www.visop-dev.com/') + '\')').keydown(); return false;" title="HyperLink"> <a href="#" onclick="sheetInstance.obj.formula().val('=HYPERLINK(\'' + prompt('Enter Web Address', 'http://www.visop-dev.com/') + '\')').keydown(); return false;" title="HyperLink">
<img alt="Web Link" src="jquery_sheet_image/page_link.png" /> <img alt="Web Link" src="jquery_sheet_image/page_link.png" />
</a> </a>
<a href="#" onclick="sheetInstance.toggleFullScreen(); $('#lockedMenu').toggle(); return false;" title="Toggle Full Screen"> <a href="#" onclick="sheetInstance.toggleFullScreen(); $('#lockedMenu').toggle(); return false;" title="Toggle Full Screen">
<img alt="Web Link" src="jquery_sheet_image/arrow_out.png" /> <img alt="Web Link" src="jquery_sheet_editor/jquery_sheet_image/arrow_out.png" />
</a> </a>
</span> </span>
......
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