Changeset 881
- Timestamp:
- Apr 6, 2015 5:13:24 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pro-violet-viettel/www/deploy/20150304/assets/js/manager.js
r880 r881 23 23 if (o.navigationbar == undefined) 24 24 o.navigationbar = null; 25 25 26 26 if (o.oTree == undefined) 27 27 o.oTree = null; … … 60 60 act: null 61 61 }; 62 62 63 63 var aryPath = []; 64 64 65 65 if (o.homeNode == undefined) 66 66 o.homeNode = null; … … 208 208 manager: oContainer 209 209 }); 210 210 211 211 self.setHomeNode(); 212 212 213 213 self.refreshStatusBar(); 214 214 }; … … 322 322 }); 323 323 }); 324 324 325 325 $(document).on({ 326 326 ajaxStart: function() { $("body").addClass("loading"); }, 327 ajaxStop: function() { $("body").removeClass("loading"); } 327 ajaxStop: function() { $("body").removeClass("loading"); } 328 328 }); 329 329 330 330 sendCommand({ 331 331 postdata: null, … … 357 357 } 358 358 359 var searchItemsByParent = function (parentID, 360 type) { 359 var searchItemsByParent = function (parentID, type) { 361 360 var data = {}; 362 361 var aryItem = []; … … 415 414 416 415 } 417 416 418 417 var btnDownloadClick = function () { 419 418 var items = o.oGrid.getHighLightItem(); … … 439 438 self.redirectPost(url, { 440 439 data: JSON.stringify(items) 441 }); 442 443 444 440 }); 441 442 443 445 444 } 446 445 … … 600 599 return bootbox.dialog(promptOptions); 601 600 } 602 601 603 602 var uploadDone = function (result) { 604 603 605 604 } 606 605 607 606 var btnPreviewClick = function () { 608 607 var items = o.oGrid.getHighLightItem(); … … 707 706 var content = "KhÃŽng há» trợ xem trưá»c loại tá»p nà y, vui lòng tải xuá»ng và xem trên máy"; 708 707 bootbox.alert(content); 709 708 710 709 } 711 710 … … 791 790 792 791 } 793 }, 792 }, 794 793 fail: function (e, data) { 795 794 // Something has … … 932 931 933 932 var items = []; 933 var aryDupplicated = []; 934 var messageText = ''; 934 935 935 936 var destination = self.getTreeCurrentNode(); 936 if (oClipBoard.act != 'copy') {937 /*$(oClipBoard.items).each(937 /*if (oClipBoard.act != 'copy') { 938 $(oClipBoard.items).each( 938 939 function (index) { 939 940 var node = new Object; 940 941 if (this.type == 'directory') 941 942 buildTreeFromParent(this.id, node); 942 943 943 944 else { 944 945 node.id = this.id; … … 947 948 948 949 items[index] = node; 949 });*/ 950 951 } else { 950 }); 951 952 } else {*/ 953 var destinationChildDirs = searchItemsByParent(destination, 'directory'); 954 var destinationChildFiles = searchItemsByParent(destination, 'file'); 955 952 956 items = oClipBoard.items; 953 } 954 957 958 for (var i = 0; i < items.length; i++) { 959 if (items[i].type == 'directory' ) { 960 for (var d = 0; d < destinationChildDirs.length; d++) { 961 if (destinationChildDirs[d].name == items[i].name) { 962 aryDupplicated.push(items[i]); 963 } 964 } 965 } 966 967 if (items[i].type == 'file' ) { 968 for (var f = 0; f < destinationChildFiles.length; f++) { 969 if (destinationChildFiles[f].name == items[i].name) { 970 aryDupplicated.push(items[i]); 971 } 972 } 973 } 974 } 975 //} 976 955 977 for (var i = 0; i < items.length; i++) { 956 978 if (items[i].type == 'directory') { … … 960 982 } 961 983 984 if (aryDupplicated.length > 0) { 985 if (aryDupplicated.length > 1){ 986 messageText = 'Các thư mục (files) '; 987 for (var m = 0; m < aryDupplicated.length; m++) { 988 messageText += '<strong>' + aryDupplicated[m].name + '</strong>, '; 989 } 990 } 991 else { 992 var type = aryDupplicated[0].type; 993 messageText = type == 'directory' ? 'Thư mục <strong>' + aryDupplicated[0].name + '</strong>' : 'File <strong>' + aryDupplicated[0].name + '</strong>'; 994 } 995 996 messageText += ' Äã tá»n tại, bạn có muá»n ghi ÄÚ lên khÃŽng?'; 997 998 var confirmOptions = { 999 message: messageText, 1000 buttons: { 1001 confirm: { 1002 label: "Ghi ÄÚ" 1003 }, 1004 cancel: { 1005 label: "Há»§y bá»" 1006 } 1007 }, 1008 callback: function (result) { 1009 console.log(result); 1010 } 1011 } 1012 1013 bootbox.confirm(confirmOptions); 1014 } 1015 } 1016 1017 var pasteComplete = function (items, destination) { 1018 if (items.length == 0 || destination == null) return false; 962 1019 var postdata = { 963 act: oClipBoard.act, 964 destination: destination, 965 data: JSON.stringify(items) 966 }; 967 var script = oClipBoard.act; 968 969 sendCommand({ 970 postdata: postdata, 971 script: script, 972 callbackSuccess: function (parseData) { 973 if (oClipBoard.act == 'copy') { 974 $(parseData.DIRECTORIES).each( 975 function (index) { 976 o.data.DIRECTORIES[$(o.data.DIRECTORIES).length] = this; 977 }); 978 979 $(parseData.FILES).each( 980 function (index) { 981 o.data.FILES[$(o.data.FILES).length] = this; 982 }); 983 984 o.data.DIRECTORIES.sort(function (a, b) { 985 return a.parentID - b.parentID; 986 }); 987 988 o.oTree.setData(o.data.DIRECTORIES); 989 o.oGrid.setData(o.data); 990 o.oTree.createCopyNode(parseData.DIRECTORIES); 991 o.oGrid.reloadGrid(); 992 } else if (oClipBoard.act == 'move') { 993 1020 act: oClipBoard.act, 1021 destination: destination, 1022 data: JSON.stringify(items) 1023 }; 1024 var script = oClipBoard.act; 1025 1026 sendCommand({ 1027 postdata: postdata, 1028 script: script, 1029 callbackSuccess: function (parseData) { 1030 if (oClipBoard.act == 'copy') { 1031 $(parseData.DIRECTORIES).each( 1032 function (index) { 1033 o.data.DIRECTORIES[$(o.data.DIRECTORIES).length] = this; 1034 }); 1035 1036 $(parseData.FILES).each( 1037 function (index) { 1038 o.data.FILES[$(o.data.FILES).length] = this; 1039 }); 1040 1041 o.data.DIRECTORIES.sort(function (a, b) { 1042 return a.parentID - b.parentID; 1043 }); 1044 1045 o.oTree.setData(o.data.DIRECTORIES); 1046 o.oGrid.setData(o.data); 1047 o.oTree.createCopyNode(parseData.DIRECTORIES); 1048 o.oGrid.reloadGrid(); 1049 } else if (oClipBoard.act == 'move') { 1050 1051 } 1052 1053 oClipBoard.act == ''; 1054 oClipBoard.items = null; 994 1055 } 995 996 oClipBoard.act == ''; 997 oClipBoard.items = null; 998 } 999 }); 1056 }); 1000 1057 } 1001 1058 … … 1021 1078 var childDirs = []; 1022 1079 var childFiles = []; 1023 1080 1024 1081 for(var i = 0; i < o.data.DIRECTORIES.length; i++) { 1025 1082 aryDirs[i] = o.data.DIRECTORIES[i]; 1026 1083 } 1027 1084 1028 1085 for (var i = 0; i < aryDirs.length; i++) { 1029 1086 if (aryDirs[i].parentID == parentID) { … … 1034 1091 } 1035 1092 } 1036 1093 1037 1094 return branch; 1038 1095 } 1039 1096 1040 1097 this.searchParents = function (objDir) { 1041 1098 var parentID = objDir.parentID; 1042 var aryDirs = []; 1043 1099 var aryDirs = []; 1100 1044 1101 aryDirs[0] = o.homeNode; 1045 1102 for(var i = 1; i <= o.data.DIRECTORIES.length; i++) { 1046 1103 aryDirs[i] = o.data.DIRECTORIES[i - 1]; 1047 1104 } 1048 1105 1049 1106 for (var i = 0; i < aryDirs.length; i++) { 1050 1107 if (aryDirs[i].id == parentID) { … … 1054 1111 } 1055 1112 } 1056 1113 1057 1114 this.deleteItem = function (item) { 1058 1115 … … 1191 1248 } 1192 1249 1193 1250 1194 1251 this.getTreeCurrentNode = function () { 1195 1252 return treeCurrentNode; … … 1315 1372 $(statusbar).html(message); 1316 1373 } 1317 1374 1318 1375 this.refreshNavigator = function () { 1319 1376 var navigatorBar = $('DIV#' + o.navigationbar + ' > UL.breadcrumb'); 1320 1377 $(navigatorBar).find('LI').remove(); 1321 1378 1322 1379 var nodeID = self.getTreeCurrentNode(); 1323 1380 if (nodeID != 0) { … … 1330 1387 aryPath.push(o.homeNode); 1331 1388 } 1332 1389 1333 1390 for(var idx = 0; idx < aryPath.length; idx++) { 1334 1391 var i = $('<i></i>',{'class':'ace-icon icon-folder-close home-icon'}); 1335 1392 var a = $('<a></a>',{text: aryPath[idx].name}); 1336 1393 var li = $('<li></li>'); 1337 if (aryPath[idx].id == 0) 1394 if (aryPath[idx].id == 0) 1338 1395 $(li).append(i, a); 1339 else 1396 else 1340 1397 $(li).append(a); 1341 1398 1342 1399 $(navigatorBar).append(li); 1343 1400 } 1344 1401 1345 1402 aryPath.splice(0,aryPath.length); 1346 1403 } 1347 1404 1348 1405 this.redirectPost = function (location, args) { 1349 1406 var form = ''; 1350 1407 $.each(args, function (key, value) { 1351 1408 1352 1409 form += "<input type='hidden' name='" 1353 1410 + key + "' value='" + value … … 1386 1443 } 1387 1444 } 1388 1445 1389 1446 this.setHomeNode = function () { 1390 1447 o.homeNode = {id:0, name:o.oTree.getRootName(), parentID:-1};
Note: See TracChangeset
for help on using the changeset viewer.