MSelectDialogBox - jQuery plugin for interactive dropdown lists.

Overview

#MSelectDBox - jQuery plugin for interactive dropdown lists.

Features

  • Multiselect
  • Events
  • Autocomplete
  • Custom function of autocomplete filter. Example: correction of keyboard language layout
  • Could be attached to any target element
  • Adapted for portable devices
  • API propose the possibility to customize control (demo)

Demo

Download MSelectDialogBox.js

Download MSelectDBox.min.js

JSDoc documentation (detailed API)

Документация на русском

Example

$("#selector").mSelectDBox({
	"list": (function(){
		var arr = [];
		for(var c=0; c<30; c++){
			arr.push(Math.round(Math.random() * 10000));
		}
		return arr;
	})(),
	"multiple": false,
	"autoComplete": true,
	"name": "a"
});

Constructor arguments

Passing as single object with keys:

  • [Array] list - where list items may be key-value object with two string type properties {label:String(1),value:String(1)} or string

Example:

var list = [
	{"label": "Apple", "value": "0"},
	{"label": "Orange", "value": "1"},
	{"label": "Banana", "value": "2"}
];

Example:

var list = ["Apple", "Orange", "Banana"];

if need after initialization you can reassign the list by assigning a new array through a "set" method. Example:

$("#selector").mSelectDBox(
	"set",
	"list",
	[
    	"alpha",
    	"beta",
    	"gamma",
    	"delta",
    	"epsilon"
    ]
);
  • [Boolean] multiple - enable or disable multiple selection of items in list. Default: false.

  • [Boolean] autoComplete - enable or disable auto compelete. Only if target element is text input or textarea. Default: false.

  • [Boolean] openOnFocus - enable or disable auto open of list box on focus event. Default: true.

  • [String] name - name of instance. Used for search initialized instance by name. Default: undefined

  • [Array] optionFilters - autocomplete filters. Default: [$.prototype.mSelectDBox.prototype.defaultOptionFilters.default]

  • [Boolean] embeddedInput - activates search input inside listbox

  • [String] width - width of list box. Example: "10px" or "auto"

  • [Number] zIndex - z-index style property of list box

  • [String] language - set language of instance (en | ru)

Events

  • init - fires when instance initialized

  • onselect - fires when list item is selected

  • onchange - fires when text input was changed

  • onkeydown - same as original onkeydown event

  • onkeyup - same as original onkeyup event

  • input:empty - fires when text input become empty

  • autocomplete:empty - fires when autocomplete function results empty list

  • autocomplete:not-empty - fires when autocomplete function results not empty list

  • focus - you know... focus

  • focusout - same as blur

  • set - Fires when calling set method. Example: instance.set("fieldName", 100);

  • set:field - Fires when calling "set" method with specified key. Example: instance.set("field", 100);

  • get - Fires when calling "get" method. Example: instance.get("fieldName");

  • get:field - Fires when calling "get" method with specified key. Example: instance.get("field", 100);

  • afterSet:field - Fires after "get" method was called with specified key. The event ensures that the function will be executed after the assignment and will have access to new value;

  • beforeSet:field - Fires before "get" method will be called with specified key.


Events may be attached in two ways:

Example:

$("#selector").mSelectDBox({
	"list": [1,2,3],
	"onchange": function(msdbContext, event){
		console.log(arguments);
	},
	"onselect": function(msdbContext, event){
		console.log(arguments);
	},
	"input:empty": function(msdbContext, event){
		console.log(arguments);
	}
});

Example:

$("#selector").mSelectDBox({
	"list": [1,2,3],
	"events": {
		"change": function(msdbContext, event){
			console.log(arguments);
		},
		"select": function(msdbContext, event){
			console.log(arguments);
		},
		"input:empty": function(msdbContext, event){
			console.log(arguments);
		}
	}
});

Autocomplete filters

Filter it's function. Part of autocomplete module. It compares each element of the list with the value of input. Returns true if it meets the search condition,false otherwise.

Example:

/**
* @param {String} inputString
* @param {String | Number} optionString
*/
function(inputString, optionString){
	var pattern = new RegExp(inputString.trim(),"ig");
	optionString = String(optionString);
	return Boolean(optionString.match(pattern));
}

Passing through constructor (param. "optionFilters"). Or may be added after initialization instance.get("optionFilters").push(function(matcherStr, matchedStr){...}) Filters available by default:

  • $.prototype.mSelectDBox.prototype.defaultOptionFilters.default - default autocomplete filter
  • $.prototype.mSelectDBox.prototype.defaultOptionFilters.russianKeyboard - correcting layout to russian keyboard

Language support

Language of dropdown list can be assigned through constructor by using key language

If language is not specified, the library will try to determine language by user system settings

Predefined language codes:

  • en - English
  • ru - Russian

Example:

$("#selector").mSelectDBox({
	"list": [1, 2, 3],
	"language": "en" // English
});

To define or redefine a texts for a particular language, you can use the method setText

// Initialized instance
$("#selector").mSelectDBox("setText", "Tap to close", ".m-select-d-box-fade__outside-click-label-text", "en");

the same to define new language support

// Initialized instance
$("#selector").mSelectDBox("setText", "kapatmak için dokunun", ".m-select-d-box-fade__outside-click-label-text", "tr"); // Турецкий

Texts codes:

  • .m-select-d-box-fade__outside-click-label-text - "Tap to close"
  • .m-select-d-box__search-input - search input

Methods

.getInstances()

getInstances([Object] arg) — search initialized instances by name. Return array of matched instances.

Example:

var dbox = $.prototype.mSelectDBox.prototype.getInstances({"name":"instanceName"});

Alternative:

var dbox = $("#selector").mSelectDBox();

The following methods can be called as an instance method or as a parameter to the method "mSelectDBox".

var dbox = $.prototype.mSelectDBox.prototype.getInstances({"name":"instanceName"})[0];
dbox.method(...);

.trigger()

trigger([String] eventName), .("trigger", [String] eventName) — fire predefined event.

Example:

var dbox = $.prototype.mSelectDBox.prototype.getInstances({"name":"instanceName"})[0];
dbox.trigger("select");

Alternative:

$("#selector").mSelectDBox("trigger","select");

.on()

on([String] eventName, [Function] callback), .("on", [String] eventName, [Function] callback) — add custom event listener.

Example:

var dbox = $.prototype.mSelectDBox.prototype.getInstances({"name":"instanceName"})[0];
dbox.on(
	"select", 
	function(msdbContext, event){
		console.log(arguments);
	}
);

Alternative:

$("#selector").mSelectDBox(
	"on",
	"select",
	function(msdbContext, event){
		console.log(arguments);
    }
);

.select()

select([Object] arg),.("select", [Object] arg) — select list options by value, label or id (key)

arg = {"label": Array | String};

or

arg = {"value": Array | String};

Example:

var dbox = $.prototype.mSelectDBox.prototype.getInstances({"name":"instanceName"})[0];
dbox.select({"label": ["100", "200"]});
dbox.select({"label": "100"});
dbox.select({"value": "0"});

Alternative:

$("#selector").mSelectDBox("select",{"label": ["100", "200"]});

.getSelectedLabels()

Return array of selected list labels

var array = $("#selector").mSelectDBox("getSelectedLabels");

Alternative:

var array = $("#selector").mSelectDBox().getSelectedLabels();

.getSelectedValues()

Return array of selected list values

var array = $("#selector").mSelectDBox("getSelectedValues");

Alternative:

var array = $("#selector").mSelectDBox().getSelectedValues();

.selectAll()

selectAll(void) — select all list options. Only if multiple = true

.deselectAll()

deselectAll(void)

.open()

open(void) — show list box

.close()

close(void) — hide list box

.isActive()

isActive(void) — return true if list box is visible

.get()

get([String] key) — returns property of MSelectDBox instance

.set()

set([String] key, [Any] value) — set new or update property of MSelectDBox instance

TODO

  • Groups
  • README.MD
Comments
  • Падение при вызове val()

    Падение при вызове val()

    при вызове функции val() для элементов не содержащих аттрибута data-msdb-value js падает с ошибкой: Uncaught TypeError: Cannot read property 'toLowerCase' of undefined

    вероятно причина в этом потому как валидный вызов: jQueryValFn.apply(this, arguments); пруф

    bug 
    opened by enz0jke 2
  • Max select items

    Max select items

    Hi,

    Is there any option that we can select max items in multiple list ? for eaxmple, i have a list of 10 items and only want user to max select 4 options.

    opened by monymirza 2
  • There should be a way to configure 'autoopen' on-off

    There should be a way to configure 'autoopen' on-off

    Currently whenever focus goes in to the input, options dropdown open by default. There should be a way to disable this feature. From accessibility point of view, user should be able to open the options by pressing enter button or clicking into the input textbox.

    opened by stackchetan 1
  • Backspace clear input

    Backspace clear input

    As per demo https://eugenegantz.github.io/MSelectDialogBox/example.html 2nd example ( multiple = true, autoComplete = true )

    I type "am" and get filtered result, then i press Backspace 1 time, it clears whole field while it should only remove last letter "m" and remain filtered results with "a".

    opened by monymirza 1
  • Unable to open and close listbox on particular event

    Unable to open and close listbox on particular event

    I am using MSelectDialogBox to allow customer enter values one by one by selecting item from listboox and after all selection and clicking on filter button, filter grid records with selected csv of UserIds. Customer should also be allowed to copy and paste a csv in same filter textbox.

    I am using Kendo Grid Problem is, I am having a filter icon on column header, clicking on which open a small window and listbox open simultaneously. I want customer totype in some values and after that listbox to appear and listbox to close when user clicks on filter or close button.

    image

    opened by VanditaChhabaria 0
Owner
null
Jquery.iocurve - jQuery plugin like Tone Curve on Photoshop or GIMP

jquery.iocurve jQuery plugin like Tone Curve on Photoshop or GIMP. See Official page for more information. Quick start Create HTML and open in your br

null 5 Jul 28, 2022
Jquery.Circle.js - Circle is a Javascript global-menu library for jQuery.

Circle About Circle is a Javascript global-menu library for jQuery. Read more at the website: http://uc.gpgkd906.com/ Installation Just include the Ja

陈瀚 3 Jul 19, 2021
jQuery Validation Plugin library sources

jQuery Validation Plugin - Form validation made easy The jQuery Validation Plugin provides drop-in validation for your existing forms, while making al

null 10.3k Jan 3, 2023
The best @jquery plugin to validate form fields. Designed to use with Bootstrap + Zurb Foundation + Pure + SemanticUI + UIKit + Your own frameworks.

FormValidation - Download http://formvalidation.io - The best jQuery plugin to validate form fields, designed to use with: Bootstrap Foundation Pure S

FormValidation 2.8k Mar 29, 2021
[DISCONTINUED] jQuery plugin that makes it easy to validate user input while keeping your HTML markup clean from javascript code.

jQuery Form Validator [DISCONTINUED] Validation framework that let's you configure, rather than code, your validation logic. I started writing this pl

Victor Jonsson 976 Dec 30, 2022
jQuery Validation Plugin library sources

jQuery Validation Plugin - Form validation made easy The jQuery Validation Plugin provides drop-in validation for your existing forms, while making al

null 10.3k Jan 3, 2023
jQuery form validation plugin

jQuery.validationEngine v3.1.0 Looking for official contributors This project has now been going on for more than 7 years, right now I only maintain t

Cedric Dugas 2.6k Dec 23, 2022
Internationalisation - A jQuery-Plugin to replace alternate version of text for client side internationalization.

Project status Use case A jQuery plugin to replace alternate version of text for client side internationalisation. Content [TOC] Installation Classica

Torben Sickert 10 Nov 30, 2022
Funkytooltips - A jQuery plugin to create funky tooltips

Funkytooltips Funkytooltips is a jQuery plugin to generate tooltips based on the data contained in HTML tags. Installation The plugin can be installed

Nourdine 0 Apr 17, 2021
Fallblatt - fallblatt is a lightweight jQuery plugin for animating split flap displays

fallblatt Ever wondered about those big legacy displays in aiport terminals and train stations? They are called split-flap displays (Fallblattanzeige

Julian Pelizäus 11 Oct 11, 2022
Jquery-anyimagecomparisonslider-plugin - The any Image Comparison Slider is an extremely versatile yet slim slider for comparing images. You have a lot of options to configure the slider and it works just about everywhere.

any Image Comparison Slider (jquery-anyimagecomparisonslider-plugin ) Description The any Image Comparison Slider is an extremely versatile yet slim s

Niklas 6 Sep 12, 2022
HTML 5 & Bootstrap Jquery Form Validation Plugin

HTML 5 & Bootstrap Jquery Form Validation Plugin HTML 5 & Bootstrap 5 & Jquery 3 jbvalidator is a fresh new jQuery based form validation plugin that i

null 37 Dec 6, 2022
jQuery library to validate html forms. compatible with bootstrap v4 and bootstrap v3

jQuery form validation jQuery form validation is a library that helps you to validate your HTML form, it's completable with both Bootstrap 3 and Boots

Bassam Nabriss 33 Jun 10, 2021
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
jQuery plugin to fire events when user's cursor aims at particular dropdown menu items. For making responsive mega dropdowns like Amazon's.

jQuery-menu-aim menu-aim is a jQuery plugin for dropdown menus that can differentiate between a user trying hover over a dropdown item vs trying to na

Ben Kamens 7.7k Dec 30, 2022
Ordered lists, flat or nested, multiple formats ordered lists.

logseq-plugin-ol 有序列表,单级或多级、多种样式的有序列表。 Ordered lists, flat or nested, multiple formats ordered lists. 使用展示 (Usage) 在想要展示为有序列表的块上添加一个以 #.ol 开头的标签就可以了。有

Seth Yuan 25 Jan 1, 2023