diff --git a/circle/dashboard/static/dashboard/dashboard.css b/circle/dashboard/static/dashboard/dashboard.css index caf4eca..6d4a916 100644 --- a/circle/dashboard/static/dashboard/dashboard.css +++ b/circle/dashboard/static/dashboard/dashboard.css @@ -722,3 +722,35 @@ textarea[name="list-new-namelist"] { margin-bottom: 20px; } + +#store-list-list { + list-style: none; +} + +.store-list-item { + cursor: pointer; +} + +.store-list-item:hover { + background: rgba(0, 0, 0, 0.6); +} + +.store-list-item-icon { + width: 20px; + text-align: center; + display: inline-block; + margin-right: 15px; +} + +.store-list-item-size { + width: 70px; + text-align: right; + float: right; +} + +.store-list-file-infos { + padding: 20px; + display: none; + border-left: 1px solid #ddd; + border-right: 1px solid #ddd; +} diff --git a/circle/dashboard/static/dashboard/store.js b/circle/dashboard/static/dashboard/store.js new file mode 100644 index 0000000..4f50721 --- /dev/null +++ b/circle/dashboard/static/dashboard/store.js @@ -0,0 +1,58 @@ +$(function() { + $(".store-list-item").click(function() { + if($(this).data("item-type") == "D") return true; + $(this).next(".store-list-file-infos").stop().slideToggle(); + return false; + }); + + /* less js way, but at least works, tho redirection is bad */ + $('form input[type="submit"]').click(function() { + var current_dir = $("form").find('[name="current_dir"]').val(); + $.get($("form").data("action") + "?current_dir=" + current_dir, function(result) { + $("form").get(0).setAttribute("action", result['url']); + $("form").submit(); + }); + + return false; + }); + + /* click on the "fake" browse button will */ + $('#store-upload-browse').click(function() { + $('#store-upload-form input[type="file"]').click(); + }); + + $("#store-upload-file").change(function() { + var input = $(this); + var numFiles = input.get(0).files ? input.get(0).files.length : 1; + var label = input.val().replace(/\\/g, '/').replace(/.*\//, ''); + input.trigger('fileselect', [numFiles, label]); + }); + + $("#store-upload-file").on("fileselect", function(event, numFiles, label) { + var input = $("#store-upload-filename"); + var log = numFiles > 1 ? numFiles + ' files selected' : label; + + if(input.length) { + input.val(log); + } + }); + + + /* this does not work + $('form input[type="submit"]').click(function() { + var current_dir = $("form").find('[name="current_dir"]').val(); + $.get($("form").data("action") + "?current_dir=" + current_dir, function(result) { + $.ajax({ + method: "POST", + url: result['url'], + data: $("form").serialize(), + success: function(re) { + console.log(re); + } + }); + }); + + return false; + }); */ + +}); diff --git a/circle/dashboard/templates/dashboard/store/list.html b/circle/dashboard/templates/dashboard/store/list.html index 6a67450..9bdc651 100644 --- a/circle/dashboard/templates/dashboard/store/list.html +++ b/circle/dashboard/templates/dashboard/store/list.html @@ -74,107 +74,12 @@ </span> </div> <input id="store-upload-file" name="data" type="file" style="display:none" multiple> - -<script type="text/javascript"> - $('#store-upload-browse').click(function() { - $('#store-upload-form input[type="file"]').click(); - }); - - $("#store-upload-file").change(function() { - var input = $(this); - var numFiles = input.get(0).files ? input.get(0).files.length : 1; - var label = input.val().replace(/\\/g, '/').replace(/.*\//, ''); - input.trigger('fileselect', [numFiles, label]); - }); - - $("#store-upload-file").on("fileselect", function(event, numFiles, label) { - var input = $("#store-upload-filename"); - var log = numFiles > 1 ? numFiles + ' files selected' : label; - - if( input.length ) { - input.val(log); - } - }); - -</script> </form> </div> </div> </div> </div> -<style> - #store-list-list { - list-style: none; - } - - .store-list-item { - cursor: pointer; - } - - .store-list-item:hover { - background: rgba(0, 0, 0, 0.6); - } - - .store-list-item-icon { - width: 20px; - text-align: center; - display: inline-block; - margin-right: 15px; - } - - .store-list-item-size { - width: 70px; - text-align: right; - float: right; - } - - .store-list-file-infos { - padding: 20px; - display: none; - border-left: 1px solid #ddd; - border-right: 1px solid #ddd; - } -</style> -<script> -$(function() { - $(".store-list-item").click(function() { - if($(this).data("item-type") == "D") return true; - $(this).next(".store-list-file-infos").stop().slideToggle(); - return false; - }); - - /* less js way, but at least works, tho redirection is bad */ - $('form input[type="submit"]').click(function() { - var current_dir = $("form").find('[name="current_dir"]').val(); - $.get($("form").data("action") + "?current_dir=" + current_dir, function(result) { - $("form").get(0).setAttribute("action", result['url']); - $("form").submit(); - }); - - return false; - }); - - /* this does not work - $('form input[type="submit"]').click(function() { - var current_dir = $("form").find('[name="current_dir"]').val(); - $.get($("form").data("action") + "?current_dir=" + current_dir, function(result) { - $.ajax({ - method: "POST", - url: result['url'], - data: $("form").serialize(), - success: function(re) { - console.log(re); - } - }); - }); - - return false; - }); */ - -}); -</script> - {% endblock %} {% block extra_js %}