%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/bitrix/www/bitrix/js/bizproc/
Upload File :
Create Path :
Current File : /home/bitrix/www/bitrix/js/bizproc/bp_selector.min.js

(function(){var e=window.BX;e.namespace("BX.Bizproc");if(e.Bizproc.Selector)return;e.Bizproc.Selector={delimiter:"=",listenKeyCode:187,currentData:{},inputElement:null,popup:null,selectedTab:null,activitiesItemsCache:null};e.Bizproc.Selector.initSelectors=function(t){if(!t)t=document;var s,i,a,r=t.querySelectorAll('[data-role="bp-selector-button"]');if(r){for(a=0;a<r.length;++a){i=JSON.parse(r[a].getAttribute("data-bp-selector-props"));if(typeof i!=="object")continue;s=document.getElementById(i.controlId);if(!s)continue;e.bind(s,"keydown",function(t){e.Bizproc.Selector.onSearch(this,t)});s.setAttribute("autocomplete","off")}}};e.Bizproc.Selector.getTabItems=function(e){var t;for(t=0;t<this.currentData.length;++t){if(this.currentData[t]["tabId"]===e)return this.currentData[t]["items"]}return[]};e.Bizproc.Selector.getActivitiesItems=function(){if(this.activitiesItemsCache===null){this.activitiesItemsCache=this.getTemplateActivitiesItems([rootActivity.Serialize()],arAllActivities)}return this.activitiesItemsCache};e.Bizproc.Selector.getTemplateActivitiesItems=function(e,t){var s=[],i,a,r,o,n;for(i=0,a=e.length;i<a;++i){r=e[i].Type.toLowerCase();if(t[r])o=t[r];if(o&&o["RETURN"]){for(n in o["RETURN"]){if(!o["RETURN"].hasOwnProperty(n))continue;s.push({text:o["RETURN"][n].NAME,description:e[i].Properties.Title||o.NAME,value:"{="+e[i].Name+":"+n+"}"})}}if(e[i].Children&&e[i].Children.length>0){var l=this.getTemplateActivitiesItems(e[i].Children,t);for(var c=0;c<l.length;++c){s.push(l[c])}}}return s};e.Bizproc.Selector.getTabsCounters=function(){var e,t={};for(e=0;e<this.currentData.length;++e){t[this.currentData[e]["tabId"]]=this.currentData[e]["items"].length}return t};e.Bizproc.Selector.getListElement=function(){return e.findChild(this.popup.contentContainer,{className:"bp-selector-list"},true)};e.Bizproc.Selector.getSelectedItem=function(){return e.findChild(this.popup.contentContainer,{className:"bp-selector-item-selected"},true)};e.Bizproc.Selector.getTabsElements=function(){return e.findChildren(this.popup.contentContainer,{className:"bp-selector-tab"},true)};e.Bizproc.Selector.closePopup=function(){if(this.popup)this.popup.close()};e.Bizproc.Selector.insertItemValue=function(e,t){var s=this.inputElement.value.substr(0,this.inputElement.selectionEnd),i=this.inputElement.value.substr(0,s.lastIndexOf(this.delimiter)),a=e.getAttribute("data-value")+(t?this.delimiter:""),r=this.inputElement.value.substr(this.inputElement.selectionEnd),o=parseInt(e.getAttribute("data-cursor-position"));if(isNaN(o))o=a.length;if(i.substr(-1)==="{")i=i.substr(0,i.length-1);this.inputElement.value=i+a+r;this.inputElement.selectionEnd=i.length+Math.max(0,o)+1};e.Bizproc.Selector.onSearch=function(t,s){var i=this,a=true;if(t.mentionListen){if(s.keyCode==27){t.mentionListen=false;this.closePopup();return e.PreventDefault(s)}else if(s.keyCode==13&&this.popup){var r=this.getSelectedItem();if(r){this.insertItemValue(r,s.shiftKey===true);if(s.shiftKey!==true)this.closePopup()}return e.PreventDefault(s)}else if((s.keyCode==37||s.keyCode==39||s.keyCode==9)&&this.popup){this.SelectNextTab(s.keyCode==37?-1:1);return e.PreventDefault(s)}else if((s.keyCode==38||s.keyCode==40)&&this.popup){this.SelectNextItem(s.keyCode==38?-1:1);return e.PreventDefault(s)}else if(s.altKey===true||s.ctrlKey===true||s.shiftKey===true&&s.keyCode==16){}else{setTimeout(e.delegate(function(){var e=this.value.substr(0,this.selectionEnd);if(e.lastIndexOf(i.delimiter)<0){i.closePopup();return false}e=e.substr(e.lastIndexOf(i.delimiter),this.selectionEnd-e.lastIndexOf(i.delimiter));if(e.length<=0){i.closePopup();return false}e=e.substr(1);if(e.substr(0,1)==" "){i.closePopup();return false}if(i.popup)i.updatePopupContent(e)},t),10)}}else if(s.shiftKey===false&&s.keyCode==i.listenKeyCode){if(!t.mentionListen){setTimeout(e.delegate(function(){var t=this.value.substr(this.selectionEnd-1,1);if(t!=i.delimiter)return false;this.mentionListen=true;i.closePopup();i.popup=new e.PopupWindow("bx-bizproc-selector",this,{lightShadow:true,offsetTop:0,closeIcon:true,offsetLeft:0,autoHide:true,bindOptions:{position:"bottom"},closeByEsc:true,zIndex:200,events:{onPopupShow:function(){e.WindowManager.currently_loaded=this;this.CloseDialog=this.Close=function(){e.WindowManager.currently_loaded=null;if(i.popup!==null){var t=e.WindowManager.Get();if(t&&!t.unclosable)t.Close()}}},onPopupClose:function(){this.destroy();setTimeout(function(){e.WindowManager.currently_loaded=null},50)},onPopupDestroy:e.delegate(function(){i.popup=null;i.activitiesItemsCache=null;this.mentionListen=false},this)},content:e.create("DIV",{children:[i.generatePopupContent()]})});i.popup.show();i.inputElement=this},t),100)}}if(!a)return e.PreventDefault(s)};e.Bizproc.Selector.extractMenuItem=function(e,t,s){var i=[];var a;for(a in t){if(!t.hasOwnProperty(a))continue;i.push({text:t[a].Name,value:"{="+s+":"+a+"}"})}return this.filterItems(i,e)};e.Bizproc.Selector.filterItems=function(t,s){var i=[],a;s=s?s.toLowerCase():"";var r=s&&e.correctText?e.correctText(s,{replace_way:"AUTO",mixed:true}).toLowerCase():"";for(a=0;a<t.length;++a){if(!s||t[a].text.toLowerCase().indexOf(s)>=0||t[a].value.toLowerCase().indexOf(s)>=0||t[a].text.toLowerCase().indexOf(r)>=0||t[a].value.toLowerCase().indexOf(r)>=0){i.push(t[a])}}return i};e.Bizproc.Selector.updateCurrentData=function(t){var s=[];if(e.util.object_keys(arWorkflowParameters).length>0)s.push({tabName:e.message("BIZPROC_JS_BP_SELECTOR_PARAMETERS"),tabId:"parameters",items:this.extractMenuItem(t,arWorkflowParameters,"Template")});if(e.util.object_keys(arWorkflowVariables).length>0)s.push({tabName:e.message("BIZPROC_JS_BP_SELECTOR_VARIABLES"),tabId:"variables",items:this.extractMenuItem(t,arWorkflowVariables,"Variable")});if(e.util.object_keys(arWorkflowConstants).length>0)s.push({tabName:e.message("BIZPROC_JS_BP_SELECTOR_CONSTANTS"),tabId:"constants",items:this.extractMenuItem(t,arWorkflowConstants,"Constant")});if(typeof arDocumentFields!=="undefined"){s.push({tabName:e.message("BIZPROC_JS_BP_SELECTOR_DOCUMENT"),tabId:"document",items:this.extractMenuItem(t,arDocumentFields,"Document")})}var i=this.getActivitiesItems();if(i.length>0)s.push({tabName:e.message("BIZPROC_JS_BP_SELECTOR_ACTIVITIES"),tabId:"activities",items:this.filterItems(i,t)});s.push({tabName:e.message("BIZPROC_JS_BP_SELECTOR_SYSTEM"),tabId:"system",items:this.filterItems([{text:e.message("BIZPROC_JS_BP_SELECTOR_WORKFLOW_ID"),value:"{=Workflow:ID}"},{text:e.message("BIZPROC_JS_BP_SELECTOR_TARGET_USER"),value:"{=Template:TargetUser}"},{text:e.message("BIZPROC_JS_BP_SELECTOR_USER_ID"),value:"{=User:ID}"},{text:e.message("BIZPROC_JS_BP_SELECTOR_NOW"),value:"{=System:Now}"},{text:e.message("BIZPROC_JS_BP_SELECTOR_NOW_LOCAL"),value:"{=System:NowLocal}"},{text:e.message("BIZPROC_JS_BP_SELECTOR_DATE"),value:"{=System:Date}"}],t)});s.push({tabName:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTIONS"),tabId:"functions",items:this.filterItems([{text:"abs",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_ABS_DESCRIPTION"),value:"{{=abs()}}"},{text:"dateadd",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_DATEADD_DESCRIPTION"),value:"{{=dateadd(,)}}"},{text:"datediff",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_DATEDIFF_DESCRIPTION"),value:"{{=datediff(,,)}}"},{text:"date",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_DATE_DESCRIPTION"),value:"{{=date(,)}}"},{text:"workdateadd",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_WORKDATEADD_DESCRIPTION"),value:"{{=workdateadd(,)}}"},{text:"addworkdays",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_ADDWORKDAYS_DESCRIPTION"),value:"{{=addworkdays(,)}}"},{text:"isworkday",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_ISWORKDAY_DESCRIPTION"),value:"{{=isworkday()}}"},{text:"isworktime",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_ISWORKTIME_DESCRIPTION"),value:"{{=isworktime()}}"},{text:"if",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_IF_DESCRIPTION"),value:"{{=if(,,)}}"},{text:"intval",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_INTVAL_DESCRIPTION"),value:"{{=intval()}}"},{text:"floatval",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_FLOATVAL_DESCRIPTION"),value:"{{=floatval()}}"},{text:"numberformat",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_NUMBER_FORMAT_DESCRIPTION"),value:"{{=numberformat(,)}}"},{text:"min",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_MIN_DESCRIPTION"),value:"{{=min(,)}}"},{text:"max",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_MAX_DESCRIPTION"),value:"{{=max(,)}}"},{text:"rand",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_RAND_DESCRIPTION"),value:"{{=rand(0,)}}"},{text:"round",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_ROUND_DESCRIPTION"),value:"{{=round(,)}}"},{text:"ceil",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_CEIL_DESCRIPTION"),value:"{{=ceil()}}"},{text:"floor",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_FLOOR_DESCRIPTION"),value:"{{=floor()}}"},{text:"substr",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_SUBSTR_DESCRIPTION"),value:"{{=substr(,,)}}"},{text:"strpos",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_STRPOS_DESCRIPTION"),value:"{{=strpos(,)}}"},{text:"strlen",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_STRLEN_DESCRIPTION"),value:"{{=strlen()}}"},{text:"randstring",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_RANDSTRING_DESCRIPTION"),value:"{{=randstring(10)}}"},{text:"merge",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_MERGE_DESCRIPTION"),value:"{{=merge(,)}}"},{text:"urlencode",description:e.message("BIZPROC_JS_BP_SELECTOR_FUNCTION_URLENCODE_DESCRIPTION"),value:"{{=urlencode()}}"}],t)});this.currentData=s;return s};e.Bizproc.Selector.generatePopupContent=function(t){var s=e.create("DIV",{attrs:{className:"bp-selector-popup"}});var i=e.create("UL",{attrs:{className:"bp-selector-tabs"}});var a=e.create("UL",{attrs:{className:"bp-selector-list"}});s.appendChild(i);s.appendChild(a);var r=this.updateCurrentData(t);var o,n,l=this;for(o=0;o<r.length;++o){n=e.create("LI",{attrs:{className:"bp-selector-tab"},html:r[o].tabName+' (<span class="counter-value">'+r[o].items.length+"</span>)"});n.setAttribute("data-tab-id",r[o].tabId);n.setAttribute("hidefocus","true");if(!this.selectedTab&&o===0||this.selectedTab==r[o].tabId){e.addClass(n,"selected");this.updateList(a,r[o].items)}e.bind(n,"click",function(t){l.selectTab(this);e.focus(l.inputElement);return e.PreventDefault(t)});i.appendChild(n)}return s};e.Bizproc.Selector.updatePopupContent=function(t){var s=this.getListElement();var i,a,r,o=this.updateCurrentData(t);var n=this.getTabsCounters();var l=this.getTabsElements();for(i=0;i<l.length;++i){a=l[i].getAttribute("data-tab-id");r=e.findChild(l[i],{className:"counter-value"});r.innerHTML=n[a]||0;if(e.hasClass(l[i],"selected")){this.updateList(s,this.getTabItems(a))}}};e.Bizproc.Selector.SelectNextTab=function(t){var s,i,a,r,o,n=this.getTabsElements();for(a=0,r=n.length;a<r;++a){s=e.hasClass(n[a],"selected");if(s&&t<0){o=a-1>=0?a-1:r-1;e.removeClass(n[a],"selected");e.addClass(n[o],"selected");i=n[o].getAttribute("data-tab-id");break}if(s&&t>0){o=a+1<=r-1?a+1:0;e.removeClass(n[a],"selected");e.addClass(n[o],"selected");i=n[o].getAttribute("data-tab-id");break}}var l=this.getListElement();this.updateList(l,this.getTabItems(i));this.selectedTab=i};e.Bizproc.Selector.selectTab=function(t){var s=this.getListElement();var i=this.getTabsElements();for(var a=0;a<i.length;++a){if(i[a]==t){e.addClass(t,"selected");this.updateList(s,this.getTabItems(t.getAttribute("data-tab-id")))}else{e.removeClass(i[a],"selected")}}this.selectedTab=t.getAttribute("data-tab-id")};e.Bizproc.Selector.SelectNextItem=function(t){var s=this.getListElement();var i,a,r,o=0,n=e.findChildren(s,{className:"bp-selector-item"},true);for(a=0,r=n.length;a<r;++a){i=e.hasClass(n[a],"bp-selector-item-selected");if(i&&t<0){o=a-1>=0?a-1:r-1;e.removeClass(n[a],"bp-selector-item-selected");e.addClass(n[o],"bp-selector-item-selected");break}if(i&&t>0){o=a+1<=r-1?a+1:0;e.removeClass(n[a],"bp-selector-item-selected");e.addClass(n[o],"bp-selector-item-selected");break}}this.fixListScroll(s,n[o])};e.Bizproc.Selector.updateList=function(t,s){e.cleanNode(t);var i,a,r,o=this;if(s.length===0){r=e.create("LI",{html:e.message("BIZPROC_JS_BP_SELECTOR_EMPTY_LIST")});e.addClass(r,"bp-selector-item-empty");t.appendChild(r)}for(i=0;i<s.length;++i){a=s[i];r=e.create("LI",{html:e.util.htmlspecialchars(a.text)+(a.description?'<span class="bp-selector-item-description"> '+e.util.htmlspecialchars(a.description)+"</span>":"")});r.setAttribute("data-value",a.value);r.setAttribute("data-cursor-position",a.value.indexOf("("));r.setAttribute("hidefocus","true");e.addClass(r,"bp-selector-item");if(i===0)e.addClass(r,"bp-selector-item-selected");e.bind(r,"click",function(t){o.insertItemValue(this,t.shiftKey===true);if(t.shiftKey!==true)o.closePopup();e.focus(o.inputElement);return e.PreventDefault(t)});t.appendChild(r)}t.scrollTop=0};e.Bizproc.Selector.fixListScroll=function(t,s){var i=e.pos(t);var a=e.pos(s);if(a.bottom>i.bottom||a.top<i.top){t.scrollTop+=a.bottom>i.bottom?a.bottom-i.bottom:a.top-i.top}}})();
//# sourceMappingURL=bp_selector.map.js

Zerion Mini Shell 1.0