@@ -19,7 +19,7 @@ module.exports = baseVw.extend({
1919 'click #shippingFreeFalse' : 'enableShippingPrice' ,
2020 'change .js-itemImageUpload' : 'onImageFileChange' ,
2121 'dragover .js-photosModule' : 'onPhotoDragOver' ,
22- 'dragleave .js-photosModule' : 'onPhotoDragLeave' ,
22+ 'dragleave .js-photosModule' : 'onPhotoDragLeave' ,
2323 'drop .js-photosModule' : 'onPhotoDrop' ,
2424 'change #inputType' : 'changeType' ,
2525 'click .js-editItemDeleteImage' : 'deleteImage' ,
@@ -48,15 +48,15 @@ module.exports = baseVw.extend({
4848 countryList . forEach ( function ( country ) {
4949 allRegions . push ( country . dataName ) ;
5050 } ) ;
51-
51+
5252 var europeanUnion = [
5353 'AUSTRIA' , 'BELGIUM' , 'BULGARIA' , 'CROATIA' , 'CYPRUS' , 'CZECH_REPUBLIC' , 'DENMARK' , 'ESTONIA' ,
5454 'FINLAND' , 'FRANCE' , 'GERMANY' , 'GREECE' , 'HUNGARY' , 'IRELAND' , 'ITALY' , 'LATVIA' , 'LITHUANIA' , 'LUXEMBOURG' ,
55- 'MALTA' , 'NETHERLANDS' , 'POLAND' , 'PORTUGAL' , 'ROMANIA' , 'SLOVAKIA' , 'SLOVENIA' , 'SPAIN' , 'SWEDEN' , 'UNITED_KINGDOM'
55+ 'MALTA' , 'NETHERLANDS' , 'POLAND' , 'PORTUGAL' , 'ROMANIA' , 'SLOVAKIA' , 'SLOVENIA' , 'SPAIN' , 'SWEDEN' , 'UNITED_KINGDOM'
5656 ] ;
57-
57+
5858 var europeanEconomicArea = europeanUnion . concat ( [ 'ICELAND' , 'LIECHTENSTEIN' , 'NORWAY' ] ) ;
59-
59+
6060 this . regions = {
6161 'ALL' : allRegions ,
6262 'EUROPEAN_UNION' : europeanUnion ,
@@ -67,15 +67,15 @@ module.exports = baseVw.extend({
6767 this . defaultDate = nowDate . getFullYear ( ) + "-" + padTime ( nowMonth ) + "-" + padTime ( nowDate . getDate ( ) ) + "T" + padTime ( nowDate . getHours ( ) ) + ":" + padTime ( nowDate . getMinutes ( ) ) ;
6868 this . imgHashes = this . model . get ( 'vendor_offer' ) . listing . item . image_hashes ;
6969 __ . bindAll ( this , 'validateDescription' ) ;
70-
70+
7171 self . model . set ( 'expTime' , self . model . get ( 'vendor_offer' ) . listing . metadata . expiry . replace ( " UTC" , "" ) ) ;
7272
7373 this . listenTo ( this . model , 'change:priceSet' , this . render ( ) ) ;
7474 } ,
7575
7676 render : function ( ) {
7777 var self = this ;
78-
78+
7979 loadTemplate ( './js/templates/itemEdit.html' , function ( loadedTemplate ) {
8080 var context = __ . extend ( { } , self . model . toJSON ( ) , {
8181 MAX_PHOTOS : self . MAX_PHOTOS ,
@@ -120,7 +120,7 @@ module.exports = baseVw.extend({
120120 } ) . change ( function ( e ) {
121121 self . shipsToChange ( e ) ;
122122 } ) ;
123-
123+
124124 self . $ ( '.chosenRegions' ) . chosen ( {
125125 width : '100%' ,
126126 disable_search : true ,
@@ -209,6 +209,17 @@ module.exports = baseVw.extend({
209209 preserveCase : true ,
210210 saveOnBlur : true ,
211211 placeholder : window . polyglot . t ( 'KeywordsPlaceholder' ) ,
212+ onBeforeTagAdd : ( event , tag ) => {
213+ console . log ( tag ) ;
214+ console . log ( tag . length ) ;
215+ if ( tag . length > 40 ) {
216+ app . simpleMessageModal . open ( {
217+ title : window . polyglot . t ( 'errorMessages.tagIsTooLongHeadline' ) ,
218+ message : window . polyglot . t ( 'errorMessages.tagIsTooLongBody' )
219+ } ) ;
220+ return false ;
221+ }
222+ } ,
212223 onTagAdd : ( ) => {
213224 this . $ ( '#inputKeyword' ) . removeClass ( 'invalid' ) ;
214225 } ,
@@ -340,7 +351,7 @@ module.exports = baseVw.extend({
340351 onPhotoDragLeave : function ( e ) {
341352 this . $photosModule . removeClass ( 'dragOver' ) ;
342353 e . preventDefault ( ) ;
343- } ,
354+ } ,
344355
345356 onPhotoDrop : function ( e ) {
346357 this . $photosModule . removeClass ( 'dragOver' ) ;
@@ -373,11 +384,11 @@ module.exports = baseVw.extend({
373384
374385 if ( this . imgHashes . length + imageFiles . length > this . MAX_PHOTOS ) {
375386 imageFiles = imageFiles . slice ( 0 , this . MAX_PHOTOS - this . imgHashes . length ) ;
376-
387+
377388 app . simpleMessageModal . open ( {
378389 title : window . polyglot . t ( 'errorMessages.tooManyPhotosTitle' ) ,
379390 message : window . polyglot . t ( 'errorMessages.tooManyPhotosBody' )
380- } ) ;
391+ } ) ;
381392 }
382393
383394 if ( ! imageFiles . length ) return ;
@@ -434,15 +445,15 @@ module.exports = baseVw.extend({
434445 } ) ;
435446 } else if ( loaded === imageCount ) {
436447 self . uploadImage ( imageList ) ;
437- }
448+ }
438449 } ;
439450 } ) ;
440451 } ,
441452
442453 uploadImage : function ( imageList ) {
443454 var self = this ,
444455 formData = new FormData ( ) ;
445-
456+
446457 __ . each ( imageList , function ( dataURL ) {
447458 formData . append ( 'image' , dataURL ) ;
448459 } ) ;
@@ -665,7 +676,7 @@ module.exports = baseVw.extend({
665676 message : window . polyglot . t ( 'errorMessages.missingError' ) + '<br><i><br />' +
666677 invalidInputList . join ( '<br />' ) + '</i>'
667678 } ) ;
668-
679+
669680 return $ . Deferred ( ) . reject ( 'failed form validation' ) . promise ( ) ;
670681 } ,
671682
@@ -674,4 +685,4 @@ module.exports = baseVw.extend({
674685
675686 return this . $ ( '#contractForm' ) [ 0 ] . checkValidity ( ) ;
676687 }
677- } ) ;
688+ } ) ;
0 commit comments