Initial commit
This commit is contained in:
116
Backend/dist/Integrations/buildin/deck/actions/setbackground.js
vendored
Normal file
116
Backend/dist/Integrations/buildin/deck/actions/setbackground.js
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
||||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
||||
to[j] = from[i];
|
||||
return to;
|
||||
};
|
||||
exports.__esModule = true;
|
||||
module.exports = function (actionAPI) {
|
||||
actionAPI.handle(function (properties, status, deck) {
|
||||
if (properties.key != undefined && properties.key.length > 0) {
|
||||
if (properties.color != undefined) {
|
||||
var location = Undecked.Pages.KeyManager.getLocation(properties.key);
|
||||
if (location) {
|
||||
if (Undecked.Pages.exists(location.pageID)) {
|
||||
var page = Undecked.Pages.get(location.pageID);
|
||||
if (page.hasKey(location.x, location.y)) {
|
||||
var key = page.getKey(location.x, location.y);
|
||||
if (key.appearence == undefined)
|
||||
key.appearence = {};
|
||||
if (key.appearence.background == undefined)
|
||||
key.appearence.background = { color: null };
|
||||
key.appearence.background.color = properties.color;
|
||||
page.updateKey(location.x, location.y, key, null);
|
||||
status('Key color has been updated', 'info');
|
||||
}
|
||||
else
|
||||
status('Unable to find locaton', 'error');
|
||||
}
|
||||
else
|
||||
status('Unable to find page', 'error');
|
||||
}
|
||||
else
|
||||
status('Invalid key ID. Maybe it was removed?', 'error');
|
||||
}
|
||||
else
|
||||
status('No color specified', 'error');
|
||||
}
|
||||
else
|
||||
status('No key specified', 'error');
|
||||
});
|
||||
actionAPI.onOpenEditor(function (editorAPI, properties) {
|
||||
var lastPageState = 'current';
|
||||
var initKey = 'current';
|
||||
var initColor = properties.color != undefined ? properties.color : '#ff0000';
|
||||
if (properties.key != undefined) {
|
||||
var location = Undecked.Pages.KeyManager.getLocation(properties.key);
|
||||
if (location) {
|
||||
lastPageState = location.pageID == editorAPI.keyPageID ? 'current' : location.pageID;
|
||||
}
|
||||
initKey = properties.key == editorAPI.key.id ? 'current' : properties.key;
|
||||
}
|
||||
var fields = [
|
||||
{
|
||||
id: 'page',
|
||||
name: 'Page',
|
||||
type: 'select',
|
||||
value: lastPageState,
|
||||
values: getPageValues()
|
||||
},
|
||||
{
|
||||
id: 'key',
|
||||
name: 'Key',
|
||||
type: 'select',
|
||||
value: initKey,
|
||||
values: getPageKeyValues(lastPageState)
|
||||
},
|
||||
{
|
||||
id: 'color',
|
||||
name: 'Color',
|
||||
type: 'color',
|
||||
value: initColor
|
||||
}
|
||||
];
|
||||
editorAPI.saveProperties({
|
||||
key: initKey == 'current' ? editorAPI.key.id : initKey,
|
||||
color: initColor
|
||||
});
|
||||
editorAPI.onFieldChanges(function (changedFields) {
|
||||
var fieldObject = editorAPI.tools.objectifyFieldsValues(changedFields);
|
||||
fields[0].value = fieldObject.page;
|
||||
fields[1].value = fieldObject.key;
|
||||
fields[2].value = fieldObject.color;
|
||||
if (fieldObject.page != lastPageState) {
|
||||
fields[1].values = getPageKeyValues(fieldObject.page);
|
||||
editorAPI.setFields(fields);
|
||||
}
|
||||
editorAPI.saveProperties({
|
||||
key: fieldObject.key == 'current' ? editorAPI.key.id : fieldObject.key,
|
||||
color: fieldObject.color
|
||||
});
|
||||
});
|
||||
editorAPI.setFields(fields);
|
||||
function getPageValues() {
|
||||
return __spreadArray([
|
||||
{ id: 'current', text: 'Current Page' }
|
||||
], Undecked.Pages.getNames().map(function (page) {
|
||||
return { id: page.pageID, text: page.name };
|
||||
}));
|
||||
}
|
||||
function getPageKeyValues(pageID) {
|
||||
var values = [
|
||||
{ id: 'current', text: 'Current Key' }
|
||||
];
|
||||
if (pageID == 'current')
|
||||
pageID = editorAPI.keyPageID;
|
||||
else
|
||||
values = [];
|
||||
if (Undecked.Pages.exists(pageID))
|
||||
return __spreadArray(__spreadArray([], values), Undecked.Pages.get(pageID).getKeyTextList().map(function (key) {
|
||||
return { id: key.id, text: key.x + "," + key.y + " - " + (key.text != null ? key.text : 'Empty') };
|
||||
}));
|
||||
else
|
||||
return [];
|
||||
}
|
||||
});
|
||||
};
|
||||
//# sourceMappingURL=setbackground.js.map
|
||||
Reference in New Issue
Block a user