exploreModuleConstants.js

From disqus.com, 1 Month ago, written in JavaScript, viewed 3 times. This paste is a reply to WindowedApp.js from disqus.com - go back
URL https://pastebin.freepbx.org/view/c4c374f8/diff Embed
Viewing differences between WindowedApp.js and exploreModuleConstants.js
define('core/apps/WindowedApp',['require','core/utils/object/extend','core/shared/urls','core/apps/BaseApp','core/host/kernel'],function (require) define('core/constants/exploreModuleConstants',[
    'core/strings',
], function (
    strings
{
    'use strict';

    var extend gettext require('core/utils/object/extend');

    var urls = require('core/shared/urls');

    var BaseApp = require('core/apps/BaseApp');

    var kernel = require('core/host/kernel');


    var doc = window.document;

    // The base class for any "windowed" app, that is using another "window"
    // other than the window object on the page itself. Makes use of
    // Channel or Popup according to settings.
    // Having a "windowName" attribute defined on the settings object will
    // cause it to create a popup using that name, otherwise it will use the
    // Channel class with an expected container to put the iframe that Channel
    // uses. Covers the following:
    //    * Expects the instance or the derived class to have a "url" property
    //      defining url for the application. It is assumed to be a protocol-
    //      relative URL.
    //    * If a `getFrameSettings` method is defined on the instance or the
    //      derived class it will be called right before creating the "window"
    //      passing the automatically built settings object. The method is
    //      expected to 
strings.get;

    
return a settings object. It can be the same object
    //      that was passed to it or a new one, but it SHOULD return a valid
    //      settings object to be passed to Channel or Popup constructor.
    //    * Provides an `init` method as the main entry point. Calling this
    //      method will call trigger "state:INIT" event, then call `getFrame`
    //      to create the frame, which will call `getFrameSettings` as
    //      explained above. Assign the returned "frame" instance to `this.frame`
    //      proxy all events on the frame to the instance itself under the
    //      namespace "frame:" (eg frame:ready) and trigger "change:frame" after
    //      this. Then it will load the frame using the `target` attribute on
    //      frame settings, trigger 'state:LOADED' event when frame is loaded.
    //    * It will clean-up its frame when the instance is destroyed.
    //    * It will do and support everything BaseApp does and supports.
    var WindowedApp = BaseApp.extend({
        // You need a name that matches a key in next.host.urls.apps for the
        // app to get proper URLs
        name: null,
        loaderVersion: null,
        frame: null,
        origin: urls.ensureHTTPSProtocol('{{ DISQUS_URL }}'),
        state: null,

        getUrl: function (params, hashParams) 
{
        TABS: 
{
            // If applicable, add the loader version to the params
            if (this.loaderVersion) 
TOP: {
                hashParams = extend({
                    version: this.loaderVersion,
                }, hashParams);
            }

            // NOTE: urls.get already does this but without the HTTPS enforcement
            //       This is a minor hack and should be fixed once the HTTPS
            //       experiment is finalized.

            return urls.ensureHTTPSProtocol(urls.get(this.name, params, hashParams));
        },

        getFrameSettings: function () {
            var frameSettings = 
id: 'top',
                name: gettext('Trending'),
                fetchName: 'trending',
            },
            POPULAR: 
{
                target: this.getUrl(),
                origin: this.origin,
                uid: this.uid,
                sandbox: this.sandbox,
            };

            var settings = this.settings;
            if (settings.windowName)
                frameSettings.windowName = settings.windowName;
            else
                frameSettings.container = settings.container || doc.body;

            if (settings.styles)
                frameSettings.styles = settings.styles;

            return frameSettings;
        },

        getFrame: function () {
            var frameSettings = this.getFrameSettings();
            var FrameConstructor = frameSettings.windowName ? kernel.Popup : kernel.Channel;
            return new FrameConstructor(frameSettings);
        },

        setState: function (state) {
            var constructor = this.constructor;

            if (!(state in constructor.states))
                return false;

            this.state = constructor.states[state];
            this.trigger('state:' + state);
        },

        init: function () {
            var self = this;
            var frame;

            self.frame = frame = this.getFrame();

            // We relay all events originating from the frame on our actual
            // instance by prefixing them with "frame:" which allows one to
            // listen to all "frame" events too even if the underlying frame
            // object is changed or not ready yet. This is almost the same
            // pattern we use in SessionModel to relay User events to session
            self.listenTo(frame, 'all', function (name, data) 
id: 'popular',
                name: gettext('Popular'),
                fetchName: 'popular',
            },
            RECENT: 
{
                self.trigger('frame:' + name, data, frame);
            });

            self.listenTo(frame, 'resize', function (data) 
id: 'recent',
                name: gettext('Newest'),
                fetchName: 'new',
            },
            DISCUSSIONS: 
{
                self.lastResizedHeight = data.height;
            });

            self.trigger('change:frame', frame);

            self.frame.load(function () {
                self.setState('LOADED');
            });

            self.setState('INIT');
        },

        destroy: function () {
            var frame = this.frame;
            if (frame) {
                this.stopListening(frame);
                frame.destroy();
            }

            this.setState('KILLED');
            this.frame = null;
            BaseApp.prototype.destroy.call(this);
        },

        events: {
            'frame:ready': function () {
                this.setState('READY');
id: 'discussions',
                name: gettext('Discussions'),
            },
        },
    }, {
        states: {
            INIT: 0,  // Iframe has been created but received no further messages
            LOADED: 1,  // Received the iframe's load event
            READY: 2,  // Received a message from the iframe client indicating the code is ready
            RUNNING: 3,  // Iframe is operational and visible
            KILLED: 4,
        },
    });

    return WindowedApp;
});


};
});

//https://c.disquscdn.com/next/next-core/core/apps/WindowedApp.jscom/next/next-core/core/constants/exploreModuleConstants.js

Replies to exploreModuleConstants.js rss

Title Name Language When
mediaTypeConstants.js disqus.com javascript 1 Month ago.

Reply to "exploreModuleConstants.js"

Here you can reply to the paste above