Merge
This commit is contained in:
commit
ff598eaad2
39 changed files with 995 additions and 86 deletions
|
@ -1,20 +1,79 @@
|
|||
var processDialog;
|
||||
processDialog = processDialog || (function () {
|
||||
var processDialogDiv = $('#processDialog');
|
||||
function WspDialogs() {
|
||||
this.settings = { dialogId: "#confirm-dialog", processDialogId: "#processDialog" };
|
||||
}
|
||||
|
||||
WspDialogs.prototype =
|
||||
{
|
||||
showConfirmDialog: function(title, content, positiveButton, positiveClickFunction, dialogId) {
|
||||
dialogId = dialogId || this.settings.dialogId;
|
||||
|
||||
//title replace
|
||||
if (title) {
|
||||
$(dialogId).find('.modal-title').empty();
|
||||
$(dialogId).find('.modal-title').text(title);
|
||||
}
|
||||
|
||||
//body replace
|
||||
$(dialogId).find('.modal-body').empty();
|
||||
$(dialogId).find('.modal-body').html(content);
|
||||
|
||||
//title replace
|
||||
if (positiveButton) {
|
||||
$(dialogId).find('.modal-footer .positive-button').empty();
|
||||
$(dialogId).find('.modal-footer .positive-button').text(positiveButton);
|
||||
}
|
||||
|
||||
//binding click event
|
||||
$(dialogId).find('.modal-footer .positive-button').unbind('click');
|
||||
$(dialogId).find('.modal-footer .positive-button').click(positiveClickFunction);
|
||||
|
||||
$(dialogId).modal();
|
||||
},
|
||||
|
||||
showProcessDialog: function() {
|
||||
$(this.settings.processDialogId).modal();
|
||||
},
|
||||
|
||||
hideProcessDialog: function() {
|
||||
$(this.settings.processDialogId).modal('hide');
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
wsp.dialogs = wsp.dialogs || (function () {
|
||||
var settings = { dialogId: "#confirm-dialog" };
|
||||
|
||||
return {
|
||||
showPleaseWait: function () {
|
||||
settings: settings,
|
||||
|
||||
showConfirmDialog : function (title, content, positiveButton, positiveClickFunction, dialogId) {
|
||||
dialogId = dialogId || this.settings.dialogId;
|
||||
|
||||
//title replace
|
||||
if (title) {
|
||||
$(dialogId).find('.modal-title').empty();
|
||||
$(dialogId).find('.modal-title').text(title);
|
||||
}
|
||||
|
||||
//body replace
|
||||
$(dialogId).find('.modal-body').empty();
|
||||
$(dialogId).find('.modal-body').html(content);
|
||||
|
||||
//title replace
|
||||
if (positiveButton) {
|
||||
$(dialogId).find('.modal-footer .positive-button').empty();
|
||||
$(dialogId).find('.modal-footer .positive-button').text(positiveButton);
|
||||
}
|
||||
|
||||
//binding click event
|
||||
$(dialogId).find('.modal-footer .positive-button').unbind('click');
|
||||
$(dialogId).find('.modal-footer .positive-button').click(positiveClickFunction);
|
||||
|
||||
$(dialogId).modal();
|
||||
},
|
||||
|
||||
showProcessDialog: function () {
|
||||
$('#processDialog').modal();
|
||||
},
|
||||
hidePleaseWait: function () {
|
||||
$('#processDialog').modal('hide');
|
||||
},
|
||||
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.processing-dialog').click(function () {
|
||||
processDialog.showPleaseWait();
|
||||
});
|
||||
});
|
||||
})();*/
|
|
@ -0,0 +1,89 @@
|
|||
function WspFileBrowser() {
|
||||
this.settings = { deletionBlockSelector: ".file-actions-menu .file-deletion", deletionUrl: "files-group-action/delete1" };
|
||||
}
|
||||
|
||||
WspFileBrowser.prototype = {
|
||||
setSettings: function(options) {
|
||||
this.settings = $.extend(this.settings, options);
|
||||
},
|
||||
|
||||
clearAllSelectedItems: function() {
|
||||
$('.element-container').removeClass("selected-file");
|
||||
},
|
||||
|
||||
selectItem: function(item) {
|
||||
$(item).addClass("selected-file");
|
||||
},
|
||||
|
||||
openItem: function(item) {
|
||||
var links = $(item).find('.file-link');
|
||||
|
||||
if (links.length != 0) {
|
||||
links[0].click();
|
||||
}
|
||||
},
|
||||
|
||||
getSelectedItemsCount: function() {
|
||||
return $('.element-container.selected-file').length;
|
||||
},
|
||||
|
||||
getSelectedItemsPaths: function() {
|
||||
return $('.element-container.selected-file a').map(function() {
|
||||
return $(this).attr('href');
|
||||
}).get();
|
||||
},
|
||||
|
||||
deleteSelectedItems: function(e) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: wsp.fileBrowser.settings.deletionUrl,
|
||||
data: { filePathes: wsp.fileBrowser.getSelectedItemsPaths() },
|
||||
dataType: "json",
|
||||
success: function(model) {
|
||||
wsp.messages.showMessages(model.Messages);
|
||||
|
||||
wsp.fileBrowser.clearDeletedItems(model.DeletedFiles);
|
||||
|
||||
wsp.fileBrowser.refreshDeletionBlock();
|
||||
|
||||
wsp.dialogs.hideProcessDialog();
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
wsp.messages.addErrorMessage(errorThrown);
|
||||
wsp.fileBrowser.refreshDeletionBlock();
|
||||
wsp.dialogs.hideProcessDialog();
|
||||
}
|
||||
});
|
||||
|
||||
wsp.dialogs.showProcessDialog();
|
||||
},
|
||||
|
||||
clearDeletedItems: function(items) {
|
||||
$.each(items, function(i, item) {
|
||||
$('.element-container').has('a[href="' + item + '"]').remove();
|
||||
});
|
||||
},
|
||||
refreshDeletionBlock: function() {
|
||||
if (this.getSelectedItemsCount() > 0) {
|
||||
|
||||
$(this.settings.deletionBlockSelector).css('display', 'inline-block');
|
||||
|
||||
} else {
|
||||
$(this.settings.deletionBlockSelector).hide();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
function WspMessager(messageDivId) {
|
||||
this.settings = {
|
||||
messageDivId: messageDivId,
|
||||
successClass: "alert-success",
|
||||
infoClass: "alert-info",
|
||||
warningClass: "alert-warning",
|
||||
dangerClass: "alert-danger",
|
||||
messageDivtemplate: '<div class="alert {0} alert-dismissible" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>{1}</div>'
|
||||
};
|
||||
}
|
||||
|
||||
WspMessager.prototype = {
|
||||
addMessage: function(cssClass, message) {
|
||||
var messageDiv = jQuery.validator.format(this.settings.messageDivtemplate, cssClass, message);
|
||||
|
||||
$(messageDiv).appendTo(this.settings.messageDivId);
|
||||
},
|
||||
|
||||
addSuccessMessage: function(message) {
|
||||
this.addMessage(this.settings.successClass, message);
|
||||
},
|
||||
|
||||
addInfoMessage: function(message) {
|
||||
this.addMessage(this.settings.infoClass, message);
|
||||
},
|
||||
|
||||
addWarningMessage : function (message) {
|
||||
this.addMessage(this.settings.warningClass, message);
|
||||
},
|
||||
|
||||
addErrorMessage: function (message) {
|
||||
this.addMessage(this.settings.dangerClass, message);
|
||||
},
|
||||
|
||||
showMessages: function (messages) {
|
||||
var objthis = this;
|
||||
|
||||
$.each(messages, function(i, message) {
|
||||
|
||||
if ((message.Type == 0)) {
|
||||
objthis.addSuccessMessage(message.Value);
|
||||
}
|
||||
else if (message.Type == 1) {
|
||||
objthis.addInfoMessage(message.Value);
|
||||
}
|
||||
else if (message.Type == 2) {
|
||||
objthis.addWarningMessage(message.Value);
|
||||
}
|
||||
else if (message.Type == 3) {
|
||||
objthis.addErrorMessage(message.Value);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
|
@ -6,6 +6,10 @@
|
|||
|
||||
maxHeight = Math.max.apply(null, heights);
|
||||
|
||||
if (maxHeight < 135) {
|
||||
maxHeight = 135;
|
||||
}
|
||||
|
||||
$(".element-container").height(maxHeight);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
var wsp = {
|
||||
messages: new WspMessager('#message-area'),
|
||||
fileBrowser: new WspFileBrowser(),
|
||||
dialogs: new WspDialogs()
|
||||
};
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
$('.processing-dialog').click(function () {
|
||||
wsp.dialogs.showProcessDialog();
|
||||
});
|
||||
});
|
||||
|
||||
//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();
|
||||
});
|
||||
|
||||
//Double click file open
|
||||
$(document).on('dblclick', '.element-container', function (e) {
|
||||
wsp.fileBrowser.openItem(this);
|
||||
});
|
||||
|
||||
|
||||
//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();
|
||||
}
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue