/**
* The umbrella namespace for all SOTI Snap custom JavaScript APIs.
* @namespace Snap
* @type {object}
*/
var Snap = {
/**
* This namespace is a gateway to widget specific namespaces such as Snap.widgets.textbox or Snap.widgets.camera. Within those namespaces, are properties that you can use to manipulate the widgets in your SOTI Snap app.
* @example
* Snap.widgets.audio.getDisplayText('widget-id')
* @namespace Snap.widgets
* @memberof Snap
* @type {object}
*/
widgets: {
/**
* This namespace provides access to the properties of the Text Box widget.
* @example
* Snap.widgets.textbox.getDisplayText("widget-id");
* @namespace Snap.widgets.textbox
* @memberof Snap.widgets
* @type {object}
*/
textbox: {
/**
* Get value of textbox
* @memberof Snap.widgets.textbox
* @param {string} id Widget Id
* @returns {string}
*/
getValue: function(id) {
var element = document.getElementById(id);
return element.value;
},
/**
* Set value of textbox
* @memberof Snap.widgets.textbox
* @param {string} id Widget Id
* @param {string} value Widget Value
*/
setValue: function(id, value) {
AppRuntimeModule.bindValueToField(appModelIdDataGenyIdMap[id], value);
},
/**
* Get display text value of textbox (placeholder)
* @memberof Snap.widgets.textbox
* @param {string} id Widget Id
* @returns {string}
*/
getDisplayText: function(id) {
var element = document.getElementById(id);
return element.placeholder;
},
/**
* Set display text value of textbox (placeholder)
* @memberof Snap.widgets.textbox
* @param {string} id Widget Id
* @param {string} value Display Text
*/
setDisplayText: function(id, value) {
var element = document.getElementById(id);
element.placeholder = value;
},
/**
* Get widget border style
* @memberof Snap.widgets.textbox
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.textbox
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.textbox
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.textbox
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).borderRadius;
}
,
/**
* Get font size
* @memberof Snap.widgets.textbox
* @param {string} id Widget Id
* @returns {string}
*/
getFontSize: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).fontSize;
},
/**
* Get font color
* @memberof Snap.widgets.textbox
* @param {string} id Widget Id
* @returns {string}
*/
getFontColor: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).color;
},
/**
* Get font style
* @memberof Snap.widgets.textbox
* @param {string} id Widget Id
* @returns {string} fontStyle, fontWeight, textDecorationLine
*/
getFontStyle: function(id) {
var element = document.getElementById(id),
computedStyle = getComputedStyle(element);
return {
fontStyle: computedStyle.fontStyle,
fontWeight: computedStyle.fontWeight,
textDecorationLine: computedStyle.textDecorationLine
};
},
/**
* Get text alignment
* @memberof Snap.widgets.textbox
* @param {string} id Widget Id
* @returns {string}
*/
getTextAlignment: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).textAlign;
},
/**
* Get widget alignment
* @memberof Snap.widgets.textbox
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function(id) {
var id = document.getElementById(id),
dataGenyId = id.getAttribute('data-geny'),
element = document.querySelector('.alignment-wrapper-' + dataGenyId);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.textbox
* @param {string} id Widget Id
* @returns {number}
*/
getHeight: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.textbox
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetWidth;
},
/**
* Get widget padding
* @memberof Snap.widgets.textbox
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.' + dataGenyId + '-padding'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.textbox
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.'+dataGenyId+'-margin'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
}
}
,
/**
* This namespace provides access to the properties of the Paragraph widget.
* @example
* Snap.widgets.paragraph.getDisplayText("widget-id");
* @namespace Snap.widgets.paragraph
* @memberof Snap.widgets
* @type {object}
*/
paragraph: {
/**
* Get display text of paragraph
* @memberof Snap.widgets.paragraph
* @param {string} id Widget Id
* @returns {string}
*/
getDisplayText: function(id) {
var element = document.getElementById(id);
return element.innerText;
},
/**
* Set display text of paragraph
* @memberof Snap.widgets.paragraph
* @param {string} id Widget Id
* @param {string} value Display Text
*/
setDisplayText: function(id, value) {
var element = document.getElementById(id);
element.innerText = value;
}
,
/**
* Get font size
* @memberof Snap.widgets.paragraph
* @param {string} id Widget Id
* @returns {string}
*/
getFontSize: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).fontSize;
},
/**
* Get font color
* @memberof Snap.widgets.paragraph
* @param {string} id Widget Id
* @returns {string}
*/
getFontColor: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).color;
},
/**
* Get font style
* @memberof Snap.widgets.paragraph
* @param {string} id Widget Id
* @returns {string} fontStyle, fontWeight, textDecorationLine
*/
getFontStyle: function(id) {
var element = document.getElementById(id),
computedStyle = getComputedStyle(element);
return {
fontStyle: computedStyle.fontStyle,
fontWeight: computedStyle.fontWeight,
textDecorationLine: computedStyle.textDecorationLine
};
},
/**
* Get text alignment
* @memberof Snap.widgets.paragraph
* @param {string} id Widget Id
* @returns {string}
*/
getTextAlignment: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).textAlign;
},
/**
* Get widget alignment
* @memberof Snap.widgets.paragraph
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function(id) {
var id = document.getElementById(id),
dataGenyId = id.getAttribute('data-geny'),
element = document.querySelector('.alignment-wrapper-' + dataGenyId);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.paragraph
* @param {string} id Widget Id
* @returns {number}
*/
getHeight: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.paragraph
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetWidth;
},
/**
* Get widget border style
* @memberof Snap.widgets.paragraph
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.paragraph
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.paragraph
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.paragraph
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderRadius;
},
/**
* Get widget padding
* @memberof Snap.widgets.paragraph
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.' + dataGenyId + '-padding'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.paragraph
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.'+dataGenyId+'-margin'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
}
}
,
/**
* This namespace provides access to the properties of the Label widget.
* @example
* Snap.widgets.label.getDisplayText("widget-id");
* @namespace Snap.widgets.paragraph
* @namespace Snap.widgets.label
* @memberof Snap.widgets
* @type {object}
*/
label: {
/**
* Get display text of label
* @memberof Snap.widgets.label
* @param {string} id Widget Id
* @returns {string}
*/
getDisplayText: function(id) {
var element = document.getElementById(id);
return element.innerText;
},
/**
* Set display text of label
* @memberof Snap.widgets.label
* @param {string} id Widget Id
* @param {string} value Display Text
*/
setDisplayText: function(id, value) {
var element = document.getElementById(id);
element.innerText = value;
}
,
/**
* Get font size
* @memberof Snap.widgets.label
* @param {string} id Widget Id
* @returns {string}
*/
getFontSize: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).fontSize;
},
/**
* Get font color
* @memberof Snap.widgets.label
* @param {string} id Widget Id
* @returns {string}
*/
getFontColor: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).color;
},
/**
* Get font style
* @memberof Snap.widgets.label
* @param {string} id Widget Id
* @returns {string} fontStyle, fontWeight, textDecorationLine
*/
getFontStyle: function(id) {
var element = document.getElementById(id),
computedStyle = getComputedStyle(element);
return {
fontStyle: computedStyle.fontStyle,
fontWeight: computedStyle.fontWeight,
textDecorationLine: computedStyle.textDecorationLine
};
},
/**
* Get text alignment
* @memberof Snap.widgets.label
* @param {string} id Widget Id
* @returns {string}
*/
getTextAlignment: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).textAlign;
},
/**
* Get widget alignment
* @memberof Snap.widgets.label
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function(id) {
var id = document.getElementById(id),
dataGenyId = id.getAttribute('data-geny'),
element = document.querySelector('.alignment-wrapper-' + dataGenyId);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.label
* @param {string} id Widget Id
* @returns {number}
*/
getHeight: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.label
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetWidth;
},
/**
* Get widget border style
* @memberof Snap.widgets.label
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.label
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.label
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.label
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderRadius;
},
/**
* Get widget padding
* @memberof Snap.widgets.label
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.' + dataGenyId + '-padding'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.label
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.'+dataGenyId+'-margin'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
}
}
,
/**
* This namespace provides access to the properties of the Radio Button widget.
* @example
* Snap.widgets.radiobutton.getValue("widget-id");
* Snap.widgets.radiobutton.setValue("widget-id", true, "text", "Option 1");
* @namespace Snap.widgets.radiobutton
* @memberof Snap.widgets
* @type {object}
*/
radiobutton: {
/**
* Get value of radio button
* @memberof Snap.widgets.radiobutton
* @param {string} id Widget Id
* @returns {string}
*/
getValue: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny'),
selectedValue = UtilityModule.getWidgetValue(dataGenyId);
delete selectedValue.value.dataGeny;
return selectedValue.value;
},
/**
* Set value of radio button
* @memberof Snap.widgets.radiobutton
* @param {string} id Widget Id
* @param {bool} value Boolean for checked or unchecked
* @param {string} selectortype Type of selector - "value" or "text"
* @param {string} selectorValue Matching value for selectorType
*/
setValue: function(id, value, selectorType, selectorValue) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
UtilityModule.setWidgetValue(
'radiobutton',
dataGenyId,
{
type: selectorType,
value: selectorValue
},
value
);
}
,/**
* Get font size
@memberof Snap.widgets.radiobutton
* @param {string} id Widget Id
* @returns {string}
*/
getFontSize: function(id) {
var element = document.querySelector("#"+id+" label");
return getComputedStyle(element).fontSize;
},
/**
* Get font color
* @memberof Snap.widgets.radiobutton
* @param {string} id Widget Id
* @returns {string}
*/
getFontColor: function(id) {
var element = document.querySelector("#"+id+" label");
return getComputedStyle(element).color;
},
/**
* Get font style
* @memberof Snap.widgets.radiobutton
* @param {string} id Widget Id
* @returns {string} fontStyle, fontWeight, textDecorationLine
*/
getFontStyle: function(id) {
var element = document.querySelector("#" + id + " label"),
computedStyle = getComputedStyle(element);
return {
fontStyle: computedStyle.fontStyle,
fontWeight: computedStyle.fontWeight,
textDecorationLine: computedStyle.textDecorationLine
};
},
/**
* Get widget alignment (flex CSS)
* @memberof Snap.widgets.radiobutton
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function(id) {
var element = document.querySelector('.alignment-wrapper-' + id);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.radiobutton
* @param {number} id Widget Id
* @returns {number}
*/
getHeight: function(id) {
var element = document.getElementById(id);
return element.offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.radiobutton
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function(id) {
var element = document.getElementById(id);
return element.offsetWidth;
},
/**
* Get widget border style
* @memberof Snap.widgets.radiobutton
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("."+dataGenyId+"-border")).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.radiobutton
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("."+dataGenyId+"-border")).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.radiobutton
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("."+dataGenyId+"-border")).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.radiobutton
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("."+dataGenyId+"-border")).borderRadius;
},
/**
* Get widget padding
* @memberof Snap.widgets.radiobutton
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function(id, position) {
var element = document.getElementById(id),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.radiobutton
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.'+dataGenyId+'-margin'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
},
}
,
/**
* This namespace provides access to the properties of the Check Box widget.
* @example
* Snap.widgets.checkbox.getValue("widget-id");
* Snap.widgets.checkbox.setValue("widget-id", true, "text", "Option 1");
* @namespace Snap.widgets.checkbox
* @memberof Snap.widgets
* @type {object}
*/
checkbox: {
/**
* Get value of checkbox
* @memberof Snap.widgets.checkbox
* @param {string} id Widget Id
* @returns {string}
*/
getValue: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny'),
selectedValue = UtilityModule.getWidgetValue(dataGenyId);
// delete selectedValue.value.dataGeny;
return selectedValue.value;
},
/**
* Set value of checkbox
* @memberof Snap.widgets.checkbox
* @param {string} id Widget Id
* @param {bool} value Boolean for checked or unchecked
* @param {string} selectortype Type of selector - "value" or "text"
* @param {string} selectorValue Matching value for selectorType
*/
setValue: function(id, value, selectorType, selectorValue) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
UtilityModule.setWidgetValue(
'checkbox',
dataGenyId,
{
type: selectorType,
value: selectorValue
},
value
);
}
,/**
* Get font size
@memberof Snap.widgets.checkbox
* @param {string} id Widget Id
* @returns {string}
*/
getFontSize: function(id) {
var element = document.querySelector("#"+id+" label");
return getComputedStyle(element).fontSize;
},
/**
* Get font color
* @memberof Snap.widgets.checkbox
* @param {string} id Widget Id
* @returns {string}
*/
getFontColor: function(id) {
var element = document.querySelector("#"+id+" label");
return getComputedStyle(element).color;
},
/**
* Get font style
* @memberof Snap.widgets.checkbox
* @param {string} id Widget Id
* @returns {string} fontStyle, fontWeight, textDecorationLine
*/
getFontStyle: function(id) {
var element = document.querySelector("#" + id + " label"),
computedStyle = getComputedStyle(element);
return {
fontStyle: computedStyle.fontStyle,
fontWeight: computedStyle.fontWeight,
textDecorationLine: computedStyle.textDecorationLine
};
},
/**
* Get widget alignment (flex CSS)
* @memberof Snap.widgets.checkbox
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function(id) {
var element = document.querySelector('.alignment-wrapper-' + id);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.checkbox
* @param {number} id Widget Id
* @returns {number}
*/
getHeight: function(id) {
var element = document.getElementById(id);
return element.offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.checkbox
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function(id) {
var element = document.getElementById(id);
return element.offsetWidth;
},
/**
* Get widget border style
* @memberof Snap.widgets.checkbox
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("."+dataGenyId+"-border")).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.checkbox
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("."+dataGenyId+"-border")).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.checkbox
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("."+dataGenyId+"-border")).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.checkbox
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("."+dataGenyId+"-border")).borderRadius;
},
/**
* Get widget padding
* @memberof Snap.widgets.checkbox
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function(id, position) {
var element = document.getElementById(id),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.checkbox
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.'+dataGenyId+'-margin'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
},
}
,
/**
* This namespace provides access to the properties of the Drop Down widget.
* @example
* Snap.widgets.dropdown.getValue("widget-id");
* @namespace Snap.widgets.dropdown
* @memberof Snap.widgets
* @type {object}
*/
dropdown: {
/**
* Get value of dropdown
* @memberof Snap.widgets.dropdown
* @param {string} id Widget Id
* @returns {Dropdown}
*/
getValue: function(id) {
var element = document.getElementById(id).selectedOptions[0];
return { text: element.text, value: element.value };
},
/**
* Set value of dropdown
* @memberof Snap.widgets.dropdown
* @param {string} id Widget Id
* @param {string} selectortype Type of selector - "value" or "text"
* @param {string} selectorValue Matching value for selectorType
*/
setValue: function(id, selectorType, selectorValue) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
UtilityModule.setWidgetValue('dropdown', dataGenyId, {
type: selectorType,
value: selectorValue
});
}
,/**
* Get widget alignment (flex CSS)
@memberof Snap.widgets.dropdown
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function(id) {
var element = document.querySelector('.alignment-wrapper-' + id);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.dropdown
* @param {number} id Widget Id
* @returns {number}
*/
getHeight: function(id) {
var element = document.getElementById(id);
return element.offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.dropdown
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function(id) {
var element = document.getElementById(id);
return element.offsetWidth;
},
/**
* Get widget border style
* @memberof Snap.widgets.dropdown
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("."+dataGenyId+"-border")).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.dropdown
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("."+dataGenyId+"-border")).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.dropdown
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("."+dataGenyId+"-border")).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.dropdown
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("."+dataGenyId+"-border")).borderRadius;
},
/**
* Get widget padding
* @memberof Snap.widgets.dropdown
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function(id, position) {
var element = document.getElementById(id+"-button"),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.dropdown
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.'+dataGenyId+'-margin'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
},
}
,
/**
* This namespace provides access to the properties of the Dynamic Dropdown (External Source widget).
* @example
* Snap.widgets.dynamicdropdown.getValue("widget-id");
* @namespace Snap.widgets.dynamicdropdown
* @memberof Snap.widgets
* @type {object}
*/
dynamicdropdown: {
/**
* Get value of external source
* @memberof Snap.widgets.dynamicdropdown
* @param {string} id Widget Id
* @returns {array}
*/
getValue: function(id) {
var element = document.getElementById(id),
selectedValues = [];
for (var i = 0; i < element.parentElement.children.length - 1; i++) {
selectedValues.push(element.parentElement.children[i].innerText);
}
return selectedValues;
}
,
/**
* Get widget alignment
* @memberof Snap.widgets.dynamicdropdown
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function(id) {
var id = document.getElementById(id),
dataGenyId = id.getAttribute('data-geny'),
element = document.querySelector('.alignment-wrapper-' + dataGenyId);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.dynamicdropdown
* @param {string} id Widget Id
* @returns {number}
*/
getHeight: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.dynamicdropdown
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetWidth;
},
/**
* Get widget border style
* @memberof Snap.widgets.dynamicdropdown
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.dynamicdropdown
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.dynamicdropdown
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.dynamicdropdown
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderRadius;
},
/**
* Get widget margin
* @memberof Snap.widgets.dynamicdropdown
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.'+dataGenyId+'-margin'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
}
}
,
/**
* This namespace provides access to the properties of the Rating widget.
* @example
* Snap.widgets.rating.getValue("widget-id");
* @namespace Snap.widgets.rating
* @memberof Snap.widgets
* @type {object}
*/
rating: {
/**
* Get value of rating
* @memberof Snap.widgets.rating
* @param {string} id Widget Id
* @returns {number}
*/
getValue: function(id) {
var element = document.getElementById(id),
count = 0;
for (var i = 0; i < element.children.length; i++) {
if (element.children[i].classList.value.indexOf('selected') > -1) {
count = i + 1;
}
}
return count;
}
,
/**
* Get widget alignment
* @memberof Snap.widgets.rating
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function(id) {
var id = document.getElementById(id),
dataGenyId = id.getAttribute('data-geny'),
element = document.querySelector('.alignment-wrapper-' + dataGenyId);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.rating
* @param {string} id Widget Id
* @returns {number}
*/
getHeight: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.rating
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetWidth;
},
/**
* Get widget border style
* @memberof Snap.widgets.rating
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.rating
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.rating
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.rating
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderRadius;
},
/**
* Get widget padding
* @memberof Snap.widgets.rating
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.' + dataGenyId + '-padding'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.rating
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.'+dataGenyId+'-margin'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
}
}
,
/**
* This namespace provides access to the properties of the Date widget.
* @example
* Snap.widgets.datepicker.getValue("widget-id");
* @namespace Snap.widgets.datepicker
* @memberof Snap.widgets
* @type {object}
*/
datepicker: {
/**
* Get value of datepicker
* @memberof Snap.widgets.datepicker
* @param {string} id Widget Id
* @returns {string}
*/
getValue: function(id) {
var element = document.getElementById(id);
return element.value;
},
/**
* Get widget border style
* @memberof Snap.widgets.datepicker
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.datepicker
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.datepicker
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.datepicker
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).borderRadius;
}
,
/**
* Get font size
* @memberof Snap.widgets.datepicker
* @param {string} id Widget Id
* @returns {string}
*/
getFontSize: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).fontSize;
},
/**
* Get font color
* @memberof Snap.widgets.datepicker
* @param {string} id Widget Id
* @returns {string}
*/
getFontColor: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).color;
},
/**
* Get font style
* @memberof Snap.widgets.datepicker
* @param {string} id Widget Id
* @returns {string} fontStyle, fontWeight, textDecorationLine
*/
getFontStyle: function(id) {
var element = document.getElementById(id),
computedStyle = getComputedStyle(element);
return {
fontStyle: computedStyle.fontStyle,
fontWeight: computedStyle.fontWeight,
textDecorationLine: computedStyle.textDecorationLine
};
},
/**
* Get text alignment
* @memberof Snap.widgets.datepicker
* @param {string} id Widget Id
* @returns {string}
*/
getTextAlignment: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).textAlign;
},
/**
* Get widget alignment
* @memberof Snap.widgets.datepicker
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function(id) {
var id = document.getElementById(id),
dataGenyId = id.getAttribute('data-geny'),
element = document.querySelector('.alignment-wrapper-' + dataGenyId);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.datepicker
* @param {string} id Widget Id
* @returns {number}
*/
getHeight: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.datepicker
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetWidth;
},
/**
* Get widget padding
* @memberof Snap.widgets.datepicker
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.' + dataGenyId + '-padding'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.datepicker
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.'+dataGenyId+'-margin'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
}
}
,
/**
* This namespace provides access to the properties of the Switch widget.
* @example
* Snap.widgets.switch.getValue("widget-id");
* @namespace Snap.widgets.switch
* @memberof Snap.widgets
* @type {object}
*/
switch: {
/**
* Get value of switch
* @param {string} id Widget Id
* @returns {string}
*/
getValue: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny'),
selectedValue = UtilityModule.getWidgetValue(dataGenyId);
return selectedValue;
},
/**
* Set value of switch
* @memberof Snap.widgets.switch
* @param {string} id Widget Id
* @param {number} value 0 or 1
*/
setValue: function(id, value) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
UtilityModule.setWidgetValue('flipswitch', dataGenyId, null, value);
},
/**
* Get display text value of switch
* @memberof Snap.widgets.switch
* @param {string} id Widget Id
* @returns {string}
*/
getDisplayText: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector('#lbl-' + dataGenyId).innerText;
},
/**
* Set display text value of switch
* @memberof Snap.widgets.switch
* @param {string} id Widget Id
* @param {string} value Display Text
*/
setDisplayText: function(id, value) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
document.querySelector('#lbl-' + dataGenyId).innerText = value;
},
/**
* Get font size
* @memberof Snap.widgets.switch
* @param {string} id Widget Id
* @returns {string}
*/
getFontSize: function(id) {
var element = document.querySelector("."+appModelIdDataGenyIdMap[id]+" label");
return getComputedStyle(element).fontSize;
},
/**
* Get font color
* @memberof Snap.widgets.switch
* @param {string} id Widget Id
* @returns {string}
*/
getFontColor: function(id) {
var element = document.querySelector("."+appModelIdDataGenyIdMap[id]+" label");
return getComputedStyle(element).color;
},
/**
* Get font style
* @memberof Snap.widgets.switch
* @param {string} id Widget Id
* @returns {string} fontStyle, fontWeight, textDecorationLine
*/
getFontStyle: function(id) {
var element = document.querySelector("."+appModelIdDataGenyIdMap[id]+" label"),
computedStyle = getComputedStyle(element);
return {
fontStyle: computedStyle.fontStyle,
fontWeight: computedStyle.fontWeight,
textDecorationLine: computedStyle.textDecorationLine
};
},
/**
* Get text alignment
* @memberof Snap.widgets.switch
* @param {string} id Widget Id
* @returns {string}
*/
getTextAlignment: function(id) {
var element = document.querySelector("."+appModelIdDataGenyIdMap[id]+" label");
return getComputedStyle(element).textAlign;
}
,
/**
* Get widget alignment
* @memberof Snap.widgets.switch
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function(id) {
var id = document.getElementById(id),
dataGenyId = id.getAttribute('data-geny'),
element = document.querySelector('.alignment-wrapper-' + dataGenyId);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.switch
* @param {string} id Widget Id
* @returns {number}
*/
getHeight: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.switch
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetWidth;
},
/**
* Get widget border style
* @memberof Snap.widgets.switch
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.switch
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.switch
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.switch
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderRadius;
},
/**
* Get widget padding
* @memberof Snap.widgets.switch
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.' + dataGenyId + '-padding'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.switch
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.'+dataGenyId+'-margin'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
}
}
,
/**
* This namespace provides access to the properties of the Geo Location widget.
* @example
* Snap.widgets.geolocation.getValue("widget-id");
* @namespace Snap.widgets.geolocation
* @memberof Snap.widgets
* @type {object}
*/
geolocation: {
/**
* Get value of geolocation
* @memberof Snap.widgets.geolocation
* @param {string} id Widget Id
* @returns {string}
*/
getValue: function(id) {
var element = document.getElementById(id);
return element.value;
},
/**
* Get display text value of geolocation (placeholder)
* @memberof Snap.widgets.geolocation
* @param {string} id Widget Id
* @returns {string}
*/
getDisplayText: function(id) {
var element = document.getElementById(id);
return element.placeholder;
},
/**
* Set display text value of geolocation (placeholder)
* @memberof Snap.widgets.geolocation
* @param {string} id Widget Id
* @param {string} value Display Text
*/
setDisplayText: function(id, value) {
var element = document.getElementById(id);
element.placeholder = value;
}
,
/**
* Get widget alignment
* @memberof Snap.widgets.geolocation
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function(id) {
var id = document.getElementById(id),
dataGenyId = id.getAttribute('data-geny'),
element = document.querySelector('.alignment-wrapper-' + dataGenyId);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.geolocation
* @param {string} id Widget Id
* @returns {number}
*/
getHeight: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.geolocation
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetWidth;
},
/**
* Get widget border style
* @memberof Snap.widgets.geolocation
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.geolocation
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.geolocation
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.geolocation
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderRadius;
},
/**
* Get widget padding
* @memberof Snap.widgets.geolocation
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.' + dataGenyId + '-padding'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.geolocation
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.'+dataGenyId+'-margin'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
}
}
,
/**
* This namespace provides access to the properties of the Button widget.
* @example
* Snap.widgets.button.getDisplayText("widget-id");
* @namespace Snap.widgets.button
* @memberof Snap.widgets
* @type {object}
*/
button: {
// /**
// * Get value of button
// * @memberof Snap.widgets.button
// * @param {string} id
// * @returns {string}
// */
// getValue: function(id) {
// var element = document.getElementById(id);
// return element.value;
// },
// /**
// * Set value of button
// * @memberof Snap.widgets.button
// * @param {string} id
// * @param {string} value
// */
// setValue: function(value) {
// var element = document.getElementById(id);
// element.value = value;
// },
/**
* Get display text value of button (placeholder)
* @memberof Snap.widgets.button
* @param {string} id Widget Id
* @returns {string}
*/
getDisplayText: function(id) {
var element = document.getElementById(id);
return element.parentElement.textContent;
},
/**
* Set display text value of button (placeholder)
* @memberof Snap.widgets.button
* @param {string} id Widget Id
* @param {string} value Display Text
*/
setDisplayText: function(id, value) {
var element = document.getElementById(id);
element.parentElement.childNodes[0].nodeValue = value;
},
/**
* Get widget border style
* @memberof Snap.widgets.button
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function(id) {
return getComputedStyle(document.querySelector(".item-" + appModelIdDataGenyIdMap[id] + " .controller")).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.button
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function(id) {
return getComputedStyle(document.querySelector(".item-" + appModelIdDataGenyIdMap[id] + " .controller")).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.button
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function(id) {
return getComputedStyle(document.querySelector(".item-" + appModelIdDataGenyIdMap[id] + " .controller")).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.button
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function(id) {
return getComputedStyle(document.querySelector(".item-" + appModelIdDataGenyIdMap[id] + " .controller")).borderRadius;
},
/**
* Get text alignment
* @memberof Snap.widgets.button
* @param {string} id Widget Id
* @returns {string}
*/
getTextAlignment: function(id) {
return getComputedStyle(document.querySelector(".item-" + appModelIdDataGenyIdMap[id] + " .ui-input-btn")).textAlign;
},
/**
* Get font size
* @memberof Snap.widgets.button
* @param {string} id Widget Id
* @returns {string}
*/
getFontSize: function(id) {
return getComputedStyle(document.querySelector(".item-" + appModelIdDataGenyIdMap[id] + " .ui-input-btn")).fontSize;
},
/**
* Get font color
* @memberof Snap.widgets.button
* @param {string} id Widget Id
* @returns {string}
*/
getFontColor: function(id) {
return getComputedStyle(document.querySelector(".item-" + appModelIdDataGenyIdMap[id] + " .ui-input-btn")).color;
},
/**
* Get font style
* @memberof Snap.widgets.button
* @param {string} id Widget Id
* @returns {string} fontStyle, fontWeight, textDecorationLine
*/
getFontStyle: function(id) {
var computedStyle = getComputedStyle(document.querySelector(".item-" + appModelIdDataGenyIdMap[id] + " .ui-input-btn"));
return {
fontStyle: computedStyle.fontStyle,
fontWeight: computedStyle.fontWeight,
textDecorationLine: computedStyle.textDecorationLine
};
},
/**
* Get widget padding
* @memberof Snap.widgets.button
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function(id, position) {
var computedStyle = getComputedStyle(document.querySelector(".item-" + appModelIdDataGenyIdMap[id] + " .ui-input-btn")), value = "";
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
}
,
/**
* Get widget alignment
* @memberof Snap.widgets.button
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function(id) {
var id = document.getElementById(id),
dataGenyId = id.getAttribute('data-geny'),
element = document.querySelector('.alignment-wrapper-' + dataGenyId);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.button
* @param {string} id Widget Id
* @returns {number}
*/
getHeight: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.button
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetWidth;
},
/**
* Get widget margin
* @memberof Snap.widgets.button
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.'+dataGenyId+'-margin'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
}
}
,
/**
* This namespace provides access to the properties of the Camera widget.
* @example
* Snap.widgets.camera.getHeight("widget-id");
* @namespace Snap.widgets.camera
* @memberof Snap.widgets
* @type {object}
*/
camera: {
/**
* Get widget alignment (flex CSS)
* @memberof Snap.widgets.camera
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function (id) {
var element = document.querySelector('.alignment-wrapper-' + id);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.camera
* @param {string} id Widget Id
* @returns {number}
*/
getHeight: function (id) {
var element = document.getElementById(id);
return element.offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.camera
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function (id) {
var element = document.querySelector('#item-' + id);
return element.offsetWidth;
},
/**
* Get widget border style
* @memberof Snap.widgets.camera
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.camera
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.camera
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.camera
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderRadius;
},
/**
* Get widget padding
* @memberof Snap.widgets.camera
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function (id, position) {
var computedStyle = getComputedStyle(
document.querySelector('.' + appModelIdDataGenyIdMap[id] + '-padding')
),
value = '';
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.camera
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function (id, position) {
var computedStyle = getComputedStyle(
document.querySelector('.' + appModelIdDataGenyIdMap[id] + '-padding')
),
value = '';
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
},
}
,
/**
* This namespace provides access to the properties of the Barcode widget.
* @example
* Snap.widgets.barcode.getDisplayText("widget-id");
* @namespace Snap.widgets.barcode
* @memberof Snap.widgets
* @type {object}
*/
barcode: {
/**
* Get display text value of barcode (placeholder)
* @memberof Snap.widgets.barcode
* @param {string} id Widget Id
* @returns {string}
*/
getDisplayText: function(id) {
var element = document.querySelector("."+appModelIdDataGenyIdMap[id]+" .ui-input-btn");
return element.textContent;
},
/**
* Set display text value of barcode (placeholder)
* @memberof Snap.widgets.barcode
* @param {string} id Widget Id
* @param {string} value Display Text
*/
setDisplayText: function(id, value) {
var element = document.querySelector("."+appModelIdDataGenyIdMap[id]+" .ui-input-btn");
element.childNodes[0].textContent = value;
},
/**
* Get text alignment
* @memberof Snap.widgets.barcode
* @param {string} id Widget Id
* @returns {string}
*/
getTextAlignment: function(id) {
// var element = document.getElementById(id);
return getComputedStyle(document.querySelector("#item-" + appModelIdDataGenyIdMap[id]+ " .ui-input-btn")).textAlign;
},
/**
* Get font size
* @memberof Snap.widgets.barcode
* @param {string} id Widget Id
* @returns {string}
*/
getFontSize: function(id) {
return getComputedStyle(document.querySelector("#item-" + appModelIdDataGenyIdMap[id]+ " .ui-input-btn")).fontSize;
},
/**
* Get font color
* @memberof Snap.widgets.barcode
* @param {string} id Widget Id
* @returns {string}
*/
getFontColor: function(id) {
return getComputedStyle(document.querySelector("#item-" + appModelIdDataGenyIdMap[id]+ " .ui-input-btn")).color;
},
/**
* Get font style
* @memberof Snap.widgets.barcode
* @param {string} id Widget Id
* @returns {string} fontStyle, fontWeight, textDecorationLine
*/
getFontStyle: function(id) {
var computedStyle = getComputedStyle(document.querySelector("#item-" + appModelIdDataGenyIdMap[id]+ " .ui-input-btn"));
return {
fontStyle: computedStyle.fontStyle,
fontWeight: computedStyle.fontWeight,
textDecorationLine: computedStyle.textDecorationLine
};
}
,
/**
* Get widget alignment
* @memberof Snap.widgets.barcode
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function(id) {
var id = document.getElementById(id),
dataGenyId = id.getAttribute('data-geny'),
element = document.querySelector('.alignment-wrapper-' + dataGenyId);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.barcode
* @param {string} id Widget Id
* @returns {number}
*/
getHeight: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.barcode
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetWidth;
},
/**
* Get widget border style
* @memberof Snap.widgets.barcode
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.barcode
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.barcode
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.barcode
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderRadius;
},
/**
* Get widget padding
* @memberof Snap.widgets.barcode
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.' + dataGenyId + '-padding'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.barcode
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.'+dataGenyId+'-margin'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
}
}
,
/**
* This namespace provides access to the properties of the Signature widget.
* @example
* Snap.widgets.signature.getDisplayText("widget-id");
* @namespace Snap.widgets.signature
* @memberof Snap.widgets
* @type {object}
*/
signature: {
/**
* Get display text value of signature
* @memberof Snap.widgets.signature
* @param {string} id Widget Id
* @returns {string}
*/
getDisplayText: function(id) {
var element = document.getElementById(id);
return element.innerText;
},
/**
* Set display text value of signature
* @memberof Snap.widgets.signature
* @param {string} id Widget Id
* @param {string} value Display Text
*/
setDisplayText: function(id, value) {
var element = document.getElementById(id);
element.innerText = value;
}
,
/**
* Get font size
* @memberof Snap.widgets.signature
* @param {string} id Widget Id
* @returns {string}
*/
getFontSize: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).fontSize;
},
/**
* Get font color
* @memberof Snap.widgets.signature
* @param {string} id Widget Id
* @returns {string}
*/
getFontColor: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).color;
},
/**
* Get font style
* @memberof Snap.widgets.signature
* @param {string} id Widget Id
* @returns {string} fontStyle, fontWeight, textDecorationLine
*/
getFontStyle: function(id) {
var element = document.getElementById(id),
computedStyle = getComputedStyle(element);
return {
fontStyle: computedStyle.fontStyle,
fontWeight: computedStyle.fontWeight,
textDecorationLine: computedStyle.textDecorationLine
};
},
/**
* Get text alignment
* @memberof Snap.widgets.signature
* @param {string} id Widget Id
* @returns {string}
*/
getTextAlignment: function(id) {
var element = document.getElementById(id);
return getComputedStyle(element).textAlign;
},
/**
* Get widget alignment
* @memberof Snap.widgets.signature
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function(id) {
var id = document.getElementById(id),
dataGenyId = id.getAttribute('data-geny'),
element = document.querySelector('.alignment-wrapper-' + dataGenyId);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.signature
* @param {string} id Widget Id
* @returns {number}
*/
getHeight: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.signature
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetWidth;
},
/**
* Get widget border style
* @memberof Snap.widgets.signature
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.signature
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.signature
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.signature
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderRadius;
},
/**
* Get widget padding
* @memberof Snap.widgets.signature
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.' + dataGenyId + '-padding'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.signature
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.'+dataGenyId+'-margin'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
}
}
,
/**
* This namespace provides access to the properties of the Audio widget.
* @example
* Snap.widgets.audio.getDisplayText("widget-id");
* @namespace Snap.widgets.audio
* @memberof Snap.widgets
* @type {object}
*/
audio: {
/**
* Get display text value of audio
* @memberof Snap.widgets.audio
* @param {string} id Widget Id
* @returns {string}
*/
getDisplayText: function(id) {
var element = document.querySelector('#' + id + ' .displayText');
return element.innerText;
},
/**
* Set display text value of audio
* @memberof Snap.widgets.audio
* @param {string} id Widget Id
* @param {string} value Display Text
*/
setDisplayText: function(id, value) {
var element = document.querySelector('#' + id + ' .displayText');
element.innerText = value;
},
/**
* Get font size
* @memberof Snap.widgets.audio
* @param {string} id Widget Id
* @returns {string}
*/
getFontSize: function(id) {
var element = document.querySelector('#' + id + ' .displayText');
return getComputedStyle(element).fontSize;
},
/**
* Get font color
* @memberof Snap.widgets.audio
* @param {string} id Widget Id
* @returns {string}
*/
getFontColor: function(id) {
var element = document.querySelector('#' + id + ' .displayText');
return getComputedStyle(element).color;
},
/**
* Get font style
* @memberof Snap.widgets.audio
* @param {string} id Widget Id
* @returns {string} fontStyle, fontWeight, textDecorationLine
*/
getFontStyle: function(id) {
var element = document.querySelector('#' + id + ' .displayText'),
computedStyle = getComputedStyle(element);
return {
fontStyle: computedStyle.fontStyle,
fontWeight: computedStyle.fontWeight,
textDecorationLine: computedStyle.textDecorationLine
};
},
/**
* Get text alignment
* @memberof Snap.widgets.audio
* @param {string} id Widget Id
* @returns {string}
*/
getTextAlignment: function(id) {
// var element = document.getElementById(id);
return getComputedStyle(document.querySelector('#' + id + ' .displayText')).textAlign;
}
,
/**
* Get widget alignment
* @memberof Snap.widgets.audio
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function(id) {
var id = document.getElementById(id),
dataGenyId = id.getAttribute('data-geny'),
element = document.querySelector('.alignment-wrapper-' + dataGenyId);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.audio
* @param {string} id Widget Id
* @returns {number}
*/
getHeight: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.audio
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetWidth;
},
/**
* Get widget border style
* @memberof Snap.widgets.audio
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.audio
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.audio
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.audio
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderRadius;
},
/**
* Get widget padding
* @memberof Snap.widgets.audio
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.' + dataGenyId + '-padding'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.audio
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.'+dataGenyId+'-margin'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
}
}
,
/**
* This namespace provides access to the properties of the Image widget.
* @example
* Snap.widgets.image.getHeight("widget-id");
* @namespace Snap.widgets.image
* @memberof Snap.widgets
* @type {object}
*/
image: {
/**
* Get widget alignment
* @memberof Snap.widgets.image
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function (id) {
var id = document.getElementById(id),
dataGenyId = id.getAttribute('data-geny'),
element = document.querySelector('.alignment-wrapper-' + dataGenyId);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.image
* @param {string} id Widget Id
* @returns {string}
*/
getHeight: function (id) {
var element = document.getElementById(id);
return element.offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.image
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function (id) {
var element = document.querySelector('#item-' + id);
return element.offsetWidth;
},
/**
* Get widget border style
* @memberof Snap.widgets.image
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector('.' + dataGenyId + 'border'))
.borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.image
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.image
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.image
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderRadius;
},
/**
* Get widget padding
* @memberof Snap.widgets.image
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function (id, position) {
var element = document.querySelector('#' + id + ' img'),
computedStyle = getComputedStyle(element),
value = '';
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.image
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function (id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.' + dataGenyId + '-margin'),
computedStyle = getComputedStyle(element),
value = '';
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
},
}
,
/**
* This namespace provides access to the properties of the YouTube widget.
* @example
* Snap.widgets.youtube.getHeight("widget-id");
* @namespace Snap.widgets.youtube
* @memberof Snap.widgets
* @type {object}
*/
youtube: {
/**
* Get widget height
* @memberof Snap.widgets.youtube
* @param {string} id Widget Id
* @returns {number}
*/
getHeight: function (id) {
var element = document.querySelector('#item-' + id + ' .controller');
return parseInt(getComputedStyle(element).height, 10);
},
/**
* Get widget width
* @memberof Snap.widgets.youtube
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function (id) {
var element = document.querySelector('#item-' + id);
return element.offsetWidth;
},
/**
* Get widget border style
* @memberof Snap.widgets.youtube
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.youtube
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.youtube
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.youtube
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderRadius;
},
/**
* Get widget padding
* @memberof Snap.widgets.youtube
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function (id, position) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny'),
computedStyle = getComputedStyle(
document.querySelector('.' + dataGenyId + '-padding')
),
value = '';
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.youtube
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function (id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.' + dataGenyId + '-margin'),
computedStyle = getComputedStyle(element),
value = '';
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
},
}
,
/**
* This namespace provides access to the properties of the NFC widget.
* @example
* Snap.widgets.nfc.getHeight("widget-id");
* @namespace Snap.widgets.nfc
* @memberof Snap.widgets
* @type {object}
*/
nfc: {
/**
* Get display text value of nfc
* @memberof Snap.widgets.nfc
* @param {string} id Widget Id
* @returns {string}
*/
getDisplayText: function (id) {
var element = document.getElementById(id);
return element.innerText;
},
/**
* Set display text value of nfc
* @memberof Snap.widgets.nfc
* @param {string} id Widget Id
* @param {string} value Display Text
*/
setDisplayText: function (id, value) {
var element = document.getElementById(id);
element.innerText = value;
},
/**
* Get font size
* @memberof Snap.widgets.nfc
* @param {string} id Widget Id
* @returns {string}
*/
getFontSize: function (id) {
var element = document.getElementById(id);
return getComputedStyle(element).fontSize;
},
/**
* Get font color
* @memberof Snap.widgets.nfc
* @param {string} id Widget Id
* @returns {string}
*/
getFontColor: function (id) {
var element = document.getElementById(id);
return getComputedStyle(element).color;
},
/**
* Get font style
* @memberof Snap.widgets.nfc
* @param {string} id Widget Id
* @returns {string} fontStyle, fontWeight, textDecorationLine
*/
getFontStyle: function (id) {
var element = document.getElementById(id),
computedStyle = getComputedStyle(element);
return {
fontStyle: computedStyle.fontStyle,
fontWeight: computedStyle.fontWeight,
textDecorationLine: computedStyle.textDecorationLine,
};
},
/**
* Get text alignment (flex CSS)
* @memberof Snap.widgets.nfc
* @param {string} id Widget Id
* @returns {string}
*/
getTextAlignment: function (id) {
var element = document.getElementById(id);
return getComputedStyle(element).textAlign;
},
/**
* Get widget alignment
* @memberof Snap.widgets.nfc
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function (id) {
var dataGenyId = document
.getElementById(id)
.getAttribute('parent-ctrl-id')
.split('-')[1];
element = document.querySelector('.alignment-wrapper-' + dataGenyId);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.nfc
* @param {string} id Widget Id
* @returns {number}
*/
getHeight: function (id) {
var element = document.getElementById(appModelIdDataGenyIdMap[id]);
return element.offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.nfc
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function (id) {
var element = document.getElementById(appModelIdDataGenyIdMap[id]);
return element.offsetWidth;
},
/**
* Get widget border style
* @memberof Snap.widgets.nfc
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function (id) {
return getComputedStyle(
document.querySelector('.' + appModelIdDataGenyIdMap[id] + '-border')
).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.nfc
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function (id) {
return getComputedStyle(
document.querySelector('.' + appModelIdDataGenyIdMap[id] + '-border')
).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.nfc
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function (id) {
return getComputedStyle(
document.querySelector('.' + appModelIdDataGenyIdMap[id] + '-border')
).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.nfc
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function (id) {
return getComputedStyle(
document.querySelector('.' + appModelIdDataGenyIdMap[id] + '-border')
).borderRadius;
},
/**
* Get widget padding
* @memberof Snap.widgets.nfc
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function (id, position) {
var element = document.querySelector(
'#' + appModelIdDataGenyIdMap[id] + ' .ui-controlgroup-controls'
),
computedStyle = getComputedStyle(element),
value = '';
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.nfc
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function (id, position) {
var element = document.querySelector(
'.' + appModelIdDataGenyIdMap[id] + '-margin'
),
computedStyle = getComputedStyle(element),
value = '';
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
},
}
,
/**
* This namespace provides access to the properties of the Map widget.
* @example
* Snap.widgets.map.getHeight("widget-id");
* @namespace Snap.widgets.map
* @memberof Snap.widgets
* @type {object}
*/
map: {
/**
* Get widget alignment (flex CSS)
* @memberof Snap.widgets.map
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function (id) {
var id = document.getElementById(id),
dataGenyId = id.getAttribute('data-geny'),
element = document.querySelector('.alignment-wrapper-' + dataGenyId);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.map
* @param {string} id Widget Id
* @returns {number}
*/
getHeight: function (id) {
var element = document.getElementById(id);
return element.offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.map
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function (id) {
var element = document.querySelector('#item-' + id);
return element.offsetWidth;
},
/**
* Get widget border style
* @memberof Snap.widgets.map
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.map
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.map
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.map
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderRadius;
},
/**
* Get widget padding
* @memberof Snap.widgets.map
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function (id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.' + dataGenyId + '-padding'),
computedStyle = getComputedStyle(element),
value = '';
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.map
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function (id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.' + dataGenyId + '-margin'),
computedStyle = getComputedStyle(element),
value = '';
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
},
}
,
/**
* This namespace provides access to the properties of the Link widget.
* @example
* Snap.widgets.link.getHeight("widget-id");
* @namespace Snap.widgets.link
* @memberof Snap.widgets
* @type {object}
*/
link: {
/**
* Get widget alignment
* @memberof Snap.widgets.link
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function (id) {
var id = document.getElementById(id),
dataGenyId = id.getAttribute('data-geny'),
element = document.querySelector('.alignment-wrapper-' + dataGenyId);
return getComputedStyle(element).justifyContent;
},
/**
* Get font size
* @memberof Snap.widgets.link
* @param {string} id Widget Id
* @returns {string}
*/
getFontSize: function (id) {
var element = document.querySelector('#' + id + ' a');
return getComputedStyle(element).fontSize;
},
/**
* Get font color
* @memberof Snap.widgets.link
* @param {string} id Widget Id
* @returns {string}
*/
getFontColor: function (id) {
var element = document.querySelector('#' + id + ' a');
return getComputedStyle(element).color;
},
/**
* Get font style
* @memberof Snap.widgets.link
* @param {string} id Widget Id
* @returns {string} fontStyle, fontWeight, textDecorationLine
*/
getFontStyle: function (id) {
var element = document.querySelector('#' + id + ' a'),
computedStyle = getComputedStyle(element);
return {
fontStyle: computedStyle.fontStyle,
fontWeight: computedStyle.fontWeight,
textDecorationLine: computedStyle.textDecorationLine,
};
},
/**
* Get text alignment
* @memberof Snap.widgets.link
* @param {string} id Widget Id
* @returns {string}
*/
getTextAlignment: function (id) {
var element = document.querySelector('#' + id + ' a');
return getComputedStyle(element).textAlign;
},
/**
* Get widget border style
* @memberof Snap.widgets.link
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.link
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.link
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.link
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderRadius;
},
/**
* Get widget padding
* @memberof Snap.widgets.link
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function (id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.' + dataGenyId + '-padding'),
computedStyle = getComputedStyle(element),
value = '';
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.link
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function (id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.' + dataGenyId + '-margin'),
computedStyle = getComputedStyle(element),
value = '';
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
},
}
,
/**
* This namespace provides access to the properties of the List widget.
* @example
* Snap.widgets.list.getHeight("widget-id");
* @namespace Snap.widgets.list
* @memberof Snap.widgets
* @type {object}
*/
list: {
/**
* Get font size
* @memberof Snap.widgets.list
* @param {string} id Widget Id
* @returns {string}
*/
getFontSize: function (id) {
var element = document.getElementById(id);
return getComputedStyle(element).fontSize;
},
/**
* Get font color
* @memberof Snap.widgets.list
* @param {string} id Widget Id
* @returns {string}
*/
getFontColor: function (id) {
var element = document.getElementById(id);
return getComputedStyle(element).color;
},
/**
* Get font style
* @memberof Snap.widgets.list
* @param {string} id Widget Id
* @returns {string} fontStyle, fontWeight, textDecorationLine
*/
getFontStyle: function (id) {
var element = document.getElementById(id),
computedStyle = getComputedStyle(element);
return {
fontStyle: computedStyle.fontStyle,
fontWeight: computedStyle.fontWeight,
textDecorationLine: computedStyle.textDecorationLine,
};
},
/**
* Get text alignment (flex CSS)
* @memberof Snap.widgets.list
* @param {string} id Widget Id
* @returns {string}
*/
getTextAlignment: function (id) {
var element = document.getElementById(id);
return getComputedStyle(element).textAlign;
},
/**
* Get widget alignment
* @memberof Snap.widgets.list
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function (id) {
var id = document.getElementById(id),
dataGenyId = id.getAttribute('data-geny'),
element = document.querySelector('.alignment-wrapper-' + dataGenyId);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.list
* @param {string} id Widget Id
* @returns {number}
*/
getHeight: function (id) {
var element = document.getElementById(id);
return element.offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.list
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function (id) {
var element = document.querySelector('#item-' + id);
return element.offsetWidth;
},
/**
* Get widget border style
* @memberof Snap.widgets.list
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector('.' + dataGenyId + 'border'))
.borderStyle;
},
/**
* Get widget border width
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.list
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.list
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(
document.querySelector('.' + dataGenyId + '-border')
).borderRadius;
},
/**
* Get widget padding
* @memberof Snap.widgets.list
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function (id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.' + dataGenyId + '-padding'),
computedStyle = getComputedStyle(element),
value = '';
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.list
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function (id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.' + dataGenyId + '-margin'),
computedStyle = getComputedStyle(element),
value = '';
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
},
}
,
/**
* This namespace provides access to the properties of the File Upload widget.
* @example
* Snap.widgets.fileupload.getDisplayText("widget-id");
* @namespace Snap.widgets.fileupload
* @memberof Snap.widgets
* @type {object}
*/
fileupload: {
/**
* Get display text value of fileupload
* @memberof Snap.widgets.fileupload
* @param {string} id Widget Id
* @returns {string}
*/
getDisplayText: function(id) {
var element = document.querySelector('#' + id + ' .upload-trigger .ui-input-btn');
return element.innerText;
},
/**
* Set display text value of fileupload
* @memberof Snap.widgets.fileupload
* @param {string} id Widget Id
* @param {string} value Display Text
*/
setDisplayText: function(id, value) {
var element = document.querySelector('#' + id + ' .upload-trigger .ui-input-btn');
element.innerText = value;
},
/**
* Get font size
* @memberof Snap.widgets.fileupload
* @param {string} id Widget Id
* @returns {string}
*/
getFontSize: function(id) {
var element = document.querySelector('#' + id + ' .upload-trigger .ui-input-btn');
return getComputedStyle(element).fontSize;
},
/**
* Get font color
* @memberof Snap.widgets.fileupload
* @param {string} id Widget Id
* @returns {string}
*/
getFontColor: function(id) {
var element = document.querySelector('#' + id + ' .upload-trigger .ui-input-btn');
return getComputedStyle(element).color;
},
/**
* Get font style
* @memberof Snap.widgets.fileupload
* @param {string} id Widget Id
* @returns {string} fontStyle, fontWeight, textDecorationLine
*/
getFontStyle: function(id) {
var element = document.querySelector('#' + id + ' .upload-trigger .ui-input-btn'),
computedStyle = getComputedStyle(element);
return {
fontStyle: computedStyle.fontStyle,
fontWeight: computedStyle.fontWeight,
textDecorationLine: computedStyle.textDecorationLine
};
}
,
/**
* Get widget alignment
* @memberof Snap.widgets.fileupload
* @param {string} id Widget Id
* @returns {string}
*/
getWidgetAlignment: function(id) {
var id = document.getElementById(id),
dataGenyId = id.getAttribute('data-geny'),
element = document.querySelector('.alignment-wrapper-' + dataGenyId);
return getComputedStyle(element).justifyContent;
},
/**
* Get widget height
* @memberof Snap.widgets.fileupload
* @param {string} id Widget Id
* @returns {number}
*/
getHeight: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetHeight;
},
/**
* Get widget width
* @memberof Snap.widgets.fileupload
* @param {string} id Widget Id
* @returns {number}
*/
getWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return document.querySelector("#item-"+dataGenyId).offsetWidth;
},
/**
* Get widget border style
* @memberof Snap.widgets.fileupload
* @param {string} id Widget Id
* @returns {string}
*/
getBorderStyle: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderStyle;
},
/**
* Get widget border width
* @memberof Snap.widgets.fileupload
* @param {string} id Widget Id
* @returns {string}
*/
getBorderWidth: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderWidth;
},
/**
* Get widget border color
* @memberof Snap.widgets.fileupload
* @param {string} id Widget Id
* @returns {string}
*/
getBorderColor: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderColor;
},
/**
* Get widget border radius
* @memberof Snap.widgets.fileupload
* @param {string} id Widget Id
* @returns {string}
*/
getBorderRadius: function(id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny');
return getComputedStyle(document.querySelector("." + dataGenyId + "-border")).borderRadius;
},
/**
* Get widget padding
* @memberof Snap.widgets.fileupload
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getPadding: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.' + dataGenyId + '-padding'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.paddingLeft;
break;
case 'right':
value = computedStyle.paddingRight;
break;
case 'top':
value = computedStyle.paddingTop;
break;
case 'bottom':
value = computedStyle.paddingBottom;
break;
case 'all':
value = computedStyle.padding;
break;
default:
value = computedStyle.padding;
break;
}
return value;
},
/**
* Get widget margin
* @memberof Snap.widgets.fileupload
* @param {string} id Widget Id
* @param {string} position 'left', 'right', 'top', 'bottom', 'all' - if value not defined it will return all
* @returns {string}
*/
getMargin: function(id, position) {
var dataGenyId = document.getElementById(id).getAttribute('data-geny'),
element = document.querySelector('.'+dataGenyId+'-margin'),
computedStyle = getComputedStyle(element), value = "";
switch (position) {
case 'left':
value = computedStyle.marginLeft;
break;
case 'right':
value = computedStyle.marginRight;
break;
case 'top':
value = computedStyle.marginTop;
break;
case 'bottom':
value = computedStyle.marginBottom;
break;
case 'all':
value = computedStyle.margin;
break;
default:
value = computedStyle.margin;
break;
}
return value;
}
}
,
},
/**
* This namespace provides access to the properties of the various form screens in the SOTI Snap app.
* @example
* Snap.forms.getActivePageId();
* @namespace Snap.forms
* @memberof Snap
* @type {object}
*/
forms: {
/**
* Get active page ID
* @memberof Snap.forms
* @returns {string}
*/
getActivePageId: function () {
return document.querySelector(
"[data-geny-id='" + UtilityModule.getActiveScreenDataGenyId() + "']"
).id;
},
/**
* Get active page title
* @memberof Snap.forms
* @returns {string}
*/
getActivePageTitle: function () {
return appWidgetConfigurations[UtilityModule.getActiveScreenDataGenyId()]
.widgetConfiguration.displayName;
},
/**
* Set active page title
* @memberof Snap.forms
* @param {string} value
*/
setActivePageTitle: function (value) {
var pageDataGeny = UtilityModule.getActiveScreenDataGenyId();
appWidgetConfigurations[
pageDataGeny
].widgetConfiguration.displayName = value;
pageModule.updatePageNameOnHeader(pageDataGeny);
},
/**
* Submit active form
* @memberof Snap.forms
*/
submitActiveForm: function () {
try {
var pageDataGeny = UtilityModule.getActiveScreenDataGenyId(),
formDataGeny = appWidgetMetaData[pageDataGeny].formDataGenyId;
executeEvent('Save', formDataGeny, pageDataGeny);
} catch (error) {
console.log(error);
}
},
/**
* Reset active form
* @memberof Snap.forms
*/
resetActiveForm: function () {
try {
var pageDataGeny = UtilityModule.getActiveScreenDataGenyId(),
formDataGeny = appWidgetMetaData[pageDataGeny].formDataGenyId;
executeEvent('ResetForm', formDataGeny, pageDataGeny);
} catch (error) {
console.log(error);
}
},
}
,
/**
* This namespace provides access to navigation properties to facilitate movement between SOTI Snap app screens.
* @example
* Snap.navigation.navigateTo();
* @namespace Snap.navigation
* @memberof Snap
* @type {object}
*/
navigation: {
/**
* Navigate to page
* @memberof Snap.navigation
* @param {string} id Page or Screen Id
*/
navigateTo: function (id) {
var element = document.getElementById(id),
dataGenyId = element.getAttribute('data-geny-id');
new navigateEventService().executeNavigate(dataGenyId);
},
}
,
/**
* This namespace provides access to the properties of app environment variables.
* @example
* Snap.variables.getValue("variable-name");
* @namespace Snap.variables
* @memberof Snap
* @type {object}
*/
variables: {
/**
* Get variable value
* @memberof Snap.variables
* @param {string} name Variable Name
* @returns {string} Value
*/
getValue: function (name) {
return environmentVariableModule.getVariableValueByName(name);
},
/**
* Set variable value
* @memberof Snap.variables
* @param {string} name Variable Name
* @param {string} value Variable Value
*/
setValue: function (name, value) {
environmentVariableModule.setVariableValueByName(name, value);
},
}
,
};