diff --git a/blank_theme.css b/css/blank_theme.css
similarity index 95%
rename from blank_theme.css
rename to css/blank_theme.css
index fafef52a..1aeff24a 100644
--- a/blank_theme.css
+++ b/css/blank_theme.css
@@ -20,8 +20,6 @@
float: left; }
.dk_container a {
outline: 0; }
- .dk_container[disabled] a {
- cursor: not-allowed; }
.dk_toggle {
display: -moz-inline-stack;
diff --git a/blank_theme.scss b/css/blank_theme.scss
similarity index 100%
rename from blank_theme.scss
rename to css/blank_theme.scss
diff --git a/dropkick.css b/css/dropkick.css
old mode 100755
new mode 100644
similarity index 98%
rename from dropkick.css
rename to css/dropkick.css
index 4fe69e3c..8413bf58
--- a/dropkick.css
+++ b/css/dropkick.css
@@ -192,7 +192,7 @@
-moz-appearance: none;
-webkit-appearance: none; }
-/* Here we reflect some of the styles from .dk_container to achieve the same visual also when without javascript */
+/* Here we reflect some of the styles from .dk_container to achieve the same visual also when without javascript */
.dk_wrap {
position: relative;
display: inline-block;
@@ -249,7 +249,7 @@
display: none;
}
- /* Firefox only */
+ /* Firefox only */
@-moz-document url-prefix() {
.dk_wrap select { padding: 7px 49px 5px 6px; }
}
diff --git a/dropkick.scss b/css/dropkick.scss
similarity index 100%
rename from dropkick.scss
rename to css/dropkick.scss
diff --git a/example/examples.html b/example/examples.html
index cb20c7a3..db4bf214 100755
--- a/example/examples.html
+++ b/example/examples.html
@@ -6,7 +6,7 @@
Robdel12/DropKick @ GitHub
-
+
@@ -278,13 +278,22 @@ Disabled <option>
United Kingdom
United States
+
+ All options disabled
+ Australia
+ Canada
+ Germany
+ Japan
+ United Kingdom
+ United States
+
With <optgroup>
-
+
Try optgroup support!
Canada
diff --git a/gulpfile.js b/gulpfile.js
index 508e3b10..c9745053 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -10,7 +10,7 @@ var rename = require('gulp-rename');
// Lint Task
gulp.task('lint', function() {
- return gulp.src('*.js')
+ return gulp.src('jquery.dropkick.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
@@ -25,11 +25,9 @@ gulp.task('sass', function() {
// Concatenate & Minify JS
gulp.task('scripts', function() {
return gulp.src('*.js')
- .pipe(concat('all.js'))
- .pipe(gulp.dest('dist'))
- .pipe(rename('all.min.js'))
+ .pipe(rename('jquery.dropkick-min.js'))
.pipe(uglify())
- .pipe(gulp.dest('dist'));
+ .pipe(gulp.dest(''));
});
// Watch Files For Changes
diff --git a/jquery.dropkick-min.js b/jquery.dropkick-min.js
old mode 100755
new mode 100644
index 15ba13eb..d43d82fe
--- a/jquery.dropkick-min.js
+++ b/jquery.dropkick-min.js
@@ -1,10 +1 @@
-/*
- * DropKick 1.5
- *
- * Highly customizable lists
- * https://github.com/robdel12/DropKick
- *
- * Created by: Jamie Lottering
- *
- *
-*/(function(t,e,i){"use strict";var n=navigator.userAgent.match(/MSIE ([0-9]{1,}[\.0-9]{0,})/),a=!!n,d=a&&parseFloat(n[1])<7,r=navigator.userAgent.match(/iPad|iPhone|Android|IEMobile|BlackBerry/i),o=a?"mousedown":"click",l="onwheel"in e?"wheel":"onmousewheel"in i?"mousewheel":"MouseScrollEvent"in e&&"DOMMouseScroll MozMousePixelScroll",s={fired:!1,fire:function(){t(i).on(o,".dk_options a",function(){var e=t(this),i=e.parent(),n=e.parents(".dk_container").first();return i.hasClass("disabled")||i.closest(".dk_optgroup",n).hasClass("disabled")||(i.hasClass("dk_option_current")||(b(e,n),$(e.parent(),n)),m(n)),!1}).on(l,".dk_options_inner",function(t){var e=t.originalEvent.wheelDelta||-t.originalEvent.deltaY||-t.originalEvent.detail;return a?(this.scrollTop-=Math.round(e/10),!1):e>0&&this.scrollTop<=0||0>e&&this.scrollTop>=this.scrollHeight-this.offsetHeight?!1:!0}).on({"keydown.dk_nav":function(t){var e=v||_;e&&A(t,e)},click:function(e){var i,n=t(e.target);if(v&&0===n.closest(".dk_container").length)m(v);else{if(n.is(".dk_toggle, .dk_label"))return i=n.parents(".dk_container").first(),i.hasClass("dk_open")?m(i):(v&&m(v),!i.attr("disabled")&&x(i,e)),!1;n.attr("for")&&t("#dk_container_"+n.attr("for"))[0]&&t("#dk_container_"+n.attr("for")).trigger("focus.dropkick")}}}),this.fired=!0}},p={},c=[],f={left:37,up:38,right:39,down:40,enter:13,tab:9,zero:48,z:90,last:221},u=['"].join(""),k='{{ text }} ',h='{{ text }} ',g={startSpeed:400,theme:!1,changes:!1,syncReverse:!0,nativeMobile:!0,autoWidth:!0},v=null,_=null,b=function(t,e,i){var n=t.attr("data-dk-dropdown-value"),a=t.text(),d=e.data("dropkick"),r=d.$select;e.find(".dk_label").text(a?a:" "),i?r.val(n):r.val(n).trigger("change"),d.settings.change&&!i&&!d.settings.syncReverse&&d.settings.change.call(r,n,a)},m=function(t){t.removeClass("dk_open dk_open_top"),v=null},C=function(i){if(i.data("dropkick").settings.fixedMove)return"up"==i.data("dropkick").settings.fixedMove?!1:!0;var n=i.find(".dk_toggle"),a=i.find(".dk_options").outerHeight(),d=t(e).height()-n.outerHeight()-n.offset().top+t(e).scrollTop(),r=n.offset().top-t(e).scrollTop();return r>a?d>a:!0},w=function(t,e,i){var n=t.find(".dk_options_inner"),a=e.prevAll("li").outerHeight()*e.prevAll("li").length+(e.closest(".dk_optgroup",n).length&&e.closest(".dk_optgroup",n).prevAll("li").outerHeight()*e.closest(".dk_optgroup",n).prevAll("li").length),d=n.scrollTop(),r=n.height()+n.scrollTop()-e.outerHeight();(i&&"keydown"===i.type||d>a||a>r)&&n.scrollTop(a)},x=function(t,e){var i=C(t),n="dk_open"+(i?"":" dk_open_top");t.find(".dk_options").css({top:i?t.find(".dk_toggle").outerHeight()-1:"",bottom:i?"":t.find(".dk_toggle").outerHeight()-1}),v=t.addClass(n),w(t,t.find(".dk_option_current"),e)},$=function(t,e,i){e.find(".dk_option_current").removeClass("dk_option_current"),t.addClass("dk_option_current"),w(e,t,i)},A=function(e,i){var n,a,d,r,o,l,s,p=e.keyCode,c=i.data("dropkick"),u=String.fromCharCode(p),k=i.find(".dk_options"),h=i.hasClass("dk_open"),g=k.find("li:not(.disabled)"),v=i.find(".dk_option_current"),_=v.closest(".dk_optgroup",k),C=g.first().hasClass("dk_optgroup")?g.first().find("li:not(.disabled)").first():g.first(),w=g.last().hasClass("dk_optgroup")?g.last().find("li:not(.disabled)").last():g.last();switch(p){case f.enter:h?v.hasClass("disabled")||(b(v.find("a"),i),m(i)):x(i,e),e.preventDefault();break;case f.tab:h&&(v.length&&b(v.find("a"),i),m(i));break;case f.up:h?(a=v.prevAll("li:not(.disabled)").first(),a.hasClass("dk_optgroup")&&(a=a.find("li:not(.disabled)").last()),!a.length&&_.length&&(a=_.prevAll("li:not(.disabled)").first().hasClass("dk_optgroup")?_.prevAll("li:not(.disabled)").first().find("li:not(.disabled)").last():_.prevAll("li:not(.disabled)").first()),$(a.length?a:w,i,e)):x(i,e),e.preventDefault();break;case f.down:h?(n=v.nextAll("li:not(.disabled)").first(),n.hasClass("dk_optgroup")&&(n=n.find("li:not(.disabled)").first()),!n.length&&_.length&&(n=_.nextAll("li:not(.disabled)").first().hasClass("dk_optgroup")?_.nextAll("li:not(.disabled)").first().find("li:not(.disabled)").first():_.nextAll("li:not(.disabled)").first()),$(n.length?n:C,i,e)):x(i,e),e.preventDefault()}if(p>=f.zero&&p<=f.z){for(d=(new Date).getTime(),null===c.finder||void 0===c.finder?(c.finder=u.toUpperCase(),c.timer=d):d>parseInt(c.timer,10)+1e3?(c.finder=u.toUpperCase(),c.timer=d):(c.finder=c.finder+u.toUpperCase(),c.timer=d),r=g.find("a"),o=0,l=r.length;l>o;o++)if(s=t(r[o]),0===s.html().toUpperCase().indexOf(c.finder)&&!s.closest(".dk_optgroup",k).hasClass("disabled")){b(s,i),$(s.parent(),i,e);break}i.data("dropkick",c)}},y=function(e){return t.trim(e).length>0?e:!1},T=function(e,i){var n,a,d,r,o,l=function(e){return k.replace("{{ value }}",e.val()).replace("{{ current }}",y(e.val())===i.value?"dk_option_current":"").replace("{{ disabled }}",void 0!==e.attr("disabled")?"disabled":"").replace("{{ text }}",t.trim(e.html())?t.trim(e.html()):" ")},s=e.replace("{{ id }}",i.id).replace("{{ label }}",i.label).replace("{{ tabindex }}",i.tabindex),p=[];if(i.options&&i.options.length)for(a=0,d=i.options.length;d>a;a++){if(r=t(i.options[a]),r.is("option"))o=0===a&&void 0!==r.attr("selected")&&void 0!==r.attr("disabled")?null:l(r);else if(r.is("optgroup")){if(o=h.replace("{{ text }}",r.attr("label")||"---").replace("{{ disabled }}",void 0!==r.attr("disabled")?" disabled":""),t(i.options[a]).children().length){o+="";for(var c=0,f=t(i.options[a]).children().length;f>c;c++){var u=t(i.options[a]).children().eq(c);o+=l(u)}o+=" "}o+=" "}p[p.length]=o}return n=t(s),n.find(".dk_options_inner").html(p.join("")),n};p.init=function(e){return e=t.extend({},g,e),u=e.dropdownTemplate?e.dropdownTemplate:u,k=e.optionTemplate?e.optionTemplate:k,!s.fired&&s.fire(),this.each(function(){var i,n,a=t(this),d=a.find(":selected").first(),o=a.children(),l=a.data("dropkick")||{},s=a.attr("id")||a.attr("name"),p=a.parent(".dk_wrap"),f=e.width||p.length?p.width()-(a.innerWidth()-a.width()):a.outerWidth(),k=a.attr("tabindex")||"0",h=!!a.attr("disabled"),g=!1;return l.id?a:(l.settings=e,l.tabindex=k,l.id=s,l.$original=d,l.$select=a,l.value=y(a.val())||y(d.attr("value")),l.label=d.text()?d.text():" ",l.options=o,l.theme=e.theme||"default",g=T(u,l),l.settings.autoWidth&&g.find(".dk_toggle").css({width:f+"px"}),h&&g.attr({disabled:"disabled",tabindex:-1}),a.before(g).appendTo(g.addClass("dk_theme_"+i)),p.length?(p.removeClass("dk_wrap"),g.show()):g.fadeIn(e.startSpeed),l.$dk=g,a.data("dropkick",l),g.addClass(a.attr("class")),g.data("dropkick",l),c[c.length]=a,g.on({"focus.dropkick":function(){_=!g.attr("disabled")&&g.addClass("dk_focus")},"blur.dropkick":function(){g.removeClass("dk_focus"),_=null}}),r&&l.settings.nativeMobile&&g.addClass("dk_mobile"),l.settings.syncReverse&&a.on("change",function(e){var i=a.val(),n=t('a[data-dk-dropdown-value="'+i+'"]',g),d=n.text();g.find(".dk_label").text(d?d:" "),$(n.parent(),g,e),l.settings.change&&l.settings.change.call(a,i,d)}),n=a.attr("form")?t("#"+a.attr("form").replace(" ",", #")):a.closest("form"),void(n.length&&n.on("reset",function(){a.dropkick("reset")})))})},p.theme=function(e){var i=t(this).data("dropkick"),n=i.$dk,a="dk_theme_"+i.theme;i.theme=e||i.theme,n.removeClass(a).addClass("dk_theme_"+e)},p.reset=function(e){return this.each(function(){var i=t(this).data("dropkick"),n=i.$dk,a=t('a[data-dk-dropdown-value="'+i.$original.attr("value")+'"]',n);i.$original.prop("selected",!0),$(a.parent(),n),b(a,n,!e)})},p.setValue=function(e){return this.each(function(){var i=t(this).data("dropkick").$dk,n=t('.dk_options a[data-dk-dropdown-value="'+e+'"]',i);n.length&&b(n,i)|$(n.parent(),i)})},p.refresh=function(e){return this.each(function(){var i,n,a=t(this).data("dropkick"),d=a.$select,r=a.$dk;a.options=d.children(),n=T(u,a).find(".dk_options_inner"),r.find(".dk_options_inner").replaceWith(n),a.$original.parent().length||(a.$original=d.find(":selected").first(),a.label=a.$original.text()),i=t('a[data-dk-dropdown-value="'+d.val()+'"]',r),$(i.parent(),r),b(i,r,!e)})},p.destroy=function(){return this.each(function(){var e=t(this).data("dropkick");e.$dk.before(function(){return e.$select.removeData("dropkick")}).remove()})},p.clone=function(e,i,n){var a=[];t.each(this,function(d){var r=t(this).data("dropkick"),o=r.settings,l=r.$select.clone();o.autoWidth&&(o.width=r.$dk.find(".dk_label").width()),i&&l.attr({id:i}),n&&l.attr({name:n}),l.removeData("dropkick"),e===!1?a[d]=l[0]:(l.dropkick(o),a[d]=l.data("dropkick").$dk[0])})},p.disable=function(e){return this.each(function(){var i=t(this).data("dropkick"),n=i.$select,a=i.$dk;e===!1?(n.removeAttr("disabled"),a.removeAttr("disabled").attr({tabindex:i.tabindex})):(a.hasClass("dk_open")&&m(a),n.attr({disabled:"disabled"}),a.attr({disabled:"disabled",tabindex:-1}))})},t.fn.dropkick=function(t){if(!d){if(p[t])return p[t].apply(this,Array.prototype.slice.call(arguments,1));if("object"==typeof t||!t)return p.init.apply(this,arguments)}}})(jQuery,window,document);
\ No newline at end of file
+(function(t,e,i){"use strict";var n=navigator.userAgent.match(/MSIE ([0-9]{1,}[\.0-9]{0,})/),a=!!n,d=a&&parseFloat(n[1])<7,r=navigator.userAgent.match(/iPad|iPhone|Android|IEMobile|BlackBerry/i),o=a?"mousedown":"click",l="onwheel"in e?"wheel":"onmousewheel"in i?"mousewheel":"MouseScrollEvent"in e&&"DOMMouseScroll MozMousePixelScroll",s={fired:!1,fire:function(){t(i).on(o,".dk_options a",function(){var e=t(this),i=e.parent(),n=e.parents(".dk_container").first();return i.hasClass("disabled")||i.closest(".dk_optgroup",n).hasClass("disabled")||(i.hasClass("dk_option_current")||(b(e,n),$(e.parent(),n)),m(n)),!1}).on(l,".dk_options_inner",function(t){var e=t.originalEvent.wheelDelta||-t.originalEvent.deltaY||-t.originalEvent.detail;return a?(this.scrollTop-=Math.round(e/10),!1):e>0&&this.scrollTop<=0||0>e&&this.scrollTop>=this.scrollHeight-this.offsetHeight?!1:!0}).on({"keydown.dk_nav":function(t){var e=v||_;e&&A(t,e)},click:function(e){var i,n=t(e.target);if(v&&0===n.closest(".dk_container").length)m(v);else{if(n.is(".dk_toggle, .dk_label"))return i=n.parents(".dk_container").first(),i.hasClass("dk_open")?m(i):(v&&m(v),!i.attr("disabled")&&x(i,e)),!1;n.attr("for")&&t("#dk_container_"+n.attr("for"))[0]&&t("#dk_container_"+n.attr("for")).trigger("focus.dropkick")}}}),this.fired=!0}},p={},c=[],f={left:37,up:38,right:39,down:40,enter:13,tab:9,zero:48,z:90,last:221},u=['"].join(""),h='{{ text }} ',k='{{ text }} ',g={startSpeed:400,theme:!1,changes:!1,syncReverse:!0,nativeMobile:!0,autoWidth:!0},v=null,_=null,b=function(t,e,i){var n=e.data("dropkick"),a=n.$select,d=t.length?t:n.$original,r=d.attr("data-dk-dropdown-value")||t.attr("value"),o=d.text();e.find(".dk_label").html(o?o:" "),i?a.val(r):a.val(r).trigger("change"),n.settings.change&&!i&&!n.settings.syncReverse&&n.settings.change.call(a,r,o)},m=function(t){t.removeClass("dk_open dk_open_top"),v=null},C=function(i){if(i.data("dropkick").settings.fixedMove)return"up"==i.data("dropkick").settings.fixedMove?!1:!0;var n=i.find(".dk_toggle"),a=i.find(".dk_options").outerHeight(),d=t(e).height()-n.outerHeight()-n.offset().top+t(e).scrollTop(),r=n.offset().top-t(e).scrollTop();return r>a?d>a:!0},w=function(t,e,i){var n=t.find(".dk_options_inner"),a=e.prevAll("li").outerHeight()*e.prevAll("li").length+(e.closest(".dk_optgroup",n).length&&e.closest(".dk_optgroup",n).prevAll("li").outerHeight()*e.closest(".dk_optgroup",n).prevAll("li").length),d=n.scrollTop(),r=n.height()+n.scrollTop()-e.outerHeight();(i&&"keydown"===i.type||d>a||a>r)&&n.scrollTop(a)},x=function(t,e){var i=C(t),n="dk_open"+(i?"":" dk_open_top");t.find(".dk_options").css({top:i?t.find(".dk_toggle").outerHeight()-1:"",bottom:i?"":t.find(".dk_toggle").outerHeight()-1}),v=t.addClass(n),w(t,t.find(".dk_option_current"),e)},$=function(t,e,i){e.find(".dk_option_current").removeClass("dk_option_current"),t.addClass("dk_option_current"),w(e,t,i)},A=function(e,i){var n,a,d,r,o,l,s,p=e.keyCode,c=i.data("dropkick"),u=String.fromCharCode(p),h=i.find(".dk_options"),k=i.hasClass("dk_open"),g=h.find("li:not(.disabled)"),v=i.find(".dk_option_current"),_=v.closest(".dk_optgroup",h),C=g.first().hasClass("dk_optgroup")?g.first().find("li:not(.disabled)").first():g.first(),w=g.last().hasClass("dk_optgroup")?g.last().find("li:not(.disabled)").last():g.last();switch(p){case f.enter:k?v.hasClass("disabled")||(b(v.find("a"),i),m(i)):x(i,e),e.preventDefault();break;case f.tab:k&&(v.length&&b(v.find("a"),i),m(i));break;case f.up:k?(a=v.prevAll("li:not(.disabled)").first(),a.hasClass("dk_optgroup")&&(a=a.find("li:not(.disabled)").last()),!a.length&&_.length&&(a=_.prevAll("li:not(.disabled)").first().hasClass("dk_optgroup")?_.prevAll("li:not(.disabled)").first().find("li:not(.disabled)").last():_.prevAll("li:not(.disabled)").first()),$(a.length?a:w,i,e)):x(i,e),e.preventDefault();break;case f.down:k?(n=v.nextAll("li:not(.disabled)").first(),n.hasClass("dk_optgroup")&&(n=n.find("li:not(.disabled)").first()),!n.length&&_.length&&(n=_.nextAll("li:not(.disabled)").first().hasClass("dk_optgroup")?_.nextAll("li:not(.disabled)").first().find("li:not(.disabled)").first():_.nextAll("li:not(.disabled)").first()),$(n.length?n:C,i,e)):x(i,e),e.preventDefault()}if(p>=f.zero&&p<=f.z){for(d=(new Date).getTime(),null===c.finder||void 0===c.finder?(c.finder=u.toUpperCase(),c.timer=d):d>parseInt(c.timer,10)+1e3?(c.finder=u.toUpperCase(),c.timer=d):(c.finder=c.finder+u.toUpperCase(),c.timer=d),r=g.find("a"),o=0,l=r.length;l>o;o++)if(s=t(r[o]),0===s.html().toUpperCase().indexOf(c.finder)&&!s.closest(".dk_optgroup",h).hasClass("disabled")){b(s,i),$(s.parent(),i,e);break}i.data("dropkick",c)}},y=function(e){return t.trim(e).length>0?e:!1},T=function(e,i){var n,a,d,r,o,l=function(e){var n=e.val(),a=e.html(),d=void 0!==e.attr("disabled");return h.replace("{{ value }}",n).replace("{{ current }}",y(n)!==i.value||d?"":"dk_option_current").replace("{{ disabled }}",d?"disabled":"").replace("{{ text }}",t.trim(a)?t.trim(a):" ")},s=e.replace("{{ id }}",i.id).replace("{{ label }}",i.label).replace("{{ tabindex }}",i.tabindex),p=[];if(i.options&&i.options.length)for(a=0,d=i.options.length;d>a;a++){if(r=t(i.options[a]),r.is("option"))o=0===a&&void 0!==r.attr("selected")&&void 0!==r.attr("disabled")?null:l(r);else if(r.is("optgroup")){if(o=k.replace("{{ text }}",r.attr("label")||"---").replace("{{ disabled }}",void 0!==r.attr("disabled")?" disabled":""),t(i.options[a]).children().length){o+="";for(var c=0,f=t(i.options[a]).children().length;f>c;c++){var u=t(i.options[a]).children().eq(c);o+=l(u)}o+=" "}o+=" "}p[p.length]=o}return n=t(s),n.find(".dk_options_inner").html(p.join("")),n};p.init=function(e){return e=t.extend({},g,e),u=e.dropdownTemplate?e.dropdownTemplate:u,h=e.optionTemplate?e.optionTemplate:h,!s.fired&&s.fire(),this.each(function(){var i,n=t(this),a=n.find(":selected").first(),d=n.children(),o=n.data("dropkick")||{},l=n.attr("id")||n.attr("name"),s=n.parent(".dk_wrap"),p=e.width||s.length?s.width()-(n.innerWidth()-n.width()):n.outerWidth(),f=n.attr("tabindex")||"0",h=!!n.attr("disabled"),k=!1;return o.id?n:(o.settings=e,o.tabindex=f,o.id=l,o.$original=a,o.$select=n,o.value=y(n.val())||y(a.attr("value")),o.label=a.text()?a.text():" ",o.options=d,o.theme=e.theme||"default",k=T(u,o),o.settings.autoWidth&&k.find(".dk_toggle").css({width:p+"px"}),h&&k.attr({disabled:"disabled",tabindex:-1}),n.before(k).appendTo(k.addClass("dk_theme_"+o.theme)),s.length?(s.removeClass("dk_wrap"),k.show()):k.fadeIn(e.startSpeed),o.$dk=k,n.data("dropkick",o),k.addClass(n.attr("class")),k.data("dropkick",o),c[c.length]=n,k.on({"focus.dropkick":function(){_=!k.attr("disabled")&&k.addClass("dk_focus")},"blur.dropkick":function(){k.removeClass("dk_focus"),_=null}}),r&&o.settings.nativeMobile&&k.addClass("dk_mobile"),o.settings.syncReverse&&n.on("change",function(e){var i=n.val(),a=t('a[data-dk-dropdown-value="'+i+'"]',k),d=a.text();k.find(".dk_label").html(d?d:" "),$(a.parent(),k,e),o.settings.change&&o.settings.change.call(n,i,d)}),i=n.attr("form")?t("#"+n.attr("form").replace(" ",", #")):n.closest("form"),void(i.length&&i.on("reset",function(){n.dropkick("reset")})))})},p.theme=function(e){var i=t(this).data("dropkick"),n=i.$dk,a="dk_theme_"+i.theme;i.theme=e||i.theme,n.removeClass(a).addClass("dk_theme_"+e)},p.reset=function(e){return this.each(function(){var i=t(this).data("dropkick"),n=i.$dk,a=t('a[data-dk-dropdown-value="'+i.$original.attr("value")+'"]',n);i.$original.prop("selected",!0),$(a.parent(),n),b(a,n,!e)})},p.setValue=function(e){return this.each(function(){var i=t(this).data("dropkick").$dk,n=t('.dk_options a[data-dk-dropdown-value="'+e+'"]',i);n.length&&b(n,i)|$(n.parent(),i)})},p.refresh=function(e){return this.each(function(){var i,n,a=t(this).data("dropkick"),d=a.$select,r=a.$dk;a.options=d.children(),n=T(u,a).find(".dk_options_inner"),r.find(".dk_options_inner").replaceWith(n),a.$original.parent().length||(a.$original=d.find(":selected").first(),a.label=a.$original.text()),i=t('a[data-dk-dropdown-value="'+d.val()+'"]',r),$(i.parent(),r),b(i,r,!e)})},p.destroy=function(){return this.each(function(){var e=t(this).data("dropkick");e.$dk.before(function(){return e.$select.removeData("dropkick")}).remove()})},p.clone=function(e,i,n){var a=[];t.each(this,function(d){var r=t(this).data("dropkick"),o=r.settings,l=r.$select.clone();o.autoWidth&&(o.width=r.$dk.find(".dk_label").width()),i&&l.attr({id:i}),n&&l.attr({name:n}),l.removeData("dropkick"),e===!1?a[d]=l[0]:(l.dropkick(o),a[d]=l.data("dropkick").$dk[0])})},p.disable=function(e){return this.each(function(){var i=t(this).data("dropkick"),n=i.$select,a=i.$dk;e===!1?(n.removeAttr("disabled"),a.removeAttr("disabled").attr({tabindex:i.tabindex})):(a.hasClass("dk_open")&&m(a),n.attr({disabled:"disabled"}),a.attr({disabled:"disabled",tabindex:-1}))})},t.fn.dropkick=function(t){if(!d){if(p[t])return p[t].apply(this,Array.prototype.slice.call(arguments,1));if("object"==typeof t||!t)return p.init.apply(this,arguments)}}})(jQuery,window,document);
\ No newline at end of file
diff --git a/jquery.dropkick.js b/jquery.dropkick.js
index 77633a3b..ae497228 100755
--- a/jquery.dropkick.js
+++ b/jquery.dropkick.js
@@ -1,5 +1,5 @@
/*
- * DropKick 1.5
+ * DropKick 1.5.1
*
* Highly customizable lists
* https://github.com/robdel12/DropKick
@@ -34,7 +34,7 @@
if(!$value.hasClass('disabled') && !$value.closest('.dk_optgroup',$dk).hasClass('disabled')){
if (!$value.hasClass('dk_option_current')) { // Also check if this isn't the selected option
updateFields($option, $dk);
- setCurrent($option.parent(), $dk); // IE8+, iOS4 and some Android [4.0] Browsers back to scrollTop 0 when an option is clicked and the dropdown is opened again
+ setCurrent($option.parent(), $dk); // IE8+, iOS4 and some Android [4.0] Browsers back to scrollTop 0 when an option is clicked and the dropdown is opened again
}
closeDropdown($dk);
}
@@ -130,15 +130,16 @@
// private
// Update the value, and the dropdown label
updateFields = function(option, $dk, reset) {
- var
- value = option.attr('data-dk-dropdown-value'),
- label = option.text(),
+ var
data = $dk.data('dropkick'),
- $select = data.$select
+ $select = data.$select,
+ $option = option.length ? option : data.$original,
+ value = $option.attr('data-dk-dropdown-value') || option.attr('value'),
+ label = $option.text()
;
- $dk.find('.dk_label').text(!!label?label:' ');
-
+ $dk.find('.dk_label').html(!!label?label:' ');
+
!reset ? $select.val(value).trigger('change') : $select.val(value); // Let it act like a normal select when needed
data.settings.change && !reset && !data.settings.syncReverse && data.settings.change.call($select, value, label);
@@ -306,10 +307,15 @@
var
// Template for the dropdown
buildOption = function($el) {
- return optionTemplate.replace('{{ value }}', $el.val())
- .replace('{{ current }}', (notBlank($el.val()) === view.value) ? 'dk_option_current' : '')
- .replace('{{ disabled }}', ($el.attr('disabled') !== undefined) ? 'disabled' : '')
- .replace('{{ text }}', !!$.trim($el.html()) ? $.trim($el.html()) : ' ' )
+ var
+ value = $el.val(),
+ html = $el.html(),
+ disabled = $el.attr('disabled') !== undefined
+ ;
+ return optionTemplate.replace('{{ value }}', value)
+ .replace('{{ current }}', (notBlank(value) === view.value && !disabled) ? 'dk_option_current' : '')
+ .replace('{{ disabled }}', (disabled) ? 'disabled' : '')
+ .replace('{{ text }}', !!$.trim(html) ? $.trim(html) : ' ' )
;
},
template = tpl.replace('{{ id }}', view.id).replace('{{ label }}', view.label).replace('{{ tabindex }}', view.tabindex),
@@ -325,7 +331,7 @@
if (view.options && view.options.length) {
for (i = 0, l = view.options.length; i < l; i++) {
$option = $(view.options[i]);
-
+
if ($option.is('option')) {
oTemplate = (i === 0 && $option.attr('selected') !== undefined && $option.attr('disabled') !== undefined) ? null : buildOption($option);
} else if ($option.is('optgroup')) {
@@ -339,7 +345,7 @@
oTemplate += '';
}
oTemplate += '';
-
+
}
options[options.length] = oTemplate;
@@ -398,8 +404,6 @@
// The completed dk_container element
$dk = false,
- theme,
-
// The form relative to the select
$form
;
@@ -430,13 +434,13 @@
// Hide the list and place our new one in front of it
// $dk = $('div[id="dk_container_' + id + '"]').fadeIn(settings.startSpeed);
// To permite cloning methods, will no more need to update the reference to $dk
- $select.before($dk).appendTo($dk.addClass('dk_theme_' + theme));
+ $select.before($dk).appendTo($dk.addClass('dk_theme_' + data.theme));
if ($wrap.length) {
$wrap.removeClass('dk_wrap');
$dk.show();
} else {
- $dk.fadeIn(settings.startSpeed)
+ $dk.fadeIn(settings.startSpeed);
}
// Save the updated $dk reference into our data object
@@ -471,7 +475,7 @@
label = option.text()
;
- $dk.find('.dk_label').text(!!label?label:' ');
+ $dk.find('.dk_label').html(!!label?label:' ');
setCurrent(option.parent(), $dk, e);
data.settings.change && data.settings.change.call($select, value, label);
});
@@ -539,7 +543,7 @@
$current,
$dkopts
;
- // Update data options
+ // Update data options
data.options = $select.children();
// Rebuild options list. filter options inner and replace
$dkopts = build(dropdownTemplate, data).find('.dk_options_inner');
@@ -594,7 +598,7 @@
$clone.dropkick(settings);
toReturn[i] = $clone.data('dropkick').$dk[0];
}
-
+
});
};
diff --git a/package.json b/package.json
index 8fc3f38c..f15b3295 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "DropKick",
- "version": "1.5.0",
+ "version": "1.5.1",
"description": "A jQuery plugin for creating beautiful, graceful, and painless custom dropdowns.",
"main": "jquery.dropkick-min.js",
"directories": {