Booking, QI Content, Trees, Media
This commit is contained in:
parent
1f340e96fa
commit
7fbac395a9
260 changed files with 27160 additions and 3773 deletions
766
public/js/filemanager.js
Normal file
766
public/js/filemanager.js
Normal file
|
|
@ -0,0 +1,766 @@
|
|||
|
||||
var lfm_route = location.origin + '/laravel-filemanager';
|
||||
var lfm_show_list;
|
||||
var lfm_sort_type = 'alphabetic';
|
||||
var lfm_selected = [];
|
||||
var lfm_items = [];
|
||||
var lfm_content = '#file-manager-content';
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
/*
|
||||
|
||||
actions.reverse().forEach(function (action) {
|
||||
$('#nav-buttons > ul').prepend(
|
||||
$('<li>').addClass('nav-item').append(
|
||||
$('<a>').addClass('nav-link d-none')
|
||||
.attr('data-action', action.name)
|
||||
.attr('data-multiple', action.multiple)
|
||||
.append($('<i>').addClass('fas fa-fw fa-' + action.icon))
|
||||
.append($('<span>').text(action.label))
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
sortings.forEach(function (sort) {
|
||||
$('#nav-buttons .dropdown-menu').append(
|
||||
$('<a>').addClass('dropdown-item').attr('data-sortby', sort.by)
|
||||
.append($('<i>').addClass('fas fa-fw fa-' + sort.icon))
|
||||
.append($('<span>').text(sort.label))
|
||||
.click(function() {
|
||||
sort_type = sort.by;
|
||||
loadItems();
|
||||
})
|
||||
);
|
||||
});
|
||||
*/
|
||||
|
||||
if($(lfm_content).length) {
|
||||
loadItems();
|
||||
performLfmRequest('errors')
|
||||
.done(function (response) {
|
||||
JSON.parse(response).forEach(function (message) {
|
||||
$('#alerts').append(
|
||||
$('<div>').addClass('alert alert-warning')
|
||||
.append($('<i>').addClass('fas fa-exclamation-circle'))
|
||||
.append(' ' + message)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
$(lfm_content).on('dragenter', function () {
|
||||
$('#uploadModal').modal('show');
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
/* if (usingWysiwygEditor()) {
|
||||
$('#multi_selection_toggle').hide();
|
||||
}*/
|
||||
});
|
||||
|
||||
// ======================
|
||||
// == Navbar actions ==
|
||||
// ======================
|
||||
/*
|
||||
$('#multi_selection_toggle').click(function () {
|
||||
multi_selection_enabled = !multi_selection_enabled;
|
||||
|
||||
$('#multi_selection_toggle i')
|
||||
.toggleClass('fa-times', multi_selection_enabled)
|
||||
.toggleClass('fa-check-double', !multi_selection_enabled);
|
||||
|
||||
if (!multi_selection_enabled) {
|
||||
clearSelected();
|
||||
}
|
||||
});
|
||||
|
||||
*/
|
||||
|
||||
|
||||
$(document).on('click', '#lfm_add-folder', function () {
|
||||
dialog(lang['message-name'], '', createFolder);
|
||||
});
|
||||
|
||||
$(document).on('click', '#lfm_upload', function () {
|
||||
$('#uploadModal').modal('show');
|
||||
});
|
||||
/*
|
||||
$(document).on('click', '[data-display]', function() {
|
||||
show_list = $(this).data('display');
|
||||
loadItems();
|
||||
});
|
||||
|
||||
$(document).on('click', '[data-action]', function() {
|
||||
window[$(this).data('action')]($(this).data('multiple') ? getSelectedItems() : getOneSelectedElement());
|
||||
});
|
||||
|
||||
// ==========================
|
||||
// == Multiple Selection ==
|
||||
// ==========================
|
||||
*/
|
||||
|
||||
/*
|
||||
function clearSelected () {
|
||||
selected = [];
|
||||
|
||||
multi_selection_enabled = false;
|
||||
|
||||
updateSelectedStyle();
|
||||
}
|
||||
|
||||
function updateSelectedStyle() {
|
||||
items.forEach(function (item, index) {
|
||||
$('[data-id=' + index + ']')
|
||||
.find('.square')
|
||||
.toggleClass('selected', selected.indexOf(index) > -1);
|
||||
});
|
||||
toggleActions();
|
||||
}
|
||||
|
||||
function getOneSelectedElement(orderOfItem) {
|
||||
var index = orderOfItem !== undefined ? orderOfItem : selected[0];
|
||||
return items[index];
|
||||
}
|
||||
function getSelectedItems() {
|
||||
return selected.reduce(function (arr_objects, id) {
|
||||
arr_objects.push(getOneSelectedElement(id));
|
||||
return arr_objects
|
||||
}, []);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
function getSelectedItems() {
|
||||
var items = [];
|
||||
|
||||
$('input.lfm-control-input').each(function () {
|
||||
if($(this).prop('checked')){
|
||||
items.push(getOneSelectedElement($(this).parents('.file-item').data('id')));
|
||||
}
|
||||
});
|
||||
return items;
|
||||
}
|
||||
|
||||
function hasSelectedItems() {
|
||||
$('input.lfm-control-input').each(function () {
|
||||
console.log($(this).prop('checked'));
|
||||
if($(this).prop('checked')){
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function getOneSelectedElement(orderOfItem) {
|
||||
var index = orderOfItem !== undefined ? orderOfItem : lfm_selected[0];
|
||||
return lfm_items[index];
|
||||
}
|
||||
|
||||
function toggleActions() {
|
||||
|
||||
$('a[data-action=item_rename]').on('click', function () {
|
||||
item = getOneSelectedElement($(this).parents('.file-item').data('id'));
|
||||
rename(item);
|
||||
});
|
||||
|
||||
$('a[data-action=item_move]').on('click', function () {
|
||||
var items = [];
|
||||
items.push(getOneSelectedElement($(this).parents('.file-item').data('id')));
|
||||
move(items);
|
||||
});
|
||||
|
||||
|
||||
$('a[data-action=item_trash]').on('click', function () {
|
||||
var items = [];
|
||||
items.push(getOneSelectedElement($(this).parents('.file-item').data('id')));
|
||||
trash(items);
|
||||
});
|
||||
|
||||
$('a[data-action=item_download]').on('click', function () {
|
||||
var items = [];
|
||||
items.push(getOneSelectedElement($(this).parents('.file-item').data('id')));
|
||||
download(items);
|
||||
});
|
||||
|
||||
|
||||
|
||||
$('a[data-action=selected_items_move]').on('click', function () {
|
||||
var items = getSelectedItems();
|
||||
move(items);
|
||||
});
|
||||
|
||||
$('a[data-action=selected_items_remove]').on('click', function () {
|
||||
var items = getSelectedItems();
|
||||
trash(items);
|
||||
});
|
||||
|
||||
$('a[data-action=selected_items_download]').on('click', function () {
|
||||
var items = getSelectedItems();
|
||||
download(items);
|
||||
});
|
||||
|
||||
|
||||
/* var one_selected = selected.length === 1;
|
||||
var many_selected = selected.length >= 1;
|
||||
var only_image = getSelectedItems()
|
||||
.filter(function (item) { return !item.is_image; })
|
||||
.length === 0;
|
||||
var only_file = getSelectedItems()
|
||||
.filter(function (item) { return !item.is_file; })
|
||||
.length === 0;
|
||||
|
||||
$('[data-action=use]').toggleClass('d-none', !(many_selected && only_file));
|
||||
$('[data-action=rename]').toggleClass('d-none', !one_selected);
|
||||
$('[data-action=preview]').toggleClass('d-none', !(many_selected && only_file));
|
||||
$('[data-action=move]').toggleClass('d-none', !many_selected);
|
||||
$('[data-action=download]').toggleClass('d-none', !(many_selected && only_file));
|
||||
$('[data-action=resize]').toggleClass('d-none', !(one_selected && only_image));
|
||||
$('[data-action=crop]').toggleClass('d-none', !(one_selected && only_image));
|
||||
$('[data-action=trash]').toggleClass('d-none', !many_selected);
|
||||
$('[data-action=open]').toggleClass('d-none', !one_selected || only_file);
|
||||
$('#multi_selection_toggle').toggleClass('d-none', usingWysiwygEditor() || !many_selected);
|
||||
$('#actions').toggleClass('d-none', selected.length === 0);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ======================
|
||||
// == Folder actions ==
|
||||
// ======================
|
||||
|
||||
|
||||
|
||||
function goTo(new_dir) {
|
||||
$('#working_dir').val(new_dir);
|
||||
loadItems();
|
||||
}
|
||||
|
||||
function getPreviousDir() {
|
||||
var working_dir = $('#working_dir').val();
|
||||
return working_dir.substring(0, working_dir.lastIndexOf('/'));
|
||||
}
|
||||
|
||||
|
||||
// ====================
|
||||
// == Ajax actions ==
|
||||
// ====================
|
||||
|
||||
function performLfmRequest(url, parameter, type) {
|
||||
var data = defaultParameters();
|
||||
if (parameter != null) {
|
||||
$.each(parameter, function (key, value) {
|
||||
data[key] = value;
|
||||
});
|
||||
}return $.ajax({
|
||||
type: 'GET',
|
||||
beforeSend: function(request) {
|
||||
var token = getUrlParam('token');
|
||||
if (token !== null) {
|
||||
request.setRequestHeader("Authorization", 'Bearer ' + token);
|
||||
}
|
||||
},
|
||||
dataType: type || 'text',
|
||||
url: lfm_route + '/' + url,
|
||||
data: data,
|
||||
cache: false
|
||||
}).done(function (data) {
|
||||
console.log(data);
|
||||
/* if(data !== "OK"){
|
||||
var response = JSON.parse(data);
|
||||
console.log("done");
|
||||
console.log(response);
|
||||
if(response.type === "error"){
|
||||
$.growl({
|
||||
title: "Error",
|
||||
message: response.data,
|
||||
location: 'tr'
|
||||
});
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}).fail(function (jqXHR, textStatus, errorThrown) {
|
||||
console.log(jqXHR);
|
||||
console.log(textStatus);
|
||||
console.log(errorThrown);
|
||||
displayErrorResponse(jqXHR);
|
||||
});
|
||||
}
|
||||
|
||||
function displayErrorResponse(jqXHR) {
|
||||
notify('<div style="max-height:50vh;overflow: scroll;">' + jqXHR.responseText + '</div>');
|
||||
};
|
||||
|
||||
function isJSON(text) {
|
||||
if (typeof text!=="string"){
|
||||
return false;
|
||||
}
|
||||
try{
|
||||
JSON.parse(text);
|
||||
return true;
|
||||
}
|
||||
catch (error){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var refreshFoldersAndItems = function (data) {
|
||||
loadItems();
|
||||
if(isJSON(data)){
|
||||
var response = JSON.parse(data);
|
||||
console.log("done");
|
||||
console.log(response);
|
||||
if(response.type === "error"){
|
||||
$.growl({
|
||||
title: "Error",
|
||||
message: response.data,
|
||||
location: 'tr'
|
||||
});
|
||||
}
|
||||
}else{
|
||||
if(data != 'OK') {
|
||||
data = Array.isArray(data) ? data.join('<br/>') : data;
|
||||
notify(data);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
var hideNavAndShowEditor = function (data) {
|
||||
$('#nav-buttons > ul').addClass('d-none');
|
||||
$(lfm_content).html(data).removeClass('preserve_actions_space');
|
||||
clearSelected();
|
||||
};
|
||||
|
||||
function loadItems() {
|
||||
loading(true);
|
||||
performLfmRequest('jsonitems', {show_list: lfm_show_list, sort_type: lfm_sort_type}, 'html')
|
||||
.done(function (data) {
|
||||
//console.log(data);
|
||||
lfm_selected = [];
|
||||
var response = JSON.parse(data);
|
||||
var working_dir = response.working_dir;
|
||||
lfm_items = response.items;
|
||||
var hasItems = lfm_items.length !== 0;
|
||||
$('#lfm_empty').toggleClass('d-none', hasItems);
|
||||
|
||||
//$(lfm_content).html(''); //.removeAttr('class');
|
||||
|
||||
var toprev = $('<div class="file-item" id="to-previous"><div class="file-item-icon file-item-level-up fas fa-level-up-alt text-secondary"></div><a href="javascript:void(0)" class="file-item-name">zurück</a></div>');
|
||||
$(lfm_content).html('').append(toprev);
|
||||
|
||||
if (hasItems) {
|
||||
|
||||
$(lfm_content).addClass(response.display).addClass('preserve_actions_space');
|
||||
|
||||
lfm_items.forEach(function (item, index) {
|
||||
var template = $('#lfm_item-template').clone()
|
||||
.removeAttr('id').removeClass('d-none')
|
||||
.attr('data-id', index)
|
||||
//.click(toggleSelected)
|
||||
.click(function (e) {
|
||||
if(!$(e.target).hasClass('lfm-click-disable') && !$(e.target).hasClass('dropdown-item')){
|
||||
if (item.is_file) {
|
||||
if($(e.target).hasClass('file-item-img') || $(e.target).hasClass('file-item-icon')){
|
||||
preview_item(item);
|
||||
}else{
|
||||
if($(this).hasClass('file-item')){
|
||||
$(this).find('.lfm-control-input').click();
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
goTo(item.url);
|
||||
}
|
||||
}
|
||||
if($(e.target).hasClass('lfm-control-input')){
|
||||
if(getSelectedItems().length > 0){
|
||||
if($('.media-multi-settings').hasClass('d-none')){
|
||||
$('.media-multi-settings').removeClass('d-none');
|
||||
}
|
||||
}else{
|
||||
if(!$('.media-multi-settings').hasClass('d-none')){
|
||||
$('.media-multi-settings').addClass('d-none');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (item.thumb_url) {
|
||||
var image = $('<div>').addClass('file-item-img').css('background-image', 'url("' + item.thumb_url + '?timestamp=' + item.time + '")');
|
||||
} else {
|
||||
var image = $('<div>').addClass('file-item-icon text-secondary fa ' + item.icon);
|
||||
}
|
||||
template.find('.file-item-name').before(image);
|
||||
template.find('.file-item-name').text(item.name);
|
||||
template.find('file-item-changed').text((new Date(item.time * 1000)).toLocaleString());
|
||||
$(lfm_content).append(template);
|
||||
});
|
||||
}
|
||||
|
||||
//$('#nav-buttons > ul').removeClass('d-none');
|
||||
|
||||
$('#working_dir').val(working_dir);
|
||||
console.log('Current working_dir : ' + working_dir);
|
||||
var breadcrumbs = [];
|
||||
var validSegments = working_dir.split('/').filter(function (e) { return e; });
|
||||
validSegments.forEach(function (segment, index) {
|
||||
if (index === 0) {
|
||||
// set root folder name as the first breadcrumb
|
||||
breadcrumbs.push("Medien");
|
||||
//breadcrumbs.push($("[data-path='/" + segment + "']").text());
|
||||
} else {
|
||||
breadcrumbs.push(segment);
|
||||
}
|
||||
});
|
||||
|
||||
$('#current_folder').text(breadcrumbs[breadcrumbs.length - 1]);
|
||||
$('#lfm_breadcrumbs > ol').html('');
|
||||
breadcrumbs.forEach(function (breadcrumb, index) {
|
||||
var li = $('<li>').addClass('breadcrumb-item').text(breadcrumb);
|
||||
|
||||
if (index === breadcrumbs.length - 1) {
|
||||
li.addClass('active').attr('aria-current', 'page');
|
||||
} else {
|
||||
li.click(function () {
|
||||
// go to corresponding path
|
||||
goTo('/' + validSegments.slice(0, 1 + index).join('/'));
|
||||
});
|
||||
}
|
||||
|
||||
$('#lfm_breadcrumbs > ol').append(li);
|
||||
});
|
||||
var atRootFolder = getPreviousDir() == '';
|
||||
$('#to-previous').toggleClass('d-none', atRootFolder);
|
||||
$('#to-previous').click(function () {
|
||||
var previous_dir = getPreviousDir();
|
||||
if (previous_dir == '') return;
|
||||
goTo(previous_dir);
|
||||
});
|
||||
|
||||
loading(false);
|
||||
toggleActions();
|
||||
});
|
||||
}
|
||||
|
||||
function loading(show_loading) {
|
||||
$('#lfm_loading').toggleClass('d-none', !show_loading);
|
||||
}
|
||||
|
||||
function createFolder(folder_name) {
|
||||
performLfmRequest('newfolder', {name: folder_name})
|
||||
.done(refreshFoldersAndItems);
|
||||
}
|
||||
|
||||
|
||||
// ==================================
|
||||
// == File Actions ==
|
||||
// ==================================
|
||||
|
||||
function rename(item) {
|
||||
dialog(lang['message-rename'], item.name, function (new_name) {
|
||||
performLfmRequest('rename', {
|
||||
file: item.name,
|
||||
new_name: new_name
|
||||
}).done(refreshFoldersAndItems);
|
||||
});
|
||||
}
|
||||
|
||||
function trash(items) {
|
||||
notify(lang['message-delete'], function () {
|
||||
var d = performLfmRequest('delete', {
|
||||
items: items.map(function (item) { return item.name; })
|
||||
}).done(refreshFoldersAndItems);
|
||||
// console.log(d);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function crop(item) {
|
||||
performLfmRequest('crop', {img: item.name})
|
||||
.done(hideNavAndShowEditor);
|
||||
}
|
||||
|
||||
function resize(item) {
|
||||
performLfmRequest('resize', {img: item.name})
|
||||
.done(hideNavAndShowEditor);
|
||||
}
|
||||
|
||||
function move(items) {
|
||||
performLfmRequest('move', { items: items.map(function (item) { return item.name; }) })
|
||||
.done(refreshFoldersAndItems);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function download(items) {
|
||||
items.forEach(function (item, index) {
|
||||
var data = defaultParameters();
|
||||
|
||||
data['file'] = item.name;
|
||||
|
||||
var token = getUrlParam('token');
|
||||
if (token) {
|
||||
data['token'] = token;
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
location.href = lfm_route + '/download?' + $.param(data);
|
||||
}, index * 100);
|
||||
});
|
||||
}
|
||||
|
||||
function open(item) {
|
||||
goTo(item.url);
|
||||
}
|
||||
|
||||
function preview_item(item) {
|
||||
//var items = [];
|
||||
//items.push(item);
|
||||
preview(item);
|
||||
}
|
||||
|
||||
function preview(item) {
|
||||
var media = $('#previewTemplate').clone().attr('id', 'previewMedia').removeClass('d-none');
|
||||
|
||||
|
||||
media.find('.media-preview').attr('src', item.url + '?timestamp=' + item.time);
|
||||
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);
|
||||
|
||||
/* 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($('<div>').addClass('mime-icon ico-' + item.icon));
|
||||
}
|
||||
|
||||
media.find('.carousel-label')
|
||||
|
||||
.append($('<i class="fas fa-external-link-alt ml-2"></i>'));
|
||||
*/
|
||||
|
||||
|
||||
|
||||
notify(media);
|
||||
}
|
||||
|
||||
/*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($('<div>').addClass('mime-icon ico-' + item.icon));
|
||||
}
|
||||
|
||||
carouselItem.find('.carousel-label').attr('target', '_blank').attr('href', item.url)
|
||||
.append(item.name)
|
||||
.append($('<i class="fas fa-external-link-alt ml-2"></i>'));
|
||||
|
||||
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);
|
||||
$('#notify').find('.btn-primary').unbind().click(callback);
|
||||
$('#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(function (e) {
|
||||
callback($('#dialog').find('input').val());
|
||||
});
|
||||
$('#dialog').modal('show').find('.modal-title').text(title);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue