Commit 89fe5ca8 authored by Lingnan Wu's avatar Lingnan Wu

add a new button in list page to remove all the lists

parent 1c7b82ab
/*
* jQuery Mobile Framework : plugin to provide a simple Dialog widget.
* Copyright (c) JTSage
* CC 3.0 Attribution. May be relicensed without permission/notifcation.
* https://github.com/jtsage/jquery-mobile-simpledialog
*/
.ui-simpledialog-header h4{margin-top:5px;margin-bottom:5px;text-align:center}.ui-simpledialog-container{border:5px solid #111!important;width:85%;max-width:500px}.ui-simpledialog-screen{position:absolute;top:0;left:0;width:100%;height:100%}.ui-simpledialog-hidden{display:none}.ui-simpledialog-input{width:85%!important;display:block!important;margin-left:auto;margin-right:auto}.ui-simpledialog-screen-modal{background-color:black;-moz-opacity:.8;opacity:.80;filter:alpha(opacity=80)}.ui-simpledialog-subtitle{text-align:center}.ui-simpledialog-controls .buttons-separator{min-height:.6em}.ui-simpledialog-controls .button-hidden{display:none}.ui-dialog .ui-simpledialog-container{border:none!important}.ui-dialog-simpledialog .ui-content{padding:5px!important}
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<head> <head>
<title>OfficeJS-Mobile</title> <title>OfficeJS-Mobile</title>
<link rel="stylesheet" href="css/themes/default/jquery.mobile-1.1.0.css" /> <link rel="stylesheet" href="css/themes/default/jquery.mobile-1.1.0.css" />
<link rel="stylesheet" href="css/simpledialog.min.css" />
<script src="js/jquery.js"></script> <script src="js/jquery.js"></script>
<script src="js/jquery.mobile-1.1.0.js"></script> <script src="js/jquery.mobile-1.1.0.js"></script>
<script type="text/javascript" src="lib/jstorage/jstorage.js"></script> <script type="text/javascript" src="lib/jstorage/jstorage.js"></script>
...@@ -11,6 +12,8 @@ ...@@ -11,6 +12,8 @@
<script type="text/javascript" src="lib/base64/base64.js"></script> <script type="text/javascript" src="lib/base64/base64.js"></script>
<script type="text/javascript" src="lib/sjcl/sjcl.min.js"></script> <script type="text/javascript" src="lib/sjcl/sjcl.min.js"></script>
<script type="text/javascript" src="src/jio.storage.js"></script> <script type="text/javascript" src="src/jio.storage.js"></script>
<script type="text/javascript" src="js/simpledialog2.min.js"></script>
<script type="text/javascript" src="js/officejs-mobile.js"></script> <script type="text/javascript" src="js/officejs-mobile.js"></script>
<script type="text/javascript" src="js/list-page.js"></script> <script type="text/javascript" src="js/list-page.js"></script>
<script type="text/javascript" src="js/text-editor.js"></script> <script type="text/javascript" src="js/text-editor.js"></script>
...@@ -104,6 +107,9 @@ $('#input_json_applicant').attr('value'));"> ...@@ -104,6 +107,9 @@ $('#input_json_applicant').attr('value'));">
<div data-role="content" style="padding: 15px"> <div data-role="content" style="padding: 15px">
<ul class="ui-listview" data-role="listview" id="textlist"> <ul class="ui-listview" data-role="listview" id="textlist">
</ul> </ul>
<div>
<a href="#" id="removeall" data-role="button" data-theme="a">Remove All</a>
</div>
</div> </div>
</div> </div>
......
...@@ -25,7 +25,7 @@ NewList = function (listnumber,listname,listcontent){ ...@@ -25,7 +25,7 @@ NewList = function (listnumber,listname,listcontent){
//set a tag //set a tag
newa = document.createElement("a"); newa = document.createElement("a");
newa.setAttribute("id",listname); newa.setAttribute("id",listname);
newa.setAttribute("class","ui-link-inherit"); newa.setAttribute("class","listcontent ui-link-inherit");
newa.setAttribute("href","#text"); newa.setAttribute("href","#text");
newa.setAttribute("onclick","OfficeJS.load(this.id);"); newa.setAttribute("onclick","OfficeJS.load(this.id);");
newSeconddiv.appendChild(newa); newSeconddiv.appendChild(newa);
...@@ -47,3 +47,54 @@ NewList = function (listnumber,listname,listcontent){ ...@@ -47,3 +47,54 @@ NewList = function (listnumber,listname,listcontent){
newFirstdiv.appendChild(newshadow); newFirstdiv.appendChild(newshadow);
} }
//set the List
setList = function (result_return_value){
removeLists();
//set all the list
for(var i=0;i<result_return_value.length;i++){
NewList(i,result_return_value[i].name,"text-Editor");
}
}
//remove all lists
removeLists = function(){
var n = document.getElementById('textlist').childNodes.length;
for ( var i = 0; i < n; i++) {
document.getElementById('textlist').removeChild(
document.getElementById('textlist').firstChild);
}
}
//set the popup dialog for remove all button
$(document).delegate('#removeall', 'click', function() {
$('<div>').simpledialog2({
mode: 'button',
headerText: 'Are you sure?',
headerClose: true,
buttonPrompt: 'Can not be retrieved',
buttons : {
'OK': {
click: function () {
RemoveAllDocument();
removeLists();
}
},
'Cancel': {
click: function () {
},
icon: "delete",
theme: "c"
}
}
})
})
//remove all
RemoveAllDocument = function(){
var document_name_array = [];
var document_list=document.getElementsByClassName('listcontent');
for (var i = 0; i < document_list.length; i++) {
document_name_array.push(document_list[i].id);
}
OfficeJS.removeSeveralFromArray (document_name_array);
}
...@@ -471,10 +471,7 @@ ...@@ -471,10 +471,7 @@
'onResponse':function (result) { 'onResponse':function (result) {
if (result.status === 'done') { if (result.status === 'done') {
priv.data_object.documentList = result.return_value; priv.data_object.documentList = result.return_value;
//set the List setList(result.return_value);
for(var i=0;i<result.return_value.length;i++){
NewList(i,result.return_value[i].name,"text-Editor");
}
//priv.showDocumentListInsideLeftNavBar(); //priv.showDocumentListInsideLeftNavBar();
} else { } else {
console.error (result.message); console.error (result.message);
...@@ -587,23 +584,23 @@ ...@@ -587,23 +584,23 @@
* @param {array} documentarray Contains all file names ({string}). * @param {array} documentarray Contains all file names ({string}).
*/ */
that.removeSeveralFromArray = function (documentarray) { that.removeSeveralFromArray = function (documentarray) {
var i, l, cpt = 0, current_editor = priv.data_object.currentEditor; var i, l, cpt = 0;//current_editor = priv.data_object.currentEditor;
if (!priv.isJioSet()) { if (!priv.isJioSet()) {
console.error ('No Jio set yet.'); console.error ('No Jio set yet.');
return; return;
} }
for (i = 0, l = documentarray.length; i < l; i+= 1) { for (i = 0, l = documentarray.length; i < l; i+= 1) {
priv.loading_object.remove(); // priv.loading_object.remove();
priv.jio.removeDocument({ priv.jio.removeDocument({
name:documentarray[i], name:documentarray[i],
onResponse:function (result) { onResponse:function (result) {
cpt += 1; cpt += 1;
if (cpt === l) { if (cpt === l) {
if (typeof current_editor.update !== 'undefined') { // if (typeof current_editor.update !== 'undefined') {
that.getList(current_editor.update); // that.getList(current_editor.update);
// }
} }
} // priv.loading_object.end_remove();
priv.loading_object.end_remove();
}}); }});
} }
}; };
......
This diff is collapsed.
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