4 lines
11 KiB
JavaScript
4 lines
11 KiB
JavaScript
(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[1536],{12525:()=>{},41235:()=>{},4502:()=>{},42845:(t,s,e)=>{"use strict";e.d(s,{default:()=>h});var i=e(20497),o=(e(41235),e(23127)),n=e(13398);const a=e(98125).getLogger("Ui.TvControlCheckbox"),l={labelWrapper:'{{#hasLabel}}<label>{{#labelLeft}}<span class="tv-control-checkbox__label {{#labelAddClass}}{{labelAddClass}}{{/labelAddClass}}">{{labelLeft}}</span>{{/labelLeft}}{{> inputWrapper }}{{#labelRight}}<span class="tv-control-checkbox__label {{#labelAddClass}}{{labelAddClass}}{{/labelAddClass}}">{{labelRight}}</span>{{/labelRight}}</label>{{/hasLabel}}{{^hasLabel}}{{> inputWrapper }}{{/hasLabel}}',inputWrapper:'<{{ tag }} class="{{ customClass }}{{#disabled}} i-disabled{{/disabled}}">{{^hasCheckbox}}{{> checkbox }}{{/hasCheckbox}}{{> box }}{{> ripple }}</{{ tag }}>',checkbox:'<input{{#id}} id="{{ id }}"{{/id}} class="{{> checkboxClass }}" type="checkbox"{{#name}} name="{{ name }}"{{/name}}{{#checked}} checked{{/checked}}{{#disabled}} disabled{{/disabled}}>',checkboxClass:"{{ customClass }}__input",box:'<span class="{{ customClass }}__box {{#boxAddClass}}{{boxAddClass}}{{/boxAddClass}}">'+e(4135)+"</span>",ripple:'<span class="{{ customClass }}__ripple js-ripple"></span>'};class d{constructor({customClass:t="tv-control-checkbox",$checkbox:s,tag:e,id:i,name:n,checked:l,disabled:d,labelLeft:h,labelRight:c,labelAddClass:r,boxAddClass:u}){this.$el=null,void 0===e&&(e=h||c?"span":"label");const p=s instanceof o&&!!s.length;if(p){if(!s.is("input[type=checkbox]"))return void a.logError("`$checkbox` need to be input[type=checkbox]");if(s.hasClass("i-inited"))return;this._setInputId(s,i),this._setInputClass(s,t),this._setInputName(s,n),this._setInputChecked(s,l),this._setInputDisabled(s,d),l=!!s.prop("checked"),d=!!s.attr("disabled")}this.$el=this.render({$checkbox:s,hasCheckbox:p,customClass:t,tag:e,id:i,name:n,checked:l,disabled:d,labelLeft:h,labelRight:c,hasLabel:h||c,labelAddClass:r,boxAddClass:u}),this.$checkbox=p?s:this.$el.find("input[type=checkbox]")}_setInputId(t,s){void 0!==s&&t.attr("id",s)}_setInputClass(t,s){const e=n.render(l.checkboxClass,{customClass:s});t.addClass(e)}_setInputName(t,s){void 0!==s&&t.attr("name",s)}_setInputChecked(t,s){void 0!==s&&t.prop("checked",!!s)}_setInputDisabled(t,s){void 0!==s&&(s?t.setAttribute("disabled","disabled"):t.removeAttr("disabled"))}render(t){const s=t.$checkbox,e=o(n.render(l.labelWrapper,t,l));if(t.hasCheckbox){e.insertBefore(s);e.find("."+t.customClass).andSelf().filter("."+t.customClass).eq(0).prepend(s.detach()),s.addClass("i-inited")}return e}set checked(t){this._setInputChecked(this.$checkbox,!!t)}get checked(){return!!this.$checkbox.prop("checked")}}o.fn.tvControlCheckbox=(0,i.createTvBlockWithInstance)("tv-control-checkbox",(function(t,s={}){return new d(TradingView.mergeObj(s,{$checkbox:t}))}));const h=d},51536:(t,s,e)=>{"use strict";e.d(s,{TVDialogAbstract:()=>m});var i=e(32563),o=e(68587),n=(e(78754),e(42845)),a=(e(4502),e(12525),e(52014),
|
|
e(85459)),l=e.n(a),d=e(88216),h=e(23127),c=e(13398),r=e(25977);let u,p=0,b=[];const g=h(document),f={closeOnEsc:!0,closeButton:!0,focusFirstControl:!0,closeOnOutsideClick:!0,closeButtonAddClass:"",focusClass:"i-focused",template:'<div class="tv-dialog" tabindex="-1">',errorTemplate:'<div class="tv-dialog__error i-slided{{# errorMod }} tv-dialog__error--{{ errorMod }}{{/ errorMod }}">{{{ error }}}</div>',titleTemplate:'<div class="tv-dialog__section tv-dialog__section--title js-dialog__drag"><div class="js-title-text tv-dialog__title">{{{ title }}}</div></div>',contentWrapTemplate:'<div class="tv-dialog__section tv-dialog__section--no-border">',actionsWrapTemplate:'<div class="tv-dialog__section tv-dialog__section--actions tv-dialog__section--no-border">',closeButtonTemplate:`<div class="tv-dialog__close js-dialog__close">${e(49370)}</div>`,helpButtonTemplate:'<a href="{{{ link }}}" target="_blank" class="tv-dialog__help apply-common-tooltip" title="{{{ title }}}"></a>',helpActionsMod:"tv-dialog__section--actions_with-help"},v={default:"tv-button tv-button--default",primary:"tv-button tv-button--primary",success:"tv-button tv-button--success",danger:"tv-button tv-button--danger",warning:"tv-button tv-button--warning",link:"tv-button tv-button--link",checkbox:"tv-control-checkbox tv-control-checkbox--in-actions","default-ghost":"tv-button tv-button--default_ghost","primary-ghost":"tv-button tv-button--primary_ghost","success-ghost":"tv-button tv-button--success_ghost","danger-ghost":"tv-button tv-button--danger_ghost","warning-ghost":"tv-button tv-button--warning_ghost"},_={_default:'<div data-name="{{ name }}" class="js-dialog__action-click js-dialog__no-drag {{ class }}">{{ text }}</div>',"submit-primary":'<button type="submit" class="tv-button tv-button--primary">{{ text }}</button>',"submit-success":'<button type="submit" class="tv-button tv-button--success">{{ text }}</button>'};class m extends(l()){constructor(t={}){if(super(),this.manager=t.manager||(0,d.getRootOverlapManager)(t.ownerDocument),this._id=p++,this.loadingActions=[],this.disabledActions=[],this.firstFocusControl=null,this.options={...f,...t},this.$el=h(c.render(this.options.template,{title:this.options.title,closeButton:this.options.closeButton})),this.$el.addClass("js-dialog"),this.el=this.$el[0],this.options.dataset)for(const[t,s]of Object.entries(this.options.dataset))"string"==typeof s&&this.el.setAttribute("data-"+t,s);for(this.options.addClass&&this.$el.addClass(this.options.addClass),this.options.width&&this.$el.css({width:"100%","max-width":this.options.width}),this.on("beforeOpen",()=>{this.$wrap=this.manager.ensureWindow(this._id)}),this.on("afterClose",()=>{this.$wrap=null,this.manager.unregisterWindow(this._id)}),this.options.title&&(this.$title=h(c.render(this.options.titleTemplate,{title:this.options.title})).appendTo(this.$el)),this.$content=h(this.options.contentWrapTemplate).appendTo(this.$el),this.$contentIn=this.$content;this.$contentIn.length;)this.$contentIn=this.$contentIn.children();if(this.$contentIn=this.$contentIn.end(),
|
|
this.options.content&&this.renderContent(this.options.content),(this.options.actions||this.options.help)&&(this.$content.hasClass("tv-dialog__section")&&this.$content.addClass("tv-dialog__section--no-padding_bottom"),this.$actions=h(this.options.actionsWrapTemplate).appendTo(this.$el)),this.options.actions){this.actions={},this.$el.on("click",".js-dialog__action-click",t=>{t.preventDefault(),this.actionDispatcher(h(t.currentTarget).data("name"))});for(let t=this.options.actions.length-1;t>=0;t--){const s=this.options.actions[t];if(s.type||(s.type="default"),s.class||(s.class=v[s.type]?v[s.type]:v.default),"checkbox"===s.type){const t=new n.default({labelRight:s.text,name:s.name,checked:s.checked});this.actions[s.name]=t.$el.appendTo(this.$actions),this.actions[s.name].on("change",()=>{setTimeout(()=>this.actionDispatcher(s.name,t.checked))})}else this.actions[s.name]=h(c.render(s.template?s.template:_[s.type]||_._default,s,s)).appendTo(this.$actions);if(s.method&&"function"==typeof this[s.method]&&this.on("action:"+s.name,this[s.method].bind(this)),s.addClass&&this.actions[s.name].addClass(s.addClass),s.key)if("string"==typeof s.key&&s.key.split("+").length>1){let t=[];const e=s.key.split("+"),i=s=>{t=[]},o=i=>{const o=""+i.keyCode;-1!==e.indexOf(o)&&t.indexOf(o)&&t.push(o),this._focused&&t.length===e.length&&(t=[],this.actionDispatcher(s.name))};this.on("afterOpen",()=>{g.on("keydown",o),g.on("keyup",i)}),this.on("beforeClose",()=>{g.off("keydown",o),g.off("keyup",i)})}else{const t=h.isArray(s.key)?s.key:[s.key],e=e=>{!e.isDefaultPrevented()&&this._focused&&-1!==t.indexOf(e.keyCode)&&this.actionDispatcher(s.name)};this.on("afterOpen",()=>g.on("keydown",e)),this.on("beforeClose",()=>g.off("keydown",e))}}}if(this.options.help&&h(c.render(this.options.helpButtonTemplate,this.options.help)).prependTo(this.$actions.addClass(this.options.helpActionsMod)),this.options.closeButton){const t=h(this.options.closeButtonTemplate);t.addClass(this.options.closeButtonAddClass||"");let s=this.$el;1===this.$el.find(".js-close-button-place").length&&(s=this.$el.find(".js-close-button-place")),t.appendTo(s)}this.setZIndex(110+b.length),t.errorMod&&(this.errorMod=t.errorMod),this.on("afterOpen",()=>{this.$el.focus(),this.options.focusFirstControl&&!i.mobiletouch&&(this.firstFocusControl||this.$el.find('input:not([type="hidden"]), textarea').first()).focus()}),this.$el.on("click",".js-dialog__close",this.close.bind(this)),this.$el.on("mousedown touchstart",this.focus.bind(this)),b.push(this)}renderContent(t){return this.$contentIn.html("function"==typeof t?t(this):t),this}setDestroyOnClose(t){this.options.destroyOnClose=t}setZIndex(t){return this.zIndex=t,this.trigger("change:zIndex",[this]),this}toTop(){for(let t=b.length-1;t>=0;t--)b[t].zIndex>this.zIndex&&b[t].setZIndex(b[t].zIndex-1);return this.setZIndex(110+b.length),this.manager.moveToTop(this._id),this._hotkeys&&this._hotkeys.promote(),this}isEventOut(t){if(this.options.isClickOutFn){const s=this.options.isClickOutFn(t);if(void 0!==s)return s}let s=!0;const e=h(t.target)
|
|
;return e.get(0)!==this.$el.get(0)&&(h(">*",this.$el).each((function(){e.get(0)===h(this).get(0)&&(s=!1),0===e.closest("HTML",h(this).get(0)).length&&(s=!1)})),s)}focus(){u&&u!==this&&u.unfocus(),this._setFocused(),this._focused=!0,this.$el.addClass(this.options.focusClass),this.trigger("focus",[this]),setTimeout(()=>{g.on("mousedown.tv-dialog-unfocus-"+this._id,t=>{this.isEventOut(t)&&(this.unfocus(),g.off("mousedown.tv-dialog-unfocus-"+this._id))})},20)}_setFocused(){u!==this&&(u=this)}_setUnfocused(){u===this&&(u=void 0)}unfocus(){u===this&&(this._setUnfocused(),this._focused=!1,this.$el.removeClass(this.options.focusClass).find(":focus").blur(),this.trigger("unfocus",[this]))}isFocused(){return this._focused}setTitle(t,s=!1){return this.$title.toggleClass("tv-dialog__section--one-line apply-overflow-tooltip",s),this.$title.html(t),this}setTitleText(t){this.$title.find(".js-title-text").text(t)}actionDispatcher(t,...s){this.disabledActions.includes(t)||this.loadingActions.includes(t)||this.trigger("action:"+t,[this,...s])}toggleAction(t,s){return s||this.disabledActions.includes(t)?s&&this.disabledActions.includes(t)&&(this.disabledActions=r.without(this.disabledActions,t)):this.disabledActions.push(t),this.actions[t].toggleClass("i-disabled",!s),this}actionLoader(t,s="init"){return this.actions[t].tvButtonLoader(s),"init"===s&&(this.actions[t].off("tv-button-loader:start.dialog-action").on("tv-button-loader:start.dialog-action",()=>{this.loadingActions.push(t)}),this.actions[t].off("tv-button-loader:stop.dialog-action").on("tv-button-loader:stop.dialog-action",()=>{this.loadingActions=r.without(this.loadingActions,t)})),this}error(t){const s=h(c.render(this.options.errorTemplate,{error:t,errorMod:this.errorMod})).appendTo(this.$el);return setTimeout(()=>s.removeClass("i-slided"),20),g.one("touchstart mousedown keydown",()=>{s.addClass("i-slided"),setTimeout(()=>s.remove(),.75*o.dur)}),this.trigger("error",[this,s]),this}destroy(){this.$wrap=null,this.manager.unregisterWindow(this._id),this._hotkeys&&this._hotkeys.destroy(),b=r.without(b,this);for(let t=0;t<b.length;t++)b[t].setZIndex(110+t);this.trigger("destroy",[this])}isOpened(){return Boolean(this.opened)}getDialogId(){return this._id}}},49370:t=>{t.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13"><path fill="currentColor" d="M5.18 6.6L1.3 2.7.6 2 2 .59l.7.7 3.9 3.9 3.89-3.9.7-.7L12.61 2l-.71.7L8 6.6l3.89 3.89.7.7-1.4 1.42-.71-.71L6.58 8 2.72 11.9l-.71.7-1.41-1.4.7-.71 3.9-3.9z"/></svg>'}}]); |