1
- /*
2
- Copyright 2017 Ziadin Givan
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
-
16
- https://github.com/givanz/VvvebJs
17
- */
18
-
1
+ /**
2
+ * Vvveb
3
+ *
4
+ * Copyright (C) 2021 Ziadin Givan
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as
8
+ * published by the Free Software Foundation, either version 3 of the
9
+ * License, or (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ *
19
+ */
20
+
19
21
let Input = {
20
22
21
23
init : function ( name ) {
@@ -734,7 +736,11 @@ let ListInput = { ...Input, ...{
734
736
let data = input . data ;
735
737
736
738
if ( data . removeElement ) {
737
- input . node . querySelector ( data . container + " " + data . selector + ":nth-child(" + ( index + 1 ) + ")" ) . remove ( ) ;
739
+ let container = input . node ;
740
+ if ( data . container ) {
741
+ container . querySelector ( data . container ) ;
742
+ }
743
+ container . querySelector ( data . selector + ":nth-child(" + ( index + 1 ) + ")" ) . remove ( ) ;
738
744
}
739
745
sectionItem . remove ( ) ;
740
746
@@ -748,7 +754,11 @@ let ListInput = { ...Input, ...{
748
754
add : function ( event , node , input ) {
749
755
let newElement = input . data . newElement ?? false ;
750
756
if ( newElement ) {
751
- event . data . input . node . querySelector ( input . data . container ) . append ( generateElements ( newElement ) [ 0 ] ) ;
757
+ let container = input . node ;
758
+ if ( data . container ) {
759
+ container . querySelector ( data . container ) ;
760
+ }
761
+ container . append ( generateElements ( newElement ) [ 0 ] ) ;
752
762
}
753
763
754
764
event . action = "add" ;
@@ -784,7 +794,7 @@ let ListInput = { ...Input, ...{
784
794
if ( data . nameElement ) {
785
795
element = element . querySelector ( data . nameElement ) ;
786
796
}
787
- let name = ( data . name = "text" ? element . textContent : element . id ) ;
797
+ let name = ( data . name = "text" ? element . textContent . substr ( 0 , 15 ) : element . id ) ;
788
798
options . push ( {
789
799
name : name ,
790
800
type : ( data . prefix ?? "" ) + ( i + 1 ) + ( data . suffix ?? "" ) ,
@@ -806,9 +816,10 @@ let AutocompleteInput = { ...Input, ...{
806
816
[ "autocomplete.change" , "onAutocompleteChange" , "input" ] ,
807
817
] ,
808
818
809
- onAutocompleteChange : function ( event , value , text ) {
810
- input . value = value ;
811
- return this . onChange ( event , node ) ;
819
+ onAutocompleteChange : function ( event , node , input ) {
820
+ input . value = event . detail . value ;
821
+ //return input.onChange(event, node, input);
822
+ return input . onChange . call ( this , event , node , input ) ;
812
823
} ,
813
824
814
825
init : function ( data ) {
0 commit comments