UNPKG

4.46 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
4Object.defineProperty(exports, "__esModule", {
5 value: true
6});
7
8var _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; }; }();
9
10function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
12var Widget = function () {
13 function Widget(config) {
14 var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
15
16 _classCallCheck(this, Widget);
17
18 this.config = config;
19 this.context = context;
20 }
21
22 _createClass(Widget, [{
23 key: 'render',
24 value: function render() {
25 var ctx = this.context;
26
27 this._insertStyle();
28
29 // iframe
30 var iframe = document.createElement('iframe');
31 iframe.setAttribute('class', 'scrolliris-frame');
32
33 // iframe container
34 var container = document.createElement('div');
35 container.setAttribute('id', 'scrolliris_container');
36 container.appendChild(iframe);
37 document.body.appendChild(container);
38
39 var currentScript = ctx.currentScript || document.currentScript,
40 scriptSrc = currentScript.getAttribute('src') || '';
41 // This part assumes -canvas.{js|css} are both hosted in same location
42 // as -browser.js.
43 //
44 // reflector.js --> reflector-canvas.js,.css
45 // reflector-browser.js --> reflector-canvas.js,.css
46 var reflectorJSRegex = /(-browser)?(\.min)?\.js(\?)?/;
47 var canvasJS = (ctx.settings || {}).canvasJS || scriptSrc.replace(reflectorJSRegex, '-canvas$2.js$3').toString(),
48 canvasCSS = (ctx.settings || {}).canvasCSS || scriptSrc.replace(reflectorJSRegex, '-canvas$2.css$3').toString();
49
50 if (canvasJS === '') {
51 console.error('canvasJS is missing');
52 }
53 if (canvasCSS === '') {
54 console.error('canvasCSS is missing');
55 }
56
57 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';
58 content = content.replace(/\n/g, '');
59 iframe.contentWindow.ScrollirisReadabilityReflector = {
60 Context: ctx
61 };
62 iframe.contentWindow.document.open();
63 iframe.contentWindow.document.write(content);
64 iframe.contentWindow.document.close();
65 }
66 }, {
67 key: '_insertStyle',
68 value: function _insertStyle() {
69 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';
70
71 var style = document.createElement('style');
72 style.type = 'text/css';
73 style.appendChild(document.createTextNode(cssContent));
74
75 var h = document.getElementsByTagName('head')[0];
76 h.appendChild(style);
77 }
78 }]);
79
80 return Widget;
81}();
82
83exports.default = Widget;
84
85},{}]},{},[1]);