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.5 to 1.2.6

64

dist/paramBox-compiled.js

@@ -675,8 +675,10 @@ "use strict";

var objectHierarchy = null;
if (properties.constructor === Array) {
for (var i = 0; i < properties.length; i++) {
if (typeof object[properties[i]] == 'undefined') {
throw new Error("object property " + properties[i] + " is undefined");
}
objectHierarchy = this.getDescendantProp(object, properties[i]);
var objectTemp = objectHierarchy[0];
var property = objectHierarchy[1];
var rowDom = this.newRowInDom();

@@ -688,3 +690,3 @@ var bindedField = null;

if (typeof constraints[properties[i]] != 'undefined') {
var bindedField = new BindedField(object, properties[i], rowDom, 'selector', constraints[properties[i]]);
var bindedField = new BindedField(objectTemp, property, rowDom, 'selector', constraints[properties[i]]);
}

@@ -695,6 +697,6 @@ }

if (!bindedField) {
if (object[properties[i]].constructor === Boolean) {
var bindedField = new BindedField(object, properties[i], rowDom, 'selector', ["TRUE", "FALSE"]);
if (objectTemp[property].constructor === Boolean) {
var bindedField = new BindedField(objectTemp, property, rowDom, 'selector', ["TRUE", "FALSE"]);
} else {
var bindedField = new BindedField(object, properties[i], rowDom);
var bindedField = new BindedField(objectTemp, property, rowDom);
}

@@ -706,6 +708,7 @@ }

} else {
if (typeof object[properties] == 'undefined') {
throw new Error("object property " + properties + " is undefined");
}
objectHierarchy = this.getDescendantProp(object, properties);
var objectTemp = objectHierarchy[0];
var property = objectHierarchy[1];
var rowDom = this.newRowInDom();

@@ -716,4 +719,4 @@ var bindedField = null;

if (constraints !== null) {
if (typeof constraints[properties] != 'undefined') {
var bindedField = new BindedField(object, properties, rowDom, 'selector', constraints[properties]);
if (typeof constraints[properties] !== 'undefined') {
var bindedField = new BindedField(objectTemp, property, rowDom, 'selector', constraints[properties]);
}

@@ -724,6 +727,6 @@ }

if (!bindedField) {
if (object[property].constructor === Boolean) {
var bindedField = new BindedField(object, properties, rowDom, 'selector', ["TRUE", "FALSE"]);
if (objectTemp[property].constructor === Boolean) {
var bindedField = new BindedField(objectTemp, property, rowDom, 'selector', ["TRUE", "FALSE"]);
} else {
var bindedField = new BindedField(object, properties, rowDom);
var bindedField = new BindedField(objectTemp, property, rowDom);
}

@@ -794,2 +797,33 @@ }

}
/**
* Gets the last object and property from a string description of object hierachy
* @param {object} object Top object from which the hierarchy starts
* @param {string} description String describing the object hierachy (e.g this.object.has.property )
* @return {array} [parentObject, lastProperty, propertyValue]
*/
}, {
key: "getDescendantProp",
value: function getDescendantProp(object, description) {
var arr = description.split(".");
var parentObject = null;
var lastProperty = null;
while (arr.length) {
parentObject = object;
lastProperty = arr.shift();
if (typeof object[lastProperty] === "undefined") {
throw new Error("object property " + lastProperty + " is undefined");
}
object = object[lastProperty];
}
/* the last object of the while is the value of the specified property */
var propertyValue = object;
return [parentObject, lastProperty, propertyValue];
}
}]);

@@ -796,0 +830,0 @@

@@ -592,8 +592,10 @@ class DragBox {

var objectHierarchy = null;
if (properties.constructor === Array) {
for (var i = 0; i < properties.length; i++) {
if (typeof object[properties[i]] == 'undefined') {
throw new Error("object property " + properties[i] + " is undefined");
}
objectHierarchy = this.getDescendantProp(object, properties[i]);
var objectTemp = objectHierarchy[0];
var property = objectHierarchy[1];
var rowDom = this.newRowInDom();

@@ -605,5 +607,4 @@ var bindedField = null;

if (typeof constraints[properties[i]] != 'undefined') {
var bindedField = new BindedField(object, properties[i], rowDom, 'selector', constraints[properties[i]]);
var bindedField = new BindedField(objectTemp, property, rowDom, 'selector', constraints[properties[i]]);
}
}

@@ -613,6 +614,6 @@

if (!bindedField) {
if (object[properties[i]].constructor === Boolean) {
var bindedField = new BindedField(object, properties[i], rowDom, 'selector', ["TRUE", "FALSE"]);
if (objectTemp[property].constructor === Boolean) {
var bindedField = new BindedField(objectTemp, property, rowDom, 'selector', ["TRUE", "FALSE"]);
} else {
var bindedField = new BindedField(object, properties[i], rowDom);
var bindedField = new BindedField(objectTemp, property, rowDom);
}

@@ -624,6 +625,7 @@ }

} else {
if (typeof object[properties] == 'undefined') {
throw new Error("object property " + properties + " is undefined");
}
objectHierarchy = this.getDescendantProp(object, properties);
var objectTemp = objectHierarchy[0];
var property = objectHierarchy[1];
var rowDom = this.newRowInDom();

@@ -634,4 +636,4 @@ var bindedField = null;

if (constraints !== null) {
if (typeof constraints[properties] != 'undefined') {
var bindedField = new BindedField(object, properties, rowDom, 'selector', constraints[properties]);
if (typeof constraints[properties] !== 'undefined') {
var bindedField = new BindedField(objectTemp, property, rowDom, 'selector', constraints[properties]);
}

@@ -642,6 +644,6 @@ }

if (!bindedField) {
if (object[property].constructor === Boolean) {
var bindedField = new BindedField(object, properties, rowDom, 'selector', ["TRUE", "FALSE"]);
if (objectTemp[property].constructor === Boolean) {
var bindedField = new BindedField(objectTemp, property, rowDom, 'selector', ["TRUE", "FALSE"]);
} else {
var bindedField = new BindedField(object, properties, rowDom);
var bindedField = new BindedField(objectTemp, property, rowDom);
}

@@ -708,2 +710,30 @@ }

/**
* Gets the last object and property from a string description of object hierachy
* @param {object} object Top object from which the hierarchy starts
* @param {string} description String describing the object hierachy (e.g this.object.has.property )
* @return {array} [parentObject, lastProperty, propertyValue]
*/
getDescendantProp(object, description) {
var arr = description.split(".");
var parentObject = null;
var lastProperty = null;
while (arr.length) {
parentObject = object;
lastProperty = arr.shift();
if (typeof object[lastProperty] === "undefined") {
throw new Error("object property " + lastProperty + " is undefined");
}
object = object[lastProperty];
}
/* the last object of the while is the value of the specified property */
var propertyValue = object;
return [parentObject, lastProperty, propertyValue];
}
}

@@ -710,0 +740,0 @@

@@ -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)}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 i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),DragBox=function(){function t(){var e=arguments.length<=0||void 0===arguments[0]?null:arguments[0],i=arguments.length<=1||void 0===arguments[1]?null:arguments[1],n=arguments.length<=2||void 0===arguments[2]?null:arguments[2];_classCallCheck(this,t),this.MAX_BINDED_PROPERTIES=15,this.INIT_WIDTH=i?i:400,this.INIT_HEIGHT=n?n: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 o=this;$(document).mousemove(function(t){o.currentMousePos.x=t.pageX,o.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){o.keyfunction(t)}),$(document.body).keyup(function(t){o.keyfunction(t)}),$(this.boxElement).find(".dragbox-title").mousedown(function(t){o.startDrag(t)}),$(this.boxElement).find(".dragbox-title").mouseup(function(t){o.stopDrag(t)}),$(document).click(function(t){o.stopDrag(t)})}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(),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,i=this.currentMousePos.y-t.y,n={offsetLeft:e,offsetTop:i,offsetWidth:$(this.boxElement).width(),offsetHeigth:$(this.boxElement).height()},o=ParamBox.stayInWindow(n),s=o.x,r=o.y;this.shouldStick&&(o.stickyX!=-2&&2!=o.stickyX||(this.isStickingX=!0),this.isStickingX&&0!==o.stickyX&&(s=o.leftSticky),0===o.stickyX&&(this.isStickingX=!1),o.stickyY!=-2&&2!=o.stickyY||(this.isStickingY=!0),this.isStickingY&&0!==o.stickyY&&(r=o.topSticky),0===o.stickyY&&(this.isStickingY=!1)),this.shouldMagnetize&&(s=o.leftSticky,r=o.topSticky);var l=this;return $(this.boxElement).animate({left:s,top:r},25,function(){l.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];this.boxElement&&("container"!=e?this.boxElement.find(e).append(t):this.boxElement.append(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)}},{key:"content",set:function(t){this.boxElement&&this.contentDiv.html(t)},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,i=t.offsetLeft,n=t.offsetLeft+t.offsetWidth,o=t.offsetTop,s=t.offsetTop+t.offsetHeigth,r=window.innerWidth-t.offsetWidth,l=window.innerHeight-t.offsetHeigth;return{x:i<0?0:n>window.innerWidth?r:i,y:o<0?0:s>window.innerHeight?l:o,stickyX:i<=0?-2:i<=e*t.offsetWidth?-1:n>=window.innerWidth?2:n>=window.innerWidth-e*t.offsetWidth?1:0,stickyY:o<=0?-2:o<=e*t.offsetHeigth?-1:s>=window.innerHeight?2:s>=window.innerHeight-e*t.offsetHeigth?1:0,leftSticky:i<=0?0:i<=e*t.offsetWidth?0:n>=window.innerWidth?window.innerWidth-t.offsetWidth:n>=window.innerWidth-e*t.offsetWidth?window.innerWidth-t.offsetWidth:i,topSticky:o<=0?0:o<=e*t.offsetHeigth?0:s>=window.innerHeight?window.innerHeight-t.offsetHeigth:s>=window.innerHeight-e*t.offsetHeigth?window.innerHeight-t.offsetHeigth:o}}},{key:"getCoordinateInWindow",value:function(t){var e=t.offsetLeft,i=t.offsetLeft+t.offsetWidth,n=t.offsetTop,o=t.offsetTop+t.offsetHeigth,s=window.innerWidth-t.offsetWidth,r=window.innerHeight-t.offsetHeigth;return{left:e,right:i,top:n,bottom:o,maxLeft:s,maxTop:r}}},{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],i=arguments.length<=1||void 0===arguments[1]?null:arguments[1],n=arguments.length<=2||void 0===arguments[2]?"closebutton":arguments[2],o=arguments.length<=3||void 0===arguments[3]?null:arguments[3];_classCallCheck(this,e);var s=_possibleConstructorReturn(this,Object.getPrototypeOf(e).call(this,o));if(s.DEFAULT_BUTTON_ROW_HTML='<div class="col-xs-12 dragbox-row smartmodal-buttonrow"></div>',s.DEFAULT_BUTTON_HTML={closebutton:'<button type="button" class="btn btn-secondary smartmodal-closebutton">Close</button>',nextbutton:'<button type="button" class="btn btn-secondary smartmodal-nextbutton">Next</button>',blankbutton:'<button type="button" class="btn btn-secondary smartmodal-blankbutton"></button>'},s.DEFAULT_FORMAT_TYPES={centralSmall:[.2,.4,.3],centralLarge:[.2,.7,.6],across:[.3,1,.4]},s.callback=i,s.draggable=!1,s.formatType=t,s.buttonRowHtml=s.DEFAULT_BUTTON_ROW_HTML,!(n in s.DEFAULT_BUTTON_HTML))throw new Error("buttonType invalid");s.buttonType=n,s.rows=[],s.title="<center><h5>Smart Modal</h5></center>",s.append(s.buttonRowHtml,".dragbox-footer"),s.append(s.DEFAULT_BUTTON_HTML[s.buttonType],".smartmodal-buttonrow"),s.button=$(s.boxElement).find(".smartmodal-"+s.buttonType),s.updatePosition(),s.show();var r=s;return $(window).resize(function(){r.updatePosition()}),$(s.button).click(function(){r.callThenDestroy()}),s}return _inherits(e,t),_createClass(e,[{key:"callThenDestroy",value:function(){this.callback&&this.callback(),this.destroy()}},{key:"updatePosition",value:function(){var t=window.innerHeight,e=window.innerWidth,i=this.DEFAULT_FORMAT_TYPES[this.formatType],n=i[0]*t,o=e*(1-i[1])/2,s=e*i[1],r=t*i[2];return this.width=s,this.height=r,$(this.boxElement).animate({left:o,top:n},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 i=_possibleConstructorReturn(this,Object.getPrototypeOf(e).call(this,t));return i.DEFAULT_ROW_HTML='<div class="col-md-12 dragbox-row paramboxtmprow"></div>',i.rowHtml=i.DEFAULT_ROW_HTML,i.rows=[],i.title='<h5><i class="fa fa-cog fa-1x"></i> Parameter Box</h5>',i.overflow="scroll",i}return _inherits(e,t),_createClass(e,[{key:"bind",value:function(t,e){var i=arguments.length<=2||void 0===arguments[2]?null:arguments[2];if("undefined"==typeof t)throw new Error("object is undefined");if(e.constructor===Array)for(var n=0;n<e.length;n++){if("undefined"==typeof t[e[n]])throw new Error("object property "+e[n]+" is undefined");var o=this.newRowInDom(),s=null;if(null!==i&&"undefined"!=typeof i[e[n]])var s=new BindedField(t,e[n],o,"selector",i[e[n]]);if(!s)if(t[e[n]].constructor===Boolean)var s=new BindedField(t,e[n],o,"selector",["TRUE","FALSE"]);else var s=new BindedField(t,e[n],o);this.rows.push(this.getBindedRow(o,s))}else{if("undefined"==typeof t[e])throw new Error("object property "+e+" is undefined");var o=this.newRowInDom(),s=null;if(null!==i&&"undefined"!=typeof i[e])var s=new BindedField(t,e,o,"selector",i[e]);if(!s)if(t[property].constructor===Boolean)var s=new BindedField(t,e,o,"selector",["TRUE","FALSE"]);else var s=new BindedField(t,e,o);this.rows.push(this.getBindedRow(o,s))}}},{key:"unbind",value:function(t,e){for(var i=0;i<this.rows.length;i++){var n=this.rows[i].bindedField;n.object===t&&n.property==e&&(this.rows.splice(i,1),n.delete())}}},{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(){}},{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())}}]),e}(DragBox),BindedProperty=function(){function t(){var e=arguments.length<=0||void 0===arguments[0]?null:arguments[0],i=arguments.length<=1||void 0===arguments[1]?null:arguments[1];_classCallCheck(this,t),this.HANDLED_VARIABLE_TYPES=["number","string","boolean"],this.property=i,this.object=e,this.propagate=!1,this.type=null,this.object||(this.object=window),i&&this.bind(e,i)}return _createClass(t,[{key:"bind",value:function(t,e){var i=_typeof(this.object[this.property]);if("undefined"===i)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(i)==-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],i=arguments.length<=1||void 0===arguments[1]?mandatory("property"):arguments[1],n=arguments.length<=2||void 0===arguments[2]?null:arguments[2],o=arguments.length<=3||void 0===arguments[3]?"input":arguments[3],s=arguments.length<=4||void 0===arguments[4]?null:arguments[4];_classCallCheck(this,e);var r=_possibleConstructorReturn(this,Object.getPrototypeOf(e).call(this,t,i));switch(r.VALID_FIELD_TYPE=["input","selector","slider"],r.field=null,r.fieldType=o,r.fieldHTML=null,r.allowedValues=s,r.tempClass="binded-"+("undefined"==typeof t?"undefined":_typeof(t))+i,r.parent=n,r.fieldType){case"input":r.fieldHTML='<fieldset class="form-group"><label>'+i+'</label><input type="text" class="form-control '+r.tempClass+'" data-binded="'+i+'"></fieldset>';break;case"selector":if(!s)throw new Error("fieldType selector needs at least one allowedValues");r.fieldHTML='<fieldset class="form-group"><label>'+i+'</label><select class="form-control '+r.tempClass+'" data-binded="'+i+'">';for(var l=0;l<r.allowedValues.length;l++)r.fieldHTML=r.fieldHTML+'<option value="'+r.allowedValues[l]+'">'+r.allowedValues[l]+"</option>";r.fieldHTML=r.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 n&&r.placeInParent(),r}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.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)}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 i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),DragBox=function(){function t(){var e=arguments.length<=0||void 0===arguments[0]?null:arguments[0],i=arguments.length<=1||void 0===arguments[1]?null:arguments[1],n=arguments.length<=2||void 0===arguments[2]?null:arguments[2];_classCallCheck(this,t),this.MAX_BINDED_PROPERTIES=15,this.INIT_WIDTH=i?i:400,this.INIT_HEIGHT=n?n: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 o=this;$(document).mousemove(function(t){o.currentMousePos.x=t.pageX,o.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){o.keyfunction(t)}),$(document.body).keyup(function(t){o.keyfunction(t)}),$(this.boxElement).find(".dragbox-title").mousedown(function(t){o.startDrag(t)}),$(this.boxElement).find(".dragbox-title").mouseup(function(t){o.stopDrag(t)}),$(document).click(function(t){o.stopDrag(t)})}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(),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,i=this.currentMousePos.y-t.y,n={offsetLeft:e,offsetTop:i,offsetWidth:$(this.boxElement).width(),offsetHeigth:$(this.boxElement).height()},o=ParamBox.stayInWindow(n),s=o.x,r=o.y;this.shouldStick&&(o.stickyX!=-2&&2!=o.stickyX||(this.isStickingX=!0),this.isStickingX&&0!==o.stickyX&&(s=o.leftSticky),0===o.stickyX&&(this.isStickingX=!1),o.stickyY!=-2&&2!=o.stickyY||(this.isStickingY=!0),this.isStickingY&&0!==o.stickyY&&(r=o.topSticky),0===o.stickyY&&(this.isStickingY=!1)),this.shouldMagnetize&&(s=o.leftSticky,r=o.topSticky);var l=this;return $(this.boxElement).animate({left:s,top:r},25,function(){l.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];this.boxElement&&("container"!=e?this.boxElement.find(e).append(t):this.boxElement.append(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)}},{key:"content",set:function(t){this.boxElement&&this.contentDiv.html(t)},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,i=t.offsetLeft,n=t.offsetLeft+t.offsetWidth,o=t.offsetTop,s=t.offsetTop+t.offsetHeigth,r=window.innerWidth-t.offsetWidth,l=window.innerHeight-t.offsetHeigth;return{x:i<0?0:n>window.innerWidth?r:i,y:o<0?0:s>window.innerHeight?l:o,stickyX:i<=0?-2:i<=e*t.offsetWidth?-1:n>=window.innerWidth?2:n>=window.innerWidth-e*t.offsetWidth?1:0,stickyY:o<=0?-2:o<=e*t.offsetHeigth?-1:s>=window.innerHeight?2:s>=window.innerHeight-e*t.offsetHeigth?1:0,leftSticky:i<=0?0:i<=e*t.offsetWidth?0:n>=window.innerWidth?window.innerWidth-t.offsetWidth:n>=window.innerWidth-e*t.offsetWidth?window.innerWidth-t.offsetWidth:i,topSticky:o<=0?0:o<=e*t.offsetHeigth?0:s>=window.innerHeight?window.innerHeight-t.offsetHeigth:s>=window.innerHeight-e*t.offsetHeigth?window.innerHeight-t.offsetHeigth:o}}},{key:"getCoordinateInWindow",value:function(t){var e=t.offsetLeft,i=t.offsetLeft+t.offsetWidth,n=t.offsetTop,o=t.offsetTop+t.offsetHeigth,s=window.innerWidth-t.offsetWidth,r=window.innerHeight-t.offsetHeigth;return{left:e,right:i,top:n,bottom:o,maxLeft:s,maxTop:r}}},{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],i=arguments.length<=1||void 0===arguments[1]?null:arguments[1],n=arguments.length<=2||void 0===arguments[2]?"closebutton":arguments[2],o=arguments.length<=3||void 0===arguments[3]?null:arguments[3];_classCallCheck(this,e);var s=_possibleConstructorReturn(this,Object.getPrototypeOf(e).call(this,o));if(s.DEFAULT_BUTTON_ROW_HTML='<div class="col-xs-12 dragbox-row smartmodal-buttonrow"></div>',s.DEFAULT_BUTTON_HTML={closebutton:'<button type="button" class="btn btn-secondary smartmodal-closebutton">Close</button>',nextbutton:'<button type="button" class="btn btn-secondary smartmodal-nextbutton">Next</button>',blankbutton:'<button type="button" class="btn btn-secondary smartmodal-blankbutton"></button>'},s.DEFAULT_FORMAT_TYPES={centralSmall:[.2,.4,.3],centralLarge:[.2,.7,.6],across:[.3,1,.4]},s.callback=i,s.draggable=!1,s.formatType=t,s.buttonRowHtml=s.DEFAULT_BUTTON_ROW_HTML,!(n in s.DEFAULT_BUTTON_HTML))throw new Error("buttonType invalid");s.buttonType=n,s.rows=[],s.title="<center><h5>Smart Modal</h5></center>",s.append(s.buttonRowHtml,".dragbox-footer"),s.append(s.DEFAULT_BUTTON_HTML[s.buttonType],".smartmodal-buttonrow"),s.button=$(s.boxElement).find(".smartmodal-"+s.buttonType),s.updatePosition(),s.show();var r=s;return $(window).resize(function(){r.updatePosition()}),$(s.button).click(function(){r.callThenDestroy()}),s}return _inherits(e,t),_createClass(e,[{key:"callThenDestroy",value:function(){this.callback&&this.callback(),this.destroy()}},{key:"updatePosition",value:function(){var t=window.innerHeight,e=window.innerWidth,i=this.DEFAULT_FORMAT_TYPES[this.formatType],n=i[0]*t,o=e*(1-i[1])/2,s=e*i[1],r=t*i[2];return this.width=s,this.height=r,$(this.boxElement).animate({left:o,top:n},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 i=_possibleConstructorReturn(this,Object.getPrototypeOf(e).call(this,t));return i.DEFAULT_ROW_HTML='<div class="col-md-12 dragbox-row paramboxtmprow"></div>',i.rowHtml=i.DEFAULT_ROW_HTML,i.rows=[],i.title='<h5><i class="fa fa-cog fa-1x"></i> Parameter Box</h5>',i.overflow="scroll",i}return _inherits(e,t),_createClass(e,[{key:"bind",value:function(t,e){var i=arguments.length<=2||void 0===arguments[2]?null:arguments[2];if("undefined"==typeof t)throw new Error("object is undefined");var n=null;if(e.constructor===Array)for(var o=0;o<e.length;o++){n=this.getDescendantProp(t,e[o]);var s=n[0],r=n[1],l=this.newRowInDom(),a=null;if(null!==i&&"undefined"!=typeof i[e[o]])var a=new BindedField(s,r,l,"selector",i[e[o]]);if(!a)if(s[r].constructor===Boolean)var a=new BindedField(s,r,l,"selector",["TRUE","FALSE"]);else var a=new BindedField(s,r,l);this.rows.push(this.getBindedRow(l,a))}else{n=this.getDescendantProp(t,e);var s=n[0],r=n[1],l=this.newRowInDom(),a=null;if(null!==i&&"undefined"!=typeof i[e])var a=new BindedField(s,r,l,"selector",i[e]);if(!a)if(s[r].constructor===Boolean)var a=new BindedField(s,r,l,"selector",["TRUE","FALSE"]);else var a=new BindedField(s,r,l);this.rows.push(this.getBindedRow(l,a))}}},{key:"unbind",value:function(t,e){for(var i=0;i<this.rows.length;i++){var n=this.rows[i].bindedField;n.object===t&&n.property==e&&(this.rows.splice(i,1),n.delete())}}},{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(){}},{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:"getDescendantProp",value:function(t,e){for(var i=e.split("."),n=null,o=null;i.length;){if(n=t,o=i.shift(),"undefined"==typeof t[o])throw new Error("object property "+o+" is undefined");t=t[o]}var s=t;return[n,o,s]}}]),e}(DragBox),BindedProperty=function(){function t(){var e=arguments.length<=0||void 0===arguments[0]?null:arguments[0],i=arguments.length<=1||void 0===arguments[1]?null:arguments[1];_classCallCheck(this,t),this.HANDLED_VARIABLE_TYPES=["number","string","boolean"],this.property=i,this.object=e,this.propagate=!1,this.type=null,this.object||(this.object=window),i&&this.bind(e,i)}return _createClass(t,[{key:"bind",value:function(t,e){var i=_typeof(this.object[this.property]);if("undefined"===i)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(i)==-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],i=arguments.length<=1||void 0===arguments[1]?mandatory("property"):arguments[1],n=arguments.length<=2||void 0===arguments[2]?null:arguments[2],o=arguments.length<=3||void 0===arguments[3]?"input":arguments[3],s=arguments.length<=4||void 0===arguments[4]?null:arguments[4];_classCallCheck(this,e);var r=_possibleConstructorReturn(this,Object.getPrototypeOf(e).call(this,t,i));switch(r.VALID_FIELD_TYPE=["input","selector","slider"],r.field=null,r.fieldType=o,r.fieldHTML=null,r.allowedValues=s,r.tempClass="binded-"+("undefined"==typeof t?"undefined":_typeof(t))+i,r.parent=n,r.fieldType){case"input":r.fieldHTML='<fieldset class="form-group"><label>'+i+'</label><input type="text" class="form-control '+r.tempClass+'" data-binded="'+i+'"></fieldset>';break;case"selector":if(!s)throw new Error("fieldType selector needs at least one allowedValues");r.fieldHTML='<fieldset class="form-group"><label>'+i+'</label><select class="form-control '+r.tempClass+'" data-binded="'+i+'">';for(var l=0;l<r.allowedValues.length;l++)r.fieldHTML=r.fieldHTML+'<option value="'+r.allowedValues[l]+'">'+r.allowedValues[l]+"</option>";r.fieldHTML=r.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 n&&r.placeInParent(),r}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.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.5",
"version": "1.2.6",
"description": "Too much parameters to handle ? paramBox is a collection of smart plug and play tools to facilitate the design of javascript games and cognitive tasks.",

@@ -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