cef1259c0d3d7212742288875339bcbe8e6fd5847f33daf96eb0fa4e570c7ef2

Source Code:

mcWeb.attributeSelector=new function(n){"use strict";ko.bindingHandlers.inOut={init:function(t,i,r,u,f){ko.bindingHandlers.html.init(t,i,r,u,f);n(t).hide()},update:function(t,i,r,u,f){ko.bindingHandlers.html.update(t,i,r,u,f);u.AttributesModified&&(n(t).fadeIn(1500),window.setTimeout(function(){n(t).fadeOut(1500)},1500))}};this.vm=function(t){var i=this;i.id="#"+t;i.service=new WebApiService("Attribute");i.ChooseText=ko.observable("");i.ChooseValueText=ko.observable("");i.Attributes=ko.observableArray();i.AttributeValues=ko.observableArray();i.AttributeId=ko.observable();i.AttributeValueId=ko.observable();i.UsageArea=0;i.UserKey="";i.UsageKey="";i.InstanceKey="";i.InitialAttributeId=null;i.InitialAttributeValueId=null;i.UseSetupId=!1;i.AttributeValueWasSaved=ko.observable(0);i.AttributeWasSaved=ko.observable(0);i.AttributeSavedText="";i.AttributeNotSavedText="";i.AttributeValueSavedText="";i.AttributeValueNotSavedText="";i.AttributesModified=!1;this.addNewAttribute=function(t,r,u){var f={UsageArea:t,UsageName:r,UserKey:u,OnlyRenderNewAttribute:!0};i.service.PostAction("RenderAttributeTagger",f).done(function(t){if(t!=null&&t.length>0&&t.Success){var i=n("attribute-selector-add-attribute-button");i.before(t.Response)}})};this.load=function(n,t){t==null||n&&n!=null||(i.UserKey=t.UserKey,i.UsageArea=t.UsageArea,i.UsageName=t.UsageName,i.InstanceKey=t.InstanceKey,i.ChooseText(t.SelectText),i.ChooseValueText(t.SelectValueText),i.InitialAttributeId=t.AttributeId,i.InitialAttributeValueId=t.AttributeValueId,i.UseSetupId=t.UseSetupId,i.AttributeSavedText=t.AttributeSavedText,i.AttributeNotSavedText=t.AttributeNotSavedText,i.AttributeValueSavedText=t.AttributeValueSavedText,i.AttributeValueNotSavedText=t.AttributeValueNotSavedText,n={AttributeId:t.AttributeId,UserKey:i.UserKey,UsageArea:i.UsageArea,UsageName:i.UsageName,InstanceKey:i.InstanceKey,UseSetupId:i.UseSetupId},i.service.GetAction("ListAllAttributes",n).done(function(n){n!=null&&n.Attributes.length>0&&(i.Attributes(n.Attributes),i.AttributeId(t.AttributeId))}))};i.removeAttribute=function(){var n={AttributeId:null,AttributeValueId:null,UserKey:i.UserKey,UsageArea:i.UsageArea,UsageName:i.UsageName,InstanceKey:i.InstanceKey,UseSetupId:i.UseSetupId};i.service.PostAction("SaveSelectedAttribute",n).done(function(t){i.AttributesModified=!0;t&&t.Success?(i.InitialAttributeId=n.AttributeId,i.InitialAttributeValueId=null,i.AttributeWasSaved(""),i.AttributeWasSaved(i.AttributeSavedText),t.FieldId>0&&mcWeb.ajaxRenderEngine.replaceField(t.FieldId,t.NodeId,t.IsEdm)):i.AttributeWasSaved(0);var r=jQuery(i.id),u=r.next("script");jQuery(u).remove();jQuery(r).remove()})};i.AttributeId.subscribe(function(n){var r=!1,u,t;(i.InitialAttributeId!=0&&i.InitialAttributeId!=null&&(u=i.AttributeValues(),(u==null||u==undefined||u.length<=0)&&(r=!0)),r||n!=i.InitialAttributeId&&(n!=undefined||i.InitialAttributeId!=null))&&(t={AttributeId:n,AttributeValueId:null,UserKey:i.UserKey,UsageArea:i.UsageArea,UsageName:i.UsageName,InstanceKey:i.InstanceKey,UseSetupId:i.UseSetupId},r&&(t.AttributeValueId=i.InitialAttributeValueId),t.AttributeId==undefined&&(t.AttributeId=null),i.service.GetAction("ListAllAttributeValues",t).done(function(n){n.AttributeValues!=null&&n.AttributeValues.length>0&&i.AttributeValues(n.AttributeValues);r&&i.AttributeValueId(i.InitialAttributeValueId);r||i.service.PostAction("SaveSelectedAttribute",t).done(function(n){i.AttributesModified=!0;n&&n.Success?(i.InitialAttributeId=t.AttributeId,i.InitialAttributeValueId=null,i.AttributeWasSaved(""),i.AttributeWasSaved(i.AttributeSavedText),n.FieldId>0&&mcWeb.ajaxRenderEngine.replaceField(n.FieldId,n.NodeId,n.IsEdm)):i.AttributeWasSaved(0)})}))});i.AttributeValueId.subscribe(function(n){if(n!=i.InitialAttributeValueId&&(n!=undefined||i.InitialAttributeValueId!=null)){var t={AttributeId:i.AttributeId(),AttributeValueId:n,UserKey:i.UserKey,UsageArea:i.UsageArea,UsageName:i.UsageName,InstanceKey:i.InstanceKey,UseSetupId:i.UseSetupId};t.AttributeValueId==undefined&&(t.AttributeValueId=null);i.service.PostAction("SaveSelectedAttribute",t).done(function(n){i.AttributesModified=!0;n&&n.Success?(i.InitialAttributeId=t.AttributeId,i.InitialAttributeValueId=t.AttributeValueId,i.AttributeWasSaved(""),i.AttributeWasSaved(i.AttributeValueSavedText),n.FieldId>0&&mcWeb.ajaxRenderEngine.replaceField(n.FieldId,n.NodeId,n.IsEdm)):i.AttributeWasSaved(0)})}})}}(jQuery)