(function (global, factory) { if (typeof define === "function" && define.amd) { define('ss.AddToCampaignForm', ['jQuery'], factory); } else if (typeof exports !== "undefined") { factory(require('jQuery')); } else { var mod = { exports: {} }; factory(global.jQuery); global.ssAddToCampaignForm = mod.exports; } })(this, function (_jQuery) { 'use strict'; var _jQuery2 = _interopRequireDefault(_jQuery); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _jQuery2.default.entwine('ss', function ($) { $('.add-to-campaign-action, #add-to-campaign__action').entwine({ onclick: function onclick() { var dialog = $('#add-to-campaign__dialog'); if (dialog.length) { dialog.open(); } else { dialog = $('
'); $('body').append(dialog); } if (dialog.children().length === 0) dialog.addClass('loading'); var form = this.closest('form'); var button = this; var formData = form.serializeArray(); formData.push({ name: button.attr('name'), value: '1' }); $.ajax({ url: form.attr('action'), data: formData, type: 'POST', global: false, complete: function complete() { dialog.removeClass('loading'); }, success: function success(data, status, xhr) { if (xhr.getResponseHeader('Content-Type').indexOf('text/plain') === 0) { var container = $('