document/folder chooser even works for forms not named 'form1'

This commit is contained in:
Uwe Steinmann 2014-07-07 15:45:24 +02:00
parent eb909aa100
commit cc61505825
2 changed files with 8 additions and 9 deletions

View File

@ -74,7 +74,6 @@ $(document).ready( function() {
/* Document chooser */
$("[id^=choosedocsearch]").typeahead({
minLength: 3,
formname: 'form1',
source: function(query, process) {
// console.log(this.options);
$.get('../op/op.Ajax.php', { command: 'searchdocument', query: query, limit: 8 }, function(data) {
@ -86,8 +85,8 @@ $(document).ready( function() {
* we use it to update a second input field with the doc id. */
updater: function (item) {
strarr = item.split("#");
//console.log(this.options.formname);
$('#docid' + this.options.formname).attr('value', strarr[0]);
target = this.$element.data('target');
$('#'+target).attr('value', strarr[0]);
return strarr[1];
},
/* Set a matcher that allows any returned value */
@ -103,7 +102,6 @@ $(document).ready( function() {
/* Folder chooser */
$("[id^=choosefoldersearch]").typeahead({
minLength: 3,
formname: 'form1',
source: function(query, process) {
// console.log(this.options);
$.get('../op/op.Ajax.php', { command: 'searchfolder', query: query, limit: 8 }, function(data) {
@ -115,8 +113,9 @@ $(document).ready( function() {
* it to set the document location. */
updater: function (item) {
strarr = item.split("#");
//console.log(this.options.formname);
$('#targetid' + this.options.formname).attr('value', strarr[0]);
//console.log(this.$element.data('target'));
target = this.$element.data('target');
$('#'+target).attr('value', strarr[0]);
return strarr[1];
},
/* Set a matcher that allows any returned value */

View File

@ -889,9 +889,9 @@ $(document).ready(function () {
} /* }}} */
function printDocumentChooser($formName) { /* {{{ */
print "<input type=\"hidden\" id=\"docid".$formName."\" name=\"docid\">";
print "<input type=\"hidden\" id=\"docid".$formName."\" name=\"docid\" value=\"\">";
print "<div class=\"input-append\">\n";
print "<input type=\"text\" id=\"choosedocsearch\" data-provide=\"typeahead\" name=\"docname".$formName."\" placeholder=\"".getMLText('type_to_search')."\" autocomplete=\"off\" />";
print "<input type=\"text\" id=\"choosedocsearch\" data-target=\"docid".$formName."\" data-provide=\"typeahead\" name=\"docname".$formName."\" placeholder=\"".getMLText('type_to_search')."\" autocomplete=\"off\" />";
print "<a data-target=\"#docChooser".$formName."\" href=\"out.DocumentChooser.php?form=".$formName."&folderid=".$this->params['rootfolderid']."\" role=\"button\" class=\"btn\" data-toggle=\"modal\">".getMLText("document")."…</a>\n";
print "</div>\n";
?>
@ -923,7 +923,7 @@ function folderSelected<?php echo $formName ?>(id, name) {
function printFolderChooser($formName, $accessMode, $exclude = -1, $default = false) { /* {{{ */
print "<input type=\"hidden\" id=\"targetid".$formName."\" name=\"targetid".$formName."\" value=\"". (($default) ? $default->getID() : "") ."\">";
print "<div class=\"input-append\">\n";
print "<input type=\"text\" id=\"choosefoldersearch".$formName."\" data-provide=\"typeahead\" name=\"targetname".$formName."\" value=\"". (($default) ? htmlspecialchars($default->getName()) : "") ."\" placeholder=\"".getMLText('type_to_search')."\" autocomplete=\"off\" />";
print "<input type=\"text\" id=\"choosefoldersearch".$formName."\" data-target=\"targetid".$formName."\" data-provide=\"typeahead\" name=\"targetname".$formName."\" value=\"". (($default) ? htmlspecialchars($default->getName()) : "") ."\" placeholder=\"".getMLText('type_to_search')."\" autocomplete=\"off\" />";
print "<a data-target=\"#folderChooser".$formName."\" href=\"../out/out.FolderChooser.php?form=".$formName."&mode=".$accessMode."&exclude=".$exclude."\" role=\"button\" class=\"btn\" data-toggle=\"modal\">".getMLText("folder")."…</a>\n";
print "</div>\n";
?>