Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

parambox

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parambox - npm Package Compare versions

Comparing version 1.2.12 to 1.2.13

7

dist/paramBox-compiled.js

@@ -104,3 +104,3 @@ "use strict";

// get a unique ID for the box
this.boxId = "dragbox" + ($("." + this._boxClass).length + 1);
this.boxId = "dragbox" + ($('div[id*="dragbox"]').length + 1);

@@ -1153,2 +1153,7 @@ // html for creation

if (typeof options.options.title.text !== "undefined") {
options.options.title.display = false;
_this3.title = '<center><h5>' + options.options.title.text + '</h5></center>';
}
// Create chart

@@ -1155,0 +1160,0 @@ try {

@@ -85,3 +85,3 @@ /**

// get a unique ID for the box
this.boxId = "dragbox" + ($("." + this._boxClass).length + 1);
this.boxId = "dragbox" + ($('div[id*="dragbox"]').length + 1);

@@ -1026,2 +1026,7 @@ // html for creation

if (typeof options.options.title.text !== "undefined") {
options.options.title.display = false;
this.title = '<center><h5>' + options.options.title.text + '</h5></center>';
}
// Create chart

@@ -1028,0 +1033,0 @@ try {

2

dist/paramBox.min.js

@@ -1,1 +0,1 @@

"use strict";function _possibleConstructorReturn(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function mandatory(){var t=arguments.length<=0||void 0===arguments[0]?"":arguments[0];throw new Error("Missing parameter "+t)}function findAllIndices(){for(var t=arguments.length<=0||void 0===arguments[0]?mandatory():arguments[0],e=arguments.length<=1||void 0===arguments[1]?mandatory():arguments[1],n=[],o=0;o<e.length;o++)e.substr(o,t.length)===t&&n.push(o);return n.length?n:-1}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},_createClass=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),scripts=document.getElementsByTagName("script"),paramBoxFullpath=scripts[scripts.length-1].src,delimiterIndices=findAllIndices("/",paramBoxFullpath);paramBoxFullpath=paramBoxFullpath.substr(0,delimiterIndices[delimiterIndices.length-2]),document.addEventListener("DOMContentLoaded",function(t){var e=document.getElementsByTagName("head")[0],n=document.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=paramBoxFullpath+"/dist/paramBox.css",e.appendChild(n)});var DragBox=function(){function t(){var e=arguments.length<=0||void 0===arguments[0]?null:arguments[0],n=arguments.length<=1||void 0===arguments[1]?null:arguments[1],o=arguments.length<=2||void 0===arguments[2]?null:arguments[2];_classCallCheck(this,t),this.MAX_BINDED_PROPERTIES=15,this.INIT_WIDTH=n?n:400,this.INIT_HEIGHT=o?o:300,this.DEFAULT_BOX_CLASS="dragbox",this.DEFAULT_DRAGGABLE=!0,this.DEFAULT_STICKINESS_TYPE="magnetized",this.boxId=null,this.boxElement=e,this.draggable=this.DEFAULT_DRAGGABLE,this.boxHTML=null,this.shouldStick=null,this.shouldMagnetize=null,this.isStickingX=null,this.isStickingY=null,this.stickiness=this.DEFAULT_STICKINESS_TYPE,this._beingDragged=!1,this._visibility="hidden",this._overflow="hidden",this._boxClass=this.DEFAULT_BOX_CLASS,this._width=this.INIT_WIDTH,this._height=this.INIT_HEIGHT,this.map=[],this.currentMousePos={x:-1,y:-1};var i=this;$(document).mousemove(function(t){i.currentMousePos.x=t.pageX,i.currentMousePos.y=t.pageY}),this.boxElement?this.boxId=$(this.boxElement).attr("id"):(this.boxId="dragbox"+($("."+this._boxClass).length+1),this.boxHTML='<div id="'+this.boxId+'" class="'+this._boxClass+'" style="opacity:0.0;" draggable="true"><div class="col-xs-12 dragbox-container"><div class="col-xs-12 dragbox-title"><center><h3>Dragbox</h3></center></div><div class="col-xs-12 dragbox-content"></div><div class="col-xs-12 dragbox-footer"></div></div></div>',$(document.body).append(this.boxHTML),this.boxElement=$("#"+this.boxId)),this.boxClass=$(this.boxElement).attr("class"),this.width=this._width,this.height=this._height,this.overflow="hidden",$(document.body).keydown(function(t){i.keyfunction(t)}),$(document.body).keyup(function(t){i.keyfunction(t)}),$(this.boxElement).find(".dragbox-title").mousedown(function(t){i.startDrag(t)}),$(this.boxElement).find(".dragbox-title").mouseup(function(t){i.stopDrag(t)}),$(document).click(function(t){i.stopDrag(t)}),this.queryString=this.getQueryString()}return _createClass(t,[{key:"destroy",value:function(){var t=this;$(this.boxElement).animate({opacity:0},25,function(){$(t.boxElement).remove()})}},{key:"updateSize",value:function(){$(this.boxElement).width(this.width),$(this.boxElement).height(this.height);var t=this.height-$(this.boxElement).find(".dragbox-title").height()-$(this.boxElement).find(".dragbox-footer").height()-7,e=this;$(this.boxElement).animate({height:e.height,width:e.width},25,function(){}),$(this.boxElement).find(".dragbox-container").animate({height:e.height},25,function(){}),$(this.boxElement).find(".dragbox-content").animate({height:t},25,function(){})}},{key:"startDrag",value:function(t){if(t.preventDefault(),"true"==this.beingDragged)return void(this.beingDragged=!1);if(this.draggable){var e={x:t.clientX-$(this.boxElement).offset().left,y:t.clientY-$(this.boxElement).offset().top};return this.beingDragged=!0,this.loopDrag(e),!1}}},{key:"stopDrag",value:function(){this.beingDragged=!1}},{key:"loopDrag",value:function(t){if(this.beingDragged===!0){var e=this.currentMousePos.x-t.x,n=this.currentMousePos.y-t.y,o={offsetLeft:e,offsetTop:n,offsetWidth:$(this.boxElement).width(),offsetHeigth:$(this.boxElement).height()},i=ParamBox.stayInWindow(o),r=i.x,s=i.y;this.shouldStick&&(i.stickyX!=-2&&2!=i.stickyX||(this.isStickingX=!0),this.isStickingX&&0!==i.stickyX&&(r=i.leftSticky),0===i.stickyX&&(this.isStickingX=!1),i.stickyY!=-2&&2!=i.stickyY||(this.isStickingY=!0),this.isStickingY&&0!==i.stickyY&&(s=i.topSticky),0===i.stickyY&&(this.isStickingY=!1)),this.shouldMagnetize&&(r=i.leftSticky,s=i.topSticky);var a=this;return $(this.boxElement).animate({left:r,top:s},25,function(){a.loopDrag(t)}),!1}}},{key:"keyfunction",value:function(t){console.log("keyEvent dragbox method")}},{key:"toggle",value:function(){"hidden"==this.visibility?this.visibility="visible":this.visibility="hidden"}},{key:"show",value:function(){this.visibility="visible"}},{key:"hide",value:function(){this.visibility="hidden"}},{key:"append",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?".dragbox-content":arguments[1],n=arguments.length<=2||void 0===arguments[2]?null:arguments[2];this.boxElement&&(null!==n&&(t='<div class="'+n+'" >'+t+"</div>"),"container"!=e?this.boxElement.find(e).append(t):this.boxElement.append(t))}},{key:"html",value:function(){var t=arguments.length<=0||void 0===arguments[0]?".dragbox-content":arguments[0],e=arguments.length<=1||void 0===arguments[1]?null:arguments[1];if(this.boxElement){var n="container"!=t?this.boxElement.find(t):this.boxElement;if(null===e)return n.html();n.html(e)}}},{key:"getQueryString",value:function(){for(var t={},e=window.location.search.substring(1),n=e.split("&"),o=0;o<n.length;o++){var i=n[o].split("=");if("undefined"==typeof t[i[0]])t[i[0]]=decodeURIComponent(i[1]);else if("string"==typeof t[i[0]]){var r=[t[i[0]],decodeURIComponent(i[1])];t[i[0]]=r}else t[i[0]].push(decodeURIComponent(i[1]))}return t}},{key:"width",set:function(t){this._width=t,this.updateSize()},get:function(){return this._width}},{key:"height",set:function(t){this._height=t,this.updateSize()},get:function(){return this._height}},{key:"beingDragged",set:function(t){this._beingDragged=t,$(this.boxElement).attr("beingDragged",t)},get:function(){return this._beingDragged}},{key:"boxClass",set:function(t){if(this.boxElement){if("string"!=typeof t)throw new Error("newClass must be a string");var e=t.indexOf(" ");e!=-1&&(t=t.substr(0,e)),this.boxElement.removeClass(this.boxClass).addClass(t),this._boxClass=t}},get:function(){if(this.boxElement)return this._boxClass}},{key:"visibility",set:function(t){this._visibility=t,"visible"==t?$(this.boxElement).animate({opacity:1},150):$(this.boxElement).animate({opacity:0},150)},get:function(){return this._visibility}},{key:"overflow",set:function(t){this._overflow=t,$(this.boxElement).find(".dragbox-content").css("overflow-y",t)},get:function(){return this._overflow}},{key:"stickiness",get:function(){return this._stickiness},set:function(t){switch(t){case"none":this.shouldMagnetize=!1,this.shouldStick=!1,console.log("Parambox: stickiness set to none");break;case"glue":this.shouldStick=!0,this.shouldMagnetize=!1,console.log("stickiness set to glue");break;case"magnetized":this.shouldStick=!1,this.shouldMagnetize=!0,console.log("stickiness set to magnetized");break;default:throw new Error("this sticky type does not exist. Types are : none, glue, or magnetized.")}this._stickiness=t}},{key:"title",get:function(){this.boxElement&&$(this.boxElement).find(".dragbox-title").html()},set:function(t){this.boxElement&&($(this.boxElement).find(".dragbox-title").html(t),this.updateSize())}},{key:"content",set:function(t){this.boxElement&&(this.contentDiv.html(t),this.updateSize())},get:function(){if(this.boxElement)return this.contentDiv.html()}},{key:"contentDiv",get:function(){if(this.boxElement)return $(this.boxElement).find(".dragbox-content")}}],[{key:"stayInWindow",value:function(t){if("undefined"==typeof t)throw new Error("element is undefined");var e=.15,n=t.offsetLeft,o=t.offsetLeft+t.offsetWidth,i=t.offsetTop,r=t.offsetTop+t.offsetHeigth,s=window.innerWidth-t.offsetWidth,a=window.innerHeight-t.offsetHeigth;return{x:n<0?0:o>window.innerWidth?s:n,y:i<0?0:r>window.innerHeight?a:i,stickyX:n<=0?-2:n<=e*t.offsetWidth?-1:o>=window.innerWidth?2:o>=window.innerWidth-e*t.offsetWidth?1:0,stickyY:i<=0?-2:i<=e*t.offsetHeigth?-1:r>=window.innerHeight?2:r>=window.innerHeight-e*t.offsetHeigth?1:0,leftSticky:n<=0?0:n<=e*t.offsetWidth?0:o>=window.innerWidth?window.innerWidth-t.offsetWidth:o>=window.innerWidth-e*t.offsetWidth?window.innerWidth-t.offsetWidth:n,topSticky:i<=0?0:i<=e*t.offsetHeigth?0:r>=window.innerHeight?window.innerHeight-t.offsetHeigth:r>=window.innerHeight-e*t.offsetHeigth?window.innerHeight-t.offsetHeigth:i}}},{key:"getCoordinateInWindow",value:function(t){var e=t.offsetLeft,n=t.offsetLeft+t.offsetWidth,o=t.offsetTop,i=t.offsetTop+t.offsetHeigth,r=window.innerWidth-t.offsetWidth,s=window.innerHeight-t.offsetHeigth;return{left:e,right:n,top:o,bottom:i,maxLeft:r,maxTop:s}}},{key:"stickiness",get:function(){}},{key:"title",get:function(){}}]),t}(),SmartModal=function(t){function e(){var t=arguments.length<=0||void 0===arguments[0]?"across":arguments[0],n=arguments.length<=1||void 0===arguments[1]?null:arguments[1],o=arguments.length<=2||void 0===arguments[2]?"closebutton":arguments[2],i=arguments.length<=3||void 0===arguments[3]?null:arguments[3];_classCallCheck(this,e);var r=_possibleConstructorReturn(this,Object.getPrototypeOf(e).call(this,i));if(r.DEFAULT_BUTTON_ROW_HTML='<div class="col-xs-12 dragbox-row smartmodal-buttonrow"></div>',r.DEFAULT_BUTTON_HTML={closebutton:'<button type="button" class="btn btn-secondary dragbox-button smartmodal-closebutton">Close</button>',nextbutton:'<button type="button" class="btn btn-secondary dragbox-button smartmodal-nextbutton">Next</button>',blankbutton:'<button type="button" class="btn btn-secondary dragbox-button smartmodal-blankbutton"></button>',sendbutton:'<button type="button" class="btn btn-secondary dragbox-button smartmodal-sendbutton">Send</button>'},r.DEFAULT_FORMAT_TYPES={centralSmall:[.2,.4,.3],centralLarge:[.2,.7,.6],across:[.3,1,.4],overlay:[.1,.8,.8]},r.callback=n,r.draggable=!1,r.formatType=t,r.buttonRowHtml=r.DEFAULT_BUTTON_ROW_HTML,!(o in r.DEFAULT_BUTTON_HTML))throw new Error("buttonType invalid");r.buttonType=o,r.rows=[],r.title="<center><h5>Smart Modal</h5></center>",r.append(r.buttonRowHtml,".dragbox-footer"),r.append(r.DEFAULT_BUTTON_HTML[r.buttonType],".smartmodal-buttonrow"),r.button=$(r.boxElement).find(".smartmodal-"+r.buttonType),r.callAfterConstructor();var s=r;return $(window).resize(function(){s.updatePosition()}),$(r.button).click(function(){s.callThenDestroy()}),r}return _inherits(e,t),_createClass(e,[{key:"callAfterConstructor",value:function(){this.updatePosition(),this.updateSize(),this.show()}},{key:"callThenDestroy",value:function(){this.callback&&this.callback(),this.destroy()}},{key:"updatePosition",value:function(){var t=window.innerHeight,e=window.innerWidth,n=this.DEFAULT_FORMAT_TYPES[this.formatType],o=n[0]*t,i=e*(1-n[1])/2,r=e*n[1],s=t*n[2];return this.width=r,this.height=s,$(this.boxElement).animate({left:i,top:o},25,function(){}),!1}}]),e}(DragBox),ParamBox=function(t){function e(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0];_classCallCheck(this,e);var n=_possibleConstructorReturn(this,Object.getPrototypeOf(e).call(this,t));n.DEFAULT_ROW_HTML='<div class="col-md-12 dragbox-row paramboxtmprow"></div>',n.PARAMBOX_EMPTY_ROW_HTML='<div class="col-md-12 dragbox-row parambox-empty"><center>No parameters binded.</center></div>',n.DEFAULT_BUTTON_ROW_HTML='<div class="col-xs-12 dragbox-row parambox-buttonrow"></div>',n.DEFAULT_BUTTON_HTML={savebutton:'<button type="button" class="btn btn-secondary btn-block dragbox-button parambox-savebutton">Save</button>',importbutton:'<button type="button" class="btn btn-secondary btn-block dragbox-button parambox-importbutton">Import</button>',reloadbutton:'<button type="button" class="btn btn-secondary btn-block dragbox-button parambox-reloadbutton">Reload</button>'},n.append(n.DEFAULT_BUTTON_ROW_HTML,".dragbox-footer"),n.append(n.DEFAULT_BUTTON_HTML.savebutton,".parambox-buttonrow","col-xs-4"),n.append(n.DEFAULT_BUTTON_HTML.importbutton,".parambox-buttonrow","col-xs-4"),n.append(n.DEFAULT_BUTTON_HTML.reloadbutton,".parambox-buttonrow","col-xs-4");var o=n;return n.boxElement[0].getElementsByClassName("parambox-savebutton")[0].addEventListener("click",function(t){o.save(t)}),n.boxElement[0].getElementsByClassName("parambox-importbutton")[0].addEventListener("click",function(t){o.import(t)}),n.boxElement[0].getElementsByClassName("parambox-reloadbutton")[0].addEventListener("click",function(t){o.reloadAndImport(t)}),n.rowHtml=n.DEFAULT_ROW_HTML,n.rows=[],n.title='<h5><i class="fa fa-cog fa-1x"></i> Parameter Box</h5>',n.overflow="scroll","undefined"==typeof window.paramPrefixIncrement?window.paramPrefixIncrement=0:window.paramPrefixIncrement+=1,n.prefix="paramBox"+window.paramPrefixIncrement,n.updateSize(),n.refreshView(),n}return _inherits(e,t),_createClass(e,[{key:"bind",value:function(t,e){var n=arguments.length<=2||void 0===arguments[2]?null:arguments[2];if("undefined"==typeof t)throw new Error("object is undefined");var o=null;e.constructor!==Array&&(e=[e]);for(var i=0;i<e.length;i++){o=this.getDescendantProp(t,e[i]);var r=o[0],s=o[1],a=this.newRowInDom(),l=null,h=null;if("undefined"!=typeof this.queryString[s]&&(h=this.queryString[s]),null!==n&&"undefined"!=typeof n[e[i]]){var d=n[e[i]];if(null!==h){if(d.indexOf(h)===-1)throw new Error("ParamBox.bind: cannot set initial value to query string value of "+h+" because it is not in the constraints array.");r[s]=r[s].constructor(h)}var l=new BindedField(r,s,a,"selector",d)}if(!l)if(null!==h&&(r[s]=r[s].constructor(h)),r[s].constructor===Boolean)var l=new BindedField(r,s,a,"selector",["TRUE","FALSE"],h);else var l=new BindedField(r,s,a,"input",null,h);this.rows.push(this.getBindedRow(a,l))}this.refreshView()}},{key:"unbind",value:function(t,e){for(var n=0;n<this.rows.length;n++){var o=this.rows[n].bindedField;o.object===t&&o.property==e&&(this.rows.splice(n,1),o.delete())}this.refreshView()}},{key:"addExportButton",value:function(){}},{key:"newRowInDom",value:function(){var t=null;return $(this.boxElement).find(".dragbox-content").append(this.rowHtml),t=this.boxElement.find(".paramboxtmprow"),$(t).removeClass("paramboxtmprow"),t}},{key:"getBindedRow",value:function(t,e){return{rowDom:t,bindedField:e}}},{key:"refreshView",value:function(){this.rows.length?this.boxElement[0].getElementsByClassName("parambox-buttonrow")[0].style.visibility="visible":this.boxElement[0].getElementsByClassName("parambox-buttonrow")[0].style.visibility="hidden";var t=80+75*this.rows.length;t>600&&(t=600),this.height=t}},{key:"keyfunction",value:function(t){this.map[t.keyCode]="keydown"==t.type,this.map[16]&&this.map[80]&&(this.map[80]=!1,this.toggle(),t.preventDefault())}},{key:"getSummaryArray",value:function(){for(var t=[],e=0;e<this.rows.length;e++){var n=this.rows[e].bindedField;t.push({property:n.property,value:n.value})}return t}},{key:"import",value:function(t){var e=prompt("Enter a JSON string:"),n=null;try{n=JSON.parse(e)}catch(t){console.error("ParamBox.import: Invalid JSON string - Parsing error:",t)}if(null!==n){n.constructor!==Array&&console.error("ParamBox.import: Invalid JSON string - the parent object needs to be of the same structure as the summaryArray");for(var o=0;o<n.length;o++)"undefined"==typeof n[o].property&&console.error("ParamBox.import: importedJSON["+o+"].property is undefined. Invalid JSON string - the parent object needs to be of the same structure as the summaryArray."),"undefined"==typeof n[o].value&&console.error("ParamBox.import: importedJSON["+o+"].value is undefined. Invalid JSON string - the parent object needs to be of the same structure as the summaryArray."),this.setProperty(n[o].property,n[o].value)}}},{key:"save",value:function(t){var e=this.getSummaryArray(),n=JSON.stringify(e,null,2),o=30+70*e.length;o>500&&(o=500),window.open("data:application/json;"+(window.btoa?"base64,"+btoa(n):n),"ParamBox.save","width=400,height="+o)}},{key:"reloadAndImport",value:function(t){for(var e=this.getSummaryArray(),n="",o=0;o<e.length;o++)""!==n&&(n+="&"),n+=e[o].property+"="+encodeURIComponent(e[o].value);var i=window.location.href,r=i.indexOf("?");r!==-1&&(i=i.substring(0,r)),i+="?"+n,window.location.href=i}},{key:"getDescendantProp",value:function(t,e){for(var n=e.split("."),o=null,i=null;n.length;){if(o=t,i=n.shift(),"undefined"==typeof t[i])throw new Error("object property "+i+" is undefined");t=t[i]}var r=t;return[o,i,r]}},{key:"setProperty",value:function(t,e){if(t.constructor!==String)throw new Error("ParamBox.setProperty: property needs to be a string.");for(var n=!1,o=0;o<this.rows.length;o++)this.rows[o].bindedField.property===t&&(this.rows[o].bindedField.value=e,n=!0);n===!1&&console.warn("ParamBox.setProperty: did not find property "+t)}}]),e}(DragBox),SmartChart=function(t){function e(){var t=arguments.length<=0||void 0===arguments[0]?mandatory():arguments[0],n=arguments.length<=1||void 0===arguments[1]?null:arguments[1],o=arguments.length<=2||void 0===arguments[2]?null:arguments[2];if(_classCallCheck(this,e),"undefined"==typeof Chart)throw new Error("SmartChart.constructor: Chart.js is not loaded.");if(t.constructor!==Object)throw new Error("SmartChart.constructor: options needs to be an object (chart.js chart options)");var i=_possibleConstructorReturn(this,Object.getPrototypeOf(e).call(this,"overlay",n,"closebutton",o));i.chartOptions=$.extend(!0,{},t),i.title="<center><h5>Smart Chart</h5></center>";var r="chart-canvas"+($("canvas").length+1);i.content='<canvas id="'+r+'" class="chart-canvas"></canvas>',i.canvas=document.getElementById(r);try{Chart.defaults.global.responsive=!0,Chart.defaults.global.maintainAspectRatio=!1,i.chart=new Chart(i.canvas,t)}catch(t){throw new Error("SmartChart.constructor: could not build the chart. Error: "+t)}i.canvas.style.background="white",i.boxClass="dragbox-white-boxshadow",i.DEFAULT_BUTTON_ROW_HTML='<div class="col-xs-12 dragbox-row smartchart-buttonrow"><div class="col-xs-10"></div></div>',i.DEFAULT_BUTTON_HTML={closebutton:'<button type="button" class="btn btn-secondary dragbox-button smartchart-closebutton">Close</button>',savebutton:'<button type="button" class="btn btn-secondary dragbox-button smartchart-savebutton">Save</button>'},i.html(".dragbox-footer",i.DEFAULT_BUTTON_ROW_HTML),i.append(i.DEFAULT_BUTTON_HTML.savebutton,".smartchart-buttonrow","col-xs-1 centered"),i.append(i.DEFAULT_BUTTON_HTML.closebutton,".smartchart-buttonrow","col-xs-1 centered"),i.closeButton=i.button=$(i.boxElement).find(".smartchart-closebutton"),i.saveButton=$(i.boxElement).find(".smartchart-savebutton"),s=i,$(i.closeButton).click(function(t){s.callThenDestroy()}),$(i.saveButton).click(function(t){s.save(t)}),i.updatePosition(),i.updateSize();var s=i;return setTimeout(function(){s.chart.resize(),s.show()},250),i}return _inherits(e,t),_createClass(e,[{key:"callAfterConstructor",value:function(){}},{key:"callThenDestroy",value:function(){this.callback&&this.callback(),"undefined"!=typeof this.chart&&"undefined"!=typeof Chart&&this.chart.constructor===Chart&&this.chart.destroy(),this.destroy()}},{key:"save",value:function(t){var e=JSON.stringify(this.chartOptions,null,2),n=150+150*this.chartOptions.data.datasets.length;n>500&&(n=500),window.open("data:application/json;"+(window.btoa?"base64,"+btoa(e):e),"SmartChart.save","width=400,height="+n)}}]),e}(SmartModal),BindedProperty=function(){function t(){var e=arguments.length<=0||void 0===arguments[0]?null:arguments[0],n=arguments.length<=1||void 0===arguments[1]?null:arguments[1];_classCallCheck(this,t),this.HANDLED_VARIABLE_TYPES=["number","string","boolean"],this.property=n,this.object=e,this.propagate=!1,this.type=null,this.object||(this.object=window),null!==n&&this.bind(e,n)}return _createClass(t,[{key:"bind",value:function(t,e){var n=_typeof(this.object[this.property]);if("undefined"===n)throw new Error("Parambox: The variable '"+e+"' you are trying to bind is undefined - either this object or the property is not defined");if(this.HANDLED_VARIABLE_TYPES.indexOf(n)==-1)throw new Error("The variable you are trying to bind is of a non-handled type (string, number or boolean");this.property=e,this.object=t,this.type=this.object[this.property].constructor}},{key:"convertToType",value:function(t){if(this.type){if(this.type===Boolean)switch(String(t).toUpperCase()){case"0":return!1;case"1":return!0;case"FALSE":return!1;case"TRUE":return!0}return this.type(t)}throw new Error("You are trying to convert a value to a the type of the binded property but the object has no property binded to it (or no type)")}},{key:"value",set:function(t){if("undefined"==typeof this.object[this.property])throw new Error("The variable you are trying to bind is undefined - either this object or the property is incorrect");this.object[this.property]=this.convertToType(t)},get:function(){if("undefined"==typeof this.object[this.property])throw new Error("The variable you are trying to bind is undefined - either this object or the property is incorrect");return this.object[this.property]}}]),t}(),BindedField=function(t){function e(){var t=arguments.length<=0||void 0===arguments[0]?mandatory("object"):arguments[0],n=arguments.length<=1||void 0===arguments[1]?mandatory("property"):arguments[1],o=arguments.length<=2||void 0===arguments[2]?null:arguments[2],i=arguments.length<=3||void 0===arguments[3]?"input":arguments[3],r=arguments.length<=4||void 0===arguments[4]?null:arguments[4];_classCallCheck(this,e);var s=_possibleConstructorReturn(this,Object.getPrototypeOf(e).call(this,t,n));switch(s.VALID_FIELD_TYPE=["input","selector","slider"],s.field=null,s.fieldType=i,s.fieldHTML=null,s.allowedValues=r,s.tempClass="binded-"+("undefined"==typeof t?"undefined":_typeof(t))+n,s.parent=o,s.fieldType){case"input":s.fieldHTML='<fieldset class="form-group"><label>'+n+'</label><input type="text" class="form-control '+s.tempClass+'" data-binded="'+n+'"></fieldset>';break;case"selector":if(!r)throw new Error("fieldType selector needs at least one allowedValues");s.fieldHTML='<fieldset class="form-group"><label>'+n+'</label><select class="form-control '+s.tempClass+'" data-binded="'+n+'">';for(var a=0;a<s.allowedValues.length;a++)s.fieldHTML=s.fieldHTML+'<option value="'+s.allowedValues[a]+'">'+s.allowedValues[a]+"</option>";s.fieldHTML=s.fieldHTML+"</select></fieldset>";break;case"slider":break;default:throw new Error("fieldType is invalid : input, selector and slider are the only valid type for now")}return o&&s.placeInParent(),s}return _inherits(e,t),_createClass(e,[{key:"placeInParent",value:function(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0];t&&(this.parent=t),$(this.parent).append(this.fieldHTML),this.field=$("."+this.tempClass),this.field.removeClass(this.tempClass),this.allowedValues&&this.allowedValues.constructor===Array?this.allowedValues.indexOf(this.value)!==-1?this.field.val(this.value):this.field.val(this.allowedValues[0]):this.field.val(this.value);var e=this;this.field.change(function(t){e.update("field")}),this.field.keydown(function(t){switch(t.keyCode){case 13:e.update("field")}})}},{key:"delete",value:function(){this.field.parent().remove(),this.property=null,this.object=null}},{key:"update",value:function(){var t=arguments.length<=0||void 0===arguments[0]?"field":arguments[0];"field"==t?(this.value=$(this.field).val(),$(this.field).get(0).blur()):$(this.field).val().toUpperCase()!=String(this.value).toUpperCase()&&$(this.field).val(this.value)}},{key:"value",set:function(t){if("undefined"==typeof this.object[this.property])throw new Error("The variable you are trying to bind is undefined - either this object or the property is incorrect");this.object[this.property]=this.convertToType(t),this.update("setter")},get:function(){if("undefined"==typeof this.object[this.property])throw new Error("The variable you are trying to bind is undefined - either this object or the property is incorrect");return this.object[this.property]}}]),e}(BindedProperty);
"use strict";function _possibleConstructorReturn(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function mandatory(){var t=arguments.length<=0||void 0===arguments[0]?"":arguments[0];throw new Error("Missing parameter "+t)}function findAllIndices(){for(var t=arguments.length<=0||void 0===arguments[0]?mandatory():arguments[0],e=arguments.length<=1||void 0===arguments[1]?mandatory():arguments[1],n=[],o=0;o<e.length;o++)e.substr(o,t.length)===t&&n.push(o);return n.length?n:-1}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},_createClass=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),scripts=document.getElementsByTagName("script"),paramBoxFullpath=scripts[scripts.length-1].src,delimiterIndices=findAllIndices("/",paramBoxFullpath);paramBoxFullpath=paramBoxFullpath.substr(0,delimiterIndices[delimiterIndices.length-2]),document.addEventListener("DOMContentLoaded",function(t){var e=document.getElementsByTagName("head")[0],n=document.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=paramBoxFullpath+"/dist/paramBox.css",e.appendChild(n)});var DragBox=function(){function t(){var e=arguments.length<=0||void 0===arguments[0]?null:arguments[0],n=arguments.length<=1||void 0===arguments[1]?null:arguments[1],o=arguments.length<=2||void 0===arguments[2]?null:arguments[2];_classCallCheck(this,t),this.MAX_BINDED_PROPERTIES=15,this.INIT_WIDTH=n?n:400,this.INIT_HEIGHT=o?o:300,this.DEFAULT_BOX_CLASS="dragbox",this.DEFAULT_DRAGGABLE=!0,this.DEFAULT_STICKINESS_TYPE="magnetized",this.boxId=null,this.boxElement=e,this.draggable=this.DEFAULT_DRAGGABLE,this.boxHTML=null,this.shouldStick=null,this.shouldMagnetize=null,this.isStickingX=null,this.isStickingY=null,this.stickiness=this.DEFAULT_STICKINESS_TYPE,this._beingDragged=!1,this._visibility="hidden",this._overflow="hidden",this._boxClass=this.DEFAULT_BOX_CLASS,this._width=this.INIT_WIDTH,this._height=this.INIT_HEIGHT,this.map=[],this.currentMousePos={x:-1,y:-1};var i=this;$(document).mousemove(function(t){i.currentMousePos.x=t.pageX,i.currentMousePos.y=t.pageY}),this.boxElement?this.boxId=$(this.boxElement).attr("id"):(this.boxId="dragbox"+($('div[id*="dragbox"]').length+1),this.boxHTML='<div id="'+this.boxId+'" class="'+this._boxClass+'" style="opacity:0.0;" draggable="true"><div class="col-xs-12 dragbox-container"><div class="col-xs-12 dragbox-title"><center><h3>Dragbox</h3></center></div><div class="col-xs-12 dragbox-content"></div><div class="col-xs-12 dragbox-footer"></div></div></div>',$(document.body).append(this.boxHTML),this.boxElement=$("#"+this.boxId)),this.boxClass=$(this.boxElement).attr("class"),this.width=this._width,this.height=this._height,this.overflow="hidden",$(document.body).keydown(function(t){i.keyfunction(t)}),$(document.body).keyup(function(t){i.keyfunction(t)}),$(this.boxElement).find(".dragbox-title").mousedown(function(t){i.startDrag(t)}),$(this.boxElement).find(".dragbox-title").mouseup(function(t){i.stopDrag(t)}),$(document).click(function(t){i.stopDrag(t)}),this.queryString=this.getQueryString()}return _createClass(t,[{key:"destroy",value:function(){var t=this;$(this.boxElement).animate({opacity:0},25,function(){$(t.boxElement).remove()})}},{key:"updateSize",value:function(){$(this.boxElement).width(this.width),$(this.boxElement).height(this.height);var t=this.height-$(this.boxElement).find(".dragbox-title").height()-$(this.boxElement).find(".dragbox-footer").height()-7,e=this;$(this.boxElement).animate({height:e.height,width:e.width},25,function(){}),$(this.boxElement).find(".dragbox-container").animate({height:e.height},25,function(){}),$(this.boxElement).find(".dragbox-content").animate({height:t},25,function(){})}},{key:"startDrag",value:function(t){if(t.preventDefault(),"true"==this.beingDragged)return void(this.beingDragged=!1);if(this.draggable){var e={x:t.clientX-$(this.boxElement).offset().left,y:t.clientY-$(this.boxElement).offset().top};return this.beingDragged=!0,this.loopDrag(e),!1}}},{key:"stopDrag",value:function(){this.beingDragged=!1}},{key:"loopDrag",value:function(t){if(this.beingDragged===!0){var e=this.currentMousePos.x-t.x,n=this.currentMousePos.y-t.y,o={offsetLeft:e,offsetTop:n,offsetWidth:$(this.boxElement).width(),offsetHeigth:$(this.boxElement).height()},i=ParamBox.stayInWindow(o),r=i.x,s=i.y;this.shouldStick&&(i.stickyX!=-2&&2!=i.stickyX||(this.isStickingX=!0),this.isStickingX&&0!==i.stickyX&&(r=i.leftSticky),0===i.stickyX&&(this.isStickingX=!1),i.stickyY!=-2&&2!=i.stickyY||(this.isStickingY=!0),this.isStickingY&&0!==i.stickyY&&(s=i.topSticky),0===i.stickyY&&(this.isStickingY=!1)),this.shouldMagnetize&&(r=i.leftSticky,s=i.topSticky);var a=this;return $(this.boxElement).animate({left:r,top:s},25,function(){a.loopDrag(t)}),!1}}},{key:"keyfunction",value:function(t){console.log("keyEvent dragbox method")}},{key:"toggle",value:function(){"hidden"==this.visibility?this.visibility="visible":this.visibility="hidden"}},{key:"show",value:function(){this.visibility="visible"}},{key:"hide",value:function(){this.visibility="hidden"}},{key:"append",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?".dragbox-content":arguments[1],n=arguments.length<=2||void 0===arguments[2]?null:arguments[2];this.boxElement&&(null!==n&&(t='<div class="'+n+'" >'+t+"</div>"),"container"!=e?this.boxElement.find(e).append(t):this.boxElement.append(t))}},{key:"html",value:function(){var t=arguments.length<=0||void 0===arguments[0]?".dragbox-content":arguments[0],e=arguments.length<=1||void 0===arguments[1]?null:arguments[1];if(this.boxElement){var n="container"!=t?this.boxElement.find(t):this.boxElement;if(null===e)return n.html();n.html(e)}}},{key:"getQueryString",value:function(){for(var t={},e=window.location.search.substring(1),n=e.split("&"),o=0;o<n.length;o++){var i=n[o].split("=");if("undefined"==typeof t[i[0]])t[i[0]]=decodeURIComponent(i[1]);else if("string"==typeof t[i[0]]){var r=[t[i[0]],decodeURIComponent(i[1])];t[i[0]]=r}else t[i[0]].push(decodeURIComponent(i[1]))}return t}},{key:"width",set:function(t){this._width=t,this.updateSize()},get:function(){return this._width}},{key:"height",set:function(t){this._height=t,this.updateSize()},get:function(){return this._height}},{key:"beingDragged",set:function(t){this._beingDragged=t,$(this.boxElement).attr("beingDragged",t)},get:function(){return this._beingDragged}},{key:"boxClass",set:function(t){if(this.boxElement){if("string"!=typeof t)throw new Error("newClass must be a string");var e=t.indexOf(" ");e!=-1&&(t=t.substr(0,e)),this.boxElement.removeClass(this.boxClass).addClass(t),this._boxClass=t}},get:function(){if(this.boxElement)return this._boxClass}},{key:"visibility",set:function(t){this._visibility=t,"visible"==t?$(this.boxElement).animate({opacity:1},150):$(this.boxElement).animate({opacity:0},150)},get:function(){return this._visibility}},{key:"overflow",set:function(t){this._overflow=t,$(this.boxElement).find(".dragbox-content").css("overflow-y",t)},get:function(){return this._overflow}},{key:"stickiness",get:function(){return this._stickiness},set:function(t){switch(t){case"none":this.shouldMagnetize=!1,this.shouldStick=!1,console.log("Parambox: stickiness set to none");break;case"glue":this.shouldStick=!0,this.shouldMagnetize=!1,console.log("stickiness set to glue");break;case"magnetized":this.shouldStick=!1,this.shouldMagnetize=!0,console.log("stickiness set to magnetized");break;default:throw new Error("this sticky type does not exist. Types are : none, glue, or magnetized.")}this._stickiness=t}},{key:"title",get:function(){this.boxElement&&$(this.boxElement).find(".dragbox-title").html()},set:function(t){this.boxElement&&($(this.boxElement).find(".dragbox-title").html(t),this.updateSize())}},{key:"content",set:function(t){this.boxElement&&(this.contentDiv.html(t),this.updateSize())},get:function(){if(this.boxElement)return this.contentDiv.html()}},{key:"contentDiv",get:function(){if(this.boxElement)return $(this.boxElement).find(".dragbox-content")}}],[{key:"stayInWindow",value:function(t){if("undefined"==typeof t)throw new Error("element is undefined");var e=.15,n=t.offsetLeft,o=t.offsetLeft+t.offsetWidth,i=t.offsetTop,r=t.offsetTop+t.offsetHeigth,s=window.innerWidth-t.offsetWidth,a=window.innerHeight-t.offsetHeigth;return{x:n<0?0:o>window.innerWidth?s:n,y:i<0?0:r>window.innerHeight?a:i,stickyX:n<=0?-2:n<=e*t.offsetWidth?-1:o>=window.innerWidth?2:o>=window.innerWidth-e*t.offsetWidth?1:0,stickyY:i<=0?-2:i<=e*t.offsetHeigth?-1:r>=window.innerHeight?2:r>=window.innerHeight-e*t.offsetHeigth?1:0,leftSticky:n<=0?0:n<=e*t.offsetWidth?0:o>=window.innerWidth?window.innerWidth-t.offsetWidth:o>=window.innerWidth-e*t.offsetWidth?window.innerWidth-t.offsetWidth:n,topSticky:i<=0?0:i<=e*t.offsetHeigth?0:r>=window.innerHeight?window.innerHeight-t.offsetHeigth:r>=window.innerHeight-e*t.offsetHeigth?window.innerHeight-t.offsetHeigth:i}}},{key:"getCoordinateInWindow",value:function(t){var e=t.offsetLeft,n=t.offsetLeft+t.offsetWidth,o=t.offsetTop,i=t.offsetTop+t.offsetHeigth,r=window.innerWidth-t.offsetWidth,s=window.innerHeight-t.offsetHeigth;return{left:e,right:n,top:o,bottom:i,maxLeft:r,maxTop:s}}},{key:"stickiness",get:function(){}},{key:"title",get:function(){}}]),t}(),SmartModal=function(t){function e(){var t=arguments.length<=0||void 0===arguments[0]?"across":arguments[0],n=arguments.length<=1||void 0===arguments[1]?null:arguments[1],o=arguments.length<=2||void 0===arguments[2]?"closebutton":arguments[2],i=arguments.length<=3||void 0===arguments[3]?null:arguments[3];_classCallCheck(this,e);var r=_possibleConstructorReturn(this,Object.getPrototypeOf(e).call(this,i));if(r.DEFAULT_BUTTON_ROW_HTML='<div class="col-xs-12 dragbox-row smartmodal-buttonrow"></div>',r.DEFAULT_BUTTON_HTML={closebutton:'<button type="button" class="btn btn-secondary dragbox-button smartmodal-closebutton">Close</button>',nextbutton:'<button type="button" class="btn btn-secondary dragbox-button smartmodal-nextbutton">Next</button>',blankbutton:'<button type="button" class="btn btn-secondary dragbox-button smartmodal-blankbutton"></button>',sendbutton:'<button type="button" class="btn btn-secondary dragbox-button smartmodal-sendbutton">Send</button>'},r.DEFAULT_FORMAT_TYPES={centralSmall:[.2,.4,.3],centralLarge:[.2,.7,.6],across:[.3,1,.4],overlay:[.1,.8,.8]},r.callback=n,r.draggable=!1,r.formatType=t,r.buttonRowHtml=r.DEFAULT_BUTTON_ROW_HTML,!(o in r.DEFAULT_BUTTON_HTML))throw new Error("buttonType invalid");r.buttonType=o,r.rows=[],r.title="<center><h5>Smart Modal</h5></center>",r.append(r.buttonRowHtml,".dragbox-footer"),r.append(r.DEFAULT_BUTTON_HTML[r.buttonType],".smartmodal-buttonrow"),r.button=$(r.boxElement).find(".smartmodal-"+r.buttonType),r.callAfterConstructor();var s=r;return $(window).resize(function(){s.updatePosition()}),$(r.button).click(function(){s.callThenDestroy()}),r}return _inherits(e,t),_createClass(e,[{key:"callAfterConstructor",value:function(){this.updatePosition(),this.updateSize(),this.show()}},{key:"callThenDestroy",value:function(){this.callback&&this.callback(),this.destroy()}},{key:"updatePosition",value:function(){var t=window.innerHeight,e=window.innerWidth,n=this.DEFAULT_FORMAT_TYPES[this.formatType],o=n[0]*t,i=e*(1-n[1])/2,r=e*n[1],s=t*n[2];return this.width=r,this.height=s,$(this.boxElement).animate({left:i,top:o},25,function(){}),!1}}]),e}(DragBox),ParamBox=function(t){function e(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0];_classCallCheck(this,e);var n=_possibleConstructorReturn(this,Object.getPrototypeOf(e).call(this,t));n.DEFAULT_ROW_HTML='<div class="col-md-12 dragbox-row paramboxtmprow"></div>',n.PARAMBOX_EMPTY_ROW_HTML='<div class="col-md-12 dragbox-row parambox-empty"><center>No parameters binded.</center></div>',n.DEFAULT_BUTTON_ROW_HTML='<div class="col-xs-12 dragbox-row parambox-buttonrow"></div>',n.DEFAULT_BUTTON_HTML={savebutton:'<button type="button" class="btn btn-secondary btn-block dragbox-button parambox-savebutton">Save</button>',importbutton:'<button type="button" class="btn btn-secondary btn-block dragbox-button parambox-importbutton">Import</button>',reloadbutton:'<button type="button" class="btn btn-secondary btn-block dragbox-button parambox-reloadbutton">Reload</button>'},n.append(n.DEFAULT_BUTTON_ROW_HTML,".dragbox-footer"),n.append(n.DEFAULT_BUTTON_HTML.savebutton,".parambox-buttonrow","col-xs-4"),n.append(n.DEFAULT_BUTTON_HTML.importbutton,".parambox-buttonrow","col-xs-4"),n.append(n.DEFAULT_BUTTON_HTML.reloadbutton,".parambox-buttonrow","col-xs-4");var o=n;return n.boxElement[0].getElementsByClassName("parambox-savebutton")[0].addEventListener("click",function(t){o.save(t)}),n.boxElement[0].getElementsByClassName("parambox-importbutton")[0].addEventListener("click",function(t){o.import(t)}),n.boxElement[0].getElementsByClassName("parambox-reloadbutton")[0].addEventListener("click",function(t){o.reloadAndImport(t)}),n.rowHtml=n.DEFAULT_ROW_HTML,n.rows=[],n.title='<h5><i class="fa fa-cog fa-1x"></i> Parameter Box</h5>',n.overflow="scroll","undefined"==typeof window.paramPrefixIncrement?window.paramPrefixIncrement=0:window.paramPrefixIncrement+=1,n.prefix="paramBox"+window.paramPrefixIncrement,n.updateSize(),n.refreshView(),n}return _inherits(e,t),_createClass(e,[{key:"bind",value:function(t,e){var n=arguments.length<=2||void 0===arguments[2]?null:arguments[2];if("undefined"==typeof t)throw new Error("object is undefined");var o=null;e.constructor!==Array&&(e=[e]);for(var i=0;i<e.length;i++){o=this.getDescendantProp(t,e[i]);var r=o[0],s=o[1],a=this.newRowInDom(),l=null,h=null;if("undefined"!=typeof this.queryString[s]&&(h=this.queryString[s]),null!==n&&"undefined"!=typeof n[e[i]]){var d=n[e[i]];if(null!==h){if(d.indexOf(h)===-1)throw new Error("ParamBox.bind: cannot set initial value to query string value of "+h+" because it is not in the constraints array.");r[s]=r[s].constructor(h)}var l=new BindedField(r,s,a,"selector",d)}if(!l)if(null!==h&&(r[s]=r[s].constructor(h)),r[s].constructor===Boolean)var l=new BindedField(r,s,a,"selector",["TRUE","FALSE"],h);else var l=new BindedField(r,s,a,"input",null,h);this.rows.push(this.getBindedRow(a,l))}this.refreshView()}},{key:"unbind",value:function(t,e){for(var n=0;n<this.rows.length;n++){var o=this.rows[n].bindedField;o.object===t&&o.property==e&&(this.rows.splice(n,1),o.delete())}this.refreshView()}},{key:"addExportButton",value:function(){}},{key:"newRowInDom",value:function(){var t=null;return $(this.boxElement).find(".dragbox-content").append(this.rowHtml),t=this.boxElement.find(".paramboxtmprow"),$(t).removeClass("paramboxtmprow"),t}},{key:"getBindedRow",value:function(t,e){return{rowDom:t,bindedField:e}}},{key:"refreshView",value:function(){this.rows.length?this.boxElement[0].getElementsByClassName("parambox-buttonrow")[0].style.visibility="visible":this.boxElement[0].getElementsByClassName("parambox-buttonrow")[0].style.visibility="hidden";var t=80+75*this.rows.length;t>600&&(t=600),this.height=t}},{key:"keyfunction",value:function(t){this.map[t.keyCode]="keydown"==t.type,this.map[16]&&this.map[80]&&(this.map[80]=!1,this.toggle(),t.preventDefault())}},{key:"getSummaryArray",value:function(){for(var t=[],e=0;e<this.rows.length;e++){var n=this.rows[e].bindedField;t.push({property:n.property,value:n.value})}return t}},{key:"import",value:function(t){var e=prompt("Enter a JSON string:"),n=null;try{n=JSON.parse(e)}catch(t){console.error("ParamBox.import: Invalid JSON string - Parsing error:",t)}if(null!==n){n.constructor!==Array&&console.error("ParamBox.import: Invalid JSON string - the parent object needs to be of the same structure as the summaryArray");for(var o=0;o<n.length;o++)"undefined"==typeof n[o].property&&console.error("ParamBox.import: importedJSON["+o+"].property is undefined. Invalid JSON string - the parent object needs to be of the same structure as the summaryArray."),"undefined"==typeof n[o].value&&console.error("ParamBox.import: importedJSON["+o+"].value is undefined. Invalid JSON string - the parent object needs to be of the same structure as the summaryArray."),this.setProperty(n[o].property,n[o].value)}}},{key:"save",value:function(t){var e=this.getSummaryArray(),n=JSON.stringify(e,null,2),o=30+70*e.length;o>500&&(o=500),window.open("data:application/json;"+(window.btoa?"base64,"+btoa(n):n),"ParamBox.save","width=400,height="+o)}},{key:"reloadAndImport",value:function(t){for(var e=this.getSummaryArray(),n="",o=0;o<e.length;o++)""!==n&&(n+="&"),n+=e[o].property+"="+encodeURIComponent(e[o].value);var i=window.location.href,r=i.indexOf("?");r!==-1&&(i=i.substring(0,r)),i+="?"+n,window.location.href=i}},{key:"getDescendantProp",value:function(t,e){for(var n=e.split("."),o=null,i=null;n.length;){if(o=t,i=n.shift(),"undefined"==typeof t[i])throw new Error("object property "+i+" is undefined");t=t[i]}var r=t;return[o,i,r]}},{key:"setProperty",value:function(t,e){if(t.constructor!==String)throw new Error("ParamBox.setProperty: property needs to be a string.");for(var n=!1,o=0;o<this.rows.length;o++)this.rows[o].bindedField.property===t&&(this.rows[o].bindedField.value=e,n=!0);n===!1&&console.warn("ParamBox.setProperty: did not find property "+t)}}]),e}(DragBox),SmartChart=function(t){function e(){var t=arguments.length<=0||void 0===arguments[0]?mandatory():arguments[0],n=arguments.length<=1||void 0===arguments[1]?null:arguments[1],o=arguments.length<=2||void 0===arguments[2]?null:arguments[2];if(_classCallCheck(this,e),"undefined"==typeof Chart)throw new Error("SmartChart.constructor: Chart.js is not loaded.");if(t.constructor!==Object)throw new Error("SmartChart.constructor: options needs to be an object (chart.js chart options)");var i=_possibleConstructorReturn(this,Object.getPrototypeOf(e).call(this,"overlay",n,"closebutton",o));i.chartOptions=$.extend(!0,{},t),i.title="<center><h5>Smart Chart</h5></center>";var r="chart-canvas"+($("canvas").length+1);i.content='<canvas id="'+r+'" class="chart-canvas"></canvas>',i.canvas=document.getElementById(r),"undefined"!=typeof t.options.title.text&&(t.options.title.display=!1,i.title="<center><h5>"+t.options.title.text+"</h5></center>");try{Chart.defaults.global.responsive=!0,Chart.defaults.global.maintainAspectRatio=!1,i.chart=new Chart(i.canvas,t)}catch(t){throw new Error("SmartChart.constructor: could not build the chart. Error: "+t)}i.canvas.style.background="white",i.boxClass="dragbox-white-boxshadow",i.DEFAULT_BUTTON_ROW_HTML='<div class="col-xs-12 dragbox-row smartchart-buttonrow"><div class="col-xs-10"></div></div>',i.DEFAULT_BUTTON_HTML={closebutton:'<button type="button" class="btn btn-secondary dragbox-button smartchart-closebutton">Close</button>',savebutton:'<button type="button" class="btn btn-secondary dragbox-button smartchart-savebutton">Save</button>'},i.html(".dragbox-footer",i.DEFAULT_BUTTON_ROW_HTML),i.append(i.DEFAULT_BUTTON_HTML.savebutton,".smartchart-buttonrow","col-xs-1 centered"),i.append(i.DEFAULT_BUTTON_HTML.closebutton,".smartchart-buttonrow","col-xs-1 centered"),i.closeButton=i.button=$(i.boxElement).find(".smartchart-closebutton"),i.saveButton=$(i.boxElement).find(".smartchart-savebutton"),s=i,$(i.closeButton).click(function(t){s.callThenDestroy()}),$(i.saveButton).click(function(t){s.save(t)}),i.updatePosition(),i.updateSize();var s=i;return setTimeout(function(){s.chart.resize(),s.show()},250),i}return _inherits(e,t),_createClass(e,[{key:"callAfterConstructor",value:function(){}},{key:"callThenDestroy",value:function(){this.callback&&this.callback(),"undefined"!=typeof this.chart&&"undefined"!=typeof Chart&&this.chart.constructor===Chart&&this.chart.destroy(),this.destroy()}},{key:"save",value:function(t){var e=JSON.stringify(this.chartOptions,null,2),n=150+150*this.chartOptions.data.datasets.length;n>500&&(n=500),window.open("data:application/json;"+(window.btoa?"base64,"+btoa(e):e),"SmartChart.save","width=400,height="+n)}}]),e}(SmartModal),BindedProperty=function(){function t(){var e=arguments.length<=0||void 0===arguments[0]?null:arguments[0],n=arguments.length<=1||void 0===arguments[1]?null:arguments[1];_classCallCheck(this,t),this.HANDLED_VARIABLE_TYPES=["number","string","boolean"],this.property=n,this.object=e,this.propagate=!1,this.type=null,this.object||(this.object=window),null!==n&&this.bind(e,n)}return _createClass(t,[{key:"bind",value:function(t,e){var n=_typeof(this.object[this.property]);if("undefined"===n)throw new Error("Parambox: The variable '"+e+"' you are trying to bind is undefined - either this object or the property is not defined");if(this.HANDLED_VARIABLE_TYPES.indexOf(n)==-1)throw new Error("The variable you are trying to bind is of a non-handled type (string, number or boolean");this.property=e,this.object=t,this.type=this.object[this.property].constructor}},{key:"convertToType",value:function(t){if(this.type){if(this.type===Boolean)switch(String(t).toUpperCase()){case"0":return!1;case"1":return!0;case"FALSE":return!1;case"TRUE":return!0}return this.type(t)}throw new Error("You are trying to convert a value to a the type of the binded property but the object has no property binded to it (or no type)")}},{key:"value",set:function(t){if("undefined"==typeof this.object[this.property])throw new Error("The variable you are trying to bind is undefined - either this object or the property is incorrect");this.object[this.property]=this.convertToType(t)},get:function(){if("undefined"==typeof this.object[this.property])throw new Error("The variable you are trying to bind is undefined - either this object or the property is incorrect");return this.object[this.property]}}]),t}(),BindedField=function(t){function e(){var t=arguments.length<=0||void 0===arguments[0]?mandatory("object"):arguments[0],n=arguments.length<=1||void 0===arguments[1]?mandatory("property"):arguments[1],o=arguments.length<=2||void 0===arguments[2]?null:arguments[2],i=arguments.length<=3||void 0===arguments[3]?"input":arguments[3],r=arguments.length<=4||void 0===arguments[4]?null:arguments[4];_classCallCheck(this,e);var s=_possibleConstructorReturn(this,Object.getPrototypeOf(e).call(this,t,n));switch(s.VALID_FIELD_TYPE=["input","selector","slider"],s.field=null,s.fieldType=i,s.fieldHTML=null,s.allowedValues=r,s.tempClass="binded-"+("undefined"==typeof t?"undefined":_typeof(t))+n,s.parent=o,s.fieldType){case"input":s.fieldHTML='<fieldset class="form-group"><label>'+n+'</label><input type="text" class="form-control '+s.tempClass+'" data-binded="'+n+'"></fieldset>';break;case"selector":if(!r)throw new Error("fieldType selector needs at least one allowedValues");s.fieldHTML='<fieldset class="form-group"><label>'+n+'</label><select class="form-control '+s.tempClass+'" data-binded="'+n+'">';for(var a=0;a<s.allowedValues.length;a++)s.fieldHTML=s.fieldHTML+'<option value="'+s.allowedValues[a]+'">'+s.allowedValues[a]+"</option>";s.fieldHTML=s.fieldHTML+"</select></fieldset>";break;case"slider":break;default:throw new Error("fieldType is invalid : input, selector and slider are the only valid type for now")}return o&&s.placeInParent(),s}return _inherits(e,t),_createClass(e,[{key:"placeInParent",value:function(){var t=arguments.length<=0||void 0===arguments[0]?null:arguments[0];t&&(this.parent=t),$(this.parent).append(this.fieldHTML),this.field=$("."+this.tempClass),this.field.removeClass(this.tempClass),this.allowedValues&&this.allowedValues.constructor===Array?this.allowedValues.indexOf(this.value)!==-1?this.field.val(this.value):this.field.val(this.allowedValues[0]):this.field.val(this.value);var e=this;this.field.change(function(t){e.update("field")}),this.field.keydown(function(t){switch(t.keyCode){case 13:e.update("field")}})}},{key:"delete",value:function(){this.field.parent().remove(),this.property=null,this.object=null}},{key:"update",value:function(){var t=arguments.length<=0||void 0===arguments[0]?"field":arguments[0];"field"==t?(this.value=$(this.field).val(),$(this.field).get(0).blur()):$(this.field).val().toUpperCase()!=String(this.value).toUpperCase()&&$(this.field).val(this.value)}},{key:"value",set:function(t){if("undefined"==typeof this.object[this.property])throw new Error("The variable you are trying to bind is undefined - either this object or the property is incorrect");this.object[this.property]=this.convertToType(t),this.update("setter")},get:function(){if("undefined"==typeof this.object[this.property])throw new Error("The variable you are trying to bind is undefined - either this object or the property is incorrect");return this.object[this.property]}}]),e}(BindedProperty);
{
"name": "parambox",
"version": "1.2.12",
"version": "1.2.13",
"description": "Too much parameters to handle ? paramBox is a collection of smart plug and play tools to facilitate the design of javascript projects such as games and cognitive tasks. ParamBox is one of the helper class and allows to modify key variable on the fly without having to modify the code or reload the page.",

@@ -5,0 +5,0 @@ "main": "lib/paramBox-transpiled-0.2.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc