| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- /**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup UnaStudio UNA Studio
- * @{
- */
- function BxDolStudioOptions(oOptions) {
- this.sActionsUrl = oOptions.sActionUrl;
- this.sObjName = oOptions.sObjName == undefined ? 'oBxDolStudioOptions' : oOptions.sObjName;
- this.sParamPrefix = oOptions.sParamPrefix == undefined ? 'opt' : oOptions.sParamPrefix;
- this.sType = oOptions.sType == undefined ? '' : oOptions.sType;
- this.sCategory = oOptions.sCategory == undefined ? '' : oOptions.sCategory;
- this.sMix = oOptions.sMix == undefined ? '' : oOptions.sMix;
- this.sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'fade' : oOptions.sAnimationEffect;
- this.iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
- this.bBusy = false;
- }
- BxDolStudioOptions.prototype.onSubmit = function(oForm) {
- if(this.bBusy)
- return false;
- var oSubmit = $(oForm).find('input[type="submit"],button[type="submit"]');
- setTimeout(() => bx_std_loading_btn(oSubmit, true), 0);
- return (this.bBusy = true);
- };
- BxDolStudioOptions.prototype.onSubmitted = function(sFormId, sTocken, oData) {
- var oForm = $('#' + sFormId);
- var oSubmit = oForm.find('input[type="submit"],button[type="submit"]');
- oForm.find('input[name="csrf_token"]').val(sTocken);
- bx_std_loading_btn(oSubmit, false);
- this.bBusy = false;
- };
- BxDolStudioOptions.prototype.import = function(oButton) {
- this.mixAction(oButton, 'import');
- };
- BxDolStudioOptions.prototype.onImport = function(oData) {
- document.location.href = document.location.href;
- };
- BxDolStudioOptions.prototype.export = function(oButton) {
- this.mixAction(oButton, 'export');
- };
- BxDolStudioOptions.prototype.onExport = function(oData) {
- document.location.href = oData.url;
- };
- BxDolStudioOptions.prototype.mixCreate = function(oButton) {
- this.mixActionWithValue(oButton, 'create-mix');
- };
- BxDolStudioOptions.prototype.onMixCreate = function(oData) {
- document.location.href = document.location.href;
- };
- BxDolStudioOptions.prototype.mixImport = function(oButton) {
- this.mixActionWithValue(oButton, 'import-mix');
- };
- BxDolStudioOptions.prototype.onMixImport = function(oData) {
- document.location.href = document.location.href;
- };
- BxDolStudioOptions.prototype.mixSelect = function(oSelect) {
- this.mixActionWithValue(oSelect, 'select-mix', $(oSelect).val());
- };
- BxDolStudioOptions.prototype.onMixSelect = function(oData) {
- document.location.href = document.location.href;
- };
- BxDolStudioOptions.prototype.mixExport = function(oButton, iId) {
- this.mixActionWithValue(oButton, 'export-mix', iId);
- };
- BxDolStudioOptions.prototype.onMixExport = function(oData) {
- document.location.href = oData.url;
- };
- BxDolStudioOptions.prototype.mixPublish = function(oButton, iId) {
- this.mixActionWithValue(oButton, 'publish-mix', iId);
- };
- BxDolStudioOptions.prototype.onMixPublish = function(oData) {
- document.location.href = document.location.href;
- };
- BxDolStudioOptions.prototype.mixHide = function(oButton, iId) {
- this.mixActionWithValue(oButton, 'hide-mix', iId);
- };
- BxDolStudioOptions.prototype.onMixHide = function(oData) {
- document.location.href = document.location.href;
- };
- BxDolStudioOptions.prototype.mixDelete = function(oButton, iId) {
- this.mixActionWithValue(oButton, 'delete-mix', iId, 1);
- };
- BxDolStudioOptions.prototype.onMixDelete = function(oData) {
- document.location.href = document.location.href;
- };
- BxDolStudioOptions.prototype.mixAction = function(oSource, sAction, bConfirm) {
- var $this = this;
- var oDate = new Date();
- var aParams = {
- type: this.sType,
- category: this.sCategory,
- _t:oDate.getTime()
- };
- aParams[this.sParamPrefix + '_action'] = sAction;
- var oPerform = function() {
- $.post(
- this.sActionsUrl,
- aParams,
- function (oData) {
- processJsonData(oData);
- },
- 'json'
- );
- };
- if(bConfirm != undefined && parseInt(bConfirm) == 1)
- bx_confirm('', oPerform);
- else
- oPerform();
- };
- BxDolStudioOptions.prototype.mixActionWithValue = function(oSource, sAction, mixedValue, bConfirm) {
- var $this = this;
- var oDate = new Date();
- var aParams = {
- type: $this.sType,
- category: $this.sCategory,
- _t:oDate.getTime()
- };
- aParams[this.sParamPrefix + '_action'] = sAction;
- aParams[this.sParamPrefix + '_value'] = mixedValue;
- var oPerform = function() {
- $.post(
- $this.sActionsUrl,
- aParams,
- function (oData) {
- processJsonData(oData)
- },
- 'json'
- );
- };
- if(bConfirm != undefined && parseInt(bConfirm) == 1)
- bx_confirm('', oPerform);
- else
- oPerform();
- };
- BxDolStudioOptions.prototype.processResult = function(oData) {
- processJsonData(oData);
- };
- /** @} */
|