Merge branch 'seeddms-5.1.x' into seeddms-6.0.x

This commit is contained in:
Uwe Steinmann 2024-11-01 17:49:44 +01:00
commit 36acb63ebe
8 changed files with 178 additions and 62 deletions

View File

@ -74,6 +74,13 @@ module.exports = function (grunt) {
], ],
dest: bootstrapDir + '/select2/js', dest: bootstrapDir + '/select2/js',
flatten: true flatten: true
},{
expand: true,
src: [
nodeDir + '/select2/dist/js/i18n/*'
],
dest: bootstrapDir + '/select2/js/i18n',
flatten: true
},{ },{
expand: true, expand: true,
src: [ src: [

View File

@ -133,30 +133,46 @@ switch($command) {
} }
break; /* }}} */ break; /* }}} */
/* Used for folder chooser */ /* This is used for searching folders in the folder selectors
* 1. the selector also having a tree
* 2. the selector based on select2 for <select class="chzn-select-folder" ...>
* $format is set to 'select2' in the second case.
*/
case 'searchfolder': /* {{{ */ case 'searchfolder': /* {{{ */
if($user) { if($user) {
$query = $_GET['query']; $format = $_GET['format'] ?? '';
$query = $_GET['query'] ?? '';
if(!$query) {
header('Content-Type: application/json');
if($format == 'select2')
echo json_encode(['results'=>[]]);
else
echo json_encode([]);
return;
}
if(false !== ($pos = strpos($query, '/'))) { if(false !== ($pos = strpos($query, '/'))) {
$subquery = substr($query, 0, $pos); $subquery = substr($query, 0, $pos);
$hits = $dms->search($subquery, $limit=0, $offset=0, $logicalmode='AND', $searchin=array(), $startFolder=$dms->getRootFolder(), $owner=null, $status = array(), $creationstartdate=array(), $creationenddate=array(), $modificationstartdate=array(), $modificationenddate=array(), $categories=array(), $attributes=array(), $mode=0x2, $expirationstartdate=array(), $expirationenddate=array()); $hits = $dms->search($subquery, $limit=0, $offset=0, $logicalmode='AND', $searchin=array(2), $startFolder=$dms->getRootFolder(), $owner=null, $status = array(), $creationstartdate=array(), $creationenddate=array(), $modificationstartdate=array(), $modificationenddate=array(), $categories=array(), $attributes=array(), $mode=0x2, $expirationstartdate=array(), $expirationenddate=array());
if($hits) { if($hits) {
if(count($hits['folders']) == 1) { if(count($hits['folders']) == 1) {
$hit = $hits['folders'][0]; $hit = $hits['folders'][0];
$basefolder = $dms->getFolder($hit->getID()); $basefolder = $dms->getFolder($hit->getID());
if($basefolder->getAccessMode($user, 'search') >= M_READ) { if($basefolder->getAccessMode($user, 'search') >= M_READ) {
if($subquery = substr($query, $pos+1)) { if($subquery = substr($query, $pos+1)) {
$hits = $dms->search($subquery, $limit=0, $offset=0, $logicalmode='AND', $searchin=array(), $startFolder=$basefolder, $owner=null, $status = array(), $creationstartdate=array(), $creationenddate=array(), $modificationstartdate=array(), $modificationenddate=array(), $categories=array(), $attributes=array(), $mode=0x2, $expirationstartdate=array(), $expirationenddate=array()); $hits = $dms->search($subquery, $limit=0, $offset=0, $logicalmode='AND', $searchin=array(2), $startFolder=$basefolder, $owner=null, $status = array(), $creationstartdate=array(), $creationenddate=array(), $modificationstartdate=array(), $modificationenddate=array(), $categories=array(), $attributes=array(), $mode=0x2, $expirationstartdate=array(), $expirationenddate=array());
if($hits) { if($hits) {
$result = array(); $result = array();
foreach($hits['folders'] as $hit) { foreach($hits['folders'] as $hit) {
if($hit->getAccessMode($user, 'search') >= M_READ) if($hit->getAccessMode($user, 'search') >= M_READ)
// $result[] = $hit->getID().'#'.$hit->getFolderPathPlain(true, '/'); // $result[] = $hit->getID().'#'.$hit->getFolderPathPlain(true, '/');
$result[] = array('type'=>'F', 'id'=>$hit->getId(), 'name'=>htmlspecialchars($hit->getFolderPathPlain(true, '/')), 'path'=>htmlspecialchars($hit->getParent()->getFolderPathPlain(true, '/'))); $result[] = array('type'=>'F', 'id'=>$hit->getId(), 'name'=>htmlspecialchars($hit->getName()), 'path'=>htmlspecialchars($hit->getParent()->getFolderPathPlain(true, '/')));
} }
header('Content-Type: application/json'); header('Content-Type: application/json');
echo json_encode($result); if($format == 'select2')
echo json_encode(['results'=>$result]);
else
echo json_encode($result);
return; return;
} }
} else { } else {
@ -166,10 +182,13 @@ switch($command) {
foreach($subfolders as $subfolder) { foreach($subfolders as $subfolder) {
//$result[] = $subfolder->getID().'#'.$basefolder->getName().'/'.$subfolder->getName(); //$result[] = $subfolder->getID().'#'.$basefolder->getName().'/'.$subfolder->getName();
// $result[] = $subfolder->getID().'#'.$subfolder->getFolderPathPlain(true, '/'); // $result[] = $subfolder->getID().'#'.$subfolder->getFolderPathPlain(true, '/');
$result[] = array('type'=>'F', 'id'=>$subfolder->getId(), 'name'=>htmlspecialchars($subfolder->getFolderPathPlain(true, '/')), 'path'=>htmlspecialchars($subfolder->getParent()->getFolderPathPlain(true, '/'))); $result[] = array('type'=>'F', 'id'=>$subfolder->getId(), 'name'=>htmlspecialchars($subfolder->getName()), 'path'=>htmlspecialchars($subfolder->getParent()->getFolderPathPlain(true, '/')));
} }
header('Content-Type: application/json'); header('Content-Type: application/json');
echo json_encode($result); if($format == 'select2')
echo json_encode(['results'=>$result]);
else
echo json_encode($result);
return; return;
} }
} }
@ -182,10 +201,13 @@ switch($command) {
foreach($hits['folders'] as $hit) { foreach($hits['folders'] as $hit) {
if($hit->getAccessMode($user, 'search') >= M_READ) if($hit->getAccessMode($user, 'search') >= M_READ)
// $result[] = $hit->getID().'#'.$hit->getFolderPathPlain(true, '/'); // $result[] = $hit->getID().'#'.$hit->getFolderPathPlain(true, '/');
$result[] = array('type'=>'F', 'id'=>$hit->getId(), 'name'=>htmlspecialchars($hit->getFolderPathPlain(true, '/')), 'path'=>htmlspecialchars($hit->getParent()->getFolderPathPlain(true, '/'))); $result[] = array('type'=>'F', 'id'=>$hit->getId(), 'name'=>htmlspecialchars($hit->getName()), 'path'=>htmlspecialchars($hit->getParent()->getFolderPathPlain(true, '/')));
} }
header('Content-Type: application/json'); header('Content-Type: application/json');
echo json_encode($result); if($format == 'select2')
echo json_encode(['results'=>$result]);
else
echo json_encode($result);
} }
} }
break; /* }}} */ break; /* }}} */

View File

@ -101,9 +101,11 @@ class SeedDMS_Theme_Style extends SeedDMS_View_Common {
echo "<!DOCTYPE html>\n"; echo "<!DOCTYPE html>\n";
echo "<html lang=\""; echo "<html lang=\"";
if(!empty($this->params['session']) && ($slang = $this->params['session']->getLanguage())) { if(!empty($this->params['session']) && ($slang = $this->params['session']->getLanguage())) {
echo str_replace('_', '-', $slang); echo substr($slang, 0, 2);
// echo str_replace('_', '-', $slang);
} else { } else {
echo str_replace('_', '-', $this->params['settings']->_language); echo substr($this->params['settings']->_language, 0, 2);
// echo str_replace('_', '-', $this->params['settings']->_language);
} }
echo "\">\n<head>\n"; echo "\">\n<head>\n";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n"; echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
@ -213,7 +215,7 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
$this->addFooterJS('SeedDMSTask.run();'); $this->addFooterJS('SeedDMSTask.run();');
} }
if($this->params['enabledropfolderlist'] && isset($this->params['user']) && $this->params['user']) { if($this->params['enabledropfolderlist'] && isset($this->params['user']) && $this->params['user']) {
$this->addFooterJS("SeedDMSTask.add({name: 'dropfolder', interval: 30, func: function(){\$('#menu-dropfolder > div.ajax').trigger('update', {folderid: seeddms_folder});}});"); $this->addFooterJS("SeedDMSTask.add({name: 'dropfolder', interval: 30, func: function(){\$('#menu-dropfolder > div.ajax').trigger('update', {folderid: seeddms_folder, noinit: true});}});");
} }
if($this->footerjs) { if($this->footerjs) {
$jscode = "$(document).ready(function () {\n"; $jscode = "$(document).ready(function () {\n";

View File

@ -737,7 +737,7 @@ if(($kkk = $this->callHook('getFullSearchEngine')) && is_array($kkk))
case "users": case "users":
$users = $dms->getAllUsers(); $users = $dms->getAllUsers();
if($users) { if($users) {
echo "<select class=\"chzn-select\"".($allowempty ? " data-allow-clear=\"true\"" : "")." name=\"extensions[".$extname."][".$confkey."][]\"".(!empty($conf['multiple']) ? " multiple" : "").(!empty($conf['size']) ? " size=\"".$conf['size']."\"" : "")." data-placeholder=\"".getMLText("select_user")."\" style=\"width: 100%;\">"; echo "<select class=\"chzn-select\"".($allowempty ? " data-allow-clear=\"true\"" : "")." name=\"extensions[".$extname."][".$confkey."][]\"".(!empty($conf['multiple']) ? " multiple" : "").(!empty($conf['size']) ? " size=\"".$conf['size']."\"" : "")." data-placeholder=\"".getMLText("select_user")."\" style=\"width: 100%;\">";
if($allowempty) if($allowempty)
echo "<option value=\"\"></option>"; echo "<option value=\"\"></option>";
foreach($users as $curuser) { foreach($users as $curuser) {
@ -752,7 +752,7 @@ if(($kkk = $this->callHook('getFullSearchEngine')) && is_array($kkk))
case "groups": case "groups":
$recs = $dms->getAllGroups(); $recs = $dms->getAllGroups();
if($recs) { if($recs) {
echo "<select class=\"chzn-select\"".($allowempty ? " data-allow-clear=\"true\"" : "")." name=\"extensions[".$extname."][".$confkey."][]\"".(!empty($conf['multiple']) ? " multiple" : "").(!empty($conf['size']) ? " size=\"".$conf['size']."\"" : "")." data-placeholder=\"".getMLText("select_group")."\" style=\"width: 100%;\">"; echo "<select class=\"chzn-select\"".($allowempty ? " data-allow-clear=\"true\"" : "")." name=\"extensions[".$extname."][".$confkey."][]\"".(!empty($conf['multiple']) ? " multiple" : "").(!empty($conf['size']) ? " size=\"".$conf['size']."\"" : "")." data-placeholder=\"".getMLText("select_group")."\" style=\"width: 100%;\">";
if($allowempty) if($allowempty)
echo "<option value=\"\"></option>"; echo "<option value=\"\"></option>";
foreach($recs as $rec) { foreach($recs as $rec) {
@ -769,7 +769,7 @@ if(($kkk = $this->callHook('getFullSearchEngine')) && is_array($kkk))
$attrtype = empty($conf['attrtype']) ? 0 : $conf['attrtype']; $attrtype = empty($conf['attrtype']) ? 0 : $conf['attrtype'];
$recs = $dms->getAllAttributeDefinitions($objtype, $attrtype); $recs = $dms->getAllAttributeDefinitions($objtype, $attrtype);
if($recs) { if($recs) {
echo "<select class=\"chzn-select\"".($allowempty ? " data-allow-clear=\"true\"" : "")." name=\"extensions[".$extname."][".$confkey."][]\"".(!empty($conf['multiple']) ? " multiple" : "").(!empty($conf['size']) ? " size=\"".$conf['size']."\"" : "")." data-placeholder=\"".getMLText("select_attrdef")."\" data-no_results_text=\"".getMLText('unknown_attrdef')."\" style=\"width: 100%;\">"; echo "<select class=\"chzn-select\"".($allowempty ? " data-allow-clear=\"true\"" : "")." name=\"extensions[".$extname."][".$confkey."][]\"".(!empty($conf['multiple']) ? " multiple" : "").(!empty($conf['size']) ? " size=\"".$conf['size']."\"" : "")." data-placeholder=\"".getMLText("select_attrdef")."\" data-no_results_text=\"".getMLText('unknown_attrdef')."\" style=\"width: 100%;\">";
if($allowempty) if($allowempty)
echo "<option value=\"\"></option>"; echo "<option value=\"\"></option>";
foreach($recs as $rec) { foreach($recs as $rec) {
@ -786,7 +786,7 @@ if(($kkk = $this->callHook('getFullSearchEngine')) && is_array($kkk))
case "workflows": case "workflows":
$recs = $dms->getAllWorkflows(); $recs = $dms->getAllWorkflows();
if($recs) { if($recs) {
echo "<select class=\"chzn-select\"".($allowempty ? " data-allow-clear=\"true\"" : "")." name=\"extensions[".$extname."][".$confkey."][]\"".(!empty($conf['multiple']) ? " multiple" : "").(!empty($conf['size']) ? " size=\"".$conf['size']."\"" : "")." data-placeholder=\"".getMLText("select_attribute_value")."\" style=\"width: 100%;\">"; echo "<select class=\"chzn-select\"".($allowempty ? " data-allow-clear=\"true\"" : "")." name=\"extensions[".$extname."][".$confkey."][]\"".(!empty($conf['multiple']) ? " multiple" : "").(!empty($conf['size']) ? " size=\"".$conf['size']."\"" : "")." data-placeholder=\"".getMLText("select_attribute_value")."\" style=\"width: 100%;\">";
if($allowempty) if($allowempty)
echo "<option value=\"\"></option>"; echo "<option value=\"\"></option>";
foreach($recs as $rec) { foreach($recs as $rec) {
@ -803,6 +803,19 @@ if(($kkk = $this->callHook('getFullSearchEngine')) && is_array($kkk))
case "folders": case "folders":
$this->formField(null, $this->getFolderChooserHtml("form".$extname.$confkey, M_READ, -1, $selections ? $dms->getFolder($selections[0]) : 0, 'extensions['.$extname."][".$confkey."]")); $this->formField(null, $this->getFolderChooserHtml("form".$extname.$confkey, M_READ, -1, $selections ? $dms->getFolder($selections[0]) : 0, 'extensions['.$extname."][".$confkey."]"));
break; break;
case "folderlist":
echo "<select class=\"chzn-select-folder\"".($allowempty ? " data-allow-clear=\"true\"" : "")." name=\"extensions[".$extname."][".$confkey."][]\"".(!empty($conf['multiple']) ? " multiple" : "").(!empty($conf['size']) ? " size=\"".$conf['size']."\"" : "")." data-placeholder=\"".getMLText("select_attribute_value")."\" style=\"width: 100%;\">";
if($selections) {
foreach ($selections as $selid) {
if ($f = $dms->getFolder($selid)) {
echo "<option value=\"".$f->getID()."\"";
echo " selected";
echo ">".htmlspecialchars($f->getName())."</option>";
}
}
}
echo "</select>";
break;
case "documents": case "documents":
$this->formField(null, $this->getDocumentChooserHtml("form".$extname.$confkey, M_READ, -1, $selections ? $dms->getDocument($selections[0]) : 0, 'extensions['.$extname."][".$confkey."]")); $this->formField(null, $this->getDocumentChooserHtml("form".$extname.$confkey, M_READ, -1, $selections ? $dms->getDocument($selections[0]) : 0, 'extensions['.$extname."][".$confkey."]"));
break; break;

View File

@ -4,8 +4,10 @@
* will receive an unescaped string * will receive an unescaped string
* (see https://forums.select2.org/t/propperly-escape-option-value-to-prevent-xss/788) * (see https://forums.select2.org/t/propperly-escape-option-value-to-prevent-xss/788)
*/ */
chzn_template_func = function (state) { chzn_template_func = function (state) { /* {{{ */
var subtitle = ''; var subtitle = '';
if(state.subtitle)
subtitle = state.subtitle;
if($(state.element).data('subtitle')) if($(state.element).data('subtitle'))
subtitle = $(state.element).data('subtitle')+''; /* make sure it is a string */ subtitle = $(state.element).data('subtitle')+''; /* make sure it is a string */
var warning = ''; var warning = '';
@ -24,9 +26,9 @@ chzn_template_func = function (state) {
html += '</span>'; html += '</span>';
var $newstate = $(html); var $newstate = $(html);
return $newstate; return $newstate;
}; }; /* }}} */
function escapeHtml(text) { function escapeHtml(text) { /* {{{ */
var map = { var map = {
'&': '&amp;', '&': '&amp;',
'<': '&lt;', '<': '&lt;',
@ -36,7 +38,7 @@ function escapeHtml(text) {
}; };
return text.replace(/[&<>"']/g, function(m) { return map[m]; }); return text.replace(/[&<>"']/g, function(m) { return map[m]; });
} } /* }}} */
/** /**
* Format bytes as human-readable text. * Format bytes as human-readable text.
@ -48,7 +50,7 @@ function escapeHtml(text) {
* *
* @return Formatted string. * @return Formatted string.
*/ */
function formatFileSize(bytes, si=false, dp=1) { function formatFileSize(bytes, si=false, dp=1) { /* {{{ */
const thresh = si ? 1000 : 1024; const thresh = si ? 1000 : 1024;
if (Math.abs(bytes) < thresh) { if (Math.abs(bytes) < thresh) {
@ -68,7 +70,7 @@ function formatFileSize(bytes, si=false, dp=1) {
return bytes.toFixed(dp) + ' ' + units[u]; return bytes.toFixed(dp) + ' ' + units[u];
} } /* }}} */
function treeFolderSelected(formid, nodeid, nodename) { function treeFolderSelected(formid, nodeid, nodename) {
$('#'+formid).val(nodeid); $('#'+formid).val(nodeid);
@ -82,7 +84,7 @@ function treeDocumentSelected(formid, nodeid, nodename) {
$('#docChooser'+formid).modal('hide'); $('#docChooser'+formid).modal('hide');
} }
function initMost() { function initMost() { /* {{{ */
$('.datepicker, #expirationdate, #createstartdate, #createenddate, #expirationstartdate, #expirationenddate') $('.datepicker, #expirationdate, #createstartdate, #createenddate, #expirationstartdate, #expirationenddate')
.datepicker({todayHighlight: true, toggleActive: true}) .datepicker({todayHighlight: true, toggleActive: true})
.on('changeDate', function(ev){ .on('changeDate', function(ev){
@ -92,11 +94,37 @@ function initMost() {
$(ev.currentTarget).datepicker('hide'); $(ev.currentTarget).datepicker('hide');
}); });
$(".chzn-select").select2({ $(".chzn-select").select2({ /* {{{ */
width: '100%', width: '100%',
templateResult: chzn_template_func//, templateResult: chzn_template_func
//templateSelection: chzn_template_func }); /* }}} */
});
$(".chzn-select-folder").select2({ /* {{{ */
theme: "bootstrap4",
width: 'resolve',
debug: false,
ajax: {
url: seeddms_webroot+"op/op.Ajax.php",
delay: 500,
data: function (params) {
var query = {
query: params.term,
command: 'searchfolder',
format: 'select2'
}
// Query parameters will be ?search=[term]&command=folderlist
return query;
},
processResults: function(data) {
$.map(data.results, function (obj) {obj.text = obj.name || obj.text; obj.subtitle = obj.path || obj.subtitle; return obj; });
return {
results: data.results
};
},
dataType: 'json'
},
templateResult: chzn_template_func
}); /* }}} */
/* change the color and length of the bar graph showing the password /* change the color and length of the bar graph showing the password
* strength on each change to the passwod field. * strength on each change to the passwod field.
@ -307,26 +335,27 @@ function initMost() {
return this return this
} }
}); /* }}} */ }); /* }}} */
} } /* }}} */
$(document).ready( function() { $(document).ready( function() {
/* close popovers when clicking somewhere except in the popover or the /* close popovers when clicking somewhere except in the popover or the
* remove icon * remove icon
*/ */
$('html').on('click', function(e) { $('html').on('click', function(e) { /* {{{ */
if (typeof $(e.target).data('original-title') == 'undefined' && !$(e.target).parents().is('.popover.in') && !$(e.target).is('.fa fa-remove')) { if (typeof $(e.target).data('original-title') == 'undefined' && !$(e.target).parents().is('.popover.in') && !$(e.target).is('.fa fa-remove')) {
$('[data-original-title]').popover('hide'); $('[data-original-title]').popover('hide');
} }
}); }); /* }}} */
$('body').on('hidden', '.modal', function () { $('body').on('hidden', '.modal', function () { /* {{{ */
$(this).removeData('modal'); $(this).removeData('modal');
}); }); /* }}} */
$('body').on('click', '[data-toggle="modal"]', function(ev){
$('body').on('click', '[data-toggle="modal"]', function(ev){ /* {{{ */
/* Also set the title */ /* Also set the title */
if($(this).data("modal-title")) if($(this).data("modal-title"))
$($(this).data("target")+' .modal-header h3').html($(this).data("modal-title")); $($(this).data("target")+' .modal-header h3').html($(this).data("modal-title"));
}); }); /* }}} */
$('body').on('touchstart.dropdown', '.dropdown-menu', function (e) { e.stopPropagation(); }); $('body').on('touchstart.dropdown', '.dropdown-menu', function (e) { e.stopPropagation(); });
@ -584,6 +613,7 @@ $(document).ready( function() {
var query = element.data('query'); var query = element.data('query');
var afterload = $(this).data('afterload'); var afterload = $(this).data('afterload');
var updatemsg = element.data('update-msg'); var updatemsg = element.data('update-msg');
var runinit = true;
if(view && action) { if(view && action) {
url = seeddms_webroot+base+"out/out."+view+".php?action="+action; url = seeddms_webroot+base+"out/out."+view+".php?action="+action;
if(query) { if(query) {
@ -595,6 +625,8 @@ $(document).ready( function() {
for(var key in param1) { for(var key in param1) {
if(key == 'callback') if(key == 'callback')
callback = param1[key]; callback = param1[key];
else if(key == 'noinit')
runinit = !param1[key];
else { else {
if($.isArray(param1[key])) { if($.isArray(param1[key])) {
if(param1[key].length > 0) if(param1[key].length > 0)
@ -621,7 +653,9 @@ $(document).ready( function() {
func(); func();
} }
} }
initMost(); if(runinit) {
initMost();
}
SeedDMSAjax.run(view, action); SeedDMSAjax.run(view, action);
}); });
}); /* }}} */ }); /* }}} */

View File

@ -103,9 +103,11 @@ class SeedDMS_Theme_Style extends SeedDMS_View_Common {
echo "<!DOCTYPE html>\n"; echo "<!DOCTYPE html>\n";
echo "<html lang=\""; echo "<html lang=\"";
if(!empty($this->params['session']) && ($slang = $this->params['session']->getLanguage())) { if(!empty($this->params['session']) && ($slang = $this->params['session']->getLanguage())) {
echo str_replace('_', '-', $slang); echo substr($slang, 0, 2);
// echo str_replace('_', '-', $slang);
} else { } else {
echo str_replace('_', '-', $this->params['settings']->_language); echo substr($this->params['settings']->_language, 0, 2);
// echo str_replace('_', '-', $this->params['settings']->_language);
} }
echo "\">\n<head>\n"; echo "\">\n<head>\n";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n"; echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
@ -218,7 +220,7 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
$this->addFooterJS('SeedDMSTask.run();'); $this->addFooterJS('SeedDMSTask.run();');
} }
if($this->params['enabledropfolderlist'] && isset($this->params['user']) && $this->params['user']) { if($this->params['enabledropfolderlist'] && isset($this->params['user']) && $this->params['user']) {
$this->addFooterJS("SeedDMSTask.add({name: 'dropfolder', interval: 30, func: function(){\$('#menu-dropfolder > div.ajax').trigger('update', {folderid: seeddms_folder});}});"); $this->addFooterJS("SeedDMSTask.add({name: 'dropfolder', interval: 30, func: function(){\$('#menu-dropfolder > div.ajax').trigger('update', {folderid: seeddms_folder, noinit: true});}});");
} }
if($this->footerjs) { if($this->footerjs) {
$jscode = "$(document).ready(function () {\n"; $jscode = "$(document).ready(function () {\n";

View File

@ -278,6 +278,9 @@ a.accordion2-toggle:focus, a.accordion2-toggle:hover {
.select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice { .select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice {
border-radius: 0px; border-radius: 0px;
} }
.select2-results__option span i {
font-size: 80%;
}
.datepicker { .datepicker {
border-radius: 0px; border-radius: 0px;
} }

View File

@ -4,8 +4,10 @@
* will receive an unescaped string * will receive an unescaped string
* (see https://forums.select2.org/t/propperly-escape-option-value-to-prevent-xss/788) * (see https://forums.select2.org/t/propperly-escape-option-value-to-prevent-xss/788)
*/ */
chzn_template_func = function (state) { chzn_template_func = function (state) { /* {{{ */
var subtitle = ''; var subtitle = '';
if(state.subtitle)
subtitle = state.subtitle;
if($(state.element).data('subtitle')) if($(state.element).data('subtitle'))
subtitle = $(state.element).data('subtitle')+''; /* make sure it is a string */ subtitle = $(state.element).data('subtitle')+''; /* make sure it is a string */
var warning = ''; var warning = '';
@ -24,9 +26,9 @@ chzn_template_func = function (state) {
html += '</span>'; html += '</span>';
var $newstate = $(html); var $newstate = $(html);
return $newstate; return $newstate;
}; }; /* }}} */
function escapeHtml(text) { function escapeHtml(text) { /* {{{ */
var map = { var map = {
'&': '&amp;', '&': '&amp;',
'<': '&lt;', '<': '&lt;',
@ -36,7 +38,7 @@ function escapeHtml(text) {
}; };
return text.replace(/[&<>"']/g, function(m) { return map[m]; }); return text.replace(/[&<>"']/g, function(m) { return map[m]; });
} } /* }}} */
/** /**
* Format bytes as human-readable text. * Format bytes as human-readable text.
@ -48,7 +50,7 @@ function escapeHtml(text) {
* *
* @return Formatted string. * @return Formatted string.
*/ */
function formatFileSize(bytes, si=false, dp=1) { function formatFileSize(bytes, si=false, dp=1) { /* {{{ */
const thresh = si ? 1000 : 1024; const thresh = si ? 1000 : 1024;
if (Math.abs(bytes) < thresh) { if (Math.abs(bytes) < thresh) {
@ -68,7 +70,7 @@ function formatFileSize(bytes, si=false, dp=1) {
return bytes.toFixed(dp) + ' ' + units[u]; return bytes.toFixed(dp) + ' ' + units[u];
} } /* }}} */
function treeFolderSelected(formid, nodeid, nodename) { function treeFolderSelected(formid, nodeid, nodename) {
$('#'+formid).val(nodeid); $('#'+formid).val(nodeid);
@ -82,7 +84,7 @@ function treeDocumentSelected(formid, nodeid, nodename) {
$('#docChooser'+formid).modal('hide'); $('#docChooser'+formid).modal('hide');
} }
function initMost() { function initMost() { /* {{{ */
$('.datepicker, #expirationdate, #createstartdate, #createenddate, #expirationstartdate, #expirationenddate') $('.datepicker, #expirationdate, #createstartdate, #createenddate, #expirationstartdate, #expirationenddate')
.datepicker({todayHighlight: true, toggleActive: true, autoclose: "true", zIndexOffset: "1040"}) .datepicker({todayHighlight: true, toggleActive: true, autoclose: "true", zIndexOffset: "1040"})
/* /*
@ -94,12 +96,38 @@ function initMost() {
}); });
*/ */
$(".chzn-select").select2({ $(".chzn-select").select2({ /* {{{ */
theme: "bootstrap4", theme: "bootstrap4",
width: 'resolve', width: 'resolve',
templateResult: chzn_template_func//, debug: false,
//templateSelection: chzn_template_func templateResult: chzn_template_func
}); }); /* }}} */
$(".chzn-select-folder").select2({ /* {{{ */
theme: "bootstrap4",
width: 'resolve',
ajax: {
url: seeddms_webroot+"op/op.Ajax.php",
delay: 500,
data: function (params) {
var query = {
query: params.term,
command: 'searchfolder',
format: 'select2'
}
// Query parameters will be ?search=[term]&command=folderlist
return query;
},
processResults: function(data) {
$.map(data.results, function (obj) {obj.text = obj.name || obj.text; obj.subtitle = obj.path || obj.subtitle; return obj; });
return {
results: data.results
};
},
dataType: 'json'
},
templateResult: chzn_template_func
}); /* }}} */
/* change the color and length of the bar graph showing the password /* change the color and length of the bar graph showing the password
* strength on each change to the passwod field. * strength on each change to the passwod field.
@ -319,10 +347,10 @@ function initMost() {
return this return this
} }
}); /* }}} */ }); /* }}} */
} } /* }}} */
$(document).ready( function() { $(document).ready( function() {
$('body').on('click', '.dropdown-menu a.dropdown-toggle', function (e) { $('body').on('click', '.dropdown-menu a.dropdown-toggle', function (e) { /* {{{ */
if (!$(this).next().hasClass('show')) { if (!$(this).next().hasClass('show')) {
$(this).parents('.dropdown-menu').first().find('.show').removeClass("show"); $(this).parents('.dropdown-menu').first().find('.show').removeClass("show");
} }
@ -336,33 +364,33 @@ $(document).ready( function() {
return false; return false;
}); }); /* }}} */
/* close popovers when clicking somewhere except in the popover or the /* close popovers when clicking somewhere except in the popover or the
* remove icon * remove icon
*/ */
$('html').on('click', function(e) { $('html').on('click', function(e) { /* {{{ */
if (typeof $(e.target).data('original-title') == 'undefined' && !$(e.target).parents().is('.popover.in') && !$(e.target).is('.fa fa-remove')) { if (typeof $(e.target).data('original-title') == 'undefined' && !$(e.target).parents().is('.popover.in') && !$(e.target).is('.fa fa-remove')) {
$('[data-original-title]').popover('hide'); $('[data-original-title]').popover('hide');
} }
}); }); /* }}} */
$('body').on('hidden', '.modal', function () { $('body').on('hidden', '.modal', function () { /* {{{ */
$(this).removeData('modal'); $(this).removeData('modal');
}); }); /* }}} */
/* Bootstrap 4 does not support to the remote loading of the modal content /* Bootstrap 4 does not support to the remote loading of the modal content
* anymore. This adds it by using jquery. * anymore. This adds it by using jquery.
*/ */
$('body').on('click', '[data-toggle="modal"]', function(ev){ $('body').on('click', '[data-toggle="modal"]', function(ev){ /* {{{ */
ev.preventDefault(); ev.preventDefault();
$($(this).data("target")+' .modal-body').load($(this).data("remote")); $($(this).data("target")+' .modal-body').load($(this).data("remote"));
/* Also set the title */ /* Also set the title */
if($(this).data("modal-title")) if($(this).data("modal-title"))
$($(this).data("target")+' .modal-header h3').html($(this).data("modal-title")); $($(this).data("target")+' .modal-header h3').html($(this).data("modal-title"));
}); }); /* }}} */
$('body').on('click', '.show-hide-password a', function(ev){ $('body').on('click', '.show-hide-password a', function(ev) { /* {{{ */
ev.preventDefault(); ev.preventDefault();
// console.log($(this).closest('input')); // console.log($(this).closest('input'));
// console.log($(ev.target).parent().parent().children('input')); // console.log($(ev.target).parent().parent().children('input'));
@ -375,7 +403,7 @@ $(document).ready( function() {
$('.show-hide-password i').removeClass( "fa-eye-slash" ); $('.show-hide-password i').removeClass( "fa-eye-slash" );
$('.show-hide-password i').addClass( "fa-eye" ); $('.show-hide-password i').addClass( "fa-eye" );
} }
}); }); /* }}} */
// $('body').on('touchstart.dropdown', '.dropdown-menu', function (e) { e.stopPropagation(); }); // $('body').on('touchstart.dropdown', '.dropdown-menu', function (e) { e.stopPropagation(); });
@ -633,6 +661,7 @@ $(document).ready( function() {
var query = element.data('query'); var query = element.data('query');
var afterload = $(this).data('afterload'); var afterload = $(this).data('afterload');
var updatemsg = element.data('update-msg'); var updatemsg = element.data('update-msg');
var runinit = true;
if(view && action) { if(view && action) {
url = seeddms_webroot+base+"out/out."+view+".php?action="+action; url = seeddms_webroot+base+"out/out."+view+".php?action="+action;
if(query) { if(query) {
@ -644,6 +673,8 @@ $(document).ready( function() {
for(var key in param1) { for(var key in param1) {
if(key == 'callback') if(key == 'callback')
callback = param1[key]; callback = param1[key];
else if(key == 'noinit')
runinit = !param1[key];
else { else {
if($.isArray(param1[key])) { if($.isArray(param1[key])) {
if(param1[key].length > 0) if(param1[key].length > 0)
@ -670,7 +701,9 @@ $(document).ready( function() {
func(); func();
} }
} }
initMost(); if(runinit) {
initMost();
}
SeedDMSAjax.run(view, action); SeedDMSAjax.run(view, action);
}); });
}); /* }}} */ }); /* }}} */