Commit 96f1b1e0 by Dányi Bence

store: ajax new folder

parent e453dc74
......@@ -32,4 +32,5 @@ urlpatterns = patterns('',
url(r'^ajax/store/download$', 'store.views.ajax_download', name='store_ajax_download'),
url(r'^ajax/store/upload$', 'store.views.ajax_upload', name='store_ajax_upload'),
url(r'^ajax/store/delete$', 'store.views.ajax_delete', name='store_ajax_delete'),
url(r'^ajax/store/newFolder$', 'store.views.ajax_new_folder', name='store_ajax_new_folder'),
)
......@@ -138,6 +138,16 @@
}
}
}
#new-folder-form {
float: right;
margin-left: 5px;
display: none;
z-index: 2;
position: relative;
}
}
&.opened #new-folder-form {
display: block;
}
.details{
border-top: 1px solid #888;
......@@ -206,9 +216,6 @@
}
}
}
&.opened .details{
display: block;
}
&.new .name{
background-image: url(icons/computer--plus.png);
}
......@@ -239,7 +246,7 @@
background-image: url(icons/folder-zipper.png);
}
.filetype-folder {
background-image: url(icons/folder-horizontal.png);
background-image: url(icons/folder.png);
}
.filetype-more {
background-image: url(icons/arrow-circle-double.png);
......@@ -247,6 +254,9 @@
.filetype-up {
background-image: url(icons/upload-cloud.png);
}
.filetype-new-folder {
background-image: url(icons/folder--plus.png);
}
.filetype-jump-out {
background-image: url(icons/arrow-curve-090.png);
}
......
......@@ -28,15 +28,15 @@ $(function() {
}
});
toggleDetails = function() {
if($(this).next('.details').is(':hidden')) {
$(this).next('.details').slideDown(700);
$(this).parent('.wm').addClass('opened');
if($(this).parent('.wm').hasClass('opened')){
$(this).parent('.wm').removeClass('opened');
$(this).next('.details').slideUp(700);
} else {
var that = this;
$(this).next('.details').slideUp(700, function() {
$(that).parent('.wm').removeClass('opened');
});
console.log('addClass');
$(this).parent('.wm').addClass('opened');
$(this).next('.details').slideDown(700);
}
}
$('.wm .summary').unbind('click').click(toggleDetails);
$('#load-more-files').click(function() {
......@@ -76,9 +76,8 @@ $(function() {
self.allFiles = [];
self.notInRoot = ko.observable(false);
self.fileLimit = 5;
var disabled = false;
function throttle(f) {
var disabled = false;
return function() {
if(disabled) {
console.log('disabled');
......@@ -195,18 +194,29 @@ $(function() {
}
self.uploadURL=ko.observable('/');
self.getUploadURL=function(){
console.log('sad')
$.ajax({
type: 'POST',
data: 'ul='+self.currentPath(),
data: 'ul='+self.currentPath()+'&next='+encodeURI(window.location.href),
url: '/ajax/store/upload',
dataType: 'json',
success: function(data){
console.log('asdasd', data);
self.uploadURL(data.url);
}
}).error(function(){ console.log('asd', arguments)})
}
self.newFolderName=ko.observable();
self.newFolder=throttle(function(i,e){
$(e.target).parent().parent().parent().removeClass('opened');
$.ajax({
type: 'POST',
data: 'new='+self.newFolderName()+'&path='+self.currentPath(),
url: '/ajax/store/newFolder',
dataType: 'json',
success: function(data){
loadFolder(self.currentPath());
}
})
});
loadFolder(self.currentPath());
}
var model = new Model();
......
......@@ -61,6 +61,16 @@
<div class="clear"></div>
</div>
</li>
<li class="wm">
<div class="summary">
<div class="name filetype-new-folder">Új mappa</div>
<div id="new-folder-form">
<input type="text" placeholder="Új mappa neve" data-bind="value: newFolderName, click: function(m,e){console.log(arguments); e.preventDefault(); e.stopPropagation(); return false;}" />
<input type="submit" data-bind="click: newFolder, clickBubble: false" value="Létrehozás" />
</div>
<div class="clear"></div>
</div>
</li>
<li class="file-upload wm">
<div class="summary" data-bind="click: getUploadURL">
<div class="name filetype-up">Fájlfeltöltés</div>
......
......@@ -127,6 +127,18 @@ def ajax_delete(request):
return HttpResponse('File not found!', status_code=404)
@login_required
def ajax_new_folder(request):
user = request.user.username
try:
path = request.POST['path']
new = request.POST['new']
success = StoreApi.requestnewfolder(user,path+'/'+new)
return HttpResponse(json.dumps({'success':success}))
except:
pass
return HttpResponse('Error!', status_code=404)
@login_required
def toplist(request):
user = request.user.username
path = backpath = '/'
......
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 sign in to comment