diff --git a/_src/selectordie.js b/_src/selectordie.js
index 59d0063..330aacd 100644
--- a/_src/selectordie.js
+++ b/_src/selectordie.js
@@ -32,7 +32,8 @@
linksExternal: false, // Boolean - false by default - Should the options be treated as links and open in a new window/tab?
size: 0, // Integer - 0 by default - The value set equals the amount of items before scroll is needed
tabIndex: 0, // integer - 0 by default
- onChange: $.noop // Adds a callback function for when the SoD gets changed
+ onChange: $.noop, // Adds a callback function for when the SoD gets changed
+ forceNative: false // Forces native select
},
$_settings = {},
$_sodKeysWhenClosed = false,
@@ -58,6 +59,7 @@
$settingsSize = parseInt($select.data("size")) ? $select.data("size") : $_settings.size,
$settingsTabIndex = parseInt($select.data("tabindex")) ? $select.data("tabindex") : ( $_settings.tabIndex ? $_settings.tabIndex : ( $select.attr("tabindex") ? $select.attr("tabindex") : $_settings.tabIndex ) ),
$settingsStripEmpty = $select.data("strip-empty") ? $select.data("strip-empty") : $_settings.stripEmpty,
+ $forceNative = $select.data("force-native") ? $select.data("force-native") : $_settings.forceNative,
$selectTitle = $select.prop("title") ? $select.prop("title") : null,
$selectDisabled = $select.is(":disabled") ? " disabled" : "",
$sodPrefix = "",
@@ -95,7 +97,7 @@
}).insertAfter( this );
// If it's a touch device
- if ( _private.isTouch() ) {
+ if ( _private.isTouch() || $forceNative ) {
$sod.addClass("touch");
}
diff --git a/_src/selectordie.min.js b/_src/selectordie.min.js
index 011242e..06d9456 100644
--- a/_src/selectordie.min.js
+++ b/_src/selectordie.min.js
@@ -1,16 +1 @@
-/* ===========================================================
- *
- * Name: selectordie.min.js
- * Updated: 2014-10-11
- * Version: 0.1.8
- * Created by: Per V @ Vst.mn
- * What?: Minified version of the Select or Die JS
- *
- * Copyright (c) 2014 Per Vestman
- * Dual licensed under the MIT and GPL licenses.
- *
- * Beards, Rock & Loud Guns | Cogs 'n Kegs
- *
- * =========================================================== */
-
-!function(a){"use strict";a.fn.selectOrDie=function(b){var f,g,c={customID:null,customClass:"",placeholder:null,placeholderOption:!1,prefix:null,cycle:!1,stripEmpty:!1,links:!1,linksExternal:!1,size:0,tabIndex:0,onChange:a.noop},d={},e=!1,h={initSoD:function(b){return d=a.extend({},c,b),this.each(function(){if(a(this).parent().hasClass("sod_select"))console.log("Select or Die: It looks like the SoD already exists");else{var u,v,w,b=a(this),c=b.data("custom-id")?b.data("custom-id"):d.customID,e=b.data("custom-class")?b.data("custom-class"):d.customClass,f=b.data("prefix")?b.data("prefix"):d.prefix,g=b.data("placeholder")?b.data("placeholder"):d.placeholder,i=b.data("placeholder-option")?b.data("placeholder-option"):d.placeholderOption,j=b.data("cycle")?b.data("cycle"):d.cycle,k=b.data("links")?b.data("links"):d.links,l=b.data("links-external")?b.data("links-external"):d.linksExternal,m=parseInt(b.data("size"))?b.data("size"):d.size,n=parseInt(b.data("tabindex"))?b.data("tabindex"):d.tabIndex?d.tabIndex:b.attr("tabindex")?b.attr("tabindex"):d.tabIndex,o=b.data("strip-empty")?b.data("strip-empty"):d.stripEmpty,p=b.prop("title")?b.prop("title"):null,q=b.is(":disabled")?" disabled":"",r="",s="",t=0;f&&(r=''+f+" "),s+=g&&!f?''+g+"":''+r+"",u=a("",{id:c,"class":"sod_select "+e+q,title:p,tabindex:n,html:s,"data-cycle":j,"data-links":k,"data-links-external":l,"data-placeholder":g,"data-placeholder-option":i,"data-prefix":f,"data-filter":""}).insertAfter(this),h.isTouch()&&u.addClass("touch"),v=a("",{"class":"sod_list_wrapper"}).appendTo(u),w=a("",{"class":"sod_list"}).appendTo(v),a("option, optgroup",b).each(function(b){var c=a(this);o&&!a.trim(c.text())?c.remove():0===b&&i&&!r?h.populateSoD(c,w,u,!0):h.populateSoD(c,w,u,!1)}),m&&(v.show(),a(".sod_option:lt("+m+")",w).each(function(){t+=a(this).outerHeight()}),v.removeAttr("style"),w.css({"max-height":t})),b.appendTo(u),u.on("focusin",h.focusSod).on("click",h.triggerSod).on("click",".sod_option",h.optionClick).on("mousemove",".sod_option",h.optionHover).on("keydown",h.keyboardUse),b.on("change",h.selectChange),a(document).on("click","label[for='"+b.attr("id")+"']",function(a){a.preventDefault(),u.focus()})}})},populateSoD:function(b,c,d,e){var f=d.data("placeholder"),g=d.data("placeholder-option"),h=d.data("prefix"),i=d.find(".sod_label"),j=b.parent(),k=b.text(),l=b.val(),m=b.data("custom-id")?b.data("custom-id"):null,n=b.data("custom-class")?b.data("custom-class"):"",o=b.is(":disabled")?" disabled ":"",p=b.is(":selected")?" selected active ":"",q=b.data("link")?" link ":"",r=b.data("link-external")?" linkexternal":"",s=b.prop("label");b.is("option")?(a("",{"class":"sod_option "+n+o+p+q+r,id:m,title:k,html:k,"data-value":l}).appendTo(c),e&&!h?(d.data("label",k),d.data("placeholder",k),b.prop("disabled",!0),c.find(".sod_option:last").addClass("is-placeholder disabled"),p&&i.addClass("sod_placeholder")):p&&f&&!g&&!h?d.data("label",f):p&&d.data("label",k),(p&&!f||p&&g||p&&h)&&i.append(k),j.is("optgroup")&&(c.find(".sod_option:last").addClass("groupchild"),j.is(":disabled")&&c.find(".sod_option:last").addClass("disabled"))):a("",{"class":"sod_option optgroup "+o,title:s,html:s,"data-label":s}).appendTo(c)},focusSod:function(){var b=a(this);b.hasClass("disabled")?h.blurSod(b):(h.blurSod(a(".sod_select.focus").not(b)),b.addClass("focus"),a("html").on("click.sodBlur",function(){h.blurSod(b)}))},triggerSod:function(b){b.stopPropagation();var c=a(this),d=c.find(".sod_list"),e=c.data("placeholder"),f=c.find(".active"),i=c.find(".selected");c.hasClass("disabled")||c.hasClass("open")||c.hasClass("touch")?(clearTimeout(g),c.removeClass("open"),e&&(c.find(".sod_label").get(0).lastChild.nodeValue=f.text())):(c.addClass("open"),e&&!c.data("prefix")&&c.find(".sod_label").addClass("sod_placeholder").html(e),h.listScroll(d,i),h.checkViewport(c,d))},keyboardUse:function(b){var l,m,n,c=a(this),d=c.find(".sod_list"),g=c.find(".sod_option"),i=c.find(".sod_label"),j=c.data("cycle"),k=g.filter(".active");return b.which>36&&b.which<41?(37===b.which||38===b.which?(m=k.prevAll(":not('.disabled, .optgroup')").first(),n=g.not(".disabled, .optgroup").last()):(39===b.which||40===b.which)&&(m=k.nextAll(":not('.disabled, .optgroup')").first(),n=g.not(".disabled, .optgroup").first()),!m.hasClass("sod_option")&&j&&(m=n),(m.hasClass("sod_option")||j)&&(k.removeClass("active"),m.addClass("active"),i.get(0).lastChild.nodeValue=m.text(),h.listScroll(d,m),c.hasClass("open")||(e=!0)),!1):(13===b.which||32===b.which&&c.hasClass("open")&&(" "===c.data("filter")[0]||""===c.data("filter"))?(b.preventDefault(),k.click()):32!==b.which||c.hasClass("open")||" "!==c.data("filter")[0]&&""!==c.data("filter")?27===b.which&&h.blurSod(c):(b.preventDefault(),e=!1,c.click()),0!==b.which&&(clearTimeout(f),c.data("filter",c.data("filter")+String.fromCharCode(b.which)),l=g.filter(function(){return 0===a(this).text().toLowerCase().indexOf(c.data("filter").toLowerCase())}).not(".disabled, .optgroup").first(),l.length&&(k.removeClass("active"),l.addClass("active"),h.listScroll(d,l),i.get(0).lastChild.nodeValue=l.text(),c.hasClass("open")||(e=!0)),f=setTimeout(function(){c.data("filter","")},500)),void 0)},optionHover:function(){var b=a(this);b.hasClass("disabled")||b.hasClass("optgroup")||b.siblings().removeClass("active").end().addClass("active")},optionClick:function(b){b.stopPropagation();var c=a(this),d=c.closest(".sod_select"),e=c.hasClass("disabled"),f=c.hasClass("optgroup"),h=d.find(".sod_option:not('.optgroup')").index(this);d.hasClass("touch")||(e||f||(d.find(".selected, .sod_placeholder").removeClass("selected sod_placeholder"),c.addClass("selected"),d.find("select option")[h].selected=!0,d.find("select").change()),clearTimeout(g),d.removeClass("open"))},selectChange:function(){var b=a(this),c=b.find(":selected"),e=c.text(),f=b.closest(".sod_select");f.find(".sod_label").get(0).lastChild.nodeValue=e,f.data("label",e),d.onChange.call(this),!f.data("links")&&!c.data("link")||c.data("link-external")?(f.data("links-external")||c.data("link-external"))&&window.open(c.val(),"_blank"):window.location.href=c.val()},blurSod:function(b){if(a("body").find(b).length){var c=b.data("label"),d=b.data("placeholder"),f=b.find(".active"),h=b.find(".selected"),i=!1;clearTimeout(g),e&&!f.hasClass("selected")?(f.click(),i=!0):f.hasClass("selected")||(f.removeClass("active"),h.addClass("active")),!i&&d?b.find(".sod_label").get(0).lastChild.nodeValue=h.text():i||(b.find(".sod_label").get(0).lastChild.nodeValue=c),e=!1,b.removeClass("open focus"),b.blur(),a("html").off(".sodBlur")}},checkViewport:function(b,c){var d=b[0].getBoundingClientRect(),e=c.outerHeight();d.bottom+e+10>a(window).height()&&d.top-e>10?b.addClass("above"):b.removeClass("above"),g=setTimeout(function(){h.checkViewport(b,c)},200)},listScroll:function(a,b){var c=a[0].getBoundingClientRect(),d=b[0].getBoundingClientRect();c.top>d.top?a.scrollTop(a.scrollTop()-c.top+d.top):c.bottom0||navigator.msMaxTouchPoints>0}},i={destroy:function(){return this.each(function(){var b=a(this),c=b.parent();c.hasClass("sod_select")?(b.off("change"),c.find("span").remove(),b.unwrap()):console.log("Select or Die: There's no SoD to destroy")})},update:function(){return this.each(function(){var b=a(this),c=b.parent(),d=c.find(".sod_list:first");c.hasClass("sod_select")?(d.empty(),c.find(".sod_label").get(0).lastChild.nodeValue="",b.is(":disabled")&&c.addClass("disabled"),a("option, optgroup",b).each(function(){h.populateSoD(a(this),d,c)})):console.log("Select or Die: There's no SoD to update")})},disable:function(b){return this.each(function(){var c=a(this),d=c.parent();d.hasClass("sod_select")?"undefined"!=typeof b?(d.find(".sod_list:first .sod_option[data-value='"+b+"']").addClass("disabled"),d.find(".sod_list:first .sod_option[data-label='"+b+"']").nextUntil(":not(.groupchild)").addClass("disabled"),a("option[value='"+b+"'], optgroup[label='"+b+"']",this).prop("disabled",!0)):d.hasClass("sod_select")&&(d.addClass("disabled"),c.prop("disabled",!0)):console.log("Select or Die: There's no SoD to disable")})},enable:function(b){return this.each(function(){var c=a(this),d=c.parent();d.hasClass("sod_select")?"undefined"!=typeof b?(d.find(".sod_list:first .sod_option[data-value='"+b+"']").removeClass("disabled"),d.find(".sod_list:first .sod_option[data-label='"+b+"']").nextUntil(":not(.groupchild)").removeClass("disabled"),a("option[value='"+b+"'], optgroup[label='"+b+"']",this).prop("disabled",!1)):d.hasClass("sod_select")&&(d.removeClass("disabled"),c.prop("disabled",!1)):console.log("Select or Die: There's no SoD to enable")})}};return i[b]?i[b].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof b&&b?(a.error('Select or Die: Oh no! No such method "'+b+'" for the SoD instance'),void 0):h.initSoD.apply(this,arguments)}}(jQuery);
+(function(e){"use strict";e.fn.selectOrDie=function(a){var t={customID:null,customClass:"",placeholder:null,placeholderOption:false,prefix:null,cycle:false,stripEmpty:false,links:false,linksExternal:false,size:0,tabIndex:0,onChange:e.noop,forceNative:false},s={},l=false,o,i;var d={initSoD:function(a){s=e.extend({},t,a);return this.each(function(){if(!e(this).parent().hasClass("sod_select")){var a=e(this),t=a.data("custom-id")?a.data("custom-id"):s.customID,l=a.data("custom-class")?a.data("custom-class"):s.customClass,o=a.data("prefix")?a.data("prefix"):s.prefix,i=a.data("placeholder")?a.data("placeholder"):s.placeholder,n=a.data("placeholder-option")?a.data("placeholder-option"):s.placeholderOption,r=a.data("cycle")?a.data("cycle"):s.cycle,c=a.data("links")?a.data("links"):s.links,p=a.data("links-external")?a.data("links-external"):s.linksExternal,f=parseInt(a.data("size"))?a.data("size"):s.size,h=parseInt(a.data("tabindex"))?a.data("tabindex"):s.tabIndex?s.tabIndex:a.attr("tabindex")?a.attr("tabindex"):s.tabIndex,u=a.data("strip-empty")?a.data("strip-empty"):s.stripEmpty,b=a.data("force-native")?a.data("force-native"):s.forceNative,C=a.prop("title")?a.prop("title"):null,v=a.is(":disabled")?" disabled":"",g="",m="",_=0,x,k,S;if(o){g=''+o+" "}if(i&&!o){m+=''+i+""}else{m+=''+g+""}x=e("",{id:t,"class":"sod_select "+l+v,title:C,tabindex:h,html:m,"data-cycle":r,"data-links":c,"data-links-external":p,"data-placeholder":i,"data-placeholder-option":n,"data-prefix":o,"data-filter":""}).insertAfter(this);if(d.isTouch()||b){x.addClass("touch")}k=e("",{"class":"sod_list_wrapper"}).appendTo(x);S=e("",{"class":"sod_list"}).appendTo(k);e("option, optgroup",a).each(function(a){var t=e(this);if(u&&!e.trim(t.text())){t.remove()}else if(a===0&&n&&!g)d.populateSoD(t,S,x,true);else{d.populateSoD(t,S,x,false)}});if(f){k.show();e(".sod_option:lt("+f+")",S).each(function(){_+=e(this).outerHeight()});k.removeAttr("style");S.css({"max-height":_})}a.appendTo(x);x.on("focusin",d.focusSod).on("click",d.triggerSod).on("click",".sod_option",d.optionClick).on("mousemove",".sod_option",d.optionHover).on("keydown",d.keyboardUse);a.on("change",d.selectChange);e(document).on("click","label[for='"+a.attr("id")+"']",function(e){e.preventDefault();x.focus()})}else{console.log("Select or Die: It looks like the SoD already exists")}})},populateSoD:function(a,t,s,l){var o=s.data("placeholder"),i=s.data("placeholder-option"),d=s.data("prefix"),n=s.find(".sod_label"),r=a.parent(),c=a.text(),p=a.val(),f=a.data("custom-id")?a.data("custom-id"):null,h=a.data("custom-class")?a.data("custom-class"):"",u=a.is(":disabled")?" disabled ":"",b=a.is(":selected")?" selected active ":"",C=a.data("link")?" link ":"",v=a.data("link-external")?" linkexternal":"",g=a.prop("label");if(a.is("option")){e("",{"class":"sod_option "+h+u+b+C+v,id:f,title:c,html:c,"data-value":p}).appendTo(t);if(l&&!d){s.data("label",c);s.data("placeholder",c);a.prop("disabled",true);t.find(".sod_option:last").addClass("is-placeholder disabled");if(b){n.addClass("sod_placeholder")}}else if(b&&o&&!i&&!d){s.data("label",o)}else if(b){s.data("label",c)}if(b&&!o||b&&i||b&&d){n.append(c)}if(r.is("optgroup")){t.find(".sod_option:last").addClass("groupchild");if(r.is(":disabled")){t.find(".sod_option:last").addClass("disabled")}}}else{e("",{"class":"sod_option optgroup "+u,title:g,html:g,"data-label":g}).appendTo(t)}},focusSod:function(){var a=e(this);if(!a.hasClass("disabled")){d.blurSod(e(".sod_select.focus").not(a));a.addClass("focus");e("html").on("click.sodBlur",function(){d.blurSod(a)})}else{d.blurSod(a)}},triggerSod:function(a){a.stopPropagation();var t=e(this),s=t.find(".sod_list"),l=t.data("placeholder"),o=t.find(".active"),n=t.find(".selected");if(!t.hasClass("disabled")&&!t.hasClass("open")&&!t.hasClass("touch")){t.addClass("open");if(l&&!t.data("prefix")){t.find(".sod_label").addClass("sod_placeholder").html(l)}d.listScroll(s,n);d.checkViewport(t,s)}else{clearTimeout(i);t.removeClass("open");if(l){t.find(".sod_label").get(0).lastChild.nodeValue=o.text()}}},keyboardUse:function(a){var t=e(this),s=t.find(".sod_list"),i=t.find(".sod_option"),n=t.find(".sod_label"),r=t.data("cycle"),c=i.filter(".active"),p,f,h;if(a.which>36&&a.which<41){if(a.which===37||a.which===38){f=c.prevAll(":not('.disabled, .optgroup')").first();h=i.not(".disabled, .optgroup").last()}else if(a.which===39||a.which===40){f=c.nextAll(":not('.disabled, .optgroup')").first();h=i.not(".disabled, .optgroup").first()}if(!f.hasClass("sod_option")&&r){f=h}if(f.hasClass("sod_option")||r){c.removeClass("active");f.addClass("active");n.get(0).lastChild.nodeValue=f.text();d.listScroll(s,f);if(!t.hasClass("open")){l=true}}return false}else if(a.which===13||a.which===32&&t.hasClass("open")&&(t.data("filter")[0]===" "||t.data("filter")==="")){a.preventDefault();c.click()}else if(a.which===32&&!t.hasClass("open")&&(t.data("filter")[0]===" "||t.data("filter")==="")){a.preventDefault();l=false;t.click()}else if(a.which===27){d.blurSod(t)}if(a.which!==0){clearTimeout(o);t.data("filter",t.data("filter")+String.fromCharCode(a.which));p=i.filter(function(){return e(this).text().toLowerCase().indexOf(t.data("filter").toLowerCase())===0}).not(".disabled, .optgroup").first();if(p.length){c.removeClass("active");p.addClass("active");d.listScroll(s,p);n.get(0).lastChild.nodeValue=p.text();if(!t.hasClass("open")){l=true}}o=setTimeout(function(){t.data("filter","")},500)}},optionHover:function(){var a=e(this);if(!a.hasClass("disabled")&&!a.hasClass("optgroup")){a.siblings().removeClass("active").end().addClass("active")}},optionClick:function(a){a.stopPropagation();var t=e(this),s=t.closest(".sod_select"),l=t.hasClass("disabled"),o=t.hasClass("optgroup"),d=s.find(".sod_option:not('.optgroup')").index(this);if(s.hasClass("touch")){return}if(!l&&!o){s.find(".selected, .sod_placeholder").removeClass("selected sod_placeholder");t.addClass("selected");s.find("select option")[d].selected=true;s.find("select").change()}clearTimeout(i);s.removeClass("open")},selectChange:function(){var a=e(this),t=a.find(":selected"),l=t.text(),o=a.closest(".sod_select");o.find(".sod_label").get(0).lastChild.nodeValue=l;o.data("label",l);s.onChange.call(this);if((o.data("links")||t.data("link"))&&!t.data("link-external")){window.location.href=t.val()}else if(o.data("links-external")||t.data("link-external")){window.open(t.val(),"_blank")}},blurSod:function(a){if(e("body").find(a).length){var t=a.data("label"),s=a.data("placeholder"),o=a.find(".active"),d=a.find(".selected"),n=false;clearTimeout(i);if(l&&!o.hasClass("selected")){o.click();n=true}else if(!o.hasClass("selected")){o.removeClass("active");d.addClass("active")}if(!n&&s){a.find(".sod_label").get(0).lastChild.nodeValue=d.text()}else if(!n){a.find(".sod_label").get(0).lastChild.nodeValue=t}l=false;a.removeClass("open focus");a.blur();e("html").off(".sodBlur")}},checkViewport:function(a,t){var s=a[0].getBoundingClientRect(),l=t.outerHeight();if(s.bottom+l+10>e(window).height()&&s.top-l>10){a.addClass("above")}else{a.removeClass("above")}i=setTimeout(function(){d.checkViewport(a,t)},200)},listScroll:function(e,a){var t=e[0].getBoundingClientRect(),s=a[0].getBoundingClientRect();if(t.top>s.top){e.scrollTop(e.scrollTop()-t.top+s.top)}else if(t.bottom0||navigator.msMaxTouchPoints>0}};var n={destroy:function(){return this.each(function(){var a=e(this),t=a.parent();if(t.hasClass("sod_select")){a.off("change");t.find("span").remove();a.unwrap()}else{console.log("Select or Die: There's no SoD to destroy")}})},update:function(){return this.each(function(){var a=e(this),t=a.parent(),s=t.find(".sod_list:first");if(t.hasClass("sod_select")){s.empty();t.find(".sod_label").get(0).lastChild.nodeValue="";if(a.is(":disabled")){t.addClass("disabled")}e("option, optgroup",a).each(function(){d.populateSoD(e(this),s,t)})}else{console.log("Select or Die: There's no SoD to update")}})},disable:function(a){return this.each(function(){var t=e(this),s=t.parent();if(s.hasClass("sod_select")){if(typeof a!=="undefined"){s.find(".sod_list:first .sod_option[data-value='"+a+"']").addClass("disabled");s.find(".sod_list:first .sod_option[data-label='"+a+"']").nextUntil(":not(.groupchild)").addClass("disabled");e("option[value='"+a+"'], optgroup[label='"+a+"']",this).prop("disabled",true)}else if(s.hasClass("sod_select")){s.addClass("disabled");t.prop("disabled",true)}}else{console.log("Select or Die: There's no SoD to disable")}})},enable:function(a){return this.each(function(){var t=e(this),s=t.parent();if(s.hasClass("sod_select")){if(typeof a!=="undefined"){s.find(".sod_list:first .sod_option[data-value='"+a+"']").removeClass("disabled");s.find(".sod_list:first .sod_option[data-label='"+a+"']").nextUntil(":not(.groupchild)").removeClass("disabled");e("option[value='"+a+"'], optgroup[label='"+a+"']",this).prop("disabled",false)}else if(s.hasClass("sod_select")){s.removeClass("disabled");t.prop("disabled",false)}}else{console.log("Select or Die: There's no SoD to enable")}})}};if(n[a]){return n[a].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof a==="object"||!a){return d.initSoD.apply(this,arguments)}else{e.error('Select or Die: Oh no! No such method "'+a+'" for the SoD instance')}}})(jQuery);
\ No newline at end of file