From cc6150582574f3afacfcc50f5fb0f235d37979bc Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 7 Jul 2014 15:45:24 +0200 Subject: [PATCH] document/folder chooser even works for forms not named 'form1' --- styles/bootstrap/application.js | 11 +++++------ views/bootstrap/class.Bootstrap.php | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/styles/bootstrap/application.js b/styles/bootstrap/application.js index e601c0def..0b42439fa 100644 --- a/styles/bootstrap/application.js +++ b/styles/bootstrap/application.js @@ -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 */ diff --git a/views/bootstrap/class.Bootstrap.php b/views/bootstrap/class.Bootstrap.php index d06ab8102..c1478a012 100644 --- a/views/bootstrap/class.Bootstrap.php +++ b/views/bootstrap/class.Bootstrap.php @@ -889,9 +889,9 @@ $(document).ready(function () { } /* }}} */ function printDocumentChooser($formName) { /* {{{ */ - print ""; + print ""; print "
\n"; - print ""; + print ""; print "params['rootfolderid']."\" role=\"button\" class=\"btn\" data-toggle=\"modal\">".getMLText("document")."…\n"; print "
\n"; ?> @@ -923,7 +923,7 @@ function folderSelected(id, name) { function printFolderChooser($formName, $accessMode, $exclude = -1, $default = false) { /* {{{ */ print "getID() : "") ."\">"; print "
\n"; - print "getName()) : "") ."\" placeholder=\"".getMLText('type_to_search')."\" autocomplete=\"off\" />"; + print "getName()) : "") ."\" placeholder=\"".getMLText('type_to_search')."\" autocomplete=\"off\" />"; print "".getMLText("folder")."…\n"; print "
\n"; ?>