diff --git a/web/autoescape.gif b/web/autoescape.gif deleted file mode 100644 index 0070e30e5..000000000 Binary files a/web/autoescape.gif and /dev/null differ diff --git a/web/css/file_manager.css b/web/css/file_manager.css index ada907fce..9770b537a 100644 --- a/web/css/file_manager.css +++ b/web/css/file_manager.css @@ -3,7 +3,7 @@ body { margin: 0; padding: 0; } .l-logo { background-image: url("/images/sprite.png"); - background-position: -117px -34px; + background-position: -118px -59px; background-repeat: no-repeat; display: inline-block; float: left; @@ -18,36 +18,57 @@ body { margin: 0; padding: 0; } .window { display: inline-block; float: left; /*border: 1px solid #eee;*/ width: 50%; height: 100%; background-color: #ececec; /*background: url(/images/background-dots.png) #ececec;*/ } .window.active { background: #fff; } -.pwd { background-color: #7b7b7b; height: 31px; padding: 12px 0 0 17px; color: #eee; font-size: 14px; } +.pwd { background-color: #7b7b7b; height: 28px; padding: 12px 0 0 17px; color: #eee; font-size: 14px; } .window.active .pwd { background-color: #333; } .window.active .pwd a { color: #FFF; } .pwd a { color: #CFCFCF; margin-right: 6px; padding: 0 7px; cursor: pointer; text-decoration: none; } .window.active .pwd a:hover, .pwd a:hover { color: #FFCC00; } -.menu { background-color: #E2E2E0; display: inline-block; color: #999999; width: 100%; padding: 8px 0 7px 0; border-bottom: 1px solid #CFCFCD; border-left: 1px solid #CFCFCD; margin-left: -1px; } +.active .menu { box-shadow: 0 1px 11px -5px rgba(0, 0, 0, 0.5); } +.menu { /*background-color: #EEE;*/ display: inline-block; color: #999999; width: 100%; padding: 8px 0 7px 0; border-bottom: 1px solid #CFCFCD; border-left: 1px solid #CFCFCD; margin-left: -1px; } -.menu div { display: inline-block; float: left; padding: 5px 9px; font-size: 11px; margin: 0 3px; line-height: 14px; } -.menu div.button.disabled:hover, -.menu div.button { cursor: pointer; border: 1px solid #E2E2E0; border-radius: 3px; text-decoration: underline; background-color: #E2E2E0; - transition: box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1) 0s; - -webkit-transition: box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1) 0s; - box-shadow: none; color: #999; -} -.menu div.button:hover { border: 1px solid #B7B7B7; text-decoration: none; background-color: #FFF; /*#EAEAE8;*/ color: #333; -/* box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.64); */ - box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.29); -/* box-shadow: 0 6px 15px rgba( 0, 0, 0, 0.23), 0 10px 18px rgba( 0, 0, 0, 0.16);*/ -/* box-shadow: 0 3px 10px rgba(0, 0, 0, 0.23), 0 3px 10px rgba(0, 0, 0, 0.16);*/ +.menu div { display: inline-block; float: left; padding: 6px 5px 5px; font-size: 11px; margin: 0 3px; line-height: 14px; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; } +.window.active .menu div.button { color: #777; } + +.menu div.button.small { display: none; width: 19px; height: 12px; } +.menu div.button.small.mkfile { background: url("/images/flat_icons.png") no-repeat scroll -176px -97px; margin-left: 10px; } +.menu div.button.small.mkdir { background: url("/images/flat_icons.png") no-repeat scroll -176px -123px; } +.menu div.button.small.del { background: url("/images/flat_icons.png") no-repeat scroll -176px -149px; } +.menu div.button.small.rename { background: url("/images/flat_icons.png") no-repeat scroll -180px -180px; width: 12px; } +.menu div.button.small.copy { background: url("/images/flat_icons.png") no-repeat scroll -177px -210px; } +.menu div.button.small.download { background: url("/images/flat_icons.png") no-repeat scroll -176px -243px; } +.menu div.button.small.extract { background: url("/images/flat_icons.png") no-repeat scroll -232px -35px; } +.menu div.button.small.archive { background: url("/images/flat_icons.png") no-repeat scroll -175px -58px; } + + +.menu div.button.small.mkfile:hover { background-position: -203px -97px; } +.menu div.button.small.mkdir:hover { background-position: -203px -123px; } +.menu div.button.small.del:hover { background-position: -203px -149px; } +.menu div.button.small.rename:hover { background-position: -207px -180px; } +.menu div.button.small.copy:hover { background-position: -204px -210px; } +.menu div.button.small.download:hover { background-position: -204px -243px; } +.menu div.button.small.extract:hover { background: url("/images/flat_icons.png") no-repeat scroll -255px -35px; } +.menu div.button.small.archive:hover { background: url("/images/flat_icons.png") no-repeat scroll -201px -35px; } + + + + + +.menu div.button.disabled:hover, +.menu div.button { cursor: pointer; transition: box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1) 0s; -webkit-transition: box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1) 0s; box-shadow: none; color: #999 } +.window.active .menu div.button:hover, +.menu div.button:hover { text-decoration: none; color: #1FB9CA; border-radius: 0; } + .menu div.button.disabled:hover, .menu div.button.disabled { opacity: 0.5; cursor: default; text-decoration: none; } .menu .upload.button { color: #777; border: 1px solid #B7B7B7; background-color: #EAEAE8; text-transform: uppercase; font-size: 12px; text-decoration: none; margin-left: 8px; padding: 5px 12px; margin-right: 10px; border-radius: 3px; float: left; transition: box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1) 0s; -webkit-transition: box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1) 0s; font-size: 11px; line-height: 14px; } -.window.active .menu .upload { border: 1px solid #F79B44; background-color: #F79B44; color: #FFF; } +.window.active .menu .upload { border: 1px solid #AACC0D; background-color: #AACC0D; color: #FFF; } .menu .upload.button.progress { background: url(/images/progress.gif) no-repeat /*-98px*/ -60px 0px #EBEBEB; border-color: #8A9079; color: transparent; padding: 3px 12px; height: 0; margin-top: 9px; transition: background 0.28s cubic-bezier(0.4, 0, 0.2, 1) 0s; -webkit-transition: background 0.28s cubic-bezier(0.4, 0, 0.2, 1) 0s; @@ -55,22 +76,22 @@ body { margin: 0; padding: 0; } .menu .upload.button.progress.done { background-color: #d1ff66; border-color: #8a9079; box-shadow: 0 0 9px 0 #d1ff38; color: transparent; height: 0; margin-top: 9px; padding: 3px 12px; transition: background 0.28s cubic-bezier(0.4, 0, 0.2, 1) 0s; -webkit-transition: background 0.28s cubic-bezier(0.4, 0, 0.2, 1) 0s; transition: height 0.28s cubic-bezier(0.4, 0, 0.2, 1) 0s; -webkit-transition: height 0.28s cubic-bezier(0.4, 0, 0.2, 1) 0s; } -.menu .upload.button:hover, .window.active .menu .upload:hover { border: 1px solid #469D8D; background-color: #54bdaa; /*border: 1px solid #6DB8D3; background-color: #6DB8D3;*/ color: #fff; box-shadow: 0 2px 5px 0 rgba( 47, 106, 95, 0.8); } +.menu .upload.button:hover, .window.active .menu .upload:hover { border: 1px solid #C0E60F; background-color: #C0E60F; color: #fff; } .menu .upload.button:active, .window.active .menu .upload:active { border: 1px solid #FFCC00; background-color: #FFCC00; color: #FFF; } .menu .not-writable { color: #BD846A; font-size: 12px; text-decoration: none; margin-left: 10px; padding: 5px 12px; margin-right: 20px; } -.menu .sort-by { border-bottom: 1px solid #b7b7b7; border-radius: 0; cursor: pointer; float: right; height: 17px; line-height: 10px; margin-right: 8px; padding: 8px 10px 0; text-decoration: none; width: 100px; } -.menu .sort-by .direction { background: url("/images/flat_icons.png") repeat scroll -245px -76px; display: inline-block; float:right; width: 12px; height: 20px; margin-top: -10px; } -.menu .sort-by.desc .direction { background-position: -270px -76px; } +.menu .sort-by { border-radius: 0; cursor: pointer; float: right; height: 17px; line-height: 10px; margin-right: 8px; padding: 8px 10px 0; text-decoration: none; } +.menu .sort-by .direction { background: url("/images/flat_icons.png") repeat scroll -390px -76px; display: inline-block; float:right; width: 12px; height: 20px; margin-top: -10px; } +.menu .sort-by.desc .direction { background-position: -415px -76px; } .menu .sort-by span { font-size: 12px; color: #555; text-decoration: none; border: none; } .menu .sort-by span.entity { color: #555; text-decoration: none; border: none; float: right; display: inline-block; } -.menu .sort-by:hover span { color: #429586; } +.menu .sort-by:hover span { color: #43B2BE; } .menu .total-size { padding: 7px 0 0 0; } .menu .not-writable:hover { border: 1px solid #E2E2E0; } -ul.listing { list-style-type: none; padding: 18px 0 0; margin: 0; border-left: 1px solid #DDDDDD; margin-left: -1px; overflow: auto; } +ul.listing { list-style-type: none; padding: 18px 0 0; margin: -4px 0 0 -1px; border-left: 1px solid #DDDDDD; overflow: auto; } .listing li { color: #999999; display: block; height: 32px; margin: 1px 0 0; line-height: 30px; border: 1px solid transparent; } .listing li span { display: inline-block; float: right; } .listing li .marker { width: 4px; float: left; height: 100%; margin-right: 31px; } @@ -170,29 +191,35 @@ ul.listing { list-style-type: none; padding: 18px 0 0; margin: 0; border-left: .listing li .icon.filetype-xhtml { background: url("/images/flat_icons.png") no-repeat scroll -138px -228px; } -.listing li .filename { color: #555; cursor: pointer; height: 32px; float: left; padding: 0 7px 0 7px; border-radius: 3px; transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1) 0s; -webkit-transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1) 0s; } +.listing li .filename { color: #555; cursor: pointer; height: 32px; max-width: 40%; overflow: hidden; float: left; padding: 0 7px 0 7px; border-radius: 3px; transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1) 0s; -webkit-transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1) 0s; } /* .listing li .filename { background: url("/images/folder_.png") no-repeat scroll -2px 6px; color: #555; cursor: pointer; float: left; margin-left: -27px; padding-left: 19px; }*/ - +.listing li .filename:hover { color: #333; background-color: #D1D0CF; } +/* .listing li .filename:hover { color: #FFF; background-color: #6CB6B9; } .listing li.selected .filename:hover { color: #FFF; } .listing li.active .filename:hover { color: #FFF; background-color: #CAA335; } .listing li.active.selected .filename:hover { color: #FFF; background-color: #60A885; } - +*/ .listing li .filename a { color: #7D7D7D; text-decoration: none; } .listing li .mode { width: 51px; font-size: 11px; } .listing li .owner { width: 11%; font-style: italic; color: #81A64F; font-size: 12px; } -.listing li .size { width: 8%; color: #44a8b3; font-size: 12px; padding-right: 7px; text-align: right; } -.listing li .size-unit { width: 5%; font-size: 11px; font-weight: bold; color: #A7A7A7; padding-top: 1px; } -.listing li .date { width: 11%; font-size: 11px; } -.listing li .time { width: 8%; font-size: 11px; } +.listing li .size-value { width: 70px; color: #44a8b3; font-size: 12px; padding-right: 7px; text-align: right; } +.listing li .size-unit { width: 30px; font-size: 11px; font-weight: bold; color: #A7A7A7; text-align: left; } +.listing li .date { width: 50px; font-size: 11px; } +.listing li .time { width: 50px; font-size: 11px; } .listing li.selected-inactive.selected { background-color: #e9e9e9; border-top: 1px solid #ccc; border-bottom: 1px solid #ccc; } .listing li.selected-inactive .mode, .listing li.selected-inactive .time, .listing li.selected-inactive .date { color: #999 !important; } .window.active .listing li.selected.active { background-color: #73CAA0; } -.listing li.selected { background-color: #7FD5D9; } + +.listing li.selected { background-color: #777 /*#7FD5D9*/; } +.listing.active li.selected { background-color: #ffd437 /*#7FD5D9*/; } +.listing li.selected .filename:hover { color: #333; background-color: #F0B607; } + + .listing li.selected-inactive.selected.active { background-color: #dfc891; border-top: 1px solid #cdb885; border-bottom: 1px solid #cdb885; } @@ -202,7 +229,7 @@ ul.listing { list-style-type: none; padding: 18px 0 0; margin: 0; border-left: .listing li.selected .filename { color: #333; } .listing li.selected .date, .listing li.selected .mode, -.listing li.selected .time { color: #FFF; } +.listing li.selected .time { color: #777; } .listing li.selected .owner { color: #31775A; } .listing li.selected .size { color: #31775A; } @@ -213,9 +240,9 @@ ul.listing { list-style-type: none; padding: 18px 0 0; margin: 0; border-left: .listing li .filename a:hover { color: #3399FF; } -.listing li:hover { background-color: #F4F4F2; } +.listing li:hover { background-color: #E5E5E5; cursor: pointer; } .listing li.active:hover { background-color: #FFD63F; } -.listing li.selected:hover { background-color: #89E6EA; } +.listing li.selected:hover { background-color: /*#89E6EA*/#FFE570; } .listing li.selected.active:hover { background-color: #77D1A6; } @@ -238,12 +265,12 @@ ul.listing { list-style-type: none; padding: 18px 0 0; margin: 0; border-left: .context-menu.sort-order li.last { border: none; } .context-menu.sort-order li:hover { background-color: #333; } .context-menu.sort-order span { padding: 12px 12px 12px 12px; background: ulr(/images/flat_icons.png) } -.context-menu.sort-order span.up { background: url(/images/flat_icons.png) -255px -141px; padding: 12px 14px; display: inline-block; width: 16px; } +.context-menu.sort-order span.up { background: url(/images/flat_icons.png) -399px -141px; padding: 12px 14px; display: inline-block; width: 16px; } .context-menu.sort-order span.name, .context-menu.sort-order span.date, .context-menu.sort-order span.size, .context-menu.sort-order span.type - { background: url("/images/flat_icons.png") repeat scroll -162px -105px; display: inline-block; padding: 12px 28px 12px 12px; width: 64px; } + { background: url("/images/flat_icons.png") repeat scroll -308px -105px; display: inline-block; padding: 12px 28px 12px 12px; width: 64px; } @@ -281,7 +308,7 @@ ul.listing { list-style-type: none; padding: 18px 0 0; margin: 0; border-left: /*.confirm-box.delete { height: 183px; }*/ -.confirm-box .new-title { background-color: #292929; border: 1px solid #111; color: #fff; font-family: Arial; font-size: 16px; margin-bottom: 73px; margin-left: 27px; padding: 10px 14px; width: 396px; } +.confirm-box .new-title { background-color: #292929; border: 1px solid #111; color: #eee; font-family: Arial; font-size: 16px; margin-bottom: 73px; margin-left: 27px; padding: 10px 14px; width: 396px; } .confirm-box .new-title:focus { border: 1px solid #FFCC00; box-shadow: 0 0 5px 0 rgba(255, 204, 0 , 0.3); } /*.confirm-box.rename { height: 209px; } */ @@ -303,6 +330,11 @@ ul.listing { list-style-type: none; padding: 18px 0 0; margin: 0; border-left: .confirm-box.archive.warning .warning { display: inline-block; } .confirm-box.archive.warning .message { margin-bottom: -31px; } +.confirm-box.copy .message { margin-bottom: 0; } +.confirm-box.unpack .message { margin-bottom: 0; } +.confirm-box.pack .message { margin-bottom: 0; } + + .confirm-box .actions select { background-color: #333333; border: 1px solid #ccc; color: #fff; font-family: Arial; font-size: 16px; margin-bottom: 27px; margin-left: 27px; padding: 10px 14px; } .confirm-box .actions .title { color: #ccc; font-family: Arial; line-height: 33px; padding-left: 27px; text-transform: capitalize; } .confirm-box .actions label { cursor: pointer; padding-left: 27px; color: #ebe697; } @@ -436,3 +468,134 @@ ul.listing { list-style-type: none; padding: 18px 0 0; margin: 0; border-left: background-color: #FFCC00; } + + + + +.checkbox-toolbar { + float: left !important; +} +/*W +.check-label::before { + background-image: url("/images/sprite.png"); + background-position: -232px -9px; + background-repeat: no-repeat; + background-size: 450px auto; + content: ""; + display: inline-block; + height: 16px; + width: 16px; + margin-top: -25px; + + border: 1px solid red; +} +input[type="checkbox"] { + display: none; +} + +.clicked-on.check-label::before, .checkbox-selected .check-label { + background-position: -225px -42px; + content: ""; + display: inline-block; + height: 27px; + left: -6px; + top: -6px; + width: 27px; +} +*/ + +@media (max-width: 1400px) { + .listing li .filename { width: 35%; } +} + + +@media (max-width: 1320px) { + .menu div.button.mkfile, + .menu div.button.mkdir { display: none; } + .menu div.button.mkfile.small, + .menu div.button.mkdir.small { display: inline-block; } + .listing li .filename { max-width: 30%; } +} + +@media (max-width: 1210px) { + .menu div.button.del { display: none; } + .menu div.button.del.small { display: inline-block; } + .listing li .filename { max-width: 25%; } +} + + +@media (max-width: 1180px) { + .menu div.button { display: none; } + .menu div.button.medium, + .menu div.button.small { display: inline-block; } + .listing li .filename { max-width: 20%; } +} + +@media (max-width: 1080px) { + .listing li .owner { display: none; } +} + +@media (max-width: 890px) { + .window { width: 100%; } + .window:nth-of-type(2){ display: none; } + .listing li .owner { display: inline-block; } + + .menu div.button { display: inline-block; } + .menu div.button.small { display: none; } + .menu div.copy.button { display: none; } + .listing li .filename { max-width: 40%; } +} + +@media (max-width: 720px) { + .listing li .filename { max-width: 30%; } +} + +@media (max-width: 600px) { + .menu div.button { display: none; } + .menu div.button.medium, + .menu div.button.small { display: inline-block; } + .menu div.copy.button.small { display: none; } + .listing li .filename { max-width: 20%; } +} + +@media (max-width: 520px) { + .listing li .owner { display: none; } + .listing li .filename { max-width: 15%; } +} + +@media (max-width: 400px) { + .listing li .mode { display: none; } + .listing li .time { display: none; } + .listing li .filename { max-width: 30%; } +} + +@media (max-width: 360px) { + .listing li .date { display: none; } +} + +@media (max-width: 310px) { + .listing li .size { display: none; } +} + + +.subcontext-control.hidden { + display: none !important; +} + +.subcontext-control { + color: red; +} +.subcontext-menu-hidden { + display: none; +} + +.subcontext-menu { + position: absolute; + background-color: yellow; + padding: 10px; + border: 1px solid red; +} + +.subcontext-menu li { + /*float: left;*/ +} diff --git a/web/download/file/index.php b/web/download/file/index.php new file mode 100644 index 000000000..6065d0fc7 --- /dev/null +++ b/web/download/file/index.php @@ -0,0 +1,15 @@ + diff --git a/web/edit/file/index.php b/web/edit/file/index.php new file mode 100644 index 000000000..8b3f49a00 --- /dev/null +++ b/web/edit/file/index.php @@ -0,0 +1,76 @@ + + +Edit file <?= htmlspecialchars($_REQUEST['path']) ?> + + + + + + + + + + + +
+ + + + + +
+ diff --git a/web/file_manager/fm_api.php b/web/file_manager/fm_api.php index b8e40fa20..80615df91 100644 --- a/web/file_manager/fm_api.php +++ b/web/file_manager/fm_api.php @@ -27,18 +27,29 @@ $fm->setRootDir($panel[$user]['HOME']); $_REQUEST['action'] = empty($_REQUEST['action']) ? '' : $_REQUEST['action']; switch ($_REQUEST['action']) { + case 'cd': + $dir = $_REQUEST['dir']; + print json_encode($fm->ls($dir)); + break; case 'rename_file': $dir = $_REQUEST['dir']; $item = $_REQUEST['item']; $target_name = $_REQUEST['target_name']; - print json_encode($fm->renameItem($dir, $item, $target_name)); + print json_encode($fm->renameFile($dir, $item, $target_name)); + break; + case 'rename_directory': + $dir = $_REQUEST['dir']; + $item = $_REQUEST['item']; + $target_name = $_REQUEST['target_name']; + + print json_encode($fm->renameDirectory($dir, $item, $target_name)); break; case 'delete_files': $dir = $_REQUEST['dir']; $item = $_REQUEST['item']; - print json_encode($fm->deleteItems($dir, $item)); + print json_encode($fm->deleteItem($dir, $item)); break; case 'create_file': $dir = $_REQUEST['dir']; @@ -50,19 +61,38 @@ switch ($_REQUEST['action']) { $dirname = $_REQUEST['dirname']; print json_encode($fm->createDir($dir, $dirname)); break; - case 'cd': - $dir = $_REQUEST['dir']; - print json_encode($fm->ls($dir)); - break; + case 'open_file': $dir = $_REQUEST['dir']; print json_encode($fm->open_file($dir)); break; - case 'copy_files': + case 'copy_file': $dir = $_REQUEST['dir']; $target_dir = $_REQUEST['dir_target']; $filename = $_REQUEST['filename']; - print json_encode($fm->copyFile($dir, $target_dir, $filename)); + $item = $_REQUEST['item']; + print json_encode($fm->copyFile($item, $dir, $target_dir, $filename)); + break; + case 'copy_directory': + $dir = $_REQUEST['dir']; + $target_dir = $_REQUEST['dir_target']; + $filename = $_REQUEST['filename']; + $item = $_REQUEST['item']; + print json_encode($fm->copyDirectory($item, $dir, $target_dir, $filename)); + break; + case 'unpack_item': + $dir = $_REQUEST['dir']; + $target_dir = $_REQUEST['dir_target']; + $filename = $_REQUEST['filename']; + $item = $_REQUEST['item']; + print json_encode($fm->unpackItem($item, $dir, $target_dir, $filename)); + break; + case 'pack_item': + $dir = $_REQUEST['dir']; + $target_dir = $_REQUEST['dir_target']; + $filename = $_REQUEST['filename']; + $item = $_REQUEST['item']; + print json_encode($fm->packItem($item, $dir, $target_dir, $filename)); break; default: //print json_encode($fm->init()); diff --git a/web/file_manager/fm_core.php b/web/file_manager/fm_core.php index 61871b1bd..67ca31d51 100644 --- a/web/file_manager/fm_core.php +++ b/web/file_manager/fm_core.php @@ -32,7 +32,7 @@ class FileManager { $path = !empty($_REQUEST['dir']) ? $_REQUEST['dir'] : ''; $start_url = !empty($path) ? $this->ROOT_DIR . '/' . $path : $this->ROOT_DIR; $listing = $this->getDirectoryListing($path); - + return $data = array( 'result' => true, 'ROOT_DIR' => $this->ROOT_DIR, @@ -50,11 +50,34 @@ class FileManager { $path = $this->ROOT_DIR . '/' . $path_part; } //var_dump($path);die(); + //$path = str_replace(' ', '\ ', $path); return escapeshellarg($path); } - function deleteItems($dir, $item) { - if (is_readable($item)) { + function deleteItem($dir, $item) { + $dir = $this->formatFullPath($item); + if (is_dir($item)) { + exec (VESTA_CMD . "v-delete-fs-directory {$this->user} {$dir}", $output, $return_var); + } + else { + exec (VESTA_CMD . "v-delete-fs-file {$this->user} {$dir}", $output, $return_var); + } + + $error = self::check_return_code($return_var, $output); + + if (empty($error)) { + return array( + 'result' => true + ); + } + else { + return array( + 'result' => false, + 'message' => $error + ); + } + + /*if (is_readable($item)) { unlink($item); } if (is_readable($item)) { @@ -65,93 +88,194 @@ class FileManager { } return array( 'result' => true - ); + );*/ } - function copyFile($dir, $target_dir, $filename) { - // todo: checks - // todo: vesta method "create file" - if (empty($dir)) { - $dir = $this->ROOT_DIR; - } + function copyFile($item, $dir, $target_dir, $filename) { + $src = $this->formatFullPath($item); + $dst = $this->formatFullPath($target_dir); + + exec (VESTA_CMD . "v-copy-fs-file {$this->user} {$src} {$dst}", $output, $return_var); + + $error = self::check_return_code($return_var, $output); - if (empty($target_dir)) { - $target_dir = $this->ROOT_DIR; - } - copy($dir . '/' . $filename, $target_dir.'/'.$filename); - - if (!is_readable($target_dir . '/' .$filename)) { + if (empty($error)) { return array( - 'result' => false, - 'message' => 'item was not created' + 'result' => true ); } + else { + return array( + 'result' => false, + 'message' => $error + ); + } + } + + + function copyDirectory($item, $dir, $target_dir, $filename) { + $src = $this->formatFullPath($item); + $dst = $this->formatFullPath($target_dir); + + exec (VESTA_CMD . "v-copy-fs-directory {$this->user} {$src} {$dst}", $output, $return_var); + + + $error = self::check_return_code($return_var, $output); - return array( - 'result' => true, - 'bla' => $target_dir.'/'.$filename, - 'bla2' => $dir . '/' . $filename - ); + if (empty($error)) { + return array( + 'result' => true + ); + } + else { + return array( + 'result' => false, + 'message' => $error + ); + } + } + + static function check_return_code($return_var, $output) { + if ($return_var != 0) { + $error = implode('
', $output); + return $error; + //if (empty($error)) $error = __('Error code:',$return_var); + //$_SESSION['error_msg'] = $error; + } + + return null; } function createFile($dir, $filename) { - // todo: checks - // todo: vesta method "create file" - if (empty($dir)) { - $dir = $this->ROOT_DIR; - } - file_put_contents($dir . '/' . $filename, ''); + $dir = $this->formatFullPath($dir . '/' . $filename); + + exec (VESTA_CMD . "v-add-fs-file {$this->user} {$dir}", $output, $return_var); + + $error = self::check_return_code($return_var, $output); - if (!is_readable($dir . '/' .$filename)) { + if (empty($error)) { return array( - 'result' => false, - 'message' => 'item was not created' + 'result' => true + ); + } + else { + return array( + 'result' => false, + 'message' => $error ); } - - return array( - 'result' => true - ); } - function renameItem($dir, $item, $target_name) { - if (empty($dir)) { - $dir = $this->ROOT_DIR; - } - if (is_readable($dir . '/' . $item)) { - rename($dir . '/' . $item, $dir . '/' . $target_name); - } - if (!is_readable($dir . '/' .$target_name)) { + function packItem($item, $dir, $target_dir, $filename) { + $item = $this->formatFullPath($item); + $dst_item = $this->formatFullPath($target_dir); +//print VESTA_CMD . "v-add-fs-archive {$this->user} {$item} {$dst_item}";die(); + exec (VESTA_CMD . "v-add-fs-archive {$this->user} {$item} {$dst_item}", $output, $return_var); + + $error = self::check_return_code($return_var, $output); + + if (empty($error)) { return array( - 'result' => false, - 'message' => 'item was not renamed' + 'result' => true ); } + else { + return array( + 'result' => false, + 'message' => $error + ); + } + } + + function unpackItem($item, $dir, $target_dir, $filename) { + $item = $this->formatFullPath($item); + $dst_item = $this->formatFullPath($target_dir); + + exec (VESTA_CMD . "v-extract-fs-archive {$this->user} {$item} {$dst_item}", $output, $return_var); + + $error = self::check_return_code($return_var, $output); - return array( - 'result' => true - ); + if (empty($error)) { + return array( + 'result' => true + ); + } + else { + return array( + 'result' => false, + 'message' => $error + ); + } + } + + function renameFile($dir, $item, $target_name) { + $item = $this->formatFullPath($dir . '/' . $item); + $dst_item = $this->formatFullPath($dir . '/' . $target_name); + +// var_dump(VESTA_CMD . "v-move-fs-file {$this->user} {$item} {$dst_item}");die(); + + exec (VESTA_CMD . "v-move-fs-file {$this->user} {$item} {$dst_item}", $output, $return_var); + + $error = self::check_return_code($return_var, $output); + + if (empty($error)) { + return array( + 'result' => true + ); + } + else { + return array( + 'result' => false, + 'message' => $error + ); + } + } + function renameDirectory($dir, $item, $target_name) { + $item = $this->formatFullPath($dir . $item); + $dst_item = $this->formatFullPath($dir . $target_name); + + if ($item == $dst_item) { + return array( + 'result' => true + ); + } + + + exec (VESTA_CMD . "v-move-fs-directory {$this->user} {$item} {$dst_item}", $output, $return_var); + + $error = self::check_return_code($return_var, $output); + + if (empty($error)) { + return array( + 'result' => true + ); + } + else { + return array( + 'result' => false, + 'message' => $error + ); + } } function createDir($dir, $dirname) { - // todo: checks - // todo: vesta method "create file" - if (empty($dir)) { - $dir = $this->ROOT_DIR; - } + $dir = $this->formatFullPath($dir . '/' . $dirname); - mkdir($dir . '/' . $dirname); + exec (VESTA_CMD . "v-add-fs-directory {$this->user} {$dir}", $output, $return_var); + + $error = self::check_return_code($return_var, $output); - if (!is_readable($dir . '/' .$dirname)) { + if (empty($error)) { return array( - 'result' => false, - 'message' => 'item was not created' + 'result' => true + ); + } + else { + return array( + 'result' => false, + 'message' => $error ); } - - return array( - 'result' => true - ); } function getDirectoryListing($dir = '') { diff --git a/web/images/flat_icons.png b/web/images/flat_icons.png index 631f3b3c5..3b1080002 100644 Binary files a/web/images/flat_icons.png and b/web/images/flat_icons.png differ diff --git a/web/images/in_progress.gif b/web/images/in_progress.gif new file mode 100644 index 000000000..d6819abfb Binary files /dev/null and b/web/images/in_progress.gif differ diff --git a/web/js/app.js b/web/js/app.js index f75ee7806..1a3f18198 100644 --- a/web/js/app.js +++ b/web/js/app.js @@ -800,6 +800,38 @@ App.Ajax.request = function(method, data, callback, onError){ }*/ //App.Helpers.setAjaxBusy(method, data); data = data || {}; + + var prgs = $('.progress-container'); + + switch (method) { + case 'cd': + prgs.find('title').text('Opening dir'); + prgs.show(); + break; + case 'delete_files': + prgs.find('title').text('Deleting'); + prgs.show(); + break; + case 'unpack_item': + prgs.find('title').text('Unpacking'); + prgs.show(); + break; + case 'create_file': + prgs.find('title').text('Creating file'); + prgs.show(); + break; + case 'create_dir': + prgs.find('title').text('Creating directory'); + prgs.show(); + break; + case 'rename_file': + prgs.find('title').text('Renaming file'); + prgs.show(); + break; + default: + + break; + } jQuery.ajax({ url: GLOBAL.ajax_url, @@ -816,6 +848,7 @@ App.Ajax.request = function(method, data, callback, onError){ cache: false, error: function(jqXHR, textStatus, errorThrown) { + prgs.hide(); onError && onError(); if ('undefined' != typeof onError) { fb.error(textStatus); @@ -824,9 +857,11 @@ App.Ajax.request = function(method, data, callback, onError){ complete: function() { //App.Helpers.setAjaxFree(method, data); + prgs.hide(); }, success: function(reply) { + prgs.hide(); //App.Helpers.setAjaxFree(method, data); try { callback && callback(reply); diff --git a/web/js/file_manager.js b/web/js/file_manager.js index c355a7d06..361f111de 100644 --- a/web/js/file_manager.js +++ b/web/js/file_manager.js @@ -1,9 +1,13 @@ var FM = {}; +FM.Env = {}; + GLOBAL.ajax_url = '/file_manager/fm_api.php'; FM.DIR_MARKER = '  /'; +FM.errorMessageTimeout = 3500; + FM.CURRENT_TAB = ''; FM.CURRENT_A_LINE = -1; FM.CURRENT_B_LINE = -1; @@ -32,13 +36,45 @@ FM.IMAGES = {'A':[], 'B': []}; FM.IMG_FILETYPES = 'png, jpg, jpeg, gif'; +FM.SUPPORTED_ARCHIEVES = [ + 'zip', 'tgz', 'tar.gz', + 'gzip', 'tbz', 'tar.bz', + 'gz', 'zip', 'tar', 'rar' +]; + +FM.EDITABLE_FILETYPES = [ + 'txt', 'php', 'js', 'html' +]; + +FM.preselectedItems = {'A': [], 'B': []}; + FM.directoryNotAvailable = function(reply) { alert('Directory not available'); // todo: translate } FM.showError = function(type, message) { - alert(message); + if (FM.isPopupOpened()) { + var ref = FM.getPopupReference(); + if (ref.find('.warning-message').length > 0) { + ref.find('.warning-message').html('

' + message + '

'); + ref.find('.warning-message').show(); + + clearInterval(FM.Env.errorMessageHideTimeout); + FM.Env.errorMessageHideTimeout = + setTimeout(function() { + ref.find('.warning-message').fadeOut(); + }, FM.errorMessageTimeout); + return; + } + } + else { + FM.popupClose(); + var tpl = Tpl.get('popup_alert', 'FM'); + tpl.set(':TEXT', message); + + FM.popupOpen(tpl.finalize()); + } } FM.formatPath = function(dir) { @@ -95,8 +131,8 @@ FM.setActive = function(index, box) { //console.log(pos); var wwh = w_height - w_offset + pos.top; //console.info(wwh); - console.info((pos.top + w_offset) + ' > ' + w_height); - console.log((pos.top + w_offset) > w_height); + //console.info((pos.top + w_offset) + ' > ' + w_height); + //console.log((pos.top + w_offset) > w_height); /* if (pos.top > w_height) { var cur_elm = $(box).find('li.selected').position(); var cur_elm_height = $(box).find('li.selected').height(); @@ -114,6 +150,10 @@ FM.setActive = function(index, box) { FM['CURRENT_' + tab + '_LINE'] = index; FM.CURRENT_TAB = box; + + $(FM.preselectedItems[tab]).each(function(i, index) { + $(box).find('.dir:eq(' + index + ')').addClass('selected'); + }); } FM.setSecondInactive = function(index, box) { @@ -156,7 +196,8 @@ FM.open = function(dir, box, callback) { 'dir': dir }; App.Ajax.request('cd', params, function(reply) { - if (reply.result) { + FM.preselectedItems[tab] = []; + if (reply.result == true) { var html = FM.generate_listing(reply.listing, box); } else { @@ -167,10 +208,31 @@ FM.open = function(dir, box, callback) { var current_pwd = dir.trim() == '' ? FM.ROOT_DIR : dir; - $('.pwd-tab-' + tab).html(current_pwd); + FM.updateTopLevelPathBar(box, tab, current_pwd); + + + var path_a = FM['TAB_A_CURRENT_PATH'] == '' ? FM.ROOT_DIR : FM['TAB_A_CURRENT_PATH']; + var path_b = FM['TAB_B_CURRENT_PATH'] == '' ? FM.ROOT_DIR : FM['TAB_B_CURRENT_PATH']; + var url = '/list/directory/?dir_a='+path_a+'&dir_b='+path_b; + history.pushState({}, null, url); + + }); +} + +FM.updateTopLevelPathBar = function(box, tab, path) { + console.log(path); + var formattedPath = []; + path = path.replace(FM.ROOT_DIR, ''); + formattedPath.push(''+FM.ROOT_DIR+''); + + $.each(path.split('/'), function(i, part) { + if (part.trim() == '') { + return; + } + formattedPath.push(''+part+''); }); - + $('.pwd-tab-' + tab).html(formattedPath.join('/')); } FM.isItemFile = function(item) { @@ -302,28 +364,58 @@ FM.sortItems = function(items, box) { return sorted; } +FM.isFileEditable = function(src) { + if ('undefined' == typeof src.filetype) { + return false; + } + + if ($.inArray(src.filetype, FM.EDITABLE_FILETYPES) != -1) { + return true; + } + + return false; +} + +FM.editFileFromSubcontext = function(elm) { + var elm = $(elm).hasClass('dir') ? $(elm) : $(elm).closest('.dir'); + var src = $.parseJSON($(elm).find('.source').val()); + + var myWindow = window.open('/edit/file/?path=' + src.full_path, '_blank');//, src.full_path, "width=900, height=700"); +} + +FM.downloadFileFromSubcontext = function(elm) { + var elm = $(elm).hasClass('dir') ? $(elm) : $(elm).closest('.dir'); + var src = $.parseJSON($(elm).find('.source').val()); + + var path = src.full_path; + var win = window.open('/download/file/?path=' + path, '_blank'); + win.focus(); +} + FM.openFile = function(dir, box, elm) { var tab = FM.getTabLetter(box); FM['TAB_'+tab+'_CURRENT_PATH'] = dir; + + var elm = $(elm).hasClass('dir') ? $(elm) : $(elm).closest('.dir'); var src = $.parseJSON($(elm).find('.source').val()); + console.log(elm); + if (FM.isItemPseudo(src)) { + FM.open(FM['TAB_' + tab + '_CURRENT_PATH'], FM['TAB_' + tab]); + } + + if (FM.isFileEditable(src)) { + var myWindow = window.open('/edit/file/?path=' + src.full_path, '_blank');//, src.full_path, "width=900, height=700"); + } + else { + var path = src.full_path; + var win = window.open('/download/file/?path=' + path, '_blank'); + win.focus(); + } + - var myWindow = window.open('/edit/file/?path=' + src.full_path, '_blank');//, src.full_path, "width=900, height=700"); - /*var params = { - 'dir': dir - }; - App.Ajax.request('open_file', params, function(reply) { - if (reply.result) { - - //var html = FM.generate_listing(reply.listing, box); - } - else { - //FM.directoryNotAvailable(reply); - alert('Cannot open file'); - } - });*/ } FM.getTabLetter = function(box) { @@ -335,6 +427,10 @@ FM.getTabLetter = function(box) { return tab; } +FM.toggleSubContextMenu = function(ref) { + $(ref).find('.subcontext-menu').toggleClass('subcontext-menu-hidden'); +} + FM.generate_listing = function(reply, box) { var tab = FM.getTabLetter(box); FM.IMAGES[tab] = []; @@ -361,9 +457,12 @@ FM.generate_listing = function(reply, box) { } reply = FM.sortItems(reply, box); + $(reply).each(function(i, o) { var path = FM.formatPath(FM['TAB_'+tab+'_CURRENT_PATH']+'/'+o.name); var cl_act = o.type == 'd' ? 'onClick="FM.open(\'' + path + '\', \'' + box + '\')"' : 'onClick="FM.openFile(\''+path+'\', \'' + box + '\', this)"'; + //var cl_act = o.type == 'd' ? 'onDblClick="FM.open(\'' + path + '\', \'' + box + '\')"' : 'onDblClick="FM.openFile(\''+path+'\', \'' + box + '\', this)"'; + //var cl_act = ''; if (o.name == '') { path = FM.formatPath(back_path); @@ -382,14 +481,17 @@ FM.generate_listing = function(reply, box) { var time = o.time.split('.'); time = time[0]; + var psDate = new Date(o.date); + o.full_path = path; - o.filetype = FM.getFileType(o.name); - if(FM.IMG_FILETYPES.indexOf(o.filetype) >= 0 && o.filetype.length > 0) { - FM.IMAGES[tab][FM.IMAGES[tab].length] = {'img': "/view/file/?path=/home/admin/"+o.name+"&raw=true", 'thumb': "/view/file/?path=/home/admin/"+o.name+"&raw=true", 'id': 'img-'+i}; - cl_act = 'onClick="FM.fotoramaOpen(\'' + tab + '\', \'img-' + i +'\')"'; - } - + o.filetype = FM.getFileType(o.name); + if(FM.IMG_FILETYPES.indexOf(o.filetype) >= 0 && o.filetype.length > 0) { + FM.IMAGES[tab][FM.IMAGES[tab].length] = {'img': "/view/file/?path=/home/admin/"+o.name+"&raw=true", 'thumb': "/view/file/?path=/home/admin/"+o.name+"&raw=true", 'id': 'img-'+i}; + cl_act = 'onClick="FM.fotoramaOpen(\'' + tab + '\', \'img-' + i +'\')"'; + } + + var t_index = tab + '_' + i; var tpl = Tpl.get('entry_line', 'FM'); tpl.set(':CL_ACTION_1', cl_act); @@ -397,9 +499,21 @@ FM.generate_listing = function(reply, box) { tpl.set(':NAME', o.name); tpl.set(':PERMISSIONS', o.permissions); tpl.set(':OWNER', o.owner); - tpl.set(':SIZE', o.size); - tpl.set(':TIME', time); - tpl.set(':DATE', o.date); + tpl.set(':SIZE_VALUE', o.type == 'f' ? FM.humanFileSizeValue(o.size) : ' '); + tpl.set(':SIZE_UNIT', o.type == 'f' ? FM.humanFileSizeUnit(o.size) : ' '); + tpl.set(':TIME', (psDate.getFullYear() != new Date().getFullYear()) ? psDate.getFullYear() || "" : time); + tpl.set(':DATE', o.date.trim() != '' ? psDate.format('mmm d') : ' '/*o.date*/); + + + if (o.name == '..' || o.type == 'd') { + tpl.set(':SUBMENU_CLASS', 'hidden'); + } + else { + tpl.set(':SUBMENU_CLASS', ''); + } + /*tpl.set(':index', t_index); + tpl.set(':index1', t_index); + tpl.set(':index2', t_index);*/ if (FM.isItemDir(o)) { tpl.set(':ITEM_TYPE', 'filetype-dir'); @@ -416,17 +530,25 @@ FM.generate_listing = function(reply, box) { FM['CURRENT_'+tab+'_LINE'] = -1; } +FM.toggleCheck = function(uid) { + var ref = $('#check' + uid); + if (ref.length > 0) { + //ref.attr('checked', true); + $(ref).hasClass('checkbox-selected') ? $(ref).addClass('checkbox-selected') : $(ref).removeClass('checkbox-selected'); + } +} + FM.fotoramaOpen = function(tab, img_index) { console.log('index: ' + img_index); $('.fotorama').fotorama({ - nav: 'thumbs', - arrows: true, - click: true, - allowfullscreen: true, - fit: 'scaledown', - thumbfit: 'scaledown', - data: FM.IMAGES[tab] + nav: 'thumbs', + arrows: true, + click: true, + allowfullscreen: true, + fit: 'scaledown', + thumbfit: 'scaledown', + data: FM.IMAGES[tab] }); $('.fotorama').on('fotorama:fullscreenexit', function (e, fotorama) { @@ -437,21 +559,300 @@ FM.fotoramaOpen = function(tab, img_index) { $('.fotorama').fotorama().data('fotorama').show(img_index); } -FM.selectItem = function(item, box) { +FM.bulkOperation = function(ref) { + //console.log(ref); + var box = $(ref).parents('.menu').hasClass('menu-left') ? FM.setTabActive(FM.TAB_A, 'skip_highlights') : FM.setTabActive(FM.TAB_B, 'skip_highlights'); - if (FM.CURRENT_TAB == FM.TAB_A) { - FM.setTabActive(FM.TAB_B); - $(FM.TAB_B).find('.selected-inactive').removeClass('selected-inactive'); - $(FM.TAB_A).find('.selected').addClass('selected-inactive'); + var operation = $(ref).val(); + if ('function' == typeof FM[operation]) { + FM[operation] && FM[operation](ref); + } + + $(ref).find('option[value=-1]').attr('selected', true); +} + +FM.checkBulkStatus = function(bulkStatuses, acc) { + var status = false; + var msg = ''; + if (bulkStatuses.length == acc.length) { + $.each(bulkStatuses, function(i, o) { + if (o != true) { + msg += '

'+o+'

'; + } + }); + + if (msg == '') { + status = true; + } + } + + if (status == true) { + $('#popup .results').html(msg); + $('.controls p').replaceWith('

close

'); } else { - FM.setTabActive(FM.TAB_A); + $('#popup .results').html(msg); + $('.controls p').replaceWith('

close

'); + } +} + +FM.bulkPopupClose = function() { + FM.popupClose(); + FM.open(FM['TAB_A_CURRENT_PATH'], FM['TAB_A']); + FM.open(FM['TAB_B_CURRENT_PATH'], FM['TAB_B']); +} + +FM.humanFileSize = function(size) { + var sizes = [' Bytes', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB']; + for (var i = 1; i < sizes.length; i++) { + if (size < Math.pow(1024, i)) return (Math.round((size/Math.pow(1024, i-1))*100)/100) + sizes[i-1]; + } + return size; +} + +FM.humanFileSizeValue = function(size) { + var sizes = ['b', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + for (var i = 1; i < sizes.length; i++) { + if (size < Math.pow(1024, i)) return (Math.round((size/Math.pow(1024, i-1))*100)/100); + } + return size; +} + +FM.humanFileSizeUnit = function(size) { + if (!parseInt(size)) return " "; + + var sizes = ['b', ' kb', ' Mb', ' Gb', ' Tb', ' Pb', ' Eb', ' Zb', ' Yb']; + for (var i = 1; i < sizes.length; i++) { + if (size < Math.pow(1024, i)) return sizes[i-1]; + } + return sizes[i]; +} + + +FM.bulkCopy = function() { + var acc = $(FM.CURRENT_TAB).find('.dir.selected'); + if (acc.length > 0) { + //FM.popupClose(); + + var cfr_html = ''; + + $.each(acc, function(i, o) { + var ref = $(o).parents('.dir'); + var src = $(ref).find('.source').val(); + src = $.parseJSON(src); + + if (!FM.isItemPseudo(o)) { + cfr_html += '
'+src.name+'
'; + } + }); + + var tpl = Tpl.get('popup_bulk', 'FM'); + tpl.set(':ACTION', 'YOU ARE COPYING'); + tpl.set(':TEXT', cfr_html); + + FM.popupOpen(tpl.finalize()); + + var bulkStatuses = []; + $.each(acc, function(i, o) { + var ref = $(o).parents('.dir'); + var src = $(ref).find('.source').val(); + src = $.parseJSON(src); + + /*if (!FM.isItemPseudo(o)) { + cfr_html += '
'+src.name+'
'; + }*/ + var tab = FM.getTabLetter(FM.CURRENT_TAB); + + var opposite_tab = 'A'; + if (tab == 'A') { + opposite_tab = 'B'; + } + + if (FM.isItemPseudo(src)) { + return FM.displayError( + App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED + ); + } + + var dest = FM['TAB_' + opposite_tab + '_CURRENT_PATH' ]; + if (dest == '') { + dest = GLOBAL.ROOT_DIR; + } + + var action = FM.isItemFile(src) ? 'copy_file' : 'copy_directory'; + + var params = { + item: src.full_path, + filename: src.name, + dir: FM['TAB_' + tab + '_CURRENT_PATH'], + dir_target: dest + }; + + App.Ajax.request(action, params, function(reply) { + if (reply.result == true) { + bulkStatuses.push(true); + } + else { + //FM.showError('copy-items', reply.message); + bulkStatuses.push(reply.message); + } + + FM.checkBulkStatus(bulkStatuses, acc); + }); + }); + + } +} + +FM.bulkRemove = function() { + var acc = $(FM.CURRENT_TAB).find('.dir.selected'); + if (acc.length > 0) { + //FM.popupClose(); + + var cfr_html = ''; + + $.each(acc, function(i, o) { + var ref = $(o).parents('.dir'); + var src = $(ref).find('.source').val(); + src = $.parseJSON(src); + + if (!FM.isItemPseudo(o)) { + cfr_html += '
'+src.name+'
'; + } + }); + + var tpl = Tpl.get('popup_bulk', 'FM'); + tpl.set(':ACTION', 'YOU ARE REMOVING'); + tpl.set(':TEXT', cfr_html); + + FM.popupOpen(tpl.finalize()); + + var bulkStatuses = []; + $.each(acc, function(i, o) { + var ref = $(o).parents('.dir'); + var src = $(ref).find('.source').val(); + src = $.parseJSON(src); + + /*if (!FM.isItemPseudo(o)) { + cfr_html += '
'+src.name+'
'; + }*/ + var tab = FM.getTabLetter(FM.CURRENT_TAB); + + var opposite_tab = 'A'; + if (tab == 'A') { + opposite_tab = 'B'; + } + + if (FM.isItemPseudo(src)) { + return FM.displayError( + App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED + ); + } + + var dest = FM['TAB_' + opposite_tab + '_CURRENT_PATH' ]; + if (dest == '') { + dest = GLOBAL.ROOT_DIR; + } + + var params = { + item: src.full_path, + dir: FM['TAB_' + tab + '_CURRENT_PATH'] + }; + + App.Ajax.request('delete_files', params, function(reply) { + if (reply.result == true) { + bulkStatuses.push(true); + } + else { + //FM.showError('copy-items', reply.message); + bulkStatuses.push(reply.message); + } + + FM.checkBulkStatus(bulkStatuses, acc); + }); + }); + + } +} + +FM.toggleAllItemsSelected = function() { + var tab = FM.getTabLetter(FM.CURRENT_TAB); + var box = FM['TAB_' + tab]; + var selected = $(FM['TAB_' + tab] ).find('.dir.selected'); + var dir_items = $(FM['TAB_' + tab] ).find('.dir'); + if (selected.length == dir_items.length) { + $(box).find('.dir').removeClass('selected'); + var index = FM['CURRENT_' + tab + '_LINE']; + $(box).find('.dir:eq(' + index + ')').addClass('selected'); + } + else { + $(box).find('.dir').addClass('selected'); + } +} + +FM.selectCurrentElementAndGoToNext = function () { + var tab = FM.getTabLetter(FM.CURRENT_TAB); + var box = FM['TAB_' + tab]; + + var index = FM['CURRENT_' + tab + '_LINE']; + + if ($.inArray(index, FM.preselectedItems[tab]) != -1) { + FM.preselectedItems[tab] = $.grep(FM.preselectedItems[tab], function(i) { + return i != index; + }); + + $(box).find('.dir:eq(' + index + ')').removeClass('selected'); + //FM.preselectedItems[tab].push(index); + } + else { + $(box).find('.dir:eq(' + index + ')').addClass('selected'); + FM.preselectedItems[tab].push(index); + } + + FM.goDown(); +} + +FM.selectItem = function(item, box) { + //console.log(item); + /*if ($(item).hasClass('ch-toggle')) { + if ($(item).parents('.dir').prev('.dir').length == 0) { + var checked = $(item).parents('.dir').find('.ch-toggle').is(':checked'); + $(item).parents('.listing').find('.ch-toggle').prop('checked', checked); + } + + return; + }*/ + + + + if (FM.CURRENT_TAB == FM.TAB_A) { + FM.setTabActive(FM.TAB_B, 'skip_highlights'); + $(FM.TAB_B).find('.selected-inactive').removeClass('selected-inactive'); + // tmp + //$(FM.TAB_A).find('.selected-inactive').removeClass('selected-inactive'); + $(FM.TAB_B).find('.selected').removeClass('selected'); + + //$(FM.TAB_A).find('.selected').addClass('selected-inactive'); + $(FM.TAB_B).find('.selected').addClass('selected-inactive').removeClass('selected'); + } + else { + FM.setTabActive(FM.TAB_A, 'skip_highlights'); $(FM.TAB_A).find('.selected-inactive').removeClass('selected-inactive'); - $(FM.TAB_B).find('.selected').addClass('selected-inactive'); + //$(FM.TAB_B).find('.selected-inactive').removeClass('selected-inactive'); + //$(FM.TAB_B).find('.selected').addClass('selected-inactive'); + $(FM.TAB_A).find('.selected').removeClass('selected'); + + $(FM.TAB_A).find('.selected').addClass('selected-inactive').removeClass('selected'); } $(box).find('.active').removeClass('active'); $(box).find('.selected').removeClass('selected'); + + // + // tmp + //$(FM.TAB_A).find('.selected-inactive').removeClass('selected-inactive'); + //$(FM.TAB_B).find('.selected-inactive').removeClass('selected-inactive'); + /*if ($(item).hasClass('active')) { $(item).removeClass('active'); } @@ -465,10 +866,115 @@ FM.selectItem = function(item, box) { $(item).addClass('selected'); } + + FM.setTabActive(box); + + var item = $(item).hasClass('dir') ? item : $(item).parents('.dir'); + var tab = FM.getTabLetter(FM.CURRENT_TAB); + var src = $(item).find('.source').val(); + src = $.parseJSON(src); + var tab = FM.getTabLetter(FM.CURRENT_TAB); + if (FM.itemIsArchieve(src)) { + $('.menu-'+tab+' .extract-btn').show(); + } + else { + $('.menu-'+tab+' .extract-btn').hide(); + } + } +FM.isItemPseudo = function(item) { + if (item.name == '.' || item.name == '..') { + return true; + } + return false; +} + +FM.itemIsArchieve = function(item) { + + if ($.inArray(item.filetype, FM.SUPPORTED_ARCHIEVES) != -1) { + return true; + } + + return false; +} + +FM.unpackItem = function() { + var tab = FM.getTabLetter(FM.CURRENT_TAB); + var box = FM['TAB_' + tab]; + var selected = $(FM['TAB_' + tab] ).find('.dir.selected'); + if (selected.length == 0) { + return alert('No file selected'); + } + + + var src = selected.find('.source').val(); + src = $.parseJSON(src); + + if (FM.isItemPseudo(src)) { + return FM.displayError( + App.Constants.FM_NO_FILE_SELECTED + ); + } + + if (!FM.itemIsArchieve(src)) { + return FM.displayError( + App.Constants.FM_FILE_TYPE_NOT_SUPPORTED + ); + } + + var dst = FM['TAB_' + tab + '_CURRENT_PATH']; + if (dst == '') { + dst = GLOBAL.ROOT_DIR; + } + + var tpl = Tpl.get('popup_unpack', 'FM'); + tpl.set(':FILENAME', src.name); + tpl.set(':DST_DIRNAME', dst + '/' + src.name + '_extracted'); + FM.popupOpen(tpl.finalize()); +} + +FM.packItem = function() { + var tab = FM.getTabLetter(FM.CURRENT_TAB); + var box = FM['TAB_' + tab]; + var selected = $(FM['TAB_' + tab] ).find('.dir.selected'); + if (selected.length == 0) { + return FM.displayError( + App.Constants.FM_NO_FILE_SELECTED + ); + } + + + var src = selected.find('.source').val(); + src = $.parseJSON(src); + + if (FM.isItemPseudo(src)) { + return FM.displayError( + App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED + ); + } + + if (FM.isItemPseudo(src)) { + return FM.displayError( + App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED + ); + } + + + var dst = FM['TAB_' + tab + '_CURRENT_PATH']; + if (dst == '') { + dst = GLOBAL.ROOT_DIR; + } + + var tpl = Tpl.get('popup_pack', 'FM'); + tpl.set(':FILENAME', src.name); + tpl.set(':DST_DIRNAME', dst + '/' + src.name + '_packed.tar.gz'); + FM.popupOpen(tpl.finalize()); +} + + FM.switchTab = function() { if (FM.CURRENT_TAB == FM.TAB_A) { @@ -489,13 +995,24 @@ FM.switchTab = function() { } } -FM.setTabActive = function(box) { +FM.setTabActive = function(box, action) { FM.CURRENT_TAB = box; $('.window.active').removeClass('active'); $('.listing-left.active').removeClass('active'); $('.listing-right.active').removeClass('active'); $(FM.CURRENT_TAB).addClass('active'); $(FM.CURRENT_TAB).closest('.window').addClass('active'); + + if (action == 'skip_highlights') { + return true; + } + + if (FM.CURRENT_TAB == FM.TAB_A) { + $(FM.TAB_B).find('.selected').addClass('selected-inactive').removeClass('selected'); + } + else { + $(FM.TAB_A).find('.selected').addClass('selected-inactive').removeClass('selected'); + } } FM.confirmRename = function() { @@ -503,7 +1020,9 @@ FM.confirmRename = function() { var box = FM['TAB_' + tab]; var selected = $(FM['TAB_' + tab] ).find('.dir.selected'); if (!selected) { - return alert('No file selected'); + return FM.displayError( + App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED + ); } var src = selected.find('.source').val(); @@ -512,23 +1031,27 @@ FM.confirmRename = function() { var target_name = $('#rename-title').val(); if (target_name.trim().length == 0) { - return alert('Cannot be renamed.'); + return FM.displayError( + App.Constants.FM_FILE_NAME_CANNOT_BE_EMPTY + ); } + + var action = FM.isItemFile(src) ? 'rename_file' : 'rename_directory'; var params = { item: src.name, target_name: target_name, - dir: FM['TAB_' + tab + '_CURRENT_PATH'] + dir: FM['TAB_' + tab + '_CURRENT_PATH'] + '/' }; - App.Ajax.request('rename_file', params, function(reply) { - if (reply.result) { + App.Ajax.request(action, params, function(reply) { + if (reply.result == true) { + FM.popupClose(); FM.open(FM['TAB_' + tab + '_CURRENT_PATH'], box); } else { FM.showError('rename-items', reply.message); } - FM.popupClose(); }); } @@ -536,44 +1059,189 @@ FM.renameItems = function() { var tab = FM.getTabLetter(FM.CURRENT_TAB); var selected = $(FM['TAB_' + tab] ).find('.dir.selected'); if (selected.length == 0) { - return alert('No file selected'); + return FM.displayError( + App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED + ); } var src = selected.find('.source').val(); src = $.parseJSON(src); + + if (FM.isItemPseudo(src)) { + return FM.displayError( + App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED + ); + } var tpl = Tpl.get('popup_rename', 'FM'); tpl.set(':FILENAME', src.name); + tpl.set(':NEW_NAME', src.name); FM.popupOpen(tpl.finalize()); - /*var tab = FM.getTabLetter(FM.CURRENT_TAB); - var box = FM.CURRENT_TAB; - - var delete_list = $(box).find('.active'); - if (delete_list.length == 0) { - return FM.showError('hint', 'No selected items'); - } - - $(delete_list).each(function(i, o) { - var opt = $(o).find('.source').val(); - opt = $.parseJSON(opt); - prompt('Rename "' + opt.name + '" to:'); - });*/ } FM.popupOpen = function(html) { - $('
').attr('id', 'popup').html(html).flayer(); + $('
').attr('id', 'popup').html(html).flayer({ + afterStart: function(elm) { + elm.find('input[type="text"]:first').focus(); + } + }); } FM.popupClose = function() { + clearTimeout(FM.Env.errorMessageHideTimeout); return $('#popup').flayer_close(); } FM.copyItems = function() { var tab = FM.getTabLetter(FM.CURRENT_TAB); var selected = $(FM['TAB_' + tab] ).find('.dir.selected'); + if (selected.length == 0) { + return FM.displayError( + App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED + ); + } + + if (selected.length > 1) { // multi operation + return FM.bulkCopy(); + } + + + var src = selected.find('.source').val(); + src = $.parseJSON(src); + + if (FM.isItemPseudo(src)) { + return FM.displayError( + App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED + ); + } + + var opposite_tab = 'A'; + if (tab == 'A') { + opposite_tab = 'B'; + } + + var dst = FM['TAB_' + opposite_tab + '_CURRENT_PATH']; + if (dst == '') { + dst = GLOBAL.ROOT_DIR; + } + + var tpl = Tpl.get('popup_copy', 'FM'); + tpl.set(':SRC_FILENAME', src.full_path); + tpl.set(':DST_FILENAME', dst + '/' + src.name); + FM.popupOpen(tpl.finalize()); +} + +FM.confirmUnpackItem = function () { + var tab = FM.getTabLetter(FM.CURRENT_TAB); + var box = FM['TAB_' + tab]; + var selected = $(FM['TAB_' + tab] ).find('.dir.selected'); + if (selected.length == 0) { + return FM.displayError( + App.Constants.FM_NO_FILE_SELECTED + ); + } + + var opposite_tab = 'A'; + if (tab == 'A') { + opposite_tab = 'B'; + } + + var src = selected.find('.source').val(); + src = $.parseJSON(src); + + if (FM.isItemPseudo(src)) { + return FM.displayError( + App.Constants.FM_NO_FILE_SELECTED + ); + } + + if (!FM.itemIsArchieve(src)) { + return FM.displayError( + App.Constants.FM_FILE_TYPE_NOT_SUPPORTED + ); + } + + var dst = FM['TAB_' + tab + '_CURRENT_PATH']; + if (dst == '') { + dst = GLOBAL.ROOT_DIR; + } + + var params = { + item: src.full_path, + filename: src.name, + dir: FM['TAB_' + tab + '_CURRENT_PATH'], + dir_target: $('#unpack-destination').val() + }; + + App.Ajax.request('unpack_item', params, function(reply) { + if (reply.result == true) { + FM.popupClose(); + FM.open(FM['TAB_' + tab + '_CURRENT_PATH'], FM['TAB_' + tab]); + FM.open(FM['TAB_' + opposite_tab + '_CURRENT_PATH'], FM['TAB_' + opposite_tab]); + } + else { + FM.showError('unpack_item', reply.message); + } + }); +} + +FM.confirmPackItem = function () { + var tab = FM.getTabLetter(FM.CURRENT_TAB); + var box = FM['TAB_' + tab]; + var selected = $(FM['TAB_' + tab] ).find('.dir.selected'); + if (selected.length == 0) { + return FM.displayError( + App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED + ); + } + + var opposite_tab = 'A'; + if (tab == 'A') { + opposite_tab = 'B'; + } + + var src = selected.find('.source').val(); + src = $.parseJSON(src); + + if (FM.isItemPseudo(src)) { + return FM.displayError( + App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED + ); + } + + var dst = FM['TAB_' + tab + '_CURRENT_PATH']; + if (dst == '') { + dst = GLOBAL.ROOT_DIR; + } + + var params = { + item: src.full_path, + filename: src.name, + dir: FM['TAB_' + tab + '_CURRENT_PATH'], + dir_target: $('#pack-destination').val() + }; + + + App.Ajax.request('pack_item', params, function(reply) { + if (reply.result == true) { + FM.popupClose(); + FM.open(FM['TAB_' + tab + '_CURRENT_PATH'], FM['TAB_' + tab]); + FM.open(FM['TAB_' + opposite_tab + '_CURRENT_PATH'], FM['TAB_' + opposite_tab]); + } + else { + FM.showError('unpack_item', reply.message); + } + }); +} + +FM.confirmCopyItems = function () { + var tab = FM.getTabLetter(FM.CURRENT_TAB); + var selected = $(FM['TAB_' + tab] ).find('.dir.selected'); if (!selected) { - return alert('No file selected'); + return FM.displayError( + App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED + ); } var opposite_tab = 'A'; @@ -583,24 +1251,36 @@ FM.copyItems = function() { var src = selected.find('.source').val(); src = $.parseJSON(src); - console.log(src); + + if (FM.isItemPseudo(src)) { + return FM.displayError( + App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED + ); + } + + var dest = $('#copy_dest').val(); + if (dest == '') { + dest = GLOBAL.ROOT_DIR; + } + + var action = FM.isItemFile(src) ? 'copy_file' : 'copy_directory'; var params = { item: src.full_path, filename: src.name, dir: FM['TAB_' + tab + '_CURRENT_PATH'], - dir_target: FM['TAB_' + opposite_tab + '_CURRENT_PATH'] + dir_target: dest }; - App.Ajax.request('copy_files', params, function(reply) { - if (reply.result) { + App.Ajax.request(action, params, function(reply) { + if (reply.result == true) { + FM.popupClose(); FM.open(FM['TAB_' + tab + '_CURRENT_PATH'], FM['TAB_' + tab]); FM.open(FM['TAB_' + opposite_tab + '_CURRENT_PATH'], FM['TAB_' + opposite_tab]); } else { - FM.showError('delete-items', reply.message); + FM.showError('copy-items', reply.message); } - //FM.popupClose(); }); } @@ -608,14 +1288,24 @@ FM.downloadFiles = function() { var tab = FM.getTabLetter(FM.CURRENT_TAB); var selected = $(FM['TAB_' + tab] ).find('.dir.selected'); if (!selected) { - return alert('No file selected'); + return FM.displayError( + App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED + ); } var src = selected.find('.source').val(); src = $.parseJSON(src); - - if (src.type != 'f') { - return alert('Only files can be dosnloaded in this version'); + + if (FM.isItemPseudo(src) || FM.isItemDir(src)) { + alert('Folder downloads are in progress atm'); + } + + if (FM.isItemPseudo(src)) { + if (FM.isItemPseudo(src)) { + return FM.displayError( + App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED + ); + } } var path = src.full_path; @@ -633,11 +1323,19 @@ FM.confirmDelete = function() { var box = FM['TAB_' + tab]; var selected = $(FM['TAB_' + tab] ).find('.dir.selected'); if (!selected) { - return alert('No file selected'); + return FM.displayError( + App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED + ); } var src = selected.find('.source').val(); src = $.parseJSON(src); + + if (FM.isItemPseudo(src)) { + return FM.displayError( + App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED + ); + } var params = { item: src.full_path, @@ -645,13 +1343,13 @@ FM.confirmDelete = function() { }; App.Ajax.request('delete_files', params, function(reply) { - if (reply.result) { + if (reply.result == true) { + FM.popupClose(); FM.open(FM['TAB_' + tab + '_CURRENT_PATH'], box); } else { FM.showError('delete-items', reply.message); } - FM.popupClose(); }); } @@ -659,62 +1357,66 @@ FM.deleteItems = function() { var tab = FM.getTabLetter(FM.CURRENT_TAB); var selected = $(FM['TAB_' + tab] ).find('.dir.selected'); if (selected.length == 0) { - return alert('No file selected'); + return FM.displayError( + App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED + ); } + if (selected.length > 1) { // multi operation + return FM.bulkRemove(); + } + + + var src = selected.find('.source').val(); src = $.parseJSON(src); + + if (FM.isItemPseudo(src)) { + return FM.displayError( + App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED + ); + } var tpl = Tpl.get('popup_delete', 'FM'); tpl.set(':FILENAME', src.name); FM.popupOpen(tpl.finalize()); - - - /*var tab = FM.getTabLetter(FM.CURRENT_TAB); - var confirmed = confirm(App.i18n.ARE_YOU_SURE); - var box = FM.CURRENT_TAB; - - var delete_list = $(box).find('.selected'); - if (delete_list.length == 0) { - return FM.showError('hint', 'No selected items'); - } - - var params = { - items: [], - dir: FM['TAB_' + tab + '_CURRENT_PATH'] - }; - $(delete_list).each(function(i, opt){ - var opt = $(o).find('.source').val(); - opt = $.parseJSON(opt); - params.items.push(opt.name); - }); - - App.Ajax.request('delete_files', params, function(reply) { - if (reply.result) { - FM.open(FM['TAB_' + tab + '_CURRENT_PATH'], box); - } - else { - FM.showError('delete-items', reply.message); - } - });*/ } +FM.displayError = function(msg) { + if (FM.isPopupOpened()) { + var ref = FM.getPopupReference(); + if (ref.find('.warning-message').length > 0) { + ref.find('.warning-message').html('

' + msg + '

'); + ref.find('.warning-message').show(); + + clearInterval(FM.Env.errorMessageHideTimeout); + FM.Env.errorMessageHideTimeout = + setTimeout(function() { + ref.find('.warning-message').fadeOut(); + }, FM.errorMessageTimeout); + return; + } + } + + FM.popupClose(); + var tpl = Tpl.get('popup_alert', 'FM'); + tpl.set(':TEXT', msg); + + FM.popupOpen(tpl.finalize()); + //return alert(msg); +} + FM.confirmCreateDir = function() { var tab = FM.getTabLetter(FM.CURRENT_TAB); var box = FM['TAB_' + tab]; - /*var selected = $(FM['TAB_' + tab] ).find('.dir.selected'); - if (!selected) { - return alert('No file selected'); - } - - var src = selected.find('.source').val(); - src = $.parseJSON(src);*/ var dirname = $('#rename-title').val(); if (dirname.trim().length == 0) { - return alert('Cannot be created.'); + return FM.displayError( + App.Constants.FM_DIRECTORY_NAME_CANNOT_BE_EMPTY + ); } var params = { @@ -723,13 +1425,13 @@ FM.confirmCreateDir = function() { }; App.Ajax.request('create_dir', params, function(reply) { - if (reply.result) { + if (reply.result == true) { + FM.popupClose(); FM.open(FM['TAB_' + tab + '_CURRENT_PATH'], box); } else { - FM.showError('create-file', reply.message); + FM.showError('create-dir', reply.message); } - FM.popupClose(); }); } @@ -738,44 +1440,18 @@ FM.createDir = function() { var tpl = Tpl.get('popup_create_dir', 'FM'); FM.popupOpen(tpl.finalize()); - /*var dirname = prompt('Enter dir name:'); - if (dirname.trim() != '') { - - var box = FM.CURRENT_TAB; - var tab = FM.getTabLetter(box); - var params = { - 'dirname': dirname, - 'dir': FM['TAB_' + tab + '_CURRENT_PATH'] - }; - App.Ajax.request('create_dir', params, function(reply) { - if (reply.result) { - FM.open(FM['TAB_' + tab + '_CURRENT_PATH'], box); - } - else { - FM.showError('create-dir', reply.message); - } - }); - } - else { - FM.showError('dirname-empty', 'Dirname cannot be empty'); - }*/ } FM.confirmCreateFile = function() { var tab = FM.getTabLetter(FM.CURRENT_TAB); var box = FM['TAB_' + tab]; - /*var selected = $(FM['TAB_' + tab] ).find('.dir.selected'); - if (!selected) { - return alert('No file selected'); - } - - var src = selected.find('.source').val(); - src = $.parseJSON(src);*/ var filename = $('#rename-title').val(); if (filename.trim().length == 0) { - return alert('Cannot be created.'); + return FM.displayError( + App.Constants.FM_FILE_NAME_CANNOT_BE_EMPTY + ); } var params = { @@ -784,13 +1460,13 @@ FM.confirmCreateFile = function() { }; App.Ajax.request('create_file', params, function(reply) { - if (reply.result) { + if (reply.result == true) { + FM.popupClose(); FM.open(FM['TAB_' + tab + '_CURRENT_PATH'], box); } else { FM.showError('create-file', reply.message); } - FM.popupClose(); }); } @@ -799,27 +1475,6 @@ FM.createFile = function() { var tpl = Tpl.get('popup_create_file', 'FM'); FM.popupOpen(tpl.finalize()); - /*var filename = prompt('Enter file name:'); - if (filename.trim() != '') { - - var box = FM.CURRENT_TAB; - var tab = FM.getTabLetter(box); - var params = { - 'filename': filename, - 'dir': FM['TAB_' + tab + '_CURRENT_PATH'] - }; - App.Ajax.request('create_file', params, function(reply) { - if (reply.result) { - FM.open(FM['TAB_' + tab + '_CURRENT_PATH'], box); - } - else { - FM.showError('create-file', reply.message); - } - }); - } - else { - FM.showError('filename-empty', 'Filename cannot be empty'); - }*/ } FM.showOrderBox = function(elm, tab) { @@ -885,12 +1540,47 @@ FM.reOrderList = function(elm){ FM.open(path, tab); } +FM.isPopupOpened = function() { + var ref = $('#popup'); + if (ref.length > 0) { + return true; + } + + return false; +} + +FM.getPopupReference = function() { + var ref = $('#popup'); + + return ref; +} + +FM.handlePopupSubmit = function() { + try { + var method = $('#popup').find('.ok').attr('onClick'); + if (method) { + method = method.replace('\(\);', '').replace('FM.', ''); + if ('function' == typeof FM[method]) { + FM[method](); + } + } + } + catch(e) { + + } +} + +FM.handlePopupCancel = function() { + FM.popupClose(); +} + FM.init(); $(document).ready(function() { + $('.progress-container').hide(); //return alert('statechange: Back'); /*$(document).bind('keydown.up', function() { @@ -915,6 +1605,17 @@ $(document).ready(function() { $('.window ul').outerHeight(hgt); + shortcut.add("Esc",function() { + if (FM.isPopupOpened()) { + return FM.handlePopupCancel(); + } + },{ + 'type': 'keydown', + 'propagate': false, + 'disable_in_input': false, + 'target': document + }); + shortcut.add("Down",function() { FM.goDown(); },{ @@ -941,8 +1642,39 @@ $(document).ready(function() { 'disable_in_input': false, 'target': document }); + + shortcut.add("Space",function() { + FM.selectCurrentElementAndGoToNext(); + },{ + 'type': 'keydown', + 'propagate': false, + 'disable_in_input': false, + 'target': document + }); + + shortcut.add("Insert",function() { + FM.selectCurrentElementAndGoToNext(); + },{ + 'type': 'keydown', + 'propagate': false, + 'disable_in_input': false, + 'target': document + }); + + + shortcut.add("ctrl+a",function() { + FM.toggleAllItemsSelected(); + },{ + 'type': 'keydown', + 'propagate': false, + 'disable_in_input': false, + 'target': document + }); shortcut.add("Enter",function() { + if (FM.isPopupOpened()) { + return FM.handlePopupSubmit(); + } var tab = FM.getTabLetter(FM.CURRENT_TAB); var elm = $(FM.CURRENT_TAB).find('.dir:eq('+FM['CURRENT_'+tab+'_LINE']+')'); @@ -964,6 +1696,8 @@ $(document).ready(function() { }); + + /* is jQuery .live() has been removed in version 1.9 onwards $(FM.TAB_A + ' .dir').live('click', function(evt) { FM.selectItem(evt.target, FM.TAB_A); @@ -973,12 +1707,19 @@ $(document).ready(function() { }); */ - $(FM.TAB_A).on('click', '.dir', function(evt) { + /*$(FM.TAB_A).on('click', '.dir', function(evt) { + //console.log(evt); + if (evt.ctrlKey || evt.metaKey || evt.altKey) { + return; + } FM.selectItem(evt.target, FM.TAB_A); }); $(FM.TAB_B).on('click', '.dir', function(evt) { + if (evt.ctrlKey || evt.metaKey || evt.altKey) { + return; + } FM.selectItem(evt.target, FM.TAB_B); - }); + });*/ $(FM.TAB_A_MENU).on('click', '.sort-by', function(evt){ FM.showOrderBox($(evt.target), FM.TAB_A); @@ -996,6 +1737,10 @@ $(document).ready(function() { $(evt.target).closest('.warning-box').hide(); }); + $('.menu-A .extract-btn').hide(); + $('.menu-B .extract-btn').hide(); + + }); diff --git a/web/js/floating_layer.js b/web/js/floating_layer.js index b0af2a903..84f6c91f7 100644 --- a/web/js/floating_layer.js +++ b/web/js/floating_layer.js @@ -2,7 +2,12 @@ { jQuery.fn.flayer_close = function() { - jQuery(this).flayer.close(); + try { + jQuery(this).flayer.close(); + } + catch (e) { + fb.error(e); + } } jQuery.fn.flayer = function(params) { @@ -15,8 +20,9 @@ id : 'floating-box', className : 'floating-box-class', zIndex : 5000, - beforeStart : function(){}, - beforeEnd : function(){}, + beforeStart : function() {}, + beforeEnd : function() {}, + afterStart: function() {}, close : null, closeClass : 'close-floating-layer', outerClose : false, @@ -207,6 +213,7 @@ jQuery(ref.content).append(jQuery(elm).removeClass('hidden')); start_ovservers(); jQuery(ref.container).removeClass('hidden').css({'display':'block'}); + config.afterStart(elm); } // diff --git a/web/js/i18n.js.php b/web/js/i18n.js.php index 7fe3b6192..dcf372709 100644 --- a/web/js/i18n.js.php +++ b/web/js/i18n.js.php @@ -46,3 +46,10 @@ if (!function_exists('__')) { App.i18n.ARE_YOU_SURE = ''; App.Constants.UNLIM_TRANSLATED_VALUE = ''; + +App.Constants.FM_DIRECTORY_NAME_CANNOT_BE_EMPTY = ''; +App.Constants.FM_FILE_NAME_CANNOT_BE_EMPTY = ''; +App.Constants.FM_NO_FILE_SELECTED = ''; +App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED = ''; +App.Constants.FM_FILE_TYPE_NOT_SUPPORTED = ''; + diff --git a/web/js/templates.js b/web/js/templates.js index 21b8dbef2..9cc360b1d 100644 --- a/web/js/templates.js +++ b/web/js/templates.js @@ -7,31 +7,65 @@ App.Templates.html = { hint: [''] }, // file manager + // + +//\ + FM: { entry_line: ['
  • \ - \ + \ + \ \ \ ~!:NAME~!\ ~!:PERMISSIONS~!\ ~!:OWNER~!\ - ~!:SIZE~!\ + ~!:SIZE_UNIT~!\ + ~!:SIZE_VALUE~!\ ~!:DATE~!\ ~!:TIME~!\ + ••• \ +
    • Download
    • Edit
    \ +
    \
  • '], + popup_alert: [''], + popup_bulk: [''], popup_delete: [''], - popup_rename_: ['
    \ -
    Rename file "~!:FILENAME~!"
    \ - \ -
    \ + popup_copy: [''], + popup_rename: ['
    \ +
    Original name: "~!:FILENAME~!"
    \ + \ +
    \ +
    \ + \
    \
    \

    cancel

    \ @@ -43,15 +77,33 @@ App.Templates.html = {
    \
    '], - popup_rename: ['
    \ -
    Extract archive "~!:FILENAME~!" to "~!:DIRNAME~!"
    \ -
    \ + popup_pack: ['
    \ +
    Pack "~!:FILENAME~!" into:
    \
    \ - \ + \
    \ +
    \ + \
    \

    cancel

    \ -

    Extract

    \ +

    Pack

    \ +
    \ +
    '], + + popup_unpack: ['
    \ +
    Extract archive "~!:FILENAME~!" to:
    \ +
    \ + \ +
    \ +
    \ + \ +
    \ +

    cancel

    \ +

    Extract

    \
    \
    '], @@ -59,7 +111,7 @@ App.Templates.html = { popup_create_file: ['
    \
    Create file
    \ \ -
    \ +
    \
    \ \
    \ @@ -71,7 +123,7 @@ App.Templates.html = { popup_create_dir: ['
    \
    Create directory
    \ \ -
    \ +
    \
    \ \
    \ @@ -79,6 +131,12 @@ App.Templates.html = {

    cancel

    \

    create

    \
    \ +
    '], + popup_no_file_selected: ['
    \ +
    Please select a file
    \ +
    \ +

    ok

    \ +
    \
    '] } }; diff --git a/web/templates/file_manager/main.php b/web/templates/file_manager/main.php index c2cfe315d..426cf4e96 100644 --- a/web/templates/file_manager/main.php +++ b/web/templates/file_manager/main.php @@ -16,19 +16,19 @@
    -
    + +
    '.$dir.''; } ?> */ ?>
    -