updated elysia_cron, elfinder, metatag, libraries, email_registration, migrate, nodeform_cols
This commit is contained in:
@@ -1,239 +1,414 @@
|
||||
/*
|
||||
* elFinder Integration
|
||||
*
|
||||
* Copyright (c) 2010-2018, Alexey Sukhotin. All rights reserved.
|
||||
*/
|
||||
|
||||
// $Id: elfinder.callback.js 106 2011-02-26 08:19:56Z ph0enix $
|
||||
|
||||
(function($) {
|
||||
|
||||
/**
|
||||
* @class elFinder command "search"
|
||||
* Find files
|
||||
*
|
||||
* @author Dmitry (dio) Levashov
|
||||
**/
|
||||
elFinder.prototype.commands.search = function() {
|
||||
this.title = 'Find files';
|
||||
this.options = {ui : 'searchbutton'}
|
||||
this.alwaysEnabled = true;
|
||||
this.updateOnSelect = false;
|
||||
|
||||
/**
|
||||
* Return command status.
|
||||
* Search does not support old api.
|
||||
*
|
||||
* @return Number
|
||||
**/
|
||||
this.getstate = function() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send search request to backend.
|
||||
*
|
||||
* @param String search string
|
||||
* @return $.Deferred
|
||||
**/
|
||||
this.exec = function(q) {
|
||||
var fm = this.fm;
|
||||
|
||||
if (typeof(q) == 'string' && q) {
|
||||
return fm.request({
|
||||
data : {cmd : 'search', elfinder_search_q : q},
|
||||
notify : {type : 'search', cnt : 1, hideCnt : true}
|
||||
});
|
||||
}
|
||||
fm.getUI('toolbar').find('.'+fm.res('class', 'searchbtn')+' :text').focus();
|
||||
return $.Deferred().reject();
|
||||
}
|
||||
/**
|
||||
* @class elFinder command "search"
|
||||
* Find files
|
||||
*
|
||||
* @author Dmitry (dio) Levashov
|
||||
**/
|
||||
elFinder.prototype.commands.search = function() {
|
||||
this.title = 'Find files';
|
||||
this.options = {ui: 'searchbutton'}
|
||||
this.alwaysEnabled = true;
|
||||
this.updateOnSelect = false;
|
||||
|
||||
}
|
||||
/**
|
||||
* Return command status.
|
||||
* Search does not support old api.
|
||||
*
|
||||
* @return Number
|
||||
**/
|
||||
this.getstate = function() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
elFinder.prototype.commands.test134 = function() {
|
||||
this.title = 'Test Command';
|
||||
//this.options = {ui : 'uploadbutton'}
|
||||
this.alwaysEnabled = true;
|
||||
this.updateOnSelect = false;
|
||||
this.state = 0;
|
||||
|
||||
this.getstate = function() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send search request to backend.
|
||||
*
|
||||
* @param String search string
|
||||
* @return $.Deferred
|
||||
**/
|
||||
this.exec = function(q) {
|
||||
var fm = this.fm;
|
||||
|
||||
alert(Drupal.t('test command. arg=') + q);
|
||||
|
||||
return $.Deferred().reject();
|
||||
}
|
||||
/**
|
||||
* Send search request to backend.
|
||||
*
|
||||
* @param String search string
|
||||
* @return $.Deferred
|
||||
**/
|
||||
this.exec = function(q) {
|
||||
var fm = this.fm;
|
||||
|
||||
}
|
||||
if (typeof(q) == 'string' && q) {
|
||||
return fm.request({
|
||||
data: {cmd: 'search', elfinder_search_q: q},
|
||||
notify: {type: 'search', cnt: 1, hideCnt: true}
|
||||
});
|
||||
}
|
||||
fm.getUI('toolbar').find('.' + fm.res('class', 'searchbtn') + ' :text').focus();
|
||||
return $.Deferred().reject();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
elFinder.prototype.commands.test134 = function() {
|
||||
this.title = 'Test Command';
|
||||
//this.options = {ui : 'uploadbutton'}
|
||||
this.alwaysEnabled = true;
|
||||
this.updateOnSelect = false;
|
||||
this.state = 0;
|
||||
|
||||
this.getstate = function() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send search request to backend.
|
||||
*
|
||||
* @param String search string
|
||||
* @return $.Deferred
|
||||
**/
|
||||
this.exec = function(q) {
|
||||
var fm = this.fm;
|
||||
|
||||
alert(Drupal.t('test command. arg=') + q);
|
||||
|
||||
return $.Deferred().reject();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$().ready(function() {
|
||||
var uiopts = elFinder.prototype._options.uiOptions.toolbar;
|
||||
$().ready(function() {
|
||||
var uiopts = elFinder.prototype._options.uiOptions.toolbar;
|
||||
|
||||
var newOpts = new Array();
|
||||
var newOpts = new Array();
|
||||
|
||||
var disabledCommands = Drupal.settings.elfinder.disabledCommands;
|
||||
|
||||
|
||||
for (var i in uiopts) {
|
||||
var optsGroup = uiopts[i];
|
||||
var newOptsGroup = Array();
|
||||
var disabledCommands = Drupal.settings.elfinder.disabledCommands;
|
||||
|
||||
for (var j in optsGroup) {
|
||||
|
||||
for (var i in uiopts) {
|
||||
var optsGroup = uiopts[i];
|
||||
var newOptsGroup = Array();
|
||||
|
||||
|
||||
for (var j in optsGroup) {
|
||||
var found = false;
|
||||
for (var k in disabledCommands) {
|
||||
if (disabledCommands[k] == optsGroup[j]) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (found == false) {
|
||||
newOptsGroup.push(optsGroup[j]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
newOptsGroup.push('up');
|
||||
}
|
||||
|
||||
if (newOptsGroup.length >= 1) {
|
||||
newOpts.push(newOptsGroup);
|
||||
}
|
||||
}
|
||||
|
||||
/*elFinder.prototype._options.contextmenu.files.push('|');
|
||||
elFinder.prototype._options.contextmenu.files.push('rename'); */
|
||||
|
||||
var contextMenuCwd = elFinder.prototype._options.contextmenu.cwd;
|
||||
var contextMenuFiles = elFinder.prototype._options.contextmenu.files;
|
||||
var contextMenuNavbar = elFinder.prototype._options.contextmenu.navbar;
|
||||
|
||||
var newContextMenuCwd = Array();
|
||||
var newContextMenuFiles = Array();
|
||||
var newContextMenuNavbar = Array();
|
||||
|
||||
for (var i in contextMenuCwd) {
|
||||
var found = false;
|
||||
for (var k in disabledCommands) {
|
||||
if (disabledCommands[k] == optsGroup[j]) {
|
||||
if (disabledCommands[k] == contextMenuCwd[i]) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (found == false) {
|
||||
newOptsGroup.push(optsGroup[j]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
newOptsGroup.push('up');
|
||||
}
|
||||
|
||||
if (newOptsGroup.length >= 1) {
|
||||
newOpts.push(newOptsGroup);
|
||||
}
|
||||
}
|
||||
|
||||
var contextMenuCwd = elFinder.prototype._options.contextmenu.cwd;
|
||||
var contextMenuFiles = elFinder.prototype._options.contextmenu.files;
|
||||
var contextMenuNavbar = elFinder.prototype._options.contextmenu.navbar;
|
||||
|
||||
var newContextMenuCwd = Array();
|
||||
var newContextMenuFiles = Array();
|
||||
var newContextMenuNavbar = Array();
|
||||
|
||||
for (var i in contextMenuCwd) {
|
||||
var found = false;
|
||||
for (var k in disabledCommands) {
|
||||
if (disabledCommands[k] == contextMenuCwd[i]) {
|
||||
found = true;
|
||||
|
||||
if (found == false && contextMenuCwd[i] != '|') {
|
||||
newContextMenuCwd.push(contextMenuCwd[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (found == false && contextMenuCwd[i] != '|') {
|
||||
newContextMenuCwd.push(contextMenuCwd[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i in contextMenuFiles) {
|
||||
var found = false;
|
||||
for (var k in disabledCommands) {
|
||||
if (disabledCommands[k] == contextMenuFiles[i]) {
|
||||
found = true;
|
||||
|
||||
for (var i in contextMenuFiles) {
|
||||
var found = false;
|
||||
for (var k in disabledCommands) {
|
||||
if (disabledCommands[k] == contextMenuFiles[i]) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (found == false && contextMenuFiles[i] != '|') {
|
||||
newContextMenuFiles.push(contextMenuFiles[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (found == false && contextMenuFiles[i] != '|') {
|
||||
newContextMenuFiles.push(contextMenuFiles[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i in contextMenuNavbar) {
|
||||
var found = false;
|
||||
for (var k in disabledCommands) {
|
||||
if (disabledCommands[k] == contextMenuNavbar[i]) {
|
||||
found = true;
|
||||
|
||||
for (var i in contextMenuNavbar) {
|
||||
var found = false;
|
||||
for (var k in disabledCommands) {
|
||||
if (disabledCommands[k] == contextMenuNavbar[i]) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (found == false && contextMenuNavbar[i] != '|') {
|
||||
newContextMenuNavbar.push(contextMenuNavbar[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (found == false && contextMenuNavbar[i] != '|') {
|
||||
newContextMenuNavbar.push(contextMenuNavbar[i]);
|
||||
}
|
||||
}
|
||||
elFinder.prototype._options.uiOptions.toolbar = newOpts;
|
||||
elFinder.prototype._options.contextmenu.cwd = newContextMenuCwd;
|
||||
elFinder.prototype._options.contextmenu.files = newContextMenuFiles;
|
||||
elFinder.prototype._options.contextmenu.navbar = newContextMenuNavbar;
|
||||
elFinder.prototype._options.uiOptions.toolbar = newOpts;
|
||||
elFinder.prototype._options.contextmenu.cwd = newContextMenuCwd;
|
||||
elFinder.prototype._options.contextmenu.files = newContextMenuFiles;
|
||||
elFinder.prototype._options.contextmenu.navbar = newContextMenuNavbar;
|
||||
|
||||
});
|
||||
//elFinder.prototype._options.ui.push('mouseover');
|
||||
});
|
||||
|
||||
|
||||
$().ready(function() {
|
||||
if (Drupal.settings.elfinder) {
|
||||
var editorApp = Drupal.settings.elfinder.editorApp;
|
||||
|
||||
$().ready(function() {
|
||||
if (Drupal.settings.elfinder) {
|
||||
var editorApp = Drupal.settings.elfinder.editorApp;
|
||||
var elfinderOpts = {
|
||||
url: Drupal.settings.elfinder.connectorUrl,
|
||||
lang: Drupal.settings.elfinder.langCode,
|
||||
rememberLastDir: Drupal.settings.elfinder.rememberLastDir,
|
||||
closeOnEditorCallback: false,
|
||||
customData: {token: Drupal.settings.elfinder.token},
|
||||
commandsOptions_: {}
|
||||
}
|
||||
|
||||
var elfinderOpts = {
|
||||
url : Drupal.settings.elfinder.connectorUrl,
|
||||
lang : Drupal.settings.elfinder.langCode,
|
||||
rememberLastDir : Drupal.settings.elfinder.rememberLastDir,
|
||||
closeOnEditorCallback : false,
|
||||
customData : {token: Drupal.settings.elfinder.token}
|
||||
}
|
||||
|
||||
/* Pushing all settings to elFinder */
|
||||
$.extend(elfinderOpts, Drupal.settings.elfinder);
|
||||
|
||||
if (editorApp && typeof window[Drupal.settings.elfinder.editorCallback] == 'function') {
|
||||
elfinderOpts.editorCallback = window[Drupal.settings.elfinder.editorCallback];
|
||||
}
|
||||
// help tab rendering issues in admin theme
|
||||
if (Drupal.settings.elfinder.browserMode != 'default' && elFinder.prototype._options.commandsOptions.help) {
|
||||
final_options = [];
|
||||
|
||||
if (editorApp && typeof window[Drupal.settings.elfinder.editorCallback] == 'function') {
|
||||
elfinderOpts.getFileCallback = window[Drupal.settings.elfinder.editorCallback];
|
||||
}
|
||||
|
||||
if (elfinderOpts.api21) {
|
||||
//alert('api21');
|
||||
for (var i in elFinder.prototype._options.commandsOptions.help.view) {
|
||||
var option = elFinder.prototype._options.commandsOptions.help.view[i];
|
||||
if (option != 'help') {
|
||||
final_options.push(option);
|
||||
}
|
||||
}
|
||||
|
||||
elFinder.prototype._options.commandsOptions.help['view'] = final_options;
|
||||
}
|
||||
|
||||
/* Pushing all settings to elFinder */
|
||||
$.extend(elfinderOpts, Drupal.settings.elfinder);
|
||||
|
||||
if (editorApp && typeof window[Drupal.settings.elfinder.editorCallback] == 'function') {
|
||||
elfinderOpts.editorCallback = window[Drupal.settings.elfinder.editorCallback];
|
||||
}
|
||||
|
||||
if (editorApp && typeof window[Drupal.settings.elfinder.editorCallback] == 'function') {
|
||||
elfinderOpts.getFileCallback = window[Drupal.settings.elfinder.editorCallback];
|
||||
}
|
||||
|
||||
if (elfinderOpts.api21) {
|
||||
console.log('2.1 api');
|
||||
elfinderOpts['commandsOptions'] = {
|
||||
info: {
|
||||
// Key is the same as your command name
|
||||
desc : {
|
||||
// Field label
|
||||
label : 'Description1',
|
||||
|
||||
// HTML Template
|
||||
tpl : '<div class="elfinder-info-desc"><span class="elfinder-info-spinner"></span></div>',
|
||||
|
||||
// Action that sends the request to the server and get the description
|
||||
action : function(file, filemanager, dialog) {
|
||||
// Use the @filemanager object to issue a request
|
||||
filemanager.request({
|
||||
// Issuing the custom 'desc' command, targetting the selected file
|
||||
data : { cmd: 'desc', target: file.hash, },
|
||||
preventDefault: true,
|
||||
})
|
||||
// If the request fails, populate the field with 'Unknown'
|
||||
.fail(function() {
|
||||
dialog.find('.elfinder-info-desc').html(filemanager.i18n('unknown'));
|
||||
})
|
||||
// When the request is successful, show the description
|
||||
.done(function(data) {
|
||||
dialog.find('.elfinder-info-desc').html(data.desc);
|
||||
});
|
||||
},
|
||||
},
|
||||
elfinderOpts['commandsOptions']['info'] = {
|
||||
custom: {}
|
||||
|
||||
};
|
||||
|
||||
/* elfinderOpts['commandsOptions']['quicklook'] = {
|
||||
officeOnlineMimes : ['application/msword', 'application/vnd.ms-word', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
|
||||
}*/
|
||||
|
||||
var disabledCommands = Drupal.settings.elfinder.disabledCommands,
|
||||
viewDesc = $.inArray('desc', disabledCommands) == -1 ? true : false,
|
||||
editDesc = $.inArray('editdesc', disabledCommands) == -1 ? true : false,
|
||||
viewOwner = $.inArray('owner', disabledCommands) == -1 ? true : false,
|
||||
viewDownloads = $.inArray('downloadcount', disabledCommands) == -1 ? true : false;
|
||||
|
||||
|
||||
if (viewDesc || editDesc) {
|
||||
|
||||
// Key is the same as your command name
|
||||
elfinderOpts['commandsOptions']['info']['custom']['desc'] = {
|
||||
// Field label
|
||||
label: Drupal.t('Description'),
|
||||
|
||||
// HTML Template
|
||||
tpl: '<div class="elfinder-info-desc"><span class="elfinder-info-spinner"></span></div><div class="elfinder-info-save"></div>',
|
||||
|
||||
// Action that sends the request to the server and get the description
|
||||
action: function(file, filemanager, dialog) {
|
||||
console.log('desc action');
|
||||
|
||||
console.log('fm');
|
||||
console.log(file.mime);
|
||||
|
||||
// Use the @filemanager object to issue a request
|
||||
filemanager.request({
|
||||
// Issuing the custom 'desc' command, targetting the selected file
|
||||
data: {cmd: 'desc', target: file.hash,},
|
||||
preventDefault: true,
|
||||
})
|
||||
// If the request fails, populate the field with 'Unknown'
|
||||
.fail(function() {
|
||||
console.log('desc fail');
|
||||
dialog.find('.elfinder-info-desc').html(filemanager.i18n('unknown'));
|
||||
})
|
||||
// When the request is successful, show the description
|
||||
.done(function(data) {
|
||||
console.log('desc done');
|
||||
dialog.find('.elfinder-info-desc').html(data.desc);
|
||||
|
||||
if (editDesc) {
|
||||
//filemanager.lockfiles({files : [file.hash]})
|
||||
dialog.find('.elfinder-info-desc').html('<textarea cols="20" rows="5" id="elfinder-fm-file-desc" class="ui-widget ui-widget-content">' + data.desc + '</textarea>');
|
||||
|
||||
$('.elfinder-info-save').append('<input type="button" id="elfinder-fm-file-desc-btn-save" class="ui-widget ui-button" value="' + filemanager.i18n('btnSave') + '" />');
|
||||
|
||||
var btnSave = $('#elfinder-fm-file-desc-btn-save', dialog).button();
|
||||
console.log(btnSave);
|
||||
|
||||
btnSave.click(function() {
|
||||
filemanager.lockfiles({files: [file.hash]});
|
||||
filemanager.request({
|
||||
data: {cmd: 'desc', target: file.hash, content: $('#elfinder-fm-file-desc').val()},
|
||||
notify: {type: 'desc', cnt: 1}
|
||||
})
|
||||
.always(function() {
|
||||
filemanager.unlockfiles({files: [file.hash]});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (viewOwner) {
|
||||
// Key is the same as your command name
|
||||
elfinderOpts['commandsOptions']['info']['custom']['owner'] = {
|
||||
// Field label
|
||||
label: Drupal.t('Owner'),
|
||||
|
||||
// HTML Template
|
||||
tpl: '<div class="elfinder-info-owner"><span class="elfinder-info-spinner"></span></div>',
|
||||
|
||||
// Action that sends the request to the server and get the description
|
||||
action: function(file, filemanager, dialog) {
|
||||
console.log('owner action');
|
||||
|
||||
// Use the @filemanager object to issue a request
|
||||
filemanager.request({
|
||||
// Issuing the custom 'desc' command, targetting the selected file
|
||||
data: {cmd: 'owner', target: file.hash,},
|
||||
preventDefault: true,
|
||||
})
|
||||
// If the request fails, populate the field with 'Unknown'
|
||||
.fail(function() {
|
||||
console.log('owner fail');
|
||||
dialog.find('.elfinder-info-owner').html(filemanager.i18n('unknown'));
|
||||
})
|
||||
// When the request is successful, show the description
|
||||
.done(function(data) {
|
||||
console.log('owner done');
|
||||
dialog.find('.elfinder-info-owner').html(data.owner);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
elFinder.prototype._options.uiOptions.cwd.listView.columns.push('owner');
|
||||
elFinder.prototype._options.uiOptions.cwd.listView.columnsCustomName['owner'] = Drupal.t('Owner');
|
||||
|
||||
}
|
||||
|
||||
if (viewDownloads) {
|
||||
elfinderOpts['commandsOptions']['info']['custom']['downloadcount'] = {
|
||||
// Field label
|
||||
label: Drupal.t('Downloads'),
|
||||
|
||||
// HTML Template
|
||||
tpl: '<div class="elfinder-info-downloadcount"><span class="elfinder-info-spinner"></span></div>',
|
||||
|
||||
// Action that sends the request to the server and get the description
|
||||
action: function(file, filemanager, dialog) {
|
||||
// Use the @filemanager object to issue a request
|
||||
filemanager.request({
|
||||
// Issuing the custom 'desc' command, targetting the selected file
|
||||
data: {cmd: 'downloadcount', target: file.hash,},
|
||||
preventDefault: true,
|
||||
})
|
||||
// If the request fails, populate the field with 'Unknown'
|
||||
.fail(function() {
|
||||
dialog.find('.elfinder-info-downloadcount').html(0);
|
||||
})
|
||||
// When the request is successful, show the description
|
||||
.done(function(data) {
|
||||
dialog.find('.elfinder-info-downloadcount').html(data.desc);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// console.log(elfinderOpts);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
$('#finder').elfinder(elfinderOpts);
|
||||
var fm = $('#finder').elfinder(elfinderOpts);
|
||||
|
||||
var instance = fm.elfinder('instance');
|
||||
|
||||
// console.log(typeof instance == 'object' && typeof instance.toast == 'function');
|
||||
|
||||
if (typeof instance == 'object' && typeof instance.toast == 'function') {
|
||||
instance.bind('load', function(event) {
|
||||
var messages = '#elfinder-messages .messages';
|
||||
$(messages).each(function(index, value) {
|
||||
var mode = 'info';
|
||||
if ($(value).hasClass('warning')) {
|
||||
mode = 'warning';
|
||||
} else if ($(value).hasClass('error')) {
|
||||
mode = 'error';
|
||||
}
|
||||
|
||||
instance.toast({
|
||||
msg: $(value).html(),
|
||||
hideDuration: 500,
|
||||
showDuration: 300,
|
||||
timeOut: 1000,
|
||||
mode: mode
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
} else {
|
||||
$('#elfinder-messages').addClass('legacy');
|
||||
}
|
||||
//$('#finder').toast({msg: '123'});
|
||||
|
||||
var h;
|
||||
|
||||
if (elfinderOpts.browserMode != 'backend') {
|
||||
h = ($(window).height());
|
||||
} else {
|
||||
h = ($('#page').height());
|
||||
}
|
||||
|
||||
if(elfinderOpts.browserMode != 'backend') {
|
||||
// If this is a popup, add an event so that elfinder fills the window.
|
||||
$(window).resize(function() {
|
||||
var h = ($(window).height());
|
||||
if($('#finder').height() != h) {
|
||||
if ($('#finder').height() != h) {
|
||||
$('#finder').height(h).resize();
|
||||
}
|
||||
});
|
||||
|
||||
$(window).trigger('resize');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
13
sites/all/modules/contrib/files/elfinder/js/elfinder.jquery-ui.legacy.min.js
vendored
Normal file
13
sites/all/modules/contrib/files/elfinder/js/elfinder.jquery-ui.legacy.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
5
sites/all/modules/contrib/files/elfinder/js/elfinder.jquery.legacy.min.js
vendored
Normal file
5
sites/all/modules/contrib/files/elfinder/js/elfinder.jquery.legacy.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* elFinder Integration
|
||||
*
|
||||
* Copyright (c) 2010-2018, Alexey Sukhotin. All rights reserved.
|
||||
*/
|
||||
|
||||
Drupal.elfinder = {
|
||||
editor: {}
|
||||
|
||||
|
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* elFinder Integration
|
||||
*
|
||||
* Copyright (c) 2010-2018, Alexey Sukhotin. All rights reserved.
|
||||
*/
|
||||
|
||||
// $Id: helper.js 100 2011-02-20 19:14:25Z ph0enix $
|
||||
|
||||
Drupal.elfinder = {
|
||||
|
@@ -1,84 +1,90 @@
|
||||
/*
|
||||
* elFinder Integration
|
||||
*
|
||||
* Copyright (c) 2010-2018, Alexey Sukhotin. All rights reserved.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
/**
|
||||
* @class elFinder command "info".
|
||||
* @class elFinder command "info".
|
||||
* Display dialog with file properties.
|
||||
*
|
||||
* @author Dmitry (dio) Levashov, dio@std42.ru
|
||||
**/
|
||||
|
||||
|
||||
(function($) {
|
||||
|
||||
elFinder.prototype.commands.info = function() {
|
||||
var m = 'msg',
|
||||
fm = this.fm,
|
||||
spclass = 'elfinder-info-spinner',
|
||||
msg = {
|
||||
calc : fm.i18n('calc'),
|
||||
size : fm.i18n('size'),
|
||||
unknown : fm.i18n('unknown'),
|
||||
path : fm.i18n('path'),
|
||||
aliasfor : fm.i18n('aliasfor'),
|
||||
modify : fm.i18n('modify'),
|
||||
perms : fm.i18n('perms'),
|
||||
locked : fm.i18n('locked'),
|
||||
dim : fm.i18n('dim'),
|
||||
kind : fm.i18n('kind'),
|
||||
files : fm.i18n('files'),
|
||||
folders : fm.i18n('folders'),
|
||||
items : fm.i18n('items'),
|
||||
yes : fm.i18n('yes'),
|
||||
no : fm.i18n('no'),
|
||||
link : fm.i18n('link'),
|
||||
owner : fm.i18n('owner'),
|
||||
desc : fm.i18n('description'),
|
||||
downloads: fm.i18n('downloads')
|
||||
};
|
||||
|
||||
this.tpl = {
|
||||
main : '<div class="ui-helper-clearfix elfinder-info-title"><span class="elfinder-cwd-icon {class} ui-corner-all"/>{title}</div><table class="elfinder-info-tb">{content}</table>',
|
||||
itemTitle : '<strong>{name}</strong><span class="elfinder-info-kind">{kind}</span>',
|
||||
groupTitle : '<strong>{items}: {num}</strong>',
|
||||
row : '<tr><td>{label} : </td><td>{value}</td></tr>',
|
||||
spinner : '<span>{text}</span> <span class="'+spclass+' '+spclass+'-'+'{id}"/>'
|
||||
}
|
||||
|
||||
this.alwaysEnabled = true;
|
||||
this.updateOnSelect = false;
|
||||
this.shortcuts = [{
|
||||
pattern : 'ctrl+i'
|
||||
}];
|
||||
|
||||
this.init = function() {
|
||||
$.each(msg, function(k, v) {
|
||||
msg[k] = fm.i18n(v);
|
||||
});
|
||||
}
|
||||
|
||||
this.getstate = function() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
this.exec = function(hashes) {
|
||||
elFinder.prototype.commands.info = function() {
|
||||
var m = 'msg',
|
||||
fm = this.fm,
|
||||
spclass = 'elfinder-info-spinner',
|
||||
msg = {
|
||||
calc: fm.i18n('calc'),
|
||||
size: fm.i18n('size'),
|
||||
unknown: fm.i18n('unknown'),
|
||||
path: fm.i18n('path'),
|
||||
aliasfor: fm.i18n('aliasfor'),
|
||||
modify: fm.i18n('modify'),
|
||||
perms: fm.i18n('perms'),
|
||||
locked: fm.i18n('locked'),
|
||||
dim: fm.i18n('dim'),
|
||||
kind: fm.i18n('kind'),
|
||||
files: fm.i18n('files'),
|
||||
folders: fm.i18n('folders'),
|
||||
items: fm.i18n('items'),
|
||||
yes: fm.i18n('yes'),
|
||||
no: fm.i18n('no'),
|
||||
link: fm.i18n('link'),
|
||||
owner: fm.i18n('owner'),
|
||||
desc: fm.i18n('description'),
|
||||
downloads: fm.i18n('downloads')
|
||||
};
|
||||
|
||||
var self = this,
|
||||
fm = this.fm,
|
||||
tpl = this.tpl,
|
||||
row = tpl.row,
|
||||
files = this.files(hashes),
|
||||
cnt = files.length,
|
||||
content = [],
|
||||
view = tpl.main,
|
||||
l = '{label}',
|
||||
v = '{value}',
|
||||
opts = {
|
||||
title : this.title,
|
||||
width : 'auto',
|
||||
modal : true,
|
||||
this.tpl = {
|
||||
main: '<div class="ui-helper-clearfix elfinder-info-title"><span class="elfinder-cwd-icon {class} ui-corner-all"/>{title}</div><table class="elfinder-info-tb">{content}</table>',
|
||||
itemTitle: '<strong>{name}</strong><span class="elfinder-info-kind">{kind}</span>',
|
||||
groupTitle: '<strong>{items}: {num}</strong>',
|
||||
row: '<tr><td>{label} : </td><td>{value}</td></tr>',
|
||||
spinner: '<span>{text}</span> <span class="' + spclass + ' ' + spclass + '-' + '{id}"/>'
|
||||
}
|
||||
|
||||
this.alwaysEnabled = true;
|
||||
this.updateOnSelect = false;
|
||||
this.shortcuts = [{
|
||||
pattern: 'ctrl+i'
|
||||
}];
|
||||
|
||||
this.init = function() {
|
||||
$.each(msg, function(k, v) {
|
||||
msg[k] = fm.i18n(v);
|
||||
});
|
||||
}
|
||||
|
||||
this.getstate = function() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
this.exec = function(hashes) {
|
||||
|
||||
var self = this,
|
||||
fm = this.fm,
|
||||
tpl = this.tpl,
|
||||
row = tpl.row,
|
||||
files = this.files(hashes),
|
||||
cnt = files.length,
|
||||
content = [],
|
||||
view = tpl.main,
|
||||
l = '{label}',
|
||||
v = '{value}',
|
||||
opts = {
|
||||
title: this.title,
|
||||
width: 'auto',
|
||||
modal: true,
|
||||
close: function() {
|
||||
$(this).elfinderdialog('destroy');
|
||||
}
|
||||
},
|
||||
count = [],
|
||||
},
|
||||
count = [],
|
||||
replSpinner = function(msg) {
|
||||
dialog.find('.' + spclass).parent().text(msg);
|
||||
},
|
||||
@@ -88,208 +94,208 @@ elFinder.prototype.commands.info = function() {
|
||||
id = fm.namespace + '-info-' + $.map(files, function(f) {
|
||||
return f.hash
|
||||
}).join('-'),
|
||||
dialog = fm.getUI().find('#'+id),
|
||||
size, tmb, file, title, dcnt;
|
||||
|
||||
var disabledCommands = Drupal.settings.elfinder.disabledCommands,
|
||||
dialog = fm.getUI().find('#' + id),
|
||||
size, tmb, file, title, dcnt;
|
||||
|
||||
var disabledCommands = Drupal.settings.elfinder.disabledCommands,
|
||||
viewDesc = $.inArray('desc', disabledCommands) == -1 ? true : false,
|
||||
editDesc = $.inArray('editdesc', disabledCommands) == -1 ? true : false,
|
||||
viewOwner = $.inArray('owner', disabledCommands) == -1 ? true : false,
|
||||
viewDownloads = $.inArray('downloadcount', disabledCommands) == -1 ? true : false;
|
||||
|
||||
if (!cnt) {
|
||||
return $.Deferred().reject();
|
||||
}
|
||||
|
||||
if (dialog.length) {
|
||||
dialog.elfinderdialog('toTop');
|
||||
return $.Deferred().resolve();
|
||||
}
|
||||
|
||||
|
||||
if (cnt == 1) {
|
||||
file = files[0];
|
||||
view = view.replace('{class}', fm.mime2class(file.mime));
|
||||
title = tpl.itemTitle.replace('{name}', file.name).replace('{kind}', fm.mime2kind(file));
|
||||
|
||||
if (file.tmb) {
|
||||
tmb = fm.option('tmbUrl')+file.tmb;
|
||||
}
|
||||
|
||||
if (!file.read) {
|
||||
size = msg.unknown;
|
||||
} else if (file.mime != 'directory' || file.alias) {
|
||||
size = fm.formatSize(file.size);
|
||||
} else {
|
||||
/* adding spinner id to separate field updates */
|
||||
size = tpl.spinner.replace('{text}', msg.calc).replace('{id}', 'size');
|
||||
count.push(file.hash);
|
||||
}
|
||||
|
||||
content.push(row.replace(l, msg.size).replace(v, size));
|
||||
file.alias && content.push(row.replace(l, msg.aliasfor).replace(v, file.alias));
|
||||
content.push(row.replace(l, msg.path).replace(v, fm.escape(fm.path(file.hash))));
|
||||
file.read && content.push(row.replace(l, msg.link).replace(v, '<a href="'+fm.url(file.hash)+'" target="_blank">'+file.name+'</a>'));
|
||||
|
||||
if (file.dim) { // old api
|
||||
content.push(row.replace(l, msg.dim).replace(v, file.dim));
|
||||
} else if (file.mime.indexOf('image') !== -1) {
|
||||
content.push(row.replace(l, msg.dim).replace(v, tpl.spinner.replace('{text}', msg.calc).replace('{id}', 'dim')));
|
||||
fm.request({
|
||||
data : {cmd : 'dim', target : file.hash},
|
||||
preventDefault : true
|
||||
})
|
||||
.fail(function() {
|
||||
replSpinnerById(msg.unknown, 'dim');
|
||||
})
|
||||
.done(function(data) {
|
||||
replSpinnerById(data.dim || msg.unknown, 'dim');
|
||||
});
|
||||
}
|
||||
|
||||
content.push(row.replace(l, msg.modify).replace(v, fm.formatDate(file)));
|
||||
content.push(row.replace(l, msg.perms).replace(v, fm.formatPermissions(file)));
|
||||
content.push(row.replace(l, msg.locked).replace(v, file.locked ? msg.yes : msg.no));
|
||||
|
||||
/* Don't show fields if command not allowed */
|
||||
if (viewOwner) {
|
||||
content.push(row.replace(l, Drupal.t('Owner')).replace(v, tpl.spinner.replace('{text}', msg.calc).replace('{id}', 'owner')));
|
||||
|
||||
fm.request({
|
||||
data : {cmd : 'owner', target : file.hash},
|
||||
preventDefault : true
|
||||
})
|
||||
.fail(function() {
|
||||
replSpinnerById(msg.unknown, 'owner');
|
||||
})
|
||||
.done(function(data) {
|
||||
replSpinnerById(data.owner || msg.unknown, 'owner');
|
||||
});
|
||||
if (!cnt) {
|
||||
return $.Deferred().reject();
|
||||
}
|
||||
|
||||
/* Don't show fields if command not allowed */
|
||||
if (viewDownloads) {
|
||||
content.push(row.replace(l, Drupal.t('Downloads')).replace(v, tpl.spinner.replace('{text}', msg.calc).replace('{id}', 'downloads')));
|
||||
|
||||
fm.request({
|
||||
data : {cmd : 'downloadcount', target : file.hash},
|
||||
preventDefault : true
|
||||
})
|
||||
.fail(function() {
|
||||
replSpinnerById(msg.unknown, 'downloads');
|
||||
})
|
||||
.done(function(data) {
|
||||
replSpinnerById(data.downloadcount || msg.unknown, 'downloads');
|
||||
});
|
||||
|
||||
if (dialog.length) {
|
||||
dialog.elfinderdialog('toTop');
|
||||
return $.Deferred().resolve();
|
||||
}
|
||||
|
||||
/* Don't show fields if command not allowed */
|
||||
if (viewDesc || editDesc) {
|
||||
|
||||
var desc = '<div id="elfinder-fm-file-desc">' + msg.calc + '</div>';
|
||||
|
||||
if (editDesc) {
|
||||
|
||||
desc = '<textarea cols="20" rows="5" id="elfinder-fm-file-desc" class="ui-widget ui-widget-content" disabled="true" >' + msg.calc + '</textarea><input type="button" id="elfinder-fm-file-desc-btn-save" value="' + fm.i18n('btnSave') + '" />';
|
||||
|
||||
|
||||
if (cnt == 1) {
|
||||
file = files[0];
|
||||
view = view.replace('{class}', fm.mime2class(file.mime));
|
||||
title = tpl.itemTitle.replace('{name}', file.name).replace('{kind}', fm.mime2kind(file));
|
||||
|
||||
if (file.tmb) {
|
||||
tmb = fm.option('tmbUrl') + file.tmb;
|
||||
}
|
||||
|
||||
content.push(row.replace(l, Drupal.t('Description')).replace(v , desc));
|
||||
|
||||
fm.request({
|
||||
data : {cmd : 'desc', target : file.hash},
|
||||
preventDefault : true
|
||||
})
|
||||
.done(function(data) {
|
||||
var fieldDesc = dialog.find('#elfinder-fm-file-desc');
|
||||
|
||||
if (editDesc) {
|
||||
fieldDesc.val(data.desc || '');
|
||||
fieldDesc.removeAttr('disabled');
|
||||
} else {
|
||||
fieldDesc.empty();
|
||||
fieldDesc.html(data.desc || '');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
view = view.replace('{class}', 'elfinder-cwd-icon-group');
|
||||
title = tpl.groupTitle.replace('{items}', msg.items).replace('{num}', cnt);
|
||||
if (!file.read) {
|
||||
size = msg.unknown;
|
||||
} else if (file.mime != 'directory' || file.alias) {
|
||||
size = fm.formatSize(file.size);
|
||||
} else {
|
||||
/* adding spinner id to separate field updates */
|
||||
size = tpl.spinner.replace('{text}', msg.calc).replace('{id}', 'size');
|
||||
count.push(file.hash);
|
||||
}
|
||||
|
||||
content.push(row.replace(l, msg.size).replace(v, size));
|
||||
file.alias && content.push(row.replace(l, msg.aliasfor).replace(v, file.alias));
|
||||
content.push(row.replace(l, msg.path).replace(v, fm.escape(fm.path(file.hash))));
|
||||
file.read && content.push(row.replace(l, msg.link).replace(v, '<a href="' + fm.url(file.hash) + '" target="_blank">' + file.name + '</a>'));
|
||||
|
||||
if (file.dim) { // old api
|
||||
content.push(row.replace(l, msg.dim).replace(v, file.dim));
|
||||
} else if (file.mime.indexOf('image') !== -1) {
|
||||
content.push(row.replace(l, msg.dim).replace(v, tpl.spinner.replace('{text}', msg.calc).replace('{id}', 'dim')));
|
||||
fm.request({
|
||||
data: {cmd: 'dim', target: file.hash},
|
||||
preventDefault: true
|
||||
})
|
||||
.fail(function() {
|
||||
replSpinnerById(msg.unknown, 'dim');
|
||||
})
|
||||
.done(function(data) {
|
||||
replSpinnerById(data.dim || msg.unknown, 'dim');
|
||||
});
|
||||
}
|
||||
|
||||
content.push(row.replace(l, msg.modify).replace(v, fm.formatDate(file)));
|
||||
content.push(row.replace(l, msg.perms).replace(v, fm.formatPermissions(file)));
|
||||
content.push(row.replace(l, msg.locked).replace(v, file.locked ? msg.yes : msg.no));
|
||||
|
||||
/* Don't show fields if command not allowed */
|
||||
if (viewOwner) {
|
||||
content.push(row.replace(l, Drupal.t('Owner')).replace(v, tpl.spinner.replace('{text}', msg.calc).replace('{id}', 'owner')));
|
||||
|
||||
fm.request({
|
||||
data: {cmd: 'owner', target: file.hash},
|
||||
preventDefault: true
|
||||
})
|
||||
.fail(function() {
|
||||
replSpinnerById(msg.unknown, 'owner');
|
||||
})
|
||||
.done(function(data) {
|
||||
replSpinnerById(data.owner || msg.unknown, 'owner');
|
||||
});
|
||||
}
|
||||
|
||||
/* Don't show fields if command not allowed */
|
||||
if (viewDownloads) {
|
||||
content.push(row.replace(l, Drupal.t('Downloads')).replace(v, tpl.spinner.replace('{text}', msg.calc).replace('{id}', 'downloads')));
|
||||
|
||||
fm.request({
|
||||
data: {cmd: 'downloadcount', target: file.hash},
|
||||
preventDefault: true
|
||||
})
|
||||
.fail(function() {
|
||||
replSpinnerById(msg.unknown, 'downloads');
|
||||
})
|
||||
.done(function(data) {
|
||||
replSpinnerById(data.downloadcount || msg.unknown, 'downloads');
|
||||
});
|
||||
}
|
||||
|
||||
/* Don't show fields if command not allowed */
|
||||
if (viewDesc || editDesc) {
|
||||
|
||||
var desc = '<div id="elfinder-fm-file-desc">' + msg.calc + '</div>';
|
||||
|
||||
if (editDesc) {
|
||||
|
||||
desc = '<textarea cols="20" rows="5" id="elfinder-fm-file-desc" class="ui-widget ui-widget-content" disabled="true" >' + msg.calc + '</textarea><input type="button" id="elfinder-fm-file-desc-btn-save" value="' + fm.i18n('btnSave') + '" />';
|
||||
}
|
||||
|
||||
content.push(row.replace(l, Drupal.t('Description')).replace(v, desc));
|
||||
|
||||
fm.request({
|
||||
data: {cmd: 'desc', target: file.hash},
|
||||
preventDefault: true
|
||||
})
|
||||
.done(function(data) {
|
||||
var fieldDesc = dialog.find('#elfinder-fm-file-desc');
|
||||
|
||||
if (editDesc) {
|
||||
fieldDesc.val(data.desc || '');
|
||||
fieldDesc.removeAttr('disabled');
|
||||
} else {
|
||||
fieldDesc.empty();
|
||||
fieldDesc.html(data.desc || '');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
view = view.replace('{class}', 'elfinder-cwd-icon-group');
|
||||
title = tpl.groupTitle.replace('{items}', msg.items).replace('{num}', cnt);
|
||||
dcnt = $.map(files, function(f) {
|
||||
return f.mime == 'directory' ? 1 : null
|
||||
}).length;
|
||||
if (!dcnt) {
|
||||
size = 0;
|
||||
$.each(files, function(h, f) {
|
||||
var s = parseInt(f.size);
|
||||
|
||||
if (s >= 0 && size >= 0) {
|
||||
size += s;
|
||||
} else {
|
||||
size = 'unknown';
|
||||
}
|
||||
});
|
||||
content.push(row.replace(l, msg.kind).replace(v, msg.files));
|
||||
content.push(row.replace(l, msg.size).replace(v, fm.formatSize(size)));
|
||||
} else {
|
||||
content.push(row.replace(l, msg.kind).replace(v, dcnt == cnt ? msg.folders : msg.folders+' '+dcnt+', '+msg.files+' '+(cnt-dcnt)))
|
||||
content.push(row.replace(l, msg.size).replace(v, tpl.spinner.replace('{text}', msg.calc).replace('{id}', 'size')));
|
||||
if (!dcnt) {
|
||||
size = 0;
|
||||
$.each(files, function(h, f) {
|
||||
var s = parseInt(f.size);
|
||||
|
||||
if (s >= 0 && size >= 0) {
|
||||
size += s;
|
||||
} else {
|
||||
size = 'unknown';
|
||||
}
|
||||
});
|
||||
content.push(row.replace(l, msg.kind).replace(v, msg.files));
|
||||
content.push(row.replace(l, msg.size).replace(v, fm.formatSize(size)));
|
||||
} else {
|
||||
content.push(row.replace(l, msg.kind).replace(v, dcnt == cnt ? msg.folders : msg.folders + ' ' + dcnt + ', ' + msg.files + ' ' + (cnt - dcnt)))
|
||||
content.push(row.replace(l, msg.size).replace(v, tpl.spinner.replace('{text}', msg.calc).replace('{id}', 'size')));
|
||||
count = $.map(files, function(f) {
|
||||
return f.hash
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
view = view.replace('{title}', title).replace('{content}', content.join(''));
|
||||
|
||||
dialog = fm.dialog(view, opts);
|
||||
dialog.attr('id', id);
|
||||
|
||||
if (editDesc) {
|
||||
var inputDesc = $('#elfinder-fm-file-desc', dialog);
|
||||
var btnSave = $('#elfinder-fm-file-desc-btn-save', dialog).button();
|
||||
|
||||
btnSave.click(function() {
|
||||
fm.lockfiles({files : [file.hash]});
|
||||
fm.request({
|
||||
data : {cmd : 'desc', target : file.hash, content : inputDesc.val()},
|
||||
notify : {type : 'desc', cnt : 1}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
view = view.replace('{title}', title).replace('{content}', content.join(''));
|
||||
|
||||
dialog = fm.dialog(view, opts);
|
||||
dialog.attr('id', id);
|
||||
|
||||
if (editDesc) {
|
||||
var inputDesc = $('#elfinder-fm-file-desc', dialog);
|
||||
var btnSave = $('#elfinder-fm-file-desc-btn-save', dialog).button();
|
||||
|
||||
btnSave.click(function() {
|
||||
fm.lockfiles({files: [file.hash]});
|
||||
fm.request({
|
||||
data: {cmd: 'desc', target: file.hash, content: inputDesc.val()},
|
||||
notify: {type: 'desc', cnt: 1}
|
||||
})
|
||||
.always(function() {
|
||||
fm.unlockfiles({files : [file.hash]})
|
||||
});
|
||||
});
|
||||
}
|
||||
// load thumbnail
|
||||
if (tmb) {
|
||||
$('<img/>')
|
||||
.always(function() {
|
||||
fm.unlockfiles({files: [file.hash]})
|
||||
});
|
||||
});
|
||||
}
|
||||
// load thumbnail
|
||||
if (tmb) {
|
||||
$('<img/>')
|
||||
.load(function() {
|
||||
dialog.find('.elfinder-cwd-icon').css('background', 'url("' + tmb + '") center center no-repeat');
|
||||
})
|
||||
.attr('src', tmb);
|
||||
}
|
||||
|
||||
// send request to count total size
|
||||
if (count.length) {
|
||||
fm.request({
|
||||
data : {cmd : 'size', targets : count},
|
||||
preventDefault : true
|
||||
})
|
||||
.fail(function() {
|
||||
replSpinnerById(msg.unknown, 'size');
|
||||
})
|
||||
.done(function(data) {
|
||||
var size = parseInt(data.size);
|
||||
fm.log(data.size)
|
||||
replSpinnerById(size >= 0 ? fm.formatSize(size) : msg.unknown, 'size');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
.attr('src', tmb);
|
||||
}
|
||||
|
||||
// send request to count total size
|
||||
if (count.length) {
|
||||
fm.request({
|
||||
data: {cmd: 'size', targets: count},
|
||||
preventDefault: true
|
||||
})
|
||||
.fail(function() {
|
||||
replSpinnerById(msg.unknown, 'size');
|
||||
})
|
||||
.done(function(data) {
|
||||
var size = parseInt(data.size);
|
||||
fm.log(data.size)
|
||||
replSpinnerById(size >= 0 ? fm.formatSize(size) : msg.unknown, 'size');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
})(jQuery);
|
Reference in New Issue
Block a user