From 856e1d56da4f4dff3eaf59fd541030322f1b02a9 Mon Sep 17 00:00:00 2001 From: Sergey Date: Mon, 3 Nov 2014 19:20:09 +0200 Subject: [PATCH] select module fixes --- js/jcf.button.js | 2 +- js/jcf.checkbox.js | 2 +- js/jcf.file.js | 2 +- js/jcf.js | 2 +- js/jcf.radio.js | 2 +- js/jcf.scrollable.js | 2 +- js/jcf.select.js | 33 ++++++++++++++++++++++++--------- js/jcf.textarea.js | 2 +- 8 files changed, 31 insertions(+), 16 deletions(-) diff --git a/js/jcf.button.js b/js/jcf.button.js index 75794f6..f4c6726 100644 --- a/js/jcf.button.js +++ b/js/jcf.button.js @@ -4,7 +4,7 @@ * Copyright 2014 PSD2HTML (http://psd2html.com) * Released under the MIT license (LICENSE.txt) * - * Version: 1.0.0 + * Version: 1.0.1 */ ;(function($, window) { 'use strict'; diff --git a/js/jcf.checkbox.js b/js/jcf.checkbox.js index 0e47ba6..030fc80 100755 --- a/js/jcf.checkbox.js +++ b/js/jcf.checkbox.js @@ -4,7 +4,7 @@ * Copyright 2014 PSD2HTML (http://psd2html.com) * Released under the MIT license (LICENSE.txt) * - * Version: 1.0.0 + * Version: 1.0.1 */ ;(function($, window) { 'use strict'; diff --git a/js/jcf.file.js b/js/jcf.file.js index 8232610..7af87c5 100644 --- a/js/jcf.file.js +++ b/js/jcf.file.js @@ -4,7 +4,7 @@ * Copyright 2014 PSD2HTML (http://psd2html.com) * Released under the MIT license (LICENSE.txt) * - * Version: 1.0.0 + * Version: 1.0.1 */ ;(function($, window) { 'use strict'; diff --git a/js/jcf.js b/js/jcf.js index 1cfa910..7df0bd0 100755 --- a/js/jcf.js +++ b/js/jcf.js @@ -4,7 +4,7 @@ * Copyright 2014 PSD2HTML (http://psd2html.com) * Released under the MIT license (LICENSE.txt) * - * Version: 1.0.0 + * Version: 1.0.1 */ ;(function (root, factory) { if (typeof define === 'function' && define.amd) { diff --git a/js/jcf.radio.js b/js/jcf.radio.js index d92b846..7b46a32 100755 --- a/js/jcf.radio.js +++ b/js/jcf.radio.js @@ -4,7 +4,7 @@ * Copyright 2014 PSD2HTML (http://psd2html.com) * Released under the MIT license (LICENSE.txt) * - * Version: 1.0.0 + * Version: 1.0.1 */ ;(function($, window) { 'use strict'; diff --git a/js/jcf.scrollable.js b/js/jcf.scrollable.js index 1e09c9d..274d6e3 100755 --- a/js/jcf.scrollable.js +++ b/js/jcf.scrollable.js @@ -4,7 +4,7 @@ * Copyright 2014 PSD2HTML (http://psd2html.com) * Released under the MIT license (LICENSE.txt) * - * Version: 1.0.0 + * Version: 1.0.1 */ ;(function($, window) { 'use strict'; diff --git a/js/jcf.select.js b/js/jcf.select.js index bccd68a..d138ec8 100755 --- a/js/jcf.select.js +++ b/js/jcf.select.js @@ -4,7 +4,7 @@ * Copyright 2014 PSD2HTML (http://psd2html.com) * Released under the MIT license (LICENSE.txt) * - * Version: 1.0.0 + * Version: 1.0.1 */ ;(function($, window) { 'use strict'; @@ -149,7 +149,7 @@ onKeyDown: function(e) { if(e.which === 13) { this.toggleDropdown(); - } else { + } else if(this.dropActive) { this.delayedRefresh(); } }, @@ -319,6 +319,11 @@ this.dropdown.add(this.fakeElement).toggleClass(this.options.flipDropClass, this.options.flipDropToFit && needFlipDrop); }, showDropdown: function() { + // do not show empty custom dropdown + if(!this.realElement.prop('options').length) { + return; + } + // create options list if not created if(!this.dropdown) { this.createDropdown(); @@ -358,11 +363,16 @@ // redraw selected area var selectedIndex = this.realElement.prop('selectedIndex'), selectedOption = this.realElement.prop('options')[selectedIndex], - selectedOptionImage = selectedOption.getAttribute('data-image'), + selectedOptionImage = selectedOption ? selectedOption.getAttribute('data-image') : null, selectedOptionClasses, selectedFakeElement; - if(this.currentSelectedText !== selectedOption.innerHTML || this.currentSelectedImage !== selectedOptionImage) { + if(!selectedOption) { + if(this.selectImage) { + this.selectImage.hide(); + } + this.selectText.removeAttr('class').empty(); + } else if(this.currentSelectedText !== selectedOption.innerHTML || this.currentSelectedImage !== selectedOptionImage) { selectedOptionClasses = getPrefixedClasses(selectedOption.className, this.options.optionClassPrefix); this.selectText.attr('class', selectedOptionClasses).html(selectedOption.innerHTML); @@ -457,11 +467,16 @@ attachEvents: function() { // delayed refresh handler var self = this; - this.delayedRefresh = function() { - clearTimeout(self.refreshTimer); - self.refreshTimer = setTimeout(function() { - self.refresh(); - }, 1); + this.delayedRefresh = function(e) { + if(e && e.keyCode == 16) { + // ignore SHIFT key + return; + } else { + clearTimeout(self.refreshTimer); + self.refreshTimer = setTimeout(function() { + self.refresh(); + }, 1); + } }; // other event handlers diff --git a/js/jcf.textarea.js b/js/jcf.textarea.js index e4c8039..7949cc8 100644 --- a/js/jcf.textarea.js +++ b/js/jcf.textarea.js @@ -4,7 +4,7 @@ * Copyright 2014 PSD2HTML (http://psd2html.com) * Released under the MIT license (LICENSE.txt) * - * Version: 1.0.0 + * Version: 1.0.1 */ ;(function($, window) { 'use strict';