Commit 49339f20 by Dányi Bence

one: faster ajax listfolder

parent d9c6bb86
...@@ -35,7 +35,6 @@ $(function() { ...@@ -35,7 +35,6 @@ $(function() {
$(this).parent('.wm').addClass('opened'); $(this).parent('.wm').addClass('opened');
$(this).next('.details').slideDown(700); $(this).next('.details').slideDown(700);
} }
} }
$('.wm .summary').unbind('click').click(toggleDetails); $('.wm .summary').unbind('click').click(toggleDetails);
$('#new-wm-button').click(function() { $('#new-wm-button').click(function() {
...@@ -64,7 +63,7 @@ $(function() { ...@@ -64,7 +63,7 @@ $(function() {
$('.quota .used').each(function() { $('.quota .used').each(function() {
var s = this; var s = this;
$(this).css('backgroundColor', function(w) { $(this).css('backgroundColor', function(w) {
return 'hsla(' + (120 - parseFloat(w) / 100*120).toFixed(0) + ',100%,50%,0.2)'; return 'hsla(' + (120 - parseFloat(w) / 100 * 120).toFixed(0) + ',100%,50%,0.2)';
}($(this)[0].style.width)); }($(this)[0].style.width));
if(parseInt($(this).css('width')) > 0) $(this).css('borderRight', function(w) { if(parseInt($(this).css('width')) > 0) $(this).css('borderRight', function(w) {
return '1px solid hsla(' + (120 - parseFloat(w) / 100 * 120).toFixed(0) + ',100%,30%,0.4)'; return '1px solid hsla(' + (120 - parseFloat(w) / 100 * 120).toFixed(0) + ',100%,30%,0.4)';
...@@ -200,7 +199,7 @@ $(function() { ...@@ -200,7 +199,7 @@ $(function() {
}, },
size: function(a, b) { size: function(a, b) {
if(a.type === b.type) { if(a.type === b.type) {
return b.originalSize-a.originalSize; return b.originalSize - a.originalSize;
} }
if(a.type === gettext('file')) { if(a.type === gettext('file')) {
return 1; return 1;
...@@ -213,7 +212,7 @@ $(function() { ...@@ -213,7 +212,7 @@ $(function() {
/** /**
* Loads the specified folder * Loads the specified folder
*/ */
var loadFolder = throttle(function(path) { var loadFolder = throttle(function(path, fast) {
self.currentPath(path); self.currentPath(path);
self.fileLimit = 5; self.fileLimit = 5;
$.ajax({ $.ajax({
...@@ -222,20 +221,24 @@ $(function() { ...@@ -222,20 +221,24 @@ $(function() {
url: '/ajax/store/list', url: '/ajax/store/list',
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {
$('.file-list .real').css({ if(!fast) {
left: 0,
position: 'relative'
}).animate({
left: '-100%'
}, 500).promise().done(function() {
loadFolderDone(data);
$('.file-list .real').css({ $('.file-list .real').css({
left: '-300%', left: 0,
position: 'relative' position: 'relative'
}).animate({ }).animate({
left: 0 left: '-100%'
}, 500); }, 500).promise().done(function() {
}); loadFolderDone(data);
$('.file-list .real').css({
left: '-300%',
position: 'relative'
}).animate({
left: 0
}, 500);
});
} else {
loadFolderDone(data);
}
}, },
}) })
}) })
...@@ -319,7 +322,6 @@ $(function() { ...@@ -319,7 +322,6 @@ $(function() {
self.fadeOutFile = function(e) { self.fadeOutFile = function(e) {
try { try {
$(e).slideUp(500, function() { $(e).slideUp(500, function() {
console.log('sssaa', e);
e.parentNode.removeChild(e); e.parentNode.removeChild(e);
}); });
} catch(ex) { } catch(ex) {
...@@ -348,10 +350,9 @@ $(function() { ...@@ -348,10 +350,9 @@ $(function() {
self.delete = function(item) { self.delete = function(item) {
$('#modal').show(); $('#modal').show();
s = ""; s = "";
if (item.type == gettext('file')) { if(item.type == gettext('file')) {
s = gettext("You are removing the file <strong>%s</strong>."); s = gettext("You are removing the file <strong>%s</strong>.");
} } else {
else {
s = gettext("You are removing the folder <strong>%s</strong> (and its content)."); s = gettext("You are removing the folder <strong>%s</strong> (and its content).");
} }
...@@ -377,16 +378,22 @@ $(function() { ...@@ -377,16 +378,22 @@ $(function() {
* Renames the specified file * Renames the specified file
*/ */
self.rename = function(item, e) { self.rename = function(item, e) {
e.stopPropagation();
var oldName = $(e.target).parent().parent().parent().find('.name').html(); var oldName = $(e.target).parent().parent().parent().find('.name').html();
$(e.target).parent().unbind('click').click(function() { $(e.target).parent().unbind('click').click(function(f) {
f.stopPropagation();
$(e.target).parent().parent().parent().find('.name').html(oldName); $(e.target).parent().parent().parent().find('.name').html(oldName);
$(e.target).parent().click(function(e) { $(e.target).parent().click(function(g) {
self.rename(item, e); g.stopPropagation();
self.rename(item, g);
}); });
}) })
//$(e.target).parent().parent().parent().unbind('click'); //$(e.target).parent().parent().parent().unbind('click');
$(e.target).parent().parent().parent().find('.name').html('<input type="text" value="' + item.originalName + '" />\ $(e.target).parent().parent().parent().find('.name').html('<input type="text" value="' + item.originalName + '" />\
<input type="submit" value="Átnevezés" />'); <input type="submit" value="Átnevezés" />');
$(e.target).parent().parent().parent().find('.name input').click(function(f){
f.stopPropagation();
})
$(e.target).parent().parent().parent().find('.name input[type=submit]').click(function(e) { $(e.target).parent().parent().parent().find('.name input[type=submit]').click(function(e) {
e.preventDefault(); e.preventDefault();
var newName = $(e.target).parent().parent().parent().find('.name input[type=text]').val(); var newName = $(e.target).parent().parent().parent().find('.name input[type=text]').val();
...@@ -396,7 +403,7 @@ $(function() { ...@@ -396,7 +403,7 @@ $(function() {
url: '/ajax/store/rename', url: '/ajax/store/rename',
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {
loadFolder(self.currentPath()); loadFolder(self.currentPath(),true);
} }
}) })
return false; return false;
...@@ -431,7 +438,7 @@ $(function() { ...@@ -431,7 +438,7 @@ $(function() {
url: '/ajax/store/newFolder', url: '/ajax/store/newFolder',
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {
loadFolder(self.currentPath()); loadFolder(self.currentPath(),true);
} }
}) })
}); });
......
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