<commit_before>/*global angular */

/**
 * @ngdoc directive
 * @name vjsVideoApp.directive:vjs.directive.js
 * @description
 * # vjs.directive.js
 */
(function () {
    'use strict';

    var module = angular.module('vjs.video', []);

    function getVidElement(element) {
        var vid = null;
        if (!window.videojs) {
            throw new Error('video.js was not found!');
        }

        if (element[0].nodeName === 'VIDEO') {
            vid = element[0];
        } else {
            throw new Error('directive must be attached to a video tag!');
        }

        return vid;
    }

    function initVideoJs(vid, scope, setupOptions) {
        var opts = setupOptions || {};

        if (!window.videojs) {
            return null;
        }

        //bootstrap videojs
        window.videojs(vid, opts, function () {

        });

        //dispose of videojs before destroying directive
        scope.$on('$destroy', function () {
            window.videojs(vid).dispose();
        });
    }

    module.directive('vjsVideo', function () {
        return {
            restrict: 'A',
            transclude: true,
            scope: {
                vjsSetup: '='
            },
            link: function postLink(scope, element, attrs, ctrl, transclude) {
                var vid = getVidElement(element);

                //attach transcluded content
                transclude(function (content) {
                    element.append(content);
                });

                initVideoJs(vid, scope, scope.vjsSetup);
            }
        };
    });
}());
<commit_msg>Started work on creating a basic responsive container directive - #1<commit_after>/*global angular */

/**
 * @ngdoc directive
 * @name vjsVideoApp.directive:vjs.directive.js
 * @description
 * # vjs.directive.js
 */
(function () {
    'use strict';

    var module = angular.module('vjs.video', []);

    function getVidElement(element, isContainer) {
        var vid = null,
            videos;

        if (!window.videojs) {
            throw new Error('video.js was not found!');
        }

        if (isContainer) {
            videos = element.getElementsByTagName("video");
            if (videos.length === 0) {
                throw new Error('video tag must be defined within container directive!');
            } else if (videos.length > 1) {
                throw new Error('only one video can be defined within the container directive!');
            }

            vid = videos[0];

        } else {
            if (element[0].nodeName === 'VIDEO') {
                vid = element[0];
            } else {
                throw new Error('directive must be attached to a video tag!');
            }
        }

        return vid;
    }

    function initVideoJs(vid, scope, setupOptions) {
        var opts = setupOptions || {};

        if (!window.videojs) {
            return null;
        }

        //bootstrap videojs
        window.videojs(vid, opts, function () {

        });

        //dispose of videojs before destroying directive
        scope.$on('$destroy', function () {
            window.videojs(vid).dispose();
        });
    }

    module.directive('vjsVideo', function () {
        return {
            restrict: 'A',
            transclude: true,
            scope: {
                vjsSetup: '='
            },
            link: function postLink(scope, element, attrs, ctrl, transclude) {
                var vid = getVidElement(element);

                //attach transcluded content
                transclude(function (content) {
                    element.append(content);
                });

                initVideoJs(vid, scope, scope.vjsSetup);
            }
        };
    });

    module.directive('vjsVideoContainer', function () {
        return {
            restrict: 'AE',
            transclude: true,
            templateUrl: 'scripts/directives/vjs.container.html',
            scope: {
                vjsSetup: '='
            },
            link: function postLink(scope, element, attrs, ctrl) {
                var vid = getVidElement(element, true);

                initVideoJs(vid, scope, scope.vjsSetup);
            }
        };
    });
}());

{'fraction_non_alphanumeric': 0.12194543297746145, 'fraction_numerical': 0.0018979833926453143, 'mean_word_length': 1.553603876438522, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5886031', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1107, 'n_words': 267}