<commit_before>(function() {
    angular
        .module("bibframeEditor")
        .directive("scribePopover", ["$q", "$timeout", "$document", "$position", "Resolver", ScribePopoverDirective]);

    function ScribePopoverDirective($q, $timeout, $document, $position, Resolver) {
        function resolve(uri) {
            var deferred = $q.defer();
            Resolver.resolve({"uri": uri}).$promise.then(function(data) {
                deferred.resolve(data.raw);
            }).catch(function(data) {
                deferred.reject("No additional data could be found.");
            });
            return deferred.promise;
        }

        function getAttr(attrs, name) {
            var prefix = "scribePopover";
            if (angular.isDefined(attrs[prefix + name])) {
                return attrs[prefix + name];
            } else {
                return null;
            }
        }

        return {
            restrict: "A",
            link: function(scope, el, atts) {
                var delay, trigger, cancel, to, tt, ttClick, docClick, docType, show, stop, destroy;

                delay = parseInt(getAttr(atts, "Delay"), 10);
                trigger = getAttr(atts, "Trigger");
                cancel = getAttr(atts, "Cancel");
                to = null;

                show = function() {
                    if (!to) {
                        to = $timeout(function() {
                            resolve(getAttr(atts, "Resource")).then(function(h) {
                                var esc, pos;
                                $document.triggerHandler("scribePopoverOpened");
                                esc = h.replace(/</g,"&lt;").replace(/>/g,"&gt;");
                                // @@@ make this a template?
                                tt = angular.element('<div class="popover right resource"><div class="arrow"></div><code>&lt;' + getAttr(atts, "Resource") + '&gt;</code><hr><pre>' + esc + '</pre></div>');
                                $document.find("body").append(tt);
                                tt.css({ top: 0, left: 0, display: "block" });
                                pos = $position.positionElements(el, tt, "right", true);
                                pos.top += "px";
                                pos.left += "px";
                                tt.css(pos);
                                // do not destroy if tt clicked directly
                                ttClick = tt.on("click", function(evt) {
                                    evt.stopPropagation();
                                });
                            });
                        }, delay, false);
                    }
                };

                stop = function() {
                    if (to) {
                        $timeout.cancel(to);
                        to = null;
                    }
                };

                destroy = function() {
                    stop();
                    if (tt) {<commit_msg>link popover uri and include some text to describe how to use it<commit_after>(function() {
    angular
        .module("bibframeEditor")
        .directive("scribePopover", ["$q", "$timeout", "$document", "$position", "Resolver", ScribePopoverDirective]);

    function ScribePopoverDirective($q, $timeout, $document, $position, Resolver) {
        function resolve(uri) {
            var deferred = $q.defer();
            Resolver.resolve({"uri": uri}).$promise.then(function(data) {
                deferred.resolve(data.raw);
            }).catch(function(data) {
                deferred.reject("No additional data could be found.");
            });
            return deferred.promise;
        }

        function getAttr(attrs, name) {
            var prefix = "scribePopover";
            if (angular.isDefined(attrs[prefix + name])) {
                return attrs[prefix + name];
            } else {
                return null;
            }
        }

        return {
            restrict: "A",
            link: function(scope, el, atts) {
                var delay, trigger, cancel, to, tt, ttClick, docClick, docType, show, stop, destroy;

                delay = parseInt(getAttr(atts, "Delay"), 10);
                trigger = getAttr(atts, "Trigger");
                cancel = getAttr(atts, "Cancel");
                to = null;

                show = function() {
                    if (!to) {
                        to = $timeout(function() {
                            resolve(getAttr(atts, "Resource")).then(function(h) {
                                var esc, pos;
                                $document.triggerHandler("scribePopoverOpened");
                                esc = h.replace(/</g,"&lt;").replace(/>/g,"&gt;");
                                // @@@ make this a template?
                                tt = angular.element('<div class="popover right resource"><div class="arrow"></div><p class="text-center"><a target="_blank" href="' + getAttr(atts, "Resource") + '"><code>&lt;' + getAttr(atts, "Resource") + '&gt;</code></a></p><p class="text-center"><small>Click the URI above to view a more reader-oriented version in a new window, or review the RDF below.</small></p><hr><pre>' + esc + '</pre></div>');
                                $document.find("body").append(tt);
                                tt.css({ top: 0, left: 0, display: "block" });
                                pos = $position.positionElements(el, tt, "right", true);
                                pos.top += "px";
                                pos.left += "px";
                                tt.css(pos);
                                // do not destroy if tt clicked directly
                                ttClick = tt.on("click", function(evt) {
                                    evt.stopPropagation();
                                });
                            });
                        }, delay, false);
                    }
                };

                stop = function() {
                    if (to) {
                        $timeout.cancel(to);
                        to = null;
                    }
                };

                destroy = function() {
                    stop();
                    if (tt) {
{'fraction_non_alphanumeric': 0.13392857142857142, 'fraction_numerical': 0.0012755102040816326, 'mean_word_length': 1.1556701030927834, 'pattern_counts': {'":': 2, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3736513', 'n_tokens_mistral': 1570, 'n_tokens_neox': 1472, 'n_words': 339}