(config)
| 20 | } |
| 21 | })(typeof window !== "undefined" ? window : this, function (Raphael) { |
| 22 | const JustGage = function (config) { |
| 23 | const obj = this; |
| 24 | |
| 25 | obj.events = {}; |
| 26 | |
| 27 | // Helps in case developer wants to debug it. unobtrusive |
| 28 | if (isUndefined(config)) { |
| 29 | console.log("* justgage: Make sure to pass options to the constructor!"); |
| 30 | return false; |
| 31 | } |
| 32 | |
| 33 | if (!isUndefined(config.id)) { |
| 34 | obj.node = document.getElementById(config.id); |
| 35 | if (!obj.node) { |
| 36 | console.log("* justgage: No element with id : %s found", config.id); |
| 37 | return false; |
| 38 | } |
| 39 | } else if (!isUndefined(config.parentNode)) { |
| 40 | obj.node = config.parentNode; |
| 41 | } else { |
| 42 | console.log( |
| 43 | "* justgage: Make sure to pass the existing element id or parentNode to the constructor." |
| 44 | ); |
| 45 | return false; |
| 46 | } |
| 47 | |
| 48 | const dataset = obj.node.dataset ? obj.node.dataset : {}; |
| 49 | |
| 50 | // check for defaults |
| 51 | const defaults = !isUndefined(config.defaults) ? config.defaults : false; |
| 52 | if (defaults !== false) { |
| 53 | config = extend({}, config, defaults); |
| 54 | delete config.defaults; |
| 55 | } |
| 56 | |
| 57 | // configurable parameters |
| 58 | obj.config = { |
| 59 | // id : string |
| 60 | // this is container element id |
| 61 | id: config.id, |
| 62 | |
| 63 | // classId : string |
| 64 | // this is the class id utilize when generating styles |
| 65 | classId: uuid(), |
| 66 | |
| 67 | // value : float |
| 68 | // value gauge is showing |
| 69 | value: kvLookup("value", config, dataset, 0, "float"), |
| 70 | |
| 71 | // defaults : bool |
| 72 | // defaults parameter to use |
| 73 | defaults: kvLookup("defaults", config, dataset, 0, false), |
| 74 | |
| 75 | // parentNode : node object |
| 76 | // this is container element |
| 77 | parentNode: kvLookup("parentNode", config, dataset, null), |
| 78 | |
| 79 | // width : int |
nothing calls this directly
no test coverage detected