summaryrefslogtreecommitdiffstats
path: root/files
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2011-04-17 17:49:56 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2011-04-17 17:49:56 +0200
commit9b26cb0bfb6c6b3aab03eb3320a9a9917786f1ac (patch)
tree3f0d533cc60706c8a5fddcd237875cb5b82c7cce /files
parent60b682561254797330110693705b2c36dd7928a4 (diff)
downloadnextcloud-server-9b26cb0bfb6c6b3aab03eb3320a9a9917786f1ac.tar.gz
nextcloud-server-9b26cb0bfb6c6b3aab03eb3320a9a9917786f1ac.zip
implement "new folder" function
Diffstat (limited to 'files')
-rw-r--r--files/ajax/newfolder.php29
-rw-r--r--files/css/files.css4
-rw-r--r--files/js/files.js62
-rw-r--r--files/templates/index.php7
4 files changed, 89 insertions, 13 deletions
diff --git a/files/ajax/newfolder.php b/files/ajax/newfolder.php
new file mode 100644
index 00000000000..988e7f04012
--- /dev/null
+++ b/files/ajax/newfolder.php
@@ -0,0 +1,29 @@
+<?php
+
+// Init owncloud
+require_once('../../lib/base.php');
+
+// We send json data
+header( "Content-Type: application/jsonrequest" );
+
+// Check if we are a user
+if( !OC_USER::isLoggedIn()){
+ echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
+ exit();
+}
+
+// Get the params
+$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
+$foldername = isset( $_GET['foldername'] ) ? $_GET['foldername'] : '';
+
+if($foldername == '') {
+ echo json_encode( array( "status" => "error", "data" => array( "message" => "Empty Foldername" )));
+ exit();
+}
+error_log('try to create ' . $foldername . ' in ' . $dir);
+if(OC_FILES::newFile($dir, $foldername, 'dir')) {
+ echo json_encode( array( "status" => "success", "data" => array()));
+ exit();
+}
+
+echo json_encode( array( "status" => "error", "data" => array( "message" => "Error when creating the folder" ))); \ No newline at end of file
diff --git a/files/css/files.css b/files/css/files.css
index 1d7fb5ef592..4c5bd0427b6 100644
--- a/files/css/files.css
+++ b/files/css/files.css
@@ -23,11 +23,11 @@
display: none;
}
-#file_upload_target {
+#file_newfolder_form {
display: none;
}
-#file_action_panel {
+#file_upload_target {
display: none;
}
diff --git a/files/js/files.js b/files/js/files.js
index 44506763032..313727cedbc 100644
--- a/files/js/files.js
+++ b/files/js/files.js
@@ -1,4 +1,6 @@
$(document).ready(function() {
+ $('#file_action_panel').attr('activeAction', false);
+
// Sets browser table behaviour :
$('.browser tr').hover(
function() {
@@ -37,16 +39,43 @@ $(document).ready(function() {
$('.browser input:checkbox').attr('checked', false);
});
- // Shows and hides file upload form
- $('#file_upload_button').toggle(function() {
- $('#file_upload_form').css({"display":"block"});
- }, function() {
- $('#file_upload_form').css({"display":"none"});
- });
-
$('#file_upload_start').click(function() {
$('#file_upload_target').load(uploadFinished);
});
+
+ $('#file_new_dir_submit').click(function() {
+ $.ajax({
+ url: 'ajax/newfolder.php',
+ data: "dir="+$('#dir').val()+"&foldername="+$('#file_new_dir_name').val(),
+ complete: boolOpFinished
+ });
+ });
+
+ $('.upload').click(function(){
+ if($('#file_action_panel').attr('activeAction') != 'upload') {
+ $('#file_action_panel').attr('activeAction', 'upload');
+ $('#fileSelector').replaceWith('<input type="file" name="file" id="fileSelector">');
+ $('#file_action_panel form').css({"display":"none"});
+ $('#file_upload_form').css({"display":"block"});
+ } else {
+ $('#file_action_panel').attr('activeAction', 'false');
+ $('#file_upload_form').css({"display":"none"})
+ }
+ return false;
+ });
+
+ $('.new-dir').click(function(){
+ if($('#file_action_panel').attr('activeAction') != 'new-dir') {
+ $('#file_action_panel').attr('activeAction', 'new-dir');
+ $('#file_new_dir_name').val('');
+ $('#file_action_panel form').css({"display":"none"});
+ $('#file_newfolder_form').css({"display":"block"})
+ } else {
+ $('#file_newfolder_form').css({"display":"none"})
+ $('#file_action_panel').attr('activeAction', false);
+ }
+ return false;
+ });
});
function uploadFinished() {
@@ -64,6 +93,24 @@ function uploadFinished() {
}
}
+function resetFileActionPanel() {
+ $('#file_action_panel form').css({"display":"none"});
+ $('#file_action_panel').attr('activeAction', false);
+}
+
+function boolOpFinished(data) {
+ result = eval("("+data.responseText+");");
+ if(result.status == 'success'){
+ $.ajax({
+ url: 'ajax/list.php',
+ data: "dir="+$('#dir').val(),
+ complete: refreshContents
+ });
+ } else {
+ alert(result.data.message);
+ }
+}
+
function refreshContents(data) {
result = eval("("+data.responseText+");");
if(typeof(result.data.breadcrumb) != 'undefined'){
@@ -71,6 +118,7 @@ function refreshContents(data) {
}
updateFileList(result.data.files);
$('#file_upload_button').click();
+ resetFileActionPanel();
}
function updateBreadcrumb(breadcrumbHtml) {
diff --git a/files/templates/index.php b/files/templates/index.php
index 28187bcb531..c6dc123cee0 100644
--- a/files/templates/index.php
+++ b/files/templates/index.php
@@ -5,16 +5,15 @@ href="" title="" class="new-dir">New folder</a><a href="" title=""
class="download">Download</a><a href="" title="" class="share">Share</a><a
href="" title="" class="delete">Delete</a>
</p>
- <div id="file_upload_form">
- <form action="ajax/upload.php"
+ <div id="file_action_panel">
+ <form id="file_upload_form" action="ajax/upload.php"
method="post" enctype="multipart/form-data" target="file_upload_target"><input
type="hidden" name="MAX_FILE_SIZE" value="<?php echo $_["uploadMaxFilesize"] ?>" id="max_upload"><input
type="hidden" name="dir" value="<?php echo $_["dir"] ?>" id="dir"><input
type="file" name="file" id="fileSelector"><input type="submit"
id="file_upload_start" value="Upload" /><iframe id="file_upload_target"
name="file_upload_target" src=""></iframe></form>
- </div>
- <div id="file_action_panel">
+ <form id="file_newfolder_form"><input type="text" name="file_new_dir_name" id="file_new_dir_name" />&nbsp;<input type="button" id="file_new_dir_submit" name="file_new_dir_submit" value="OK" /></form>
</div>
</div>