Welcome to mirror list, hosted at ThFree Co, Russian Federation.

text_modal.html « common « html « web - github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0ae04a88d857273bbd1a977af53f215c60b9fa98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{{define "textModal"}}
<a-modal id="text-modal" v-model="txtModal.visible" :title="txtModal.title"
         :closable="true" ok-text='{{ i18n "copy" }}' cancel-text='{{ i18n "close" }}'
         :ok-button-props="{attrs:{id:'txt-modal-ok-btn'}}">
    <a-button v-if="!ObjectUtil.isEmpty(txtModal.fileName)" type="primary" style="margin-bottom: 10px;"
              @click="downloader.download(txtModal.fileName, txtModal.content)">
        {{ i18n "download" }} [[ txtModal.fileName ]]
    </a-button>
    <a-input type="textarea" v-model="txtModal.content"
             :autosize="{ minRows: 10, maxRows: 20}"></a-input>
</a-modal>

<script>

    const txtModal = {
        title: '',
        content: '',
        fileName: '',
        qrcode: null,
        clipboard: null,
        visible: false,
        show: function (title='', content='', fileName='') {
            this.title = title;
            this.content = content;
            this.fileName = fileName;
            this.visible = true;
            textModalApp.$nextTick(() => {
                if (this.clipboard === null) {
                    this.clipboard = new ClipboardJS('#txt-modal-ok-btn', {
                        text: () => this.content,
                    });
                    this.clipboard.on('success', () => app.$message.success('{{ i18n "copied" }}'));
                }
                if (this.qrcode === null) {
                    this.qrcode = new QRious({
                        element: document.querySelector('#qrCode'),
                        size: 260,
                        value: content,
                    });
                } else {
                    this.qrcode.value = content;
                }
            });
        },
        close: function () {
            this.visible = false;
        },
    };

    const textModalApp = new Vue({
        el: '#text-modal',
        data: {
            txtModal: txtModal,
        },
    });

</script>
{{end}}