Advertisement
Guest User

Untitled

a guest
Jul 9th, 2020
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                Editor.DomComponents.addType('october-swiper', {
  2.                     isComponent: el => {
  3.                         if (el.attributes) {
  4.                              
  5.                  
  6.                             if(el.attributes.getNamedItem('october-swiper')) {
  7.                                 var r = el.attributes.getNamedItem('october-swiper').value;
  8.                                  console.log(el);
  9.                                  
  10.                                 if(r == '1'){
  11.              
  12.                                     return true;
  13.                                 }
  14.              
  15.                             }
  16.              
  17.                         }
  18.              
  19.                     },
  20.                     model: {
  21.                         defaults: {
  22.                             traits: [
  23.                             'id',
  24.                             {
  25.                                 type: 'select',
  26.                                 name: 'swiper',
  27.              
  28.                                 options:  [
  29.                                     'homepage',
  30.                                     'experience',
  31.                                     'courchevel',
  32.                                     'bien-etre'
  33.                                 ]
  34.                             },
  35.              
  36.                             ]
  37.              
  38.                         },
  39.                         init() {
  40.                             this.on('change:attributes:swiper', this.handleChange);
  41.                             this.handleChange();
  42.                         },
  43.                         handleChange() {
  44.                             const swiper = this.getAttributes().swiper;
  45.              
  46.              
  47.              
  48.                             if(this.getAttributes()['october-swiper'] == '1'){          
  49.              
  50.                                 if (swiper) {
  51.              
  52.              
  53.                                     this.attributes['content'] = '';
  54.                                     this.components(`{% partial 'carousel' scope='${swiper}' %}`);
  55.              
  56.              
  57.              
  58.                                 } else {
  59.                                     this.attributes['content'] = '';
  60.                                     this.components(`Select swiper`);
  61.                                 }
  62.                             }
  63.                         }
  64.                     }
  65.                 });
  66.              
  67.                 Editor.BlockManager.add('october-swiper-block', {
  68.                     label: 'Slider',
  69.                     category: 'Components',        
  70.                     content:`<div data-gjs-type="october-swiper" october-swiper="1" ></div>`,
  71.                     attributes: {
  72.                         class: 'fa fa-code'
  73.                     }
  74.                 });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement