Commit 29c3e6dd authored by Tristan Cavelier's avatar Tristan Cavelier Committed by Sebastien Robin

Adding spinning job icons to show what is on going.

parent 68c01140
...@@ -123,7 +123,14 @@ ...@@ -123,7 +123,14 @@
</head> </head>
<body> <body>
<div id="loading" style="position: absolute; right: 20px; top: 20px;"></div> <div id="loading" style="position:absolute;right:10px;top:10px;width:100px;height:40px;">
<div id="loading_spin" style="background-image:url('img/icons/loading_spin_16.gif');width:16px;height:16px;float:right;display:none;"></div>
<div id="loading_spin" style="width:16px;height:16px;float:right;"></div>
<div id="loading_getlist" style="float:right;display:none;"><i class="icon-refresh icon-white"></i></div>
<div id="loading_save" style="float:right;display:none;"><i class="icon-download-alt icon-white"></i></div>
<div id="loading_load" style="float:right;display:none;"><i class="icon-upload icon-white"></i></div>
<div id="loading_remove" style="float:right;display:none;"><i class="icon-remove icon-white"></i></div>
</div>
<div class="navbar"> <div class="navbar">
<div class="navbar-inner"> <div class="navbar-inner">
<div class="container-fluid"> <div class="container-fluid">
......
...@@ -136,9 +136,41 @@ require(['OfficeJS'],function (OJS) { ...@@ -136,9 +136,41 @@ require(['OfficeJS'],function (OJS) {
default: default:
return null; return null;
} }
}; },
// end get the current editor // end get the current editor
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// loading function
loading_object = {
spinstate: 0,savestate: 0,loadstate: 0,getliststate: 0,removestate: 0,
main: function (string){
if (this[string+'state'] === 0){
document.querySelector ('#loading_'+string).
style.display = 'block';
}
this[string+'state'] ++;
},
end_main: function (string){
if (this[string+'state']>0) {
this[string+'state']--;
}
if (this[string+'state']===0){
document.querySelector ('#loading_'+string).
style.display = 'none';
}
},
spin:function(){this.main('spin');},
save:function(){this.main('save');this.spin();},
load:function(){this.main('load');this.spin();},
getlist:function(){this.main('getlist');this.spin();},
remove:function(){this.main('remove');this.spin();},
end_spin:function(){this.end_main('spin');},
end_save:function(){this.end_main('save');this.end_spin();},
end_load:function(){this.end_main('load');this.end_spin();},
end_getlist:function(){this.end_main('getlist');this.end_spin();},
end_remove:function(){this.end_main('remove');this.end_spin();}
}
// end loading function
////////////////////////////////////////////////////////////////////////////
// repaint the page // repaint the page
hrefClicked(); hrefClicked();
...@@ -167,14 +199,17 @@ require(['OfficeJS'],function (OJS) { ...@@ -167,14 +199,17 @@ require(['OfficeJS'],function (OJS) {
alert ('No Jio set yet.'); alert ('No Jio set yet.');
return; return;
} }
loading_object.save();
filename = $('#input_fileName').attr('value'); filename = $('#input_fileName').attr('value');
filecontent = getCurrentEditor().getHTML(); filecontent = getCurrentEditor().getHTML();
priv.jio.saveDocument({ priv.jio.saveDocument({
'fileName':filename, 'fileName':filename,
'fileContent':filecontent, 'fileContent':filecontent,
'callback':function (result){ 'callback':function (result){
alert (result.isSaved ? 'Document Saved.' : if (result.status === 'fail') {
'Error: ' + result.message); console.error ('Error: ' + result.message);
}
loading_object.end_save();
publ.getlist(); publ.getlist();
} }
}); });
...@@ -193,9 +228,8 @@ require(['OfficeJS'],function (OJS) { ...@@ -193,9 +228,8 @@ require(['OfficeJS'],function (OJS) {
if (result.document.fileName) { if (result.document.fileName) {
getCurrentEditor().setHTML( getCurrentEditor().setHTML(
result.document.fileContent); result.document.fileContent);
alert ('Document loaded');
} else { } else {
alert ('Error: ' + result.message); console.error ('Error: ' + result.message);
} }
loading_object.end_load(); loading_object.end_load();
} }
...@@ -207,12 +241,15 @@ require(['OfficeJS'],function (OJS) { ...@@ -207,12 +241,15 @@ require(['OfficeJS'],function (OJS) {
alert ('No Jio set yet.'); alert ('No Jio set yet.');
return; return;
} }
loading_object.remove();
filename = $('#input_fileName').attr('value'); filename = $('#input_fileName').attr('value');
priv.jio.removeDocument({ priv.jio.removeDocument({
'fileName':filename, 'fileName':filename,
'callback':function (result) { 'callback':function (result) {
alert (result.isRemoved?'Document Removed.': if (result.status === 'fail') {
'Error: '+result.message); console.error ('Error: ' + result.message);
}
loading_object.end_remove();
publ.getlist(); publ.getlist();
} }
}); });
...@@ -222,6 +259,7 @@ require(['OfficeJS'],function (OJS) { ...@@ -222,6 +259,7 @@ require(['OfficeJS'],function (OJS) {
alert ('No Jio set yet.'); alert ('No Jio set yet.');
return; return;
} }
loading_object.getlist();
priv.jio.getDocumentList({ priv.jio.getDocumentList({
'maxtries':3, 'maxtries':3,
'callback':function (result) { 'callback':function (result) {
...@@ -245,6 +283,7 @@ require(['OfficeJS'],function (OJS) { ...@@ -245,6 +283,7 @@ require(['OfficeJS'],function (OJS) {
ich_object.DocumentList = document_array; ich_object.DocumentList = document_array;
document.querySelector ('#document_list'). document.querySelector ('#document_list').
innerHTML = htmlString; innerHTML = htmlString;
loading_object.end_getlist();
} }
}); });
}; };
......
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