From fd21cb10b6b8aad800b4ac15317eebc24c37b33c Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Thu, 21 May 2015 16:25:01 -0500 Subject: [PATCH] search: Enter submits the advanced search --- include/class.forms.php | 4 +++- include/class.search.php | 1 + include/staff/templates/advanced-search.tmpl.php | 9 +++++---- include/staff/templates/timezone.tmpl.php | 2 +- scp/js/scp.js | 1 + 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/class.forms.php b/include/class.forms.php index be6c35e5b..38cb31ef7 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -2576,6 +2576,8 @@ class TextboxWidget extends Widget { $classes = 'class="'.$config['classes'].'"'; if (isset($config['autocomplete'])) $autocomplete = 'autocomplete="'.($config['autocomplete']?'on':'off').'"'; + if (isset($config['autofocus'])) + $autofocus = 'autofocus'; if (isset($config['disabled'])) $disabled = 'disabled="disabled"'; if (isset($config['translatable']) && $config['translatable']) @@ -2594,7 +2596,7 @@ class TextboxWidget extends Widget { id="<?php echo $this->id; ?>" <?php echo implode(' ', array_filter(array( $size, $maxlength, $classes, $autocomplete, $disabled, - $translatable, $placeholder))); ?> + $translatable, $placeholder, $autofocus))); ?> name="<?php echo $this->name; ?>" value="<?php echo Format::htmlchars($this->value); ?>"/> <?php diff --git a/include/class.search.php b/include/class.search.php index b319b0a58..5caecbd0d 100644 --- a/include/class.search.php +++ b/include/class.search.php @@ -644,6 +644,7 @@ class SavedSearch extends VerySimpleModel { 'configuration' => array( 'size' => 40, 'length' => 400, + 'autofocus' => true, 'classes' => 'full-width headline', 'placeholder' => __('Keywords — Optional'), ), diff --git a/include/staff/templates/advanced-search.tmpl.php b/include/staff/templates/advanced-search.tmpl.php index 57e9a510e..0217be16b 100644 --- a/include/staff/templates/advanced-search.tmpl.php +++ b/include/staff/templates/advanced-search.tmpl.php @@ -56,12 +56,12 @@ foreach ($matches as $name => $fields) { ?> </dt> <dd> <span> - <button onclick="javascript:$(this).closest('form').attr({ + <button type="button" onclick="javascript:$(this).closest('form').attr({ 'method': 'get', 'action': '#tickets/search/<?php echo $S->id; ?>'});"><i class="icon-chevron-left"></i> Load</button> <?php if ($thisstaff->isAdmin()) { ?> <button><i class="icon-bullhorn"></i> <?php echo __('Publish'); ?></button> <?php } ?> - <button onclick="javascript: + <button type="button" onclick="javascript: $.ajax({ url: 'ajax.php/tickets/search/<?php echo $S->id; ?>', type: 'POST', @@ -77,7 +77,7 @@ return false; "><i class="icon-save"></i> <?php echo __('Update'); ?></button> </span> <span class="pull-right"> - <button title="<?php echo __('Delete'); ?>" onclick="javascript: + <button type="button" title="<?php echo __('Delete'); ?>" onclick="javascript: if (!confirm(__('You sure?'))) return false; var that = this; $.ajax({ @@ -142,7 +142,8 @@ return false; <div id="search-hint" class="pull-left"> </div> <div class="buttons pull-right"> - <button class="button" id="do_search"><i class="icon-search"></i> <?php echo __('Search'); ?></button> + <button class="button" type="submit" id="do_search"><i class="icon-search"></i> + <?php echo __('Search'); ?></button> </div> </div> diff --git a/include/staff/templates/timezone.tmpl.php b/include/staff/templates/timezone.tmpl.php index 840940b0c..edc834050 100644 --- a/include/staff/templates/timezone.tmpl.php +++ b/include/staff/templates/timezone.tmpl.php @@ -16,7 +16,7 @@ $TZ_TIMEZONE = @$TZ_TIMEZONE ?: ''; ?>><?php echo str_replace('/',' / ',$zone); ?></option> <?php } ?> </select> - <button class="action-button" onclick="javascript: + <button type="button" class="action-button" onclick="javascript: $('head').append($('<script>').attr('src', '<?php echo ROOT_PATH; ?>js/jstz.min.js')); var recheck = setInterval(function() { diff --git a/scp/js/scp.js b/scp/js/scp.js index e3c36457e..fd1017184 100644 --- a/scp/js/scp.js +++ b/scp/js/scp.js @@ -634,6 +634,7 @@ $.dialog = function (url, codes, cb, options) { queue: false, complete: function() { if (options.onshow) options.onshow(); } }); + $("input[autofocus]:visible:enabled:first", $popup).focus(); var submit_button = null; $(document).off('.dialog'); $(document).on('click.dialog', -- GitLab