mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-13 21:21:27 +00:00
updated folder chooser
This commit is contained in:
parent
f06267dd0b
commit
245bfe640a
|
@ -144,8 +144,8 @@ switch($command) {
|
||||||
$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().'#'.$basefolder->getName().'/'.$hit->getName();
|
// $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, '/')));
|
||||||
}
|
}
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
echo json_encode($result);
|
echo json_encode($result);
|
||||||
|
@ -157,7 +157,8 @@ switch($command) {
|
||||||
$result = array();
|
$result = array();
|
||||||
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, '/')));
|
||||||
}
|
}
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
echo json_encode($result);
|
echo json_encode($result);
|
||||||
|
@ -172,7 +173,8 @@ switch($command) {
|
||||||
$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, '/')));
|
||||||
}
|
}
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
echo json_encode($result);
|
echo json_encode($result);
|
||||||
|
|
|
@ -236,7 +236,7 @@ function initMost() {
|
||||||
/* Folder chooser */
|
/* Folder chooser */
|
||||||
$("[id^=choosefoldersearch]").typeahead({ /* {{{ */
|
$("[id^=choosefoldersearch]").typeahead({ /* {{{ */
|
||||||
menu: '<div class="typeahead dropdown-menu"></div>',
|
menu: '<div class="typeahead dropdown-menu"></div>',
|
||||||
item: '<li><a class="dropdown-item" href="#"></a></li>',
|
item: '<a class="dropdown-item" href="#"></a>',
|
||||||
minLength: 3,
|
minLength: 3,
|
||||||
source: function(query, process) {
|
source: function(query, process) {
|
||||||
// console.log(this.options);
|
// console.log(this.options);
|
||||||
|
@ -248,19 +248,42 @@ function initMost() {
|
||||||
* actually provided to update the input field, but here we use
|
* actually provided to update the input field, but here we use
|
||||||
* it to set the document location. */
|
* it to set the document location. */
|
||||||
updater: function (item) {
|
updater: function (item) {
|
||||||
strarr = item.value.split("#");
|
|
||||||
//console.log(this.$element.data('target'));
|
|
||||||
target = this.$element.data('target');
|
target = this.$element.data('target');
|
||||||
$('#'+target).attr('value', strarr[0]);
|
$('#'+target).attr('value', item.id);
|
||||||
return strarr[1];
|
return item.value;
|
||||||
|
},
|
||||||
|
sorter: function(items) {
|
||||||
|
return items;
|
||||||
},
|
},
|
||||||
/* Set a matcher that allows any returned value */
|
/* Set a matcher that allows any returned value */
|
||||||
matcher : function (item) {
|
matcher : function (item) {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
highlighter : function (item) {
|
highlighter : function (item) {
|
||||||
|
return '<i class="fa fa-folder-o"></i> ' + item.name.replace(/</g, '<') + (typeof(item.path) != 'undefined' ? '<br /><span class="path">' + item.path + '</span>' : '');
|
||||||
strarr = item.split("#");
|
strarr = item.split("#");
|
||||||
return '<i class="fa fa-folder-o"></i> ' + strarr[1].replace(/</g, '<');
|
return '<i class="fa fa-folder-o"></i> ' + strarr[1].replace(/</g, '<');
|
||||||
|
},
|
||||||
|
/* This only works with a modified version of bootstrap typeahead located
|
||||||
|
* in boostrap-typeahead.js Search for 'render'
|
||||||
|
* The line
|
||||||
|
* this.render = this.options.render || this.render
|
||||||
|
* was added to bootstrap-typeahead.js
|
||||||
|
* The following function is a copy of the original render function but
|
||||||
|
* access item.name instead of item
|
||||||
|
*/
|
||||||
|
render : function (items) {
|
||||||
|
var that = this
|
||||||
|
|
||||||
|
items = $(items).map(function (i, item) {
|
||||||
|
i = $(that.options.item).attr('data-value', item.name).attr('data-id', item.id).attr('data-type', item.type);
|
||||||
|
i./*find('a').*/html(that.highlighter(item))
|
||||||
|
return i[0]
|
||||||
|
})
|
||||||
|
|
||||||
|
items.first().addClass('active')
|
||||||
|
this.$menu.html(items)
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
}); /* }}} */
|
}); /* }}} */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user