// requires DropZone ª toMarkdown if (typeof window.jQuery === 'undefined') { throw new Error('yavsc-remote-fs script requires jQuery'); } if (typeof XMLHttpRequest === 'undefined') { throw new Error('yavsc-remote-fs script requires XMLHttpRequest'); } (function ($) { 'use strict'; $.widget('psc.yarfs', { options: { fsnurl: '/api/fs' }, root: null, rmDialog: null, mvDialog: null, flist: null, fmlist: null, selection: [], curDirBar: null, subDirsBar: null, destination: null, rootDisplay: null, setRoot: function(sub) { this.root = sub; if (!this.root) this.rootDisplay.addClass('hidden'); else { this.rootDisplay.removeClass('hidden'); this.rootDisplay.html('from ' + this.root + ''); } }, openDir: function (sub) { var _this = this; this.setRoot(sub); var owner = this.element.data('owner'); this.selection = []; this.curDirBar.empty(); this.subDirsBar.empty(); $('') .click(function () { _this.openDir(null); }) .appendTo(this.curDirBar); var npath = null if (_this.root) { var dnames = _this.root.split('/'); $.each(dnames, function () { var part = this; if (npath == null) npath = encodeURIComponent(part); else npath = npath + '/' + encodeURIComponent(part); $('').click( function() { var xmlhttp = new XMLHttpRequest(); xmlhttp.open('DELETE', '/api/fs/' + _this.root, true); xmlhttp.send(); xmlhttp.onreadystatechange = function(event) { // XMLHttpRequest.DONE === 4 if (this.readyState === XMLHttpRequest.DONE) { if (this.status === 200) { var dnames = _this.root.split('/'); var dcnt = dnames.length; var nroot = dnames.slice(0,dcnt-1).join('/'); _this.openDir(nroot); } } } }).appendTo(_this.subDirsBar); } else { $.each(data.SubDirectories, function () { var item = this; var spath = _this.root ? _this.root + '/' + encodeURIComponent(item.Name) : encodeURIComponent(item.Name); $(''); mdCnt.append(mdHeader); var mdBody = $(''); mdBody.append('

You´re about to remove these files :

'); this.flist = $(''); mdBody.append(this.flist); mdCnt.append(mdBody); var rmcBtn = $('').click(function () { _this.RemoveSelectedFiles(); }); var mdFooter = $(''); mdFooter.append(rmcBtn); mdFooter.append(''); mdCnt.append(mdFooter); md.append(mdCnt); this.rmDialog.appendTo(this.element); }, onDestinationChanged: function (newDest) { this.destination = $(newDest).val(); }, createMvDialog: function () { var _this = this; this.mvDialog = $(''); this.mvDialog.addClass('modal'); this.mvDialog.addClass('fade'); var md = $('
'); md.addClass('modal-dialog'); var mdCnt = $(''); mdCnt.addClass('modal-content'); var mdHeader = $(''); mdHeader.append(''); mdHeader.append(''); mdCnt.append(mdHeader); var mdBody = $(''); mdBody.append('

You´re about to move these files :

'); this.fmlist = $(''); mdBody.append(this.fmlist); var inputDest = $('').on('change', function() { _this.onDestinationChanged(this); }); this.rootDisplay = $('

'); this.rootDisplay.addClass('hidden'); mdBody.append(this.rootDisplay); var rp = $('

to the folowing sub-directory

'); mdBody.append(rp); inputDest.appendTo(mdBody); mdCnt.append(mdBody); var moveBtn = $('').click(function () { _this.moveSelectedFiles(); }); var mdFooter = $(''); mdFooter.append(moveBtn); mdFooter.append(''); mdCnt.append(mdFooter); md.append(mdCnt); this.mvDialog.append(md); this.mvDialog.appendTo(this.element); }, _create: function () { var $view = this.element; var _this = this; this.curDirBar = $('
'); this.curDirBar.appendTo($view); this.subDirsBar = $('
'); this.subDirsBar.appendTo($view); this.ftable = $('') .css('border-spacing', '6px') .css('border-collapse', 'separate'); var btnRm = $('').click(function () { _this.askForRemoval(); }); var btnMv = $('').click(function () { _this.askForMoving(); }); var tr = $(''); _this.ftable.append(tr); tr.append($('').append(btnRm).append(btnMv)).append(''); _this.ftable.appendTo($view); this.createRmDialog(); this.createMvDialog(); this.openDir($view.data('path')); } }); })(window.jQuery);
NomTailleModification