jQuery Selectric Highlight Events
by vucko
HTML
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<div class="hero">
<div class="flex">
<h1>Ovo je neki text</h1>
<select name="Country" id="Country"><option>Land *</option><option value="Afghanistan">Afghanistan</option><option value="Egypt">Ägypten</option><option value="Aland Islands">Åland</option><option value="Albania">Albanien</option><option value="Algeria">Algerien</option><option value="Virgin Islands (U.S.)">Amerikanische Jungferninseln</option><option value="US Minor Outlying Islands">Amerikanisch-Ozeanien (US Minor Outlying Islands)</option><option value="American Samoa">Amerikanisch-Samoa</option><option value="Andorra">Andorra</option><option value="Angola">Angola</option><option value="Anguilla">Anguilla</option><option value="Antarctica">Antarktis</option><option value="Antigua and Barbuda">Antigua und Barbuda</option><option value="Equatorial Guinea">Äquatorialguinea</option><option value="Argentina">Argentinien</option><option value="Armenia">Armenien</option><option value="Aruba">Aruba</option><option value="Azerbaijan">Aserbaidschan</option><option value="Ethiopia">Äthiopien</option><option value="Australia">Australien</option><option value="Bahamas">Bahamas</option><option value="Bahrain">Bahrain</option></select>
</div>
</div>
CSS
/*======================================
Selectric v1.11.0
======================================*/
.selectric-wrapper {
position: relative;
cursor: pointer;
}
.selectric-responsive {
width: 100%;
}
.selectric {
border: 1px solid #DDD;
background: #F8F8F8;
position: relative;
}
.selectric .label {
display: block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin: 0 38px 0 10px;
font-size: 12px;
line-height: 38px;
color: #444;
height: 38px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.selectric .button {
display: block;
position: absolute;
right: 0;
top: 0;
width: 38px;
height: 38px;
color: #BBB;
text-align: center;
font: 0/0 a;
*font: 20px/38px Lucida Sans Unicode, Arial Unicode MS, Arial;
}
.selectric .button:after {
content: " ";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
width: 0;
height: 0;
border: 4px solid transparent;
border-top-color: #BBB;
border-bottom: none;
}
.selectric-focus .selectric {
border-color: #aaaaaa;
}
.selectric-hover .selectric {
border-color: #c4c4c4;
}
.selectric-hover .selectric .button {
color: #a2a2a2;
}
.selectric-hover .selectric .button:after {
border-top-color: #a2a2a2;
}
.selectric-open {
z-index: 9999;
}
.selectric-open .selectric {
border-color: #c4c4c4;
}
.selectric-open .selectric-items {
display: block;
}
.selectric-disabled {
filter: alpha(opacity=50);
opacity: 0.5;
cursor: default;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.selectric-hide-select {
position: relative;
overflow: hidden;
width: 0;
height: 0;
}
.selectric-hide-select select {
position: absolute;
left: -100%;
}
.selectric-hide-select.selectric-is-native {
position: absolute;
width: 100%;
height: 100%;
z-index: 10;
}
.selectric-hide-select.selectric-is-native...
JavaScript
/*!
* ,/
* ,'/
* ,' /
* ,' /_____,
* .'____ ,'
* / ,'
* / ,'
* /,'
* /'
*
* Selectric ϟ v1.11.0 (Dec 16 2016) - http://lcdsantos.github.io/jQuery-Selectric/
*
* Copyright (c) 2016 Leonardo Santos; MIT License
*
*/
(function(factory) {
/* global define */
/* istanbul ignore next */
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else if (typeof module === 'object' && module.exports) {
// Node/CommonJS
module.exports = function(root, jQuery) {
if (jQuery === undefined) {
if (typeof window !== 'undefined') {
jQuery = require('jquery');
} else {
jQuery = require('jquery')(root);
}
}
factory(jQuery);
return jQuery;
};
} else {
// Browser globals
factory(jQuery);
}
}(function($) {
'use strict';
var $doc = $(document);
var $win = $(window);
var pluginName = 'selectric';
var classList = 'Input Items Open Disabled TempShow HideSelect Wrapper Focus Hover Responsive Above Scroll Group GroupLabel';
var eventNamespaceSuffix = '.sl';
var chars = ['a', 'e', 'i', 'o', 'u', 'n', 'c', 'y'];
var diacritics = [
/[\xE0-\xE5]/g, // a
/[\xE8-\xEB]/g, // e
/[\xEC-\xEF]/g, // i
/[\xF2-\xF6]/g, // o
/[\xF9-\xFC]/g, // u
/[\xF1]/g, // n
/[\xE7]/g, // c
/[\xFD-\xFF]/g // y
];
/**
* Create an instance of Selectric
*
* @constructor
* @param {Node} element - The <select> element
* @param {object} opts - Options
*/
var Selectric = function(element, opts) {
var _this = this;
_this.element = element;
_this.$element = $(element);
_this.state = {
multiple: !!_this.$element.attr('multiple'),
enabled: false,
opened: false,
currValue: -1,
selectedIdx: -1,
highlightedIdx: -1
};
_this.eventTriggers = {
open: _this.open,
close: _this.close,
destroy:...