Professional Documents
Culture Documents
If If: Length Referrer
If If: Length Referrer
on('turbolinks:load', function () {
$(document).ready(function () {
setFolerNameAndId(current_folder_name, uploaded_folder_id);
var current_tree_id = "folder_" + uploaded_folder_id;
$("#" + current_tree_id).addClass("folder-mark-up");
openParentNodeFunction(current_tree_id);
}
}
});
$('.choose-folder').click(function show_folder(e) {
$("#myUL").find(".folder-mark-up").removeClass("folder-mark-up");
$(this).addClass("folder-mark-up");
var current_folder_id = parseInt($(this).find(".folder-id").text());
var current_folder_name = $(this).find(".folder-name").text();
$.ajax({
type: "GET",
url: "sub_folder_block",
dataType: "script",
data: { folder_id: current_folder_id },
success: function (data, textStatus, jqXHR) {
console.log("Dynamic group select OK!")
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(jqXHR.responseText)
}
})
$("#btnShowHistory").prop("href", "/folders/" + current_folder_id);
setFolerNameAndId(current_folder_name, current_folder_id);
});
$('.block-folder').click(function show_folder(e) {
$("#myUL").find(".folder-mark-up").removeClass("folder-mark-up");
var current_folder_id = parseInt($(this).find(".folder-id").text());
var current_folder_name = $(this).find(".folder-name").text();
$.ajax({
type: "GET",
url: "sub_folder_block",
dataType: "script",
data: { folder_id: current_folder_id },
success: function (data, textStatus, jqXHR) {
console.log("Dynamic group select OK!")
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(jqXHR.responseText)
}
})
$("#btnShowHistory").prop("href", "/folders/" + current_folder_id);
setFolerNameAndId(current_folder_name, current_folder_id);
var current_tree_id = "folder_" + current_folder_id;
$("#" + current_tree_id).addClass("folder-mark-up");
openParentNodeFunction(current_tree_id);
});
function openParentNodeFunction(param) {
var current_folder = document.getElementById(param);
var parent_li = current_folder.parentNode;
var parent_ul = parent_li.parentNode;
if (parent_ul.className == "myUL") {
return;
}
var parent_node = parent_ul.parentNode;
var parent_caret = null;
var parent_nested = null;
var current_node = null;
for (var i = 0; i < parent_node.childNodes.length; i++) {
if (parent_node.childNodes[i].className == "caret") {
parent_caret = parent_node.childNodes[i];
if (parent_node.childNodes[i].className != "caret-down") {
$(parent_caret).addClass("caret-down");
}
}
if (parent_node.childNodes[i].className == "nested") {
parent_nested = parent_node.childNodes[i];
if (parent_node.childNodes[i].className != "active") {
$(parent_nested).addClass("active");
}
}
if (parent_node.childNodes[i].className == "choose-folder") {
openParentNodeFunction($(parent_node.childNodes[i]).attr('id'));
}
}
}
if ($("#admin-decentralize-link").length > 0) {
var admin_decentralize_href = $("#admin-decentralize-link")[0].href.replace("/folders/" + old_id +
"/admin_decentralize", "/folders/" + id + "/admin_decentralize");
$("#admin-decentralize-link").attr("href", admin_decentralize_href);
}
if ($("#decentralize-link").length > 0) {
var decentralize_href = $("#decentralize-link")[0].href.replace("/folders/" + old_id + "/decentralize", "/folders/" +
id + "/decentralize");
$("#decentralize-link").attr("href", decentralize_href);
}
}
$("#btn-download-file").click(function () {
var id;
var lst_selected = [];
var folder_id = $("#current-folder-id").val();
$.each($('.tbl-file tbody tr'), function (i, row) {
var checkBox = $(row).find("input[type='checkbox']:checked").is(":checked");
if (checkBox) {
id = row.cells[1].innerHTML;
lst_selected.push(id);
// lst_selected = parseInt($("input[type='checkbox']:checked")[0].value);
return;
}
});
if (lst_selected.length == 0) return;
window.$("#loadMe").modal({
backdrop: "static", //remove ability to close modal with click
keyboard: false, //remove option to close with keyboard
show: true //Display loader!
});
window.location = 'download_multiple_file?files=' + lst_selected + '&folder_id=' + folder_id;
// $.ajax({
// type: 'GET',
// url: "download_multiple_file",
// dataType: 'script',
// data: {
// files: lst_selected,
// folder_id: folder_id,
// },
// success: function(data, textStatus, jqXHR){
// window.$("#loadMe").modal('hide');
// // console.log(data);
// console.log("Dynamic group select OK!")
// },
// error:function(jqXHR, textStatus, errorThrown){
// window.$("#loadMe").modal('hide');
// console.log("AJAX Error: #{textStatus}")
// }
// });
});
$("#btn-delete-file").click(function () {
var id;
var lst_selected = [];
var folder_id = $("#current-folder-id").val();
$.each($('.tbl-file tbody tr'), function (i, row) {
var checkBox = $(row).find("input[type='checkbox']:checked").is(":checked");
if (checkBox) {
id = row.cells[1].innerHTML;
lst_selected.push(id);
// lst_selected = parseInt($("input[type='checkbox']:checked")[0].value);
return;
}
});
if (lst_selected.length == 0) return;
$.ajax({
type: 'GET',
url: "confirm_delete",
dataType: 'script',
data: {
files: lst_selected,
folder_id: folder_id
},
success: function (data, textStatus, jqXHR) {
window.$("#loadMe").modal('hide');
// console.log(data);
console.log("Dynamic group select OK!")
},
error: function (jqXHR, textStatus, errorThrown) {
window.$("#loadMe").modal('hide');
console.log("AJAX Error: #{textStatus}")
}
});
});
//for admin
$("body").delegate('#add_partner', 'click', function () {
var lst_group_select = document.getElementById('not-decentralized-group');
var lst_group_selected = document.getElementById('tbl-lst-group-selected');
moveItemSelectTagToTable(lst_group_select, lst_group_selected);
});
//for user
$("body").delegate('#add-decentralized-department', 'click', function () {
var lst_department_select = document.getElementById('not-decentralized-department');
var lst_department_selected = document.getElementById('tbl-lst-group-selected');
moveItemSelectTagToTable(lst_department_select, lst_department_selected);
});