define([], function () { var currentDeferred; var hasChanges; var currentOptions; function onSubmit() { var form = this; var dlg = $(form).parents('paper-dialog')[0]; ApiClient.addVirtualFolder($('#txtValue', form).val(), $('#selectCollectionType', form).val(), currentOptions.refresh).done(function () { hasChanges = true; PaperDialogHelper.close(dlg); }).fail(function () { Dashboard.showError(Globalize.translate('DefaultErrorMessage')); }); return false; } function getCollectionTypeOptionsHtml(collectionTypeOptions) { return collectionTypeOptions.filter(function (i) { return i.isSelectable !== false; }).map(function (i) { return ''; }).join(""); } function initEditor(page, collectionTypeOptions) { $('#selectCollectionType', page).html(getCollectionTypeOptionsHtml(collectionTypeOptions)).val(''); $('form', page).off('submit', onSubmit).on('submit', onSubmit); } function onDialogClosed() { $(this).remove(); Dashboard.hideLoadingMsg(); currentDeferred.resolveWith(null, [hasChanges]); } function editor() { var self = this; self.show = function (options) { var deferred = DeferredBuilder.Deferred(); currentOptions = options; currentDeferred = deferred; hasChanges = false; require(['components/paperdialoghelper'], function () { HttpClient.send({ type: 'GET', url: 'components/medialibraryeditor/medialibraryeditor.template.html' }).done(function (template) { var dlg = PaperDialogHelper.createDialog({ size: 'small', theme: 'a' }); var html = ''; html += '