PageSourceSearch

https://www.ldlonline.co.uk/static/version1790757918/frontend/Cti/ldl-theme/en_GB/mage/dataPost.js

js ldlonline.co.uk collected 2026-10-08 12:45:23 UTC 2,915 bytes, 102 lines download raw bytes

1/**
2 * Copyright © Magento, Inc. All rights reserved.
3 * See COPYING.txt for license details.
4 */
5
6define([
7    'jquery',
8    'mage/template',
9    'Magento_Ui/js/modal/confirm',
10    'jquery-ui-modules/widget'
11], function ($, mageTemplate, uiConfirm) {
12    'use strict';
13
14    $.widget('mage.dataPost', {
15        options: {
16            formTemplate: '<form action="<%- data.action %>" method="post">' +
17            '<% _.each(data.data, function(value, index) { %>' +
18            '<input name="<%- index %>" value="<%- value %>">' +
19            '<% }) %></form>',
20            postTrigger: ['a[data-post]', 'button[data-post]', 'span[data-post]'],
21            formKeyInputSelector: 'input[name="form_key"]'
22        },
23
24        /** @inheritdoc */
25        _create: function () {
26            this._bind();
27        },
28
29        /** @inheritdoc */
30        _bind: function () {
31            var events = {};
32
33            $.each(this.options.postTrigger, function (index, value) {
34                events['click ' + value] = '_postDataAction';
35            });
36
37            this._on(events);
38        },
39
40        /**
41         * Handler for click.
42         *
43         * @param {Object} e
44         * @private
45         */
46        _postDataAction: function (e) {
47            var params = $(e.currentTarget).data('post');
48
49            e.preventDefault();
50            this.postData(params);
51        },
52
53        /**
54         * Data post action.
55         *
56         * @param {Object} params
57         */
58        postData: function (params) {
59            var formKey = $(this.options.formKeyInputSelector).val(),
60                $form, input;
61
62            if (formKey) {
63                params.data['form_key'] = formKey;
64            }
65
66            $form = $(mageTemplate(this.options.formTemplate, {
67                data: params
68            }));
69
70            if (params.files) {
71                $form[0].enctype = 'multipart/form-data';
72                $.each(params.files, function (key, files) {
73                    if (files instanceof FileList) {
74                        input = document.createElement('input');
75                        input.type = 'file';
76                        input.name = key;
77                        input.files = files;
78                        $form[0].appendChild(input);
79                    }
80                });
81            }
82
83            if (params.data.confirmation) {
84                uiConfirm({
85                    content: params.data.confirmationMessage,
86                    actions: {
87                        /** @inheritdoc */
88                        confirm: function () {
89                            $form.appendTo('body').hide().trigger('submit');
90                        }
91                    }
92                });
93            } else {
94                $form.appendTo('body').hide().trigger('submit');
95            }
96        }
97    });
98
99    $(document).dataPost();
100
101    return $.mage.dataPost;
102});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.