Witgets.set('socials',{ styles: { 'element': 'box-socials' }, content: { socials: { shares: ['vk', 'od', 'tw', 'fb', 'ga'], comments: 'vk', appID: null, link: null }, name: null, text: null, image: null, type: 'shares', primary: [] }, contentSettings: { 'name': 'input', 'text': 'input', 'type': 'buttons', 'socials/comments': 'buttons', 'socials/appID': 'input', 'socials/link': 'input', 'image': function(value) { if(value != null && value != '' && value != 'null') { $('#socials-image').html(''); } else { $('#socials-image').html(''); } }, 'socials/shares': function(value) { $('#socials-share-buttons button.active').removeClass('active'); $.each(value, function(i, v) { $('#socials-share-buttons button[data-type='+v+']').addClass('active'); }); } }, startEditing: function() { var c = this.getContent(), _this = this; Witgets.setButtonsEvent('type', this, function(data) { $('#socials-type-likes').hide(); $('#socials-type-shares').hide(); $('#socials-type-comments').hide(); $('#socials-type-'+data).show(); _this.set('type', data, true); }); Witgets.setButtonsEvent('socials/comments', this, function(data) { _this.set('socials/comments', data, true); $('#socials-comments-vk').hide(); $('#socials-comments-fb').hide(); $('#socials-comments-'+data).show(); }); Witgets.setUploadEvent($('#social-image-upload'), function(data) { _this.set('image', data.files); _this.setContent(); }); this.setContent(); }, updateEditing: function() { c = this.getContent(); if(c.type == 'shares') { shareBox = Setup.element.find('.box-socials'); var html = '
'); } else { socialsBox = Setup.element.find('.box-socials'); socialsBox.html(''); } }, closeEditing: function() { }, activateSocial: function(e) { c = this.getContent(); shares = c.socials.shares; type = $(e).attr('data-type'); if(shares.indexOf(type) == -1) { shares.push(type); } else { shares.splice(shares.indexOf(type), 1); } this.set('socials/shares', shares, true); this.setContent(); }, changeText: function(type, element) { value = $(element).val(); this.set(type, value); } });