betajs/betajs-media-components

View on GitHub
src/dynamics/video_player/share/share.js

Summary

Maintainability
A
0 mins
Test Coverage
Scoped.define("module:VideoPlayer.Dynamics.Share", [
    "dynamics:Dynamic",
    "module:Assets"
], function(Class, Assets, scoped) {

    var SHARES = {
        facebook: 'https://facebook.com/sharer/sharer.php?u=',
        gplus: 'https://plus.google.com/share?url=',
        linkedin: 'https://www.linkedin.com/sharing/share-offsite/?url=',
        twitter: 'https://twitter.com/intent/tweet?text='
    };

    return Class.extend({
            scoped: scoped
        }, function(inherited) {
            return {

                template: "<%= template(dirname + '/video_player_share.html') %>",

                attrs: {
                    css: "ba-videoplayer",
                    csscommon: "ba-commoncss",
                    cssplayer: "ba-player",
                    url: "",
                    shares: []
                },

                functions: {

                    shareMedia: function(share) {
                        window.open(SHARES[share] + this.get("url"), 'pop', 'width=600 height=400');
                    },

                    toggleShare: function() {
                        /*
                        var container = this.activeElement().querySelector().firstElementChild;
                        container.style.right = container.style.right ? "" : "-45px";
                        */
                    }

                }
            };
        }).register("ba-videoplayer-share")
        .registerFunctions({
            /*<%= template_function_cache(dirname + '/video_player_share.html') %>*/
        })
        .attachStringTable(Assets.strings)
        .addStrings({
            "share": "Share media"
        });
});