diff --git a/dist/jquery.ddslick.min.js b/dist/jquery.ddslick.min.js index 0f5ba46..4a39ad5 100644 --- a/dist/jquery.ddslick.min.js +++ b/dist/jquery.ddslick.min.js @@ -1 +1 @@ -!function(e){function d(e,d){var i=e.find(".dd-option-value[value= '"+d+"']").parents("li").prevAll().length;t(e,i)}function t(e,d){var t=e.data("ddslick"),i=e.find(".dd-selected"),s=i.siblings(".dd-selected-value"),l=e.find(".dd-option").eq(d),a=l.closest("li"),c=t.settings,r=t.settings.data[d];e.find(".dd-option").removeClass("dd-option-selected"),l.addClass("dd-option-selected"),t.selectedIndex=d,t.selectedItem=a,t.selectedData=r,c.showSelectedHTML?i.html((r.imageSrc?"":"")+(r.text?"":"")+(r.description?""+r.description+"":"")):i.html(r.text),s.val(r.value),t.original.val(r.value),e.data("ddslick",t),n(e),o(e),"function"==typeof c.onSelected&&c.onSelected.call(this,t)}function i(d){var t=d.find(".dd-select"),i=t.siblings(".dd-options"),n=t.find(".dd-pointer"),o=i.is(":visible");e(".dd-click-off-close").not(i).slideUp(50),e(".dd-pointer").removeClass("dd-pointer-up"),t.removeClass("dd-open"),o?(i.slideUp("fast"),n.removeClass("dd-pointer-up"),t.removeClass("dd-open")):(t.addClass("dd-open"),i.slideDown("fast"),n.addClass("dd-pointer-up")),s(d)}function n(e){e.find(".dd-select").removeClass("dd-open"),e.find(".dd-options").slideUp(50),e.find(".dd-pointer").removeClass("dd-pointer-up").removeClass("dd-pointer-up")}function o(e){var d=e.find(".dd-select").css("height"),t=e.find(".dd-selected-description"),i=e.find(".dd-selected-image");t.length<=0&&i.length>0&&e.find(".dd-selected-text").css("lineHeight",d)}function s(d){d.find(".dd-option").each(function(){var t=e(this),i=t.css("height"),n=t.find(".dd-option-description"),o=d.find(".dd-option-image");n.length<=0&&o.length>0&&t.find(".dd-option-text").css("lineHeight",i)})}e.fn.ddslick=function(d){return l[d]?l[d].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof d&&d?void e.error("Method "+d+" does not exists."):l.init.apply(this,arguments)};var l={},a={data:[],keepJSONItemsOnTop:!1,width:260,height:null,background:"#eee",selectText:"",defaultSelectedIndex:null,truncateDescription:!0,imagePosition:"left",showSelectedHTML:!0,clickOffToClose:!0,embedCSS:!0,onSelected:function(){}},c="
",r="",p="";l.init=function(d){var n=e.extend({},a,d);return e("#css-ddslick").length<=0&&n.embedCSS&&e(p).appendTo("head"),this.each(function(){var n=e.extend({},a,d),o=e(this),s=o.data("ddslick");if(!s){var l=[];o.find("option").each(function(){var d=e(this),t=d.data();l.push({text:e.trim(d.text()),value:d.val(),selected:d.is(":selected"),description:t.description,imageSrc:t.imagesrc})}),n.keepJSONItemsOnTop?e.merge(n.data,l):n.data=e.merge(l,n.data);var p=o,f=e(""+(d.value?" ":"")+(d.imageSrc?" ":"")+(d.text?" ":"")+(d.description?" "+d.description+"":"")+"")});var h={settings:n,original:p,selectedIndex:-1,selectedItem:null,selectedData:null};if(o.data("ddslick",h),n.selectText.length>0&&null==n.defaultSelectedIndex)o.find(".dd-selected").html(n.selectText);else{var g=null!=n.defaultSelectedIndex&&n.defaultSelectedIndex>=0&&n.defaultSelectedIndex":"")+(r.text?"":"")+(r.description?""+r.description+"":"")):i.html(r.text),s.val(r.value),t.original.val(r.value),e.data("ddslick",t),n(e),o(e),"function"==typeof c.onSelected&&c.onSelected.call(this,t)}function i(d){var t=d.find(".dd-select"),i=t.siblings(".dd-options"),n=t.find(".dd-pointer"),o=i.is(":visible");e(".dd-click-off-close").not(i).slideUp(50),e(".dd-pointer").removeClass("dd-pointer-up"),t.removeClass("dd-open"),o?(i.slideUp("fast"),n.removeClass("dd-pointer-up"),t.removeClass("dd-open")):(t.addClass("dd-open"),i.slideDown("fast"),n.addClass("dd-pointer-up")),s(d)}function n(e){e.find(".dd-select").removeClass("dd-open"),e.find(".dd-options").slideUp(50),e.find(".dd-pointer").removeClass("dd-pointer-up").removeClass("dd-pointer-up")}function o(e){var d=e.find(".dd-select").css("height"),t=e.find(".dd-selected-description"),i=e.find(".dd-selected-image");t.length<=0&&i.length>0&&e.find(".dd-selected-text").css("lineHeight",d)}function s(d){d.find(".dd-option").each(function(){var t=e(this),i=t.css("height"),n=t.find(".dd-option-description"),o=d.find(".dd-option-image");n.length<=0&&o.length>0&&t.find(".dd-option-text").css("lineHeight",i)})}e.fn.ddslick=function(d){return l[d]?l[d].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof d&&d?void e.error("Method "+d+" does not exists."):l.init.apply(this,arguments)};var l={},a={data:[],keepJSONItemsOnTop:!1,width:260,height:null,background:"#eee",selectText:"",defaultSelectedIndex:null,truncateDescription:!0,imagePosition:"left",showSelectedHTML:!0,clickOffToClose:!0,embedCSS:!0,onSelected:function(){}},c="
",r="",p="";l.init=function(d){var n=e.extend({},a,d);return e("#css-ddslick").length<=0&&n.embedCSS&&e(p).appendTo("head"),this.each(function(){var n=e.extend({},a,d),o=e(this),s=o.data("ddslick");if(!s){var l=[];o.find("option").each(function(){var d=e(this),t=d.data();l.push({text:e.trim(d.text()),value:d.val(),selected:d.is(":selected"),description:t.description,imageSrc:t.imagesrc})}),n.keepJSONItemsOnTop?e.merge(n.data,l):n.data=e.merge(l,n.data);var p=o,f=e("
").attr("id",o.attr("id")+"-dd-placeholder");o.replaceWith(f),o=f,o.addClass("dd-container").append(c).append(r),o.find("input.dd-selected-value").attr("id",e(p).attr("id")).attr("name",e(p).attr("name"));var u=o.find(".dd-options");l=o.find(".dd-select"),u.css({width:n.width}),l.css({width:n.width,background:n.background}),o.css({width:n.width}),null!=n.height&&u.css({height:n.height,overflow:"auto"}),e.each(n.data,function(e,d){d.selected&&(n.defaultSelectedIndex=e),u.append("
  • "+(d.value?" ":"")+(d.imageSrc?" ":"")+(d.text?" ":"")+(d.description?" "+d.description+"":"")+"
  • ")});var h={settings:n,original:p,selectedIndex:-1,selectedItem:null,selectedData:null};if(o.data("ddslick",h),n.selectText.length>0&&null==n.defaultSelectedIndex)o.find(".dd-selected").html(n.selectText);else{var g=null!=n.defaultSelectedIndex&&n.defaultSelectedIndex>=0&&n.defaultSelectedIndex").attr("id", obj.attr("id") + "-dd-placeholder"); obj.replaceWith(placeholder); obj = placeholder;