-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add `onCancel` option to give a function to run when a Cancel action is triggered. fix #13 * Improve doc by fixing a few errors and adding default values and code examples
- Loading branch information
1 parent
6216cb2
commit 6f714c4
Showing
6 changed files
with
162 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,42 +15,51 @@ | |
<body> | ||
|
||
<div class='container-fluid'> | ||
<h1>malle demo page</h1> | ||
<h2>API documentation</h2> | ||
<p>If you are looking for the complete API documentation, with all possible options and interfaces with their description, it is available here: <a href='/malle/api'>full API documentation</a>.</p> | ||
<h2>Minimal example</h2> | ||
<p>The text <span id='minimal' class='fw-bold'>in bold</span> is malleable. Try clicking on it.</p> | ||
<h2>Selecting input type</h2> | ||
<p class='tip'>Use <code>data-ma-type</code> attribute to select the appropriate input type, or set it in the options with <code>inputType</code>.</p> | ||
<p><code>data-ma-type='text'</code><br>This is the default type and doesn't need to be specified. <span data-malleable='true'>Some malleable text.</span></p> | ||
<p><code>data-ma-type='number'</code><br>Click on the number: <span data-malleable='true' data-ma-type='number'>3</span></p> | ||
<p><code>data-ma-type='email'</code><br>Email example: <span data-malleable='true' data-ma-type='email'>[email protected]</span></p> | ||
<p><code>data-ma-type='url'</code><br>Url example: <span data-malleable='true' data-ma-type='url'>https://www.deltablot.com</span></p> | ||
<h3>Select example</h3> | ||
<p>Select example. Here we set <code>inputType: InputType.Select</code> and <code>selectOptions: [{value: '1', text: 'Blah'}]</code> in the options.<br>Best country: <span class='malleableSelect'>France</span></p> | ||
<h3>Textarea example</h3> | ||
<p class='malleableTextarea'>This is a malleable paragraph that will transform into a textarea with action buttons. Settings are defined in JS options here.</p> | ||
<h3>Datetime example</h3> | ||
<p>Using <code>data-ma-type='datetime-local'</code>. Upcoming deadline: <span data-malleable='true' data-ma-type='datetime-local'>2022-07-14T13:37</span>.</p> | ||
<div class='mb-5'> | ||
<h1>malle demo page</h1> | ||
<h2>API documentation</h2> | ||
<p>If you are looking for the complete API documentation, with all possible options and interfaces with their description, it is available here:</p> | ||
<a href='/malle/api'><button class='btn btn-primary'>Complete API documentation</button></a> | ||
<h2>Minimal example</h2> | ||
<p>The text <span id='minimal' class='fw-bold'>in bold</span> is malleable. Try clicking on it.</p> | ||
<h2>Selecting input type</h2> | ||
<p class='tip'>Use <code>data-ma-type</code> attribute to select the appropriate input type, or set it in the options with <code>inputType</code>.</p> | ||
<p><code>data-ma-type='text'</code><br>This is the default type and doesn't need to be specified. <span data-malleable='true'>Some malleable text.</span></p> | ||
<p><code>data-ma-type='number'</code><br>Click on the number: <span data-malleable='true' data-ma-type='number'>3</span></p> | ||
<p><code>data-ma-type='email'</code><br>Email example: <span data-malleable='true' data-ma-type='email'>[email protected]</span></p> | ||
<p><code>data-ma-type='url'</code><br>Url example: <span data-malleable='true' data-ma-type='url'>https://www.deltablot.com</span></p> | ||
<h3>Select example</h3> | ||
<p>Select example. Here we set <code>inputType: InputType.Select</code> and <code>selectOptions: [{value: '1', text: 'Blah'}]</code> in the options.<br>Best country: <span class='malleableSelect'>France</span></p> | ||
<h3>Textarea example</h3> | ||
<p class='malleableTextarea'>This is a malleable paragraph that will transform into a textarea with action buttons. Settings are defined in JS options here.</p> | ||
<h3>Datetime example</h3> | ||
<p>Using <code>data-ma-type='datetime-local'</code>. Upcoming deadline: <span data-malleable='true' data-ma-type='datetime-local'>2022-07-14T13:37</span>.</p> | ||
|
||
<h2>Selecting behavior on blur</h2> | ||
<p class='tip'>Use <code>data-ma-blur</code> attribute to select the appropriate behavior when user clicks outside the input, or set it in the options with <code>onBlur</code>.</p> | ||
<p><code>data-ma-blur='cancel'</code><br><span data-malleable='true' data-ma-blur='cancel'>Clicking outside the input will cancel edition.</span></p> | ||
<p><code>data-ma-blur='submit'</code><br><span data-malleable='true' data-ma-blur='submit'>Clicking outside the input will submit changes.</span></p> | ||
<p><code>data-ma-blur='ignore'</code><br><span data-malleable='true' data-ma-blur='ignore'>Clicking outside the input will do nothing.</span></p> | ||
<h2>Selecting behavior on Enter keypress</h2> | ||
<p class='tip'>Use <code>data-ma-enter</code> attribute to select the appropriate behavior when user presses the Enter key, or set it in the options with <code>onEnter</code>.</p> | ||
<p><code>data-ma-enter='cancel'</code><br><span data-malleable='true' data-ma-enter='cancel'>Pressing Enter will cancel edition.</span></p> | ||
<p><code>data-ma-enter='submit'</code><br><span data-malleable='true' data-ma-enter='submit'>Pressing Enter will submit changes.</span></p> | ||
<p><code>data-ma-enter='ignore'</code><br><span data-malleable='true' data-ma-enter='ignore'>Pressing Enter will do nothing.</span></p> | ||
<h2>Setting behavior for both Blur action and Enter keypress</h2> | ||
<p data-malleable='true' data-ma-enter='submit' data-ma-blur='submit'>This text will submit onBlur and also onEnter.</p> | ||
<h3>Same with Escape keypress</h3> | ||
<p class='tip'>The default behavior is to Cancel action, but here is an example to ignore an Escape keypress:</p> | ||
<p><code>data-ma-escape='ignore'</code><br><span data-malleable='true' data-ma-escape='ignore'>Pressing Escape will do nothing.</span></p> | ||
<p><code>data-ma-escape='cancel'</code><br><span data-malleable='true' data-ma-escape='cancel'>Pressing Escape will cancel edition (default behavior, attribute doesn't need to be added).</span></p> | ||
<h2>Adding a placeholder</h2> | ||
<p><code>data-ma-placeholder='[email protected]'</code><br>Your email is: <span data-malleable='true' data-ma-placeholder='[email protected]' data-ma-type='email'>[email protected]</span></p> | ||
<h2>Selecting behavior on blur</h2> | ||
<p class='tip'>Use <code>data-ma-blur</code> attribute to select the appropriate behavior when user clicks outside the input, or set it in the options with <code>onBlur</code>.</p> | ||
<p><code>data-ma-blur='cancel'</code><br><span data-malleable='true' data-ma-blur='cancel'>Clicking outside the input will cancel edition.</span></p> | ||
<p><code>data-ma-blur='submit'</code><br><span data-malleable='true' data-ma-blur='submit'>Clicking outside the input will submit changes.</span></p> | ||
<p><code>data-ma-blur='ignore'</code><br><span data-malleable='true' data-ma-blur='ignore'>Clicking outside the input will do nothing.</span></p> | ||
<h2>Selecting behavior on Enter keypress</h2> | ||
<p class='tip'>Use <code>data-ma-enter</code> attribute to select the appropriate behavior when user presses the Enter key, or set it in the options with <code>onEnter</code>.</p> | ||
<p><code>data-ma-enter='cancel'</code><br><span data-malleable='true' data-ma-enter='cancel'>Pressing Enter will cancel edition.</span></p> | ||
<p><code>data-ma-enter='submit'</code><br><span data-malleable='true' data-ma-enter='submit'>Pressing Enter will submit changes.</span></p> | ||
<p><code>data-ma-enter='ignore'</code><br><span data-malleable='true' data-ma-enter='ignore'>Pressing Enter will do nothing.</span></p> | ||
<h2>Setting behavior for both Blur action and Enter keypress</h2> | ||
<p data-malleable='true' data-ma-enter='submit' data-ma-blur='submit'>This text will submit onBlur and also onEnter.</p> | ||
<h3>Same with Escape keypress</h3> | ||
<p class='tip'>The default behavior is to Cancel action, but here is an example to ignore an Escape keypress:</p> | ||
<p><code>data-ma-escape='ignore'</code><br><span data-malleable='true' data-ma-escape='ignore'>Pressing Escape will do nothing.</span></p> | ||
<p><code>data-ma-escape='cancel'</code><br><span data-malleable='true' data-ma-escape='cancel'>Pressing Escape will cancel edition (default behavior, attribute doesn't need to be added).</span></p> | ||
<h2>Adding a placeholder</h2> | ||
<p><code>data-ma-placeholder='[email protected]'</code><br>Your email is: <span data-malleable='true' data-ma-placeholder='[email protected]' data-ma-type='email'>[email protected]</span></p> | ||
<h2>Running a function when the Cancel button is pressed</h2> | ||
<p>The <code>onCancel</code> function will run when an <code>Action.Cancel</code> action is triggered, like clicking the Cancel button. It must return <code>true</code> for the input to be reverted to the original element. | ||
<a href='https://deltablot.github.io/malle/api/interfaces/Options.html#onCancel.onCancel-1' target='_blank'>See API documentation</a> | ||
<br> | ||
<p class='onCancel fw-bold'>click me and then click cancel while looking at the console output</p> | ||
</p> | ||
</div> | ||
</div> | ||
|
||
<script src='demo.js' type='module'></script> | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters