GEO With Us
CSMOUSE JavaScript / HTML DOM Keyboard.key Property Class on Ctrl + Shift + Left Mouse Click Event

This functionality mimics Windows® File Explorer (or any other) gimmicks when selecting/deselecting files and folders.

In our CSMOUSE Object - we programmed it to work on web application sets of lists. Number of which is not limited per one page.

ALL SELECTABLE
/0 Selected:
0 Amaranth Leaves/Chinese Spinach
1 Artichoke
2 Arugula
3 Asparagus
4 Avocado
5 Baby Corn/Candle Corn
6 Bamboo Shoots
7 Bean Sprouts
8 Beans
9 Beet
10 Beet Greens
11 Belgian Endive
12 Bell Pepper
13 Bitter Melon/Bitter Gourd
14 Bok Choy/Bok Choi/Pak Choy
15 Broccoli
16 Brussels Sprouts
17 Burdock Root/Gobo
18 Butterhead
19 Cabbage
20 Calabash
21 Capers
22 Carrot
23 Cassava/Yuca
24 Cauliflower
25 Celery
26 Celery Root/Celeriac
27 Celtuce
28 Chayote
29 Chinese Broccoli/Kai-lan
30 Collard Greens
31 Corn/Maize
32 Cucumber
33 Curly
34 Curly/Frisee
35 Daikon Radish
36 Dandelion Greens
37 Edamame
38 Eggplant/Aubergine
39 Elephant Garlic
40 Endive
41 English Cucumber
42 Escarole
SOME UNSELECTABLE
/0 Selected:
0 Fennel
1 Fiddlehead
2 Galangal
3 Garlic
4 Ginger
5 Grape Leaves
6 Green Beans/String Beans/Snap Beans
7 Greens
8 Kale
9 Kohlrabi Greens
10 Kohlrabi
11 Leeks
12 Lemongrass
13 Lettuce
14 Mushrooms
15 Napa Cabbage
16 Nopales
17 Okra
18 Olive
19 Onion
20 Parsley
21 Parsley Root
22 Parsnip
23 Peas
24 Peppers
25 Plantain
26 Potato
27 Pumpkin
28 Purslane
29 Radicchio
30 Radish
31 Rutabaga
32 Sea Vegetables
33 Shallots
34 Squash
35 Sweet Potato
36 Taro
37 Tomatillo
38 Tomato
39 Turnip
40 Water Chestnut
41 Water Spinach
42 Watercress
43 Winter Melon
44 Yams
45 Zucchini
Use Keyboard buttons Ctrl (Command on MAC), Shift or none with left mouse click.
First example (left list) uses element id as output values. Second example (right list) uses element data-value attribute as output values.


It is super-fast, simple in settings, 100% safe and styles and HTML/CSS/Datasets combinations are unlimited.

Feel free to check and explore examples from above.

Elements in lists can be div, a, li, even p or tr/td (following the HTML Standard), and they can differ from one list to another on the same web page.
List unique element class is a main selector. That is: for all selectable elements in one list, it has to be the same class name.

Number of lists (sets of elements determined by the same class name) is not limited per one document.
One can even split one list to as many lists as needed with same class selector and only one instance of this function.

The class is easily initialized via main selector and only a handful of optional settings:


var leftItemsClass, rightItemsClass;

// One can set-up unlimited number of lists, in this example we used only two.
window.addEventListener("load", function () {

	// LEFT SELECTION
	leftItemsClass = new CSMOUSE("sels",
		{
			first:  "first_sels",		// First clicked index storage.
			last:   "last_sels",		// Last clicked index storage.
			values: "sels_values",		// List of all selected values storage (DOM indexes).
			items:  "sels_items",		// Initialization list setting storage (usually returned by server).
										// (Or any unique server parsable attribute set), for example:
										// elem_1,elem_2,elem_3,...
										// It is element id attribute list delimited with comma on DOM load.
										// If not set, CSMOUSE will create items with your HTML list(s).
										// First three are dynamically created and maintained.
			color:  "sels-blue",		// Selected indicating class; There are two coloring classes. 
										// One is :hover and the other is this (color). 
										// Both must be defined in proper cascading order, like:
										// .selector:hover and .selector.color, for example: 
										// .sels:hover {background-color: #fedcba;} and 
										// .sels.sels-blue {background-color: #abcdef;}; 
										// This way, a :hover style will be overlapped with .selector.color, 
										// when element is selected;
										// Defining them without cascading order will not work, so no good: 
										// .sels:hover{}, .sels-blue{}
			all:    "sel_all",			// Select all elements button/link.
			none:   "unsel_all",		// Un-select all elements button/link.
			togg:	"toggle",			// Toggle selected elements button/link.
										// All, None and Toggle buttons are optional for use.
										// All three functions can be reached on global document scope, and
										// with no arguments.
			cnt:    "display_counter",	// Selected elements counter (recalculated on each click).
			elems:	"total_elems",		// Total elements counter (initialized on function init).
										// cnt and elems HTML elements are optional for use.
										// Both of functions can be reached on global document scope, and
										// with no arguments.
			json:   "json",				// JSON output formatter button/link. Global scope too.
			serial: "serial",			// Serialize output formatter button/link. Global scope too.
			output:	"id",				// Output attribute (can be any, should be unique id attribute).
			debug:  true				// Debug mode, should be set to false in production mode.
		}
	);

	// RIGHT SELECTION
	rightItemsClass = new CSMOUSE("sels2",
		{
			first:  "first_sels2",
			last:   "last_sels2",
			values: "sels_values2",
			items:  "sels_items2",
			color:  "sels-red",
			all:    "sel_all2",
			none:   "unsel_all2",
			togg:	"toggle2",
			cnt:    "display_counter2",
			elems:	"total_elems2",
			json:   "json2",
			serial: "serial2",
			output:	"data-value",
			debug:  true
		}
	);

});
			

Element ID (or any data- like argument, or any) can be set as an output. It exports selected items via JSON or form serialization formats.

The most interesting functions to use outside CSMOUSE are output functions - selected elements to be passed to server (or whatever) and counters. Here are examples of code on above buttons:


// Following functions shows external usage of some CSMOUSE functions (can be applied to all, 
// for example if you use single submit button for all lists, play with combos here)
function getJSONLeft(){

	var a = leftItemsClass.getSelectedJSON();
	alert(a);

}
function getSerializedLeft(){

	var b = leftItemsClass.getSelectedSerialize();
	alert(b);

}
function getJSONRight(){

	var a = rightItemsClass.getSelectedJSON();
	alert(a);

}
function getSerializedRight(){

	var b = rightItemsClass.getSelectedSerialize();
	alert(b);

}
function numberSelectedLeft(){

	var c = leftItemsClass.getSelected();
	alert(c);

}
function numberSelectedRight(){

	var d = rightItemsClass.getSelected();
	alert(d);

}
			

Functions can be called anywhere from your web application (anchor, button, whatever with onClick event (or any event)):


...onclick="javascript: getJSONLeft();">OUTPUT LEFT JSON<...
...onclick="javascript: getSerializedLeft();">OUTPUT LEFT SERIALIZED<...
...onclick="javascript: numberSelectedLeft();">COUNT<...
...onclick="javascript: numberSelectedRight();">COUNT<...
...onclick="javascript: getSerializedRight();">OUTPUT RIGHT SERIALIZED<...
...onclick="javascript: getJSONRight();">OUTPUT RIGHT JSON<...
			

Of course, one can completely use it's own logics as needed. These are just examples.
Maybe combinations of selections from multiple lists, maybe anything.
This functionality is pure base for your imagination, creativity, engineering or developer demand tasks. VoilĂ .

This version relies purely on JavaScript (JS ES5+, on any platform). There is, of course, our fruity jQuery plugin implementation here.

JavaScript Function can be downloaded here.
Available through Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) License.
For commercial or any enterprise use, please contact us at copyright@geowith.us.
This functionality is yet not available for mobile platforms. Visit soon.