UNPKG

6.19 kBJavaScriptView Raw
1(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2'use strict';
3
4var _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) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
5
6var _index = require('./index');
7
8var _index2 = _interopRequireDefault(_index);
9
10function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
12function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13
14var currentScript = document.currentScript;
15
16var WidgetProxy = function () {
17 function WidgetProxy(config) {
18 var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
19
20 _classCallCheck(this, WidgetProxy);
21
22 context.currentScript = currentScript;
23 this._widget = new _index2.default(config, context);
24 }
25
26 _createClass(WidgetProxy, [{
27 key: 'render',
28 value: function render() {
29 return this._widget.render();
30 }
31 }]);
32
33 return WidgetProxy;
34}();
35
36var ScrollirisReadabilityReflector = {
37 Widget: WidgetProxy
38};
39
40if (typeof module !== 'undefined' && module.exports) {
41 module.exports = ScrollirisReadabilityReflector;
42}
43
44window.ScrollirisReadabilityReflector = ScrollirisReadabilityReflector;
45
46},{"./index":2}],2:[function(require,module,exports){
47'use strict';
48
49Object.defineProperty(exports, "__esModule", {
50 value: true
51});
52
53var _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) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
54
55function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
56
57var Widget = function () {
58 function Widget(config) {
59 var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
60
61 _classCallCheck(this, Widget);
62
63 this.config = config;
64 this.context = context;
65 }
66
67 _createClass(Widget, [{
68 key: 'render',
69 value: function render() {
70 var ctx = this.context;
71
72 this._insertStyle();
73
74 // iframe
75 var iframe = document.createElement('iframe');
76 iframe.setAttribute('class', 'scrolliris-frame');
77
78 // iframe container
79 var container = document.createElement('div');
80 container.setAttribute('id', 'scrolliris_container');
81 container.appendChild(iframe);
82 document.body.appendChild(container);
83
84 var currentScript = ctx.currentScript || document.currentScript,
85 scriptSrc = currentScript.getAttribute('src') || '';
86 // This part assumes -canvas.{js|css} are both hosted in same location
87 // as -browser.js.
88 //
89 // reflector.js --> reflector-canvas.js,.css
90 // reflector-browser.js --> reflector-canvas.js,.css
91 var reflectorJSRegex = /(-browser)?(\.min)?\.js(\?)?/;
92 var canvasJS = (ctx.settings || {}).canvasJS || scriptSrc.replace(reflectorJSRegex, '-canvas$2.js$3').toString(),
93 canvasCSS = (ctx.settings || {}).canvasCSS || scriptSrc.replace(reflectorJSRegex, '-canvas$2.css$3').toString();
94
95 if (canvasJS === '') {
96 console.error('canvasJS is missing');
97 }
98 if (canvasCSS === '') {
99 console.error('canvasCSS is missing');
100 }
101
102 var content = '\n<head>\n <meta charset="utf-8">\n <link rel="stylesheet" href="' + canvasCSS + '">\n</head>\n<body>\n <div id="scrolliris_header">\n <h1>Text Readability Heatmap<span class="label">BETA</span></h1>\n <!-- <button class="btn close">close</button> -->\n </div>\n <div id="scrolliris_canvas_container"></div>\n <div id="scrolliris_footer">\n <p class="txt">Powered by\n <a href="https://scrolliris.com/" target="_blank">Scrolliris</a></p>\n </div>\n <script src="' + canvasJS + '"></script>\n</body>\n';
103 content = content.replace(/\n/g, '');
104 iframe.contentWindow.ScrollirisReadabilityReflector = {
105 Context: ctx
106 };
107 iframe.contentWindow.document.open();
108 iframe.contentWindow.document.write(content);
109 iframe.contentWindow.document.close();
110 }
111 }, {
112 key: '_insertStyle',
113 value: function _insertStyle() {
114 var cssContent = '\n#scrolliris_container {\n position: fixed;\n width: 0px;\n height: 0px;\n bottom: 0px;\n left: 0px;\n z-index: 9999999 !important;\n}\n\n#scrolliris_container .scrolliris-frame {\n z-index: 9999999 !important;\n position: fixed !important;\n bottom: 9px;\n left: 9px;\n width: 260px;\n height: 360px;\n border: 1px solid rgba(51, 51, 51, 0.18);\n border-radius: 1px;\n}\n';
115
116 var style = document.createElement('style');
117 style.type = 'text/css';
118 style.appendChild(document.createTextNode(cssContent));
119
120 var h = document.getElementsByTagName('head')[0];
121 h.appendChild(style);
122 }
123 }]);
124
125 return Widget;
126}();
127
128exports.default = Widget;
129
130},{}]},{},[1]);