lib/assets/javascripts/uniform.jquery.js in uniform-ui-2.2.2 vs lib/assets/javascripts/uniform.jquery.js in uniform-ui-2.3.2

- old
+ new

@@ -1,7 +1,8 @@ import * as Uniform from 'uniform'; +window.Uniform = Uniform; if($) { /* Dropdown */ $.fn.uniformDropdown = function() { @@ -110,15 +111,42 @@ $.fn.uniformTooltip = function() { return this.each(function(){ var el = $(this); var tooltip = new Uniform.Tooltip({ message: el.data('tooltip-message'), + container: el.data('tooltip-container'), el: this }); tooltip.on('*', function (event_type, tooltip) { el.trigger('tooltip-' + event_type, tooltip); }); tooltip.render(); }); }; + $.fn.uniformTristate = function () { + return this.each(function(){ + var el = $(this); + function updateTristateStatus(checked_input){ + if (checked_input.length == 0) { + el.addClass('-null'); + $(el.find('input')[1]).prop('checked', true); + } else { + var index = checked_input.index(); + var klass = index == 0 ? "-true" : (index == 1 ? "-null" : "-false"); + el.removeClass('-true -null -false'); + el.addClass(klass); + } + } + el.on('change', 'input', function (e) { + updateTristateStatus($(e.currentTarget)); + }); + updateTristateStatus(el.find('input:checked')); + el.on('blur', 'input', function (e) { + el.removeClass('-focus'); + }); + el.on('focus', 'input', function (e) { + el.addClass('-focus'); + }); + }); + } } \ No newline at end of file