modules/system/assets/toolbox/controls/input/README.md
Allows keyboard shortcuts (hotkeys) to be bound to an element's click event.
<button
class="btn btn-default"
data-hotkey="b"
onclick="alert('B is for Banana!')">
Press "B" on your keyboard
</button>
<button
class="btn btn-default"
data-hotkey="shift+r"
onclick="confirm('Shift gears...?')">
Press "Shift + R" on your keyboard
</button>
If you use a selector other than a button or a link, you will need to add the hotkeyVisible property to the hotkey config.
$('html').hotKey({
hotkey: 'ctrl+s, cmd+s',
hotkeyVisible: false,
callback: doSomething
});
This will monitor the user input for unsaved changes and show a confirmation box if the user attempts to leave the page. The script adds the "oc-data-changed" class to the form element when the form data is changed.
<form data-change-monitor>
...
</form>
Click the "Mark changed" button and "Reload page".
<form data-change-monitor>
<button type="button" onclick="$(this).trigger('change')">
Mark Changed
</button>
<button type="button" data-change-monitor-commit>
Mark Saved
</button>
<hr />
<button type="button" onclick="window.location.reload()">
Reload Page
</button>
</form>
$('#form').changeMonitor()
Scripts that manage user input events.
<input type="text" id="presetExample1" placeholder="Type something" />
<input type="text"
data-input-preset="#presetExample1"
placeholder="Watch here"
disabled />
The API allows to change elements' visibility or status (enabled/disabled) basing on other elements' statuses. Example: enable a button if any checkbox inside another element is checked.
<input type="checkbox" id="triggerChk1" />
<button class="btn disabled"
data-trigger-action="enable"
data-trigger="#triggerChk1"
data-trigger-condition="checked">
Check the checkbox
</button>
<p>
<input
type="text"
id="triggerTxt1"
value=""
onkeyup="$(this).trigger('change')"
placeholder="Enter 'foo' or 'bar' here"
class="form-control" />
</p>
<div
class="callout callout-success"
data-trigger-action="show"
data-trigger="#triggerTxt1"
data-trigger-condition="value[foo][bar]">
<div class="content">
Passphrase is valid!
</div>
</div>
Example code:
<input type="button" class="btn disabled"
data-trigger-action="enable"
data-trigger="#cblist input[type=checkbox]"
data-trigger-condition="checked" ... >
Multiple actions are supported:
data-trigger-action="hide|empty"
Multiple value conditions are supported:
data-trigger-condition="value[foo][bar]"
$('#mybutton').triggerOn({
triggerCondition: 'checked',
trigger: '#cblist input[type=checkbox]',
triggerAction: 'enable'
})