diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/App_Start/BundleConfig.cs b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/App_Start/BundleConfig.cs index 8b6dd2c9..d3be4e58 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/App_Start/BundleConfig.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/App_Start/BundleConfig.cs @@ -35,6 +35,10 @@ namespace WebsitePanel.WebDavPortal "~/Scripts/appScripts/wsp.js" )); + bundles.Add(new ScriptBundle("~/bundles/appScripts-webdav").Include( + "~/Scripts/appScripts/wsp-webdav.js" + )); + bundles.Add(new ScriptBundle("~/bundles/bigIconsScripts").Include( "~/Scripts/appScripts/recalculateResourseHeight.js" )); diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Content/Site.css b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Content/Site.css index 4f95621b..65108355 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Content/Site.css +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Content/Site.css @@ -346,6 +346,10 @@ tr.selected-file { display: none; } +#filenameForm input { + max-width: 100%; +} + /* Theme Mods */ input,div{border-radius:0px!important;} diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Scripts/appScripts/fileBrowsing.js b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Scripts/appScripts/fileBrowsing.js index 114e103d..d7a33633 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Scripts/appScripts/fileBrowsing.js +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Scripts/appScripts/fileBrowsing.js @@ -10,7 +10,8 @@ return textItemExist; } , createNewItemDialogId: "#createNewItemDialog", - createNewItemButtonId: "#create-button" + createNewItemButtonId: "#create-button", + createNewItemTitleId: '#create-dalog-label' }; this.itemsTable = null; this.searchTable = null; @@ -281,12 +282,14 @@ WspFileBrowser.prototype = { return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i]; }, - showCreateNewItemDialog: function (extension, target) { + showCreateNewItemDialog: function (extension, target, title) { $(this.settings.createNewItemButtonId).data('extension', extension); $(this.settings.createNewItemButtonId).data('target', target); $(this.settings.createNewItemDialogId + " input").val(""); + $(this.settings.createNewItemTitleId).text($(this.settings.createNewItemTitleId).data('title') + " " + title); + $(this.settings.createNewItemDialogId).modal(); }, diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Scripts/appScripts/wsp-webdav.js b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Scripts/appScripts/wsp-webdav.js index 5f282702..90c6f7d8 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Scripts/appScripts/wsp-webdav.js +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Scripts/appScripts/wsp-webdav.js @@ -1 +1,124 @@ - \ No newline at end of file +//Toggle file select + Ctrl multiselect +$(document).on('click', '.element-container', function (e) { + if (e.ctrlKey) { + $(this).toggleClass("selected-file"); + } else { + + wsp.fileBrowser.clearAllSelectedItems(); + + wsp.fileBrowser.selectItem(this); + } + + wsp.fileBrowser.refreshDeletionBlock(); +}); + +$(document).on('touchstart', '.element-container', function (e) { + var now = new Date().getTime(); + var lastTouch = $(this).data('lastTouch') || now + 1; + var delta = now - lastTouch; + + if (delta < 300 && delta > 0) { + wsp.fileBrowser.openItem(this); + $(this).data('lastTouch', 0); + } + + $(this).data('lastTouch', now); +}); + +//Double click file open +$(document).on('dblclick', '.element-container', function (e) { + wsp.fileBrowser.openItem(this); + + var links = $(this).find('.file-link'); + + if (links.length != 0 && $(links[0]).hasClass('processing-dialog')) { + wsp.dialogs.showProcessDialog(); + } +}); + + +//Delete button click +$(document).on('click', '.file-deletion #delete-button', function (e) { + var dialogId = $(this).data('target'); + var buttonText = $(this).data('target-positive-button-text'); + var content = $(this).data('target-content'); + var title = $(this).data('target-title-text'); + + content = jQuery.validator.format(content, wsp.fileBrowser.getSelectedItemsCount()); + + wsp.dialogs.showConfirmDialog(title, content, buttonText, wsp.fileBrowser.deleteSelectedItems, dialogId); +}); + + +$(document).click(function (event) { + if (!$(event.target).closest('.element-container, .prevent-deselect').length) { + wsp.fileBrowser.clearAllSelectedItems(); + wsp.fileBrowser.refreshDeletionBlock(); + } +}); + +$('#drag-and-drop-area').click(function (e) { + $('#file-input').click(); +}); + +$('#drag-and-drop-area #file-input').click(function (e) { + e.stopPropagation(); +}); + + + +$("#create-button").click(function (e) { + + if ($('#filenameForm').valid()) { + + var fileName = $('#createNewItemDialog #filename').val() + $(this).data('extension'); + + $(this).attr('href', $(this).data('href') + '/' + fileName); + + $(this).attr('target', $(this).data('target')); + + wsp.fileBrowser.hideCreateNewItemDialog(); + //; + } else { + e.preventDefault(); + } +}); + +$(document).ready(function () { + + $('#filenameForm').validate({ + onkeyup: false, + onclick: false, + async: false, + rules: { + filename: { + required: true, + synchronousRemote: wsp.fileBrowser.uniqueFileNameFieldRule("#filename") + } + }, + messages: { + filename: { + synchronousRemote: wsp.fileBrowser.settings.textItemExist + } + } + }); + +}); + +$('#filename').keydown(function (event) { + if (event.keyCode == 13) { + event.preventDefault(); + return false; + } + return true; +}); + + +$(".create-new-item li a").click(function () { + + $("#filenameForm").clearValidation(); + + wsp.fileBrowser.showCreateNewItemDialog($(this).data('extension'), $(this).data('target'), $(this).text()); + + $("#filename").focus(); +}); diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Scripts/appScripts/wsp.js b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Scripts/appScripts/wsp.js index ce9fb0a4..a45da0f1 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Scripts/appScripts/wsp.js +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Scripts/appScripts/wsp.js @@ -10,94 +10,6 @@ $(document).on('click', '.processing-dialog', function (e) { }); -//Toggle file select + Ctrl multiselect -$(document).on('click', '.element-container', function (e) { - if (e.ctrlKey) { - $(this).toggleClass("selected-file"); - } else { - - wsp.fileBrowser.clearAllSelectedItems(); - - wsp.fileBrowser.selectItem(this); - } - - wsp.fileBrowser.refreshDeletionBlock(); -}); - -$(document).on('touchstart', '.element-container', function(e) { - var now = new Date().getTime(); - var lastTouch = $(this).data('lastTouch') || now + 1; - var delta = now - lastTouch; - - if (delta < 300 && delta > 0) { - wsp.fileBrowser.openItem(this); - $(this).data('lastTouch', 0); - } - - $(this).data('lastTouch', now); -}); - -//Double click file open -$(document).on('dblclick', '.element-container', function (e) { - wsp.fileBrowser.openItem(this); - - var links = $(this).find('.file-link'); - - if (links.length != 0 && $(links[0]).hasClass('processing-dialog')) { - wsp.dialogs.showProcessDialog(); - } -}); - - -//Delete button click -$(document).on('click', '.file-deletion #delete-button', function (e) { - var dialogId = $(this).data('target'); - var buttonText = $(this).data('target-positive-button-text'); - var content = $(this).data('target-content'); - var title = $(this).data('target-title-text'); - - content = jQuery.validator.format(content, wsp.fileBrowser.getSelectedItemsCount()); - - wsp.dialogs.showConfirmDialog(title, content, buttonText, wsp.fileBrowser.deleteSelectedItems, dialogId); -}); - - -$(document).click(function(event) { - if (!$(event.target).closest('.element-container, .prevent-deselect').length) { - wsp.fileBrowser.clearAllSelectedItems(); - wsp.fileBrowser.refreshDeletionBlock(); - } -}); - -$('#drag-and-drop-area').click(function (e) { - $('#file-input').click(); -}); - -$('#drag-and-drop-area #file-input').click(function (e) { - e.stopPropagation(); -}); - - - -$("#create-button").click(function (e) { - - if ($('#filenameForm').valid()) { - - var fileName = $('#createNewItemDialog #filename').val() + $(this).data('extension'); - - $(this).attr('href', $(this).data('href') + '/' + fileName); - - $(this).attr('target', $(this).data('target')); - - wsp.fileBrowser.hideCreateNewItemDialog(); - //; - } else { - e.preventDefault(); - } -}); - -$.fn.clearValidation = function () { var v = $(this).validate(); $('[name]', this).each(function () { v.successList.push(this); v.showErrors(); }); v.resetForm(); v.reset(); $(this).find('.form-group').removeClass('has-error'); }; - $(document).ready(function() { //bootstrap jquery validate styles fix $.validator.setDefaults({ @@ -118,7 +30,7 @@ $(document).ready(function() { } }); - $.validator.addMethod("synchronousRemote", function (value, element, param) { + $.validator.addMethod("synchronousRemote", function(value, element, param) { if (this.optional(element)) { return "dependency-mismatch"; } @@ -149,7 +61,7 @@ $(document).ready(function() { port: "validate" + element.name, dataType: "json", data: data, - success: function (response) { + success: function(response) { validator.settings.messages[element.name].remote = previous.originalMessage; valid = response === true || response === "true"; if (valid) { @@ -172,36 +84,10 @@ $(document).ready(function() { }, param)); return valid; }, "Please fix this field."); - - - $('#filenameForm').validate({ - onkeyup: false, - onclick: false, - async: false, - rules: { - filename: { - required: true, - synchronousRemote: wsp.fileBrowser.uniqueFileNameFieldRule("#filename") - } - }, - messages: { - filename: { - synchronousRemote: wsp.fileBrowser.settings.textItemExist - } - } - }); - }); -$(".create-new-item li a").click(function () { - - $("#filenameForm").clearValidation(); - - wsp.fileBrowser.showCreateNewItemDialog($(this).data('extension'), $(this).data('target')); - - $("#filename").focus(); -}); +$.fn.clearValidation = function () { var v = $(this).validate(); $('[name]', this).each(function () { v.successList.push(this); v.showErrors(); }); v.resetForm(); v.reset(); $(this).find('.form-group').removeClass('has-error'); }; function isMobileDevice() { diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/FileSystem/ShowContent.cshtml b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/FileSystem/ShowContent.cshtml index e62225b2..db3e1da3 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/FileSystem/ShowContent.cshtml +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/FileSystem/ShowContent.cshtml @@ -25,12 +25,15 @@ else @section scripts{ + + + @Scripts.Render("~/bundles/appScripts-webdav") @if (Model.UserSettings.WebDavViewType == FolderViewTypes.BigIcons) { @@ -62,7 +65,7 @@ else