UNPKG

sense-extension-recipes

Version:

Recipes on working with Qlik Sense Visualization Extensions.

58 lines (46 loc) 1.41 kB
define( [ 'jquery', 'underscore' ], function ( $ /*, _*/ ) { 'use strict'; // Taken from http://www.briangrinstead.com/blog/console-log-helper-function // Full version of `log` that: // * Prevents errors on console methods when no console present. // * Exposes a global 'log' function that preserves line numbering and formatting. (function () { var method; var noop = function () { }; var methods = [ 'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn' ]; var length = methods.length; var console = (window.console = window.console || {}); while (length--) { method = methods[length]; // Only stub undefined methods. if (!console[method]) { console[method] = noop; } } if (Function.prototype.bind) { window.log = Function.prototype.bind.call(console.log, console); } else { window.log = function() { Function.prototype.apply.call(console.log, console, arguments); }; } })(); return { /** * Add a style to the document's header. * @param cssContent (String) */ addStyleToHeader: function ( cssContent ) { $( "<style>" ).html( cssContent ).appendTo( "head" ); } }; } );