CoreFiles by mySites.guru
share-modal.vue73 lines, 2,967 bytes, from Joomla_4.0.0-alpha12-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha11
md5
ccebb767b444045270a0acaf36a15406
sha1
21221858523531fbbbabe4b2ed2c8f43c85cb021
sha256
650d1b609db6d457bbcdc54297cb62b09bd88696ba78c929920fafe74d325dd5
<template>
    <media-modal v-if="$store.state.showShareModal" :size="'md'" @close="close()" :show-close="false" label-element="shareTitle">
        <h3 slot="header" id="shareTitle" class="modal-title">{{ translate('COM_MEDIA_SHARE') }}</h3>
        <div slot="body">
            <div class="desc">
                {{ translate('COM_MEDIA_SHARE_DESC') }}
                
                <template v-if="!url">
                    <div class="control">
                        <button class="btn btn-success btn-block" type="button" @click="generateUrl">{{ translate('COM_MEDIA_ACTION_SHARE') }}</button>
                    </div>
                </template>
                <template v-else>
                    <div class="control">
                        <span class="input-group">
                            <input id="url" ref="urlText" readonly v-model="url" class="form-control input-xxlarge" placeholder="URL" autocomplete="off">
                            <span class="input-group-append">
                                <button class="btn btn-secondary" type="button" @click="copyToClipboard" :title="translate('COM_MEDIA_SHARE_COPY')">
                                    <span class="fa fa-clipboard" aria-hidden="true"></span>
                                </button>
                            </span>
                        </span>     
                    </div>
                </template>
            </div>
        </div>
        <div slot="footer">
            <button class="btn btn-secondary" @click="close()">{{ translate('JCANCEL') }}</button>
        </div>
    </media-modal>
</template>

<script>
    import * as types from "./../../store/mutation-types";

    export default {
        name: 'media-share-modal',
        computed: {
            item() {
                return this.$store.state.selectedItems[this.$store.state.selectedItems.length - 1];
            },

            url() {
                return (this.$store.state.previewItem && this.$store.state.previewItem.hasOwnProperty('url') ? this.$store.state.previewItem.url : null);
            }
        },
        methods: {
            /* Close the modal instance and reset the form */
            close() {
                this.$store.commit(types.HIDE_SHARE_MODAL);
                this.$store.commit(types.LOAD_FULL_CONTENTS_SUCCESS, null);
            },

            // Generate the url from backend
            generateUrl () {
                this.$store.dispatch('getFullContents', this.item);
            },

            // Copy to clipboard
            copyToClipboard() {
                this.$refs.urlText.focus();
                this.$refs.urlText.select();

                try {
                    document.execCommand('copy');
                } catch (err) {
                    // TODO Error handling in joomla way
                    alert(translate('COM_MEDIA_SHARE_COPY_FAILED_ERROR'));
                }
            }
        }
    }
</script>

The same content is in 4 releases, Joomla 4.0.0-alpha9 to 4.0.0-alpha12. See them all, or every version of this file.