npmtest-excel4node (v0.0.1)

Code coverage report for node-npmtest-excel4node/excel4node/distribution/lib/worksheet/classes/hyperlink.js

Statements: 36.36% (24 / 66)      Branches: 21.43% (6 / 28)      Functions: 33.33% (5 / 15)      Lines: 22% (11 / 50)      Ignored: none     

All files » node-npmtest-excel4node/excel4node/distribution/lib/worksheet/classes/ » hyperlink.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105    5   1   1   1                                                   1                                               1     1   1           1                                                           1     1    
'use strict';
 
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { Eif (protoProps) defineProperties(Constructor.prototype, protoProps); Iif (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
 
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
var Hyperlink = function () {
    //§18.3.1.47 hyperlink (Hyperlink)
    function Hyperlink(opts) {
        _classCallCheck(this, Hyperlink);
 
        opts = opts ? opts : {};
 
        if (opts.ref === undefined) {
            throw new TypeError('ref is a required option when creating a hyperlink');
        }
        this.ref = opts.ref;
 
        if (opts.display !== undefined) {
            this.display = opts.display;
        } else {
            this.display = opts.location;
        }
        if (opts.location !== undefined) {
            this.location = opts.location;
        }
        if (opts.tooltip !== undefined) {
            this.tooltip = opts.tooltip;
        } else {
            this.tooltip = opts.location;
        }
        this.id;
    }
 
    _createClass(Hyperlink, [{
        key: 'addToXMLEle',
        value: function addToXMLEle(ele) {
            var thisEle = ele.ele('hyperlink');
            thisEle.att('ref', this.ref);
            thisEle.att('r:id', this.rId);
            if (this.display !== undefined) {
                thisEle.att('display', this.display);
            }
            if (this.location !== undefined) {
                thisEle.att('location', this.location);
            }
            if (this.tooltip !== undefined) {
                thisEle.att('tooltip', this.tooltip);
            }
            thisEle.up();
        }
    }, {
        key: 'rId',
        get: function get() {
            return 'rId' + this.id;
        }
    }]);
 
    return Hyperlink;
}();
 
var HyperlinkCollection = function () {
    //§18.3.1.48 hyperlinks (Hyperlinks)
    function HyperlinkCollection() {
        _classCallCheck(this, HyperlinkCollection);
 
        this.links = [];
    }
 
    _createClass(HyperlinkCollection, [{
        key: 'add',
        value: function add(opts) {
            var thisLink = new Hyperlink(opts);
            thisLink.id = this.links.length + 1;
            this.links.push(thisLink);
            return thisLink;
        }
    }, {
        key: 'addToXMLele',
        value: function addToXMLele(ele) {
            var _this = this;
 
            if (this.length > 0) {
                (function () {
                    var linksEle = ele.ele('hyperlinks');
                    _this.links.forEach(function (l) {
                        l.addToXMLEle(linksEle);
                    });
                    linksEle.up();
                })();
            }
        }
    }, {
        key: 'length',
        get: function get() {
            return this.links.length;
        }
    }]);
 
    return HyperlinkCollection;
}();
 
module.exports = { HyperlinkCollection: HyperlinkCollection, Hyperlink: Hyperlink };
//# sourceMappingURL=hyperlink.js.map