@@ -72,8 +72,10 @@ define([
72
72
const VP_DS_DRAGGABLE = 'vp-ds-draggable' ;
73
73
74
74
/** select btns */
75
+ const VP_DS_SELECT_ADD_ALL_BTN = 'vp-ds-select-add-all-btn' ;
75
76
const VP_DS_SELECT_ADD_BTN = 'vp-ds-select-add-btn' ;
76
77
const VP_DS_SELECT_DEL_BTN = 'vp-ds-select-del-btn' ;
78
+ const VP_DS_SELECT_DEL_ALL_BTN = 'vp-ds-select-del-all-btn' ;
77
79
78
80
/** slicing box */
79
81
const VP_DS_SLICING_BOX = 'vp-ds-slicing-box' ;
@@ -509,8 +511,12 @@ define([
509
511
tag . appendLine ( '</div>' ) ; // VP_DS_SELECT_LEFT
510
512
// row select - buttons
511
513
tag . appendFormatLine ( '<div class="{0}">' , VP_DS_SELECT_BTN_BOX ) ;
514
+ tag . appendFormatLine ( '<button type="button" class="{0} {1}" title="{2}">{3}</button>'
515
+ , VP_DS_SELECT_ADD_ALL_BTN , 'select-row' , 'Add all items' , '<img src="/nbextensions/visualpython/resource/arrow_right_double.svg"/></i>' ) ;
512
516
tag . appendFormatLine ( '<button type="button" class="{0} {1}">{2}</button>' , VP_DS_SELECT_ADD_BTN , 'select-row' , '<img src="/nbextensions/visualpython/resource/arrow_right.svg"/>' ) ;
513
517
tag . appendFormatLine ( '<button type="button" class="{0} {1}">{2}</button>' , VP_DS_SELECT_DEL_BTN , 'select-row' , '<img src="/nbextensions/visualpython/resource/arrow_left.svg"/>' ) ;
518
+ tag . appendFormatLine ( '<button type="button" class="{0} {1}" title="{2}">{3}</button>'
519
+ , VP_DS_SELECT_DEL_ALL_BTN , 'select-row' , 'Remove all items' , '<img src="/nbextensions/visualpython/resource/arrow_left_double.svg"/>' ) ;
514
520
tag . appendLine ( '</div>' ) ; // VP_DS_SELECT_BTNS
515
521
// row select - right
516
522
tag . appendFormatLine ( '<div class="{0}">' , VP_DS_SELECT_RIGHT ) ;
@@ -612,8 +618,12 @@ define([
612
618
tag . appendLine ( '</div>' ) ; // VP_DS_SELECT_LEFT
613
619
// col select - buttons
614
620
tag . appendFormatLine ( '<div class="{0}">' , VP_DS_SELECT_BTN_BOX ) ;
621
+ tag . appendFormatLine ( '<button type="button" class="{0} {1}" title="{2}">{3}</button>'
622
+ , VP_DS_SELECT_ADD_ALL_BTN , 'select-col' , 'Add all items' , '<img src="/nbextensions/visualpython/resource/arrow_right_double.svg"/></i>' ) ;
615
623
tag . appendFormatLine ( '<button type="button" class="{0} {1}">{2}</button>' , VP_DS_SELECT_ADD_BTN , 'select-col' , '<img src="/nbextensions/visualpython/resource/arrow_right.svg"/></i>' ) ;
616
624
tag . appendFormatLine ( '<button type="button" class="{0} {1}">{2}</button>' , VP_DS_SELECT_DEL_BTN , 'select-col' , '<img src="/nbextensions/visualpython/resource/arrow_left.svg"/>' ) ;
625
+ tag . appendFormatLine ( '<button type="button" class="{0} {1}" title="{2}">{3}</button>'
626
+ , VP_DS_SELECT_DEL_ALL_BTN , 'select-col' , 'Remove all items' , '<img src="/nbextensions/visualpython/resource/arrow_left_double.svg"/>' ) ;
617
627
tag . appendLine ( '</div>' ) ; // VP_DS_SELECT_BTNS
618
628
// col select - right
619
629
tag . appendFormatLine ( '<div class="{0}">' , VP_DS_SELECT_RIGHT ) ;
@@ -1320,8 +1330,10 @@ define([
1320
1330
$ ( document ) . off ( 'change' , this . wrapSelector ( '.select-row .' + VP_DS_SELECT_SEARCH ) ) ;
1321
1331
$ ( document ) . off ( 'change' , this . wrapSelector ( '.select-col .' + VP_DS_SELECT_SEARCH ) ) ;
1322
1332
$ ( document ) . off ( 'click' , this . wrapSelector ( '.' + VP_DS_SELECT_ITEM ) ) ;
1333
+ $ ( document ) . off ( 'click' , this . wrapSelector ( '.' + VP_DS_SELECT_ADD_ALL_BTN ) ) ;
1323
1334
$ ( document ) . off ( 'click' , this . wrapSelector ( '.' + VP_DS_SELECT_ADD_BTN ) ) ;
1324
1335
$ ( document ) . off ( 'click' , this . wrapSelector ( '.' + VP_DS_SELECT_DEL_BTN ) ) ;
1336
+ $ ( document ) . off ( 'click' , this . wrapSelector ( '.' + VP_DS_SELECT_DEL_ALL_BTN ) ) ;
1325
1337
$ ( document ) . off ( 'click' , this . wrapSelector ( '.vp-add-col' ) ) ;
1326
1338
$ ( document ) . off ( 'click' , this . wrapSelector ( '.vp-del-col' ) ) ;
1327
1339
$ ( document ) . off ( 'change' , this . wrapSelector ( '.vp-ds-slicing-box input[type="text"]' ) ) ;
@@ -1653,6 +1665,21 @@ define([
1653
1665
}
1654
1666
} ) ;
1655
1667
1668
+ // item indexing - add all
1669
+ $ ( document ) . on ( 'click' , this . wrapSelector ( '.' + VP_DS_SELECT_ADD_ALL_BTN ) , function ( event ) {
1670
+ var itemType = $ ( this ) . hasClass ( 'select-row' ) ? 'row' :'col' ;
1671
+ var selector = '.select-' + itemType ;
1672
+
1673
+ $ ( that . wrapSelector ( '.' + VP_DS_SELECT_BOX + '.left .' + VP_DS_SELECT_ITEM + selector ) ) . appendTo (
1674
+ $ ( that . wrapSelector ( selector + ' .' + VP_DS_SELECT_BOX + '.right' ) )
1675
+ ) ;
1676
+ $ ( that . wrapSelector ( selector + ' .' + VP_DS_SELECT_BOX + ' .' + VP_DS_SELECT_ITEM ) ) . addClass ( 'added' ) ;
1677
+ $ ( that . wrapSelector ( '.' + VP_DS_SELECT_ITEM + '.selected' ) ) . removeClass ( 'selected' ) ;
1678
+ that . state [ itemType + 'Pointer' ] = { start : - 1 , end : - 1 } ;
1679
+
1680
+ that . generateCode ( ) ;
1681
+ } ) ;
1682
+
1656
1683
// item indexing - add
1657
1684
$ ( document ) . on ( 'click' , this . wrapSelector ( '.' + VP_DS_SELECT_ADD_BTN ) , function ( event ) {
1658
1685
var itemType = $ ( this ) . hasClass ( 'select-row' ) ? 'row' :'col' ;
@@ -1691,6 +1718,28 @@ define([
1691
1718
that . generateCode ( ) ;
1692
1719
} ) ;
1693
1720
1721
+ // item indexing - del all
1722
+ $ ( document ) . on ( 'click' , this . wrapSelector ( '.' + VP_DS_SELECT_DEL_ALL_BTN ) , function ( event ) {
1723
+ var itemType = $ ( this ) . hasClass ( 'select-row' ) ? 'row' :'col' ;
1724
+ var selector = '.select-' + itemType ;
1725
+
1726
+ var targetBoxQuery = that . wrapSelector ( selector + ' .' + VP_DS_SELECT_BOX + '.left' ) ;
1727
+ $ ( that . wrapSelector ( selector + ' .' + VP_DS_SELECT_ITEM ) ) . appendTo (
1728
+ $ ( targetBoxQuery )
1729
+ ) ;
1730
+ // sort
1731
+ $ ( targetBoxQuery + ' .' + VP_DS_SELECT_ITEM ) . sort ( function ( a , b ) {
1732
+ return ( $ ( b ) . data ( 'idx' ) ) < ( $ ( a ) . data ( 'idx' ) ) ? 1 : - 1 ;
1733
+ } ) . appendTo (
1734
+ $ ( targetBoxQuery )
1735
+ ) ;
1736
+ $ ( that . wrapSelector ( selector + ' .' + VP_DS_SELECT_ITEM ) ) . removeClass ( 'added' ) ;
1737
+ $ ( that . wrapSelector ( selector + ' .' + VP_DS_SELECT_ITEM ) ) . removeClass ( 'selected' ) ;
1738
+ that . state [ itemType + 'Pointer' ] = { start : - 1 , end : - 1 } ;
1739
+
1740
+ that . generateCode ( ) ;
1741
+ } ) ;
1742
+
1694
1743
// row-column condition add
1695
1744
$ ( document ) . on ( 'click' , this . wrapSelector ( '.vp-add-col' ) , function ( event ) {
1696
1745
that . handleColumnAdd ( ) ;
@@ -2122,7 +2171,7 @@ define([
2122
2171
var rowList = [ ] ;
2123
2172
for ( var i = 0 ; i < rowTags . length ; i ++ ) {
2124
2173
var rowValue = $ ( rowTags [ i ] ) . data ( 'code' ) ;
2125
- if ( rowValue ) {
2174
+ if ( rowValue != undefined ) {
2126
2175
rowList . push ( rowValue ) ;
2127
2176
}
2128
2177
}
0 commit comments