mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-16 22:51:32 +00:00
jump right to document/folder in typeahead list
This commit is contained in:
parent
2e21c7c6a0
commit
b18128fef2
|
@ -130,10 +130,22 @@ $(document).ready( function() {
|
||||||
/* updater is called when the item in the list is clicked. It is
|
/* updater is called when the item in the list is clicked. It is
|
||||||
* 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. The passed value is the string
|
* it to set the document location. The passed value is the string
|
||||||
* set in data-value of the list items. */
|
* set in data-value of the list items.
|
||||||
|
* This method relies on some changes in bootstrap-typeahead.js
|
||||||
|
* Originally, update was passed only the data-value of the li item
|
||||||
|
* which is set in the render fuction below,
|
||||||
|
* but the modified version passes all data fields. which also
|
||||||
|
* contain the 'id' and 'type' (also set in render function).
|
||||||
|
**/
|
||||||
updater: function (item) {
|
updater: function (item) {
|
||||||
document.location = "../out/out.Search.php?query=" + encodeURIComponent(item);
|
if(item.id) {
|
||||||
return item;
|
if(item.type == 'D')
|
||||||
|
document.location = "../out/out.ViewDocument.php?documentid=" + item.id;
|
||||||
|
else
|
||||||
|
document.location = "../out/out.ViewFolder.php?folderid=" + item.id;
|
||||||
|
} else
|
||||||
|
document.location = "../out/out.Search.php?query=" + encodeURIComponent(item.value);
|
||||||
|
return item.value;
|
||||||
},
|
},
|
||||||
sorter: function(items) {
|
sorter: function(items) {
|
||||||
return items;
|
return items;
|
||||||
|
@ -144,6 +156,10 @@ $(document).ready( function() {
|
||||||
matcher : function (item) {
|
matcher : function (item) {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
/* highlighter is for modifying the 'a' tag text. It places an icon
|
||||||
|
* in front of the name and replaces a '<' within the name with an
|
||||||
|
* entity.
|
||||||
|
**/
|
||||||
highlighter : function (item) {
|
highlighter : function (item) {
|
||||||
if(item.type.charAt(0) == 'D')
|
if(item.type.charAt(0) == 'D')
|
||||||
return '<i class="fa fa-file"></i> ' + item.name.replace(/</g, '<');
|
return '<i class="fa fa-file"></i> ' + item.name.replace(/</g, '<');
|
||||||
|
@ -164,7 +180,7 @@ $(document).ready( function() {
|
||||||
var that = this
|
var that = this
|
||||||
|
|
||||||
items = $(items).map(function (i, item) {
|
items = $(items).map(function (i, item) {
|
||||||
i = $(that.options.item).attr('data-value', item.name)
|
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))
|
i.find('a').html(that.highlighter(item))
|
||||||
return i[0]
|
return i[0]
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user