All Projects β†’ legshooter β†’ addel

legshooter / addel

Licence: MIT license
🎡 A jQuery plugin that enables dynamic addition & deletion of HTML elements

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to addel

Scribble-Font
Scribble Font for Prototyping & Wireframing
Stars: ✭ 48 (-5.88%)
Mutual labels:  ux
itop-datacenter-view
Extension for iTop: Easily manage & visualize your racks, enclosures and datacenter devices.
Stars: ✭ 24 (-52.94%)
Mutual labels:  ux
react-native-dynamic-vector-icons
Wrapper of react-native-vector-icons to use dynamic types
Stars: ✭ 84 (+64.71%)
Mutual labels:  ux
flow-ui
Accessibility oriented design system for developing fast and powerful web interfaces.
Stars: ✭ 89 (+74.51%)
Mutual labels:  ux
firefox-omni-tweaks
A script that disables the clickSelectsAll behavior of Firefox, and more.
Stars: ✭ 33 (-35.29%)
Mutual labels:  ux
react-spring-bottom-sheet
Accessible ♿️, Delightful ✨, & Fast πŸš€
Stars: ✭ 604 (+1084.31%)
Mutual labels:  ux
ReactZooApp
ReactZooApp
Stars: ✭ 33 (-35.29%)
Mutual labels:  ux
prototype
πŸ“–Prototype Document
Stars: ✭ 45 (-11.76%)
Mutual labels:  ux
List-of-Academic-Research-on-Usability-in-FOSS
No description or website provided.
Stars: ✭ 29 (-43.14%)
Mutual labels:  ux
KDInstagram
Instagram Clone built in Swift. Utilize three design patterns in three major modules.
Stars: ✭ 119 (+133.33%)
Mutual labels:  ux
eufemia
DNB Design System
Stars: ✭ 38 (-25.49%)
Mutual labels:  ux
UX-UI-Navigation
UX / UI Custom NavigationDrawer with Fragment
Stars: ✭ 70 (+37.25%)
Mutual labels:  ux
VanGogh
πŸ’₯ Android view animations powered by RxJava 2
Stars: ✭ 95 (+86.27%)
Mutual labels:  ux
touchclick
Provides immediate visual feedback on touch for native-feeling web apps
Stars: ✭ 42 (-17.65%)
Mutual labels:  ux
sonar.css
CSS3/Sass Animated Attention Seekers
Stars: ✭ 16 (-68.63%)
Mutual labels:  ux
ui patterns
[NOTE] Development has moved to https://drupal.org/project/ui_patterns
Stars: ✭ 87 (+70.59%)
Mutual labels:  ux
KeyCommandAlertController
UIAlertController wrapper to add keyboard shortcuts easily
Stars: ✭ 16 (-68.63%)
Mutual labels:  ux
Denna
Denna to-do list application
Stars: ✭ 21 (-58.82%)
Mutual labels:  ux
negi3wm
Brings a lot of unique UX features inspired by ion3/notion wm. Probably the most sophisticated example of i3ipc usage ever created
Stars: ✭ 27 (-47.06%)
Mutual labels:  ux
floating-slideup-sheet
Simple and lightweight UI library for user new experience, combining floating bottom navigation and bottom sheet behaviour. Simple and beautiful.
Stars: ✭ 118 (+131.37%)
Mutual labels:  ux

addel Example

addel is a simple and lightweight jQuery plugin for powering UIs that enable dynamic addition and deletion of HTML elements, conceived with form elements in mind.

"addel" is short for add-delete and should be pronounced "Adele", just like the singer's name.

..Because it's all in the details, people!

Table of Contents

Notable features

  • Lightweight
  • Maximum HTML flexibility
  • Events you can hook on
  • Declarative control
  • Keyboard convenience through smart focusing
  • Customizable animation

Installation

There are multiple options:

And include it: <script src="https://github.com/path/to/file/addel.jquery.min.js"></script>

Initialization

$('.addel-container').addel({
    // optional options object
});

⚠️ HTML structure and restrictions

<div class="addel-container">
    <div class="addel-target">
        <button class="addel-del"></button>
    </div>
    <button class="addel-add"></button>
</div>

As per RFC 2119:

  • .addel-container MUST be the element addel is initialized upon
  • .addel-container MUST contain everything else: .addel-target, .addel-delete and .addel-add
  • .addel-target MAY also contain your own element/s, this is after all what we are here for
  • .addel-delete MUST be .addel-container's and .addel-target's descendant
  • .addel-add MUST be .addel-container's descendant and MUST NOT be .addel-target's descendant

Note that class names are for reference only and are completely customizable, as described in the options section.

Options

Name Type Default Info
hide boolean false Whether to initially hide the target (disables its form elements)
add integer 1 The number of targets clicking classes.add will add to the DOM
classes.target string addel-target The class name of the element to be dynamically addeledβ„’
classes.add string addel-add The class name of the element that adds a target on click
classes.delete string addel-delete The class name of the element that deletes a target on click
classes.deleting string addel-delete The class name to be added to any target that is currently being deleted
animation.duration integer 0 The animation's duration (in milliseconds) when addelingβ„’
animation.easing string swing The animation's easing when addelingβ„’
events.add callback - Detailed in the events section
events.added callback - Detailed in the events section
events.delete callback - Detailed in the events section
events.deleted callback - Detailed in the events section
  • For more information on animation.duration and animation.easing, see jQuery's .fadeIn() and .fadeOut().
  • Note that it is possible to set the add option per element using a data-attribute, as described in the data-attributes section.

Options example

$('.people').addel({
    hide: true,
    add: 2,
    classes: {
        target: 'person',
        add: 'btn-add',
        delete: 'btn-del'
    },
    animation: {
        duration: 300,
        easing: 'linear'
    }
});

Data-attributes

Some options can be set declaratively as data-attributes on the HTML elements:

Option Data-attribute equivalent Placement
hide data-addel-hide container
add data-addel-add="<number>" container
classes.target data-addel-target target
classes.add data-addel-add or data-addel-add="<number>" add
classes.delete data-addel-delete delete
animation.duration data-addel-animation-duration container
animation.easing data-addel-animation-easing container
  • Setting data-addel-add is the same as setting data-addel-add="1".
  • Setting data-addel-add="5" on .addel-container will make all .addel-add / data-addel-add elements inside of it add 5 targets on click, by default.
  • Specifying in addition a data-addel-add="10" on a specific .addel-add / data-addel-add will make that specific element add 10 targets, overriding the default 5 set earlier on the container.
  • Note that for elements to behave as buttons that add targets, you need to add either data-addel-add or data-addel-add="<number>" to the element, there's no need for both.

Data-attributes example

<div class="addel" data-addel-hide="true" data-addel-add="2">
    <div data-addel-target>
        <button data-addel-delete></button>
    </div>
    <button data-addel-add="1"></button>  // adds 1 data-addel-target, as expected
    <button data-addel-add></button>      // adds 2 data-addel-target due to default set on .addel
    <button data-addel-add="3"></button>  // adds 3 data-addel-target on click, as expected
</div>
<script>
    $(function() {
        $('.addel').addel();
    });
</script>

Defaults

Override the entire options object:

$.fn.addel.defaults = {
    // options
};

Or a specific option:

$.fn.addel.defaults.option = value;

Events

Event Triggered when... Exposes
addel:add add is clicked event.target
addel:added target is added to the DOM event.target, event.added
addel:delete delete is clicked event.target
addel:deleted target is removed from the DOM event.target

All events are triggered on the element addel is initialized upon (AKA container).

Events example

Ask for confirmation before deleting:

$('.addel-container').addel({
    
    // other options

    events: {
        delete: function (event) {
            if (!window.confirm('Are you absolutely positively sure?')) {
                event.preventDefault();
            }
        }
    }
});

Or bind the event yourself:

$('.addel-container').addel({
    // other options
})
.on('addel:delete', function (event) {
    if (!window.confirm('Are you absolutely positively sure?')) {
        event.preventDefault();
    }
});

Example

A more elaborate example of all of the above is included.

Dependencies

jQuery (v2-3).

Browser support

addel is developed using Chrome (v57). It should work properly on all evergreen browsers and IE9+.

Release policy

addel adheres to Semantic Versioning.

License

addel is released under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].