ldc-mesbr-app/public/js/ajax.js

83 lines
29 KiB
JavaScript
Raw Normal View History

2019-01-15 14:17:15 +01:00
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 4);
/******/ })
/************************************************************************/
/******/ ({
/***/ 4:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(5);
/***/ }),
/***/ 5:
/***/ (function(module, exports) {
2019-03-08 15:48:05 +01:00
eval("$('#addCoupons').on('click', function (event) {\n event.preventDefault();\n var ids = [];\n var campid = $(this).parent().find('#camp_id').val();\n $(this).parent().find('.inputGroup input').each(function (event) {\n if ($(this).is(':checked')) {\n ids.push($(this).val());\n }\n });\n $.ajaxSetup({\n headers: {\n 'X-CSRF-TOKEN': $(this).parent().find('#csrf').val()\n }\n });\n\n $.ajax({\n url: '/add-coupons-ajax',\n type: 'POST',\n data: {\n ids: ids,\n campid: campid\n },\n dataType: 'JSON',\n success: function success(reponse) {\n $.each(reponse, function (index, coupon) {\n var html = '<tr>';\n html += '<td>' + coupon.coupon_code + '</td>';\n html += '<td>' + coupon.coupon_name + '</td>';\n html += '<td><i class=\"fas fa-times delete-coupon\" data-campid=\"' + campid + '\" data-couponid=\"' + coupon.coupon_id + '\"></i></td>';\n html += '</tr>';\n $('.no-result').remove();\n $('.coupons-wrapper table').append(html);\n $('#addCoupons').parent().find('.inputGroup input').each(function (event) {\n if ($(this).val() == coupon.coupon_id) {\n $(this).parent('.inputGroup').remove();\n }\n });\n $.fancybox.close();\n });\n },\n error: function error(e) {\n console.log(e.responseText);\n }\n });\n});\n\n$('body').on('click', '.delete-coupon', function (event) {\n var campid = $(this).attr('data-campid');\n var couponid = $(this).attr('data-couponid');\n var trLinked = $(this).parent().parent();\n $.fancyConfirm({\n title: \"<i class='fas fa-times-circle'></i> Retrait\",\n message: \"Êtes-vous sûr de vouloir retirer ce coupon de cette campagne ?\",\n okButton: 'Retirer',\n noButton: 'Annuler',\n callback: function callback(value) {\n if (value) {\n event.preventDefault();\n\n $.ajaxSetup({\n headers: {\n 'X-CSRF-TOKEN': $('#csrf').val()\n }\n });\n $.ajax({\n url: '/remove-coupons-ajax',\n type: 'POST',\n data: {\n couponid: couponid,\n campid: campid\n },\n dataType: 'JSON',\n success: function success(reponse) {\n trLinked.remove();\n var html = \"<div class='inputGroup'>\";\n html += \"<input id='coupon[\" + reponse.coupon_id + \"]' name='coupon[\" + reponse.coupon_id + \"]' type='checkbox' value='\" + reponse.coupon_id + \"' >\";\n html += \"<label for='coupon[\" + reponse.coupon_id + \"]'>\" + reponse.coupon_name + \"</label>\";\n html += \"</div>\";\n $(\"#camp_id\").before(html);\n },\n error: function error(e) {\n console.log(e.responseText);\n }\n });\n }\n }\n });\n});\n\n$('body').on('click', '.unpublish', function (event) {\n event.preventDefault();\n var couponid = $(this).attr('data-couponid');\n var element = $(this).parent();\n $.fancyConfirm({\n title: \"<i class='fas fa-times-circle'></i> Dépublier\",\n message: \"Êtes-vous sûr de vouloir dépublier ce coupon ?\",\n okButton: 'Dépublier',\n noButton: 'Annuler',\n callback: function callback(value) {\n if (value) {\n $.ajaxSetup({\n headers: {\n 'X-CSRF-TOKEN': $('#csrf').val()\n }\n });\n $.ajax({\n
2019-01-15 14:17:15 +01:00
/***/ })
/******/ });