Skip to content

Commit

Permalink
Fix: Add option to disable for touch devices (fixes #4)
Browse files Browse the repository at this point in the history
  • Loading branch information
swashbuck authored Jul 5, 2023
1 parent 0cdef38 commit f238ebb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ An extension to inspect details of elements.
* Add the following to `config.json`:
```json
"_inspector": {
"_isEnabled": true
"_isEnabled": true
}
```
* Optionally, reference the [example JSON](example.json) to make Inspector link to a specific [Trac](https://trac.edgewall.org).
* Optionally, reference the [example JSON](example.json) to make Inspector link to a specific [Trac](https://trac.edgewall.org) or to disable Inspector on touch devices.
* With [Adapt CLI](https://github.com/adaptlearning/adapt-cli) installed, run `adapt install inspector`. Alternatively, download the ZIP and extract into the src > extensions directory.
* Run an appropriate Grunt task.

Expand All @@ -35,6 +35,12 @@ An extension to inspect details of elements.
<td>Enable Inspector globally</td>
<td><code>false</code></td>
</tr>
<tr>
<td colspan="2"><code>_isDisabledOnTouch</code></td>
<td>Boolean</td>
<td>Disable Inspector on touch devices</td>
<td><code>true</code></td>
</tr>
<tr>
<td rowspan="3"><code>_trac</code></td>
<td><code>_isEnabled</code></td>
Expand Down
1 change: 1 addition & 0 deletions example.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"_inspector": {
"_isEnabled": true,
"_isDisabledOnTouch": true,
"_trac": {
"_isEnabled": false,
"_url": "",
Expand Down
8 changes: 7 additions & 1 deletion js/adapt-inspector.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
define([ 'core/js/adapt' ], function(Adapt) {
define([
'core/js/adapt',
'core/js/device'
], function(Adapt, device) {

const InspectorView = Backbone.View.extend({

Expand All @@ -7,6 +10,9 @@ define([ 'core/js/adapt' ], function(Adapt) {
ids: [],

initialize: function() {
const config = Adapt.config.get('_inspector');
if (device.touch && config._isDisabledOnTouch) return;

this.listenTo(Adapt, {
'inspector:id': this.pushId,
'inspector:hover': this.setVisibility,
Expand Down
6 changes: 6 additions & 0 deletions properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
"inputType": "Checkbox",
"help": "Adds visible element IDs on hover. Also useful for Kineo employees with internal access to file issues in TRAC."
},
"_isDisabledOnTouch": {
"type": "boolean",
"default": true,
"title": "Disable Inspector on touch devices",
"inputType": "Checkbox"
},
"_trac": {
"type": "object",
"title": "Trac",
Expand Down
5 changes: 5 additions & 0 deletions schema/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
"description": "Adds visible element IDs on hover. Also useful for Kineo employees with internal access to file issues in TRAC.",
"default": false
},
"_isDisabledOnTouch": {
"type": "boolean",
"title": "Disable Inspector on touch devices",
"default": true
},
"_trac": {
"type": "object",
"title": "Trac",
Expand Down

0 comments on commit f238ebb

Please sign in to comment.