forked from 365CSI/iCSR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicsr.min.js
1 lines (1 loc) · 9.43 KB
/
icsr.min.js
1
Type.registerNamespace("iCSR"),function(e,t,n){function o(e){return"string"==typeof e}function r(e,t){return"object"==typeof e?e.hasOwnProperty(t):o(e)&&t.length>0?e.indexOf(t)>-1:0}function i(e,t){return o(e)?e.split(t||","):"object"==typeof e?Object.keys(e):[]}function a(e,t,n){i(n||t).map(function(n){r(t,n)&&(e[n]=t[n])})}function l(e,t,n){return e?(t=t||this,i(e,"|").map(function(e){return n=t[e],e===s&&(n=!!n),Array.isArray(n)&&(n=n.join("")),r(n,"|")?l(n,t):n||e}).join("")):void 0}var s="$edit";n.Template=function(u,c,d){var m={$Styles:[{outerdiv:"<div class='|$CSSid|' style='background:|color|;color:|contrast|'> |value| |$colortag|</div>",CSS:[".|$CSSid|{}"]}],$groupheader:0,$grid:0,msYellow:"#FFB700",msRed:"#F02401",msBlue:"#219DFD",msGreen:"#77BC00",colortag:"TD"};m[s]=!0,a(m,d),m.output=m.$Styles[0].outerdiv,n[u]=function(d,p,f){if(r(d,"wpq")){var g,A={},S=A.Name=p.Name,v=f.ID;return a(A,m),a(A,this!==p&&this!==e?this:{}),A.value=r(f,S)?f[S]:f[p.RealFieldName],a(A,{valuenr:A.value.match(/\d+/)/1,days:GetDaysAfterToday(new Date(A.value)),$CSSid:u,id:u+v,ID:v,Item:f}),A.valuenr?A.label=i(A.value," ")[1]:A.label=A.value,SP.SOD.executeFunc("sp.js","SP.ClientContext",function(){SP.PageContextInfo.get_webPermMasks().has(SP.PermissionKind.editListItems)||(A[s]=0)}),d.inGridMode&&!A.$grid||r(f,S+".COUNT")&&A.$groupheader?A.value:window.view===d.view?A.value:(A.$replace=l.bind(A),A.colors||(A.colors="msRed|,|msYellow|,|msBlue|,|msGreen"),o(A.colors)&&(A.colors=i(l(A.colors,A))),A.style=A.$Styles[A.style||0],g=t.getElementById(A.id),g&&g.parentNode.removeChild(g),g=t.createElement("STYLE"),g.id=A.id,t.head.appendChild(g),A.style.CSS.map(function(e){try{e=l(e,A),g.sheet.insertRule(e,0)}catch(t){}}),c.call(A,d),o(A.color)||(A.color=A.colors[A.color]),A.color===A.msRed&&(A.contrast="beige"),A.$colortag="<img onload=iCSR.$up(this,'|colortag|').style.background='|color|' src=data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7>",A.output=A.$replace(A.output),A.output)}return n[u].bind(d)}},n.$up=function(e,t){for(;e.tagName!==t;)e=e.parentNode;return e},n.$update=function(e,t,o,i){n.$up(e,"TD").innerHTML="saving...",PreventDefaultNavigation();var a=new SP.ClientContext.get_current,l=a.get_web().get_lists().getById(SP.ListOperation.Selection.getSelectedList()).getItemById(t);l.set_item(o,i),l.update(),n.$X=1,a.executeQueryAsync(function(){n.$X=0,ctx.skipNextAnimation=1,AJAXRefreshView({currentCtx:ctx,csrAjaxRefresh:!0},1)},function(){n.$X=0;var e,i=arguments[1],a=i.get_errorCode()/-1,l={2130575162:"Validation",2130575339:"Version"};e=r(l,a)?l[a]:i.get_message(),SP.UI.Status.addStatus("Update",String.format(e+" conflict ({0}) {1}",t,o))})},n.Me=function(e){SP.SOD.executeFunc("clienttemplates.js","SPClientTemplates",function(){function t(t){"function"==typeof e[t]&&e[t].call(this,ctx)}function n(){a(o.Templates,e,"View,Body,Group,Item,Header,Footer,Fields"),SPClientTemplates.TemplateManager.RegisterTemplateOverrides(o)}var o={OnPreRender:function(){t("OnPreRender")},Templates:{},OnPostRender:function(){t("OnPostRender")}};RegisterModuleInit(SPClientRenderer.ReplaceUrlTokens(e.file),n),n()})}}(window,document,iCSR);iCSR.Template("DueDate",function(){var e=this,i=e.days;for(isNaN(i)&&(e.output="<div onclick=\"iCSR.$update(this,'|ID|','|Name|',new Date())\" >|nodate|</div>"),e.colornr=0;e.range[e.colornr]<i;)e.colornr++;e.color=e.colors[e.colornr],e.absdays=Math.abs(i),0>i?e.label=e.past:0===i?(e.absdays="",e.label=e.today):i>0&&(e.label=e.future)},{colors:"|msRed|,#f7a,#fab,#fda,#cf9,|msGreen|",range:[-21,-14,-7,0,7],nodate:"No Date",today:"today",next:"next day",prev:"previous day",future:"|absdays| days left",past:"|absdays| days past",width:"145px",$clck:"<DIV onclick=\"var d=new Date('|value|');d.setDate(d.getDate()",$SPUpdate:"iCSR.$update(this,'|ID|','|Name|',new Date(d))\"",$pick:"<DIV class=|$CSSid|dayset>|$clck|-1);|$SPUpdate|>|prev|</DIV>|$clck|+1);|$SPUpdate| class=|$CSSid|tom>|next|</DIV></DIV>",$date:"<DIV style=float:left>|label|</DIV><DIV style=float:right>|value|</DIV>",$Styles:[{outerdiv:"<div class=|$CSSid| style=color:|contrast|;width:|width|>|$colortag|$date|$pick|</div>",CSS:[".|$CSSid|>DIV{position:relative}",".|$CSSid|dayset{top:-6px}",".|$CSSid|dayset>DIV{position:absolute;width:60%;opacity:0}",".|$CSSid|tom{right:0;text-align:right}",".|$CSSid|dayset>DIV:hover{opacity:1;cursor:pointer}"]}]}),iCSR.Template("Priority",function(){var e=this,i=0,t=e.choices.map(function(t,o){return e.nr=String(o),e.choice=t,e.priocolor=e.colors[o],e.textcolor=e.textcolors[o],e.value===t?(i=o,e.classname=e.$CSSidactive,e.color=e.priocolor,e.priolabel=e.label):(e.classname=e.$CSSidchoice,e.priolabel=" "),e.$edit||(e.classname+=" NonInteractive"),e.$replace(e.style.item)});e.$edit&&t[i].indexOf("click")>-1?e.choices=t:e.choices=t[i]},{choices:["(1) High","(2) Normal","(3) Low"],colors:"|msRed|,|msYellow|,|msGreen|",colortag:"DIV",textcolors:["beige","inherit","grey"],width:"110px",height:"20px",widthactive:"50%",widthchoice:"10px",fontsize:"11px",$SPUpdate:"iCSR.$update(this,'|ID|','|Name|'",$clk:"onclick=\"|$SPUpdate|,'|choice|');\"",$CSSid:"iCSRprio",$CSSidactive:"|$CSSid|_Current",$CSSidchoice:"|$CSSid|_Choice",image:"default",$Styles:[{outerdiv:"<div class='|$CSSid| |$CSSid||$edit| |$CSSid||Item.Status|'>|choices|</div>",item:'<div class="|classname| |$CSSid|" style="background:|priocolor|;color:|textcolor|" |$clk|>|priolabel|</div>',CSS:[".|$CSSid|false {width:auto}",".|$CSSid|true {width:|width|}",".|$CSSid|Completed {opacity:.2;zoom:.7}",".|$CSSid|Not {opacity:.7;zoom:.9}",".|$CSSid||$edit|>div {position:relative;float:left;display:inline;border:1px solid grey;font-size:|fontsize|;padding:1px}",".|$CSSidactive|{width:|widthactive|;text-align:center}",".|$CSSidactive|.NonInteractive {width:100%;display:block}",".|$CSSidchoice|{width:|widthchoice|;opacity:.4}",".|$CSSidchoice|:hover {opacity:1;cursor:pointer;border-color:black}"]},{outerdiv:"<div class='|$CSSid| |$CSSid||$edit| |$CSSid||Item.Status|'>|choices|$colortag|</div>",item:'<span class="|classname|" style="background:|priocolor|" |$clk|> |priolabel| </span>',CSS:[".|$CSSid|{}",".|$CSSid||$edit|>div {position:relative;float:left}",".|$CSSidactive|{width:|widthactive|;text-align:center;padding:2px}",".|$CSSidchoice|{opacity:.4}",".|$CSSidchoice|:hover {opacity:1;cursor:pointer;border-color:black}",".|$CSSidactive|.NonInteractive {width:100%;display:block}"]},{outerdiv:"<div class='|$CSSid|'>|choices|</div>",CSS:[".|$CSSid|{height:|height|}",".|$CSSidactive|.NonInteractive {width:100%;display:block}",".|$CSSidchoice|{width:|widthchoice|;opacity:.4}",".|$CSSidchoice|:hover {opacity:1;cursor:pointer;border-color:black}"],item:'<span class="|classname|" |$clk|><img src="/_layouts/images/kpi|image|-|nr|.gif"></span>'}]}),iCSR.Template("PercentComplete",function(){var e=this,i=10*Math.floor(e.valuenr/10),t=[100,90,80,70,60,50,40,30,20,10];e.bars=t.map(function(t,o){return e.nr=String(o),e.percentage=t,e.label=t,e.barclass="past",e.percent=t/100,t>e.valuenr?e.barclass="new":t===i&&(e.barclass="current"),e.barclass+="|$CSSid|",e.$replace(e.style.item)}),e.valuenr>0&&(e.percent=0,e.bars.push("<div class='reset|$CSSid|' |$clk|>|reset|</div>")),e.percent=String(e.percent)},{$grid:!0,colors:"pink",background:"lightgrey",scalecolor:"grey",scalesize:"75%",color:"|msBlue|",textcolor:"beige",hovercolor:"beige",hoverbarcolor:"green",percentsign:"<span style='display:inline-block;text-align:right;font-size:70%'> %</span>",rangecolor:"blue",labelcolor:"inherit",reset:"reset to 0",rangelabel:"<span style='color:|labelcolor|;display:inline-block;text-align:right;width:20px'>|valuenr|</span>|percentsign|",onchange:'onchange="|$SPUpdate|,this.value/100" ',oninput:'oninput="this.nextSibling.innerHTML=this.value;" ',width:"160px",height:"15px",CSSinset:"border-radius:1px;box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25) inset",$CSSid:"iCSRbar",$SPUpdate:"iCSR.$update(this,'|ID|','|Name|'",$clk:"onclick=\"|$SPUpdate|,'|percent|')\" ",$Styles:[{outerdiv:"<div class='|$CSSid|'>|bars|</div>",item:"<div class='|barclass|' style='width:|percentage|%' |$clk|>|label|</div>",CSS:[".|$CSSid|{width:|width|;height:|height|;position:relative;float:left;background:|background|}",".|$CSSid|{font-family:arial;font-size:11px;color:|scalecolor|}",".|$CSSid|>div {position:absolute;text-align:right;font-size:|scalesize|;height:100%}",".|$CSSid|>div {border-right:1px solid #aaa}",".|$CSSid|>div:not(.current|$CSSid|):hover{color:|hovercolor|;font-size:100%;background:|hoverbarcolor|;z-index:4;;opacity:.8;cursor:pointer}",".|$CSSid|>div:not(.current|$CSSid|):hover:before{content:'>>';font-weight:bold}",".|$CSSid|>div:hover:after,.|$CSSid| .current|$CSSid|:after{content:'%'}",".|$CSSid| .current|$CSSid|{font-size:100%;z-index:3}",".|$CSSid| .current|$CSSid|{background:|color|;color:|textcolor|;|CSSinset|}",".|$CSSid| .reset|$CSSid|{z-index:3;width:10%;height:|height|;overflow:hidden;border-right:0px;color:transparent;padding:0 3px}",".|$CSSid| .reset|$CSSid|:hover{width:auto}"]}]}),iCSR.Template("Status",function(){var e=this;e.color=e.colors[e.value],"Waiting on someone else"===e.value&&(e.value="Waiting"),e.value=e.value.replace(/ /gi," ")},{colors:{"Not Started":"|msBlue|",Deferred:"|msBlue|","Waiting on someone else":"|msYellow|","In Progress":"|msYellow|",Completed:"|msGreen|"},width:"20px",fontsize:"11px",height:"15px",$CSSid:"iCSRstatus",$Styles:[{outerdiv:"<div class='|$CSSid|' style='background:|color|'> |value| </div>",CSS:[".|$CSSid|{font-size:|fontsize|;height:|height|;text-align:center;padding:2px 1px 2px 1px}"]}]});