Exemplo n.º 1
0
        return new Promise(function (resolve, reject) {
            if (!that.hasAction('delete')) {
                return;
            }

            var modalOptions = options.modal || module.config.modal.deleteConfirm;

            modal.confirm(modalOptions).then(function ($confirmed) {
                if (!$confirmed) {
                    resolve(false);
                    return;
                }

                that.loader();
                var deleteUrl = that.data(DATA_CONTENT_DELETE_URL) || module.config.deleteUrl;
                if (deleteUrl) {
                    client.post(deleteUrl, {
                        data: {id: that.getKey()}
                    }).then(function (response) {
                        that.remove().then(function () {
                            resolve(true);
                        });
                    }).catch(function (err) {
                        reject(err);
                    }).finally(function () {
                        that.loader(false);
                    });
                } else {
                    reject('Content delete was called, but no url could be determined for ' + that.base);
                    that.loader(false);
                }
            });
        });
 var create = function (evt) {
     modal.load(evt).then(function () {
         modal.global.$.one('hidden.bs.modal', function() {
             client.reload();
         });
     });
 };
 var edit = function (evt) {
     modal.load(evt).then(function () {
         modal.global.$.one('hidden.bs.modal', function() {
             Widget.closest(evt.$trigger).reload();
         });
     }).catch(function(e) {
         module.log.error(e,true);
     });
 };
Exemplo n.º 4
0
 var submitMove = function(evt) {
     modal.submit(evt).then(function(response) {
        if(response.success) {
            if(response.message) {
                module.log.success(response.message);
            }
            event.trigger('humhub:content:afterMove', response);
        }
     });
 };
Exemplo n.º 5
0
 StreamEntry.prototype.editModal = function (evt) {
     var that = this;
     modal.load(evt).then(function (response) {
         modal.global.$.one('hidden.bs.modal', function () {
             that.reload();
         });
     }).catch(function (e) {
         module.log.error(e, true);
     });
 };
Exemplo n.º 6
0
                        callback: function (e) {

                            var fileModal = modal.get('#markdown-modal-file-upload');
                            fileModal.show();

                            that.getUploadButtonWidget().off('uploadEnd').on('uploadEnd', function(evt, response) {
                                fileModal.close();
                                $.each(response.result.files, function(i, file) {
                                    var chunk = (file.mimeType.substring(0, 6) == "image/") ? '!' : '';
                                    chunk += "[" + file.name + "](file-guid-" + file.guid + ")";
                                    that.insert(e, chunk);
                                    e.setSelection(e.end, 0);
                                });
                            });
                        }
Exemplo n.º 7
0
        return new Promise(function (resolve, reject) {

            var modalOptions = options.modal || module.config.modal.deleteConfirm;

            if(options.$trigger && options.$trigger.is('[data-action-confirm]')) {
                that.deleteContent(resolve, reject);
            } else {
                modal.confirm(modalOptions).then(function ($confirmed) {
                    if (!$confirmed) {
                        resolve(false);
                        return;
                    }

                    that.deleteContent(resolve, reject);
                });
            }
        });
Exemplo n.º 8
0
                        callback: function (e) {
                            var linkModal = modal.get('#markdown-modal-add-link');
                            $titleInput = linkModal.$.find('.linkTitle');
                            $urlInput = linkModal.$.find('.linkTarget');

                            linkModal.show();

                            $titleInput.val(e.getSelection().text);
                            if ($titleInput.val() == "") {
                                $titleInput.focus();
                            } else {
                                $urlInput.focus();
                            }

                            linkModal.$.find('.addLinkButton').off('click').on('click', function () {
                                that.insert(e, "[" + $titleInput.val() + "](" + $urlInput.val() + ")");
                                linkModal.close();
                            });

                            linkModal.$.on('hide.bs.modal', function (e) {
                                $titleInput.val("");
                                $urlInput.val("");
                            })
                        }
 TemplateElement.prototype.editAction = function (evt) {
     modal.load(evt, {dataType:'json', data: this.getEditData()});
 };
Exemplo n.º 10
0
 var editTask = function (evt) {
     modal.load(evt).then(function () {
         modal.global.$.one('submitted', onEditTaskSubmitted);
     });
 };
 var setEditorLink = function (evt) {
     var linkModal = modal.get('#wikiLinkModal');
     linkModal.$.trigger('submitted');
     linkModal.close();
 };
    var openModal = function (context, state, dispatch, view, attrs) {

        $('.field-wikipagesearch-anchor').hide();

        $('#wikipagesearch-anchor').empty();

        var linkModal = modal.get('#wikiLinkModal');

        $('#wikipagesearch-title').off('change.extract').on('change.extract', function() {
            var id =  $('#wikipagesearch-title').val();

            if(!id) {
                return;
            }

            $('#wikipagesearch-label').val($('#wikipagesearch-title').select2('data')[0].text);

            client.get(module.config.extractTitleUrl, {data: {id:  $('#wikipagesearch-title').val()}}).then(function(response) {
                var slugs = {};

                if(!response.response || !response.response.length) {
                    $('.field-wikipagesearch-anchor').hide();
                    return;
                }

                var $option = $('<option>').attr({value: ''}).text('');
                $('#wikipagesearch-anchor').append($option);

                response.response.forEach(function(title) {
                    var slug = uniqueSlug(slugify(title), slugs);
                    var $option = $('<option>').attr({value: slug}).text(title);
                    $('#wikipagesearch-anchor').append($option);
                });

                if (attrs && attrs.anchor) {
                    $('#wikipagesearch-anchor').val(attrs.anchor)
                }

                $('.field-wikipagesearch-anchor').show();
            }).catch(function(e) {
                module.log.error(e);
            })

        });

        if (attrs && attrs.wikiId) {
            $('#wikipagesearch-title').val(attrs.wikiId).trigger('change');
        } else {
            $('#wikipagesearch-title').val(1).trigger('change');
        }



        if (attrs && attrs.label) {
            $('#wikipagesearch-label').val(attrs.label);
        } else {
            $('#wikipagesearch-label').val(state.doc.cut(state.selection.from, state.selection.to).textContent);
        }

        linkModal.$.off('submitted').on('submitted', function () {
            var $option = $('#wikipagesearch-title option:selected');
            var $label = $('#wikipagesearch-label');

            var newAttrs = {
                title: $option.text(),
                wikiId: $('#wikipagesearch-title').val(),
                anchor: $('#wikipagesearch-anchor').val(),
                label: $label.val()
            };

            linkModal.close();

            view.dispatch(view.state.tr.replaceSelectionWith(context.schema.nodes.wiki.createAndFill(newAttrs)));


            view.focus();
        }).show();
    };