From f238ebbd2a9db5098f1c079b343163832123a669 Mon Sep 17 00:00:00 2001 From: Brad Simpson Date: Wed, 5 Jul 2023 13:29:03 -0600 Subject: [PATCH] Fix: Add option to disable for touch devices (fixes #4) --- README.md | 10 ++++++++-- example.json | 1 + js/adapt-inspector.js | 8 +++++++- properties.schema | 6 ++++++ schema/config.schema.json | 5 +++++ 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 94b83d4..b355e08 100644 --- a/README.md +++ b/README.md @@ -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. @@ -35,6 +35,12 @@ An extension to inspect details of elements. Enable Inspector globally false + + _isDisabledOnTouch + Boolean + Disable Inspector on touch devices + true + _trac _isEnabled diff --git a/example.json b/example.json index 7771cc9..fadeb61 100644 --- a/example.json +++ b/example.json @@ -1,5 +1,6 @@ "_inspector": { "_isEnabled": true, + "_isDisabledOnTouch": true, "_trac": { "_isEnabled": false, "_url": "", diff --git a/js/adapt-inspector.js b/js/adapt-inspector.js index 7fe0555..d06d10e 100644 --- a/js/adapt-inspector.js +++ b/js/adapt-inspector.js @@ -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({ @@ -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, diff --git a/properties.schema b/properties.schema index bae54f5..ae01076 100644 --- a/properties.schema +++ b/properties.schema @@ -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", diff --git a/schema/config.schema.json b/schema/config.schema.json index a0ed3e6..0b56960 100644 --- a/schema/config.schema.json +++ b/schema/config.schema.json @@ -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",