File tree 3 files changed +29
-9
lines changed
src/plugins/remove_button 3 files changed +29
-9
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ <h2>Plugin: "remove_button"</h2>
31
31
< label for ="input-tags2 "> Tags:</ label >
32
32
< input type ="text " disabled id ="input-tags2 " class ="input-tags demo-default " value ="awesome,neat ">
33
33
</ div >
34
+ < div class ="control-group ">
35
+ < label for ="input-tags "> Tags:</ label >
36
+ < input type ="text " id ="input-tags3 " class ="input-tags2 demo-default " value ="awesome ">
37
+ </ div >
34
38
< script >
35
39
$ ( '.input-tags' ) . selectize ( {
36
40
plugins : [ 'remove_button' ] ,
@@ -45,6 +49,14 @@ <h2>Plugin: "remove_button"</h2>
45
49
return confirm ( values . length > 1 ? 'Are you sure you want to remove these ' + values . length + ' items?' : 'Are you sure you want to remove "' + values [ 0 ] + '"?' ) ;
46
50
}
47
51
} ) ;
52
+
53
+ // single selection
54
+ $ ( '.input-tags2' ) . selectize ( {
55
+ plugins : [ 'remove_button' ] ,
56
+ persist : true ,
57
+ create : true ,
58
+ maxItems : 1
59
+ } ) ;
48
60
</ script >
49
61
</ div >
50
62
Original file line number Diff line number Diff line change @@ -18,15 +18,11 @@ Selectize.define('remove_button', function(options) {
18
18
options = $ . extend ( {
19
19
label : '×' ,
20
20
title : 'Remove' ,
21
- className : 'remove' ,
21
+ className : this . settings . mode === 'single' ? 'remove-single' : 'remove' ,
22
22
append : true
23
23
} , options ) ;
24
24
25
25
var self = this ;
26
- if ( this . settings . mode === 'single' ) {
27
- options . className = options . className || 'remove-single' ;
28
- }
29
-
30
26
var html = '<a href="javascript:void(0)" class="' + options . className + '" tabindex="-1" title="' + escape_html ( options . title ) + '">' + options . label + '</a>' ;
31
27
32
28
/**
Original file line number Diff line number Diff line change 34
34
.disabled [data- value] .remove {
35
35
border-left-color : lighten (desaturate (@selectize-color-item-border , 100% ), @selectize-lighten-disabled-item-border );
36
36
}
37
- .remove-single {
37
+ [data - value] .remove-single {
38
38
position : absolute ;
39
- right : 0 ;
40
- top : 0 ;
41
- font-size : 23px ;
39
+ right : @selectize-padding-x - 2px ;
40
+ top : -1px ;
41
+ display : flex ;
42
+ justify-content : center ;
43
+ align-items : center ;
44
+ font-size : @selectize-line-height ;
45
+ color : lighten (@selectize-arrow-color , 30% );
46
+ text-shadow : 0 1px 0 rgba (0 ,0 ,0 ,0.1 );
47
+ & :hover :not (:active ) {
48
+ color : transparent ;
49
+ text-shadow : 0 0 1px @selectize-arrow-color ;
50
+ }
51
+ & :hover:active {
52
+ text-shadow : none ;
53
+ }
42
54
}
43
55
}
You can’t perform that action at this time.
0 commit comments