<commit_before>/**
 * This file defines all the directives used to construct the html for the app
 */
(function (ng, app) {
    'use strict';

    var _injectors = {};

    /*   */
    /**
     * the modal which will be used to populate images
     * @type {Array} the list of angular dependencies and the modal controoler
     * @private
     */
    var _imageSelectionModal = ["$scope", "$modalInstance", "images", function ($scope, $modalInstance, images) {
        $scope.selected = {
            image: images[0].url
        };
        $scope.imageGroups = _.chain(images).
            groupBy(function (image, index) {
                //noinspection JSUnresolvedVariable
                return Math.floor(index / 5);//splitting images into groups of 5
            })
            .values()
            .value();
        $scope.ok = function () {
            $modalInstance.close($scope.selected.image);
        };

        $scope.cancel = function () {
            $modalInstance.dismiss('cancel');
        };
    }];

    /**
     * Common actions performed by all post link functions of sokratik fragment
     * @param scope the scope for the directive , this is isolated
     * @param attrs the attrs of the element
     * @param sokratikDialogueCtrl the controller of encapsulating directive
     * @private
     */
    var _fragmentCommonLink = function (scope, attrs, sokratikDialogueCtrl) {
        scope.model = {};
        scope.model.value = sokratikDialogueCtrl.getProperty(attrs.model) ;
        scope.model.css = ["fragment"];
        if (!_.str.isBlank(scope.model.value)) {
            sokratikDialogueCtrl.addFragment(scope.model);
        }
    };

    var editCommonLink = function (scope, attrs, sokratikDialogueCtrl) {
        scope.model.value =  sokratikDialogueCtrl.getProperty(attrs.model)  || attrs.default;
    };

    var _fragmentLink = {
        "edit": {
            "text": function (scope, element, attrs, sokratikDialogueCtrl) {
                _fragmentCommonLink(scope, attrs, sokratikDialogueCtrl);
                // Listen for change events to enable binding
                element.on('blur keyup change', function () {
                    scope.$apply(read);
                });
                editCommonLink(scope, attrs,sokratikDialogueCtrl);

                // Write data to the model
                function read() {
                    var html = angular.element(element).children().html();
                    scope.model.value = _injectors.$sce.trustAsHtml(html);
                    sokratikDialogueCtrl.setProperty(attrs.model, html);
                }
            },
            "image": function (scope, element, attrs, sokratikDialogueCtrl) {
                _fragmentCommonLink(scope, attrs, sokratikDialogueCtrl);
                //registers the current value in the parent dialogue which is aware of the entire presentation
                editCommonLink(scope, attrs);<commit_msg>[v1.1] fixing NPEs<commit_after>/**
 * This file defines all the directives used to construct the html for the app
 */
(function (ng, app) {
    'use strict';

    var _injectors = {};

    /*   */
    /**
     * the modal which will be used to populate images
     * @type {Array} the list of angular dependencies and the modal controoler
     * @private
     */
    var _imageSelectionModal = ["$scope", "$modalInstance", "images", function ($scope, $modalInstance, images) {
        $scope.selected = {
            image: images[0].url
        };
        $scope.imageGroups = _.chain(images).
            groupBy(function (image, index) {
                //noinspection JSUnresolvedVariable
                return Math.floor(index / 5);//splitting images into groups of 5
            })
            .values()
            .value();
        $scope.ok = function () {
            $modalInstance.close($scope.selected.image);
        };

        $scope.cancel = function () {
            $modalInstance.dismiss('cancel');
        };
    }];

    /**
     * Common actions performed by all post link functions of sokratik fragment
     * @param scope the scope for the directive , this is isolated
     * @param attrs the attrs of the element
     * @param sokratikDialogueCtrl the controller of encapsulating directive
     * @private
     */
    var _fragmentCommonLink = function (scope, attrs, sokratikDialogueCtrl) {
        scope.model = {};
        scope.model.value = sokratikDialogueCtrl.getProperty(attrs.model) ;
        scope.model.css = ["fragment"];
        if (!_.str.isBlank(scope.model.value)) {
            sokratikDialogueCtrl.addFragment(scope.model);
        }
    };

    var editCommonLink = function (scope, attrs, sokratikDialogueCtrl) {
        scope.model.value =  sokratikDialogueCtrl.getProperty(attrs.model)  || attrs.default;
    };

    var _fragmentLink = {
        "edit": {
            "text": function (scope, element, attrs, sokratikDialogueCtrl) {
                _fragmentCommonLink(scope, attrs, sokratikDialogueCtrl);
                // Listen for change events to enable binding
                element.on('blur keyup change', function () {
                    scope.$apply(read);
                });
                editCommonLink(scope, attrs,sokratikDialogueCtrl);

                // Write data to the model
                function read() {
                    var html = angular.element(element).children().html();
                    scope.model.value = _injectors.$sce.trustAsHtml(html);
                    sokratikDialogueCtrl.setProperty(attrs.model, html);
                }
            },
            "image": function (scope, element, attrs, sokratikDialogueCtrl) {
                _fragmentCommonLink(scope, attrs, sokratikDialogueCtrl);
                //registers the current value in the parent dialogue which is aware of the entire presentation
                editCommonLink(scope, attrs,sokratikDialogueCtrl);
{'fraction_non_alphanumeric': 0.10449780182617517, 'fraction_numerical': 0.0013527223537368955, 'mean_word_length': 2.0271238485158647, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, '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': '342510', 'n_tokens_mistral': 1561, 'n_tokens_neox': 1517, 'n_words': 407}