From 3f7598645f20960d16cf33365fe958d8d4058b18 Mon Sep 17 00:00:00 2001 From: Laurens Rietveld Date: Fri, 27 Oct 2017 15:30:52 +0200 Subject: [PATCH] Updated dist/docs --- dist/yasr.bundled.js | 8 ++++---- dist/yasr.bundled.js.map | 4 ++-- dist/yasr.bundled.min.js | 4 ++-- dist/yasr.bundled.min.js.map | 2 +- dist/yasr.js | 8 ++++---- dist/yasr.js.map | 4 ++-- dist/yasr.min.js | 6 +++--- dist/yasr.min.js.map | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/dist/yasr.bundled.js b/dist/yasr.bundled.js index 742abbf..b316dec 100644 --- a/dist/yasr.bundled.js +++ b/dist/yasr.bundled.js @@ -85545,7 +85545,7 @@ module.exports = { module.exports={ "name": "yasgui-yasr", "description": "Yet Another SPARQL Resultset GUI", - "version": "2.12.4", + "version": "2.12.5", "main": "src/main.js", "license": "MIT", "author": "Laurens Rietveld", @@ -86590,7 +86590,7 @@ var LibColor = require("color"); var colormap = require('colormap'); var colorScales = require('colormap/colorScale') function getWicket() { - if (!global.Wkt) global.Wkt = require("wicket/wicket"); + global.Wkt = require("wicket/wicket"); require("wicket/wicket-leaflet"); return new Wkt.Wkt(); } @@ -86669,7 +86669,7 @@ var root = (module.exports = function(yasr) { for (var i = 0; i < bindings.length; i++) { var binding = bindings[i]; - if (!binding[plotVariable].value) continue; + if (! binding[plotVariable] || !binding[plotVariable].value) continue; var getColor = function() { var colorBinding = binding[plotVariable + "Color"]; @@ -86881,7 +86881,7 @@ var maps = { }; root.defaults = { maps: maps, - L: window.L || require('leaflet'), + L: require('leaflet'), formatPopup: function(yasr, L, forVariable, bindings) { var binding = bindings[forVariable+"Label"]; if (binding && binding.value) { diff --git a/dist/yasr.bundled.js.map b/dist/yasr.bundled.js.map index 20b5c87..b39bce6 100644 --- a/dist/yasr.bundled.js.map +++ b/dist/yasr.bundled.js.map @@ -368,7 +368,7 @@ "window.console = window.console || {\"log\":function(){}};//make sure any console statements don't break IE\nmodule.exports = {\n\tstorage: require(\"./storage.js\"),\n\tsvg: require(\"./svg.js\"),\n\tversion: {\n\t\t\"yasgui-utils\" : require(\"../package.json\").version,\n\t},\n\tnestedExists : function(obj) {\n\t\tvar args = Array.prototype.slice.call(arguments, 1);\n\n\t\tfor (var i = 0; i < args.length; i++) {\n\t\t\tif (!obj || !obj.hasOwnProperty(args[i])) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tobj = obj[args[i]];\n\t\t}\n\t\treturn true;\n\t}\n};\n", "var store = require(\"store\");\nvar times = {\n day: function() {\n return 1000 * 3600 * 24; //millis to day\n },\n month: function() {\n times.day() * 30;\n },\n year: function() {\n times.month() * 12;\n }\n};\nfunction isQuotaExceeded(e) {\n var quotaExceeded = false;\n if (e) {\n if (e.code) {\n switch (e.code) {\n case 22:\n quotaExceeded = true;\n break;\n case 1014:\n // Firefox\n if (e.name === \"NS_ERROR_DOM_QUOTA_REACHED\") {\n quotaExceeded = true;\n }\n break;\n }\n } else if (e.number === -2147024882) {\n // Internet Explorer 8\n quotaExceeded = true;\n }\n }\n return quotaExceeded;\n}\nvar root = (module.exports = {\n set: function(key, val, exp, onQuotaExceeded) {\n if (!store.enabled) return; //this is probably in private mode. Don't run, as we might get Js errors\n if (key && val !== undefined) {\n if (typeof exp == \"string\") {\n exp = times[exp]();\n }\n //try to store string for dom objects (e.g. XML result). Otherwise, we might get a circular reference error when stringifying this\n if (val.documentElement) val = new XMLSerializer().serializeToString(val.documentElement);\n try {\n store.set(key, {\n val: val,\n exp: exp,\n time: new Date().getTime()\n });\n } catch (e) {\n e.quotaExceeded = isQuotaExceeded(e);\n if (e.quotaExceeded && onQuotaExceeded) {\n onQuotaExceeded(e);\n } else {\n throw e;\n }\n }\n }\n },\n remove: function(key) {\n if (!store.enabled) return; //this is probably in private mode. Don't run, as we might get Js errors\n if (key) store.remove(key);\n },\n removeAll: function(filter) {\n if (!store.enabled) return; //this is probably in private mode. Don't run, as we might get Js errors\n if (!filter) {\n store.clearAll();\n } else if (typeof filter === \"function\") {\n store.each(function(value, key) {\n if (filter(key, value)) root.remove(key);\n });\n }\n },\n get: function(key) {\n if (!store.enabled) return null; //this is probably in private mode. Don't run, as we might get Js errors\n if (key) {\n var info = store.get(key);\n if (!info) {\n return null;\n }\n if (info.exp && new Date().getTime() - info.time > info.exp) {\n return null;\n }\n return info.val;\n } else {\n return null;\n }\n }\n});\n", "module.exports = {\n\tdraw: function(parent, svgString) {\n\t\tif (!parent) return;\n\t\tvar el = module.exports.getElement(svgString);\n\t\tif (el) {\n\t\t\tif (parent.append) {\n\t\t\t\tparent.append(el);\n\t\t\t} else {\n\t\t\t\t//regular dom doc\n\t\t\t\tparent.appendChild(el);\n\t\t\t}\n\t\t}\n\t},\n\tgetElement: function(svgString) {\n\t\tif (svgString && svgString.indexOf(\"= 0) {\n //use double quotes to escape these\n value = value.replace(new RegExp(quote, \"g\"), quote + quote);\n }\n //and finally add quotes all around\n value = quote + value + quote;\n }\n csvString += \" \" + value + \" \" + delimiter;\n };\n\n var needToQuoteString = function(value) {\n //quote when it contains whitespace or the delimiter\n var needQuoting = false;\n if (value.match(\"[\\\\w|\" + delimiter + \"|\" + quote + \"]\")) {\n needQuoting = true;\n }\n return needQuoting;\n };\n\n var csvString = \"\";\n createHeader();\n createBody();\n return csvString;\n};\n", "\"use strict\";\nvar $ = require(\"jquery\");\n\n/**\n * Constructor of plugin which displays boolean info\n * \n * @param yasr {object}\n * @param parent {DOM element}\n * @param options {object}\n * @class YASR.plugins.boolean\n * @return yasr-boolean (doc)\n * \n */\nvar root = module.exports = function(yasr) {\n var container = $(\"
\");\n var draw = function() {\n container.empty().appendTo(yasr.resultsContainer);\n var booleanVal = yasr.results.getBoolean();\n\n var imgId = null;\n var textVal = null;\n if (booleanVal === true) {\n imgId = \"check\";\n textVal = \"True\";\n } else if (booleanVal === false) {\n imgId = \"cross\";\n textVal = \"False\";\n } else {\n container.width(\"140\");\n textVal = \"Could not find boolean value in response\";\n }\n\n //add icon\n if (imgId) require(\"yasgui-utils\").svg.draw(container, require(\"./imgs.js\")[imgId]);\n\n $(\"\").text(textVal).appendTo(container);\n };\n\n var canHandleResults = function() {\n return yasr.results.getBoolean && (yasr.results.getBoolean() === true || yasr.results.getBoolean() == false);\n };\n\n return {\n name: null, //don't need to set this: we don't show it in the selection widget anyway, so don't need a human-friendly name\n draw: draw,\n hideFromSelection: true,\n getPriority: 10,\n canHandleResults: canHandleResults\n };\n};\n\nroot.version = {\n \"YASR-boolean\": require(\"../package.json\").version,\n jquery: $.fn.jquery\n};\n", "\"use strict\";\nvar $ = require(\"jquery\");\nmodule.exports = {\n /**\n\t * key of default plugin to use\n\t * @property output\n\t * @type string\n\t * @default \"table\"\n\t */\n output: \"table\",\n useGoogleCharts: true,\n outputPlugins: [\"table\", \"error\", \"boolean\", \"rawResponse\", \"pivot\", \"gchart\", \"leaflet\"],\n\n /**\n\t * Draw the output selector widget\n\t *\n\t * @property drawOutputSelector\n\t * @type boolean\n\t * @default true\n\t */\n drawOutputSelector: true,\n\n /**\n\t * Draw download icon. This issues html5 download functionality to 'download' files created on the client-side.\n\t * This allows the user to download results already queried for, such as a CSV when a table is shown, or the original response when the raw response output is selected\n\t *\n\t * @property drawDownloadIcon\n\t * @type boolean\n\t * @default true\n\t */\n drawDownloadIcon: true,\n /**\n\t * Open links (anchor tags) of SPARQL results in a new browser tab/window (_blank), or the current one (_self)\n\t *\n\t * @property uriTarget\n\t * @type string ('_blank' | '_self')\n\t * @default '_blank'\n\t */\n uriTarget: \"_blank\",\n onQuotaExceeded: function(e) {\n //fail silently\n console.warn(\"Could not store in localstorage. Skipping..\", e);\n },\n getUsedPrefixes: null,\n /**\n\t * Make certain settings and values of YASR persistent. Setting a key\n\t * to null, will disable persistancy: nothing is stored between browser\n\t * sessions Setting the values to a string (or a function which returns a\n\t * string), will store the query in localstorage using the specified string.\n\t * By default, the ID is dynamically generated by finding the nearest DOM element with an \"id\" set,\n\t * to avoid collissions when using multiple YASR items on one page\n\t *\n\t * @property persistency\n\t * @type object\n\t */\n persistency: {\n prefix: function(yasr) {\n return \"yasr_\" + $(yasr.container).closest(\"[id]\").attr(\"id\") + \"_\";\n },\n /**\n\t\t * Persistency setting for the selected output\n\t\t *\n\t\t * @property persistency.outputSelector\n\t\t * @type string|function\n\t\t * @default function (determine unique id)\n\t\t */\n outputSelector: function(yasr) {\n return \"selector\";\n },\n /**\n\t\t * Persistency setting for query results.\n\t\t *\n\t\t * @property persistency.results\n\t\t * @type object\n\t\t */\n results: {\n /**\n\t\t\t * Get the key to store results in\n\t\t\t *\n\t\t\t * @property persistency.results.id\n\t\t\t * @type string|function\n\t\t\t * @default function (determine unique id)\n\t\t\t */\n id: function(yasr) {\n return \"results_\" + $(yasr.container).closest(\"[id]\").attr(\"id\");\n },\n key: \"results\",\n /**\n\t\t\t * The result set might too large to fit in local storage.\n\t\t\t * It is impossible to detect how large the local storage is.\n\t\t\t * Therefore, we do not store all results in local storage, depending on a max number of characters in the SPARQL result serialization.\n\t\t\t * Set this function conservitavely. (especially when using multiple YASR instances on one page)\n\t\t\t *\n\t\t\t * @property persistency.results.maxSize\n\t\t\t * @type int\n\t\t\t * @default 100000\n\t\t\t */\n maxSize: 100000 //char count\n }\n }\n};\n", @@ -380,7 +380,7 @@ "\"use strict\";\nmodule.exports = {\n cross: '\t',\n check: '',\n unsorted: '',\n sortDesc: '',\n sortAsc: '',\n download: '\t',\n move: 'image/svg+xml',\n fullscreen: 'image/svg+xml',\n smallscreen: 'image/svg+xml'\n};\n", "require(\"./tableToCsv.js\");\n", "\"use strict\";\nvar $ = require(\"jquery\");\n\n$.fn.tableToCsv = function(config) {\n var csvString = \"\";\n config = $.extend(\n {\n quote: '\"',\n delimiter: \",\",\n lineBreak: \"\\n\"\n },\n config\n );\n\n var needToQuoteString = function(value) {\n //quote when it contains whitespace or the delimiter\n var needQuoting = false;\n if (value.match(\"[\\\\w|\" + config.delimiter + \"|\" + config.quote + \"]\")) {\n needQuoting = true;\n }\n return needQuoting;\n };\n var addValueToString = function(value) {\n //Quotes in the string need to be escaped\n value.replace(config.quote, config.quote + config.quote);\n if (needToQuoteString(value)) {\n value = config.quote + value + config.quote;\n }\n csvString += \" \" + value + \" \" + config.delimiter;\n };\n\n var addRowToString = function(rowArray) {\n rowArray.forEach(function(val) {\n addValueToString(val);\n });\n csvString += config.lineBreak;\n };\n\n var tableArrays = [];\n var $el = $(this);\n var rowspans = {};\n\n var totalColCount = 0;\n $el.find(\"tr:first *\").each(function() {\n if ($(this).attr(\"colspan\")) {\n totalColCount += +$(this).attr(\"colspan\");\n } else {\n totalColCount++;\n }\n });\n\n $el.find(\"tr\").each(function(rowId, tr) {\n var $tr = $(tr);\n var rowArray = [];\n\n var htmlColId = 0;\n var actualColId = 0;\n while (actualColId < totalColCount) {\n if (rowspans[actualColId]) {\n rowArray.push(rowspans[actualColId].text);\n rowspans[actualColId].rowSpan--;\n if (!rowspans[actualColId].rowSpan) rowspans[actualColId] = null;\n actualColId++;\n continue;\n }\n\n var $cell = $tr.find(\":nth-child(\" + (htmlColId + 1) + \")\");\n if (!$cell) break;\n var colspan = $cell.attr(\"colspan\") || 1;\n var rowspan = $cell.attr(\"rowspan\") || 1;\n\n for (var i = 0; i < colspan; i++) {\n rowArray.push($cell.text());\n if (rowspan > 1) {\n rowspans[actualColId] = {\n rowSpan: rowspan - 1,\n text: $cell.text()\n };\n }\n actualColId++;\n }\n htmlColId++;\n }\n addRowToString(rowArray);\n });\n\n return csvString;\n};\n", - "\"use strict\";\nvar $ = require(\"jquery\");\n\nvar LibColor = require(\"color\");\n\nvar colormap = require('colormap');\nvar colorScales = require('colormap/colorScale')\nfunction getWicket() {\n if (!global.Wkt) global.Wkt = require(\"wicket/wicket\");\n require(\"wicket/wicket-leaflet\");\n return new Wkt.Wkt();\n}\nvar root = (module.exports = function(yasr) {\n var plugin = {};\n var options = $.extend(true, {}, root.defaults);\n var defaultColor = LibColor(options.defaultColor);\n var defaultStyle = options.defaultStyle;\n\n var cm = null;\n\n var getOption = function(key) {\n // if (!options[key]) return {};\n if (options[key]) {\n if (typeof options[key] === \"function\") {\n return options[key](yasr, L);\n } else {\n return options[key];\n }\n } else {\n return undefined;\n }\n };\n\n\n var getSvgMarker = function(Colors) {\n var fillColor2 = Colors.fill.lighten(0.3).toString();\n var borderColor2 = Colors.border.lighten(0.3).toString();\n var fillId=''+Math.random();\n return (\n ''\n );\n };\n var draw = function() {\n var _L = options.L;\n require(\"proj4\");\n require(\"proj4leaflet\");\n //Ugly... need to set this global, as wicket-leaflet tries to access this global variable\n\n var zoomToEl = function(e) {\n map.setView(e.latlng, 15);\n };\n var plotVariables = getGeoVariables();\n if (plotVariables.length === 0)\n return $('
Nothing to draw
').appendTo(yasr.resultsContainer);\n var mapWrapper = $('
').appendTo(yasr.resultsContainer);\n var mapConstructor = options.map;\n if (!mapConstructor) mapConstructor = options.maps[options.defaultMap || \"osm\"];\n if (!mapConstructor) {\n console.error('Could not find leaflet configuration for map ' + options.defaultMap);\n return;\n }\n var map = new _L.Map(mapWrapper.get()[0], mapConstructor(yasr, L));\n\n var mapLayers = options.defaultOverlay;\n if(mapLayers) _L.control.layers(null, mapLayers).addTo(map);\n\n if (options.clickBeforeInteract) {\n map.scrollWheelZoom.disable();\n map.on('focus', function() { map.scrollWheelZoom.enable(); });\n map.on('blur', function() { map.scrollWheelZoom.disable(); });\n }\n var features = [];\n var bindings = yasr.results.getBindings();\n var hasLabel = false;\n for (var varId = 0; varId < plotVariables.length; varId++) {\n var plotVariable = plotVariables[varId];\n\n for (var i = 0; i < bindings.length; i++) {\n var binding = bindings[i];\n if (!binding[plotVariable].value) continue;\n\n var getColor = function() {\n var colorBinding = binding[plotVariable + \"Color\"];\n if (colorBinding) {\n var colorVal = colorBinding.value;\n var scaleSettings = colorVal.split(',');\n if (scaleSettings.length === 2 && colorScales[scaleSettings[0]] && scaleSettings[1]) {\n var scaleType = scaleSettings[0];\n var scaleVal = +scaleSettings[1];\n if (scaleVal >= 0 && scaleVal <= 1) {\n var scalesForType = colormap({colormap: scaleType});\n var index = Math.max(Math.round(scaleVal * scalesForType.length) -1, 0);\n return LibColor(scalesForType[index]);\n }\n }\n try {\n return LibColor(colorVal);\n } catch(e) {\n //invalid color representation\n return LibColor('grey')\n }\n }\n return defaultColor;\n };\n var Colors = {\n fill: getColor()\n };\n Colors.border = Colors.fill.saturate(0.2);\n var wicket = getWicket();\n var mySVGIcon = _L.divIcon({\n iconSize: [25, 41],\n // shadowSize: [25, 45],\n iconAnchor: [12, 41],\n popupAnchor: [0, -41],\n html: getSvgMarker(Colors)\n });\n\n\n var style = $.extend({}, defaultStyle, { icon: mySVGIcon, color: Colors.fill.toString()})\n var feature;\n try {\n feature = wicket.read(binding[plotVariable].value).toObject(style);\n } catch(e) {\n console.error('Failed to read WKT value: ' + binding[plotVariable].value)\n continue;\n }\n\n var popupContent = options.formatPopup && options.formatPopup(yasr, L, plotVariable, binding);\n if (popupContent) {\n function addPopupAndEventsToMarker(el) {\n el.on(\"dblclick\", zoomToEl);\n var popupContent = options.formatPopup && options.formatPopup(yasr, L, plotVariable, binding);\n if (popupContent) {\n hasLabel = true;\n el.bindPopup(popupContent);\n }\n }\n\n var markerPos;\n if (feature.getBounds) {\n //get center of polygon or something\n markerPos = feature.getBounds().getCenter();\n } else if (feature.getLatLng) {\n //its a point, just get the lat/lng\n markerPos = feature.getLatLng();\n }\n if (markerPos) {\n var shouldDrawSeparateMarker = !!feature.getBounds; //a lat/lng is already a marker\n if (shouldDrawSeparateMarker) {\n addPopupAndEventsToMarker(_L.marker(markerPos, { icon: mySVGIcon }).addTo(map));\n } else {\n addPopupAndEventsToMarker(feature);\n }\n }\n }\n features.push(feature);\n }\n }\n if (features.length) {\n try {\n var group = new _L.featureGroup(features).addTo(map);\n map.fitBounds(group.getBounds());\n } catch(e) {\n //This is a strange issue. Depending on which leaflet instance was used (i.e. the window.L one, or the required one)\n \t//we might run into issues where the returned bounds are undefined...\n \t//solved it by simply preferring the global instance (though this can be turned off)\n throw e;\n }\n }\n\n // missingPopupMsg: function(yasr, L, geoVariables, bindings) {\n if (!hasLabel && options.missingPopupMsg) {\n var msg = null;\n if (typeof options.missingPopupMsg === \"string\") {\n msg = options.missingPopupMsg;\n } else if (typeof options.missingPopupMsg === \"function\") {\n msg = options.missingPopupMsg(yasr, L, plotVariables);\n }\n if (msg) yasr.resultsContainer.prepend(msg);\n }\n };\n\n var geoKeywords = [\"POINT\", \"POLYGON\", \"LINESTRING\", \"MULTIPOINT\", \"MULTILINESTRING\", \"MULTIPOLYGON\"];\n var valueIsGeometric = function(val) {\n val = val.trim().toUpperCase();\n for (var i = 0; i < geoKeywords.length; i++) {\n if (val.indexOf(geoKeywords[i]) === 0) {\n try {\n getWicket().read(val)\n } catch(e) {\n console.error('Failed to parse WKT value ' + val)\n continue;\n }\n return true;\n }\n }\n return false;\n };\n var getGeoVariables = function() {\n if (!yasr.results) return [];\n var bindings = yasr.results.getBindings();\n if (!bindings || bindings.length === 0) {\n return [];\n }\n var geoVars = [];\n var checkedVars = [];\n for (var i = 0; i < bindings.length; i++) {\n //we'd like to have checked at least 1 value for all variables. So keep looping\n //in case the first row does not contain values for all bound vars (e.g. optional)\n var binding = bindings[i];\n for (var bindingVar in binding) {\n if (checkedVars.indexOf(bindingVar) === -1 && binding[bindingVar].value) {\n checkedVars.push(bindingVar);\n if (valueIsGeometric(binding[bindingVar].value)) geoVars.push(bindingVar);\n }\n }\n if (checkedVars.length === yasr.results.getVariables().length) {\n //checked all vars. can break now\n break;\n }\n }\n return geoVars;\n };\n var canHandleResults = function() {\n return getGeoVariables().length > 0;\n };\n\n return {\n draw: draw,\n name: \"Geo\",\n canHandleResults: canHandleResults,\n getPriority: 2\n };\n});\n\nvar maps = {\n osm: function(yasr, L) {\n //use protocol relative req when served via http. Otherwise, just use http:// (e.g. when yasr is served via file://)\n var protocol = window.location.protocol.indexOf(\"http\") === 0 ? \"//\" : \"http://\";\n return {\n layers: [\n new L.tileLayer(protocol + \"tile.openstreetmap.org/{z}/{x}/{y}.png\", {\n attribution: '© OpenStreetMap contributors'\n })\n ]\n };\n },\n nlmaps: function(yasr, L) {\n var res = [3440.64, 1720.32, 860.16, 430.08, 215.04, 107.52, 53.76, 26.88, 13.44, 6.72, 3.36, 1.68, 0.84, 0.42];\n var scales = [];\n res.forEach(function(res) {\n scales.push(1 / res);\n });\n\n var k = new L.Proj\n .CRS(\n \"EPSG:28992\",\n \"+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +units=m +towgs84=565.2369,50.0087,465.658,-0.406857330322398,0.350732676542563,-1.8703473836068,4.0812 +no_defs\",\n {\n transformation: new L.Transformation(1, 285401.92, -1, 903401.92),\n scales: scales,\n bounds: new L.bounds([-285401.92, 22598.08], [595401.9199999999, 903401.9199999999])\n }\n );\n return {\n crs: k,\n layers: [\n new L.tileLayer.wms(\"http://geodata.nationaalgeoregister.nl/tms/1.0.0/brtachtergrondkaart/{z}/{x}/{y}.png\", {\n minZoom: 1,\n maxZoom: 13,\n tms: true\n })\n ]\n };\n },\n /* free only up to 25'000 megapixels/year see https://shop.swisstopo.admin.ch/en/products/geoservice/swisstopo_geoservices/WMTS_info for further informations */\n chmaps: function(yasr, L) {\n var url = 'https://wmts10.geo.admin.ch/1.0.0/ch.swisstopo.pixelkarte-farbe/default/current/3857/{z}/{x}/{y}.jpeg';\n var stopoAttr = 'Map data © swisstopo , ';\n var tilelayer = new L.tileLayer(url,{id: 'stopo.light', attribution: stopoAttr, minZoom: 4, maxZoom: 19});\n\n return {\n layers: [tilelayer] ,\n crs: L.CRS.EPSG3857,\n continuousWorld: true,\n worldCopyJump: false\n };\n }\n};\nroot.defaults = {\n maps: maps,\n L: window.L || require('leaflet'),\n formatPopup: function(yasr, L, forVariable, bindings) {\n var binding = bindings[forVariable+\"Label\"];\n if (binding && binding.value) {\n if (binding.type === 'uri') {\n //format as link\n return '' + binding.value + ''\n } else {\n return binding.value;\n }\n }\n },\n missingPopupMsg: function(yasr, L, geoVariables) {\n if (geoVariables && geoVariables.length) {\n return (\n \"Tip: Add a label variable prefixed with the geo variable name to show popups on the map. E.g. \" +\n geoVariables[0] +\n \"Label. Or, append Color to change the color of the shape or marker.\"\n );\n }\n },\n disabledTitle: \"Query for geo variables in WKT format to plot them on a map\",\n defaultColor: \"#2e6c97\",\n clickBeforeInteract: false,\n defaultStyle: {},\n defaultOverlay: null,\n defaultMap: \"osm\" //or nlmaps\n};\n\nroot.version = {\n leaflet: root.defaults.L.version\n};\n", + "\"use strict\";\nvar $ = require(\"jquery\");\n\nvar LibColor = require(\"color\");\n\nvar colormap = require('colormap');\nvar colorScales = require('colormap/colorScale')\nfunction getWicket() {\n global.Wkt = require(\"wicket/wicket\");\n require(\"wicket/wicket-leaflet\");\n return new Wkt.Wkt();\n}\nvar root = (module.exports = function(yasr) {\n var plugin = {};\n var options = $.extend(true, {}, root.defaults);\n var defaultColor = LibColor(options.defaultColor);\n var defaultStyle = options.defaultStyle;\n\n var cm = null;\n\n var getOption = function(key) {\n // if (!options[key]) return {};\n if (options[key]) {\n if (typeof options[key] === \"function\") {\n return options[key](yasr, L);\n } else {\n return options[key];\n }\n } else {\n return undefined;\n }\n };\n\n\n var getSvgMarker = function(Colors) {\n var fillColor2 = Colors.fill.lighten(0.3).toString();\n var borderColor2 = Colors.border.lighten(0.3).toString();\n var fillId=''+Math.random();\n return (\n ''\n );\n };\n var draw = function() {\n var _L = options.L;\n require(\"proj4\");\n require(\"proj4leaflet\");\n //Ugly... need to set this global, as wicket-leaflet tries to access this global variable\n\n var zoomToEl = function(e) {\n map.setView(e.latlng, 15);\n };\n var plotVariables = getGeoVariables();\n if (plotVariables.length === 0)\n return $('
Nothing to draw
').appendTo(yasr.resultsContainer);\n var mapWrapper = $('
').appendTo(yasr.resultsContainer);\n var mapConstructor = options.map;\n if (!mapConstructor) mapConstructor = options.maps[options.defaultMap || \"osm\"];\n if (!mapConstructor) {\n console.error('Could not find leaflet configuration for map ' + options.defaultMap);\n return;\n }\n var map = new _L.Map(mapWrapper.get()[0], mapConstructor(yasr, L));\n\n var mapLayers = options.defaultOverlay;\n if(mapLayers) _L.control.layers(null, mapLayers).addTo(map);\n\n if (options.clickBeforeInteract) {\n map.scrollWheelZoom.disable();\n map.on('focus', function() { map.scrollWheelZoom.enable(); });\n map.on('blur', function() { map.scrollWheelZoom.disable(); });\n }\n var features = [];\n var bindings = yasr.results.getBindings();\n var hasLabel = false;\n for (var varId = 0; varId < plotVariables.length; varId++) {\n var plotVariable = plotVariables[varId];\n\n for (var i = 0; i < bindings.length; i++) {\n var binding = bindings[i];\n if (! binding[plotVariable] || !binding[plotVariable].value) continue;\n\n var getColor = function() {\n var colorBinding = binding[plotVariable + \"Color\"];\n if (colorBinding) {\n var colorVal = colorBinding.value;\n var scaleSettings = colorVal.split(',');\n if (scaleSettings.length === 2 && colorScales[scaleSettings[0]] && scaleSettings[1]) {\n var scaleType = scaleSettings[0];\n var scaleVal = +scaleSettings[1];\n if (scaleVal >= 0 && scaleVal <= 1) {\n var scalesForType = colormap({colormap: scaleType});\n var index = Math.max(Math.round(scaleVal * scalesForType.length) -1, 0);\n return LibColor(scalesForType[index]);\n }\n }\n try {\n return LibColor(colorVal);\n } catch(e) {\n //invalid color representation\n return LibColor('grey')\n }\n }\n return defaultColor;\n };\n var Colors = {\n fill: getColor()\n };\n Colors.border = Colors.fill.saturate(0.2);\n var wicket = getWicket();\n var mySVGIcon = _L.divIcon({\n iconSize: [25, 41],\n // shadowSize: [25, 45],\n iconAnchor: [12, 41],\n popupAnchor: [0, -41],\n html: getSvgMarker(Colors)\n });\n\n\n var style = $.extend({}, defaultStyle, { icon: mySVGIcon, color: Colors.fill.toString()})\n var feature;\n try {\n feature = wicket.read(binding[plotVariable].value).toObject(style);\n } catch(e) {\n console.error('Failed to read WKT value: ' + binding[plotVariable].value)\n continue;\n }\n\n var popupContent = options.formatPopup && options.formatPopup(yasr, L, plotVariable, binding);\n if (popupContent) {\n function addPopupAndEventsToMarker(el) {\n el.on(\"dblclick\", zoomToEl);\n var popupContent = options.formatPopup && options.formatPopup(yasr, L, plotVariable, binding);\n if (popupContent) {\n hasLabel = true;\n el.bindPopup(popupContent);\n }\n }\n\n var markerPos;\n if (feature.getBounds) {\n //get center of polygon or something\n markerPos = feature.getBounds().getCenter();\n } else if (feature.getLatLng) {\n //its a point, just get the lat/lng\n markerPos = feature.getLatLng();\n }\n if (markerPos) {\n var shouldDrawSeparateMarker = !!feature.getBounds; //a lat/lng is already a marker\n if (shouldDrawSeparateMarker) {\n addPopupAndEventsToMarker(_L.marker(markerPos, { icon: mySVGIcon }).addTo(map));\n } else {\n addPopupAndEventsToMarker(feature);\n }\n }\n }\n features.push(feature);\n }\n }\n if (features.length) {\n try {\n var group = new _L.featureGroup(features).addTo(map);\n map.fitBounds(group.getBounds());\n } catch(e) {\n //This is a strange issue. Depending on which leaflet instance was used (i.e. the window.L one, or the required one)\n \t//we might run into issues where the returned bounds are undefined...\n \t//solved it by simply preferring the global instance (though this can be turned off)\n throw e;\n }\n }\n\n // missingPopupMsg: function(yasr, L, geoVariables, bindings) {\n if (!hasLabel && options.missingPopupMsg) {\n var msg = null;\n if (typeof options.missingPopupMsg === \"string\") {\n msg = options.missingPopupMsg;\n } else if (typeof options.missingPopupMsg === \"function\") {\n msg = options.missingPopupMsg(yasr, L, plotVariables);\n }\n if (msg) yasr.resultsContainer.prepend(msg);\n }\n };\n\n var geoKeywords = [\"POINT\", \"POLYGON\", \"LINESTRING\", \"MULTIPOINT\", \"MULTILINESTRING\", \"MULTIPOLYGON\"];\n var valueIsGeometric = function(val) {\n val = val.trim().toUpperCase();\n for (var i = 0; i < geoKeywords.length; i++) {\n if (val.indexOf(geoKeywords[i]) === 0) {\n try {\n getWicket().read(val)\n } catch(e) {\n console.error('Failed to parse WKT value ' + val)\n continue;\n }\n return true;\n }\n }\n return false;\n };\n var getGeoVariables = function() {\n if (!yasr.results) return [];\n var bindings = yasr.results.getBindings();\n if (!bindings || bindings.length === 0) {\n return [];\n }\n var geoVars = [];\n var checkedVars = [];\n for (var i = 0; i < bindings.length; i++) {\n //we'd like to have checked at least 1 value for all variables. So keep looping\n //in case the first row does not contain values for all bound vars (e.g. optional)\n var binding = bindings[i];\n for (var bindingVar in binding) {\n if (checkedVars.indexOf(bindingVar) === -1 && binding[bindingVar].value) {\n checkedVars.push(bindingVar);\n if (valueIsGeometric(binding[bindingVar].value)) geoVars.push(bindingVar);\n }\n }\n if (checkedVars.length === yasr.results.getVariables().length) {\n //checked all vars. can break now\n break;\n }\n }\n return geoVars;\n };\n var canHandleResults = function() {\n return getGeoVariables().length > 0;\n };\n\n return {\n draw: draw,\n name: \"Geo\",\n canHandleResults: canHandleResults,\n getPriority: 2\n };\n});\n\nvar maps = {\n osm: function(yasr, L) {\n //use protocol relative req when served via http. Otherwise, just use http:// (e.g. when yasr is served via file://)\n var protocol = window.location.protocol.indexOf(\"http\") === 0 ? \"//\" : \"http://\";\n return {\n layers: [\n new L.tileLayer(protocol + \"tile.openstreetmap.org/{z}/{x}/{y}.png\", {\n attribution: '© OpenStreetMap contributors'\n })\n ]\n };\n },\n nlmaps: function(yasr, L) {\n var res = [3440.64, 1720.32, 860.16, 430.08, 215.04, 107.52, 53.76, 26.88, 13.44, 6.72, 3.36, 1.68, 0.84, 0.42];\n var scales = [];\n res.forEach(function(res) {\n scales.push(1 / res);\n });\n\n var k = new L.Proj\n .CRS(\n \"EPSG:28992\",\n \"+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +units=m +towgs84=565.2369,50.0087,465.658,-0.406857330322398,0.350732676542563,-1.8703473836068,4.0812 +no_defs\",\n {\n transformation: new L.Transformation(1, 285401.92, -1, 903401.92),\n scales: scales,\n bounds: new L.bounds([-285401.92, 22598.08], [595401.9199999999, 903401.9199999999])\n }\n );\n return {\n crs: k,\n layers: [\n new L.tileLayer.wms(\"http://geodata.nationaalgeoregister.nl/tms/1.0.0/brtachtergrondkaart/{z}/{x}/{y}.png\", {\n minZoom: 1,\n maxZoom: 13,\n tms: true\n })\n ]\n };\n },\n /* free only up to 25'000 megapixels/year see https://shop.swisstopo.admin.ch/en/products/geoservice/swisstopo_geoservices/WMTS_info for further informations */\n chmaps: function(yasr, L) {\n var url = 'https://wmts10.geo.admin.ch/1.0.0/ch.swisstopo.pixelkarte-farbe/default/current/3857/{z}/{x}/{y}.jpeg';\n var stopoAttr = 'Map data © swisstopo , ';\n var tilelayer = new L.tileLayer(url,{id: 'stopo.light', attribution: stopoAttr, minZoom: 4, maxZoom: 19});\n\n return {\n layers: [tilelayer] ,\n crs: L.CRS.EPSG3857,\n continuousWorld: true,\n worldCopyJump: false\n };\n }\n};\nroot.defaults = {\n maps: maps,\n L: require('leaflet'),\n formatPopup: function(yasr, L, forVariable, bindings) {\n var binding = bindings[forVariable+\"Label\"];\n if (binding && binding.value) {\n if (binding.type === 'uri') {\n //format as link\n return '' + binding.value + ''\n } else {\n return binding.value;\n }\n }\n },\n missingPopupMsg: function(yasr, L, geoVariables) {\n if (geoVariables && geoVariables.length) {\n return (\n \"Tip: Add a label variable prefixed with the geo variable name to show popups on the map. E.g. \" +\n geoVariables[0] +\n \"Label. Or, append Color to change the color of the shape or marker.\"\n );\n }\n },\n disabledTitle: \"Query for geo variables in WKT format to plot them on a map\",\n defaultColor: \"#2e6c97\",\n clickBeforeInteract: false,\n defaultStyle: {},\n defaultOverlay: null,\n defaultMap: \"osm\" //or nlmaps\n};\n\nroot.version = {\n leaflet: root.defaults.L.version\n};\n", "\"use strict\";\nvar $ = require(\"jquery\"), EventEmitter = require(\"events\").EventEmitter, utils = require(\"yasgui-utils\");\nconsole = console || {\n log: function() {}\n}; //make sure any console statements don't break in IE\n\nrequire(\"./jquery/extendJquery.js\");\n\n/**\n * Main YASR constructor\n *\n * @constructor\n * @param {DOM-Element} parent element to append editor to.\n * @param {object} settings\n * @class YASR\n * @return {doc} YASR document\n */\nvar YASR = function(parent, options, queryResults) {\n EventEmitter.call(this);\n var yasr = this;\n // console.log(EventEmitter.call(this));\n\n // var yasr = {};\n // EventEmitter.call(yasr);\n yasr.options = $.extend(true, {}, module.exports.defaults, options);\n //the recursive copy does merge (overwrite) array values how we want it to. Do this manually\n if (options && options.outputPlugins) yasr.options.outputPlugins = options.outputPlugins;\n\n yasr.container = $(\"
\").appendTo(parent);\n yasr.header = $(\"
\").appendTo(yasr.container);\n yasr.resultsContainer = $(\"
\").appendTo(yasr.container);\n yasr.storage = utils.storage;\n\n var prefix = null;\n yasr.getPersistencyId = function(postfix) {\n if (prefix === null) {\n //instantiate prefix\n if (yasr.options.persistency && yasr.options.persistency.prefix) {\n prefix = typeof yasr.options.persistency.prefix == \"string\"\n ? yasr.options.persistency.prefix\n : yasr.options.persistency.prefix(yasr);\n } else {\n prefix = false;\n }\n }\n if (prefix && postfix != null) {\n return prefix + (typeof postfix == \"string\" ? postfix : postfix(yasr));\n } else {\n return null;\n }\n };\n\n if (yasr.options.useGoogleCharts) {\n //pre-load google-loader\n require(\"./gChartLoader.js\")\n .once(\"initError\", function() {\n yasr.options.useGoogleCharts = false;\n })\n .init();\n }\n\n //first initialize plugins\n yasr.plugins = {};\n for (var pluginName in module.exports.plugins) {\n if (!yasr.options.useGoogleCharts && pluginName == \"gchart\") continue;\n yasr.plugins[pluginName] = new module.exports.plugins[pluginName](yasr);\n }\n\n yasr.updateHeader = function() {\n var downloadIcon = yasr.header.find(\".yasr_downloadIcon\").removeAttr(\"title\"); //and remove previous titles\n var embedButton = yasr.header.find(\".yasr_embedBtn\");\n var outputPlugin = yasr.plugins[yasr.options.output];\n if (outputPlugin) {\n //Manage download link\n var info = outputPlugin.getDownloadInfo ? outputPlugin.getDownloadInfo() : null;\n if (info) {\n if (info.buttonTitle) downloadIcon.attr(\"title\", info.buttonTitle);\n downloadIcon.prop(\"disabled\", false);\n downloadIcon.find(\"path\").each(function() {\n this.style.fill = \"black\";\n });\n } else {\n downloadIcon.prop(\"disabled\", true).prop(\"title\", \"Download not supported for this result representation\");\n downloadIcon.find(\"path\").each(function() {\n this.style.fill = \"gray\";\n });\n }\n\n //Manage embed button\n var link = null;\n if (outputPlugin.getEmbedHtml) link = outputPlugin.getEmbedHtml();\n if (link && link.length > 0) {\n embedButton.show();\n } else {\n embedButton.hide();\n }\n }\n };\n yasr.draw = function(output) {\n if (!yasr.results) return false;\n if (!output) output = yasr.options.output;\n\n //ah, our default output does not take our current results. Try to autodetect\n var selectedOutput = null;\n var selectedOutputPriority = -1;\n var unsupportedOutputs = [];\n for (var tryOutput in yasr.plugins) {\n if (yasr.plugins[tryOutput].canHandleResults(yasr)) {\n var priority = yasr.plugins[tryOutput].getPriority;\n if (typeof priority == \"function\") priority = priority(yasr);\n if (priority != null && priority != undefined && priority > selectedOutputPriority) {\n selectedOutputPriority = priority;\n selectedOutput = tryOutput;\n }\n } else {\n unsupportedOutputs.push(tryOutput);\n }\n }\n disableOutputs(unsupportedOutputs);\n var outputToDraw = null;\n if (output in yasr.plugins && yasr.plugins[output].canHandleResults(yasr)) {\n outputToDraw = output;\n } else if (selectedOutput) {\n outputToDraw = selectedOutput;\n }\n\n if (outputToDraw) {\n $(yasr.resultsContainer).empty();\n yasr.emit(\"draw\", yasr, yasr.plugins[outputToDraw]);\n yasr.plugins[outputToDraw].draw();\n yasr.emit(\"drawn\", yasr, yasr.plugins[outputToDraw]);\n yasr.updateHeader();\n return true;\n } else {\n yasr.updateHeader();\n return false;\n }\n };\n\n var disableOutputs = function(outputs) {\n //first enable everything.\n yasr.header.find(\".yasr_btnGroup .yasr_btn\").removeClass(\"disabled\");\n\n //now disable the outputs passed as param\n outputs.forEach(function(outputName) {\n var disabledTitle, disabledMsg;\n if (module.exports.plugins[outputName] && module.exports.plugins[outputName].defaults) {\n disabledTitle = module.exports.plugins[outputName].defaults.disabledTitle;\n }\n yasr.header.find(\".yasr_btnGroup .select_\" + outputName).addClass(\"disabled\").attr(\"title\", disabledTitle || \"\");\n });\n };\n yasr.somethingDrawn = function() {\n return !yasr.resultsContainer.is(\":empty\");\n };\n\n yasr.setResponse = function(dataOrJqXhr, textStatus, jqXhrOrErrorString) {\n try {\n yasr.results = require(\"./parsers/wrapper.js\")(dataOrJqXhr, textStatus, jqXhrOrErrorString);\n } catch (exception) {\n console.log(exception);\n yasr.results = {\n getException: function() {\n return exception;\n }\n };\n }\n yasr.draw();\n\n //store if needed\n var resultsId = yasr.getPersistencyId(yasr.options.persistency.results.key);\n if (resultsId) {\n if (\n !yasr.results.getException() &&\n yasr.results.getOriginalResponseAsString &&\n yasr.results.getOriginalResponseAsString().length < yasr.options.persistency.results.maxSize\n ) {\n utils.storage.set(resultsId, yasr.results.getAsStoreObject(), \"month\", yasr.options.onQuotaExceeded);\n } else {\n //remove old string\n utils.storage.remove(resultsId);\n }\n }\n };\n var $toggableWarning = null;\n var $toggableWarningClose = null;\n var $toggableWarningMsg = null;\n yasr.warn = function(warning) {\n if (!$toggableWarning) {\n //first time instantiation\n $toggableWarning = $(\"
\", {\n class: \"toggableWarning\"\n })\n .prependTo(yasr.container)\n .hide();\n $toggableWarningClose = $(\"\", {\n class: \"toggleWarning\"\n })\n .html(\"×\")\n .click(function() {\n $toggableWarning.hide(400);\n })\n .appendTo($toggableWarning);\n $toggableWarningMsg = $(\"\", {\n class: \"toggableMsg\"\n }).appendTo($toggableWarning);\n }\n $toggableWarningMsg.empty();\n if (warning instanceof $) {\n $toggableWarningMsg.append(warning);\n } else {\n $toggableWarningMsg.html(warning);\n }\n $toggableWarning.show(400);\n };\n\n var blobDownloadSupported = null;\n var checkBlobDownloadSupported = function() {\n if (blobDownloadSupported === null) {\n var windowUrl = window.URL || window.webkitURL || window.mozURL || window.msURL;\n blobDownloadSupported = windowUrl && Blob;\n }\n return blobDownloadSupported;\n };\n var embedBtn = null;\n var drawHeader = function(yasr) {\n var drawOutputSelector = function() {\n var btnGroup = $('
');\n $.each(yasr.options.outputPlugins, function(i, pluginName) {\n var plugin = yasr.plugins[pluginName];\n if (!plugin) return; //plugin not loaded\n\n if (plugin.hideFromSelection) return;\n var name = plugin.name || pluginName;\n var button = $(\"\")\n .text(name)\n .addClass(\"select_\" + pluginName)\n .click(function() {\n //update buttons\n btnGroup.find(\"button.selected\").removeClass(\"selected\");\n $(this).addClass(\"selected\");\n //set and draw output\n yasr.options.output = pluginName;\n\n //store if needed\n yasr.store();\n\n //close warning if there is any\n if ($toggableWarning) $toggableWarning.hide(400);\n\n yasr.draw();\n })\n .appendTo(btnGroup);\n if (yasr.options.output == pluginName) button.addClass(\"selected\");\n });\n\n if (btnGroup.children().length > 1) yasr.header.append(btnGroup);\n };\n var drawDownloadIcon = function() {\n var stringToUrl = function(string, contentType) {\n var url = null;\n var windowUrl = window.URL || window.webkitURL || window.mozURL || window.msURL;\n if (windowUrl && Blob) {\n var blob = new Blob([string], {\n type: contentType\n });\n url = windowUrl.createObjectURL(blob);\n }\n return url;\n };\n var button = $(\"\")\n .append(require(\"yasgui-utils\").svg.getElement(require(\"./imgs.js\").download))\n .click(function() {\n var currentPlugin = yasr.plugins[yasr.options.output];\n if (currentPlugin && currentPlugin.getDownloadInfo) {\n var downloadInfo = currentPlugin.getDownloadInfo();\n var downloadUrl = stringToUrl(\n downloadInfo.getContent(),\n downloadInfo.contentType ? downloadInfo.contentType : \"text/plain\"\n );\n var downloadMockLink = $(\"\", {\n href: downloadUrl,\n download: downloadInfo.filename\n });\n require(\"./utils.js\").fireClick(downloadMockLink);\n //\t\t\t\t\t\tdownloadMockLink[0].click();\n }\n });\n yasr.header.append(button);\n };\n var drawFullscreenButton = function() {\n var button = $(\"\")\n .append(require(\"yasgui-utils\").svg.getElement(require(\"./imgs.js\").fullscreen))\n .click(function() {\n yasr.container.addClass(\"yasr_fullscreen\");\n });\n yasr.header.append(button);\n };\n var drawSmallscreenButton = function() {\n var button = $(\"\")\n .append(require(\"yasgui-utils\").svg.getElement(require(\"./imgs.js\").smallscreen))\n .click(function() {\n yasr.container.removeClass(\"yasr_fullscreen\");\n });\n yasr.header.append(button);\n };\n var drawEmbedButton = function() {\n embedBtn = $(\"\")\n .text(name)\n .addClass(\"select_\" + pluginName)\n .click(function() {\n //update buttons\n btnGroup.find(\"button.selected\").removeClass(\"selected\");\n $(this).addClass(\"selected\");\n //set and draw output\n yasr.options.output = pluginName;\n\n //store if needed\n yasr.store();\n\n //close warning if there is any\n if ($toggableWarning) $toggableWarning.hide(400);\n\n yasr.draw();\n })\n .appendTo(btnGroup);\n if (yasr.options.output == pluginName) button.addClass(\"selected\");\n });\n\n if (btnGroup.children().length > 1) yasr.header.append(btnGroup);\n };\n var drawDownloadIcon = function() {\n var stringToUrl = function(string, contentType) {\n var url = null;\n var windowUrl = window.URL || window.webkitURL || window.mozURL || window.msURL;\n if (windowUrl && Blob) {\n var blob = new Blob([string], {\n type: contentType\n });\n url = windowUrl.createObjectURL(blob);\n }\n return url;\n };\n var button = $(\"\")\n .append(require(\"yasgui-utils\").svg.getElement(require(\"./imgs.js\").download))\n .click(function() {\n var currentPlugin = yasr.plugins[yasr.options.output];\n if (currentPlugin && currentPlugin.getDownloadInfo) {\n var downloadInfo = currentPlugin.getDownloadInfo();\n var downloadUrl = stringToUrl(\n downloadInfo.getContent(),\n downloadInfo.contentType ? downloadInfo.contentType : \"text/plain\"\n );\n var downloadMockLink = $(\"\", {\n href: downloadUrl,\n download: downloadInfo.filename\n });\n require(\"./utils.js\").fireClick(downloadMockLink);\n //\t\t\t\t\t\tdownloadMockLink[0].click();\n }\n });\n yasr.header.append(button);\n };\n var drawFullscreenButton = function() {\n var button = $(\"\")\n .append(require(\"yasgui-utils\").svg.getElement(require(\"./imgs.js\").fullscreen))\n .click(function() {\n yasr.container.addClass(\"yasr_fullscreen\");\n });\n yasr.header.append(button);\n };\n var drawSmallscreenButton = function() {\n var button = $(\"\")\n .append(require(\"yasgui-utils\").svg.getElement(require(\"./imgs.js\").smallscreen))\n .click(function() {\n yasr.container.removeClass(\"yasr_fullscreen\");\n });\n yasr.header.append(button);\n };\n var drawEmbedButton = function() {\n embedBtn = $(\"\")\n .text(name)\n .addClass(\"select_\" + pluginName)\n .click(function() {\n //update buttons\n btnGroup.find(\"button.selected\").removeClass(\"selected\");\n $(this).addClass(\"selected\");\n //set and draw output\n yasr.options.output = pluginName;\n\n //store if needed\n yasr.store();\n\n //close warning if there is any\n if ($toggableWarning) $toggableWarning.hide(400);\n\n yasr.draw();\n })\n .appendTo(btnGroup);\n if (yasr.options.output == pluginName) button.addClass(\"selected\");\n });\n\n if (btnGroup.children().length > 1) yasr.header.append(btnGroup);\n };\n var drawDownloadIcon = function() {\n var stringToUrl = function(string, contentType) {\n var url = null;\n var windowUrl = window.URL || window.webkitURL || window.mozURL || window.msURL;\n if (windowUrl && Blob) {\n var blob = new Blob([string], {\n type: contentType\n });\n url = windowUrl.createObjectURL(blob);\n }\n return url;\n };\n var button = $(\"\")\n .append(require(\"yasgui-utils\").svg.getElement(require(\"./imgs.js\").download))\n .click(function() {\n var currentPlugin = yasr.plugins[yasr.options.output];\n if (currentPlugin && currentPlugin.getDownloadInfo) {\n var downloadInfo = currentPlugin.getDownloadInfo();\n var downloadUrl = stringToUrl(\n downloadInfo.getContent(),\n downloadInfo.contentType ? downloadInfo.contentType : \"text/plain\"\n );\n var downloadMockLink = $(\"\", {\n href: downloadUrl,\n download: downloadInfo.filename\n });\n require(\"./utils.js\").fireClick(downloadMockLink);\n //\t\t\t\t\t\tdownloadMockLink[0].click();\n }\n });\n yasr.header.append(button);\n };\n var drawFullscreenButton = function() {\n var button = $(\"\")\n .append(require(\"yasgui-utils\").svg.getElement(require(\"./imgs.js\").fullscreen))\n .click(function() {\n yasr.container.addClass(\"yasr_fullscreen\");\n });\n yasr.header.append(button);\n };\n var drawSmallscreenButton = function() {\n var button = $(\"\")\n .append(require(\"yasgui-utils\").svg.getElement(require(\"./imgs.js\").smallscreen))\n .click(function() {\n yasr.container.removeClass(\"yasr_fullscreen\");\n });\n yasr.header.append(button);\n };\n var drawEmbedButton = function() {\n embedBtn = $(\"\")\n .text(name)\n .addClass(\"select_\" + pluginName)\n .click(function() {\n //update buttons\n btnGroup.find(\"button.selected\").removeClass(\"selected\");\n $(this).addClass(\"selected\");\n //set and draw output\n yasr.options.output = pluginName;\n\n //store if needed\n yasr.store();\n\n //close warning if there is any\n if ($toggableWarning) $toggableWarning.hide(400);\n\n yasr.draw();\n })\n .appendTo(btnGroup);\n if (yasr.options.output == pluginName) button.addClass(\"selected\");\n });\n\n if (btnGroup.children().length > 1) yasr.header.append(btnGroup);\n };\n var drawDownloadIcon = function() {\n var stringToUrl = function(string, contentType) {\n var url = null;\n var windowUrl = window.URL || window.webkitURL || window.mozURL || window.msURL;\n if (windowUrl && Blob) {\n var blob = new Blob([string], {\n type: contentType\n });\n url = windowUrl.createObjectURL(blob);\n }\n return url;\n };\n var button = $(\"\")\n .append(require(\"yasgui-utils\").svg.getElement(require(\"./imgs.js\").download))\n .click(function() {\n var currentPlugin = yasr.plugins[yasr.options.output];\n if (currentPlugin && currentPlugin.getDownloadInfo) {\n var downloadInfo = currentPlugin.getDownloadInfo();\n var downloadUrl = stringToUrl(\n downloadInfo.getContent(),\n downloadInfo.contentType ? downloadInfo.contentType : \"text/plain\"\n );\n var downloadMockLink = $(\"\", {\n href: downloadUrl,\n download: downloadInfo.filename\n });\n require(\"./utils.js\").fireClick(downloadMockLink);\n //\t\t\t\t\t\tdownloadMockLink[0].click();\n }\n });\n yasr.header.append(button);\n };\n var drawFullscreenButton = function() {\n var button = $(\"\")\n .append(require(\"yasgui-utils\").svg.getElement(require(\"./imgs.js\").fullscreen))\n .click(function() {\n yasr.container.addClass(\"yasr_fullscreen\");\n });\n yasr.header.append(button);\n };\n var drawSmallscreenButton = function() {\n var button = $(\"\")\n .append(require(\"yasgui-utils\").svg.getElement(require(\"./imgs.js\").smallscreen))\n .click(function() {\n yasr.container.removeClass(\"yasr_fullscreen\");\n });\n yasr.header.append(button);\n };\n var drawEmbedButton = function() {\n embedBtn = $(\"\")\n .text(name)\n .addClass(\"select_\" + pluginName)\n .click(function() {\n //update buttons\n btnGroup.find(\"button.selected\").removeClass(\"selected\");\n $(this).addClass(\"selected\");\n //set and draw output\n yasr.options.output = pluginName;\n\n //store if needed\n yasr.store();\n\n //close warning if there is any\n if ($toggableWarning) $toggableWarning.hide(400);\n\n yasr.draw();\n })\n .appendTo(btnGroup);\n if (yasr.options.output == pluginName) button.addClass(\"selected\");\n });\n\n if (btnGroup.children().length > 1) yasr.header.append(btnGroup);\n };\n var drawDownloadIcon = function() {\n var stringToUrl = function(string, contentType) {\n var url = null;\n var windowUrl = window.URL || window.webkitURL || window.mozURL || window.msURL;\n if (windowUrl && Blob) {\n var blob = new Blob([string], {\n type: contentType\n });\n url = windowUrl.createObjectURL(blob);\n }\n return url;\n };\n var button = $(\"\")\n .append(require(\"yasgui-utils\").svg.getElement(require(\"./imgs.js\").download))\n .click(function() {\n var currentPlugin = yasr.plugins[yasr.options.output];\n if (currentPlugin && currentPlugin.getDownloadInfo) {\n var downloadInfo = currentPlugin.getDownloadInfo();\n var downloadUrl = stringToUrl(\n downloadInfo.getContent(),\n downloadInfo.contentType ? downloadInfo.contentType : \"text/plain\"\n );\n var downloadMockLink = $(\"\", {\n href: downloadUrl,\n download: downloadInfo.filename\n });\n require(\"./utils.js\").fireClick(downloadMockLink);\n //\t\t\t\t\t\tdownloadMockLink[0].click();\n }\n });\n yasr.header.append(button);\n };\n var drawFullscreenButton = function() {\n var button = $(\"\")\n .append(require(\"yasgui-utils\").svg.getElement(require(\"./imgs.js\").fullscreen))\n .click(function() {\n yasr.container.addClass(\"yasr_fullscreen\");\n });\n yasr.header.append(button);\n };\n var drawSmallscreenButton = function() {\n var button = $(\"\")\n .append(require(\"yasgui-utils\").svg.getElement(require(\"./imgs.js\").smallscreen))\n .click(function() {\n yasr.container.removeClass(\"yasr_fullscreen\");\n });\n yasr.header.append(button);\n };\n var drawEmbedButton = function() {\n embedBtn = $(\"