Current Path : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/entity-editor/js/ |
Current File : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/entity-editor/js/tool-panel.min.js |
BX.namespace("BX.UI");if(typeof BX.UI.EntityEditorToolPanel==="undefined"){BX.UI.EntityEditorToolPanel=function(){this._id="";this._settings={};this._container=null;this._wrapper=null;this._editor=null;this._isVisible=false;this._isLocked=false;this._hasLayout=false;this._keyPressHandler=BX.delegate(this.onKeyPress,this);this._customButtons={};this._buttonsOrder={VIEW:[],EDIT:[BX.UI.EntityEditorActionIds.defaultActionId,BX.UI.EntityEditorActionIds.cancelActionId]}};BX.UI.EntityEditorToolPanel.prototype={initialize:function(t,e){this._id=BX.type.isNotEmptyString(t)?t:BX.util.getRandomString(4);this._settings=e?e:{};this._container=BX.prop.getElementNode(this._settings,"container",null);this._editor=BX.prop.get(this._settings,"editor",null);this._isVisible=BX.prop.getBoolean(this._settings,"visible",false);var i=BX.prop.getArray(this._settings,"customButtons",[]);for(var o=0,n=i.length;o<n;o++){var s=i[o];this._customButtons[s.ID]=this.createCustomButton(s)}var r=BX.prop.getObject(this._settings,"buttonsOrder",{});var a=BX.prop.getArray(r,"EDIT",[]);var d=BX.prop.getArray(r,"VIEW",[]);if(a.length>0||d.length>0){this._buttonsOrder=r}this.attachToEditorEvents()},attachToEditorEvents:function(){BX.addCustomEvent(this._editor.eventsNamespace+":onControlModeChange",BX.delegate((function(t,e){if(t!==this._editor||!e.control){return}var i=e.control;if(i.getMode()===BX.UI.EntityEditorMode.edit){this.showEditModeButtons()}else{this.showViewModeButtons()}}),this));BX.addCustomEvent(this._editor.eventsNamespace+":onControlChange",BX.delegate((function(t){if(t!==this._editor){return}this.showEditModeButtons()}),this));BX.addCustomEvent(this._editor.eventsNamespace+":onControllerChange",BX.delegate((function(t){if(t!==this._editor){return}this.showEditModeButtons()}),this));BX.addCustomEvent(this._editor.eventsNamespace+":onSwitchToViewMode",BX.delegate((function(t){if(t!==this._editor){return}this.showViewModeButtons()}),this));BX.addCustomEvent(this._editor.eventsNamespace+":onNothingChanged",BX.delegate((function(t){if(t!==this._editor){return}this.showViewModeButtons()}),this))},showEditModeButtons:function(){var t=BX.prop.getArray(this._buttonsOrder,"EDIT",[]);if(t.length>0){if(this._viewModeSectionControl){BX.hide(this._viewModeSectionControl)}if(this._editModeSectionControl){BX.show(this._editModeSectionControl)}}},showViewModeButtons:function(){var t=BX.prop.getArray(this._buttonsOrder,"VIEW",[]);if(t.length>0){if(this._editModeSectionControl){BX.hide(this._editModeSectionControl)}if(this._viewModeSectionControl){BX.show(this._viewModeSectionControl)}}},getId:function(){return this._id},getContainer:function(){return this._container},setContainer:function(t){this._container=t},isVisible:function(){return this._isVisible},setVisible:function(t){t=!!t;if(this._isVisible===t){return}this._isVisible=t;this.adjustLayout()},isLocked:function(){return this._isLocked},setLocked:function(t){t=!!t;if(this._isLocked===t){return}this._isLocked=t;var e=this._editButton;if(this._clickedButton){e=this._clickedButton}if(e){if(t){BX.addClass(e,"ui-btn-clock")}else{BX.removeClass(e,"ui-btn-clock")}}},disableSaveButton:function(){if(!this._editButton){return}var t=[this._editButton];var e=this;Object.keys(this._customButtons).forEach((function(i){if(e._buttonsOrder.EDIT.includes(i)){t.push(e._customButtons[i])}}));t.forEach((function(t){t.disabled=true;BX.addClass(t,"ui-btn-disabled")}));BX.onCustomEvent(window,"onEntityEditorToolbarSaveButtonDisabled",[this])},enableSaveButton:function(){if(!this._editButton){return}var t=[this._editButton];var e=this;Object.keys(this._customButtons).forEach((function(i){if(e._buttonsOrder.EDIT.includes(i)){t.push(e._customButtons[i])}}));t.forEach((function(t){t.disabled=false;BX.removeClass(t,"ui-btn-disabled")}));BX.onCustomEvent(window,"onEntityEditorToolbarSaveButtonEnabled",[this])},isSaveButtonEnabled:function(){return this._editButton&&!this._editButton.disabled},layout:function(){this._editButton=BX.create("button",{props:{className:"ui-btn ui-btn-success",title:"[Ctrl+Enter]"},text:BX.message("UI_ENTITY_EDITOR_SAVE"),events:{click:BX.delegate(this.onSaveButtonClick,this)}});this._cancelButton=BX.create("a",{props:{className:"ui-btn ui-btn-link",title:"[Esc]"},text:BX.message("UI_ENTITY_EDITOR_CANCEL"),attrs:{href:"#"},events:{click:BX.delegate(this.onCancelButtonClick,this)}});this._errorContainer=BX.create("DIV",{props:{className:"ui-entity-section-control-error-block"}});this._errorContainer.style.maxHeight="0";var t=[];var e=BX.prop.getArray(this._buttonsOrder,"EDIT",[]);var i=BX.prop.getArray(this._buttonsOrder,"VIEW",[]);if(e.length>0||i.length>0){var o=[];var n=[];for(var s=0,r=e.length;s<r;s++){if(e[s]===BX.UI.EntityEditorActionIds.defaultActionId){o.push(this._editButton)}else if(e[s]===BX.UI.EntityEditorActionIds.cancelActionId){o.push(this._cancelButton)}else if(this._customButtons[e[s]]){o.push(this._customButtons[e[s]])}}for(var s=0,r=i.length;s<r;s++){if(i[s]===BX.UI.EntityEditorActionIds.defaultActionId){n.push(this._editButton)}else if(i[s]===BX.UI.EntityEditorActionIds.cancelActionId){n.push(this._cancelButton)}else if(this._customButtons[i[s]]){n.push(this._customButtons[i[s]])}}this._editModeSectionControl=BX.create("DIV",{props:{className:"ui-entity-section ui-entity-section-control-edit-mode"},children:o});this._viewModeSectionControl=BX.create("DIV",{props:{className:"ui-entity-section ui-entity-section-control-view-mode"},children:n});if(this._editor.getMode()===BX.UI.EntityEditorMode.edit){this.showEditModeButtons()}else{this.showViewModeButtons()}t=[this._editModeSectionControl,this._viewModeSectionControl,this._errorContainer]}else{t=[this._editButton,this._cancelButton,this._errorContainer]}this._wrapper=BX.create("DIV",{props:{className:"ui-entity-wrap"},children:[BX.create("DIV",{props:{className:"ui-entity-section ui-entity-section-control"},children:t})]});this._container.appendChild(this._wrapper);this._hasLayout=true;this.adjustLayout()},adjustLayout:function(){if(!this._hasLayout){return}if(!this._isVisible){BX.removeClass(this._wrapper,"crm-section-control-active");BX.unbind(document,"keydown",this._keyPressHandler)}else{BX.addClass(this._wrapper,"crm-section-control-active");BX.bind(document,"keydown",this._keyPressHandler)}},createCustomButton:function(t){var e=t.ACTION_ID;var i="ui-btn";if(t.CLASS){i+=" "+t.CLASS}return BX.create("button",{props:{className:i,id:"ui-entity-section-control-"+t.ID},text:BX.util.htmlspecialchars(t.TEXT),events:{click:BX.delegate(this.onCustomButtonClick,this)},dataset:{actionId:e}})},getPosition:function(){return this._hasLayout?BX.pos(this._wrapper):null}};BX.UI.EntityEditorToolPanel.prototype.onSaveButtonClick=function(t){this._clickedButton=t.target;if(!this._isLocked){this._editor.saveChanged()}};BX.UI.EntityEditorToolPanel.prototype.onCustomButtonClick=function(t){this._clickedButton=t.target;if(!this._isLocked){this._editor.performAction(this._clickedButton.dataset.actionId)}};BX.UI.EntityEditorToolPanel.prototype.onCancelButtonClick=function(t){if(!this._isLocked){this._editor.cancel()}return BX.eventReturnFalse(t)};BX.UI.EntityEditorToolPanel.prototype.onKeyPress=function(t){if(!this._isVisible){return}if(BX.type.isFunction(BX.PopupWindowManager.isAnyPopupShown)&&BX.PopupWindowManager.isAnyPopupShown()){return}t=t||window.event;if(t.keyCode==27){this._editor.cancel();BX.eventCancelBubble(t)}else if(t.keyCode==13&&t.ctrlKey){this._editor.saveChanged();BX.eventCancelBubble(t)}};BX.UI.EntityEditorToolPanel.prototype.addError=function(t){if(BX.Type.isStringFilled(t)){t=t.replace(/(<br(( *)\/)?>)/gi,"<br>").split("<br>").map((function(t){return BX.Text.encode(t)})).join("<br>")}this._errorContainer.appendChild(BX.create("DIV",{attrs:{className:"ui-entity-section-control-error-text"},html:t}));this._errorContainer.style.maxHeight=""};BX.UI.EntityEditorToolPanel.prototype.clearErrors=function(){this._errorContainer.innerHTML="";this._errorContainer.style.maxHeight="0"};BX.UI.EntityEditorToolPanel.prototype.getMessage=function(t){var e=BX.UI.EntityEditorToolPanel.messages;return e.hasOwnProperty(t)?e[t]:t};if(typeof BX.UI.EntityEditorToolPanel.messages==="undefined"){BX.UI.EntityEditorToolPanel.messages={}}BX.UI.EntityEditorToolPanel.create=function(t,e){var i=new BX.UI.EntityEditorToolPanel;i.initialize(t,e);return i}} //# sourceMappingURL=tool-panel.map.js