Inital commit
This commit is contained in:
@@ -9,12 +9,14 @@ $(function($){
|
||||
// Remove document on click
|
||||
$.documentUploadManager.initDocumentDropZone = function() {
|
||||
$.documentUploadManager.onClickDeleteDocument();
|
||||
$.documentUploadManager.onClickModal();
|
||||
$.documentUploadManager.onModalHidden();
|
||||
$.documentUploadManager.sortDocument();
|
||||
$.documentUploadManager.onClickToggleVisibilityDocument();
|
||||
|
||||
var documentDropzone = new Dropzone("#documents-dropzone", {
|
||||
dictDefaultMessage : $('.btn-browse').html(),
|
||||
uploadMultiple: false,
|
||||
maxFilesize: 8
|
||||
uploadMultiple: false
|
||||
});
|
||||
|
||||
var totalFiles = 0,
|
||||
@@ -40,6 +42,7 @@ $(function($){
|
||||
documentDropzone.removeFile(file);
|
||||
$.documentUploadManager.updateDocumentListAjax();
|
||||
$.documentUploadManager.onClickDeleteDocument();
|
||||
$.documentUploadManager.onClickToggleVisibilityDocument();
|
||||
});
|
||||
|
||||
|
||||
@@ -61,22 +64,42 @@ $(function($){
|
||||
}
|
||||
}
|
||||
}).done(function(data) {
|
||||
$documentListArea.html(
|
||||
data
|
||||
);
|
||||
$.documentUploadManager.onClickDeleteDocument();
|
||||
$.documentUploadManager.sortDocument();
|
||||
});
|
||||
$documentListArea.html(
|
||||
data
|
||||
);
|
||||
$.documentUploadManager.onClickDeleteDocument();
|
||||
$.documentUploadManager.sortDocument();
|
||||
$.documentUploadManager.onClickToggleVisibilityDocument();
|
||||
});
|
||||
};
|
||||
|
||||
// Remove document on click
|
||||
$.documentUploadManager.onClickDeleteDocument = function() {
|
||||
$('.document-manager .document-delete-btn').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
$("#submit-delete-document").data("element-id", $(this).attr("id"));
|
||||
$('#document_delete_dialog').modal("show");
|
||||
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
$.documentUploadManager.onModalHidden = function() {
|
||||
$("#document_delete_dialog").on('hidden.bs.modal', function (e) {
|
||||
$("#submit-delete-document").data("element-id", "");
|
||||
});
|
||||
};
|
||||
|
||||
$.documentUploadManager.onClickModal = function() {
|
||||
$("#submit-delete-document").on('click', function(e){
|
||||
|
||||
var $id= $(this).data("element-id");
|
||||
var $this = $("#"+$id);
|
||||
var $parent = $this.parent();
|
||||
$parent.find('a').remove();
|
||||
$parent.append('<div class="loading" ></div>');
|
||||
var $greatParent = $parent.parent();
|
||||
|
||||
$greatParent.append('<div class="loading" ></div>');
|
||||
$greatParent.find('.btn-group').remove();
|
||||
var $url = $this.attr("href");
|
||||
var errorMessage = $this.attr("data-error-message");
|
||||
$.ajax({
|
||||
@@ -90,8 +113,7 @@ $(function($){
|
||||
}
|
||||
}
|
||||
}).done(function(data) {
|
||||
$parent.parents('li').remove();
|
||||
|
||||
$greatParent.remove();
|
||||
$(".document-manager .message").html(
|
||||
data
|
||||
);
|
||||
@@ -100,6 +122,37 @@ $(function($){
|
||||
$( "#js-sort-document").children('li').each(function(position, element) {
|
||||
$(element).find('.js-sorted-position').html(position + 1);
|
||||
});
|
||||
}).always(function() {
|
||||
$('#document_delete_dialog').modal("hide");
|
||||
$("#submit-delete-document").data("element-id", "");
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// toggle document on click
|
||||
$.documentUploadManager.onClickToggleVisibilityDocument = function() {
|
||||
$('.document-manager').on('click', '.document-toggle-btn', function (e) {
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
//$parent.append('<div class="loading" ></div>');
|
||||
var $url = $this.attr("href");
|
||||
var errorMessage = $this.attr("data-error-message");
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: $url,
|
||||
statusCode: {
|
||||
404: function() {
|
||||
$(".document-manager .message").html(
|
||||
errorMessage
|
||||
);
|
||||
}
|
||||
}
|
||||
}).done(function(data) {
|
||||
$(".document-manager .message").html(
|
||||
data
|
||||
);
|
||||
|
||||
$this.toggleClass("visibility-visible");
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user