Skip to content

Commit

Permalink
Ref #13270 - remove inline events
Browse files Browse the repository at this point in the history
add handlers to registerTeardown & move some events to database/search.js

Signed-Off-By: Thomas Heinrichs <thheinrichs@outlook.de>
  • Loading branch information
Thomas1664 authored and williamdes committed Feb 16, 2021
1 parent c1a66ad commit dfe2fd5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
11 changes: 11 additions & 0 deletions js/src/database/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ AJAX.registerTeardown('database/search.js', function () {
$('#togglesearchresultlink').off('click');
$('#togglequerybox').off('click');
$('#togglesearchformlink').off('click');
$('#select_all').off('click');
$('#unselect_all').off('click');
$(document).off('submit', '#db_search_form.ajax');
});

Expand Down Expand Up @@ -244,4 +246,13 @@ AJAX.registerOnload('database/search.js', function () {
Functions.ajaxRemoveMessage($msgbox);
});
});

$('#select_all').on('click', function () {
Functions.setSelectOptions('db_search', 'criteriaTables[]', true);
return false;
});
$('#unselect_all').on('click', function () {
Functions.setSelectOptions('db_search', 'criteriaTables[]', false);
return false;
});
}); // end $()
6 changes: 6 additions & 0 deletions js/src/sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/* global codeMirrorEditor */ // js/functions.js
/* global MicroHistory */ // js/microhistory.js
/* global makeGrid */ // js/makegrid.js
/* global sqlBoxLocked */ // js/functions.js

var Sql = {};

Expand Down Expand Up @@ -213,6 +214,7 @@ AJAX.registerTeardown('sql.js', function () {
$('body').off('keyup', '#sqlqueryform');
$('body').off('click', 'form[name="resultsForm"].ajax button[name="submit_mult"], form[name="resultsForm"].ajax input[name="submit_mult"]');
$(document).off('submit', '#maxRowsForm');
$(document).off('click', '#view_as');
});

/**
Expand Down Expand Up @@ -869,6 +871,10 @@ AJAX.registerOnload('sql.js', function () {
$('#insertBtn').on('click', function () {
Functions.insertValueQuery();
});

$('#view_as').on('click', function () {
Functions.selectContent(this, sqlBoxLocked, true);
});
}); // end $()

/**
Expand Down
4 changes: 2 additions & 2 deletions templates/database/search/main.twig
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
<fieldset class="pma-fieldset">
<legend>{% trans 'Inside tables:' %}</legend>
<p>
<a href="#" onclick="Functions.setSelectOptions('db_search', 'criteriaTables[]', true); return false;">
<a href="#" id="select_all">
{% trans 'Select all' %}
</a> /
<a href="#" onclick="Functions.setSelectOptions('db_search', 'criteriaTables[]', false); return false;">
<a href="#" id="unselect_all">
{% trans 'Unselect all' %}
</a>
</p>
Expand Down
2 changes: 1 addition & 1 deletion templates/view_create.twig
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<tr>
<td class="text-nowrap">AS</td>
<td>
<textarea name="view[as]" rows="15" cols="40" dir="{{ text_dir }}" onclick="Functions.selectContent(this, sqlBoxLocked, true)">{{ view['as'] }}</textarea><br>
<textarea name="view[as]" id="view_as" rows="15" cols="40" dir="{{ text_dir }}">{{ view['as'] }}</textarea><br>
<input type="button" value="Format" id="format" class="btn btn-secondary button sqlbutton">
<span id="querymessage"></span>
</td>
Expand Down

0 comments on commit dfe2fd5

Please sign in to comment.