').addClass('file-item-icon fa ' + item.icon).css('color', item.color);
media.find('.file-manager-col-view').html(icon).removeClass('d-none');
}
if(item.content){
media.find('.media-content-title').val(item.content.title);
media.find('.media-content-description').val(item.content.description);
}
media.find('.media-content-title').parent().removeClass('d-none');
media.find('.media-content-description').parent().removeClass('d-none');
media.find('.media-name').html(item.name);
media.find('.media-url').val(item.url);
media.find('.media-download').attr('target', '_blank').attr('href', item.url);
callback = function () {
performLfmRequest('file-content', {
file: item.name,
content_id: item_content_id,
content_title: media.find('.media-content-title').val(),
content_description: media.find('.media-content-description').val(),
}).done(refreshFoldersAndItems);
};
/* if (item.thumb_url) {
media.find('.carousel-image').css('background-image', 'url(\'' + item.url + '?timestamp=' + item.time + '\')');
} else {
media.find('.carousel-image').css('width', '50vh').append($('
').addClass('mime-icon ico-' + item.icon));
}
media.find('.carousel-label')
.append($('
'));
*/
notify(media, callback);
}
/*function preview(items) {
var carousel = $('#carouselTemplate').clone().attr('id', 'previewCarousel').removeClass('d-none');
var imageTemplate = carousel.find('.carousel-item').clone().removeClass('active');
var indicatorTemplate = carousel.find('.carousel-indicators > li').clone().removeClass('active');
carousel.children('.carousel-inner').html('');
carousel.children('.carousel-indicators').html('');
carousel.children('.carousel-indicators,.carousel-control-prev,.carousel-control-next').toggle(items.length > 1);
items.forEach(function (item, index) {
var carouselItem = imageTemplate.clone()
.addClass(index === 0 ? 'active' : '');
if (item.thumb_url) {
carouselItem.find('.carousel-image').css('background-image', 'url(\'' + item.url + '?timestamp=' + item.time + '\')');
} else {
carouselItem.find('.carousel-image').css('width', '50vh').append($('
').addClass('mime-icon ico-' + item.icon));
}
carouselItem.find('.carousel-label').attr('target', '_blank').attr('href', item.url)
.append(item.name)
.append($(''));
carousel.children('.carousel-inner').append(carouselItem);
var carouselIndicator = indicatorTemplate.clone()
.addClass(index === 0 ? 'active' : '')
.attr('data-slide-to', index);
carousel.children('.carousel-indicators').append(carouselIndicator);
});
// carousel swipe control
var touchStartX = null;
carousel.on('touchstart', function (event) {
var e = event.originalEvent;
if (e.touches.length == 1) {
var touch = e.touches[0];
touchStartX = touch.pageX;
}
}).on('touchmove', function (event) {
var e = event.originalEvent;
if (touchStartX != null) {
var touchCurrentX = e.changedTouches[0].pageX;
if ((touchCurrentX - touchStartX) > 60) {
touchStartX = null;
carousel.carousel('prev');
} else if ((touchStartX - touchCurrentX) > 60) {
touchStartX = null;
carousel.carousel('next');
}
}
}).on('touchend', function () {
touchStartX = null;
});
// end carousel swipe control
notify(carousel);
}*/
/*
function use(items) {
function useTinymce3(url) {
if (!usingTinymce3()) { return; }
var win = tinyMCEPopup.getWindowArg("window");
win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = url;
if (typeof(win.ImageDialog) != "undefined") {
// Update image dimensions
if (win.ImageDialog.getImageData) {
win.ImageDialog.getImageData();
}
// Preview if necessary
if (win.ImageDialog.showPreviewImage) {
win.ImageDialog.showPreviewImage(url);
}
}
tinyMCEPopup.close();
}
function useTinymce4AndColorbox(url) {
if (!usingTinymce4AndColorbox()) { return; }
parent.document.getElementById(getUrlParam('field_name')).value = url;
if(typeof parent.tinyMCE !== "undefined") {
parent.tinyMCE.activeEditor.windowManager.close();
}
if(typeof parent.$.fn.colorbox !== "undefined") {
parent.$.fn.colorbox.close();
}
}
function useCkeditor3(url) {
if (!usingCkeditor3()) { return; }
if (window.opener) {
// Popup
window.opener.CKEDITOR.tools.callFunction(getUrlParam('CKEditorFuncNum'), url);
} else {
// Modal (in iframe)
parent.CKEDITOR.tools.callFunction(getUrlParam('CKEditorFuncNum'), url);
parent.CKEDITOR.tools.callFunction(getUrlParam('CKEditorCleanUpFuncNum'));
}
}
function useFckeditor2(url) {
if (!usingFckeditor2()) { return; }
var p = url;
var w = data['Properties']['Width'];
var h = data['Properties']['Height'];
window.opener.SetUrl(p,w,h);
}
var url = items[0].url;
var callback = getUrlParam('callback');
var useFileSucceeded = true;
if (usingWysiwygEditor()) {
useTinymce3(url);
useTinymce4AndColorbox(url);
useCkeditor3(url);
useFckeditor2(url);
} else if (callback && window[callback]) {
window[callback](getSelectedItems());
} else if (callback && parent[callback]) {
parent[callback](getSelecteditems());
} else if (window.opener) { // standalone button or other situations
window.opener.SetUrl(getSelectedItems());
} else {
useFileSucceeded = false;
}
if (useFileSucceeded) {
if (window.opener) {
window.close();
}
} else {
console.log('window.opener not found');
// No editor found, open/download file using browser's default method
window.open(url);
}
}
//end useFile
// ==================================
// == WYSIWYG Editors Check ==
// ==================================
function usingTinymce3() {
return !!window.tinyMCEPopup;
}
function usingTinymce4AndColorbox() {
return !!getUrlParam('field_name');
}
function usingCkeditor3() {
return !!getUrlParam('CKEditor') || !!getUrlParam('CKEditorCleanUpFuncNum');
}
function usingFckeditor2() {
return window.opener && typeof data != 'undefined' && data['Properties']['Width'] != '';
}
function usingWysiwygEditor() {
return usingTinymce3() || usingTinymce4AndColorbox() || usingCkeditor3() || usingFckeditor2();
}
*/
// ==================================
// == Others ==
// ==================================
function getUrlParam(paramName) {
var reParam = new RegExp('(?:[\?&]|&)' + paramName + '=([^&]+)', 'i');
var match = window.location.search.match(reParam);
return ( match && match.length > 1 ) ? match[1] : null;
}
function defaultParameters() {
return {
working_dir: $('#working_dir').val(),
type: $('#type').val()
};
}
function notImp() {
notify('Not yet implemented!');
}
function notify(body, callback) {
$('#notify').find('.btn-primary').toggle(callback !== undefined);
if(callback !== 'success'){
$('#notify').find('.btn-primary').unbind().click(callback);
}else{
$('#notify').find('.btn-primary').unbind();
}
$('#notify').modal('show').find('.modal-body').html(body);
}
function dialog(title, value, callback) {
$('#dialog').find('input').val(value);
$('#dialog').on('shown.bs.modal', function () {
$('#dialog').find('input').focus();
});
$('#dialog').find('.btn-primary').unbind('click').click(function (e) {
callback($('#dialog').find('input').val());
});
$('#dialog').find('input').unbind('keypress.key13').bind('keypress.key13', function (e) {
if (e.which === 13) {
$('#dialog').find('.btn-primary').click();
}
});
$('#dialog').modal('show').find('.modal-title').text(title);
}