Esempio n. 1
0
export default function (message) {
    modalDialog.confirm({
        name: 'text_alert',
        data: {
            message: message
        }
    });
}
Esempio n. 2
0
    return new Promise(function (resolve) {
        modalDialog.confirm({
            name: 'modal_template',
            data: data
        }).then(ok, cancel);

        // Knockout has to refresh the view
        setTimeout(function () {
            resolve();
        }, 50);
    });
Esempio n. 3
0
            .then(function(res) {
                // TODO Phantom Babel bug
                if (!res) { res = {}; }
                var results = res.content,
                    resultsTitle = res.title,
                    capiItem,
                    icc,
                    pageCode,
                    err;

                // ContentApi item
                if (results && results.length === 1) {
                    capiItem = results[0];
                    icc = internalContentCode(capiItem);
                    pageCode = internalPageCode(capiItem);
                    if (icc && icc === item.id()) {
                        populate(item, capiItem);
                        cache.put('contentApi', icc, capiItem);
                        item.id(icc);
                    } else if (pageCode) {
                        populate(item, capiItem);
                        cache.put('contentApi', pageCode, capiItem);
                        // Populate the cache with icc as well
                        if (icc) {
                            cache.put('contentApi', icc, capiItem);
                        }
                        item.id(pageCode);
                    } else {
                        err = 'Sorry, that article is malformed (has no internalPageCode)';
                    }

                // A snap, but not an absolute url
                } else if (!item.id().match(/^https?:\/\//)) {
                    err = 'Sorry, URLs must begin with http...';

                // A snap, but snaps can only be created to the Clipboard
                } else if (item.group.parentType !== 'Clipboard') {
                    err = 'Sorry, special links must be dragged to the Clipboard, initially';

                // A snap, but a link off of the tool itself
                } else if (item.id().indexOf(window.location.hostname) > -1) {
                    err = 'Sorry, that link cannot be added to a front';

                // A snap, but a link to unavailable guardian content
                } else if (results && results.length === 0 && isGuardianUrl(item.id())) {
                    err = 'Sorry, that Guardian content is unavailable';

                // A snap, that's setting it's own type, ie via dragged-in query params
                } else if (item.meta.snapType()) {
                    item.convertToSnap();

                // A snap, of type 'latest', ie.  where the target is a Guardian tag/section page.
                } else if (results && results.length > 1) {
                    modalDialog.confirm({
                        name: 'select_snap_type',
                        data: {
                            prefix: CONST.latestSnapPrefix,
                            resultsTitle: resultsTitle
                        }
                    }).then(function () {
                        item.convertToLatestSnap(resultsTitle);
                        resolve(item);
                    }, function () {
                        item.convertToLinkSnap();
                        resolve(item);
                    });

                    // Waiting for the modal to be closed
                    return;

                    // A snap, of default type 'link'.
                } else {
                    item.convertToLinkSnap();
                }

                if (err) {
                    reject(new Error(err));
                } else {
                    resolve(item);
                }
            });