]> git.joonet.de Git - adminer.git/commitdiff
Move inline event handlers to <script>
authorJakub Vrana <jakub@vrana.cz>
Fri, 12 Jan 2018 17:34:19 +0000 (18:34 +0100)
committerJakub Vrana <jakub@vrana.cz>
Fri, 12 Jan 2018 17:34:19 +0000 (18:34 +0100)
adminer/db.inc.php
adminer/include/design.inc.php
adminer/include/editing.inc.php
adminer/static/editing.js

index 0db84e26c936f76c7bf7cffefffe53ff9b235fb8..55f64bd91b749fe1088f9ac0d8a388476803efcf 100644 (file)
@@ -67,7 +67,8 @@ if ($adminer->homepage()) {
                        $doc_link = doc_link(array('sql' => 'show-table-status.html'));
                        echo "<table cellspacing='0' class='nowrap checkable'>\n";
                        echo script("mixin(qsl('table'), {onclick: tableClick, ondblclick: partialArg(tableClick, true)});");
-                       echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck.call(this, /^(tables|views)\[/);" class="jsonly">';
+                       echo '<thead><tr class="wrap">';
+                       echo '<td><input id="check-all" type="checkbox" class="jsonly">' . script("qs('#check-all').onclick = partial(formCheck, /^(tables|views)\[/);", "");
                        echo '<th>' . lang('Table');
                        echo '<td>' . lang('Engine') . doc_link(array('sql' => 'storage-engines.html'));
                        echo '<td>' . lang('Collation') . doc_link(array('sql' => 'charset-mysql.html'));
index 02ba9265f025a36a9b14542437d63da0a20f3f8b..705e101a1a844479763bb6f1d0552817d5c8d10d 100644 (file)
@@ -39,7 +39,8 @@ document.body.className = document.body.className.replace(/ nojs/, ' js');
 var offlineMessage = '<?php echo js_escape(lang('You are offline.')); ?>';
 </script>
 
-<div id="help" class="jush-<?php echo $jush; ?> jsonly hidden" onmouseover="helpOpen = 1;" onmouseout="helpMouseout.call(this, event);"></div>
+<div id="help" class="jush-<?php echo $jush; ?> jsonly hidden"></div>
+<?php echo script("mixin(qs('#help'), {onmouseover: function () { helpOpen = 1; }, onmouseout: helpMouseout});"); ?>
 
 <div id="content">
 <?php
index 1e30c48a20d2b02d957d886e09fb477b3b39d1de..40b2274fd79446dd8a217b4cee15c24999411c6d 100644 (file)
@@ -141,7 +141,7 @@ function edit_type($key, $field, $collations, $foreign_keys = array()) {
        global $structured_types, $types, $unsigned, $on_actions;
        $type = $field["type"];
        ?>
-<td><select name="<?php echo h($key); ?>[type]" class="type" onfocus="lastType = selectValue(this);" onchange="editingTypeChange(this);" aria-labelledby="label-type"><?php
+<td><select name="<?php echo h($key); ?>[type]" class="type" aria-labelledby="label-type"><?php
 if ($type && !isset($types[$type]) && !isset($foreign_keys[$type])) {
        array_unshift($structured_types, $type);
 }
@@ -151,7 +151,8 @@ if ($foreign_keys) {
 echo optionlist($structured_types, $type);
 ?></select>
 <?php echo on_help("getTarget(event).value", 1); ?>
-<td><input name="<?php echo h($key); ?>[length]" value="<?php echo h($field["length"]); ?>" size="3" onfocus="editingLengthFocus.call(this);"<?php echo (!$field["length"] && preg_match('~var(char|binary)$~', $type) ? " class='required'" : ""); ?> onchange="editingLengthChange.call(this);" onkeyup="this.onchange();" aria-labelledby="label-length"><td class="options"><?php //! type="number" with enabled JavaScript
+<?php echo script("mixin(qsl('select'), {onfocus: function () { lastType = selectValue(this); }, onchange: editingTypeChange});"); ?>
+<td><input name="<?php echo h($key); ?>[length]" value="<?php echo h($field["length"]); ?>" size="3"<?php echo (!$field["length"] && preg_match('~var(char|binary)$~', $type) ? " class='required'" : ""); ?> aria-labelledby="label-length"><?php echo script("mixin(qsl('input'), {onfocus: editingLengthFocus, onchange: editingLengthChange, onkeyup: function () { this.onchange(); }});", ""); ?><td class="options"><?php //! type="number" with enabled JavaScript
        echo "<select name='" . h($key) . "[collation]'" . (preg_match('~(char|text|enum|set)$~', $type) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';
        echo ($unsigned ? "<select name='" . h($key) . "[unsigned]'" . (!$type || preg_match('~((^|[^o])int|float|double|decimal)$~', $type) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '');
        echo (isset($field['on_update']) ? "<select name='" . h($key) . "[on_update]'" . (preg_match('~timestamp|datetime~', $type) ? "" : " class='hidden'") . '>' . optionlist(array("" => "(" . lang('ON UPDATE') . ")", "CURRENT_TIMESTAMP"), $field["on_update"]) . '</select>' : '');
@@ -240,7 +241,7 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
 <thead><tr class="wrap">
 <?php if ($type == "PROCEDURE") { ?><td>&nbsp;<?php } ?>
 <th id="label-name"><?php echo ($type == "TABLE" ? lang('Column name') : lang('Parameter name')); ?>
-<td id="label-type"><?php echo lang('Type'); ?><textarea id="enum-edit" rows="4" cols="12" wrap="off" style="display: none;" onblur="editingLengthBlur.call(this);"></textarea>
+<td id="label-type"><?php echo lang('Type'); ?><textarea id="enum-edit" rows="4" cols="12" wrap="off" style="display: none;"></textarea><?php echo script("qs('#enum-edit').onblur = editingLengthBlur;"); ?>
 <td id="label-length"><?php echo lang('Length'); ?>
 <td><?php echo lang('Options'); /* no label required, options have their own label */ ?>
 <?php if ($type == "TABLE") { ?>
@@ -256,8 +257,9 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
 <?php } ?>
 <td><?php echo "<input type='image' class='icon' name='add[" . (support("move_col") ? 0 : count($fields)) . "]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'>" . script("row_count = " . count($fields) . ";"); ?>
 </thead>
-<tbody onkeydown="return editingKeydown(event);">
+<tbody>
 <?php
+       echo script("qsl('tbody').onkeydown = editingKeydown;");
        foreach ($fields as $i => $field) {
                $i++;
                $orig = $field[($_POST ? "orig" : "field")];
index 98108f5004f72db85ade992190cc64abcadaa286..56441fea7f5d129288ccfbb8f3bd0fd099048298 100644 (file)
@@ -287,9 +287,10 @@ function editingMoveRow(dir){
 var lastType = '';
 
 /** Clear length and hide collation or unsigned
-* @param HTMLSelectElement
+* @this HTMLSelectElement
 */
-function editingTypeChange(type) {
+function editingTypeChange() {
+       var type = this;
        var name = type.name.substr(0, type.name.length - 6);
        var text = selectValue(type);
        for (var i=0; i < type.form.elements.length; i++) {