@@ -5,8 +5,8 @@ define(function (require, exports, module) {
55 const _ = require ( 'underscore' ) ;
66
77 const DropdownView = Backbone . View . extend ( {
8- className : 'dropdown' ,
9- tagName : 'dl ' ,
8+ className : 'extplug- dropdown' ,
9+ tagName : 'div ' ,
1010 initialize ( ) {
1111 if ( ! this . options . selected ) {
1212 this . options . selected = Object . keys ( this . options . options ) [ 0 ] ;
@@ -17,27 +17,33 @@ define(function (require, exports, module) {
1717 this . onRowClick = this . onRowClick . bind ( this ) ;
1818 } ,
1919 render ( ) {
20+ this . $label = $ ( '<label />' ) . addClass ( 'title' ) . text ( this . options . label ) ;
21+ this . $dl = $ ( '<dl />' ) . addClass ( 'dropdown' ) ;
2022 this . $selectedValue = $ ( '<span />' ) ;
2123 this . $selected = $ ( '<dt />' )
2224 . append ( this . $selectedValue )
2325 . append ( $ ( '<i />' ) . addClass ( 'icon icon-arrow-down-grey' ) )
2426 . append ( $ ( '<i />' ) . addClass ( 'icon icon-arrow-up-grey' ) ) ;
2527
2628 this . $rows = $ ( '<dd />' ) ;
27- var selected ;
29+ let selected ;
2830 _ . each ( this . options . options , function ( text , value ) {
29- var row = $ ( '<div />' ) . addClass ( 'row' ) . data ( 'value' , value ) ,
30- el = $ ( '<span />' ) . text ( text ) ;
31+ let row = $ ( '<div />' ) . addClass ( 'row' ) . data ( 'value' , value ) ;
32+ let el = $ ( '<span />' ) . text ( text ) ;
3133 if ( this . options . selected === value ) {
3234 selected = row ;
3335 }
3436 row . append ( el ) . appendTo ( this . $rows ) ;
3537 } , this ) ;
3638
37- this . $el
39+ this . $dl
3840 . append ( this . $selected )
3941 . append ( this . $rows ) ;
4042
43+ this . $el
44+ . append ( this . $label )
45+ . append ( this . $dl ) ;
46+
4147 this . $selected . on ( 'click' , this . onBaseClick ) ;
4248 this . $rows . on ( 'click' , this . onRowClick ) ;
4349 // trigger the above as a default
@@ -47,7 +53,7 @@ define(function (require, exports, module) {
4753 return this ;
4854 } ,
4955 close ( ) {
50- this . $el . removeClass ( 'open' ) ;
56+ this . $dl . removeClass ( 'open' ) ;
5157 $ ( document ) . off ( 'click' , this . onDocumentClick ) ;
5258 } ,
5359 remove ( ) {
@@ -56,23 +62,23 @@ define(function (require, exports, module) {
5662 this . _super ( ) ;
5763 } ,
5864 onBaseClick ( e ) {
59- if ( this . $el . hasClass ( 'open' ) ) {
65+ if ( this . $dl . hasClass ( 'open' ) ) {
6066 this . close ( ) ;
6167 }
6268 else {
63- this . $el . addClass ( 'open' ) ;
69+ this . $dl . addClass ( 'open' ) ;
6470 _ . defer ( ( ) => {
6571 $ ( document ) . on ( 'click' , this . onDocumentClick ) ;
6672 } ) ;
6773 }
6874 } ,
6975 onRowClick ( e ) {
7076 let row = $ ( e . target ) . closest ( '.row' ) ;
71- this . $ ( '.row' ) . removeClass ( 'selected' ) ;
77+ this . $dl . find ( '.row' ) . removeClass ( 'selected' ) ;
7278 row . addClass ( 'selected' ) ;
73- this . $el . removeClass ( 'open' ) ;
79+ this . $dl . removeClass ( 'open' ) ;
7480 this . $selectedValue . text ( row . text ( ) ) ;
75- this . trigger ( 'select ' , row . data ( 'value' ) ) ;
81+ this . trigger ( 'change ' , row . data ( 'value' ) ) ;
7682 } ,
7783 onDocumentClick ( e ) {
7884 _ . defer ( this . close . bind ( this ) ) ;
0 commit comments