Giter VIP home page Giter VIP logo

celesta's Introduction

Celesta

Custom selectbox with look and feel of native one. (Just see the demo.)

  • Pure JavaScript library working on top of native browser selectbox
  • Looks like <select>, feels like <select>, and quacks like <select>
  • Fully skinnable with CSS (including dropdown)

Browser support

  • IE 10+ (or 9+ with classList polyfill)
  • Opera 11.6+
  • Safari 5.1.4+
  • Firefox 4+
  • Chrome 8+
  • (?) iOS Safari 6+
  • (?) Android Browser 4+ (or 2+ with classList and bind polyfills)
  • (?) Opera Mobile 12+
  • (?) IE Mobile 10+

Basic usage

new Celesta(document.getElementById('my_select'));

Or, a little more advanced example:

var selectbox = document.querySelector('.some-select');
var celesta = new Celesta(selectbox, {
    space_key_open: false,
    options_nav_cycling: true,
    closed_options_pagekey_jump_by: 5
});

celesta.selectOption(3);

celesta.addEventListener('open', myCallbackFunction);
celesta.open();
celesta.hoverOption(6);
celesta.close();

celesta.refresh();
celesta.destroy();

For more advanced usage, see Options, Methods and Events reference. Also, you can see the demo.

Features

  • Support for optgroups, disabled state, disabled options/groups
  • Classname inheritance for select and options
  • Element and dropdown fully skinnable with CSS (no hardcoded CSS properties)
  • Automatic dropdown reverse to fit browser window viewable area
  • Dropdown scrolling:
  • Seemless dropdown fallback on mobile devices
  • Mouse support:
    • Focus with associated label click
    • Open with click
    • Highlight option with mouse hover
    • Select & close with option click
    • Close with outer click or outer mousewheel
  • Keyboard support:
    • Navigatable with Tab
    • Open with Space or Enter
    • Navigate through options with arrow keys ( & ), PageUp or PageDown
    • Find option by keyboard typing (quicksearch)
    • Close with Esc, select & close with Enter
  • Interaction:
    • Source <select> remains in DOM
    • Option select interaction: Celesta ↔ native select
    • Resets value on form reset
    • JavaScript API to control Celesta instance
    • Events handling with addEventListener
  • Falls back to native selectbox if cannot initialize
  • Plenty of options to customize UX; see the demo to play with some of them
  • No external library or framework dependencies
  • Usage mode: AMD, CommonJS or direct <script>
  • Available in npm and bower

Beta warning

This library is still under construction. API methods, option names, event callback interface, CSS classnames etc. can be changed at any time.

Todo list & known issues

  • multiple select support
  • jQuery plugin
  • Make work better with jScrollPane
  • UX testing on mobile devices
  • (?) Methods call chaining
  • (?) Link to source elements, not indexes (benchmarking needed)
  • (?) Better feature detection on initialization
  • Skin generator

Never to be implemented

  • Significant UI/UX change compared to native selectbox (if you want something "fancier", try Chosen or things like that)

Version history

  • 0.4.0 (2016-09-30): Add space_key_select param (credits to @garyanikin)
  • 0.3.1 (2015-11-05): Minor fix for mobile detection
  • 0.3.0 (2015-11-05):
    • Seemless dropdown fallback on mobile devices
    • Source select is moved inside Celesta container (no more kept next to the container)
  • 0.2.0 (2015-11-04):
    • Perfect PageUp/PageDown behavior
    • Allow disabled option to be selected initially
  • 0.1.0 (2015-10-12): Initial release

celesta's People

Contributors

thybzi avatar

Stargazers

Mike Lenyk avatar Dmitry Rudnev avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

garyanikin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.