var featherEditor = new Aviary.Feather({ apiKey: '9b4360f809e5117c', apiVersion: 3, tools: ['effects', 'orientation', 'resize', 'crop', 'text', 'warmth', 'brightness', 'contrast', 'saturation'], language: 'ru', onSave: function(imageID, newURL) { c = Witgets.image.getContent(); featherEditor.close(); $.ajax({ url: '/scr/uploadAviary', type: 'post', data: { 'url': newURL, 'file': c.src }, success: function (data) { Witgets.image.set('src', c.src, false); Setup.element.find('.box-img img').attr('src', '/upload/pages/'+c.src+'?1') } }); }, onError: function(e) { console.log(e) }, onClose: function() { $('#featherEditor-image').removeAttr('id'); }, }); Witgets.set('image',{ styles: { 'element': 'img' }, content: { edit: false, src: null, link: null, shape: 'none', position: 'center', primary: ['src'] }, contentSettings: { 'position': 'buttons', 'link': 'input', 'src': function(value) { $('#image-button-edit').hide(); if(value == null || value == '' || value == 'null') { $('#image-button-edit').hide(); $('#image-position-block').hide(); $('#image-link-block').hide(); } else { console.log(value) $('#image-position-block').show(); $('#image-link-block').show(); if(value.match(/pack/g) != null) { $('#image-button-edit').hide(); // HIDE !!!! } } } }, startEditing: function() { var c = this.getContent(), _this = this; $('#image-choosing-button').click(function() { $('#image-choosing').slideToggle(); }); Witgets.setScrollFixed($('#modal #tooltip-icons .icons')); Witgets.setButtonsEvent('position', this, function(data) { _this.set('position', data, true); }); Witgets.setUploadEvent($('#image-upload'), function(data) { _this.set('src', data.files, true); _this.setContent(); }); $('#image-button-edit').click(function() { Setup.element.find('.box-img img').attr('id', 'featherEditor-image') featherEditor.launch({ image: 'featherEditor-image', url: 'https://spagece.com/upload/pages/'+c.src }); }); $('.tooltip-images .menu div').click(function() { type = $(this).attr('data-type'); menu = $(this).parent(); menu.find('.active').removeClass('active'); $(this).addClass('active'); menu.parent().find('.icons > div').hide(); menu.parent().find('.icons > div[data-type="'+type+'"]').show(); }); this.setContent(); }, updateEditing: function() { c = this.getContent(); if(this.isUpdateAllow()) { file = c.src; image = $('
'); Setup.element.find('.box-img').html(image); } }, closeEditing: function() { }, clickOnIcon: function(element) { $(element).parent().parent().find('.active').removeClass('active'); $(element).addClass('active'); file = $(element).find('img').attr('src').split('/')[3]; this.set('src', file, true); this.setContent(); } });