From fd05a176a5ca2b4043900d8f4942dc57b266fcfd Mon Sep 17 00:00:00 2001 From: Rok Date: Tue, 10 Mar 2015 16:48:28 +0100 Subject: [PATCH] Add checkbox option for multiple selectbox --- demo/index.html | 13 +++++++++++++ less/floater_abstract.less | 8 +++++++- src/selectbox_abstract.coffee | 12 ++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/demo/index.html b/demo/index.html index 4c609d0..83f7e67 100644 --- a/demo/index.html +++ b/demo/index.html @@ -305,6 +305,19 @@

Select boxes

+ + diff --git a/less/floater_abstract.less b/less/floater_abstract.less index 6858299..cf27c85 100644 --- a/less/floater_abstract.less +++ b/less/floater_abstract.less @@ -23,7 +23,13 @@ .ellipsis; padding : @paddingVertical @paddingHorizontal; cursor : pointer; - + + .reform-checkbox-fake { + height : @fontSize; + width : @fontSize; + margin-right : @fontSize; + } + &.hover { background : @hoverBackgroundColor; color : @hoverFontColor; diff --git a/src/selectbox_abstract.coffee b/src/selectbox_abstract.coffee index 8c30999..1aac951 100644 --- a/src/selectbox_abstract.coffee +++ b/src/selectbox_abstract.coffee @@ -11,6 +11,8 @@ class SelectBoxAbstract fakeClass : 'reform-selectbox-fake' }, options + $.extend @options, @orig.data() + # Don't do this twice return if @orig.is '.reformed' @@ -164,6 +166,16 @@ class SelectBoxAbstract $item.attr 'title', $option.attr 'title' $item.attr 'value', $option.val() + if @options.showcheckbox and @orig.is '[multiple]' + checkboxOptions = + type: 'checkbox' + class: 'reform-checkbox' + + checkboxOptions.checked = 'checked' if $option.is ':selected' + checkboxOptions.checked = 'disabled' if $option.is ':disabled' + + $item.append($('', checkboxOptions)) + $item.append @createItemContent $option # Disable selected item, add values in @listMultiple