var CD=CD||{v:{cache:"v20120207",js:".v20120217",css:".v20120217",images:".v20120212"}};var Interface=function(c,b){if(arguments.length!=2){throw new Error("Interface constructor called with "+arguments.length+"arguments, but expected exactly 2.")}this.name=c;this.methods=[];for(var d=0,a=b.length;d<a;d++){if(typeof b[d]!=="string"){throw new Error("Interface constructor expects method names to be passed in as a string.")}this.methods.push(b[d])}};Interface.ensureImplements=function(c){if(arguments.length<2){throw new Error("Function Interface.ensureImplements called with "+arguments.length+"arguments, but expected at least 2.")}for(var e=1,a=arguments.length;e<a;e++){var d=arguments[e];if(d.constructor!==Interface){throw new Error("Function Interface.ensureImplements expects arguments two and above to be instances of Interface.")}for(var b=0,f=d.methods.length;b<f;b++){var g=d.methods[b];if(!c[g]||typeof c[g]!=="function"){throw new Error("Function Interface.ensureImplements: object does not implement the "+d.name+" interface. Method "+g+" was not found.")}}}};var ObjectSort=function(){var a={ASC:"asc",DESC:"desc",TYPE:{DATE:"date",STR:"string",NUM:"number"},sort:function(e,g,b,c,k){if(e.length===0){return e}var f,k=k||false,d=false;if(e[0] instanceof Backbone.Model){d=true}var h=function(o,m){var p,n,r,q;if(!d){if(typeof o[g]!=="function"){if(typeof o[g]=="undefined"&&typeof m[g]=="undefined"){return 0}if(typeof o[g]!="undefined"&&typeof m[g]=="undefined"){return -1}if(typeof o[g]=="undefined"&&typeof m[g]!="undefined"){return 1}p=o[g];n=m[g]}else{p=o[g]();n=m[g]()}}else{if(typeof o[g]==="function"){p=o[g]();n=m[g]()}else{p=o.get(g);n=m.get(g)}}if(typeof p==="string"){p=p.trim()}if(typeof n==="string"){n=n.trim()}if(p===null&&n===null){return 0}if(p!==null&&n===null){return -1}if(p===null&&n!==null){return 1}if(p===""&&n===""){return 0}if(p!==""&&n===""){return -1}if(p===""&&n!==""){return 1}switch(b){case a.TYPE.NUM:p=parseFloat(p);n=parseFloat(n);if(p=="NaN"&&n=="NaN"){return 0}if(p!="NaN"&&n=="NaN"){return -1}if(p=="NaN"&&n!="NaN"){return 1}break;case a.TYPE.DATE:r=p.split("/");p=r[2]+"/"+r[0]+"/"+r[1];q=n.split("/");n=q[2]+"/"+q[0]+"/"+q[1];break;case a.TYPE.STR:default:p=p.toLowerCase();n=n.toLowerCase();break}if(p<n){return(c===a.ASC?-1:1)}else{if(n<p){return(c===a.ASC?1:-1)}else{return 0}}};if(k!==false){f=e.clone();f.sort(h);return f}else{e.sort(h);return e}}};return a}();(function(){if(typeof console==="undefined"){var a;var b=null;if(window.location.hostname.match(/centraldesktop\.com$/)){a=function(){}}else{a=function(){var c=$A(arguments).join(", ");if(!b){b=document.body.appendChild(new Element("div",{"class":"debug-window"}));b.cnt=b.appendChild(new Element("div"));var d=b.appendChild(new Element("a",{"class":"debug-window-close"}));d.update("&times;");d.onclick=function(){b.cnt.update();return false}}b.cnt.insert("<xmp>"+c+"</xmp>")}}window.console={};(["log","info","warn","dir","trace","group","groupEnd"]).each(function(c){console[c]=a})}}());function extend(c,a){var b=function(){};b.prototype=a.prototype;c.prototype=new b();c.prototype.constructor=c;c.parentClass=a.prototype;if(a.prototype.constructor==Object.prototype.constructor){a.prototype.constructor=a}}var CD=CD||{};CD.Icons={};CD.www_forum="http://forum.centraldesktop.com";CD.www_helpcenter="http://help.centraldesktop.com/help";CD.wwwurl="http://www.centraldesktop.com";CD.space_url=null;CD.permissions={CONST_READ:1,CONST_EDIT:2,CONST_ADD:4,CONST_DELETE:16,CONST_ADMIN:8,CONST_MANAGER:32,canRead:function(a){if(a==0){return true}return userPermissions[a]&window.CD.permissions.CONST_READ},canEdit:function(a){if(a==0){return true}return userPermissions[a]&window.CD.permissions.CONST_EDIT},canAdd:function(a){if(a==0){return true}return userPermissions[a]&window.CD.permissions.CONST_ADD},canDelete:function(a){if(a==0){return true}return userPermissions[a]&window.CD.permissions.CONST_DELETE},isAdmin:function(a){if(a==0){return true}return userPermissions[a]&window.CD.permissions.CONST_ADMIN},canListManage:function(a){if(a==0){return true}return userPermissions[a]&window.CD.permissions.CONST_MANAGER}};CD.showException=function(b){if(dom.utils.browser.isIE()){var c="Exception thrown: \n";for(var a in b){c+=a+": "+b[a]+"\n"}alert(c)}else{console.log(c)}};CD.str_limit=function(b,a){if(b.length>a+3){return b.substr(0,a)+"..."}else{return b}};CD.evalScripts=function(elem){var scripts=elem.getElementsByTagName("script");for(var i=0;i<scripts.length;i++){var src=scripts[i].getAttribute("src");if(src!=null&&src!=""){continue}try{if(scripts[i].getAttribute("executed")!="yes"){eval(scripts[i].innerHTML)}scripts[i].setAttribute("executed","yes")}catch(err){}}};CD.getNamespace=function(b){var a="";switch(b){case CD.Wiki.item_type:a=CD.Wiki.namespace;break;case CD.Document.item_type:a=CD.Document.namespace;break;case CD.Spreadsheet.item_type:a=CD.Spreadsheet.namespace;break;case CD.File.item_type:a=CD.File.namespace;break;case CD.Bookmark.item_type:a=CD.Bookmark.namespace;break;case CD.Discussion.item_type:a=CD.Discussion.namespace;break;case CD.Forum.item_type:a=CD.Forum.namespace;break;case CD.BlogEntry.item_type:a=CD.BlogEntry.namespace;break;case CD.Diagram.item_type:a=CD.Diagram.namespace;default:throw new Error("cannot find matching namespace for item type: "+b);break}return a};CD.showAvatars=function(e,d,c){var a="/spaces/doaction_common";var b={"do":"showAvatars",spid:d,uids:c.join(","),format:"html"};new CD.Ajax.Request(a,{method:"post",parameters:b,onComplete:function(f){e.select(".avatars")[0].innerHTML=f.responseText;e.show()}},false)};window.getHashParams=function(){var e={};var d=document.location.href.split("#");if(d.length>1){var a=d[1].split(";");for(var b=0;b<a.length;b++){var c=a[b];c=c.split(":");e[c[0]]=c[1]}}return e};window.handleHashUrls=function(){params=window.getHashParams();if(typeof params.folder!="undefined"){var c=null;var a="";var b=document.location.href.match(/\/folder\/((\-)?[0-9]+)\/(view|image_gallery)?/);if(b){c=b[1];if(b[3]){a=b[3]}}if(params.folder!=c){document.location.href=cd_spaceurl+"folder/"+params.folder+"/"+a}}};window.handleHashUrls();CD.cdwm=(function(){return{close:function(b){var a=CD.TinyMCE.getWindowId(b);cdwm.close(a)}}})();CD.TinyMCE=(function(){return{getWindowId:function(b){try{var d=null;while(b=b.parentNode){if(b===document){return false}var c=b.id.match(/^mce_([0-9]+)$/);if(c){d=c[0];break}}return d}catch(a){return false}},getWindow:function(b){for(var a in cdwm.winStack){if(cdwm.winStack[a].id==b){return cdwm.winStack[a]}}return false}}})();CD.tinyMceOnChange=function(a,b){switch(a.editorId){case"custom_terms_of_service":$("tos_updated").value="true";break;case"custom_privacy_policy":$("privacy_updated").value="true";break}};CD.tinyMceCleanupCallback=function(a,b){if(dom.utils.browser.isSafari()){return b}if(!b||!b.replace){return b}b=b.replace(new RegExp("(\r|\n|\r\n)+</pre[^>]*>","gim"),"</pre>");return b};CD.tinyMceSaveCallback=function(b,c,a){if(dom.utils.browser.isSafari()){return c}if(!c||!c.replace){return c}c=c.replace(new RegExp("(\r|\n|\r\n)+</pre[^>]*>","gim"),"</pre>");return c};CD.tinyMceResizeEditor=function(c){var b=c.contentAreaContainer,a=document.forms[0],d={x:0,y:0,maxX:0,maxY:0},f,e;d.x=a.offsetLeft;d.y=a.offsetTop;d.x+=a.offsetWidth;d.y+=a.offsetHeight;if(window.innerHeight){d.maxX=window.innerWidth;d.maxY=window.innerHeight}else{f=(document.compatMode&&document.compatMode=="CSS1Compat")?document.documentElement:document.body||null;d.maxX=f.offsetWidth-4;d.maxY=f.offsetHeight-4}e=b.children[0];e.style.width=b.style.width=(b.offsetWidth+d.maxX-d.x-2)+"px";e.style.height=b.style.height=(b.offsetHeight+d.maxY-d.y-2)+"px"};function randFail(){var a=parseInt(Math.random()*10);console.log("rand: "+a);if(a%2==0){console.log("randFail is returning true");return true}else{console.log("randFail is returning false");return false}}function CD_Object(){this.namespace=null;this.displayName=null;this.activity_type=null;this.item_type=null;this.views={};this.actions={};this.validate={};this.handlers={};this.views.create=function(){console.log("CD.Object.views.create called.")};this.views.edit=function(){console.log("CD.Object.views.edit called.")};this.views.remove=function(){console.log("CD.Object.views.remove called.")};this.actions.create=function(){console.log("CD.Object.actions.create called.")};this.actions.edit=function(){console.log("CD.Object.actions.edit called.")};this.actions.remove=function(){console.log("CD.Object.actions.remove called.")};this.views.permalink=function(a){wiki_tools.show_generic_lightbox_w_url(cd_spaceurl+this.namespace+"/"+a+"/permalink/","","Permanent Link for this "+this.displayName,500,150)};this.validate.name=function(a){if(a!=null&&a!="null"&&a!=""){return true}else{alert("You must enter a valid name");return false}};this.handlers.checkEnter=function(d,c,e){var d=d&&d.which?d:window.event?window.event:null;var a;var b=true;if(window.event){a=d.keyCode}else{a=d.which}if(a==13){c(e);b=false;d.returnValue=b}return b};this.getDisplayName=function(){return this.displayName};this.getNamespace=function(){return this.namespace};this.showDialog=function(a){var b=this.showDialog.arguments;var e=new Array;for(var c=1;c<b.length&&c<this.views[a].length+1;c++){e.push(b[c])}var d=this.views[a];if(typeof d=="function"){d.apply(this,e)}};this.doAction=function(e){var a=this.doAction.arguments;var d=new Array;for(var b=1;b<a.length&&b<this.actions[e].length+1;b++){d.push(a[b])}var c=this.actions[e];if(typeof c=="function"){return c.apply(this,d)}};this.doValidation=function(){var b=this.doValidation.arguments;var a=true;var e=[];for(var c=0;c<b.length;c++){try{b[c]()}catch(d){a=false;e.push(d)}}if(!a){if(e.length){alert("Following validation errors occured:\n   -"+e.join("\n   -"))}else{alert("Validation error.")}}return a};this.handle=function(c){var a=this.handle.arguments;var e=new Array;for(var b=1;b<a.length&&b<this.handlers[c].length+1;b++){e.push(a[b])}var d=this.handlers[c];if(typeof d=="function"){d.apply(this,e)}};return this}$C(CD_Object);window.CD.Object=new CD_Object;CD.Object.getValidCatid=function(d,c){var e;try{if(CD.Environment.model.catid==undefined){throw new Exception()}e=CD.Environment.model.catid}catch(g){try{if(CD.Environment.model.item_type!=CD.Category.item_type){throw new Exception()}if(CD.Environment.model.id==undefined){throw new Exception()}e=CD.Environment.model.id}catch(b){try{var f=document.bmform;e=f.catid.value}catch(a){e=d}}}if((!e&&e!==CD.Folder.GENERAL)||e<CD.Folder.LAST_SYSTEM_FOLDER){if(c!=undefined){e=c}else{e=CD.Folder.GENERAL}}return e};CD.Company=(function(){return{sortTemplates:function(b){var c=b.form;c.included.value=Sortable.serialize("included");c.excluded.value=Sortable.serialize("excluded");var a="/spaces/wiki2_doaction?do=sortTemplates&"+c.included.value+"&"+c.excluded.value+"&r="+Math.random();new Ajax.Request(a,{method:"post",onSuccess:function(d){document.location.href=d.responseText},onFailure:function(d){document.reload()}})},showFeatureUpgradeMessage:function(a){var b;switch(a){case"feature_ws_clone":b="Cloning workspaces is an advanced feature that is only available to Enterprise Edition customers. To learn more contact your Salesrep or";b+=' <a href="/home/upgrade_account">click for more information</a>.<br /><br />';break;case"feature_ws_archived":b="Archived workspaces is an advanced feature that is only available to Enterprise Edition customers. To learn more contact your Salesrep or";b+=' <a href="/home/upgrade_account">click for more information</a>.<br /><br />';break;default:b="This feature is not available to you at this time. To learn more contact your Salesrep or";b+=' <a href="/home/upgrade_account">click for more information</a>.<br /><br />'}return cdwm.alert(b,{width:"460"})}}})();CD.Space=(function(){return{settings:{selectSection:function(c){var b=$("sectionLinks").select("a.jslink");var f=$$(".section");for(var d=0;d<b.length;d++){var h=b[d].getAttribute("rel");if(h!=c){b[d].removeClassName("jslink-selected")}else{b[d].addClassName("jslink-selected")}}for(var d=0;d<f.length;d++){var e=f[d];var a=e.getAttribute("rel");if(a==c){e.style.display=""}else{e.style.display="none"}}var g=$("space-settings-buttons");if(g){if(c=="general"){g.style.display=""}else{g.style.display="none"}}var k=$$("input[name=section]");k.each(function(m){m.value=c})}},Create:{showTypeOptions:function(f,c){var b=$(f);b.childElements().each(function(g){g.hide()});var d=b.select(".options-"+c)[0];if(d){b.show();d.show()}else{b.hide()}var e=function(h,g){g=!!g;h=""+h;$$("."+h).each(function(k){g?k.hide():k.show()});return};var a=/^clone_.*/i;if(a.test(c)){e("opts-for-from-preset",true);e("opts-for-template-clone",false)}else{e("opts-for-from-preset",false);e("opts-for-template-clone",true)}return},switchTabs:function(a,b){$$(".spc-wiz-tabs li").each(function(c){c.removeClassName("tab_selected")});$(a).up().addClassName("tab_selected");$("wizardWrapper").className=b}},remove:function(){window.doDeleteTxt="";var a=(arguments.length>0)?"&"+arguments[0]:"";cdwm.confirm('Are you sure you want to delete this Workspace <div class="m10 centered"><span class="biiigger red">'+spacename+'</span> ?</div>You cannot undo this action. <br />All your data in this Workspace will be erased.<br/><br /><span class="highlight">Type the word DELETE to delete this Workspace.</span><br/><div style="padding-top: 7px;"><input type="text" id="doDeleteTxt" name="doDeleteTxt" value="" onchange="window.doDeleteTxt = this.value;" class="w250 subject-field" /></div>',function(c){var b=window.doDeleteTxt;if(c!="true"){return false}else{if(b.toLowerCase()!="delete"){cdwm.alert("You must type the word DELETE to delete the Workspace.  \n"+spacename+" was not deleted.  Please Try Again")}else{disablesubmit("delete","Deleting...");window.location="/spaces/deletespace?spid="+spid+"&guid="+wiki_guid+"&spacename="+spacename+a}}},{height:420})},archive:function(a){if(a){cdwm.confirm("Are you sure you want to Archive this Workspace?\nArchiving the workspace will remove this workspace from everyone's navigation.\nYou can always Unarchive it if you need to.",function(b){if(b!="true"){return}disablesubmit("archive","Archiving...");window.location=xml_wd+"archive_space&archive=true&cd_fullurl="+escape(cd_fullurl)})}else{disablesubmit("archive","UnArchiving...");window.location=xml_wd+"archive_space&archive=false&cd_fullurl="+escape(cd_fullurl)}},clone:function(){var d=$("cloneDialogOriginal");d.style.left="-2000px";d.style.top="0px";d.style.width="570px";d.style.height="550px";d.style.display="";d.style.position="absolute";var c=dom.utils.stripIds(d.cloneNode(true));c.id="cloneDialog";c.style.height=dom.utils.getElementHeight(d)+"px";c.style.width=dom.utils.getElementWidth(d)+"px";c.style.left="0px";c.style.top="0px";c.style.padding="5px";var a=c.getElementsByTagName("input");for(var b=0;b<a.length;b++){if(a[b].type=="text"){a[b].value=""}}var e={title:"Clone Space",type:"dynamic",inline:true,element:c,height:550,width:600,clear:true};overlay.show(e,true)},showupgrade:function(){var a=$$("#cloneDialogOriginal > div:first-child")[0];var b=$(a.cloneNode(true));b.removeClassName("sysmessage-inline");b.addClassName("sysmessage-screentop");document.body.appendChild(b);return null}}})();CD.Environment=(function(){this.model=null;this.user=null;this.company=null;this.space=null;this.zf_uriprefix=null;this.listeners=new Array;var a=this;var b={trigger:function(){for(var d=0;d<a.listeners.length;d++){var c=a.listeners[d];var e=c.scope;var g=c.callback;try{g.call(e)}catch(f){}}},set:function(c){if(c.model&&(c.model!=null)){this.model=c.model}if(c.user&&(c.user!=null)){this.user=c.user;if(this.user.preferences instanceof Array){this.user.preferences={}}}if(c.company&&(c.company!=null)){this.company=c.company}if(c.space&&(c.space!=null)){c.space.longname=c.space.longname.replace("&59;",":");this.space=c.space}this.zf_uriprefix=c.zf_uriprefix||"";this.trigger()},registerListener:function(e,d){var c={scope:d,callback:e};a.listeners.push(c)}};define.call(b,"islive",!!document.location.host.match("centraldesktop.com$"));return b})();CD.Cookies=(function(){return{read:function(a){var e=a+"=";var d=document.cookie.split(";");for(var c=0;c<d.length;c++){var b=d[c];while(b.charAt(0)==" "){b=b.substring(1,b.length)}if(b.indexOf(e)==0){return b.substring(e.length,b.length)}}return null},write:function(d,f,g){var b="";if(g){var c=new Date();c.setTime(c.getTime()+(g*24*60*60*1000));b="; expires="+c.toGMTString()}else{if(g==0){var c=new Date();c.setTime(c.getTime()+(2*356*24*60*60*1000));b="; expires="+c.toGMTString()}}var a=document.location.host.split(".");if(a.length>=2){var e=a[a.length-2]+"."+a[a.length-1]}else{var e="centraldesktop.com"}document.cookie=d+"="+f+b+"; path=/; domain="+e},erase:function(a){this.write(a,"",-1)}}})();CD.getItemTypeAsString=function(a){switch(parseInt(a)){case 0:case 1:return"doc";case 2:return"spreadsheet";case 3:case 4:return"file";case 5:return"discussion";case 10:return"blogentry";case 11:return"forumentry";case 12:return"diagram"}};CD.Cookies.Prefs=(function(){var FOLDER_TYPE_BIT=2;var FOLDER_TAG_BIT=4;var FOLDER_STATUS_BIT=8;var FOLDER_VIEW_SIMPLE=16;var FOLDER_VIEW_GALLERY=32;var OVERDUE_CALENDAR_BIT=1;var folder_bitfield=null;var overdue_bitfield=null;var loaded=false;var notes_visible=false;var notes_first_load=true;function fromcookie(){if(!loaded){var serialized=CD.Cookies.read("jp");if(serialized&&serialized.length>0){var obj=eval(serialized);folder_bitfield=obj.fc;overdue_bitfield=obj.ov;notes_visible=obj.nv;if(obj.nf!=undefined){notes_first_load=obj.nf}}if(typeof folder_bitfield=="undefined"){folder_bitfield=0}if(typeof overdue_bitfield=="undefined"){overdue_bitfield=OVERDUE_CALENDAR_BIT}loaded=true}}function tocookie(){var fields=new Array;fields.push("fc:"+folder_bitfield);fields.push("ov:"+overdue_bitfield);fields.push("nv:"+notes_visible);fields.push("nf:"+notes_first_load);var string="({"+fields.join(",")+"})";CD.Cookies.write("jp",string,0)}function clear_bit(value,bit){return(value&~bit)}function set_bit(value,bit){return(value|bit)}return{is_folder_type_expanded:function(){fromcookie();return((folder_bitfield&FOLDER_TYPE_BIT)==FOLDER_TYPE_BIT)},set_folder_type_expanded:function(expanded){fromcookie();if(expanded){folder_bitfield=set_bit(folder_bitfield,FOLDER_TYPE_BIT)}else{folder_bitfield=clear_bit(folder_bitfield,FOLDER_TYPE_BIT)}tocookie()},is_folder_tag_expanded:function(){fromcookie();return((folder_bitfield&FOLDER_TAG_BIT)==FOLDER_TAG_BIT)},set_folder_tag_expanded:function(expanded){fromcookie();if(expanded){folder_bitfield=set_bit(folder_bitfield,FOLDER_TAG_BIT)}else{folder_bitfield=clear_bit(folder_bitfield,FOLDER_TAG_BIT)}tocookie()},is_folder_status_expanded:function(){fromcookie();return((folder_bitfield&FOLDER_STATUS_BIT)==FOLDER_STATUS_BIT)},set_folder_status_expanded:function(expanded){fromcookie();if(expanded){folder_bitfield=set_bit(folder_bitfield,FOLDER_STATUS_BIT)}else{folder_bitfield=clear_bit(folder_bitfield,FOLDER_STATUS_BIT)}tocookie()},is_folder_view_simple:function(){fromcookie();return((folder_bitfield&FOLDER_VIEW_SIMPLE)==FOLDER_VIEW_SIMPLE)},set_folder_view_simple:function(simpleView){fromcookie();if(simpleView){folder_bitfield=set_bit(folder_bitfield,FOLDER_VIEW_SIMPLE)}else{folder_bitfield=clear_bit(folder_bitfield,FOLDER_VIEW_SIMPLE)}tocookie()},is_overdue_calendar_expanded:function(){fromcookie();return((overdue_bitfield&OVERDUE_CALENDAR_BIT)==OVERDUE_CALENDAR_BIT)},set_overdue_calendar_expanded:function(expanded){fromcookie();if(expanded){overdue_bitfield=set_bit(overdue_bitfield,OVERDUE_CALENDAR_BIT)}else{overdue_bitfield=clear_bit(overdue_bitfield,OVERDUE_CALENDAR_BIT)}tocookie()},is_notes_visible:function(status){fromcookie();return notes_visible},set_notes_visible:function(status){notes_visible=!!status;tocookie()},is_notes_first_load:function(status){fromcookie();return notes_first_load},set_notes_first_load:function(status){notes_first_load=!!status;tocookie()}}})();function CD_Collapser(d,e,a,b,c){this.elemid=d;this.plus_minus_control=e;this.text_control=a;this.pref_accessor=b;this.pref_mutator=c;this.expanded=null;this.expand=function(){var f=$(this.elemid);if(f){f.style.display="block"}if(this.plus_minus_control!=null){f=$(this.plus_minus_control);if(f){f.removeClassName("icon_expand");f.addClassName("icon_collapse")}}if(this.text_control!=null){f=$(this.text_control);if(f){f.innerHTML="Hide"}}this.expanded=true};this.collapse=function(){var f=$(this.elemid);if(f){f.style.display="none"}if(this.plus_minus_control!=null){f=$(this.plus_minus_control);if(f){f.removeClassName("icon_collapse");f.addClassName("icon_expand")}}if(this.text_control!=null){f=$(this.text_control);if(f){f.innerHTML="Show"}}this.expanded=false};this.onClick=function(f){if(this.expanded){this.collapse()}else{this.expand()}if((this.pref_mutator!=null)&&(typeof(this.pref_mutator)=="function")){this.pref_mutator(this.expanded)}if(typeof(f)!="undefined"){f.stop()}return(false)},this.attach=function(){var g=this;if((this.pref_accessor!=null)&&(typeof this.pref_accessor=="function")){this.expanded=this.pref_accessor()}else{this.expanded=($(this.elemid).style.display.indexOf("none",0)<0)}if(this.plus_minus_control!=null){var f=$(this.plus_minus_control);if(f){Event.observe(f,"click",function(h){g.onClick(h)})}}if(this.text_control!=null){var f=$(this.text_control);if(f){Event.observe(f,"click",function(h){g.onClick(h)})}}if(this.expanded){this.expand()}else{this.collapse()}}}CD.SystemMessage=function CD_SystemMessage(c,a,b){this.msgClass=c;this.msgStatus=a;this.msgMessage=b;this.getNextId=function(){return"sysMessage"+CD.SystemMessage.nextId++};this.render=function(d,e){var g=e||7000;var k=this.getNextId();var h='<div style="position: relative"><div id="'+k+'" class="sysmessage '+this.msgClass+" sysmessage-"+this.msgStatus+'"><img class="sysmessage-icon" src="/i/ui2.0/'+this.msgStatus+'.gif" /><ul><li>'+this.msgMessage+"</li></ul>";if(a=="statuserror"){h+='<a href="#close" class="sysmessage-close icon icon_favorites_remove" onclick="$(this).up().fade(); return false;"></a>'}h+="</div>";h+="</div>";d.innerHTML=h;if(this.msgStatus!="statuserror"){var f=this;setTimeout(function(){var m=$(k).up(".tasklist");if(m){m.fade()}},g)}}};try{$C(CD.SystemMessage)}catch(err){console.log("Couldn't init systemmessage")}CD.SystemMessage.nextId=0;function selectFirstInputElement(c,a){var h=$(c).select('input[type!="hidden"], select, textarea');var b=null;var k={l:null,t:null};for(var g=0;g<h.length;g++){for(var e=0;e<a.length;e++){if(h[g].up(a[e])){continue}}var f=false;var m=dom.utils.getElementTop(h[g]);var d=dom.utils.getElementLeft(h[g]);if(b){if(m<k.t||(m==k.t&&d<k.l)){f=true}}else{f=true}if(f){b=h[g];k.t=m;k.l=d}}if(b){b.focus()}}CD.UI={setupIconHover:function(a){Event.observe(a,"mouseover",CD.UI.showIcons);Event.observe(a,"mouseout",CD.UI.hideIcons)},showIcons:function(a){try{var b=this.select(".hover-icon-container")[0];b.removeClassName("bl-dynamic")}catch(c){}},hideIcons:function(a){try{var b=this.select(".hover-icon-container")[0];b.addClassName("bl-dynamic")}catch(c){}},toggleElements:function(d,c,b,a){if(!d){return false}if(d.style.display=="none"){d.style.display="";vizElem=d;if(b){b.style.display=a?"none":""}}else{d.style.display="none";if(b){b.style.display=a?"":"none";vizElem=a?b:null}}if(c&&vizElem){dom.utils.scrollTo(vizElem)}},toggleElementsVisibility:function(h,g){try{if(CD.Environment.model["class"]=="CD.TasklistCollection"){return true}}catch(f){}var a=null;if(arguments.length==3){a=arguments[2]}for(var d=0;d<h.length;d++){var b=$$(h[d]);for(var c=0;c<b.length;c++){if(a){result=$(b[c]).up("#"+a.id);if(result){continue}}b[c].style.visibility=g?"visible":"hidden"}}}};ns("CD.Queue");CD.Queue=function(a,d){var c=this;var b=1;this.numActive=0;this.maxActive=a.maxActive||2;this.maxRetry=a.maxRetry||3;this.successes=[];this.failures=[];this.totalCount=0;this.fireCallback=function(g,h,m){try{if(h){if(g.marked===undefined){g.marked=true;c.successes.push(g.id)}}else{if(g.numAttempts<c.maxRetry){c.unshift(g)}else{if(g.marked===undefined){c.failures.push(g.id);g.marked=true}}}c.numActive--;c.flush(g.id)}catch(k){}};this.getNextId=function(){return b++};this.activeRequestIds=[];this.queued=[];this.unshift=function(e){this.queued.unshift(e)};this.shift=function(){return this.queued.shift()};this.push=function(e){this.queued.push(e)};this.pop=function(){return this.queued.pop()};this.next=function(){return this.shift()};this.add=function(e){e.id=this.getNextId();e.numAttempts=0;this.push(e);this.totalCount++};this.flush=function(g){var h;g=g||null;try{this.activeRequestIds=this.activeRequestIds.without(g);if((this.queued.length>0)===false){if(this.activeRequestIds.length===0&&this.numActive===0&&typeof this.onComplete==="function"){this.onComplete()}}while(this.numActive<this.maxActive&&this.queued.length>0){h=this.next();this.numActive++;c.fire.call(c,h,c.fireCallback)}}catch(k){}};this.onComplete=null;try{if(typeof d.onComplete==="function"){this.onComplete=d.onComplete}}catch(f){}};ns("CD.Ajax");CD.Ajax.readEnvironment=function(f){var a=true,b={},n=f.getAllResponseHeaders().replace("\r","\n"),q=n.split("\n"),k,g,c,d,h,m,p,r;for(k=0;k<q.length;k++){if(q[k].match(/\: /)){c=q[k].split(": ");b[c[0]]=c[1]}}if(typeof b["X-Json-Version"]!=="undefined"){f.version=parseFloat(b["X-Json-Version"])}else{f.version=1;d=0;for(k in b){if(b.hasOwnProperty(k)){m=b[k];if(m.match(/^JSON\_CHUNKS\: /)){c=m.split(": ",2);d=parseInt(c[1],10);break}}}h=[];for(k=0;k<d;k++){for(g=0;g<b.length;g++){m=b[g];p=new RegExp("^JSON"+k+": ");if(m.match(p)){c=m.split(": ",2);h.push(c[1]);break}}}try{r=h.join("");r=r.replace("\\:",":");CD.Environment.set(r.evalJSON())}catch(o){}}};ns("CD.Ajax.Request");CD.Ajax.Request=function(a,f,e,d){var c;f=f||{};f.parameters=f.parameters||{};e=e===false?false:true;if(typeof f.parameters!=="undefined"&&typeof f.parameters.format!=="undefined"&&f.parameters.format==="jsonenv"){d=false;e=false}else{d=d===false?false:true}f.parameters.isAjaxRequest=true;if(typeof f.parameters.r==="undefined"&&typeof f.parameters.rand==="undefined"){f.parameters.rand=Math.random()}if(typeof f.parameters.spid==="undefined"&&typeof CD.Environment.space!=="undefined"&&typeof CD.Environment.space.id!=="undefined"){f.parameters.spid=CD.Environment.space.id}if(typeof CD.Environment.company!=="undefined"&&typeof CD.Environment.company.id!=="undefined"){f.parameters.coid=CD.Environment.company.id}if(typeof CD.Environment.model!=="undefined"&&d){f.parameters.model=Object.toJSON(CD.Environment.model)||null}if(typeof f.onSuccess==="function"){c=f.onSuccess;f.onSuccess=function(h){var k=h.request;k.version=k.version||1;try{if(k.parameters.format==="jsonenv"){k.version=2}}catch(g){console.warn("unknown ver")}if(k.version<2&&e){CD.Ajax.readEnvironment(h)}resp=CD.Ajax.ResponseHandler(h);if(k.version>=2&&e){CD.Environment.set(resp.env)}c(resp)}}if(typeof f.onFailure==="function"){var b=f.onFailure;f.onFailure=function(g){var h=CD.Ajax.ResponseHandler(g);b(h)}}rqst=new Ajax.Request(a,f);rqst.onConfirm=function(){f.parameters.confirmed=true;new Ajax.Request(a,f)};return rqst};ns("CD.Ajax.ResponseHandler");CD.Ajax.ResponseHandler=function(k){var c=false,b,f,d;var a=k.getHeader("X-Json-Version")||k.request.version||1;if(a>=2){try{b=JSON.parse(k.responseText);if(CD.Ajax.ExceptionHandler(b,a)){return b}else{cdwm.confirm(b.response.message,function(e){if(e){k.request.onConfirm()}});return false}}catch(g){f={classname:"exception",code:256,exception:"Error",message:k.responseText};CD.Ajax.ExceptionHandler(f,a)}}else{try{if(!k.responseJSON){k.responseJSON=JSON.parse(k.responseText.strip().replace(/^\s*\/\*[^\*]+\*\/\s*/,"").replace(/^\s*var response =\s*/,"").replace(/;$/,""))}if(!k.responseJSON&&k.responseJSON!==false){throw new Exception()}}catch(h){k.responseJSON=null;return k}if(CD.Ajax.ExceptionHandler(k)){d=k.request.options;d.parameters.dialogConfirmed=true;if(typeof d.parameters.format!=="undefined"&&d.parameters.format==="json"){return k.responseJSON}}return k}};CD.Ajax.ExceptionHandler=function(f,k){var h,m,a,d;function e(n){var o="";switch(n){case window.CD.Ajax.ResponseHandler.CODES.E_USER_ERROR:o="Error";break;case window.CD.Ajax.ResponseHandler.CODES.E_USER_WARNING:o="Warning";break;case window.CD.Ajax.ResponseHandler.CODES.E_USER_NOTICE:o="Notice";break}return o}function b(n){var p=document.location.href;var q="sessionexpired";if(n.responseJSON){q=n.responseJSON.securityMessage}var o="/login?eid="+q+"&rurl="+encodeURIComponent(p);document.location.href=o}try{k=k||1;if(typeof f.responseJSON!=="undefined"&&f.responseJSON.classname==="exception"){if(typeof f.responseJSON!=="undefined"&&f.responseJSON.exception==="CD_Controller_Exception_LoginRequired"){b(f);return false}if(f.responseJSON&&f.responseJSON.exception==="CD_Controller_Exception"&&f.status===401){var g=f.responseJSON.message.split(":");if(g[0]==="Unable to find milestone"){cdwm.alert("This Milestone no longer exists",{title:"Milestone not found",width:480});CD.Project.Router.navigate("",true);return false}}d={title:e(f.responseJSON.code)};if(typeof f.responseJSON.mode!=="undefined"&&((f.responseJSON.mode==="devel")||f.responseJSON.mode==="devvm")){d.width=480;d.title=d.title+" [DEVEL MODE]"}switch(f.responseJSON.code){case window.CD.Ajax.ResponseHandler.CODES.E_USER_ERROR:cdwm.alert("<h3>"+d.title+"</h3><br/>"+f.responseJSON.message,d);break;case window.CD.Ajax.ResponseHandler.CODES.E_USER_NOTICE:d.buttons=[{title:"OK",click:function(){window.parent.location.reload();return false}}];cdwm.alert("<h3>"+d.title+"</h3><br/>"+f.responseJSON.message,d);break;case window.CD.Ajax.ResponseHandler.CODES.E_USER_WARNING:cdwm.confirm("<h3>"+d.title+"</h3><br/>"+f.responseJSON.message,function(q){if(q){var p=request.request.options;p.parameters.dialogConfirmed=true;var o=request.request.url;var n=new Ajax.Request(o,p)}},d);break}return false}else{if(f==="BAD REQUEST"){cdwm.alert("<h3>Invalid Request</h3><br/>This error has been logged.");return false}else{if(f==="FAIL"){cdwm.alert("<h3>Operation Failed</h3>");return false}else{if(f.response&&f.response.exception){if(f.response.exception.xdebug_message){var g=f.response.exception.xdebug_message.trim().split("/");if(g[0]==="Zend_Controller_Action_Exception: Missing model object in "){cdwm.alert("This Task/Tasklist no longer exists",{title:"Task/Tasklist not found"});CD.Project.Router.navigate("",true);return false}}}if(f.response&&f.response.message==="Application error"){if(f.response.exception.xdebug_message){var g=f.response.exception.xdebug_message.trim().split(":");if(g[0]==="CD_AccessDeniedException"||g[0]==="CD_Database_CannotQueryException"){cdwm.alert("This Task/Tasklist no longer exists",{title:"Task/Tasklist not found"});CD.Project.Router.navigate("",true);return false}}}if(f.code&&f.code===256&&f.exception&&f.exception==="Error"){if(f.message){var g=f.message.split(" ");if(g[1]==="'CD_Controller_Exception_LoginRequired'"){b(f);return false}}}if(f.response&&f.response.code&&f.response.code===512&&f.response.exception&&f.response.message){return false}return true}}}}catch(c){console.log(c);return false}};CD.Ajax.ResponseHandler.CODES={E_USER_ERROR:256,E_USER_WARNING:512,E_USER_NOTICE:1024};CD.AjaxResponseHandler=CD.Ajax.ResponseHandler;ns("CD.Ajax.Queue");CD.Ajax.Queue=function(b){b=b?b:{};CD.Queue.call(this,{maxActive:3,maxRetry:2},b);this.fire=function(d,c){var e;d.numAttempts++;if(d.params.__onSuccess===undefined&&d.params.onSuccess){d.params.__onSuccess=d.params.onSuccess}d.params.onSuccess=function(f){try{if(typeof d.params.__onSuccess==="function"){d.params.__onSuccess(f)}c(d,true,"onSuccess")}catch(g){}};if(d.params.__onFailure===undefined&&d.params.onFailure){d.params.__onFailure=d.params.onFailure}d.params.onFailure=function(f){try{if(typeof d.params.__onFailure==="function"){d.params.__onFailure(f)}c(d,false,"onFailure")}catch(g){}};this.activeRequestIds.push(d.id);e=new CD.Ajax.Request(d.url,d.params,d.updateEnvironment,d.sendModel)};var a=this;return this};extend(CD.Ajax.Queue,CD.Queue);CD.ajaxQueue=new CD.Ajax.Queue();CD.taskAjaxQueue=new CD.Ajax.Queue({onComplete:function(){setTimeout(function(){common_tasks.make_lists_sortable()},1000)}});var CD=CD||{};CD.DraggableInterface=new Interface("DraggableInterface",["isDraggable","clone"]);CD.Drag=function(d,n,u){function y(D){var C=D.element();if(!C.hasClassName("node")){C=C.up(".node")}return C}function m(D,C,F,E){if(p[D]){t(D)}p[D]=setTimeout(F.bind(C),E)}function t(C){clearTimeout(p[C]);p[C]=null}function q(){m("drag",this,function(){CD.Drag.inDrag=true},200)}function w(){t("drag")}this.setContainer=function(C){return(s=$(C))};this.getContainer=function(){return s};this.setSelectMultiple=function(C){return(z=C?true:false)};this.getSelectMultiple=function(){return z};this.setSelectedClassName=function(C){return(cssClassName=C)};this.getSelectedClassName=function(){return cssClassName};this.getGroup=function(C){return CD.DragGroup.get(this,C)};this.startDragging=function(D){var C=this.countSelected();if(CD.permissions.canEdit(CD.Environment.space.id)){if(C>0){CD.Drag.inDrag=true;this.getGroup().draw(this,D)}}};this.stopDragging=function(){this.getGroup().destroy();x.start=null;a.mousedown=null;CD.Drag.inDrag=false};this.isDragging=function(){return CD.Drag.inDrag};this.getEventElementId=function(C){return a[C.toLowerCase()]};this.setEventElementId=function(C,D){return a[C.toLowerCase()]=D};this.clearEventElementId=function(C){return this.setEventElementId(C,null)};this.countSelected=function(){var C=this.getSelected();if(C){return C.length}else{return 0}};this.getSelected=function(){return this.getContainer().select("."+this.getSelectedClassName())};this.isSelected=function(C){return C.hasClassName(this.getSelectedClassName())};this.add=function(F,E){if(!F){return false}if(!this.getSelectMultiple()){var C=this.getSelected();for(var D=0;D<C.length;D++){C[D].removeClassName(this.getSelectedClassName())}}if(!(typeof F.isDraggable=="function")||!F.isDraggable()){return}if(F.hasClassName("disabled")){return}F.addClassName(this.getSelectedClassName());return true};this.remove=function(D,C){D.removeClassName(this.getSelectedClassName());return true};this.register=function(H,D){var C=D.substr(1);var G=H.getElement();G.clone=H.clone;G.isDraggable=H.isDraggable;try{if(!G.hasClassName(C)){var F=G.select(D)[0];if(F){G=F}}}catch(E){}Event.observe(G,"mousedown",g.bind(this));Event.observe(G,"mousemove",r.bind(this));Event.observe(G,"mouseup",f.bind(this));Event.observe(G,"mouseout",o.bind(this))};this.setDropValidity=function(C){this.getGroup().setDropValidity(C)};function g(E){var D=y(E);a.mousedown=D.id;a.click=D.id;if(!x.start){if(!D.isDraggable()){return}x.start=dom.utils.getMouseCoords(E);if(!this.isSelected(D)){v=D.id}}document.onselectstart=function(){return false};document.body.focus();var C=dom.utils.getMouseCoords(E);this.getGroup().moveTo({left:C.x+10,top:C.y+10});E.stop();return false}function r(C){}function f(E){try{var D=y(E);a.mouseup=D.id;if(a.click==a.mouseup){if(typeof D._onClick=="function"){D._onClick(E)}}a.mousedown=null;a.mouseup=null;a.click=null;x.start=null;if(typeof D._onMouseUp=="function"){D._onMouseUp(this.getGroup().getElement(),D,E)}this.stopDragging();E.stop()}catch(C){}return false}function o(C){elem=y(C);if(a.mousedown==elem.id){elem.node.selectNode(true);this.startDragging(C)}a.click=null}function b(C){if(CD.Drag.inDrag){C.stop();return false}}function h(C){var E=dom.utils.getMouseCoords(C);if(x.start&&!CD.Drag.inDrag){if((Math.abs(x.start.x-E.x)>x.delta.x)||(Math.abs(x.start.y-E.y)>x.delta.y)){if(!e){var F=dom.utils.getElementHeight(document.body);var G=dom.utils.getElementWidth(document.body);e={x:G,y:F}}setTimeout((function(){this.startDragging(C)}).bind(this),500)}}if(CD.Drag.inDrag){if(!e){var F=dom.utils.getElementHeight(document.body);var G=dom.utils.getElementWidth(document.body);e={x:G,y:F}}var I={w:0,h:0};var K={x:0,y:0};var J={x:0,y:0};var H=20;if(dom.utils.browser.isIE()){J.x=document.body.parentNode.scrollLeft;J.y=document.body.parentNode.scrollTop;I.h=document.body.parentNode.clientHeight;I.w=document.body.parentNode.clientWidth}else{J.x=window.scrollX;J.y=window.scrollY;I.h=window.innerHeight;I.w=window.innerWidth}if(E.x<J.x+H&&J.x>0){K.x=-20}else{if(E.x>(I.w+J.x-20-H)&&E.x<e.x){K.x=20}}if(E.y<J.y+H&&J.y>0){K.y=-20}else{if(E.y>(I.h+J.y-20-H)&&E.y<e.y){K.y=20}}if(K.x!=0||K.y!=0){window.scrollBy(K.x,K.y)}this.getGroup().moveTo({left:E.x+10,top:E.y+10});var D=$(C.element());if(!D||(D.hasClassName&&!D.hasClassName("node")&&!D.up(".node"))){this.getGroup().setDropValidity(false)}}}function c(C){a.mousedown=null;this.stopDragging();document.onselectstart=null;return false}Event.observe(document,"mousedown",b.bind(this));Event.observe(document,"mousemove",h.bind(this));Event.observe(document,"mouseup",c.bind(this));var B=false;var s,k,e,v,A;var z=false;var a={mouseup:null,mousedown:null,click:null};var p={};var x={start:null,end:null,delta:{x:10,y:10}};this.setContainer(d);this.setSelectMultiple(n);this.setSelectedClassName(u)};CD.Drag.inDrag=false;CD.DragGroup=new (function(){this.get=function(g,f){this.setContainer(g.getContainer());this.setSelectMultiple(g.getSelectMultiple());this.setSelectedClassName(g.getSelectedClassName());if(g.getContainer()!=this.getContainer()){this.destroy()}if(f){this.positionElement(f)}return this};this.getElement=function(){return $(this.ELEM_ID)};this.setSelectMultiple=function(f){return(a=f?true:false)};this.getSelectMultiple=function(){return a};this.setContainer=function(f){if(b!==f){b=$(f)}};this.getContainer=function(){return b};this.setSelectedClassName=function(f){return(c=f)};this.getSelectedClassName=function(){return c};this.destroy=function(){var f=this.getElement();if(f&&f.parentNode){f.parentNode.removeChild(f);f=null}};this.draw=function(k,g){this.destroy();var w=k.getSelected();if(w.length==0){return false}var m=new Element("div",{id:this.ELEM_ID,"class":"dragContainer",style:"position: absolute; height: auto; width: 200px;"});m.setOpacity(0.75);var y=new Element("table",{cellPadding:0,cellSpacing:0,border:0});var p=new Element("tbody");var r=new Element("tr");dom.utils.getBody().appendChild(m);m.appendChild(y);y.appendChild(p);p.appendChild(r);var t=new Element("td",{id:"dropAlertInvalid","class":"alert invalid"});var s=new Element("img",{src:"/i/drop-no-11x11.gif",height:11,width:11,border:0,style:"padding: 2px;"});t.appendChild(s);r.appendChild(t);var t=new Element("td",{id:"dropAlertValid","class":"alert valid",style:"display: none;"});var s=new Element("img",{src:"/i/drop-yes-11x11.gif",height:11,width:11,border:0,style:"padding: 2px;"});t.appendChild(s);r.appendChild(t);var q=new Element("td",{"class":"dragItems"});r.appendChild(q);var v=0;for(var h=0;h<w.length;h++){if(v<5){var n=w[h];if(typeof n.clone=="function"){var x=n.clone(n)}else{var x=dom.utils.stripIds(n.cloneNode(true))}q.appendChild(x);v++}else{var u=new Element("div",{style:"padding-left: 20px"});u.appendChild(document.createTextNode(" . . . "));q.appendChild(u);break}}var f=new Array();for(var o=0;o<w.length;o++){f.push(w[o].id)}m.selectedIds=f;m.dragManager=k;return m};this.positionElement=function(g){var f=this.getElement();if(f){var h=dom.utils.getMouseCoords(g);f.style.left=h.x+10;f.style.top=h.y+10}};this.moveTo=function(f){var g=this.getElement();if(g){g.style.left=f.left;g.style.top=f.top}};this.setDropValidity=function(k){var g=this.getElement();if(!g){return true}var f=g.select(".alert.valid")[0];var h=g.select(".alert.invalid")[0];if(k){f.style.display="";h.style.display="none"}else{f.style.display="none";h.style.display=""}};this.toggle=function(m,k){var n=this.isSelected(m);if(k.shiftKey){var g=this.getSelected();var h=$("item_"+g[g.length-1]);if(h){var p={end:false,start:false};var o=m.parentNode.childNodes;for(var f=0;f<o.length;f++){if(o[f].nodeType!=1){continue}if(m.id==o[f].id){p.end=true}else{if(h.id==o[f].id){p.start=true}}if(p.end||p.start){this.add(o[f],k)}if(p.end&&p.start){break}}}else{this.add(m,k)}}else{if(n){this.remove(m,k)}else{this.add(m,k)}}};this.ELEM_ID="dragGroup";var d=false;var e=null;var b=null;var c=null;var a=false;return this})();var CD=CD||{};CD.DroppableInterface=new Interface("DroppableInterface",["isDroppable","canDropElement","onDrop"]);CD.Drop=function(a,b){var h=false;var d=a;var e=b||"li";function f(p){var o=p.element();if(o.tagName.toLowerCase()!=e){o=o.up(e)}return o}function k(o){}function n(o){}function c(p){if(!d.isDragging()){return}var o=f(p);if(!o){return}if(typeof o._onMouseOver=="function"){if(!o.isDroppable()){d.getGroup().setDropValidity(false);return}else{d.getGroup().setDropValidity(true)}o._onMouseOver(d.getGroup().getElement(),o,p)}}function m(p){d.clearEventElementId("click");if(!d.isDragging()){return}var o=f(p);if(typeof o._onMouseOut=="function"){o._onMouseOut(d.getGroup().getElement(),o,p)}}function g(p){var o=f(p);if(d.getEventElementId("click")==o.id){if(typeof o._onClick=="function"){o._onClick(p)}}else{if(CD.Drag.inDrag){if(typeof o._onDrop=="function"){o._onDrop(d.getGroup().getElement(),o,p)}}}d.stopDragging();if(typeof o._onMouseUp=="function"){o._onMouseUp(d.getGroup().getElement(),o,p)}d.clearEventElementId("mousedown");d.clearEventElementId("mouseup");d.clearEventElementId("click")}this.getDragManager=function(){return d};this.register=function(s,p){var o=p.substr(1);var r=s.getElement();r._canDropElement=s.canDropElement;r._onDrop=s.onDrop;r._onDropSuccess=s.onDropSuccess;r._onMouseOver=s.onMouseOver;r._onMouseOut=s.onMouseOut;r._onMouseUp=s.onMouseUp;try{if(!r.hasClassName(o)){elems=r.select(p);r=elems[0]}Event.observe(r,"mousedown",k.bind(this));Event.observe(r,"mousemove",n.bind(this));Event.observe(r,"mouseup",g.bind(this));Event.observe(r,"mouseover",c.bind(this));Event.observe(r,"mouseout",m.bind(this))}catch(q){}}};ns("CD.Draggable",{dragManager:null,initDraggable:function(b,a){a=a||{};if(typeof a.clone!=="function"){throw new Error("Must define clone method for draggables!")}this.dragManager=b;var c=$(this);c.on("click",function(d){if(c.isSelected()){c.deselectNode()}else{c.selectNode()}});c.node=this;c=_.extend(c,a);this.dragManager.register(c,".dragHandle")},getElement:function(){return $(this)},isDraggable:function(){return true},isSelected:function(){return this.hasClassName("selected")},selectNode:function(){this.dragManager.add(this)},deselectNode:function(){this.dragManager.remove(this)}});ns("CD.Droppable",{droppableFlag:true,initDroppable:function(a,b){b=b||{};if(typeof b.canDropElement!=="function"){throw new Error("Must define canDropElement method for droppables!")}if(typeof b.onDrop!=="function"){throw new Error("Must define onDrop method for droppables!")}var c=$(this);c.dropManager=a;c.addClassName("dropTarget");c.addClassName("node");c=_.extend(c,b);c.dropManager.register(c,".dropTarget")},getElement:function(){return $(this)},isDroppable:function(){if(typeof arguments[0]!=="undefined"){return(this.droppableFlag=arguments[0]?true:false)}return this.droppableFlag},setDropValidity:function(a){return this.dropManager.getDragManager().setDropValidity(a)},timers:[],startTimer:function(b,a,d,c){if(this.timers[b]){this.stopTimer(b)}this.timers[b]=setTimeout(d.bind(a),c)},stopTimer:function(a){clearTimeout(this.timers[a]);this.timers[a]=null},startHighlightTimer:function(d){var c,b,a;c=this.dropManager.getDragManager().getGroup();if(this.canDropElement(c)){b=this.getElement();a=b.getAttribute("data-id");this.startTimer("highlight-"+a,this,function(){b.highlight(d)},500)}},stopHighlightTimer:function(){var b,a;b=this.getElement();a=b.getAttribute("data-id");this.stopTimer("highlight-"+a)},highlight:function(a){if(a){this.getElement().style.backgroundColor="#FFFF9F"}else{this.getElement().style.backgroundColor="transparent"}},startExpandTimer:function(c){var b,a;b=this.getElement();a=b.getAttribute("data-id");this.startTimer("expand-"+a,b,function(){b.expand();if(typeof c==="function"){c(b)}},1000)},stopExpandTimer:function(){var b,a;b=this.getElement();a=b.getAttribute("data-id");this.stopTimer("expand-"+a)},expand:function(){}});CD=CD||{};CD.Poller=function(k,f){this.start=function(){if(e){this.reset()}this.fire()};this.fire=function(){if(!b&&d.length>c){var m=d[c];var n=m*1000;this.firstCall=(c==0);this.finalCall=(c==(d.length-1));b=setTimeout(a,n);c++}};this.reset=function(){c=0;this.stop()};this.stop=function(){if(b){clearTimeout(b);b=null}e=false};function a(){b=null;if(typeof g=="function"){g(function(m){if(!m){h.fire()}else{h.reset()}},h.firstCall,h.finalCall)}}var h=this;var c=0;var d=[];var b=null;var g=k;var e=false;if(f.intervals){d=f.intervals}if(f.immediate){this.start()}};$C(CD.Poller);var CD=CD||{};function CD_Item(){CD_Object.call(this);this.namespace="item";this.displayName="Item";this.activity_type=2;this.item_type=null;var o=this;this.views.move=function(itemIds,folderIds,description){var catid=CD.Object.getValidCatid(null,CD.Folder.ATTACHMENT);var url=CD.Environment.space.relative_url+"folder/"+catid+"/move/?rand="+Math.random()+"&itemIds="+itemIds+"&folderIds="+folderIds;var params={title:"Move "+description,file:url,type:"dynamic",inline:1,width:500,beforeRender:function(){},afterRender:function(){}};var ret=overlay.show(params,true);return ret};this.actions.move=function(itemIds,folderIds,from_spid,from_catid,to_spid,to_catid,callbackFunc,displayOpt){displayOpt=displayOpt||CD.Category.DISPLAY_OPTION.FILE;var url=CD.Environment.space.relative_url+"folder/"+from_catid+"/";var params={doaction:"move",format:"json",records:itemIds.join(","),itemIds:itemIds.join(","),folderIds:folderIds.join(","),from_spid:from_spid,from_catid:from_catid,to_spid:to_spid,to_catid:to_catid,displayOption:displayOpt,rand:Math.random()};new CD.Ajax.Request(url,{method:"post",parameters:params,onSuccess:function(response){if(typeof callbackFunc=="function"){callbackFunc(response)}}})};this.views.checkPassword=function(itemId,try_again,pgref_force,reload_function){if(try_again==undefined){try_again=false}if(pgref_force==undefined){pgref_force=""}if(!reload_function){reload_function=overlay.reload}var url=CD.Environment.space.relative_url+this.namespace+"/"+itemId+"/check_password/?try_again="+(try_again?"true":"false")+"&rand="+Math.random();url=url+"&pgref_force="+pgref_force;url=url+"&reload_function="+reload_function;var params={title:'<ins class="icon cd_icon_lock"></ins>Password',file:url,type:"dynamic",inline:1,beforeRender:function(){},afterRender:function(){$("file_password").focus()}};var ret=overlay.show(params,true);return ret};this.views.changePassword=function(itemId,mode){var mode=mode||"Change";var url=CD.Environment.space.relative_url+this.namespace+"/"+itemId+"/change_password/?rand="+Math.random();var params={title:'<ins class="icon icon_password_add"></ins> '+mode+" "+this.displayName+" Password",file:url,type:"dynamic",inline:1,beforeRender:function(){},afterRender:function(){$("new_password").focus()}};var ret=overlay.show(params,true);return ret};this.views.addRevision=function(itemId,mode){var box_width=(tagging_on)?700:500;var ns=this.namespace;var url=CD.Environment.space.relative_url+this.namespace+"/"+itemId+"/add_revision/?mode="+mode+"&rand="+Math.random();var params={title:"Save & Notify",file:url,type:"dynamic",inline:1,width:box_width,height:325,afterLoad:function(win){wiki_items.file_detail.item_tags.get_js_array(false);CD.Item.doAction("deployAssigneesPicker","upholder",ns,itemId,true)}};var ret=overlay.show(params,true);return ret};this.views.changeStatus=function(itemId,inlb){var url=CD.Environment.space.relative_url+this.namespace+"/"+itemId+"/change_status/";if(pgref.val=="vr"){url+="&pgref=vr"}var params={title:"Change "+this.displayName+" Status",file:url,type:"dynamic",inline:1,width:350};var ret=overlay.show(params,true);return ret};this.views.saveAndNotify=function(itemId){if(this.namespace=="doc"){if(!browser.isIPhoneCompatible){tinyMCE.activeEditor.save()}var version=document.forms.edit.elements.doc_current_version.value;if(version>0){wiki_tools.check_save(document.forms.edit)}else{wiki_tools.ok_to_save=true}if(wiki_tools.ok_to_save===false){return false}if(version=="0"){tinyMCE.activeEditor.save();var content="",body=tinyMCE.activeEditor.getDoc().body;if(body.textContent){content=body.textContent}if(content==""&&body.innerText){content=body.innerText}if(content==""){content=tinyMCE.activeEditor.getContent()}content=content.split("\n");content=content[0];content=content.replace(/<\/?[^>]+>/g,"");content=content.substr(0,50);var box_width=(tagging_on)?710:510;var url=CD.Environment.space.relative_url+this.namespace+"/savenew/?catid="+catid+"&pagecontent="+encodeURIComponent(content)+pgref.uri;var params={title:"Save & Notify",file:url,inline:1,type:"dynamic",height:160,width:box_width,afterLoad:function(){try{parent.parent.overlay.shouldReload=true}catch(e){}wiki_items.file_detail.item_tags.get_js_array(false);document.note_show_add_form.check_in_comments.focus()}};overlay.show(params)}else{if(document.edit.mode.value=="webdoc"){CD.Document.showDialog("addRevision",itemId,"")}}}else{if(this.namespace=="spreadsheet"){CD.Spreadsheet.showDialog("addRevision",itemId,"")}}};this.actions.saveAndNotify=function(form,itemId,isNewPage){switch(this.namespace){case CD.Document.namespace:this.actions.saveAndNotify_Document(form,itemId,isNewPage);break;case CD.Spreadsheet.namespace:this.actions.saveAndNotify_Spreadsheet(form,itemId);break;default:alert("sorry - no save & notify available for this item type.")}};function _getProofData(form){var emails=new Array;var roles=new Array;var emailElems=form.elements["proof_approver[]"];for(var i=0;i<emailElems.length;i++){if($(emailElems[i]).up(".tpl-proof-approver")){continue}emails.push(emailElems[i].value)}var roleElems=form.elements["proof_role[]"];for(var i=0;i<roleElems.length;i++){if($(roleElems[i]).up(".tpl-proof-approver")){continue}roles.push(roleElems[i].value)}var subject=form.elements.proof_subject.value;var body=form.elements.proof_body.value;var deadline=form.elements.proof_deadline.value;var swf=(typeof form.elements.swf!="undefined")?form.elements.swf.value:"";return{format:"json","emails[]":emails,"roles[]":roles,subject:subject,body:body,deadline:deadline,swf:swf}}function _stdOnDelete(pntCSSRule,autosize){var autosize=typeof(autosize)=="undefined"?true:!!autosize;return function(elm){var winId=CD.TinyMCE.getWindowId(elm);elm.up(pntCSSRule).remove();if(autosize&&winId){try{var win=cdwm.getWindow(winId);cdwm.resizeByContent(win)}catch(err){}}}}this.waitForProofHQ=function(){var url=CD.Environment.model.t_url;var params={doaction:"syncProofDetails",format:"json"};new CD.Ajax.Request(url,{method:"post",parameters:params,onSuccess:function(resp){if(!resp){setTimeout("CD.Item.waitForProofHQ();",10000)}else{if(typeof resp.type!=="undefined"&&resp.type=="Error"){cdwm.alert(resp.message)}else{window.location.replace(CD.Environment.model.t_url)}}}},false)};this.views.createProof=function(){try{var url=CD.Environment.space.relative_url+"file/"+CD.Environment.model.id+"/create_proof/"+pgref.uri;var params={title:"Launch Approval Process",file:url,inline:1,type:"dynamic",height:400,width:685,beforeClose:function(){CD.UserLookup.cancel()}};overlay.show(params)}catch(e){}};this.views.editProof=function(){try{var url=CD.Environment.space.relative_url+"file/"+CD.Environment.model.id+"/edit_proof/"+pgref.uri;var params={title:"Edit Approval Properties",file:url,inline:1,type:"dynamic",height:400,width:665};overlay.show(params)}catch(e){}};this.actions.participateInProof=function(elm){try{var url=CD.Environment.space.relative_url+"file/"+CD.Environment.model.id+"/";var params={doaction:"participateInProof",format:"json"};CD.Ajax.Request(url,{method:"post",parameters:params,onSuccess:function(response){window.location.reload();return}})}catch(e){}return true};this.addProofApproverInput=function(elem){var list=$("proofApproverList");var newApprover=ClassTpl.render("proof-approver");list.appendChild(newApprover);var winId=CD.TinyMCE.getWindowId(elem);var win=cdwm.getWindow(winId);cdwm.resizeByContent(win);if(dom.utils.getElementHeight(list)>=160){list.style.border="1px solid #eeeeee";var oTop=newApprover.offsetTop;list.scrollTop=parseInt(oTop+dom.utils.getElementHeight(newApprover))}else{list.style.border="1px solid #ffffff"}};this.removeProofApprover=function(controlElm){_stdOnDelete(".proof-approver-wrapper")(controlElm);return;var list=$("proofApproverList");if(dom.utils.getElementHeight(list)>=160){list.style.border="1px solid #eeeeee"}else{list.style.border="1px solid #ffffff"}};this.deleteProofParticipant=function(participant,onComplete){if(participant.rel){var participant_id=parseInt(participant.rel);var onComplete=onComplete||_stdOnDelete("tr")}else{var participant_id=parseInt(participant);var onComplete=null}var url=CD.Environment.space.relative_url+"file/"+CD.Environment.model.id+"/";CD.Ajax.Request(url,{method:"post",parameters:{doaction:"removeProofParticipant",participant_id:participant_id},onSuccess:function(response){if(onComplete&&onComplete.call){onComplete(participant)}}})};this.insertGroup=function(controlElm){var form=controlElm.up("form");if(form.proof_group.value>0){$("proofApproverList").update();for(var email in proof_groups[form.proof_group.value]){var approver=$("proofApproverList").appendChild(ClassTpl.render("proof-approver"));approver.select("input").first().value=email;role_options=approver.select("select").first();for(var i=0;i<role_options.length;i++){role_options[i].selected=(role_options[i].value==proof_groups[form.proof_group.value][email])}}var winId=CD.TinyMCE.getWindowId(controlElm);var win=cdwm.getWindow(winId);cdwm.resizeByContent(win)}else{alert("You must select a Proof Group OR manually enter Proof participants below.")}};this.validateProof=function(form){var emails=form.select(".proof-approver-email");var hasValidEmail=false;if(emails.length==1){CD.Item.addProofApproverInput($("proofApproverList"));emails=form.select(".proof-approver-email")}for(var i=0;i<emails.length;i++){var elem=emails[i];if(elem.up(".tpl-proof-approver")){continue}if(elem.value==""){continue}if(!/[\w\.\-]+@[\w\-]+(\.([\w\-]+))+$/.test(elem.value)){elem.addClassName("validation-failed");var advice=$(elem.parentNode).select(".validation-advice");if(!advice.length>0){var advice=new Element("div",{"class":"validation-advice"});advice.appendChild(document.createTextNode("Please enter a valid email address. For example fred@domain.com"));elem.parentNode.appendChild(advice)}}else{hasValidEmail=true;var advice=$(elem.parentNode).select(".validation-advice");if(advice.length>0){advice[0].parentNode.removeChild(advice[0])}elem.removeClassName("validation-failed")}}if(!hasValidEmail){var elem=false;for(var i=0;i<emails.length;i++){if(emails[i].up(".tpl-proof-approver")){continue}elem=emails[i];break}elem.addClassName("validation-failed");var advice=$(elem.parentNode).select(".validation-advice");if(!advice.length>0){var advice=new Element("div",{"class":"validation-advice"});advice.appendChild(document.createTextNode("Please enter a valid email address. For example fred@domain.com"));elem.parentNode.appendChild(advice)}}var winId=CD.TinyMCE.getWindowId(form);if(winId){var win=cdwm.getWindow(winId);if(win){cdwm.resizeByContent(win)}}var failed=$(form).select(".validation-failed");if(failed.length>0){return false}else{return true}};this.toggleAddParticipantForm=function(controlElm){var container=$(controlElm).up(".proof-props-addp");container.toggleClassName("expanded");try{var winId=CD.TinyMCE.getWindowId(controlElm);var win=cdwm.getWindow(winId);cdwm.resizeByContent(win)}catch(err){}if(container.hasClassName("expanded")){container.select("input")[0].focus()}var dl=$(controlElm).up("dl");if(dl&&dl.autosize){dl.autosize()}};this.actions.createProof=function(btn){try{if(!CD.Item.validateProof(btn.form)){return false}var url=CD.Environment.space.relative_url+"file/"+CD.Environment.model.id+"/";var params=_getProofData(btn.form);params.doaction="createProof";btn.value="Creating...";btn.disabled=true;CD.Ajax.Request(url,{method:"post",parameters:params,onSuccess:function(response){try{document.location.href=CD.Environment.model.t_url}catch(e){}}})}catch(e){}};this.actions.editProof=function(btn){if(!CD.Item.validateProof(btn.form)){return false}var url=CD.Environment.space.relative_url+"file/"+CD.Environment.model.id+"/";var params=_getProofData(btn.form);params.doaction="editProof";CD.Ajax.Request(url,{method:"post",parameters:params,onSuccess:function(response){try{document.location.href=CD.Environment.model.t_url}catch(e){}}})};this.actions.closeProof=function(btn){cdwm.confirm("Are you sure you want to close this proof?",function(confirmed){if(confirmed){btn.disabled=true;btn.value="Processing...";CD.Ajax.Request(CD.Environment.model.t_url,{method:"post",parameters:{doaction:"closeProof",format:"json"},onSuccess:function(response){document.location.href=CD.Environment.model.t_url}})}})};this.actions.cancelProof=function(){try{cdwm.confirm("Are you sure you want to cancel this proof?   This will delete the Proof but not the file.  This action cannot be undone.",function(resp){if(resp){var url=CD.Environment.space.relative_url+"file/"+CD.Environment.model.id+"/";var params={doaction:"cancelProof",format:"json"};CD.Ajax.Request(url,{method:"post",parameters:params,onSuccess:function(response){try{document.location.href=CD.Environment.model.t_url}catch(e){}}})}return false})}catch(e){}};this.actions.addProofParticipant=function(form){var url=CD.Environment.space.relative_url+"file/"+CD.Environment.model.id+"/";var params={doaction:"addProofParticipant",format:"JSON",email:form.email.value,role:form.role.value};CD.Ajax.Request(url,{method:"post",parameters:params,onSuccess:function(response){eval(response.responseText);var data=response;var role2str={"1":"Read Only","3":"Reviewer","4":"Approver","5":"Reviewer and Approver"};var notif2str={"1":"All new comments and replies","2":"Replies to my comments","3":"Daily summary","4":"Hourly summary","5":"Decisions only","9":"Disabled"};data.role=role2str[data.role];data.notification=notif2str[data.notification];data.deadline=data.deadline_str;var participant=ClassTpl.render("proof-p",data);participant.select("a.icon_trash")[0].rel=response.pk_id;participant.select(".proof-p-role")[0].id="prole-"+response.pk_id;participant.select(".proof-p-deadline")[0].id="pdeadline-"+response.pk_id;$("proofParticipantsTable").insert({bottom:participant});participant.show();var container=$(form).up(".proof-props-addp");container.removeClassName("expanded");$(form).up("dl").autosize();var winId=CD.TinyMCE.getWindowId(form);var win=cdwm.getWindow(winId);cdwm.resizeByContent(win);C2EManager.init()}},false)};this.actions.remove=function(discId,catId,hardDelete,goToUrl){if(hardDelete&&goToUrl){if(confirm("Permanently delete "+this.displayName+"? This action cannot be undone.")){var url=CD.Environment.space.relative_url+this.namespace+"/"+discId+"/";var params={doaction:"delete",hardDelete:true,format:"json",rand:Math.random()};new CD.Ajax.Request(url,{method:"post",parameters:params,onSuccess:function(item){window.location=goToUrl+"?successmsg="+encodeURIComponent('Deleted "'+item.name+'"')}});return true}else{return false}}else{if(confirm("Send this "+this.displayName+" to the Trash?")){var url=CD.Environment.space.relative_url+this.namespace+"/"+discId+"/";var params={doaction:"delete",format:"json",rand:Math.random()};new CD.Ajax.Request(url,{method:"post",parameters:params,onSuccess:function(item){if(pgref.is){parent.parent.overlay.hide()}else{window.location=CD.Environment.space.relative_url+CD.Folder.namespace+"/"+catId+"/?successmsg="+encodeURIComponent('Moved "'+item.name+'" to Trash')}}})}}};this.actions.deleteRevision=function(itemURL,rev,refer){var refer=refer||document.location;if(typeof(rev)=="undefined"||typeof(itemURL)=="undefined"){return false}if(confirm("Are you sure you want to permanently delete version "+rev+"?")){var url=itemURL+"&doaction=delete_revision&versionids[]="+rev+"&refer="+refer;document.location=url}return false};this.actions.restoreWikiPage=function(itemId){var url=CD.Environment.space.relative_url+this.namespace+"/"+itemId+"/";var params={doaction:"restoreWikiPage",format:"json",rand:Math.random()};new CD.Ajax.Request(url,{method:"post",parameters:params,onSuccess:function(item){if(item){window.location.href=CD.Environment.space.relative_url+"doc/"+item.id+'/?successmsg=Successfully restored "'+item.title+'"'}}})};this.actions.checkPassword=function(itemId,file_password,remember_file_password,pgref_force,reload_function){if(remember_file_password==undefined){remember_file_password=false}if(!reload_function){reload_function=overlay.reload}var params={doaction:"check_password",file_password:file_password,remember_file_password:remember_file_password,rand:Math.random(),format:"json"};var url=CD.Environment.space.relative_url+this.namespace+"/"+itemId+"/";var controller=this;new Ajax.Request(url,{method:"post",parameters:params,onComplete:function(request){var response=CD.AjaxResponseHandler(request);if(response.success){if(pgref_force=="inlb"){document.location=response.url+"?pgref=vr&lbref=lb"}else{if(pgref_force){overlay.showFullScreen("",response.url,pgref_force,reload_function)}else{document.location=response.url}}}else{overlay.hide();controller.showDialog("checkPassword",itemId,true,pgref_force,reload_function)}}});overlay.hide()},this.actions.changePassword=function(itemId,file_password){var params={doaction:"change_password",file_password:file_password,rand:Math.random(),format:"json"};var url=CD.Environment.space.relative_url+this.namespace+"/"+itemId+"/";new CD.Ajax.Request(url,{method:"post",parameters:params,onSuccess:function(response){if(response=="OK"){var elem=document.createElement("div");elem.style.padding="15px 5px 5px 5px";var html='<div id="changed_password"><div class="centered">';if(file_password==""){html=html+"The password for this document has been removed."}else{html=html+"The password for this document has successfully been changed to <b>"+file_password+"</b>."}html=html+'</div><br/><div class="centered"><input type="button" class="rbutton tm5 bm5 w50" onclick="document.location.reload(); overlay.hide();" value="Ok"/></div></div>';elem.innerHTML=html;var params={title:'<ins class="icon cd_icon_lock"></ins> Password',type:"dynamic",element:elem,inline:1,clear:true,beforeRender:function(){},afterRender:function(){}};overlay.hide();var ret=overlay.show(params,true)}}})};this.actions.rollback=function(itemId,revision,isHome){isHome=isHome||false;cdwm.confirm("You are about to make Revision "+revision+" the Current Version.\nAre you sure?",function(btnClicked){if(btnClicked){var params={doaction:"rollback",rev:revision,rand:Math.random(),format:"json"};var namespace=CD.getNamespace(isHome?CD.Wiki.item_type:CD.Environment.model.item_type);var url=CD.Environment.space.relative_url+namespace+"/"+itemId+"/";new CD.Ajax.Request(url,{method:"post",parameters:params,onSuccess:function(request){if(isHome){url=CD.Environment.space.relative_url+"home"+pgref.uri}else{url=url+"?"+pgref.uri}window.location=url}})}})};this.actions.showRevisionsDropdown=function(controlElem,itemId){controlElem=$(controlElem);var dd=new Dropdown("morerev_tmp",function(){var elem=$("morerev");return elem},{});document.body.appendChild(dd);box_width=410;boxDim=$(dd).getDimensions();ctrlDim=controlElem.getDimensions();dd.style.width=box_width+"px";var controlElmDim=controlElem.getDimensions();var controlElmPos=controlElem.cumulativeOffset();var boxDim=dd.getDimensions();var screenDim=document.viewport.getDimensions();boxDim.width=box_width;var top=controlElmPos[1]+controlElmDim.height+dd.params.margins.top+"px";if(controlElmPos[0]+boxDim.width+dd.params.margins.left>screenDim.width){var left=controlElmPos[0]-(boxDim.width+dd.params.margins.left-controlElmDim.width)-dd.params.margins.right+"px"}else{var left=controlElmPos[0]+dd.params.margins.left+"px"}dd.style.left=left;dd.style.top=top;dd.style.width=box_width+"px";dd.style.display="block"};this.actions.deployAssigneesPicker=function(holderElmId,itemType,itemId,reload){var holderElm=$(holderElmId);if(!holderElm){return}if(!window.upicker||reload){if(window.upicker){$(window.upicker).remove()}window.upicker=new UserPicker({sourceURL:CD.Environment.space.relative_url+itemType+"/"+itemId+"/?doaction=handleAssignments&format=json",maxHeight:150,selectable:CD.permissions.canListManage(spid),selectedOnly:!CD.permissions.canListManage(spid),emptyListMessage:"There are no subscribed users",ownUserId:uid?uid:null});window.upicker.init();holderElm.appendChild(window.upicker)}};return this}CD_Object.makeSubclass(CD_Item);window.CD.Item=new CD_Item();window.CD.Item.UI={LOADING:'<div class="loading-bar"><ins class="ajax-loader"></ins> Loading contents&hellip;</div>'};window.CD.Item.UI.deployComments=function(e,d,b,a){var c=$(e);if(c){url=CD.Environment.space.relative_url+CD.getItemTypeAsString(b)+"/"+d+"/comments/";new CD.Ajax.Request(url,{method:"post",parameters:{showForm:!!a},onSuccess:function(g){c.update(g.responseText);CD.Comment.UI.addEvents({spaceid:spid,activity_type:CD.Environment.model.activity_type});var f=$("comment_comment");f.addClassName("rte_discussion");tinyMCE.execCommand("mceAddControl",false,f.id)}},false)}return false};window.CD.Item.UI.pollPreview=function(k,h,d,m,e,c){var a=$(k);var g=$(h);var b=$(d);if(a&&g&&b){function f(q,p,s){var o=CD.Environment.space.relative_url+CD.getItemTypeAsString(e)+"/"+m;var n=o+"/preview";var r={isAjaxRequest:"true",format:"json",rand:Math.random()};CD.Ajax.Request(o,{method:"get",parameters:r,onSuccess:function(x){var t=!!x.preview_swf;var u=(!c||(x.virus>=0));var w=(c&&(x.virus==1));if(w){location.reload()}var v=(t&&u);if(v&&!w&&(g.style.display=="none")){g.style.display="block";a.style.display="none";b.src=n}else{if(!v&&s){msg=a.down();msg.innerHTML="A File Preview is being generated.  Please check back in a few minutes.  You can download the file above instead."}}q(v)}})}poller=new CD.Poller(f,{intervals:[2,4,8,16,30],immediate:true})}return false};window.CD.Item.UI.switchTabs=function(d,p,h){var o=true;if(arguments.length==4){o=arguments[3]}var n=$(d);if(!n){return false}var r=$(n.up());var q=r.select("li");for(var k=0;k<q.length;k++){var e=q[k];if(e.id==d){e.addClassName("tab_selected")}else{e.removeClassName("tab_selected")}}var m=$$(".tab_comments_locked");if(m.length>0){if(d=="tab_comments"){m[0].style.display=""}else{m[0].style.display="none"}}var c="/spaces/doaction_tasks";switch(d){case"tab_comments":c=CD.Environment.space.relative_url+CD.getItemTypeAsString(h)+"/"+p+"/comments/";break;case"tab_versions":c=CD.Environment.space.relative_url+CD.getItemTypeAsString(h)+"/"+p+"/revisions/";break;case"tab_audit":c=CD.Environment.space.relative_url+CD.getItemTypeAsString(h)+"/"+p+"/auditlog/";break;case"tab_proof":c=CD.Environment.space.relative_url+CD.getItemTypeAsString(h)+"/"+p+"/proofactivity/";break}CD.Cookies.write("itemViewTab",d);CD.Item.UI.replaceTabContent(d,CD.Item.UI.LOADING,false);if(o){dom.utils.scrollTo(r)}var f=new RegExp("[\\?&]num=([^&#]*)");var g=f.exec(window.location.href);var t=g==null?"0":decodeURIComponent(g[1]);var s=new RegExp("[\\?&]pgref=([^&#]*)");var a=s.exec(window.location.href);var b=a==null?"":decodeURIComponent(a[1]);new CD.Ajax.Request(c,{method:"post",parameters:{num:t,pgref:b},onSuccess:function(u){CD.Item.UI.replaceTabContent(d,u.responseText,true)}},false);return false};window.CD.Item.UI.replaceTabContent=function(b,f,h){h=h||false;try{var a=$(document.forms.addReply).select("textarea").first()}catch(g){}try{tinyMCE.execCommand("mceRemoveControl",false,a.id)}catch(g){}$$(".item-tab-wrapper ul").each(function(e){if(e.hasClassName(b)){e.style.display=""}else{e.style.display="none"}});var c=$("tab_contents");c.select(".tab_content").each(function(e){e.addClassName("bl-dynamic")});var d=$("content_"+b);if(!d){d=new Element("div",{id:"content_"+b,"class":"tab_content"});c.appendChild(d)}d.innerHTML=f;d.removeClassName("bl-dynamic");if(b==="tab_comments"){try{a=$(document.forms.addReply).select("textarea").first();tinyMCE.execCommand("mceAddControl",false,a.id)}catch(g){}if(h){CD.Comment.UI.addEvents({spaceid:spid,activity_type:CD.Environment.model.activity_type,callbacks:{onSaveNew:function(n,e){try{var m=$$("#tab_comments .count")[0];m.innerHTML=(parseInt(m.innerHTML,10)+1)}catch(k){}}}})}}};window.CD.Item.UI.fetchVersionHistory=function(e,c,g,a,b){var d=CD.Environment.space.relative_url+CD.getItemTypeAsString(g)+"/"+c+"/revisions/";var f={spid:e,recid:c,guid:a,num:b,rand:Math.random()};new CD.Ajax.Request(d,{method:"post",parameters:f,onSuccess:function(h){CD.Item.UI.replaceTabContent("tab_versions",h.responseText)}})};window.CD.Item.UI.fetchAuditLog=function(e,c,g,a,b){var d=CD.Environment.space.relative_url+CD.getItemTypeAsString(g)+"/"+c+"/auditlog/";var f={spid:e,recid:c,guid:a,num:b,rand:Math.random()};new CD.Ajax.Request(d,{method:"post",parameters:f,onSuccess:function(h){CD.Item.UI.replaceTabContent("tab_audit",h.responseText)}})};window.CD.Item.UI.deleteAuditLogEntry=function(d,e,c,g,a,b){var f=$(d.parentNode.parentNode);if(f.hasClassName("auditlog")){cdwm.confirm("Are you sure you want to delete this audit log entry? This entry can not be restored.",function(h){if(!h){return}new Ajax.Request(ajax_dt,{method:"post",parameters:ajax_params+"delete_file_audit_log&logids="+b,onComplete:function(k){var m=k.responseText.split("|");if(m[1]=="n"){if(f.nextSibling&&f.nextSibling.nextSibling&&f.nextSibling.nextSibling.tagName&&f.nextSibling.nextSibling.tagName.toLowerCase()=="hr"){f.parentNode.removeChild(f.nextSibling.nextSibling)}if(f.nextSibling&&f.nextSibling.tagName&&f.nextSibling.tagName.toLowerCase()=="div"&&$(f.nextSibling).hasClassName("clear")){f.parentNode.removeChild(f.nextSibling)}f.parentNode.removeChild(f)}displaystatus(m[0],m[1],"cccccc")}})})}else{}};function CD_Discussion(){CD_Item.call(this);this.namespace="discussion";this.displayName="Discussion";this.item_type=5;this.views.create=function(e,a){e=e||"std";var c,f,b;if(e=="db"){f="lb";c=CD.Environment.space.relative_url+"discussion/create/?discussion_fk_categoryid="+CD.Folder.ATTACHMENT+"&dbid="+a;b=overlay.reloadParent}else{var d=CD.Object.getValidCatid(null,CD.Folder.ANNOUNCEMENT);c=CD.Environment.space.relative_url+"discussion/create/?discussion_fk_categoryid="+d;f="";b=true}overlay.showFullScreen("",c,f,b)};this.views.email_addresses=function(e,d){var b=CD.Environment.space.relative_url+this.namespace+"/"+e+"/email_addresses/?rand="+Math.random();var c={title:"Email Addresses for: "+d,file:b,type:"dynamic",inline:1,width:650};var a=overlay.show(c,false);return a};this.actions.reply=function(d,a){var g="";try{var b=tinyMCE.get("message");g=b.getContent()}catch(f){var c=$("message");if(c){g=c.value}else{}}if(g=="<p>&nbsp;</p>"||g==""){alert("Please fill out your message before submitting this post.")}else{try{parent.parent.overlay.shouldReload=true}catch(f){}$("msg_sub_"+a).disabled=true;$("msg_sub_"+a).value="Posting...";d.submit()}};this.actions.showReplyForm=function(a,b){b=!!b;$(a).addClassName("cmt-replying");if(!b){$(a).select(".cmt-reply")[0].scrollTo()}tinyMCE.execInstanceCommand("message","mceFocus")};this.actions.hideReplyForm=function(a){$(a).removeClassName("cmt-replying")};this.actions.changeNotificationMode=function(a){var b={doaction:"changeNotificationMode",format:"json",notify:a,rand:Math.random()};new CD.Ajax.Request(CD.Environment.model.t_url,{method:"post",parameters:b,onSuccess:function(c){if(c=="OK"){document.location.href=CD.Environment.model.t_url}else{cdwm.alert(c)}}})};this.actions.togglePswField=function(a){msg_form_0.discussion_file_password.diabled=!a.checked;$(msg_form_0.discussion_file_password)[a.checked?"show":"hide"]();if(a.checked){msg_form_0.discussion_file_password.focus()}};this.actions.vote=function(a){var b=$(a).up(".poll");b.addClassName("poll-isprocessing");var c={doaction:"vote",format:"json",answer:a.rel,rand:Math.random()};new CD.Ajax.Request(CD.Environment.model.t_url,{method:"post",parameters:c,onSuccess:function(d){b.update(d);b.removeClassName("poll-isprocessing")}})};this.actions.addPollAnswer=function(){var a=$("poll_answer_tpl").innerHTML.strip();$("pollAnswers").insert({bottom:a})}}extend(CD_Discussion,CD_Item);window.CD.Discussion=new CD_Discussion();CD=CD||{};function CD_Document(){CD_Item.call(this);this.namespace="doc";this.displayName="Document";this.item_type=1;this.o=this;this.convertTitleToPagename=function(d){var c=d.split(" ");for(var b=0;b<c.length;b++){c[b]=(c[b].substring(0,1).toUpperCase())+c[b].substring(1)}d=c.join("");var a=new RegExp("[^a-zA-Z0-9 ]{1,}","g");d=d.replace(a,"");return d};this.views.email=function(e,a){var c=CD.Environment.space.relative_url+"doc/"+e+"/email/&r="+Math.random()+(a?"&rev="+a:"");var f=700;var d={title:"Email This Page: "+CD.Environment.model.name,file:c,type:"dynamic",inline:1,width:f};var b=cdwm.open(false,d);return b};this.actions.startNewDoc=function(b,c){b=CD.Object.getValidCatid(b,CD.Folder.GENERAL);var a=CD.Environment.space.relative_url+"doc/create/?mode=webdoc&doc_fk_categoryid="+b+"&dbid="+(pgref.dbid?pgref.dbid:"");window.location=a};this.views.createDoc=function(d,c){catId=CD.Object.getValidCatid(d,CD.Folder.GENERAL);var g="";if(!browser.isIPhoneCompatible){tinyMCE.activeEditor.save();var e=tinyMCE.activeEditor.getDoc().body;g=tinyMCE.activeEditor.getContent();if(g==""&&e.textContent){g=e.textContent}if(g==""&&e.innerText){g=e.innerText}if(g==""){g=tinyMCE.activeEditor.getContent()}}else{g=tinyMCE.activeEditor.getElement().value}g=g.split("<br />");g=g[0].replace(/<\/?[^>]+>/g,"");g=g.replace("&nbsp;"," ");g=g.split("\n");g=g[0].split("\r");g=g[0].substr(0,100);var h="doc_title="+encodeURIComponent(g)+"&doc_fk_categoryid="+d+"&doc_item_type="+CD.Environment.model.item_type+"&rand="+Math.random()+pgref.uri;var a=CD.Environment.space.relative_url+"doc/savenew/?"+h;var k=tagging_on?710:510;var b={title:"Create a New Document",file:a,type:"dynamic",inline:1,width:k,afterLoad:function(){wiki_items.file_detail.item_tags.get_js_array(false);$("docTitle").focus();CD.Folder.doAction("deployMembersPicker","upholder",d,true)}};var f=overlay.show(b,false);return f};this.actions.validateNewPage=function(b){var d=b.form;var g=document.getElementById("docTitle").value;g=CD.Document.convertTitleToPagename(g);if(g==""){cdwm.alert("You must enter a Page Name. Please note that only alpha numeric characters are allowed. Other characters are removed.");return false}else{if(d.elements.webdoc_list_0.value==""){cdwm.alert("You must select a Folder Name");return false}else{var c=b.value;b.value="Saving...";b.disabled=true;try{parent.parent.overlay.shouldReload=true}catch(h){}var a=CD.Environment.model;var f=CD.Folder.doAction("hasChildName",a.catid,$("docTitle").value,a.id||null,a.item_type);if(f){b.value=c;b.disabled=false;if(a.item_type==CD.ITEM_TYPE_WIKI){cdwm.alert("There is already a wiki page with that name.")}else{cdwm.alert("There is already a file or folder with that name.")}return false}else{CD.Document.doAction("saveNewDoc",true)}}}};this.actions.saveNewDoc=function(b){var a=tinymce.plugins.CDWM.cdwm;var c=$(a.win.iframeElement.id);var f=document;if(b){document.edit.doc_title.value=f.forms.note_show_add_form.doc_title.value;document.edit.doc_fk_categoryid.value=f.forms.note_show_add_form.webdoc_list_0.value}document.edit.doc_item_status.value=f.note_show_add_form.item_status.value;document.edit.doc_tags.value=f.note_show_add_form.tags.value;if(CD.permissions.canListManage(spid)){document.edit.check_in_comments.value=f.note_show_add_form.check_in_comments.value;document.edit.cc_me.value=document.getElementById("cc_me_checkbox").checked?"true":"false"}document.edit.notify_users.value=f.note_show_add_form.notify_users.checked?"true":"false";if(f.note_show_add_form.notify_users.checked){document.edit.notify_userids.value=upicker.getSelected(true)}try{tinyMCE.activeEditor.execCommand("mceCDWM_Close")}catch(d){}disablesubmit("tasave","Saving...");needToConfirm=false;window.onunload=function(){return true};document.edit.submit()};this.actions.saveDoc=function(d){var a=CD.Environment.model;if(d!=""){wiki_tools.check_save(document.edit);if(wiki_tools.ok_to_save===false){return false}}if(document.edit.doc_title.value==""){cdwm.alert("Please enter a title for this "+(a.item_type==CD.Wiki.item_type?"Wiki page":"Online document"));return false}else{var b=CD.Folder.doAction("hasChildName",a.catid,document.edit.doc_title.value,a.id||null,a.item_type);if(b){if(a.item_type==CD.Wiki.item_type){cdwm.alert('There is already a Wiki page with the title "'+document.edit.doc_title.value+'". Please enter a different title.')}else{cdwm.alert('There is an item or folder with the name "'+document.edit.doc_title.value+'". Please enter a different name.')}return false}}if(!browser.isIPhoneCompatible){tinyMCE.activeEditor.save()}disablesubmit("tasave","Saving...");needToConfirm=false;window.onunload=function(){return true};try{parent.parent.overlay.shouldReload=true}catch(c){}document.edit.submit()};this.actions.saveAndNotify_Document=function(c,h,g){var a=tinymce.plugins.CDWM.cdwm;var b=$(a.win.iframeElement.id);var f=document;if(g){document.edit.doc_title.value=f.getElementById("docTitle").value;document.edit.doc_fk_categoryid.value=f.getElementById("webdoc_list_0").value}document.edit.doc_item_status.value=f.note_show_add_form.item_status.value;document.edit.doc_tags.value=f.note_show_add_form.tags.value;document.edit.check_in_comments.value=f.note_show_add_form.check_in_comments.value;document.edit.cc_me.value=($("cc_me_checkbox")&&$("cc_me_checkbox").checked)?"true":"false";document.edit.notify_userids.value=typeof(upicker)!=="undefined"?upicker.getAltered(true):null;document.edit.notify_users.value=document.edit.notify_userids.value.length>2;tinyMCE.activeEditor.execCommand("mceCDWM_Close");disablesubmit("tasave","Saving...");needToConfirm=false;window.onunload=function(){return true};try{parent.parent.overlay.shouldReload=true}catch(d){}document.edit.submit()};this.actions.cancelEdit=function(a,b){needToConfirm=false;disablesubmit("tasave");if(a){CD.Document.doAction("removeAutoSave",a,function(d){if(d=="OK"){var c=true;CD.Document.doAction("cancelEditMode",a,function(e){if(pgref.is){parent.parent.overlay.hide()}else{if(document.edit.source.value!=""){window.location=document.edit.source.value}else{if(document.edit.mode.value=="webdoc"&&(!urlparam("rev")||urlparam("rev")<1)){history.back()}else{window.location=CD.Environment.space.relative_url+"doc/"+a+"/?"+b}}}})}else{return false}})}else{if(pgref.is){parent.parent.overlay.hide()}else{if(document.edit.source.value!=""){window.location=document.edit.source.value}else{if(item_type=="0"){window.location=CD.Environment.space.relative_url+"FrontPage"}else{window.location=CD.Environment.space.relative_url+"folder/"+document.edit.doc_fk_categoryid.value+"/"}}}}};this.actions.autosave=function(k,d){try{var a=document.edit.doc_file_name.value;var c=document.edit.doc_fk_categoryid?document.edit.doc_fk_categoryid.value:0;var h=document.edit.mode.value;var g={rand:Math.random(),doaction:"autosave",doc_file_name:a,doc_fk_categoryid:c,mode:h,format:"json",content:d};var b=CD.Environment.space.relative_url+this.namespace+"/"+(k?k+"/":"");new CD.Ajax.Request(b,{method:"post",parameters:g})}catch(f){}};this.actions.removeAutoSave=function(c,a){if(c==""){if(typeof a=="function"){a("OK")}else{return true}}var d={doaction:"removeautosave",rand:Math.random(),format:"json"};var b=CD.Environment.space.relative_url+"doc/"+(c!=""?c+"/":"");new CD.Ajax.Request(b,{method:"post",asynchronous:false,parameters:d,onSuccess:function(e){if(typeof a=="function"){a(e)}else{return true}}})};this.actions.printToPdf=function(c,a){var b=CD.Environment.space.relative_url+CD.getItemTypeAsString(item_type)+"/"+c+"/printtopdf";document.location.href=b};this.actions.cancelEditMode=function(c,a){var b=CD.Environment.space.relative_url+"doc/"+c;var f={doaction:"canceleditmode",rand:Math.random(),format:"json"};try{parent.parent.overlay.shouldReload=false}catch(d){}new CD.Ajax.Request(b,{method:"post",parameters:f,asynchronous:false,onSuccess:function(e){if(typeof a=="function"){a(e)}else{return true}}})};this.views.compareWith=function(d,a,c,b){CD.Document.diff.revA=c;CD.Document.diff.revB=b;CD.Document.showDialog("diff",d,a)};this.views.diff=function(e,a){var d=this.diff.revA;var c=this.diff.revB;if(d&&c&&d!=c){var b=CD.Environment.space.relative_url+CD.getItemTypeAsString(a)+"/"+e+"/diff?revA="+d+"&revB="+c;document.location.href=b}else{cdwm.alert("You must select 2 different versions to compare.")}};this.diff={revA:null,revB:null};this.UI={resizeToWindow:function(f,e){var h=$(f.id+"_ifr");h.style.position="relative";var d=$(f.id+"_tbl");var g=d.select("tr.mceLast")[0];var k=g?dom.utils.getElementHeight(g):0;var c=dom.utils.getElementTop(h);var b=dom.utils.getWindowHeight(e);var a=(b-c-k-20);if(browser.isIE){a=a-30;h.style.height=(a)+"px"}else{h.style.height=(a)+"px";f.resizeToContent()}}};return this}extend(CD_Document,CD_Item);window.CD.Document=new CD_Document;function CD_Home(){CD_Document.call(this);this.views.permalink=function(a){var c='<div style="padding: 5px 5px 10px 5px; font-size: 14px; ">Link for this Workspace<div class="sml_break3"></div><input type="text" style="background-color: #fff; width: 450px; font-size: 14px;" readonly value="'+a+'" /></div><div style="padding: 7px 5px 5px 5px; font-size: 11px;">Here is the link to this workspace. You should use this link when pointing others to this workspace.</div>';var b=new Element("div");b.innerHTML=c;var d={url:null,file:null,element:b,inline:1,type:"dynamic",title:"Link to this Workspace"};cdwm.open(true,d)};this.actions.restoreDefault=function(a){cdwm.confirm("Permanently delete your customized home page? This action cannot be undone.",function(d){if(d!="true"){return false}else{var b=CD.Environment.space.relative_url+"doc/"+a+"/";var c={doaction:"delete",hardDelete:true,skipActivityLog:true,format:"json",rand:Math.random()};new CD.Ajax.Request(b,{method:"post",parameters:c,onSuccess:function(e){window.location=CD.Environment.space.relative_url+"home?successmsg="+encodeURIComponent("Removed custom home page")}});return true}})}}extend(CD_Home,CD_Document);window.CD.Home=new CD_Home;function CD_Wiki(){CD_Object.call(this);this.namespace="doc";this.displayName="Wiki";this.activity_type=2;this.item_type=0;var a=this;this.actions.move=function(c,g,b){var e=c[0];var d=CD.Environment.space.relative_url+this.namespace+"/"+e+"/";g=g=="-2"?null:g;var f={doaction:"move",format:"json",wikiIds:c,parentId:g,rand:Math.random()};new Ajax.Request(d,{method:"post",parameters:f,onSuccess:function(k){var h=CD.AjaxResponseHandler(k);if(typeof b=="function"){b(h)}}})};return this}extend(CD_Wiki,CD_Object);window.CD.Wiki=new CD_Wiki;function CD_File(){CD_Item.call(this);this.namespace="file";this.displayName="File";this.item_type=3;var a=this;this.actions.fetchTitle=function(f,b,d){var g=$(b);var e=CD.Object.getValidCatid(d,CD.Folder.GENERAL);if((g._prevUrl&&f==g._prevUrl)||!f.match(/^https?:\/\/[a-z0-9]+/i)){return}g.disabled=true;g.value="Attempting to fetch title...";g.addClassName("fetch-title-processing");var h={doaction:"fetchtitle",url:f,format:"json",file_fk_categoryid:e,rand:Math.random()};var c=CD.Environment.space.relative_url+"file/";new CD.Ajax.Request(c,{method:"get",parameters:h,onSuccess:function(k){g.value=k;g.disabled=false;g.removeClassName("fetch-title-processing");g._prevUrl=c}})};this.showEditLink=function(c){var b=$(c).select(".edit_link")[0];b.style.display=""};this.hideEditLink=function(c){var b=$(c).select(".edit_link")[0];b.style.display="none"};return this}extend(CD_File,CD_Item);window.CD.File=new CD_File;CD=CD||{};CD_Bookmark=function(){CD_Item.call(this);this.namespace="bookmark";this.displayName="Bookmark";this.item_type=4;this.toggleEdit=function(a){var d=$$(".item-descr-edit")[0];var b=$$(".item-descr-text")[0];var c=$$(".item-descr-wrapper")[0];if(d.style.display==""){d.style.display="none";c.style.display=""}else{d.style.display="";c.style.display="none"}};this.actions.updateDescription=function(d,f){var a;var h="metadesc_textarea_"+d;var b=$(h);var e=tinyMCE.get(h);if(e==null){a=b.value}else{a=e.getContent()}var c=cd_spaceurl+"file/"+f;var g={doaction:"editdesc",guid:d,c:a,format:"json"};new CD.Ajax.Request(c,{method:"post",parameters:g,onSuccess:function(m){var o=$("metadesc_"+d);var n=$("metadesc_text_"+d);var k=$("metadesc_edit_"+d);if(n==null){o.innerHTML=m.html}else{n.innerHTML=m.html}b.value=a;o.show();k.hide()}})};return this};CD_Item.makeSubclass(CD_Bookmark);window.CD.Bookmark=new CD_Bookmark();SysEvents.regEvents(["folder.bulk_delete_start","folder.bulk_move_start","folder.bulk_delete_complete","folder.bulk_move_complete"]);function CD_Category(){CD_Object.call(this);this.GENERAL=0;this.ARCHIVE=-1;this.RECENT=-2;this.TRASH=-3;this.ATTACHMENT=-4;this.DRAFT=-5;this.ANNOUNCEMENT=-6;this.ATTACHMENT_INTERNAL=-7;this.TRASH_INTERNAL=-8;this.POPULAR=-10;this.DOCUMENTS=-30;this.SPREADSHEETS=-31;this.BOOKMARKS=-32;this.WEBPAGES=this.BOOKMARKS;this.DISCUSSIONS=-33;this.FILES=-34;this.STATUS=-40;this.TAG=-41;this.MY_FAVORITES=-42;this.MY_CREATED=-43;this.MY_VIEWED=-44;this.LAST_SYSTEM_FOLDER=-8;this.displayName="Category";this.activity_type=20;this.item_type=20;this.views.create=function(a){};this.views.edit=function(b,a){};this.views.remove=function(){};this.views.mediaUpload=function(f,a,c){var b='<div class="overlay_box_content_header"><form enctype="multipart/form-data" action="/spaces/doaction_tasks" method="POST"><input type="hidden" name="MAX_FILE_SIZE" value="'+c+'" /><input type="hidden" name="do" value="media_upload"><input type="hidden" name="spid" value="'+f+'"><input type="hidden" name="requested_dir" value="'+a+'"><input name="userfile" id="media_userfile" type="file" /> <input type="submit" class="rbutton" onSubmit="if( $(\'media_userfile\').value=\'\') { cdwm.alert( \'Please selected a file.\'); return( false);} else {return( true);}" value="Upload" /></form></div>';var d=document.createElement("div");d.style.padding="5px";d.innerHTML=b;var e={title:"Upload a File",file:null,element:d,width:350,height:100,type:"dynamic",inline:1};overlay.show(e,false)};this.actions.create=function(a,k,o,n,h,b,d,f,e){b=b||2;h=h||1;d=d||false;f=f||0;e=e===false?false:true;var m=this.validate.name(a);if(m){nn_escaped=clean_prompt_input_box(a);var g={doaction:"create",folder_categoryname:nn_escaped,folder_parent_id:k,folder_private:o,folder_fk_categorytypeid:b,folder_display_option:h,folder_track_time:d,milestone_id:f,rand:Math.random(),format:"json"};var c=CD.Environment.space.relative_url+this.namespace+"/"+k+"/";new CD.Ajax.Request(c,{method:"post",parameters:g,onSuccess:function(p){if(typeof n=="function"){n(p)}}},e)}else{if(typeof n=="function"){n(false)}}};this.actions.edit=function(c,g,d,e,a){var h=this.validate.name(g);if(h){nn_escaped=clean_prompt_input_box(g);var f={doaction:"update",format:"json",folder_categoryname:nn_escaped,"display_option[]":d,folder_private:e,rand:Math.random()};var b=CD.Environment.space.relative_url+this.namespace+"/"+c+"/";new CD.Ajax.Request(b,{method:"post",parameters:f,onSuccess:function(k){if(typeof a=="function"){a(k)}}})}else{if(typeof a=="function"){a(false)}}};this.actions.remove=function(d,b,a){var f=window.confirm("Are you sure you want to delete Folder: "+b+"\nAll items within this folder will be moved to the trash.");if(f){var e={doaction:"delete",catid:d,rand:Math.random(),format:"json"};var c=CD.Environment.space.relative_url+this.namespace+"/"+d+"/";new CD.Ajax.Request(c,{method:"post",parameters:e,onSuccess:function(g){if(typeof a=="function"){a(g)}}})}};this.actions.switchView=function(d){var g=$("fld_contents");var f=CD.TreeNodeView.get();if(!f||!g){return true}if(d=="gallery"){try{if(!f.isImageGallery()){f.isImageGallery(true);var c=CD.TreeFactory.get("tree");if(c){CD.CategoryTree.goToNodeId("tree",CD.Environment.space.id,CD.Environment.model.id)}else{window.location.href=CD.Environment.model.turl+"image_gallery/";return true}}}catch(h){window.location.href=CD.Environment.model.turl+"image_gallery/";return true}}else{if(f.isImageGallery()){f.isImageGallery(false);try{CD.CategoryTree.goToNodeId("tree",CD.Environment.space.id,CD.Environment.model.id)}catch(h){window.location.href=CD.Environment.model.turl;return true}}else{var e=(d=="simple");if(CD.Cookies.Prefs.is_folder_view_simple()!=e){CD.Cookies.Prefs.set_folder_view_simple(e)}if(e){g.addClassName("fld-view-simple")}else{g.removeClassName("fld-view-simple")}}}var b=$("viewSwitchControls");if(b){b.select("a").each(function(k){k[k.rel==d?"addClassName":"removeClassName"]("fld-viewlink-selected")})}g.style.height="auto";var a=dom.utils.getElementHeight(g);g.style.height=a+"px";var c=CD.TreeFactory.get("tree");if(c){c.setResizableHeight(a)}};this.actions.initView=function(){var b=CD.TreeNodeView.get();if(!(b&&b.isImageGallery()&&b.hasImages())){var a=(CD.Cookies.Prefs.is_folder_view_simple()?"simple":"detailed");this.doAction("switchView",a)}};this.actions.selectAll=function(a){a=(undefined==a)?true:!!a;$("folderItemsList").select(".fld-row-chbx").each(function(b){if(b.checked!=a){b.click()}})};this.actions.bulkAction=function(m,r){var r=r||{};var f=CD.Folder.ATTACHMENT;try{if(CD.Environment.model.activity_type==CD.ITEM_TYPE_DB_RECORD){f=CD.Environment.model.fk_categoryid}else{if(CD.Environment.model.item_type==CD.ITEM_TYPE_FOLDER){f=CD.Environment.model.id}}}catch(c){}var p={noselection:"You must select at least one item before selecting an action",noitems:"You must select at least one file before selecting an action",nofolders:"You must select at least one folder before selecting an action",itemsonly:"This action will only apply to files",foldersonly:"This action will only apply to folders",infected:"One of the files you have selected is quarantined.<br/>This action is not allowed for it.",proofLock:"Items that are currently in Proof Mode may not be modified."};var k=[];$$(".fld-row-chbx").each(function(v){if(v.checked){k.push(v.value)}});var g=[];$$(".fld-item-chbx").each(function(v){if(v.checked){g.push(v.value)}});var o=[];$$(".fld-folder-chbx").each(function(v){if(v.checked){o.push(v.value)}});var t=false;$$(".avscan-infected-chx").each(function(v){if(v.checked){t=true}});var u=0;var a=1;var d=2;var b=3;function q(A){var z="";var w=true;switch(A){case u:if(!k.length){z=p.noselection;w=false}for(var v=0;v<g.length;v++){var y=$("item_"+g[v]);if(y.hasClassName("proof-lock")){z=p.proofLock;w=false}}break;case a:if(!g.length){z=p.noitems;w=false}if(o.length){z=p.itemsonly}for(var v=0;v<g.length;v++){var y=$("item_"+g[v]);if(y.hasClassName("proof-lock")){z=p.proofLock;w=false}}break;case d:if(!o.length){z=p.nofolders;w=false}if(o.length){z=p.foldersonly}break;case b:if(t){z=p.infected;w=false}break}if(z){cdwm.alert(z)}return w}switch(m){case"email":if(!q(a)||!q(b)){return false}CD.Expilink.Dialogs.email(g);CD.Folder.doAction("selectAll",false);break;case"downloadzip":if(!q(a)||!q(b)){return false}new Ajax.Request(ajax_dt,{method:"post",parameters:ajax_params+"downloadzip&itemids="+g.join(","),onComplete:function(w){var v=w.responseText;if(v.substring(0,4)=="http"){location.href=v}else{cdwm.alert(v)}CD.Folder.doAction("selectAll",false)}});break;case"status":if(!q(a)){return false}var e=ajax_params;e+="change_item_status_multiple";e+="&itemids="+g.join(",");e+="&new_status="+r.status;var n=!!r.indbrec;new Ajax.Request(ajax_dt,{method:"post",parameters:e,onComplete:function(w){if(!n){try{CD.CategoryTree.goToNodeId("tree",CD.Environment.space.id,CD.Environment.model.id)}catch(v){window.location.reload()}}else{window.location.reload()}}});break;case"delete":r.to=CD.Folder.TRASH;case"move":if(!q(u)){return false}SysEvents.fire(m=="delete"?"folder.bulk_delete_start":"folder.bulk_move_start");var h=CD.TreeFactory.get("tree");CD.Item.doAction("move",g,o,CD.Environment.space.id,f,CD.Environment.space.id,r.to,function(w){var z=w.split("|");var y=z[2];var C=JSON.parse(z[3]);var E="";var B="moved";var D=false;for(var x=0;x<C.length;x++){var v=CD.TreeNodeFactory.get(h,h.getSpaceId(),C[x]);v.setParentId(r.to);var A=v.getElement();A.parentNode.removeChild(A);v.draw()}if(g.length==y){$$(".fld-item-chbx").each(function(F){if(F.checked){F.up("tr").remove()}});D=true}else{E="Some files";D=false}if(o.length==C.length){$$(".fld-folder-chbx").each(function(F){if(F.checked){F.up("tr").remove()}});D=true}else{if(E==""){E="Some folders"}else{E+=" & folders"}D=false}if(r.to==CD.Folder.TRASH){B="deleted"}if(D){notify("Successfully "+B.capitalize(),"success")}else{if(E!=""){notify(E+" were not "+B,"notice");CD.CategoryTree.goToNodeId("tree",CD.Environment.space.id,CD.Environment.model.id)}}});break;case"deleteperm":if(!q(u)){return false}var e=ajax_params;e+="emptytrash";e+="&itemids="+g.join(",");e+="&folderids="+o.join(",");new Ajax.Request(ajax_dt,{method:"post",parameters:e,onComplete:function(v){var w=v.responseText.split("|");if(g.length){$$(".fld-item-chbx").each(function(x){if(x.checked){x.up("tr").remove()}})}if(o.length){$$(".fld-folder-chbx").each(function(x){if(x.checked){x.up("tr").remove()}})}}});break;case"mowo":if(!q(u)){return false}CD.Item.showDialog("move",g.join(","),o.join(","),"Items");break;case"detach":if(!q(u)){return false}var s=r.split("|");new Ajax.Request(ajax_dt,{method:"post",parameters:ajax_params+"unattach_object_from_record&itemids="+g.join(",")+"&guid="+s[0]+"&recid="+s[1],onComplete:function(w){var v=$("folderItemsList");var x=w.responseText.split("|");if(x[1]=="n"){remove_table_rows(v,g,"item_")}$("check_all_boxes").checked=false}});break}};this.actions.showImageGallery=function(a){document.location.href=CD.Environment.space.relative_url+this.namespace+"/"+document.forms.bmform.elements.cat.value+"/image_gallery/"};this.actions.deployMembersPicker=function(a,c,d,e){var b=$(a);if(!b){return}if(!window.upicker||d){if(window.upicker){$(window.upicker).remove()}window.upicker=new UserPicker({sourceURL:CD.Environment.space.relative_url+this.namespace+"/"+c+"/?doaction=handleMembers&format=json",maxHeight:150,ownUserId:uid?uid:null,selectAll:!!e});window.upicker.init();b.appendChild(window.upicker);window.upicker.adjustSize()}};this.validate.name=function(a){if(a!=null&&a!="null"&&a!=""){return true}else{alert("You must enter a valid name");return false}};return this}CD_Object.makeSubclass(CD_Category);window.CD.Category=new CD_Category();CD.Category.DISPLAY_OPTION={FILE:1,BLOG:2,FORUM:4,DATABASE:8};function create_new_cat_js_popup_insert_select(c,e){var b=$(e);switch(c){case 2:var a="Enter a new Folder Name below";break;case 9:var a="Enter a new Task List Name below";break}var d=window.prompt(a,"");if(d==null){b.selectedIndex=0}else{if(d!=null&&d!="null"&&d!=""){nn_escaped=clean_prompt_input_box(d);if(c==2){new CD.Ajax.Request(ajax_dt,{method:"post",parameters:ajax_params+"category_add&activity_type="+c+"&new_folder_name="+nn_escaped+"&format=json",onSuccess:function(f){if(f){var h=f;var k=b.options.length;var g=new Option(unescape(nn_escaped),h);b.options[k]=g;b.selectedIndex=k}else{cdwm.alert("Unknown Error Encountered")}}})}else{if(c==9){new CD.Ajax.Request("/zf-front.php/creately/project/tasklist/index.jsonenv",{method:"post",parameters:"fk_spaceid="+CD.Environment.space.id+"&title="+nn_escaped+"&private=false&fk_milestoneid=&spid="+CD.Environment.space.id+"&coid="+CD.Environment.company.id+"&format=jsonenv",onSuccess:function(g){if(g){var f=g.response.pk_id;var k=b.options.length;var h=new Option(unescape(nn_escaped),f);b.options[k]=h;b.selectedIndex=k}else{cdwm.alert("Unknown Error Encountered")}}})}}}else{create_new_cat_js_popup_insert_select(ctid,e)}}}function create_new_cat_checkEnter(d,e,a){var d=d&&d.which?d:window.event?window.event:null;var b;var c=true;if(window.event){b=d.keyCode}else{b=d.which}if(b==13){create_new_cat_action(e,a);c=false;d.returnValue=c}return c}function create_new_cat_action(d,a){var e=$("new_category_name").value;if(e!=null&&e!="null"&&e!=""){disablesubmit("overlay_button_ok","Creating...");nn_escaped=clean_prompt_input_box(e);var b=(document.getElementById("sub_category_id"))?$("sub_category_id").value:0;if(document.getElementById("new_category_folder_private")){var c=($("new_category_folder_private").checked)?"true":"false"}else{var c="false"}new CD.Ajax.Request(ajax_dt,{method:"post",parameters:ajax_params+"category_add&activity_type="+d+"&new_folder_name="+nn_escaped+"&cat1id="+b+"&private="+c,onSuccess:function(f){var g=f.responseText;if(a==""){parent.window.location.reload()}else{parent.window.location=a+g}}})}else{alert("You must enter a valid name");$("new_category_name").focus()}}function CD_Folder(){CD_Category.call(this);this.reload=false;var a=this;this.namespace="folder";this.displayName="Folder";this.activity_type=2;this.views.permalink=function(){var c=CD.Environment.model.id;var b=CD.Environment.space.relative_url+this.namespace+"/"+c+"/permalink/";var d={title:"Permanent Link for this "+this.displayName,file:b,type:"dynamic",inline:1};overlay.show(d,true)};this.views.uploadSingle=function(g,c,f,b){var k=CD.Folder.ATTACHMENT;var d="";try{if(CD.Environment.model.activity_type==CD.ITEM_TYPE_DB_RECORD||g=="db"){k=CD.Environment.model.fk_categoryid}else{if(CD.Environment.model.item_type==CD.ITEM_TYPE_FOLDER){k=CD.Environment.model.id}}}catch(h){}overlay.showFullScreen("",CD.Environment.space.relative_url+this.namespace+"/"+k+"/uploadsingle/?"+c,f,b)};this.views.uploadFiles=function(o,f,n,b,d){var h=(d!=null)?d:CD.Folder.ATTACHMENT;try{if(CD.Environment.model.activity_type==CD.ITEM_TYPE_DB_RECORD||o=="db"){h=CD.Environment.model.fk_categoryid}else{if(CD.Environment.model.item_type==CD.ITEM_TYPE_FOLDER){h=CD.Environment.model.id}}}catch(m){}var c=CD.Environment.space.relative_url+this.namespace+"/"+h+"/uploadmulti/?"+f+"&upload_type="+o;var g={title:"Upload Files",file:c,width:575,inline:1};var k=overlay.show(g,true);return k};this.views.javaBulkUpload=function(k,n,g,c,m){c=c||"";m=m||"";var f="";var d="";try{if(k=="media"){d=n;n=""}else{if(k=="db"){f=CD.Folder.ATTACHMENT;d="Attachments"}else{if(CD.Environment.model.item_type==CD.ITEM_TYPE_FOLDER){f=CD.Environment.model.id;d=CD.Environment.model.name}else{f=m||CD.Environment.model.catid;d=c}}}}catch(h){}var b="/spaces/javaupload?upload_type="+k+"&spid="+spid+"&spacename="+encodeURIComponent(spacename_long)+"&cat="+f+"&dbid="+pgref.dbid+"&catname="+encodeURIComponent(d)+"&tag="+encodeURIComponent(n)+"&max_upload_kb="+g;remote_bulk=window.open(b,name,"height=140,width=330,toolbar=no,location=no,scrollbars=no,menubar=no");if(remote_bulk.opener==null){remote_bulk.opener=window}},this.views.savePage=function(g,b){g=g||"std";var k=CD.Folder.ATTACHMENT;var f="";var d=true;var c="";try{if(CD.Environment.model.activity_type==CD.ITEM_TYPE_DB_RECORD||g=="db"){k=CD.Environment.model.fk_categoryid;f="lb";d=overlay.reloadParent;c="dbid="+b}else{if(CD.Environment.model.item_type==CD.ITEM_TYPE_FOLDER){k=CD.Environment.model.id;if(k==CD.Folder.RECENT){k=CD.Folder.GENERAL}}}}catch(h){}overlay.showFullScreen("",CD.Environment.space.relative_url+this.namespace+"/"+k+"/savepage/?"+c,f,d)};this.views.create=function(f,m,e,n){m=m||1;var c=null;var h=true;if(CD.Environment.model.catid!=undefined){c=CD.Environment.model.catid}else{c=CD.Environment.model.id||0;h=CD.Environment.model.canCreate}if(c<0){c=0}if(!h&&c!=0){cdwm.alert('You do not have create permissions for folder "'+CD.Environment.model.name+'".');return false}var k="parent_id="+c+"&window_loc="+encodeURIComponent(document.location.href)+"&display_option="+m+"&onCreateSuccess="+e+"&onCreateFailure="+n;var o="";switch(m){case 2:o="Blog Category";break;case 4:o="Forum Category";break;default:o="Folder";break}var p=CD.TreeFactory.get("subfolder");if(p){p.setSelectedNodeId(c)}var b=CD.Environment.space.relative_url+this.namespace+"/"+c+"/create/?"+k;var d={title:"Create a New "+o,file:b,type:"dynamic",inline:1,dedicated:1,beforeRender:function(){wiki_items.file_detail.hide_preview(true)},afterRender:function(){$("newFolderName").focus()}};var g=overlay.show(d,true);return g};this.views.edit=function(e,k){var f="rand="+Math.random()+"&window_loc="+encodeURIComponent(document.location.href)+"&shareTab="+(k?"true":"false");var d=CD.Environment.space.relative_url+this.namespace+"/"+CD.Environment.model.id+"/edit/?"+f;var b=k?580:257;var g=k?550:490;var h={title:"Edit Folder Properties",file:d,type:"dynamic",inline:1,width:g,height:b,beforeLoad:function(){wiki_items.file_detail.hide_preview(true)},afterLoad:function(){if(!k){$("newFolderName").focus()}},afterClose:function(){if(CD.Folder.reload){document.location.reload()}}};var c=overlay.show(h,true);return c};this.views.emailAddresses=function(){var d,c,b;if(CD.Environment.model.id<0&&CD.Environment.model.id!=CD.Category.ANNOUNCEMENT){d=0;c="general";b="Items not in Folders"}else{d=CD.Environment.model.id;c=CD.Environment.model.guid;b=CD.Environment.model.name}wiki_items.show_emails(d,c,b,"folder")};this.views.sharedLimits=function(c,b){var e="";if(b>0){e+="You have reached the Maximum Shared Folders allowed for your Account.<br />";e+="Your current Plan includes "+b+" Shared Folders and you currently have "+c+" Shared Folders."}else{e+="Your Plan does not include any Shared Folders.  "}e+='<br /><br /><a href="/home/upgrade_account" target="_top">Click Here to see Your Upgrade Options.</a><br /><br />';var d={width:570};return cdwm.alert(e,d)};this.tabs=new Array("general","sharing");this.selectTab=function(e){var b=this.tabs[0];for(var c=0;c<this.tabs.length;c++){var d=this.tabs[c];if($(d+"_tab").hasClassName("current")){b=d;if(b==e){return false}$(d+"_tab").removeClassName("current");$(d+"_settings").style.display="none";$(d+"_buttons").style.display="none"}}$(e+"_tab").addClassName("current");$(e+"_settings").style.display="block";$(e+"_buttons").style.display="block";cdwm.resizeByContent()};this.getWorkspaceTree=function(d,f){var g=d.options[d.selectedIndex].value;var c=d.options[d.selectedIndex].innerHTML;var b=CD.TreeFactory.get(f);var e=b.getRootNode();e.removeChildren();b.setSpaceId(g);b.setRootNodeName(c);b.fetchChildren(e)};this.selectSystemFolder=function(e){var d=$("system_folders_ul");if(!d){return true}d.select("a").each(function(f){f.removeClassName("fld-system-selected")});try{var b=$("sysFolder_"+e);b.addClassName("fld-system-selected")}catch(c){}return true};this.goToSystemFolder=function(b,c){CD.CategoryTree.goToNodeId("tree",CD.Environment.space.id,b,c)};this.actions.addShare=function(e,g,d,f,b){var h={catid:e,share_spid:g,share_parentid:d,perms:f,rand:Math.random(),doaction:"addshare",format:"json"};var c=CD.Environment.space.relative_url+this.namespace+"/"+e+"/";new CD.Ajax.Request(c,{method:"post",parameters:h,onSuccess:function(k){if(typeof b=="function"){b(k)}}})};this.actions.updateShare=function(e,h,d,g,f,b){var k={catid:e,share_spid:h,share_parentid:d,type:g,perms:f,doaction:"update_share_permissions",format:"json",rand:Math.random()};var c=CD.Environment.space.relative_url+this.namespace+"/"+e+"/";new CD.Ajax.Request(c,{method:"post",parameters:k,onSuccess:function(m){if("function"==typeof b){b(m)}return}});return};this.actions.removeShare=function(e,f,d,b){var g={share_spid:f,share_parentid:d,rand:Math.random(),doaction:"removeshare",format:"json"};var c=CD.Environment.space.relative_url+this.namespace+"/"+e+"/";new CD.Ajax.Request(c,{method:"post",parameters:g,onSuccess:function(h){if(typeof b=="function"){b(h)}}})};this.actions.uploadmultixml=function(c,k,f,b){var h=document.bulkupload;var e=CD.Environment.space.relative_url+this.namespace+"/"+f+"/";var g={sid:c,dbid:h.dbid.value,catid:f,tag:h.tag.value,item_status:h.item_status.value,cd_loc:e,max_upload:h.max_upload.value,rand:Math.random(),doaction:"uploadmultixml",format:"json"};new CD.Ajax.Request(e,{method:"post",parameters:g,onSuccess:function(d){if(typeof b=="function"){b(d)}}});return true};this.actions.uploadsinglexml=function(c,m,f,b){var k=document.bulkupload;var h=(k.notify_users.checked)?"true":"false";var e=CD.Environment.space.relative_url+this.namespace+"/"+f+"/";var g={sid:c,dbid:k.dbid.value,catid:f,tags:k.tags.value,item_status:k.item_status.value,cd_loc:e,pgref:pgref.is?"vr":"",max_upload:k.max_upload.value,file_description:k.file_description.value,notify_users:h,comment:document.bulkupload.message.value,cc_me:$("cc_me")&&$("cc_me").checked?"true":"false",subscribers:typeof(window.upicker)!="undefined"?window.upicker.getSelected(true):"",rand:Math.random(),doaction:"uploadsinglexml",format:"json"};new CD.Ajax.Request(e,{method:"post",parameters:g,onSuccess:function(d){if(typeof b=="function"){b(d)}}});return true};this.actions.uploadMultipleFiles=function(c,g,d){var e=document.bulkupload;var f=e.max_upload.value;var b=$("dragDropZone_ifr");if(b){b.hide()}CD.Folder.doAction("uploadmultixml",c,g,d,function(h){CD.UploadProgress.getUploadTime(c);e.action="/cgi-bin/upload.cgi?sid="+c+"&wk="+g+"&cat="+h+"&ref="+escape(cd_fullurl)+"&max_upload="+f;e.submit()});return true};this.actions.uploadSingleFile=function(b){var d=document.bulkupload;var c=d.catid.value;var e=d.max_upload.value;if(window.upicker){d.subscribers.value=window.upicker.getSelected(true);tinyMCE.triggerSave()}CD.Folder.doAction("uploadsinglexml",b,wk,c,function(f){d.action="/cgi-bin/upload.cgi?sid="+b+"&wk="+wk+"&cat="+f+"&ref=upload_single_file&max_upload="+e;CD.UploadProgress.getUploadTime(b);d.submit();try{parent.parent.overlay.shouldReload=true}catch(g){}})};this.actions.emptytrash=function(){cdwm.confirm("Are you absolutely sure you want to permanently delete all the items in your Trash?",function(b){if(b){new Ajax.Request(ajax_dt,{method:"get",parameters:ajax_params+"emptytrash",onComplete:function(d){try{CD.CategoryTree.goToNodeId("tree",CD.Environment.space.id,CD.Environment.model.id);cdwm.alert("Trash Emptied")}catch(c){window.location=CD.Environment.space.relative_url+"folder/-3/&successmsg=Trash Emptied"}}})}})};this.actions.hasChildName=function(g,m,c,f,n,k,d){c=c||null;n=(n||CD.Environment.model.activity_type==2?"item":"category");k=k||CD.Environment.space.id;d=d||CD.Environment.space.id;var b=CD.Environment.space.relative_url+this.namespace+"/"+(g||0)+"/";var e={doaction:"hasChildName",name:m,pk_id:c,id_type:n,item_type:f,from_spid:k,to_spid:d,format:"json",rand:Math.random()};var h=false;new CD.Ajax.Request(b,{method:"post",parameters:e,asynchronous:false,onSuccess:function(o){if(o){wiki_tools.ok_to_save=false;h=o}}},false);return h};this.createFolder=function(h,m,k){var e=h.form;var g=h.value;h.disabled=true;h.value="Creating...";var c=2;var d=false;var f=null;if(k=="tasks"){c=9;d=e.track_time?e.track_time.checked:false;f=e.milestoneid?e.milestoneid.value:false}var b=$("newFolderName").value;var n=0;var o=false;if($("isPrivate")){o=($("isPrivate").checked)?true:false}CD.Folder.doAction("create",b,n,o,function(p){if(p){if(k=="false"){var r=$("addmessage_catid");var s=r.length;r.options[s]=new Option(unescape(nn_escaped),p.id);r.selectedIndex=s;overlay.hide();return true}if((k=="forum")||(k=="blog")){window.location=CD.Environment.space.relative_url+k+"/"+p.id+"/"}else{if(k=="tasks"){var q="tasklist/"+p.id+"/&addnew"}else{var q=k+"&catid="+p.id}window.location=CD.Environment.space.relative_url+q}}else{h.value=g;h.disabled=false}},m,c,d,f)};this.createNewFolder=function(g,f,h){f=f||null;h=h||null;var c=g.form;var d=g.value;g.disabled=true;g.value="Creating...";var b=$("newFolderName").value;var k=$("parentId").value;var m=false;if($("isPrivate")){m=($("isPrivate").checked)?true:false}var e=CD.TinyMCE.getWindowId(g);CD.Folder.doAction("create",b,k,m,function(n){if(n){if(typeof f=="function"){f(n);cdwm.close(e)}else{parent.window.location=CD.Environment.space.relative_url+"folder/"+n.id+"/"}}else{if(typeof h=="function"){h(n)}g.value=d;g.disabled=false}},1,CD.Folder.activity_type,false,null,false)};this.focusNewFolderNameInput=function(c){try{c=c||"newFolderName";$(c).focus()}catch(b){}};this.setNewFolderParentId=function(b,e,d){try{$(b).value=e.getId();if(d){d.stop();return false}}catch(c){}};this.edit={};this.edit.focusFolderName=function(){$("newFolderName").focus()};this.edit.selectFolderParent=function(c,b){$("shareParentId").value=c.getId();if(b){b.stop();return false}};this.edit.editFolder=function(c){var k=c.value;c.disabled=true;c.value="Saving...";var e=c.form;var b=$("catId").value;var g=$("spaceId").value;var h=$("newFolderName").value;var f=$("isPrivate")&&$("isPrivate").checked?true:false;var d=new Array;CD.Folder.doAction("edit",b,h,d,f,function(m){if(m){parent.window.location=CD.Environment.space.relative_url+"folder/"+m.id+"/"}else{c.value=k;c.disabled=false}})};this.edit.deleteFolder=function(){var d=$("catId").value;var e=$("spaceId").value;var c=$("newFolderName").value;var b=CD.Environment.model.turl+"../"+CD.Environment.model.parentId+"/?successmsg=Folder "+c+" has been deleted";CD.Folder.doAction("remove",d,c,function(f){if(f){parent.window.location.href=b}})};this.edit.addShare=function(e){var c=e.value;e.disabled=true;e.value="Sharing...";var b=e.form;var d=b.elements.catid.value;var n=b.elements.share_workspace.value;var m=b.elements.share_parent_id.value;var f=parseInt(b.elements.share_permissions_writable.value);var h=parseInt(b.elements.share_permissions_isolated.value);var g=f|h;var k=$("shareListTable");CD.Folder.doAction("addShare",d,n,m,g,function(D){if(!D){e.disabled=false;e.value=c}else{parent.CD.Folder.reload=true;var A=$$("#shareListTable tbody tr").length;var s=$$("#shareListTable tbody")[0];var z=document.createElement("tr");z.className=A%2?"even":"odd";var o=document.createElement("td");o.className="location";var q=document.createElement("nobr");for(var r=0;r<D.path.length;r++){var C=D.path[r];var v=document.createElement("a");v.setAttribute("target","_blank");v.setAttribute("href",C.url);v.appendChild(document.createTextNode(C.name));q.appendChild(v);if(r<D.path.length-1){q.appendChild(document.createTextNode(" > "))}}o.appendChild(q);z.appendChild(o);var u={RO:"Read Only",RW:"Read/Write"},t={ISO:"Not Shared",NISO:"Shared"};var o=document.createElement("td");Element.addClassName(o,"permissions c2e c2e-sf-permissions");o.id=D.fk_categoryid+"-"+D.fk_share_spaceid+"-"+D.fk_share_parent_id+"-permissions";o.appendChild(document.createTextNode(u[D.permissions]));z.appendChild(o);var o=document.createElement("td");Element.addClassName(o,"permissions c2e c2e-sf-permissions");o.id=D.fk_categoryid+"-"+D.fk_share_spaceid+"-"+D.fk_share_parent_id+"-comments";o.appendChild(document.createTextNode(t[D.comments]));z.appendChild(o);var o=document.createElement("td");o.className="remove";var y=document.createElement("a");y.setAttribute("href","#");var B="CD.Folder.edit.removeShare(this, "+D.fk_categoryid+", "+D.fk_share_spaceid+", "+D.fk_share_parent_id+"); return false;";y.setAttribute("onclick",B);var x=document.createElement("ins");Element.addClassName(x,"icon icon_trash");y.appendChild(x);o.appendChild(y);z.appendChild(o);s.appendChild(z);window.setTimeout(function(){C2EManager.init()},0);var w=b.elements.share_workspace;var p=w.selectedIndex;w.options[p]=null;if(w.options.length>0){e.disabled=false;e.value=c;CD.Folder.getWorkspaceTree(w)}}})};this.edit.removeShare=function(c,b,d,f){var e=$(c).up("tr");CD.Folder.doAction("removeShare",b,d,f,function(k){parent.CD.Folder.reload=true;e.parentNode.removeChild(e);var o=document.forms.rpc;var h=o.elements.share_workspace;while(h.options.length>0){h.options[0]=null}for(var n=0;n<k.length;n++){var g=document.createElement("OPTION");g.text=k[n][0];g.value=k[n][1];h.options.add(g)}h.selectedIndex=0;if(k.length>0){CD.Folder.getWorkspaceTree(h);var m=$("overlay_button_ok");if(m){m.disabled=false;m.value="Share"}}})};this.move={};this.move.submit=function(o){var m=o.value;o.disabled=true;o.value="Moving...";var d=o.form;var k=d.elements.item_ids.value.split(",");var b=d.elements.folder_ids.value.split(",");var p=d.elements.from_spid.value;var c=d.elements.from_catid.value;var f=d.elements.to_spid.value;var r=d.elements.to_catid.value;var q=$("fldDisplayOption").value;if(q==CD.Category.DISPLAY_OPTION.BLOG||q==CD.Category.DISPLAY_OPTION.FORUM){if($("folderItemsList")){b=new Array();var e=new Array();for(var n=0;n<k.length;n++){var h=$("item_"+k[n]);if(h){var g=h.select(".item_type_discussion");if(g&&g.length>0){e.push(k[n])}}}k=e}else{k=new Array();k.push(CD.Environment.model.id);b=new Array()}}CD.Document.doAction("move",k,b,p,c,f,r,function(s){if(s){parent.window.location=CD.Environment.space.relative_url+"folder/"+CD.Environment.model.id+"/?successmsg=Successfully+Moved"}else{o.value=m;o.disabled=false}},q)};this.move.selectSpace=function(b,d){try{var c=b.form;c.to_spaceid.value=b.value;c.to_catid.value=0;CD.Folder.move.updateFolders($("fldDisplayOption"))}catch(g){console.log(g)}};this.move.selectFolder=function(c,b){$("to_catid").value=c.getId();if(b){b.stop()}return false};this.move.updateFolders=function(b){try{var f=b.form.elements.share_workspace.value;var d=b.value;if(d==CD.Category.DISPLAY_OPTION.FILE){$("moveTreeContainer").show();$("sbxContainer").hide();CD.Folder.getWorkspaceTree(b.form.elements.share_workspace,"moveTree")}else{$("moveTreeContainer").hide();$("sbxContainer").show();var c=CD.Environment.space.relative_url+"folder/"+CD.Environment.model.id+"/";var h={doaction:"getFoldersOfType",format:"json",to_spid:f,displayOption:d,rand:Math.random()};new CD.Ajax.Request(c,{method:"post",parameters:h,onSuccess:function(k){try{$("sbxContainer").innerHTML=k;CD.evalScripts($("sbxContainer"))}catch(m){console.log(m)}}},false)}}catch(g){console.log(g)}};this.move.setSelectedFolderId=function(b){b.form.elements.to_catid.value=b.value};this.toggleElement=function(d,b){var c=$(d);if(!c){return false}if(b){c.show()}else{c.hide()}};this.UI={enableDragDrop:function(c,p,q,m){try{var d=$(c).select("iframe")[0];var k="";var f="";try{if(p=="media"){f=q;q=""}else{if(CD.Environment.model.activity_type==CD.ITEM_TYPE_DB_RECORD||p=="db"){k=CD.Environment.model.fk_categoryid;f="Attachments"}else{if(CD.Environment.model.item_type==CD.ITEM_TYPE_FOLDER){k=CD.Environment.model.id;f=CD.Environment.model.name}else{k=CD.Environment.model.catid;f=paramCatName}}}}catch(n){}var g=dom.utils.getElementHeight(c)-6;var o=dom.utils.getElementWidth(c)-6;var b="/spaces/javaupload?upload_type="+p+"&spid="+spid+"&spacename="+encodeURIComponent(spacename_long)+"&cat="+k+"&dbid="+pgref.dbid+"&catname="+encodeURIComponent(f)+"&tag="+encodeURIComponent(q)+"&max_upload_kb="+m+"&h="+g+"&w="+o+"&inline=1";d.src=b;d.style.height=g+"px";d.style.width=o+"px";d.contentWindow.reloadWindow=window;d.show()}catch(n){}},initialState:true,updateView:function(){try{var d=CD.Environment.model;if(d.id<0){d.catid=0}if(-6==d.id){d.catid=-6}var g=$("treeContainer_tree");var e="<ins class='icon icon_email_in' />";var c=new Element("a",{href:"#",title:"Folder email address",id:"btnEmailin"}).update(e);c.observe("click",function(){CD.Folder.showDialog("emailAddresses");return false});var b=g?dom.utils.getElementHeight(g):150;if(d.canCreate&&d.id!=CD.Folder.TRASH&&!d.inTrash){if(d.isShared||d.isaShare){$("folderPageMeta").removeClassName("h70");$("folderPageMeta").removeClassName("h100");$("folderPageMeta").addClassName("h130")}else{$("folderPageMeta").removeClassName("h70");$("folderPageMeta").removeClassName("h130");$("folderPageMeta").addClassName("h100")}$("folderPageMeta").setStyle({marginBottom:"0px"});$("folderViewButtons").removeClassName("bl-dynamic");if(g){$("newFolder").removeClassName("bl-dynamic")}if(this.initialState&&g){g.style.height=(b-20)+"px"}}else{if(d.isShared||d.isaShare){$("folderPageMeta").removeClassName("h130");$("folderPageMeta").removeClassName("h70");$("folderPageMeta").addClassName("h100")}else{$("folderPageMeta").removeClassName("h130");$("folderPageMeta").removeClassName("h100");$("folderPageMeta").addClassName("h70")}if(d.inTrash&&(d.id==CD.Folder.TRASH||d.id==CD.Folder.TRASH_INTERNAL)){$("folderPageMeta").setStyle({marginBottom:"30px"})}else{$("folderPageMeta").setStyle({marginBottom:"0px"})}$("folderViewButtons").addClassName("bl-dynamic");if(g){$("newFolder").addClassName("bl-dynamic")}if(this.initialState&&g){g.style.height=(b+20)+"px"}}if(d.canDelete){if(d.inTrash||d.id==CD.Folder.TRASH){$($("deleteControl").parentNode).addClassName("bl-dynamic");$($("permDeleteControl").parentNode).removeClassName("bl-dynamic")}else{$($("deleteControl").parentNode).removeClassName("bl-dynamic");$($("permDeleteControl").parentNode).addClassName("bl-dynamic")}if(d.id==CD.Folder.TRASH||d.id==CD.Folder.TRASH_INTERNAL){$("emptyTrashControl").removeClassName("bl-dynamic")}else{$("emptyTrashControl").addClassName("bl-dynamic")}}else{$($("deleteControl").parentNode).addClassName("bl-dynamic");$("emptyTrashControl").addClassName("bl-dynamic");$($("permDeleteControl").parentNode).addClassName("bl-dynamic")}if(d.canModify&&d.canDelete){if($("moveControlGroup")){$("moveControlGroup").parentNode.style.display=""}if($("moveControl_mowo")){$("moveControl_mowo").parentNode.style.display=""}if($("moveControl_"+CD.Folder.ANNOUNCEMENT)){$("moveControl_"+CD.Folder.ANNOUNCEMENT).parentNode.style.display=(d.id==CD.Folder.ANNOUNCEMENT?"none":"")}if($("moveControl_"+CD.Folder.ARCHIVE)){$("moveControl_"+CD.Folder.ARCHIVE).parentNode.style.display=(d.id==CD.Folder.ARCHIVE?"none":"")}if($("moveControl_"+CD.Folder.ATTACHMENT)){$("moveControl_"+CD.Folder.ATTACHMENT).parentNode.style.display=(d.id==CD.Folder.ATTACHMENT?"none":"")}if($("moveControl_"+CD.Folder.ATTACHMENT_INTERNAL)){$("moveControl_"+CD.Folder.ATTACHMENT_INTERNAL).parentNode.style.display=(d.id==CD.Folder.ATTACHMENT_INTERNAL?"none":"")}}else{if($("moveControlGroup")){$("moveControlGroup").parentNode.style.display="none"}if($("moveControl_mowo")){$("moveControl_mowo").parentNode.style.display="none"}if($("moveControl_"+CD.Folder.ANNOUNCEMENT)){$("moveControl_"+CD.Folder.ANNOUNCEMENT).parentNode.style.display="none"}if($("moveControl_"+CD.Folder.ARCHIVE)){$("moveControl_"+CD.Folder.ARCHIVE).parentNode.style.display="none"}if($("moveControl_"+CD.Folder.ATTACHMENT)){$("moveControl_"+CD.Folder.ATTACHMENT).parentNode.style.display="none"}if($("moveControl_"+CD.Folder.ATTACHMENT_INTERNAL)){$("moveControl_"+CD.Folder.ATTACHMENT_INTERNAL).parentNode.style.display="none"}}if(d.id==CD.Folder.GENERAL||d.id==CD.Folder.RECENT||d.id==CD.Folder.ANNOUNCEMENT){if($("btnEmailin")==null){$("btnFavorites").insert({before:c})}}else{if(d.isSystem){if($("btnEmailin")!=null){$("btnEmailin").remove()}}else{if(d.canCreate){if($("btnEmailin")==null){$("btnFavorites").insert({before:c})}}else{if($("btnEmailin")!=null){$("btnEmailin").remove()}}}}CD.Folder.doAction("initView");this.initialState=false}catch(f){}}};this.parseSharedPermissions=function(c){var e=c.id;var f=/^(\d+)-(\d+)-(\d+)-(permissions|comments)$/;if(!f.test(e)){throw new Error('Element id "'+c.id+'" does not correspond to expected pattern.')}e=e.match(f);var d,g,b={};b.catid=1*e[1];b.share_spid=1*e[2];b.share_parentid=1*e[3];b.permissions=0;b.elmntPermissions=null;b.elmntComments=null;if("comments"==e[4]){d=c;g=$(b.catid+"-"+b.share_spid+"-"+b.share_parentid+"-permissions")}else{g=c;d=$(b.catid+"-"+b.share_spid+"-"+b.share_parentid+"-comments")}b.elmntPermissions=g;b.elmntComments=d;if("Read/Write"==g.innerHTML){b.permissions|=1}if("Not Shared"==d.innerHTML){b.permissions|=2}return b}}CD_Category.makeSubclass(CD_Folder);window.CD.Folder=new CD_Folder();CD.AdvancedFolderSelect=(function(){return{currentSelectId:null,setCurrentId:function(a){CD.AdvancedFolderSelect.currentSelectId=a},currentTreeId:null,setCurrentTreeId:function(a){CD.AdvancedFolderSelect.currentTreeId=a},select:function(g,d,k){if(g&&d&&k){this.currentSelectId=g;var b=d.getName();var c=d.getId();var m=d.getIconClass();if(c==-2){c=0;b="Items not in Folders"}var h=$("sdd_folder_select_"+g+"_control");var a=$("sdd_folder_select_"+g+"_elem");h.select("span")[0].innerHTML='<ins class="icon '+m+'"></ins>'+b;a.value=c;try{a.onchange()}catch(f){}FolderSelectDropdown.hide("sdd_folder_select_"+g)}if(k){try{Event.stop(k)}catch(f){}}return false},onChange:function(b,a){CD.Folder.doAction("deployMembersPicker",b,a,true)},create:function(){CD.Folder.showDialog("create","tree")},onCreateSuccess:function(c){var a=CD.TreeFactory.get(CD.AdvancedFolderSelect.currentTreeId);a.importData([c],true);$(CD.AdvancedFolderSelect.currentSelectId+"_elem").value=c.id;try{$(CD.AdvancedFolderSelect.currentSelectId+"_elem").onchange()}catch(b){}$(CD.AdvancedFolderSelect.currentSelectId+"_control").select("span")[0].innerHTML='<ins class="icon '+c.iconClass+'"></ins>'+c.name;return true},onCreateFailure:function(c,b,a){return false}}})();function CD_MicroBlog(){CD_Object.call(this);this.namespace="microblog";this.displayName="Micro-Blog";this.cleared=false;this.actions.addEntry=function(c){var a="/home/"+this.namespace+"/";var b=$("syndicateToTwitter")?$("syndicateToTwitter").checked:false;var d=$("syndicateToFacebook")?$("syndicateToFacebook").checked:false;var e={doaction:"addEntry",format:"json",microblog_message:c,microblog_syndicated_to_twitter:b,microblog_syndicated_to_facebook:d,rand:Math.random()};new CD.Ajax.Request(a,{method:"post",parameters:e,onSuccess:function(f){var g=$("microBlogMessage");if(g){g.value=default_status_message}CD.MicroBlog.cleared=false;$("microBlogMessage").up().removeClassName("fieldWrapperInFocus");$("currentStatus").update(f.statusHTML);pw_dashboard.switch_tab(pw_dashboard_state,0);$("microBlogMessage").blur()}},false)};this.actions.deleteEntry=function(a){cdwm.confirm("Are you sure you want to permanently delete this Status Update?",function(d){if(d!="true"){return}var b="/home/microblog/"+a+"/";var c={doaction:"deleteEntry",format:"json",rand:Math.random()};new CD.Ajax.Request(b,{method:"post",parameters:c,onSuccess:function(f){if(f=="OK"){var g=$("microBlogging_entry_"+a);var e=$("microBlogging_comments_"+a);if(g){g.fade()}if(e){e.fade()}}}},false)})};this.actions.clearStatus=function(){var a="/home/"+this.namespace+"/";var b=false;var c=false;var d={doaction:"clearStatus",format:"json",microblog_message:"",microblog_syndicated_to_twitter:"false",microblog_syndicated_to_facebook:"false",rand:Math.random()};new CD.Ajax.Request(a,{method:"post",parameters:d,onSuccess:function(k){var f=$("microBlogging_currentStatus");if(f){f.innerHTML=default_status_prompt}var h=$("microBlogging_clear");if(h){h.style.display="none"}var g=$("microBlogMessage");if(g){g.value=default_status_message}CD.MicroBlog.cleared=false;$("currentStatus").update("");var e=$("microBlogMessage");if(e!=null){e.up().removeClassName("fieldWrapperInFocus")}}},false)};this.actions.stopFollowing=function(b){var a="/home/"+this.namespace+"/";var c={doaction:"stopFollowing",format:"json",fk_userid:b,rand:Math.random()};new CD.Ajax.Request(a,{method:"post",parameters:c,onSuccess:function(d){$("microblog_follow_status_"+c.fk_userid).innerHTML="Follow";$("microblog_follow_status_"+c.fk_userid).onclick=function(){CD.MicroBlog.doAction("startFollowing",c.fk_userid)}}},false)};this.actions.startFollowing=function(b){var a="/home/"+this.namespace+"/";var c={doaction:"startFollowing",format:"json",fk_userid:b,rand:Math.random()};new CD.Ajax.Request(a,{method:"post",parameters:c,onSuccess:function(d){$("microblog_follow_status_"+c.fk_userid).innerHTML="UnFollow";$("microblog_follow_status_"+c.fk_userid).onclick=function(){CD.MicroBlog.doAction("stopFollowing",c.fk_userid)}}},false)};this.actions.fetchStatusUpdates=function(d,e,c,f,a){var b="/home/"+this.namespace+"/";var g={doaction:"fetchStatusUpdates",format:"json",fk_userid:d,update_tab_selection:e,rand:Math.random()};if(typeof c!="undefined"){pw_dashboard_follow=c;g.whoToFollow=c;if($("status_updates_show_following")){$("status_updates_show_following").checked=c=="follow"?true:false}if($("status_updates_show_everyone")){$("status_updates_show_everyone").checked=c=="everyone"?true:false}}new CD.Ajax.Request(b,{method:"post",parameters:g,onSuccess:function(h){if(pw_dashboard_state!="status_updates"){return false}$("dashboard_ra_content").innerHTML=h;CD.evalScripts($("dashboard_ra_content"));if(f!=undefined){CD.MicroBlog.doAction("toggleComments",f)}if(undefined!==a&&"function"==typeof a){a()}}},false)};this.actions.fetchTags=function(b,c){var a="/home/"+this.namespace+"/";var d={doaction:"fetchTags",format:"json",fk_userid:b,update_tab_selection:c,rand:Math.random()};new CD.Ajax.Request(a,{method:"post",parameters:d,onSuccess:function(e){$("dashboard_ra_content").innerHTML=e}},false)};this.actions.fetchComments=function(d,c,b){var a="/home/"+this.namespace+"/"+d+"/";var e={doaction:"fetchComments",format:"json",showAll:c,rand:Math.random()};new CD.Ajax.Request(a,{method:"post",parameters:e,onSuccess:function(f){var g=b.down("#microBlogging_comments_"+d);var h=g.down("#microBlogging_comments_div_"+d);if(g){h.innerHTML=f;g.style.display=""}}},false)};this.actions.fetchLongLikes=function(c,b){var a="/home/"+this.namespace+"/"+c+"/";var d={doaction:"fetchLongLikes",format:"json"};new CD.Ajax.Request(a,{method:"post",parameters:d,onSuccess:function(e){var g=$("microBlogging_comments_div_"+c);var f=g.select(".likes").first();f.innerHTML=e}},false)};this.actions.toggleLike=function(d,f,b){var a="/home/"+this.namespace+"/"+d+"/";var c=false;if(b.down("#microBlogging_comments_"+d).select(".microblog_comment_form")[0]){var e=$("microBlogging_comments_"+d).select(".microblog_comment_form")[0].elements.showAll;if(e){c=e.value=="true"?true:false}}var g={doaction:"toggleLike",format:"json",showAll:c,standalone:f};new CD.Ajax.Request(a,{method:"post",parameters:g,onSuccess:function(h){var k=b.down("#microBlogging_comments_"+d);var m=b.down("#microBlogging_comments_div_"+d);if(k&&k.select(".microblog_comment_form")[0]){m.innerHTML=h;k.style.display=""}if(!f){new CD.Ajax.Request(a,{method:"post",parameters:{doaction:"getLike",format:"json"},onSuccess:function(n){$("microBlogging_entry_"+d).select(".microBlogging_like_link a")[0].innerHTML=n}},false)}}},false)};this.actions.addComment=function(e,g,k){var b="";var f=false;var c=g.form.elements.microblog_comment;if(c){b=c.value}if(b==""){cdwm.alert("You must enter a comment to Save it.");return false}var h=g.form.elements.showAll;if(h){f=h.value=="true"?true:false}var a="/home/"+this.namespace+"/"+e+"/";var d={doaction:"addComment",format:"json",comment:b,showAll:f,rand:Math.random()};new CD.Ajax.Request(a,{method:"post",parameters:d,onSuccess:function(m){var n=g.up("#microBlogging_comments_"+e);var o=n.down("#microBlogging_comments_div_"+e);if(n){o.innerHTML=m;n.style.display=""}}},false)};this.actions.toggleComments=function(d,a,b){if(!b){b=Event.element(a).up(".ra-entry")}var c=b.down("#microBlogging_comments_"+d);if(c){if(c.style.display==""){c.style.display="none"}else{CD.MicroBlog.doAction("fetchComments",d,false,b)}}};this.actions.deleteComment=function(d,c,a,b){cdwm.confirm("Are you sure you want to permanently delete this Status Update Comment?",function(g){if(g!="true"){return}var e="/home/microblog/"+d+"/";var f={doaction:"deleteComment",format:"json",commentId:c,rand:Math.random()};new CD.Ajax.Request(e,{method:"post",parameters:f,onSuccess:function(h){if(h=="OK"){CD.MicroBlog.doAction("fetchComments",d,false,b)}}},false)})};this.actions.addShare=function(){if(CD.MicroBlog.cleared){CD.MicroBlog.doAction("addEntry",$("microBlogMessage").value)}};this.actions.authorizeFacebook=function(){try{if(typeof FB=="undefined"||typeof FB.login=="undefined"){throw ("Please try again in a few seconds. Waiting for connection to Facebook.")}var b=function(c){if(c.authResponse){var d=_.extend(c.authResponse,{doaction:"setFacebookSessionKey",format:"json",rand:Math.random()});CD.Ajax.Request("/home/"+CD.MicroBlog.namespace+"/",{method:"post",parameters:d,onSuccess:function(){window.location.reload()},onFailure:function(){}})}};FB.login(b,{scope:"offline_access,publish_stream"})}catch(a){cdwm.alert(a)}};this.actions.deauthorizeFacebook=function(){var a="/home/"+this.namespace+"/";var b={doaction:"removeFacebookSessionKey",format:"json",rand:Math.random()};new CD.Ajax.Request(a,{method:"post",parameters:b,onSuccess:function(c){window.location.reload()}},false)};this.actions.removeSyndication=function(b){var a="/home/myaccount/";var c={doaction:"removeSyndication",format:"json",dest:b,rand:Math.random()};new CD.Ajax.Request("/home/myaccount/",{method:"post",parameters:c,onSuccess:function(d){window.location="/home/profile?section=credentials"}})};this.toggleTrashIcon=function(e,d,a){var b=$(e).select(".status_update_delete");if(b&&b.length>0){var c=b[0];if(d){c.style.display=""}else{c.style.display="none"}}};this.toggleCommentTrashIcon=function(c,e,a){var b=c.select(".microblog_comment_delete");if(b&&b.length>0){var d=b[0];if(e){d.style.display=""}else{d.style.display="none"}}};this.actions.toggleFollowingStateOnUserWidget=function(a,b){b=$(b);if(b.hasClassName("icon_following_start")){CD.MicroBlog.doAction("startFollowing",a);b.removeClassName("icon_following_start");b.addClassName("icon_following_stop")}else{foo=CD.MicroBlog.doAction("stopFollowing",a);b.removeClassName("icon_following_stop");b.addClassName("icon_following_start")}return false};this.clear=function(a){if(a.value=="Write a Comment..."){a.value=""}return true}}extend(CD_MicroBlog,CD_Object);window.CD.MicroBlog=new CD_MicroBlog;CD.MicroBlog_alreadySetup=false;Event.observe(window,"load",function(){if(CD.MicroBlog_alreadySetup){return}var a=$("microBlogMessage");if(a){CD.MicroBlog_alreadySetup=true;Event.observe(a,"click",function(){if(!CD.MicroBlog.cleared){a.value="is ";CD.MicroBlog.cleared=true;a.up().addClassName("fieldWrapperInFocus");a.focus();if(a.createTextRange){var b=a.createTextRange();b.move("character",a.value.length);b.select()}else{if(a.selectionStart){a.setSelectionRange(a.value.length,a.value.length)}}}});Event.observe(a,"blur",function(){if(a.value=="is "){a.value=default_status_message;CD.MicroBlog.cleared=false;a.up().removeClassName("fieldWrapperInFocus")}});Event.observe(a,"keyup",function(b){CD.MicroBlog.handle("checkEnter",b,function(c){CD.MicroBlog.doAction("addEntry",c);return false},a.value)})}});function spreadsheet_force_auto_save(){var b=new Date();var a=$("cd_spreadsheet_iframe").src;$("cd_spreadsheet_iframe").src=a+"#"+b.getTime();cd_sleep(3500)}function CD_Spreadsheet(){CD_Item.call(this);this.namespace="spreadsheet";this.displayName="Spreadsheet";this.item_type=2;var a=this;this.views.create=function(c,d){d=d||false;c=CD.Object.getValidCatid(c,CD.Folder.GENERAL);var b=CD.Environment.space.relative_url+this.namespace+"/create/?"+this.namespace+"_fk_categoryid="+c+"&wk="+wk+"&dbid="+pgref.dbid+"&rand="+Math.random();if(d){b+="&pgref="+d}else{b+=pgref.uri}var e={title:"Create a New Online Spreadsheet",file:b,width:570,height:tagging_on?350:240,type:"dynamic",scrollbars:false,inline:1};overlay.show(e,true)};this.views.importFile=function(c,d){d=d||false;c=CD.Object.getValidCatid(c,CD.Folder.GENERAL);var b=CD.Environment.space.relative_url+this.namespace+"/import/?"+this.namespace+"_fk_categoryid="+c+"&wk="+wk+"&dbid="+pgref.dbid+"&rand="+Math.random();if(d){b+="&pgref="+d}else{b+=pgref.uri}var e={title:"Import from Excel or CSV File",file:b,width:570,height:tagging_on?350:240,type:"dynamic",inline:1};overlay.show(e,true)};this.views.rename=function(d){spreadsheet_force_auto_save();var b=cd_spaceurl+this.namespace+"/"+d+"/rename/"+pgref.uri;var c={title:"Rename "+this.displayName,file:b,width:450,type:"dynamic",inline:1,afterLoad:function(e){$("new_title").focus()}};overlay.show(c,false)};this.actions.docproperties=function(b){spreadsheet_force_auto_save();window.location=b};this.actions.create=function(k,d,c,h){var b=cd_spaceurl+this.namespace+"/create/";var g={doaction:"create",spreadsheet_title:k,spreadsheet_fk_categoryid:d,spreadsheet_item_status:h,spreadsheet_tags:c,spreadsheet_dbid:pgref.dbid,rand:Math.random(),format:"json"};try{overlay.shouldReload=true;parent.parent.overlay.shouldReload=true}catch(f){}new CD.Ajax.Request(b,{method:"post",parameters:g,onSuccess:function(m){if(m){overlay.hide();var e=cd_spaceurl+CD.Spreadsheet.namespace+"/"+m.id+"/";document.location.href=e}}})};this.actions.importFile=function(){var c=$(cdwm.win.iframeElement.id).contentWindow.document;var b=c.getElementById("spreadsheet_fk_categoryid");if(!b||(b&&b.value=="")){alert("You must select a Folder Name to Import the Spreadsheet First.\nThen click the Import button again.");$("new_spreadsheet_import").checked=false;$("new_spreadsheet_scratch").checked=true}else{}};this.actions.verifyFileType=function(){var b=$("spreadsheet_filename");if(!/(\.csv|\.xls|\.xlsx|\.sxc)$/i.test(b.value)){alert("The file "+b.value+" is not a CSV, XLS, or XLSX file.");b.value=""}};this.actions.startFileUpload=function(){var h=document.spreadsheet_import;if($("webdoc_new_status_0")){var g=$("webdoc_new_status_0").value}else{var g=""}var e=h.elements.spreadsheet_fk_categoryid.value;var c=$("tags").value;var b=CD.Environment.space.relative_url+this.namespace+"/";var f={doaction:"startImportXml",rand:Math.random(),format:"json",spreadsheet_fk_categoryid:e,dbid:typeof dbid!="undefined"?dbid:"",item_status:g,tags:c};new CD.Ajax.Request(b,{method:"post",parameters:f,onSuccess:function(d){h.action="/cgi-bin/upload.cgi?sid="+session_id+"&wk="+wk+"&cat="+d+"&ref=import_spreadsheet&max_upload="+max_upload;CD.UploadProgress.getUploadTime(session_id);h.submit();CD.cdwm.close(h)}},false)};this.actions.importComplete=function(b){overlay.hide();overlay.showFullScreen("",cd_spaceurl+this.namespace+"/"+b+"/",pgref.force,false)};this.actions.importFailed=function(b,c){overlay.hide();overlay.showFullScreen("",cd_spaceurl+CD.Folder.namespace+"/"+b+"/&errormsg="+c,pgref.force,false)};this.actions.saveRedirect=function(b){spreadsheet_force_auto_save();window.location.replace(b)};this.actions.saveOnly=function(c,d,b){spreadsheet_force_auto_save()};this.actions.saveAndClose=function(e,f,c){spreadsheet_force_auto_save();var b=cd_spaceurl+CD.Spreadsheet.namespace+"/"+f+"/";var d={doaction:"update",format:"json",pgref:pgref.is?"vr":"",lbref:pgref.is?"lb":"",rand:Math.random(),spreadsheet_item_status:document.forms.edit.elements.spreadsheet_item_status.value,spreadsheet_tags:tagging_on?document.forms.edit.elements.spreadsheet_tags.value:""};new CD.Ajax.Request(b,{method:"post",parameters:d,onSuccess:function(g){if(pgref.is){top.document.location.reload()}else{if(e=="full_screen"){window.close();window.opener.location=cd_spaceurl+CD.Folder.namespace+"/"+c+"/"}else{window.location=cd_spaceurl+CD.Folder.namespace+"/"+c+"/"}}}})};this.actions.saveAndNotify_Spreadsheet=function(c,e){spreadsheet_force_auto_save();var b=cd_spaceurl+CD.Spreadsheet.namespace+"/"+e+"/";var d={doaction:"update",format:"json",pgref:pgref.is?"vr":"",lbref:pgref.is?"lb":"",rand:Math.random(),spreadsheet_item_status:c.item_status.value,spreadsheet_tags:tagging_on?document.getElementById("tags").value:"",cc_me:document.getElementById("cc_me_checkbox")&&document.getElementById("cc_me_checkbox").checked?"true":"false",check_in_comments:c.check_in_comments.value,notify_userids:upicker.getAltered(true),notify_users:true};new CD.Ajax.Request(b,{method:"post",parameters:d,onSuccess:function(f){if(pgref.is){top.document.location.reload()}else{window.location=f}}})};this.views.copy=function(d){var b=CD.Environment.space.relative_url+this.namespace+"/"+d+"/copy/"+pgref.uri;var c={title:"Copy "+this.displayName,file:b,width:500,type:"dynamic",inline:1,afterLoad:function(e){$("new_title").focus()}};overlay.show(c,false)};this.actions.copy=function(f,d,b){var c=cd_spaceurl+this.namespace+"/"+f+"/";var e={doaction:"copy",rand:Math.random(),new_catid:b,new_title:d,format:"json"};new CD.Ajax.Request(c,{method:"post",parameters:e,onSuccess:function(g){if(g&&g.id){}else{cdwm.alert("Copy failed.")}overlay.hide()}})};return this}extend(CD_Spreadsheet,CD_Item);window.CD.Spreadsheet=new CD_Spreadsheet;CD.Spreadsheet.validateRename=function(a){if(a.elements.new_title.value==""){cdwm.alert("Spreadsheet name is required.");return false}return true};function CD_User(){CD_Object.call(this);this.namespace="item";this.displayName="User";this.item_type=23;var a=this;this.views.permalink=function(b){var d='<div style="padding: 5px 5px 10px 5px; font-size: 14px; ">Permalink for this User<div class="sml_break3"></div><input type="text" style="background-color: #fff; width: 450px; font-size: 14px;" readonly value="'+b+'" /></div><div style="padding: 7px 5px 5px 5px; font-size: 11px;">A Permalink is a Permanent Link that will not break even if the user is moved to another Workspace. You should use this link when pointing others to this user.</div>';var c=new Element("div");c.innerHTML=d;var e={url:null,file:null,element:c,inline:1,type:"dynamic",title:"Permanent link to this "+this.displayName};cdwm.open(true,e)};this.actions.setPref=function(b,d,c){if(typeof(c)=="undefined"){var c=true}if(CD.Environment.user){CD.Environment.user.preferences[b]=d;if(c){CD.User.doAction("savePrefs",[b])}}};this.actions.getPref=function(c,b){if(CD.Environment.user){if(typeof(CD.Environment.user.preferences[c])!="undefined"){return CD.Environment.user.preferences[c]}else{return b}}else{return b}};this.actions.savePrefs=function(c){if(!CD.Environment.user){return}var d={doaction:"saveprefs",format:"json"};if(c&&c.length){c.each(function(e){d["pref_"+e]=CD.Environment.user.preferences[e]})}else{for(var b in CD.Environment.user.preferences){d["pref_"+b]=CD.Environment.user.preferences[b]}}new CD.Ajax.Request("/home/myaccount/",{parameters:d,onComplete:function(e){}})};this.actions.startTrial=function(b){var c={doaction:"starttrial",vendor_id:b,format:"json"};new CD.Ajax.Request("/home/myaccount/",{parameters:c,onComplete:function(e){var d=$("start_trial_div");if(d){d.innerHTML="<p>Thank you for starting your CD for Office trial.</p><p>Close MS Office and Restart it.</p>"}}})};this.actions.cancelTrial=function(b){var c={doaction:"stoptrial",vendor_id:b,format:"json"};new CD.Ajax.Request("/home/myaccount/",{parameters:c,onComplete:function(d){}})};this.actions.fetchCollaborators=function(b){};this.mkTreeHeightListener=function(c){var b=function(d,e){if(CD.Environment.user&&CD.Environment.space){CD.User.doAction("setPref",c+"_"+CD.Environment.space.id,e)}};return b};this.views.changePassword=function(){var b={title:"Change Username",file:ajax_d+"?do=change-username",width:500,height:500,inline:true,type:"dynamic",afterLoad:function(){var d=document["username-change"],e=null;d.username.focus();d.username.addClassName("username-validation-minlength username-validation-maxlength username-validation-available");Validation.add("username-validation-available","That username is already taken. Please choose a different one.",function(g,k){var f="/spaces/ns_doaction.php?do=check_valid_username&username="+window.encodeURIComponent(d.username.value)+"&rand="+1000*Math.random();var h=false;new Ajax.Request(f,{asynchronous:false,onSuccess:function(m){h=("not_exists"==m.responseText);return true}});return h});Validation.add("username-validation-minlength","Username must be 5 or more characters",{minLength:5});Validation.add("username-validation-maxlength","Username can not be more that 25 characters ",{maxLength:25});var c=new Validation(d,{onSubmit:false});Event.observe(d,"submit",function(f){if(c.validate()){d.submit.value="Submitting";d.submit.disabled=true}else{Event.stop(f)}return false});return}};overlay.show(b,false);return};return this}CD_Object.makeSubclass(CD_User);window.CD.User=new CD_User;CD.UserLookup=(function(){var e=350;var a=null;var d=null;var g=null;var o=null;var n=null;var f=null;var c=null;var b=null;var h=false;var m=false;var k={inputElement:null,init:function(){h=arguments[0]||false;m=arguments[1]||false;if(!g){var q={doaction:"fetchCollaborators",format:"json",fetchInternal:h};var p="/home/myaccount/";new CD.Ajax.Request(p,{method:"get",parameters:q,onSuccess:function(r){g=r}},false)}},bind:function(p){if(CD.UserLookup.inputElement!==null&&CD.UserLookup.inputElement!==p){this.release()}if(p!==CD.UserLookup.inputElement){CD.UserLookup.inputElement=p;b=setInterval(function(){try{CD.UserLookup.search(p)}catch(q){}},500);Event.observe(CD.UserLookup.inputElement,"keyup",this.handleKeyUp);Event.observe(CD.UserLookup.inputElement,"blur",this.delayedRelease);$(p).setAttribute("autocomplete","off")}return true},delayedRelease:function(){setTimeout(CD.UserLookup.release,200)},release:function(){if(b){clearInterval(b)}b=null;Event.stopObserving(CD.UserLookup.inputElement,"blur",k.delayedRelease);var q=k.validateEmail(CD.UserLookup.inputElement);var p=k.isLastInput();if(q&&typeof m=="function"&&p){m()}CD.UserLookup.delayedCancel();n=CD.UserLookup.inputElement.value;CD.UserLookup.inputElement=null;return true},delayedCancel:function(){setTimeout(CD.UserLookup.cancel,200)},cancel:function(){if(a){a.parentNode.removeChild(a);a=null}},handleKeyUp:function(q){if(!q.element()!==CD.UserLookup.inputElement){CD.UserLookup.bind(q.element())}if(q.keyCode==38||q.keyCode==40||q.keyCode==13){if(q.keyCode==13){if(f.length>1){var p=f[c];k.setValue(p.email);n=p.email;a.style.visibility="hidden";if(typeof m=="function"){m()}}else{if(f.length==1){k.setValue(f[0].email);n=f[0].email;a.style.visibility="hidden";if(typeof m=="function"){m()}}}}else{if(f.length>0){if(q.keyCode==38){if(c>0){c--}else{c=0}}else{if(q.keyCode==40){if(c>=0){if(c<f.length-1){c++}}else{c=0}}}k.scrollToMatch()}}q.stop();return false}},search:function(p){if(CD.UserLookup.inputElement==null){return true}o=CD.UserLookup.inputElement.value;if(o==""){if(o!=n){k.cancel();n=o}return}if(o!=n){c=0;f=new Array;var r=new RegExp(k.escapeTerm(o),"gi");for(email in g){var q=g[email];if(email.match(r)){f.push(q);continue}if(typeof q.fullname!="undefined"&&q.fullname.match(r)){f.push(q);continue}}k.render();n=o}},render:function(){if(!a){a=k.createContainer()}else{d.innerHTML=""}k.alignContainer(CD.UserLookup.inputElement);if(f.length==0){a.style.visibility="hidden";return true}for(var p=0;p<f.length;p++){var q=k.createEntry(p);d.appendChild(q)}k.scrollToMatch();a.style.visibility="visible"},createContainer:function(){var q=new Element("div",{"class":"user-lookup-wrapper"});q.style.visibility="hidden";var p=new Element("div",{"class":"dd-shadow"});d=new Element("div",{"class":"dd-contents"});q.appendChild(p);q.appendChild(d);document.body.appendChild(q);return q},alignContainer:function(p){var r=dom.utils.getDimensions(p);var q=dom.utils.getZIndex(p,true);a.style.left=r.left+"px";a.style.top=(r.top+r.height-3)+"px";a.style.width=(r.width<e?e:r.width)+"px";a.style.zIndex=q+1},createEntry:function(p){var u=f[p];var t=new Element("div",{"class":"user-lookup-entry"});t.setAttribute("email",u.email);Event.observe(t,"click",function(){try{CD.UserLookup.entryClickHandler(this.getAttribute("email"))}catch(v){}});var s=new Element("span",{"class":"user-lookup-entry-pic"});s.innerHTML=u.pic;var r=new Element("div",{"class":"user-lookup-entry-email"});r.appendChild(k.highlightMatch(u.email));var q=new Element("div",{"class":"user-lookup-entry-name"});q.appendChild(k.highlightMatch(u.fullname));t.appendChild(s);t.appendChild(r);t.appendChild(q);return t},highlightMatch:function(r){r=r||"";var p=null;var s=new RegExp("("+k.escapeTerm(o)+")","gi");if(r.match(s)){var q=r.replace(s,"<b>$1</b>");p=new Element("span");p.innerHTML=q}else{p=document.createTextNode(r)}return p},scrollToMatch:function(){var t=dom.utils.getDimensions(d);var p=d.select(".user-lookup-entry");for(var q=0;q<p.length;q++){p[q].removeClassName("selected")}var r=p[c];if(r){r.addClassName("selected");if(c>0){var s=dom.utils.getElementHeight(r);var u=s*c;if((u+s)>t.height){d.scrollTop=(u+s)-t.height}return true}}d.scrollTop=0;return true},escapeTerm:function(p){var q=new RegExp("(\\+|\\.|\\||\\?|\\!|\\\\|\\*|\\^|\\$|\\@|\\(|\\)|\\-|\\_|\\{|\\}|\\~|\\[|\\])","g");return p.replace(q,"\\$1")},setValue:function(p){CD.UserLookup.inputElement.value=p},entryClickHandler:function(p){CD.UserLookup.inputElement.value=p;this.cancel();if(typeof m=="function"&&this.isLastInput()){m()}},isLastInput:function(){var p=$$("input.proof-approver-email");var t=0;var s=null;for(var q=0;q<p.length;q++){if(p[q].up(".tpl-proof-approver")){continue}var r=dom.utils.getElementTop(p[q]);if(r>t){s=p[q]}}if(s==CD.UserLookup.inputElement){return true}else{return false}},validateEmail:function(s){if(s.up(".tpl-proof-approver")){return true}var q=false;if(s.value!=""){if(!/[\w\.\-]+@[\w\-]+(\.([\w\-]+))+$/.test(s.value)){s.addClassName("validation-failed");var p=$(s.parentNode).select(".validation-advice");if(!p.length>0){var p=new Element("div",{"class":"validation-advice"});p.appendChild(document.createTextNode("Please enter a valid email address. For example fred@domain.com"));s.parentNode.appendChild(p)}}else{q=true;var p=$(s.parentNode).select(".validation-advice");if(p.length>0){p[0].parentNode.removeChild(p[0])}s.removeClassName("validation-failed")}if(!q){s.addClassName("validation-failed");var p=$(s.parentNode).select(".validation-advice");if(p.length==0){var p=new Element("div",{"class":"validation-advice"});p.appendChild(document.createTextNode("Please enter a valid email address. For example fred@domain.com"));s.parentNode.appendChild(p)}}}var r=CD.TinyMCE.getWindowId(s);if(r){var t=cdwm.getWindow(r);if(t){cdwm.resizeByContent(t)}}return q}};return k})();function CD_Task(){CD_Object.call(this);this.activity_type=9;this.namespace="task";this.displayName="Task";this.cleared=false;this.views.request_update=function(b,a){wiki_tools.show_generic_lightbox("task_request_update_step1&taskid="+a+"&spid="+b,"Request Task Update","420px","auto")};this.actions.request_update=function(d,a){var c=$("task_update_msg").value;var b={taskid:a,spid:d,r:Math.random(),"do":"task_request_update_step2",task_update_msg:c};new Ajax.Request(ajax_dt,{method:"post",parameters:b,onComplete:function(e){overlay.hide();cdwm.alert("Task Update Request sent via Email to Assigned Member(s)")}})};this.actions.fetchOverdue=function(b,h,d,a,e){var c="/home/"+this.namespace+"/";var f=$$("#ovdItems>li").length;var g={doaction:"fetchOverdue",format:"json",limit:b,offset:f,show_user_widget:h,show_more_link:d,show_space:a,columns:e,rand:Math.random()};new CD.Ajax.Request(c,{method:"post",parameters:g,onSuccess:function(k){$("ovdItems").innerHTML=$("ovdItems").innerHTML+k.innerHTML;if((k.numItems<b)||(k.allDone)){$("ctrlOvdMore").style.display="none"}return(false)}});return(false)};this.actions.hideOverdue=function(){};this.actions.showOverdue=function(){};this.views.permalink=function(a){var c='<div style="padding: 5px 5px 10px 5px; font-size: 14px; ">Permanent Link for this Task<div class="sml_break3"></div><input type="text" style="background-color: #fff; width: 450px; font-size: 14px;" readonly value="'+a+'" /></div><div style="padding: 7px 5px 5px 5px; font-size: 11px;">Here is the permanent link to this task. You should use this link when pointing others to this task.</div>';var b=new Element("div");b.innerHTML=c;var d={url:null,file:null,element:b,inline:1,type:"dynamic",title:"Permanent Link to this Task"};cdwm.open(true,d)};this.enableDragDrop=true;this.sortableTasklistIds=new Array;this.UI={Comment:{submit:function(a){CD.Comment.UI.submit(a,{complete_task:(a.form.complete_task&&a.form.complete_task.checked)})}}}}CD_Object.makeSubclass(CD_Task);window.CD.Task=new CD_Task;CD.Task.task_cache={};CD.Task.get=function(a){if(CD.Task.task_cache[a]){return CD.Task.task_cache[a]}else{return{"private":false}}};CD.Task.set=function(b,a){for(var c in a){CD.Task.task_cache[c]=a[c]}};CD=CD||{};CD.Base=function(){this.setProperty=function(a,b){this[a]=b};this.getProperty=function(a){return this[a]}};CD.Comment=function(){CD.Base.call(this);this.save=function(d,c){c=c||{};c.callbacks=c.callbacks||{};var b=c.scopeElem||$(document.body);var e=this;var a="/spaces/doaction_tasks";var f={"do":"comment_add",fk_spaceid:this.fk_spaceid,recid:this.fk_id,recid_vc:this.fk_id_varchar,item_type:this.item_type,activity_type:this.activity_type,version:this.version,message:this.comment,notify_users:this.notify_users,cc_me:this.cc_me,cc_external:this.cc_external,complete_task:this.complete_task,comment_type:this.comment_type,seccode:this.seccode,optional_title:this.optional_title,optional_private:this.optional_private,format:"json"};new CD.Ajax.Request(a,{method:"post",parameters:f,onSuccess:function(h){if(h.reload!=undefined&&h.reload){document.location.reload(true)}else{var g=b.select(".comment_new_insert_point").first();if(g){var n=$("page_comment_id_template");var m=n.cloneNode(true);m.id="page_comment_id_"+h.pk_id;m.setAttribute("pk_id",h.pk_id);m.setAttribute("fk_spaceid",f.fk_spaceid);var k=m.select(".cmt-bbl-text .wiki-content")[0];k.innerHTML=h.comment;if(e.cc_external){var o=$$(".cc_dynamic_list").first();if(o){k.insert({after:'<div class="cmt-bbl-footer">Also sent to: '+o.innerHTML+"</div>"})}}g.parentNode.insertBefore(m,g);m.style.display="";CD.Comment.UI.resetAddComment(d)}}if(typeof c.callbacks.onSaveNew!=="undefined"){c.callbacks.onSaveNew(f)}}});return true};this.notify_users=null;this.fk_id=null;this.fk_spaceid=null;this.fk_id_varchar=null;this.is_html=null;this.version=null;this.fk_original_id=null;this.activity_type=null;this.version=null;this.comment=null;this.cc_me=null;this.comment_type="ajax";this.complete_task=null;this.seccode=null;this.optional_title=null;this.optional_private=null};extend(CD.Comment,CD.Base);CD.Comment.UI={};CD.Comment.UI.showActions=function(){var a=$(this);if(!a.hasClassName("cmt-edit-inline")&&!a.hasClassName("cmt-reply")){a.addClassName("cmt-show-actions")}else{a.removeClassName("cmt-show-actions")}};CD.Comment.UI.hideActions=function(){var a=$(this);if(!a.hasClassName("cmt-edit-inline")){a.removeClassName("cmt-show-actions")}};CD.Comment.UI.edit=function(c,a){if(a){a.stop();a.preventDefault()}if(c.comment_id>0){var b=$("page_comment_id_"+c.comment_id);CD.Comment.UI.hideActions.bind(b)();b.addClassName("cmt-edit-inline");var k="rte_discussion";var g=b.select(".cmt-bbl-text .wiki-content")[0];var d=g.innerHTML;var f=new Element("textarea",{id:"edit_comment_"+c.comment_id});f.value=d;g.parentNode.appendChild(f);if(b.up(".tasklist")){k="rte_task";f.addClassName(k)}try{tinyMCE.execCommand("mceRemoveControl",false,f.id)}catch(h){}tinyMCE.execCommand("mceAddControl",false,f.id+":"+k);if(typeof c.callback==="function"){c.callback(a)}}else{cdwm.alert("An error was encountered while editting your comment. Please reload the page and try again.")}};CD.Comment.UI.resetEditComment=function(b,a){try{var c=$("edit_comment_"+a);tinyMCE.execCommand("mceRemoveControl",false,c.id);c.parentNode.removeChild(c)}catch(d){}$("page_comment_id_"+a).removeClassName("cmt-edit-inline");if(b){b.value="Save";b.disabled=false}};CD.Comment.UI.submitEdit=function(d,f,m,k){if(f>0){try{var n=CD.Environment.model.id}catch(g){var n=k}try{var h=CD.Environment.model.activity_type}catch(g){var h=m}var b="/spaces/doaction_comments";var a=tinyMCE.get("edit_comment_"+f);if(a.plugins.spellchecker.active){a.execCommand("mceSpellCheck")}var o=a.getContent();var c={doaction:"comment_edit",format:"json",r:Math.random(),spid:(CD.Environment.space?CD.Environment.space.id:null),activity_type:h,comment_id:f,recid:n,message:o};new Ajax.Request(b,{method:"post",parameters:c,onSuccess:function(q){var p=q.responseText;var e=$("page_comment_id_"+f);var r=e.select(".cmt-bbl-text .wiki-content")[0];r.innerHTML=p;CD.Comment.UI.resetEditComment(d,f)},onError:function(e){CD.Comment.UI.resetEditComment(d,f);cdwm.alert("An error was encountered while trying to save your edit. Please try again later.")}})}else{cdwm.alert("An error was encountered and your comment was not saved.  Please save your comment, reload the page, and try again.")}};CD.Comment.UI.del=function(b,a){cdwm.confirm("Are you sure you want to permanently delete this Comment?",function(c){if(c){var d={"do":"delete_comment",commentid:b.comment_id,activity_type:b.activity_type,spid:b.spaceid,rand:Math.random()};new Ajax.Request(ajax_dt,{method:"get",parameters:d,onSuccess:function(f){Effect.BlindUp("page_comment_id_"+b.comment_id);if(typeof b.callback==="function"){b.callback(a)}else{try{var h=$$("#tab_comments .count")[0];h.innerHTML=parseInt(h.innerHTML)-1}catch(g){}}},onError:function(){cdwm.alert("Failed to delete comment.")}})}})};CD.Comment.UI.resetAddComment=function(e,c){var a=(c)?c.element():e;var d=a.up(".tabstrip-wrapper");if(!d){d=$(document.body)}var b=d.select('textarea[name="comment_comment"]').first();b.value="";tinyMCE.activeEditor.setContent("");if(e){e.value="Save";e.disabled=false}CD.Comment.UI.toggleAddComment(false,c)};CD.Comment.UI.nextId=0;CD.Comment.UI.generateId=function(){return"txtAreaComment"+(CD.Comment.UI.nextId++)};CD.Comment.UI.toggleAddComment=function(f,p){f=f||false;p.stop();p.preventDefault();var g=p.element();var b=g.up(".cmt-feed").select(".cmt-reply").first();if(!b){b=$(document.body)}var n=g.up(".cmt-feed");n.toggleClassName("cmt-replying");var o=b.select('textarea[name="comment_comment"]').first();if(o.id==="comment_comment"){try{tinyMCE.execCommand("mceRemoveControl",false,o.id)}catch(m){}o.id=CD.Comment.UI.generateId()}var a="rte_discussion";if(n.up(".tasklist")){a="rte_task";o.addClassName(a)}o.value="";o.className="rte_discussion";if(n.hasClassName("cmt-replying")){try{tinyMCE.execCommand("mceRemoveControl",false,o.id)}catch(k){}try{tinyMCE.execCommand("mceAddControl",false,o.id+":"+a)}catch(h){}setTimeout(function(){try{tinyMCE.execInstanceCommand(o.id,"mceFocus")}catch(e){}},100)}else{try{tinyMCE.execCommand("mceRemoveControl",false,o.id)}catch(d){}}var c=b.select('.cmt-meta input[type="button"]').first();if(c){c.value="Save";c.disabled=false}};CD.Comment.UI.toggleCcMeCbx=function(b){try{var a=$($(b).parentNode.parentNode);var d=a.select(".ccme_label")[0];d.toggleClassName("bl-dynamic")}catch(c){}};CD.Comment.UI.submit=function(h,c,n){c=c||{};var b=h.form,d="",a=null,f;for(var g=0;g<b.elements.length;g++){if(b.elements[g].name=="comment_comment"){a=b.elements[g];break}}n.scopeElem=h.up(".tabstrip-wrapper");try{if(tinyMCE.activeEditor.plugins.spellchecker.active){tinyMCE.activeEditor.execCommand("mceSpellCheck")}d=tinyMCE.activeEditor.getContent();if(d==""){d=a.value}else{a.value=d}}catch(k){d=a.value}if(d==""){cdwm.alert("You must enter a comment before saving it.");return false}var m=false;f=$("seccode");if(f){c.seccode=f.value;m=wiki_tools.check_captcha("seccode",h.form.id,function(){return CD.Comment.UI.submitComment(h,c,n)})}else{m=CD.Comment.UI.submitComment(h,c,n)}return m};CD.Comment.UI.submitComment=function(g,c,o){var b=g.form;g.disabled=true;g.value="Posting...";try{parent.parent.tasks_change_was_made=true;parent.parent.overlay.shouldReload=true}catch(m){}var h=new CD.Comment;var k="comment_";for(var d in c){h.setProperty(d,c[d])}for(var d=0;d<b.elements.length;d++){var a=b.elements[d].name;var f=a.match(new RegExp("^"+k+"(.+)$"));if(f&&f[1]&&b.elements[d]&&typeof b.elements[d]!="undefined"&&typeof b.elements[d]!="function"&&typeof b.elements[d].value!="undefined"){if(b.elements[d].type=="checkbox"){if(b.elements[d].checked){h.setProperty(f[1],b.elements[d].value)}else{h.setProperty(f[1],false)}}else{h.setProperty(f[1],b.elements[d].value)}}}var n=h.save(g,o);return n};CD.Comment.UI.addEvents=function(b){var c,a;b=b||{};b.callbacks=b.callbacks||{};b.parentElem=b.parentElem||$$("body")[0];$(b.parentElem).select(".cmt-comment").each(function(m){var g,h,d,f,e;if(m.id==="page_comment_id_template"){return true}g=m.readAttribute("data-pk_id");h=m.select(".cmt-meta input.rbutton")[0];d=m.select(".cmt-meta a.attention-cancel")[0];var k=false;if(g){e=m.select("a.icon_trash")[0];if(e){k=true;e.observe("click",function(n){n.stop();n.preventDefault();CD.Comment.UI.del({activity_type:b.activity_type,comment_id:g,spaceid:b.spaceid,callback:typeof b.callbacks.onDelete==="function"?b.callbacks.onDelete:null},n)})}f=m.select("a.icon_edit")[0];if(f){k=true;f.observe("click",function(n){n.stop();n.preventDefault();CD.Comment.UI.edit({activity_type:b.activity_type,comment_id:g},n);if(typeof b.callbacks.onShowEditor==="function"){b.callbacks.onShowEditor(n)}})}if(k){Event.observe(m,"mouseover",CD.Comment.UI.showActions);Event.observe(m,"mouseout",CD.Comment.UI.hideActions)}if(h){h.observe("click",function(n){n.stop();n.preventDefault();CD.Comment.UI.submitEdit(this,g,b.activity_type,b.item_id);if(typeof b.callbacks.onSaveEdit==="function"){b.callbacks.onSaveEdit(n)}})}if(d){d.observe("click",function(n){n.stop();n.preventDefault();CD.Comment.UI.resetEditComment(h,g);if(typeof b.callbacks.onCancel==="function"){b.callbacks.onCancel(n)}})}}else{if(h){h.observe("click",function(n){var p=false;var o={};n.stop();n.preventDefault();if(b.activity_type===CD.ACTIVITY_TYPE_TASK&&typeof this.form.complete_task!=="undefined"){o.complete_task=this.form.complete_task.checked}if(b.activity_type===CD.ACTIVITY_TYPE_MILESTONE&&typeof this.form.complete_milestone!=="undefined"){o.complete_milestone=this.form.complete_milestone.checked}p=CD.Comment.UI.submit(this,o,b);if(p){CD.Comment.UI.toggleAddComment(false,n);if(typeof b.callbacks.onSaveNew==="function"){b.callbacks.onSaveNew(o,n)}}})}d=m.select(".cmt-meta a.attention-cancel")[0];if(d){d.observe("click",function(n){n.stop();n.preventDefault();CD.Comment.UI.resetAddComment(false,n);if(typeof b.callbacks.onCancel==="function"){b.callbacks.onCancel(n)}})}}});$(b.parentElem).select(".cmt-feed .cmt-toggle a.jslink").each(function(d){d.observe("click",function(e){e.stop();e.preventDefault();CD.Comment.UI.toggleAddComment(false,e)})})};CD_DynDB=function(){CD_Object.call(this);this.activity_type=22;this.ajax_url="/spaces/doaction_db";this.winHandle=null;this.views.move=function(a){this.winHandle=cdwm.open(false,{title:"Move to Another Workspace",file:this.ajax_url+"?do=move_to_workspace_view&guid="+a+"&spid="+CD.Environment.space.id+"&db_method=guid",type:"dynamic",inline:1,width:500})};this.actions.move=function(a){var b=$("space_list_0").value;var c={"do":"move_to_workspace_action",spid:CD.Environment.space.id,guid:a,db_method:"guid",new_spaceid:b,rand:Math.random()};disablesubmit("move_to_workspace_submit","Moving...");new Ajax.Request(this.ajax_url,{method:"post",parameters:c,onComplete:function(d){cdwm.close(this.winHandle);this.winHandle=null;window.location="dbapp&"+d.responseText}})};this.views.copy=function(a){this.winHandle=cdwm.open(false,{title:"Copy Database",file:this.ajax_url+"?do=copy_db_view&spid="+CD.Environment.space.id+"&db_method=guid&guid="+a+"&rand="+Math.random(),type:"dynamic",inline:1,width:500})};this.actions.copy=function(b){var a=$("copy_db_new_label").value;if($("copy_db_workflow")){var c=$("copy_db_workflow").checked?1:0}else{var c=0}if(a==""){cdwm.alert("You must specify a Name for the copied database.")}else{var d={"do":"copy_db_action",spid:CD.Environment.space.id,copy_db_new_label:a,db_method:"guid",guid:b,copyWorkflows:c,rand:Math.random()};disablesubmit("copy_db_submit","Copying...");new Ajax.Request(this.ajax_url,{method:"post",parameters:d,onComplete:function(e){cdwm.close(this.winHandle);this.winHandle=null;window.location=e.responseText}})}};this.views.printAll=function(d,b){d=d!=""?d:null;b=b!=""?b:null;var c=this.ajax_url+"?do=printAll&spid="+CD.Environment.space.id+"&db_method=guid&guid="+CD.Environment.model.fk_tableid+"&r="+Math.random()+"&lbref=lb&pgref=vr";if(d!=null){c+="&sort="+d}if(b!=null){c+="&view="+b}if(dom.utils.browser.isIE()){overlay.toggleSelects(true)}var a=dom.utils.getWindowHeight();var e=dom.utils.getWindowWidth();var f={title:"Print Entire Database View",file:c,height:parseInt(a)-100,width:parseInt(e)-100,inline:1,type:"iframe",scrollbars:true,afterLoad:function(g){if(g.document.getElementById("printAllView")){if(browser.isIE){g.document.execCommand("print",false,null);setTimeout(function(){g.parent.overlay.hide()},5000)}else{g.print()}}}};return cdwm.open(false,f)};this.views.showDbLimits=function(b,a){var d="";if(a>0){d+="You have reached the Maximum Dynamic Databases allowed for your Account.<br />";d+="Your current Plan includes "+a+" Dynamic Databases and you currently have "+b+" Dynamic Databases."}else{d+="Your Plan does not include any Dynamic Databases.  "}d+='<br /><br /><a href="/home/upgrade_account" target="_top">Click Here to see Your Upgrade Options.</a><br /><br />';var c={width:570};return cdwm.alert(d,c)};this.views.showWorkflowLimits=function(b,a){var d="";if(a>0){d+="You have reached the Maximum Workflow Rules allowed for your Account.<br />";d+="Your current Plan includes "+a+" Workflow Rules and you currently have "+b+" Workflow Rules."}else{d+="Your Plan does not include any Workflow Rules.  "}d+='<br /><br /><a href="/home/upgrade_account" target="_top">Click Here to see Your Upgrade Options.</a><br /><br />';var c={width:570};return cdwm.alert(d,c)};this.views.addChildRecord=function(a,d,c){var b=this;var e={title:"Add New Record",file:"/"+CD.Environment.space.name+"/dbapp="+a+"&ac=arlb&guid="+a+"&spid="+CD.Environment.space.id+"&db_method=guid&"+encodeURIComponent(d)+"="+encodeURIComponent(c),type:"iframe",inline:true,width:850,afterLoad:function(){try{cdwm.resizeByContent(b.winHandle,{width:850})}catch(f){console.log(f)}},afterClose:function(){if(b.winHandle.parentReload){window.location.reload()}b.winHandle=null;delete window.parentDb}};this.winHandle=cdwm.open(false,e);this.winHandle.parentReload=false;window.parentDb={closeChildLb:function(){cdwm.close(b.winHandle)},setReload:function(f){b.winHandle.parentReload=!!f}};return};this.deleteField=function(b,a){this.deleteFieldGeneric(b,"","guid",a)};this.deleteFieldGeneric=function(b,c,d,a){cdwm.confirm("Are you sure you want to delete this Field?\nAll the data stored in this field will be deleted.",function(e){if(e){var f="/spaces/doaction_db";var g={"do":"fetchAffectedWorkflows",format:"json",guid:b,used_for:c,db_method:d,field_name:a,r:Math.random()};new CD.Ajax.Request(f,{method:"post",parameters:g,onSuccess:function(h){if(h.count>0){CD.DynDB.confirmAffectedWorkflows(h,b,c,d,a)}else{CD.DynDB.performConfirmedDeleteField(b,c,d,a,true)}}})}})};this.confirmAffectedWorkflows=function(e,d,g,h,b){var c='<table><tr><td style="padding-top: 15px; vertical-align: top; text-align: center; width: 55px;"><span class="mceAlertIcon"></span></td><td style="padding-top: 15px; vertical-align: top;"><b>You are about to delete a field that is a condition of the following workflow rules:</b><ul>';e.workflows.each(function(k){c+='<li><a href="'+k.url+'" target="_blank">'+k.name+"</a></li>"});c+='</ul><p>If you delete this field, these workflow rules will be deactivated until you review and reactivate them.</p><p>Are you sure you want to delete this field?</p></td></tr></table><div style="text-align: center"><input class="rbutton" type="button" id="confirmAffectedWorkflows" value="Yes, Delete Field Anyways"  onclick="CD.DynDB.performConfirmedDeleteField(\''+d+"', '"+g+"', '"+h+"', '"+b+'\', true); cdwm.closeWindow(this);" /><span class="padding_left_10 ahref cancel" onclick="cdwm.closeWindow(this);">Cancel</span></div>';var a=new Element("div");a.innerHTML=c;var f=cdwm.open(false,{element:a,inline:1,height:177+(e.count*14)})};this.performConfirmedDeleteField=function(c,d,f,b,g){g=g===true?true:false;var a="/spaces/doaction_db";var e={"do":"delete_field",loc:CD.Environment.space!=undefined?CD.Environment.space.url:"",spid:CD.Environment.space!=undefined?CD.Environment.space.id:"",guid:c,used_for:d,db_method:f,field:b,confirmed:g?true:false,r:Math.random()};new CD.Ajax.Request(a,{method:"post",parameters:e,onComplete:function(h){window.location.reload()}},false)};this.fieldAllowSelectAddons=function(d,f,c){var b=false;var a="/spaces/doaction_db";var e={"do":"allow_select_addons",spid:CD.Environment.space!=undefined?CD.Environment.space.id:"",guid:d,db_method:f,field:c,r:Math.random()};new Ajax.Request(a,{asynchronous:false,parameters:e,onComplete:function(g){b=g.responseText}});return b};this.UI={init:function(){var a=$$(".dyndb.tabstrip-wrapper").first();var c=a.select("#tab_tasks").first();var d=c.select(".count").first();if(!d){d=new Element("span",{"class":"count"});var b=c.select("span").first();b.insert(d)}CD.PageBus.subscribe("CD.Tasklist.Model.*.tasksLoaded",d,CD.DynDB.UI.updateTaskCount,null);CD.PageBus.subscribe("CD.Task.Model.*.UI.toggle-complete",d,CD.DynDB.UI.updateTaskCount,null)},updateTaskCount:function(a,b,d){var c;if(a.match(/\.tasksLoaded$/)){c=b.meta.num_records-b.meta.num_completed}else{if(a.match(/\.toggle\-complete$/)&&b.task instanceof CD.Task.Model){c=parseInt(this.getAttribute("data-count"),10);if(b.task.get("completed")){c++}else{c--}}}this.setAttribute("data-count",c);this.update(" ("+c+")")},switchTabs:function(a,k,d,h){try{var o=true;if(arguments.length==5){o=arguments[4]}var n=$(a);var r=$(n.parentNode);var q=r.up(".tabstrip-wrapper");var p=r.select("li");var c,g;r.select("li").each(function(e){e.removeClassName("tab_selected")});n.addClassName("tab_selected");q.select(".item-tab-wrapper").each(function(e){if(e.parentNode===q){e.style.display=e.hasClassName(a)?"":"none"}});var t=$("tab_comments_content");var b=$("tab_files_content");var u=$("tab_tasks_content");switch(a){case"tab_comments":if(t){t.style.display=""}if(b){b.style.display="none"}if(u){u.style.display="none"}break;case"tab_files":if(t){t.style.display="none"}if(b){b.style.display=""}if(u){u.style.display="none"}break;case"tab_tasks":if(t){t.style.display="none"}if(b){b.style.display="none"}if(u){u.style.display=""}break}try{var s=document.forms.addReply.elements.comment_comment;$(s).className="rte_discussion"}catch(m){}if(a=="tab_comments"){try{tinyMCE.execCommand("mceRemoveControl",false,"comment_comment")}catch(m){}}CD.Cookies.write("dbViewTab",a)}catch(f){console.log(f)}},deploySubscribersPicker:function(a,e,d,c){var b=$(a);if(!b){return}if(window.upicker){$(window.upicker).remove()}window.upicker=new UserPicker({sourceURL:"/spaces/doaction_db?spid="+spid+"&guid="+e+"&recid="+d+"&do=handle_subscribers",selectable:c,selectedOnly:!c,showGroups:false,emptySectionMessage:"There are no subscribers for this record",maxHeight:200,ownUserId:uid?uid:null});window.upicker.init();b.appendChild(window.upicker)},toggleSubscribersList:function(a){var b=$(a).select(".icon")[0];if(b.hasClassName("icon_expand")){b.removeClassName("icon_expand");b.addClassName("icon_collapse");$$("div.db-record-field-submit")[0].addClassName("blog-entry-showsbs")}else{b.removeClassName("icon_expand");b.addClassName("icon_expand");$$("div.db-record-field-submit")[0].removeClassName("blog-entry-showsbs")}return false}}};extend(CD_DynDB,CD_Object);window.CD.DynDB=new CD_DynDB;function CD_Blog(){}CD_Blog.prototype=new CD_Item;CD_Blog.prototype.constructor=CD_Blog;CD_Blog.superclass=CD_Item.prototype;CD_Blog.parent=CD_Item.prototype;window.CD.Blog=new CD_Blog();function CD_BlogEntry(){CD_Item.call(this);this.namespace="blogentry";this.displayName="Blog Entry";this.item_type=10;this.views.create=function(d,a){d=d||"std";var c,e,b;if(d=="db"){e="lb";c=CD.Environment.space.relative_url+this.namespace+"/create/?discussion_fk_categoryid="+CD.Folder.ATTACHMENT+"&dbid="+a;b=overlay.reloadParent}else{c=CD.Environment.space.relative_url+this.namespace+"/create/?discussion_fk_categoryid="+CD.Environment.model.id;e="";b=true}overlay.showFullScreen("",c,e,b)};this.actions.toggleSubscribersList=function(a){var b=$(a).select(".icon")[0];if(b.hasClassName("icon_expand")){b.removeClassName("icon_expand");b.addClassName("icon_collapse");$("blForm").addClassName("blog-entry-showsbs")}else{b.removeClassName("icon_expand");b.addClassName("icon_expand");$("blForm").removeClassName("blog-entry-showsbs")}};this.actions.save=function(b,a){needToConfirm=false;var b=document.entryForm;if(this.doValidation(this.validate.subject,this.validate.body)){try{parent.parent.overlay.shouldReload=true}catch(c){}if(typeof(window.upicker)!=="undefined"){if(b.doaction.value=="update"){b.subscribers.value=upicker.getAltered(true)}else{b.subscribers.value=upicker.getSelected(true)}}$("sbm").disabled=true;$("sbm").value="Posting...";b.submit();return false}else{return false}};this.views.email_addresses=function(e,d){var b=CD.Environment.space.relative_url+this.namespace+"/"+e+"/email_addresses/?rand="+Math.random();var c={title:"Email Addresses for: "+d,file:b,type:"dynamic",inline:1,width:650};var a=overlay.show(c,false);return a};this.actions.showReplyForm=function(a,b){b=!!b;$(a).addClassName("cmt-replying");if(!b){$(a).select(".cmt-reply")[0].scrollTo()}};this.actions.hideReplyForm=function(a){$(a).removeClassName("cmt-replying")};this.actions.permanentlyDelete=function(a){a=1*a;if(confirm("Permanently Delete this Blog Post?")){window.location=actionLocation=CD.Environment.space.relative_url+this.namespace+"/"+a+"/?doaction=deletePermanent"}return};this.validate.subject=function(){if(!$("subject").value.trim()){throw ("Please fill out post title")}};this.validate.body=function(){var d="";try{var a=tinyMCE.get("message");d=a.getContent().trim()}catch(c){var b=$("message");if(b){d=b.value.trim()}else{}}if(d=="<p>&nbsp;</p>"||d==""){throw ("Please fill out your message before submitting this post.")}}}extend(CD_BlogEntry,CD_Item);window.CD.BlogEntry=new CD_BlogEntry();function CD_Forum(){}CD_Forum.prototype=new CD_Item;CD_Forum.prototype.constructor=CD_Forum;CD_Forum.superclass=CD_Item.prototype;CD_Forum.parent=CD_Item.prototype;window.CD.Forum=new CD_Forum();function CD_ForumEntry(){CD_Item.call(this);this.namespace="forumentry";this.displayName="Forum Entry";this.item_type=10;this.views.create=function(d,a){d=d||"std";var c,e,b;if(d=="db"){e="lb";c=CD.Environment.space.relative_url+this.namespace+"/create/?discussion_fk_categoryid="+CD.Folder.ATTACHMENT+"&dbid="+a;b=overlay.reloadParent}else{c=CD.Environment.space.relative_url+this.namespace+"/create/?discussion_fk_categoryid="+CD.Environment.model.id;e="";b=true}overlay.showFullScreen("",c,e,b)};this.actions.toggleSubscribersList=function(a){var b=$(a).select(".icon")[0];if(b.hasClassName("icon_expand")){b.removeClassName("icon_expand");b.addClassName("icon_collapse");$("blForm").addClassName("blog-entry-showsbs")}else{b.removeClassName("icon_expand");b.addClassName("icon_expand");$("blForm").removeClassName("blog-entry-showsbs")}};this.actions.save=function(b,a){needToConfirm=false;var b=document.entryForm;if(this.doValidation(this.validate.subject,this.validate.body)){try{parent.parent.overlay.shouldReload=true}catch(c){}if(typeof(window.upicker)!=="undefined"){b.subscribers.value=upicker.getSelected(true)}$("sbm").disabled=true;$("sbm").value="Posting...";b.submit();return false}else{return false}};this.actions.deletePermanently=function(a){a=1*a;if(confirm("Permanently Delete this Forum Entry?")){window.location=CD.Environment.space.relative_url+"forumentry/"+a+"/?doaction=deletePermanently"}return};this.views.email_addresses=function(e,d){var b=CD.Environment.space.relative_url+this.namespace+"/"+e+"/email_addresses/?rand="+Math.random();var c={title:"Email Addresses for: "+d,file:b,type:"dynamic",inline:1,width:650};var a=overlay.show(c,false);return a};this.actions.showReplyForm=function(a,b){b=!!b;$(a).addClassName("cmt-replying");if(!b){$(a).select(".cmt-reply")[0].scrollTo()}};this.actions.hideReplyForm=function(a){$(a).removeClassName("cmt-replying")};this.validate.subject=function(){if(!$("subject").value.trim()){throw ("Please fill out post title")}};this.validate.body=function(){var d="";try{var a=tinyMCE.get("message");d=a.getContent().trim()}catch(c){var b=$("message");if(b){d=b.value.trim()}else{}}if(d=="<p>&nbsp;</p>"||d==""){throw ("Please fill out your message before submitting this post.")}}}extend(CD_ForumEntry,CD_Item);window.CD.ForumEntry=new CD_ForumEntry();var CD=CD||{};CD_Event=function(){CD_Object.call(this);this.activity_type=7;this.item_type=7;this.displayName="Event";this.namespace="event"};extend(CD_Event,CD_Object);window.CD.Event=new CD_Event;function CD_Diagram(){CD_Item.call(this);this.item_type=12;this.namespace="diagram";this.displayName="Diagram";var b=this;function a(c){c=(c||"").replace(/^\//i,"");return"/"+[CD.Environment.space.name,b.namespace,c].join("/")}this.actions.create=function(e){var c={diagram_fk_categoryid:[/.+/i,"Folder is not selected"],diagram_title:[/.+/i,"Title is empty"],diagram_item_status:[/.+/i,"Status is not selected"]};var d="",f;for(f in c){if(!e[f].value.strip().match(c[f][0])){d+="\n  - "+c[f][1]}}if(d){d="Diagram can't be created:"+d;alert(d)}else{disablesubmit("btnCreateDiagram","Creating...");var g={asynchronous:false,doaction:"create",format:"json",diagram_fk_categoryid:e.diagram_fk_categoryid.value,diagram_title:e.diagram_title.value,diagram_item_status:e.diagram_item_status.value};if(typeof dbapp!="undefined"&&typeof recid!="undefined"){g.diagram_dyndb_dbapp=dbapp;g.diagram_dyndb_recid=recid}new CD.Ajax.Request(a(),{method:"get",parameters:g,onSuccess:function(h){cdwm.close();if("undefined"==typeof h.id||null===h.id){cdwm.alert(h.errmsg);enablesubmit("btnCreateDiagram","Create")}else{window.location=h.t_url+"edit"}}},false)}};this.views.create=function(e){if(!FlashDetect.versionAtLeast(10)){cdwm.alert('Diagram Creation and Editing requires Adobe Flash v10.<br/><br/>Click <a href="http://get.adobe.com/flashplayer/">here</a> to install the latest Flash Player.');return}e=CD.Object.getValidCatid(e,CD.Folder.GENERAL);var d=a("create/");var c={};c[this.namespace+"_fk_categoryid"]=e;var f={title:"Create a New Online Diagram",file:d+"?"+Object.toQueryString(c),width:520,height:200,type:"dynamic",scrollbars:false,inline:1,afterLoad:function(){$("rmCreateDiagram").diagram_title.focus()}};overlay.show(f,true)}}extend(CD_Diagram,CD_Item);CD.Diagram=new CD_Diagram();function ActivityLog(b,c){var a=$(b);if(!a){throw'RecentActivity: container "'+b+' does not exist"'}var c=c||{};var e=c.onFinish||function(){};var d=c.onExpired||function(){};this.load=function(f){new Ajax.Request("/home/doaction",{method:"post",parameters:{"do":"recent_activity_more",rakey:f},onComplete:(function(g){a.select(".ra-content").first().insert({bottom:g.responseText});e()}).bind(this)})};this.disableLoadMore=function(){a.select(".btn-load-more").first().hide()};ActivityLog._instances[b]=this}ActivityLog._instances={};ActivityLog.get=function(a){return ActivityLog._instances[a]||null};CD_Search=function(){CD_Object.call(this,arguments);this.views.showInSpaces=function(m,e){var b=new Element("div",{style:"padding: 10px;"});var f=new Element("div",{style:"margin: 5px 5px 10px 5px;"});var k=new Element("b");k.appendChild(document.createTextNode(m));f.appendChild(k);f.appendChild(document.createTextNode(" is also shared in the following Workspaces:"));b.appendChild(f);for(var d=0;d<e.length;d++){var a=e[d];var n=new Element("div",{style:"margin: 5px 5px 5px 20px;"});var h=new Element("a",{style:"text-decoration: underline;"});h.href=e[d].url;h.appendChild(document.createTextNode(e[d].name));n.appendChild(h);b.appendChild(n)}var c={title:"Also shared in",type:"dynamic",inline:true,element:b,height:((e.length+2)*25),width:500,clear:true};var g=overlay.show(c,true);return g};this.actions.searchWithin=function(b){var c=$(b).serialize(true);var d=[];c.q=c.q.strip();c.st=([c.st]).flatten().compact();if(!c.q){d.push("You must type in a Keyword Search to Search within Workspaces")}if(!c.st.length){d.push("You must select at least one Workspace to Search Within")}if(d.length){var a;if(d.length>1){a="Please fix following errors:<br/> - "+d.join("<br/> - ")}else{a=d[0]}cdwm.alert(a);return}c.st=c.st.join(",");document.location="/home/search?"+Object.toQueryString(c)}};CD_Object.makeSubclass(CD_Search);CD.Search=new CD_Search;var cd_search={update_file_types:function(c){var b=document.adv_search;var e=b.q_at;if(c=="all"){for(var a=0;a<e.length;a++){e[a].checked=false}}else{if(c=="filter"){}else{$("file_type_filter_apply").checked=true}}},update_workspace_filter:function(c){var b=document.adv_search;var e=b.st;if(c=="all"){if(e.checked==true){e.checked=false}else{for(var a=0;a<e.length;a++){e[a].checked=false}}}else{if(c=="filter"){}else{$("workspace_filter_apply").checked=true}}},adv_submit:function(){var k=document.adv_search;var q="";if(k.all_words.value.trim()==""&&k.phrase_match.value.trim()==""&&((k.tags.type=="text"&&k.tags.value.trim()=="")||k.tags.type=="hidden")){if(k.tags.type=="hidden"){cdwm.alert("You must enter a keyword or keyword phrase")}else{cdwm.alert("You must enter a keyword, keyword phrase or tag")}k.all_words.focus()}else{if(k.all_words.value!=""){q+=k.all_words.value}if(k.phrase_match.value!=""){q+=' "'+k.phrase_match.value+'"'}if(k.exclude_words.value!=""){var h=k.exclude_words.value;var c=h.indexOf('"');var m=h.substring(c+1).indexOf('"');var e=false;while(!e){q+=" -"+h.substring(c,c+m+2);h=strtrim(h.substring(0,c-1))+" "+strtrim(h.substring(c+m+2));c=h.indexOf('"');m=h.substring(c+1).indexOf('"');if(m==-1){e=true}}h=h.replace(/^\s*/,"").replace(/\s*$/,"");var b=h.split(" ");for(var n=0;n<b.length;n++){q+=" -"+b[n]}}var f="true";var a=k.q_ic;for(var n=0;n<a.length;n++){if(a[n].value=="false"&&a[n].checked){f="false"}}var g=0;if($("file_type_filter_apply").checked){var a=k.q_at;for(var n=0;n<a.length;n++){if(a[n].checked){g+=parseInt(a[n].value)}}}var p="";if($("workspace_filter_apply").checked){var a=k.st;for(var n=0;n<a.length;n++){if(a[n].checked){p+=a[n].value+","}}if(p.length>0){p=p.substring(0,p.length-1)}}var r=k.tags.value;var o="/home/search?q="+encodeURIComponent(q)+"&q_ic="+f+"&q_at="+g+"&tags="+r+"&st="+p;window.location=o}return false},workspace_submit:function(){var a=document.workspace_search;var b="";if(a.search_title.value.trim()==""&&a.search_description.value.trim()==""){cdwm.alert("You must enter a string for the title or description, to search on");a.search_title.focus()}else{if(a.search_title.value!=""){b+=a.search_title.value}if(a.search_description.value!=""){b+=' "'+a.search_description.value+'"'}return true}return false}};diff={balloon:null,nextElemId:0,init:function(){diff.balloon=new Balloon({loadFunction:diff.createDiffContent,scrubFunction:diff.cleanDiffContent});var a=$$("*[changes]");a.each(function(b){diff.createBalloonContent(b);b.observe("mouseover",function(c){diff.balloon.show(b,b.getAttribute("changes"))});b.observe("mouseout",function(c){diff.balloon.hide(b)})})},createBalloonContent:function(b){id=diff.nextElemId++;b.id="jsDiff"+id;b.setAttribute("rel","jsDiffContent"+id);var a=new Element("div",{"class":"jsDiffContent"});a.setAttribute("id","jsDiffContent"+id);document.body.appendChild(a);a.innerHTML=b.getAttribute("changes")},createDiffContent:function(c,b){var a=document.getElementById("balloon_loader");if(!a){a=document.createElement("div");a.id="balloon_loader";a.style.top="-1000px";a.style.left="0px";a.style.width="50%";a.style.height="900px";a.style.overflow="hidden";a.style.position="absolute";dom.utils.getBody().appendChild(a)}a.innerHTML=c.getAttribute("changes");srcElement=document.getElementById(raId);return srcElement},cleanDiffContent:function(b,a){return b}};CD.LocalStorage=function(a){if(!CD.LocalStorage.compatible){throw Error("HTML5 Local Storage not supported on this User-Agent")}if(!a){throw Error("Cannot instantiate an CD.LocalStorage object without a _storeName parameter")}var b=a+".";this.get=function(d){var c=window.localStorage[b+d];if(c){return JSON.parse(c)}return null};this.set=function(c,d){record=JSON.stringify(d);try{window.localStorage[b+c]=record;return true}catch(f){console.warn(f);return false}};this.unset=function(c){window.localStorage.removeItem(b+c)};this.unsetWhereNot=function(g,e){var d;var f=window.localStorage.length;for(d=f-1;d>=0;d--){var c=window.localStorage.key(d);if(c.indexOf(b)===0){var h=JSON.parse(window.localStorage.getItem(c));console.log(h);console.log(g+" -> "+h[g]);if(h[g]!==e){console.log("removing stale record: "+c);window.localStorage.removeItem(c)}else{console.log(c+" is NOT stale. Keeping.")}}}};this.reset=function(){var d;var e=window.localStorage.length;for(d=e-1;d>=0;d--){var c=window.localStorage.key(d);console.log(c);if(c.indexOf(b)===0){window.localStorage.removeItem(c)}}}};CD.LocalStorage.compatible=(window.Modernizr?Modernizr.localstorage:(typeof window.localStorage!=="undefined"));CD.LocalStorage.instances={};CD.LocalStorage.getInstance=function(a){if(typeof CD.LocalStorage.instances[a]==="undefined"){CD.LocalStorage.instances[a]=new CD.LocalStorage(a)}return CD.LocalStorage.instances[a]};(function(){var c=this;var b=[["C2EGenericHandler",/\bc2e-gnr-([^$\s]+)/],["C2EDBHandler",/\bc2e-db-([^$\s]+)/],["C2EFWHandler",/\bc2e-fw-([^$\s]+)/],["C2ESFHandler",/\bc2e-sf-([^$\s]+)/],["C2EGeneralHandler",/\bc2e-gn-([^$\s]+)/]];var d=false,a={};C2EManager={init:function(){if(!d){d=true;var e=new Element("span",{id:"c2eEditButton",className:"c2e-btn-edit icon icon_edit",title:"Click to Edit Field"});e.setStyle({display:"none"});e._activeElm=null;e._onclick=function(){this._activeElm.startEdit()};$(document.body).appendChild(e);e.showFor=function(n){if(this._hideTimer){clearTimeout(this._hideTimer)}if(this._relElm){this._relElm.highlight(false)}this._relElm=n;n.highlight(true);var h=n.cumulativeOffset(),g=n.cumulativeScrollOffset(),m=this.getDimensions(),f=n.getDimensions(),k=dom.utils.getZIndex(n);this.setStyle({left:h.left-g.left+f.width-m.width-5+"px",top:h.top+(f.height-m.height)/2+"px",zIndex:k});this.show()};e.hideLater=function(){if(this._hideTimer){clearTimeout(this._hideTimer)}this._hideTimer=setTimeout(function(){if(e._relElm){e._relElm.highlight(false)}e.hide()},100)};e.onmouseover=function(){if(this._hideTimer){clearTimeout(this._hideTimer)}};e.onclick=function(){if(this._relElm){this._relElm.onInitEditorReq()}this.hide()}}$$(".c2e").each(function(h){var g=null;for(var f=0;f<b.length;f++){if(h.className.match(b[f][1])){g=b[f][0];break}}if(g){if(!a[g]){a[g]=new window[g]()}a[g].registerEditable(h,RegExp.$1)}else{}})},getHandler:function(e){return a[e]||null}}}());function C2EAbstractHandler(){var f=this;var c={};var h=false;var e=$("c2eEditButton");this.setBusy=function(k){h=!!k};this.isBusy=function(){return h};function d(n){n=$(n);var k=false;var m=n.innerHTML.strip();n.observe("mouseover",function(o){if(k||f.isBusy()){return}e.showFor(this)});n.observe("mouseout",function(o){if(k||f.isBusy()){return}e.hideLater()});n.highlight=function(o){if(o){this.addClassName("c2e-editable-hover");this.title="Double Click to Edit Field"}else{this.removeClassName("c2e-editable-hover");this.title=""}};n.onInitEditorReq=function(){};n.observe("dblclick",function(){if(k||f.isBusy()){return}e.hideLater();this.onInitEditorReq()});n.setVal=function(o){this.update(o);try{new Effect.Highlight(this,{startcolor:"#fffbb9",endcolor:"#ffffff",restorecolor:""})}catch(p){}};n.backup=function(){m=n.innerHTML.strip()};n.restore=function(){n.innerHTML=m};n.getBackup=function(){return m};n.getMeta=function(){return this.identify().split("-")};n.markFailed=function(){this.addClassName("c2e-editable-failed");k=true};n.cancelClose=function(o){return false};return n}function g(k){return k.getBackup().replace("&nbsp;","")}g._instant=true;function b(){return true}function a(){return true}this.registerType=function(m,k,p,o,n){c[m]={name:m,editorClass:k,fetchValue:n||g,validate:o||b,save:p}};this.registerEditable=function(n,k){if(!c[k]){return false}var m=c[k];n=d(n);n.onInitEditorReq=function(){this.backup();f.setBusy(true);var q=new m.editorClass(this);q.deploy();if(!m.fetchValue._instant){q.showProc(true)}var r=m.fetchValue.call(m,this);if(r==null){n.markFailed()}else{q.setValue(r)}if(!m.fetchValue._instant){q.showProc(false)}q.focus();q.onDeployed();function p(){var u=q.getValue();q.showProc(true);var t=m.validate.call(m,u);if(t){q.warn(false);var s=m.save.call(m,n.getMeta(),u);q.remove();if(s==null){n.restore();n.markFailed()}else{if(s&&s.call){s(n)}else{n.setVal(s)}}n.backup();f.setBusy(false)}else{q.warn(true)}q.showProc(false);return t}function o(u){var s=$(Event.element(u));var t=false;if(s&&(s.hasClassName("c2e-editor")||s.up(".c2e-editor"))){t=true}if(s&&s.hasClassName("c2e-btn-edit")){t=true}if(n.cancelClose(u)){t=true}if(!t){if(p()){document.body.stopObserving("click",o)}}}q.onSave=p;if(!q.hasWindow){document.body.observe("click",o)}q.onRemove=function(){if(!q.hasWindow){document.body.stopObserving("click",o)}n.restore();f.setBusy(false)}}};this.getRegisteredTypes=function(){return c}}$C(C2EAbstractHandler);function C2EGeneralHandler(){this._self._parent.apply(this,arguments);for(var a in this._self.registeredTypes){this.registerType.apply(this,this._self.registeredTypes[a])}}C2EAbstractHandler.makeSubclass(C2EGeneralHandler);C2EGeneralHandler.classProperty("registeredTypes",{});C2EGeneralHandler.classMethod("registerType",function(b,c,a,f,e,d){b.registeredTypes[c]=[c,a,f,e,d]});function C2EAbstractEditor(a){this.hasWindow=false;this._html2elm=function(b){var c=new Element("div");c.update(b);return c.firstDescendant()};this.deploy=function(){};this.getValue=function(){};this.setValue=function(b){};this.remove=function(b){this.onRemove()};this.showProc=function(b){};this.focus=function(){};this.warn=function(b){};this.onDeployed=function(){};this.onRemove=function(){};this.onSave=function(){}}$C(C2EAbstractEditor);function C2ETextEditor(f){this._self._parent.apply(this,arguments);var d=this;var a='<span class="c2e-editor c2e-editor-text"><span><input type="text" value="" /></span><a href="#cancel" class="icon icon_favorites_remove" title="Cancel Edit"></a><ins class="ajax-loader"></ins></span>';var b=this._html2elm(a);var c=b.select("input")[0];var e=b.select("a")[0];b.observe("click",function(g){Event.stop(g)});e.observe("click",function(g){d.remove()});c.observe("keydown",function(g){switch(g.keyCode){case Event.KEY_RETURN:d.onSave();Event.stop(g);break;case Event.KEY_ESC:d.remove();Event.stop(g);break}});this.deploy=function(){b.setStyle({width:f.getWidth()});f.update(b)};this.getValue=function(){return c.value.strip()};this.setValue=function(g){c.value=g};this.showProc=function(g){g?b.addClassName("c2e-editor-processing"):b.removeClassName("c2e-editor-processing")};this.focus=function(){c.focus()};this.warn=function(g){g?b.addClassName("c2e-editor-error"):b.removeClassName("c2e-editor-error")}}C2EAbstractEditor.makeSubclass(C2ETextEditor);function C2EFlagEditor(e){this._self._parent.apply(this,arguments);var d=this;var a='<span class="c2e-editor c2e-editor-flag"><input type="checkbox" value="" /><ins class="ajax-loader"></ins></span>';var b=this._html2elm(a);var c=b.select("input")[0];c.observe("click",function(f){Event.stop(f)});c.observe("mouseup",function(f){this.checked=!this.checked});c.observe("keydown",function(f){switch(f.keyCode){case Event.KEY_RETURN:d.onSave();Event.stop(f);break;case Event.KEY_ESC:d.remove();Event.stop(f);break}});this.deploy=function(){var f=e.innerHTML.strip();e.update(b)};this.getValue=function(){return c.checked};this.setValue=function(f){f=f.toLowerCase()=="yes"||f===1||f===true;c.checked=!!f};this.showProc=function(f){f?b.addClassName("c2e-editor-processing"):b.removeClassName("c2e-editor-processing")};this.focus=function(){c.focus()}}C2EAbstractEditor.makeSubclass(C2EFlagEditor);function C2ESelectEditor(h){this._self._parent.apply(this,arguments);var e=this;var g=h.getMeta();g.shift();var a=g[0];var f=g[2];var b='<span class="c2e-editor c2e-editor-select">';if(CD.DynDB.fieldAllowSelectAddons(a,"guid",f)){b=b+"<select name="+f+" id="+f+' class="validate-is-not-addon fix-iewidth" onChange="databases.add_new_choice(\''+a+"', this.options[this.selectedIndex].value, '"+f+"', "+CD.Environment.space.id+');"></select>'}else{b=b+'<select class="fix-iewidth"></select>'}b=b+'<ins class="ajax-loader"></ins></span>';var c=this._html2elm(b);var d=c.select("select")[0];c.observe("click",function(k){Event.stop(k)});d.observe("keydown",function(k){switch(k.keyCode){case Event.KEY_RETURN:e.onSave();Event.stop(k);break;case Event.KEY_ESC:e.remove();Event.stop(k);break}});this.deploy=function(){h.update(c);if(window.fixIESelectWidth){fixIESelectWidth()}};this.getValue=function(){return d.options[d.selectedIndex]?d.options[d.selectedIndex].value:""};this.setValue=function(k){k.each(function(m){m[1]=escapeHTML(m[1]);d.appendChild(new Element("option",{value:m[0]})).update(m[1]).selected=m[2]})};this.showProc=function(k){k?c.addClassName("c2e-editor-processing"):c.removeClassName("c2e-editor-processing")};this.focus=function(){d.focus()}}C2EAbstractEditor.makeSubclass(C2ESelectEditor);function C2EDateEditor(h){this._self._parent.apply(this,arguments);var e=this;var a=h.id+"_editor";var b='<span class="c2e-editor c2e-editor-text" id="'+a+'_trigger"><span><input type="text" value="" id="'+a+'" readonly /></span><a href="#cancel" class="icon icon_favorites_remove"></a><ins class="ajax-loader"></ins></span>';var c=this._html2elm(b);var d=c.select("input")[0];var g=c.select("a")[0];c.observe("click",function(k){Event.stop(k)});g.observe("click",function(k){e.remove();Event.stop(k)});d.observe("keydown",function(k){switch(k.keyCode){case Event.KEY_ESC:e.remove();Event.stop(k);break;case Event.KEY_RETURN:e.onSave();Event.stop(k);break}});var f=this._html2elm('<a href="#none">None</a>');f.setStyle({fontSize:"10px"});f.addClassName("jslink");f.observe("click",function(k){$(a).value="None";d.focus();Event.stop(k)});h.cancelClose=function(m){var k=$(Event.element(m));return !!k.up("div.calendar")};this.deploy=function(){c.setStyle({width:h.getWidth()});h.update(c);h.appendChild(f);Calendar.setup({inputField:a,ifFormat:"%b %d, %Y",weekNumbers:false,align:"T",button:a+"_trigger"});return};this.getValue=function(){return d.value.strip()};this.setValue=function(k){d.value=k};this.showProc=function(k){k?c.addClassName("c2e-editor-processing"):c.removeClassName("c2e-editor-processing")};this.warn=function(k){k?c.addClassName("c2e-editor-error"):c.removeClassName("c2e-editor-error")};this.onDeployed=function(){c.showCalendar()}}C2EAbstractEditor.makeSubclass(C2EDateEditor);function C2EMultitextEditor(g){this._self._parent.apply(this,arguments);this.hasWindow=true;var e=this;var b='<div class="c2e-editor c2e-editor-window"><textarea class="c2e-hltable"></textarea><div class="centered"><input type="button" value="Save" class="rbutton rm10" /><a href="#" class="attention-cancel">Cancel</a></div><ins class="ajax-loader"></ins></div>';var c=this._html2elm(b);var d=c.select("textarea")[0];var a=c.select("input")[0];var f=c.select("a")[0];a.observe("click",function(h){e.onSave()});f.observe("click",function(h){e.remove();Event.stop(h)});this.deploy=function(){g.update("Editing&hellip;");var h={title:"Edit field",file:null,element:c,width:400,height:300,type:"dynamic",inline:1,afterClose:function(){e.onRemove()}};overlay.show(h,true)};this.remove=function(h){this.onRemove();cdwm.close()};this.getValue=function(){return d.value.strip()};this.setValue=function(h){d.value=h};this.showProc=function(h){h?c.addClassName("c2e-editor-processing"):c.removeClassName("c2e-editor-processing")};this.focus=function(){d.focus()};this.warn=function(h){h?c.addClassName("c2e-editor-error"):c.removeClassName("c2e-editor-error")}}C2EAbstractEditor.makeSubclass(C2EMultitextEditor);function C2EMultichoiceEditor(h){this._self._parent.apply(this,arguments);this.hasWindow=true;var f=this;var c='<div class="c2e-editor c2e-editor-window"><div class="c2e-hltable c2e-choicesbox"></div><div class="centered"><input type="button" value="Save" class="rbutton rm10" /><a href="#" class="attention-cancel">Cancel</a></div><div class="c2e-pcessing"><ins class="ajax-loader"></ins> Processing&hellip;</div></div>';var d=this._html2elm(c);var e=d.select("textarea")[0];var b=d.select("input")[0];var g=d.select("a")[0];var a=d.select(".c2e-choicesbox")[0];b.observe("click",function(k){f.onSave()});g.observe("click",function(k){f.remove();Event.stop(k)});this.deploy=function(){h.update("Editing&hellip;");var k={title:"Edit field",file:null,element:d,width:400,height:300,type:"dynamic",inline:1,afterClose:function(){f.onRemove()}};overlay.show(k,true)};this.remove=function(k){this.onRemove();cdwm.close()};this.getValue=function(){var k=[];a.select("input").each(function(m){if(m.checked){k.push(m.value)}});return k};this.setValue=function(k){a.update("");k.each(function(n){var m=new Element("label");m.update(n[1]);var o=new Element("input",{type:"checkbox",value:n[0]});o.checked=n[2];m.insert({top:o});a.insert({bottom:m})});a.insert({bottom:new Element("div",{"class":"clear"})})};this.showProc=function(k){k?d.addClassName("c2e-editor-processing"):d.removeClassName("c2e-editor-processing")};this.warn=function(k){k?d.addClassName("c2e-editor-error"):d.removeClassName("c2e-editor-error")}}C2EAbstractEditor.makeSubclass(C2EMultichoiceEditor);var C2E=C2EManager;function C2EDBHandler(){this._self._parent.apply(this,arguments);var f="/spaces/doaction_db";var u=function(B,z){var A={spid:CD.Environment.space.id,guid:B[0],recid:B[1],field:B[2]};if(B.length>3){A.db_method=B[3];A.used_for=B[4]}return Object.extend(A,z)};var x=function(z,A){return(z.length>3?["fld",z[0],z[1],A[0],z[3],z[4]]:["fld",z[0],z[1],A[0]]).join("-")};var w=function(D,A){var z=null;var C=(A instanceof Array)?"value[]":"value";D.shift();var B=u(D,{"do":"c2e_save"});B[C]=A;new Ajax.Request(f,{asynchronous:false,parameters:B,onComplete:function(F){var E=F.responseText.evalJSON();if(!E||!E.succeed||typeof(E.updated)=="undefined"){console.warn(E.err||"Failed to save changes.")}else{if(E.updated.length==0){z=function(G){G.restore()}}else{z=function(G){E.updated.each(function(I){var H=$(x(D,I));if(H){G.setVal.call(H,I[1])}})}}}}});return z};function h(z){return z.toString().replace(/&nbsp;/gi,"")}function o(A){var z=h(A.getBackup()).replace(/<br\/?>/ig,"\n").replace(/<[^>]+>/ig,"");return z}function b(A){var z=html_entity_decode(h(A.getBackup()).replace(/<[^>]+>/ig,""));return z}function a(A){h(A.getBackup()).match(/href="([^"]+)"/i);var z=RegExp.$1;return z}function m(A){var z=h(A.getBackup()).replace(/[^\d\.\s,]/ig,"");return z}function v(C){var z=null;var B=C.getMeta();B.shift();var A=u(B,{"do":"c2e_getchoices"});new Ajax.Request(f,{asynchronous:false,parameters:A,onComplete:function(E){var D=E.responseText.evalJSON();if(!D||!D.succeed||typeof(D.choices)=="undefined"){console.warn(D.err||"Failed to initialize editor.")}else{z=D.choices}}});return z}function r(z){return !!z.match(/\S+/i)}function d(z){return !!z.match(/^\d+(,\d+)*$/i)}function g(z){return !!z.match(/^[\d]+$/i)}function c(z){return !!z.match(/^\d+(,\d+)*(\.\d+)?$/i)}function e(z){return !!z.match(/^\+?(\(?\d+\)?[\-\s\.]?)+([A-Z]+)?$/)}function s(z){return !!z.match(/^[\w\.\-]+@[\w\-]+(\.([\w\-]+))+$/i)}function k(z){return !!z.match(/^https?:\/\/([a-z0-9\-]+\.)+[a-z]{2,4}/i)}function y(z){return !!z.match(/^https?:\/\/[a-z0-9\-]+(\.[a-z0-9\-])*/i)}function t(z){return z.length>0}function p(z){return !!z.match(/^\d+(\.[0-5]\d*)?$/i)}function q(z){return function(A){if(A.strip){A=A.strip()}return !A.length||z(A)}}function n(A,z){return function(B){var B=B.toString().strip();return(B.length<=z)&&A(B)}}this.registerType("text",C2ETextEditor,w,q(r),b);this.registerType("rtext",C2ETextEditor,w,r,b);this.registerType("num-nodec",C2ETextEditor,w,q(d),b);this.registerType("rnum-nodec",C2ETextEditor,w,d,b);this.registerType("num-nodec-nocomma",C2ETextEditor,w,q(g),b);this.registerType("rnum-nodec-nocomma",C2ETextEditor,w,g,b);this.registerType("num",C2ETextEditor,w,q(c),b);this.registerType("rnum",C2ETextEditor,w,c,b);this.registerType("email",C2ETextEditor,w,q(s),b);this.registerType("remail",C2ETextEditor,w,s,b);this.registerType("internal-url",C2ETextEditor,w,q(y),a,b);this.registerType("rinternal-url",C2ETextEditor,w,y,a,b);this.registerType("url",C2ETextEditor,w,q(k),a,b);this.registerType("rurl",C2ETextEditor,w,k,a,b);this.registerType("phone",C2ETextEditor,w,q(e),b);this.registerType("rphone",C2ETextEditor,w,e,b);this.registerType("flag",C2EFlagEditor,w,null,b);this.registerType("rflag",C2EFlagEditor,w,null,b);this.registerType("select",C2ESelectEditor,w,null,v);this.registerType("rselect",C2ESelectEditor,w,null,v);this.registerType("date",C2EDateEditor,w,null,b);this.registerType("rdate",C2EDateEditor,w,null,b);this.registerType("multitext",C2EMultitextEditor,w,q(r),o);this.registerType("rmultitext",C2EMultitextEditor,w,r,o);this.registerType("multichoice",C2EMultichoiceEditor,w,q(t),v);this.registerType("rmultichoice",C2EMultichoiceEditor,w,t,v);this.registerType("elapsedtime",C2ETextEditor,w,q(p),b);this.registerType("elapsedtime",C2ETextEditor,w,p,b);this.registerType("status",C2ESelectEditor,w,null,v);this.registerType("rstatus",C2ESelectEditor,w,null,v);this.registerType("intmember",C2ESelectEditor,w,null,v);this.registerType("rintmember",C2ESelectEditor,w,null,v);this.registerType("wsmember",C2ESelectEditor,w,null,v);this.registerType("rwsmember",C2ESelectEditor,w,null,v);this.registerType("currency",C2ETextEditor,w,n(q(c),14),m,b);this.registerType("rcurrency",C2ETextEditor,w,n(c,14),m,b);this.registerType("currency-nodec",C2ETextEditor,w,n(q(d),14),m,b);this.registerType("rcurrency-nodec",C2ETextEditor,w,n(d,14),m,b);this.registerType("percent",C2ETextEditor,w,q(c),m,b);this.registerType("rpercent",C2ETextEditor,w,c,m,b)}C2EAbstractHandler.makeSubclass(C2EDBHandler);(function(){var role2str={"1":"Read Only","3":"Reviewer","4":"Approver","5":"Reviewer and Approver"};var str2role={};for(var r in role2str){str2role[role2str[r]]=r}var notif2str={"1":"All new comments and replies","2":"Replies to my comments","3":"Daily summary","4":"Hourly summary","5":"Decisions only","9":"Disabled"};var str2notif={};for(var n in str2notif){str2notif[notif2str[n]]=n}function mkSaveFunc(field,retvalFunc){var retvalFunc=retvalFunc||function(p){return p[field]};return function(meta,newVal){var ret=null;var url=CD.Environment.space.relative_url+"file/"+CD.Environment.model.id+"/";var params={doaction:"updProofParticipant",format:"JSON",participant_id:meta[1],field:field,newval:newVal};CD.Ajax.Request(url,{method:"post",asynchronous:false,parameters:params,onSuccess:function(response){eval(response.responseText);ret=retvalFunc(response);try{cdwm.resizeByContent()}catch(err){}}});return ret}}function getRoles(elm){var selected=elm.getBackup();var ret=[];for(var r in role2str){ret.push([r,role2str[r],role2str[r]==selected])}return ret}function getNotifications(elm){var selected=elm.getBackup();var ret=[];for(var n in notif2str){ret.push([n,notif2str[n],notif2str[n]==selected])}return ret}C2EGeneralHandler.registerType("prfprole",C2ESelectEditor,mkSaveFunc("role",function(p){return role2str[p.role]}),null,getRoles);C2EGeneralHandler.registerType("prfpdeadline",C2EDateEditor,mkSaveFunc("deadline",function(p){return p.deadline_str}),null);C2EGeneralHandler.registerType("prfpnotif",C2ESelectEditor,mkSaveFunc("notification",function(p){return notif2str[p.notification]}),null,getNotifications)})();function C2ESFPermissionsEditor(e){this._self._parent.apply(this,arguments);var c=this;var a='<span class="c2e-editor c2e-editor-select"><select style="font-size:10px;"></select><ins class="ajax-loader"></ins></span>';var b=this._html2elm(a);var d=b.down("select");d.observe("keydown",function(f){switch(f.keyCode){case Event.KEY_RETURN:c.onSave();Event.stop(f);break;case Event.KEY_ESC:c.remove();Event.stop(f);break}});this.deploy=function(){e.update(b);return};this.getValue=function(){return 1*d.getValue()};this.setValue=function(f){f.each(function(g){d.appendChild(new Element("option",{value:g[0]})).update(g[1]).selected=g[2]});return};this.remove=function(){this.onRemove()};this.showProc=function(f){f?b.addClassName("c2e-editor-processing"):b.removeClassName("c2e-editor-processing");return};this.focus=function(){d.focus()};this.warn=function(f){};this.onRemove=function(){};this.onSave=function(){}}C2EAbstractEditor.makeSubclass(C2ESFPermissionsEditor);function C2ESFHandler(){this._self._parent.apply(this,arguments);function c(f){var e=f.getMeta(),d=[];if("permissions"==e[3]){d.push([1,"Read/Write",(f.getBackup()=="Read/Write")]);d.push([0,"Read Only",(f.getBackup()=="Read Only")])}else{if("comments"==e[3]){d.push([0,"Shared",(f.getBackup()=="Shared")]);d.push([2,"Not Shared",(f.getBackup()=="Not Shared")])}else{throw Error("Unknown element type: "+e[3])}}return d}function a(e,d){CD.Folder.doAction("updateShare",e[0],e[1],e[2],e[3],d);CD.Folder.reload=true;return function(f){if("permissions"==e[3]){f.update((0==d)?"Read Only":"Read/Write")}else{f.update((0==d)?"Shared":"Not Shared")}return}}function b(d){return true}this.registerType("permissions",C2ESFPermissionsEditor,a,b,c)}C2EAbstractHandler.makeSubclass(C2ESFHandler);function C2EGenericHandler(){var g=this;this._self._parent.apply(this,arguments);function b(s,r){return([CD.Environment.zf_uriprefix,"c2e",s,r]).compact().join("/")+".json"}function o(u,s){var r=null;u.shift();var t={field:u[1],value:Object.toJSON(s)};new Ajax.Request(b(u[0],"update"),{asynchronous:false,parameters:t,onComplete:function(w){var v=w.responseText.evalJSON();if(!v||!v.succeed||typeof(v.updated)=="undefined"){console.warn(v.err||"Failed to save changes.")}else{if(v.updated.length==0){r=function(x){x.restore()}}else{r=function(x){v.updated.each(function(z){var y=$(["fld",u[0],u[1]].join("-"));if(y){x.setVal.call(y,z[1])}})}}}}});return r}function n(r){var s=new Element("div");s.update(r);return s.innerText.replace(/^\s+|[ \t]+|\s+$/g,"")}function k(r){return n(r.getBackup())}function a(r){r.getBackup().match(/href="([^"]+)"/i);return RegExp.$1}function e(r){return n(r.getBackup()).replace(/[^\d\.\s,]/ig,"")}function f(t){var r=null;var s=t.getMeta();s.shift();new Ajax.Request(b(s[0],"choices"),{asynchronous:false,parameters:{field:s[1]},onComplete:function(v){var u=v.responseText.evalJSON();if(!u||!u.succeed||typeof(u.choices)=="undefined"){console.warn(u.err||"Failed to initialize editor.")}else{r=u.choices}}});return r}function m(r){return !!r.match(/\S+/i)}function d(r){return !!r.match(/^\d+(,\d+)*$/i)}function c(r){return r.length>0}function p(r){return function(s){if(s.strip){s=s.strip()}return !s.length||r(s)}}function h(s,r){return function(t){var t=t.toString().strip();return(t.length<=r)&&s(t)}}this.registerType("text",C2ETextEditor,o,p(m),k);this.registerType("rtext",C2ETextEditor,o,m,k);this.registerType("num-nodec",C2ETextEditor,o,p(d),k);this.registerType("rnum-nodec",C2ETextEditor,o,d,k);this.registerType("flag",C2EFlagEditor,o,null,k);this.registerType("rflag",C2EFlagEditor,o,null,k);this.registerType("select",C2ESelectEditor,o,null,f);this.registerType("rselect",C2ESelectEditor,o,null,f);this.registerType("date",C2EDateEditor,o,null,k);this.registerType("rdate",C2EDateEditor,o,null,k);this.registerType("intmember",C2ESelectEditor,o,null,f);this.registerType("rintmember",C2ESelectEditor,o,null,f);this.registerType("wsmember",C2ESelectEditor,o,null,f);this.registerType("rwsmember",C2ESelectEditor,o,null,f);for(var q in this._self.registeredTypes){this.registerType.apply(this,this._self.registeredTypes[q])}}C2EAbstractHandler.makeSubclass(C2EGenericHandler);C2EGenericHandler.classProperty("registeredTypes",{});C2EGenericHandler.classMethod("registerType",function(b,c,a,f,e,d){b.registeredTypes[c]=[c,a,f,e,d]});(function(){var a=Backbone.View.extend({watch_model:false,cls:"",constructor:function(b){var c=this;this.toString=function(){return this.ns()+"."+this.cid};Backbone.View.prototype.constructor.call(this,b);this.el.addClassName(this.options.cls||this.cls||"");this._watching_model=false;if(this.model&&(this.watch_model||b.watch_model)){if(!this._watching_model){var c=this;this._watching_model=true;if(!_.isFunction(this._redraw)){this._redraw=this.render.bind(this)}if(_.isArray(this.watch_model)){this.watch_model.each(function(d){c.model.bind("change:"+d,c._redraw)})}else{this.model.bind("change",c._redraw)}this.model.bind("destroy",this.remove.bind(this))}}this.el.on("click",".ctl-action",function(f){f.preventDefault();var g=f.element(),d=g.data("action")||(g.href&&g.href.substr(g.href.indexOf("#")+1));var d=_.map(d.split(":"),function(e){return isNaN(e)?e:parseFloat(e)});c.trigger.apply(c,_.union(["action"],d,[f]));c.trigger.apply(c,_.union(["action:"+d[0]],d.slice(1),[f]))})}});a.getInstance=function(){if(_.isUndefined(this.__instance)){this.__instance=new this()}return this.__instance};_.extend(a.prototype,CD.PageBus);ns("CD.BaseView",a)}());(function(){var c={change:"changed",destroy:"deleted",add:"adopted",remove:"orphaned"};function b(d,e){this.el=(new Element("span")).update("["+d+" missing meta.views."+e+"]")}b.prototype.render=Prototype.emptyFunction;b.prototype.remove=Prototype.emptyFunction;var a=Backbone.Model.extend({idAttribute:"pk_id",url:function(d){d=(d||"").split(".");d[0]=d[0]||"index";d[1]=d[1]||"jsonenv";return([CD.Environment.zf_uriprefix,CD.Environment.space?CD.Environment.space.name:"home",this.urlNamespace,this.id||null,d[0]]).compact().join("/")+"."+d[1]},request_options:null,constructor:function(d,f){this.toString=function(){return this.namespace+"."+(this.id||"new")};Backbone.Model.prototype.constructor.apply(this,arguments);d=d||{};f=f||{};this.request_options=this.request_options||{};if(typeof this.urlNamespace==="undefined"){throw new Error("Objects that extend "+this.namespace+" MUST define urlNamespace!")}if(f.autoLoad){this.fetch()}_.each(c,function(g,h){this.bind(h,function(){PageBus.publish(this+"."+g,this,null)})},this);var e=false;this.loaded=function(g){if(_.isUndefined(g)){return e}else{e=!!g;if(e){PageBus.publish(this+".loaded",this,null)}return this}};this.loaded(f.loaded)},meta:function(){var d={icon:"icon_file",label:"[ untitled ]",views:{},actions:{},edit_actions:[],shortcut_actions:[]};return d},mkview:function(g,e){e=e||{};e.model=this;try{var d=new (this.meta().views[g])(e);if(!e.skip_render){d.render()}return d}catch(f){console.warn("Failed to render view",this.toString(),g,f);return new b(this,g)}},viewed:function(e){var d=this.url("viewed");e=_.extend({},{context:"web"},e);CD.Ajax.Request(d,{method:"post",parameters:e,onSuccess:function(){},onFailure:function(){}})}});a.url=function(e,d){e=isNaN(e)?null:e;d=_.isString(d)?d:null;return["",CD.Environment.space.name,this.prototype.urlNamespace,[e,d],""].flatten().compact().join("/")};ns("CD.BaseModel",a)}());(function(){var a=0;var c={add:"changed",remove:"changed",reset:"changed",destroy:"deleted"};var b=Backbone.Collection.extend({url:function(){return["",CD.Environment.space.name,this.urlNamespace,""].compact().join("/")},request_options:null,constructor:function(e,d){this.toString=function(){return this.namespace+"."+this.cid};Backbone.Collection.prototype.constructor.apply(this,arguments);e=e||[];d=d||{};this.cid=_.uniqueId("c");this.request_options=this.request_options||{};if(typeof this.urlNamespace==="undefined"){throw new Error("Collections that extend "+this.namespace+" MUST define urlNamespace!")}if(d.autoLoad){this.fetch()}this.bind("all",function(f){if(!_.isUndefined(c[f])){PageBus.publish(this+"."+c[f],this,null)}});if(e.length>0){PageBus.publish(this+".loaded",this,null)}this.options=d;this.initialize.apply(this,arguments)},clear:function(){this.each(this.remove.bind(this))},_prepareModel:function(e,d){return Backbone.Collection.prototype._prepareModel.apply(this,arguments).loaded(true)}});ns("CD.BaseCollection",b)}());(function(){var a=function(c,b){this.data=_.extend(this.data,c||{});this.options=_.extend(this.options,b||{});this.initialize(c)};_.extend(a.prototype,{options:{},data:{},initialize:function(b){}});_.extend(a.prototype,CD.PageBus);a.extend=clsextend;ns("CD.BaseController",a)}());(function(){compiled={};var url=function(){return CD.Environment.zf_uriprefix+"/home/jstemplate.json"};var compile=function(str){var ret=null;if(_.isFunction(str)){ret=str}else{if(_.isString(str)){try{if(str.match(/^\s*function\s*\(/)){ret=Handlebars.template(eval("("+str+")"))}else{ret=Handlebars.compile(str)}}catch(err){console.warn("Failed to compile template:",_.isString(str)?str.substr(0,25)+" ... ("+(str.length-25)+")":str)}}}if(_.isFunction(ret)&&!ret._decorated&&0){var decorated=function(){var args=_.toArray(arguments);args[0]=args[0]||{};var spaceid=args[0].fk_spaceid||window.spid||0;if(CD.permissions){_.extend(args[0],{canAdd:CD.permissions.canAdd(spaceid),canRead:CD.permissions.canRead(spaceid),canEdit:CD.permissions.canEdit(spaceid),canDelete:CD.permissions.canDelete(spaceid),isAdmin:CD.permissions.isAdmin(spaceid),canListManage:CD.permissions.canListManage(spaceid)})}ret.apply(this,args)};decorated._decorated=true;return decorated}return ret};var Loader={get:function(name,options){options=options||{};options.success=options.success||Prototype.emptyFunction;options.success_context=options.success_context||window;options.error=options.error||Prototype.emptyFunction;options.error_context=options.error_context||window;if(_.isUndefined(compiled[name])){new Ajax.Request(url(),{method:"post",parameters:{name:name},onSuccess:function(response){compiled[name]=compile(response.responseText.evalJSON().template);options.success.call(options.success_context,compiled[name])},onFailure:function(){compiled[name]=null;options.error.call(options.error_context)}})}else{options.success.call(options.success_context,compiled[name])}},set:function(name,template){compiled[name]=compile(template)}};ns("CD.Template.Loader",Loader)}());(function(){var a="CD.Template.View";ns(a,CD.BaseView.extend({rendered:false,get_template:function(){var d,b=(this.model)?this.model.attributes:{},c={view:this,model:b};d=CD.Handlebars.getTemplate(this.template);return d(c)},render:function(){try{if(this.template){this.el.insert(this.get_template())}}catch(b){console.warn("template",this.id,this.el,this.get_template());console.warn("You probably forgot to add your widget's jstemplate to your xhtml template.")}},update:function(){this.el.update(this.get_template())}}))}());(function(){ns("CD.Report.Model",CD.BaseModel.extend({subjectAttribute:"subject",messageAttribute:"message",urlNamespace:"report",url:function(a){return([CD.Environment.zf_uriprefix,"home","report",this.urlNamespace,a]).compact().join("/")+".json"}}))}());(function(){ns("CD.AuditLog.Model",CD.BaseModel.extend({namespace:"auditlog",urlNamespace:"auditlog",url:function(c,d){var a="";var b=CD.Environment.space?CD.Environment.space.name:"home";if(d!==undefined){a=([CD.Environment.zf_uriprefix,b,this.urlNamespace,this.id||null,c]).compact().join("/")}else{c=(c||"").split(".");c[0]=c[0]||"index";c[1]=c[1]||"jsonenv";a=([CD.Environment.zf_uriprefix,b,this.id||null,this.urlNamespace,c[0]]).compact().join("/")+"."+c[1]}return a}}));CD.AuditLog.Model.find=function(c,a){a=a||{};var b=CD.Store.AuditLog.getInstance();b.getRecord(c,a)}})();(function(){ns("CD.AuditLog.Collection",CD.BaseCollection.extend({urlNamespace:"auditlog",model:CD.AuditLog.Model,refModel:null,url:function(){var a=new CD.AuditLog.Model(this.refModel.attributes);return a.url("find")},comparator:function(a){return 0-a.get("pk_id")},constructor:function(b,a){if(!a.refModel){throw new Error(this.ns()+" requires a refModel to be defined")}this.refModel=a.refModel;CD.BaseCollection.prototype.constructor.apply(this,arguments);this.request_options.data={fk_id:this.refModel.id,fk_spaceid:this.refModel.get("fk_spaceid"),activity_type:this.refModel.activityType,item_type:this.refModel.itemType,page_num:a.pageNum||1}}}))}());(function(){ns("CD.AuditLog.View.Row",CD.BaseView.extend({idPrefix:"auditlog-row-",cls:"auditlog-row",automount:true,template:"auditLogRowTpl",tpl:null,model:null,initialize:function(a){CD.BaseView.prototype.initialize.call(this,a);this.tpl=CD.Handlebars.getTemplate(this.template)},render:function(){var c,b=this;CD.BaseView.prototype.render.call(this);console.log("this.model: ",this.model);c=this.model.toJSON();c.num_events=this.model.get("events").length;c.activity_text=c.activity;if(c.activity==="Changed"&&c.events.length>0){c.activity_text+=" "+c.events.length+" fields"}var a=this.tpl(c);this.el.update(a);return this}}))}());(function(){ns("CD.AuditLog.View.Grid",CD.BaseView.extend({paginator:null,templates:{row:"auditLogRowTpl",grid:"auditLogGridTpl"},gridTpl:null,rowTpl:null,setupTemplates:function(){Handlebars.registerPartial(this.templates.row,CD.Handlebars.getTemplate(this.templates.row));this.gridTpl=CD.Handlebars.getTemplate(this.templates.grid);this.rowTpl=CD.Handlebars.getTemplate(this.templates.row)},initialize:function(a){CD.BaseView.prototype.initialize.call(this,arguments);this.setupTemplates();this.fetch()},fetch:function(){var a=this;this.model.request_options.data.page_num=this.pageNum;this.model.fetch({success:function(d,c){var b=[],e;a.numRecords=c.num_records;a.recordsPerPage=c.page_size;a.pageNum=c.page_num;for(e in c.entries){if(c.entries.hasOwnProperty(e)){b.push(new CD.AuditLog.Model(c.entries[e]))}}a.model.reset(b);a.render()},error:function(c,b){console.log(a.ns()+" model (collection) fetch error callback triggered, arguments: ",arguments)}})},render:function(){var d,g,h,a,c;a={rows:[]};for(d=0;d<this.model.models.length;d++){h=this.model.models[d].toJSON();c=this.model.models[d].get("events");h.num_events=c?c.length:0;h.activity_text=h.activity;if(h.activity==="Changed"&&h.num_events>0){h.activity_text+=" "+h.num_events+" field"+(h.num_events>1?"s":"")}a.rows.push(h)}var b=this.el.select(".grd").first();if(b){a.entriesOnly=true;var e=this.gridTpl(a);b.innerHTML=e}else{var e=this.gridTpl(a);this.el.insert(e)}var f=this;this.el.select(".tab-commands .export-csv").each(function(k){k.observe("click",function(m){m.stop();var o=new CD.AuditLog.Model();var p=["fk_id="+f.options.refModel.get("pk_id"),"fk_spaceid="+f.options.refModel.get("fk_spaceid"),"activity_type="+f.options.refModel.activityType,"item_type="+f.options.refModel.itemType,"r="+Math.random()];var n=o.url("export.csv")+"?"+p.join("&");document.location.href=n})});this.el.select(".audit-log-row .delete").each(function(k){k.observe("click",function(m){var n;m.stop();n=k.up(".audit-log-row");n.addClassName("selected");cdwm.confirm("Are you sure you want to delete the selected audit log entry? This cannot be undone!",function(o){if(o){CD.AuditLog.Model.find(parseInt(n.getAttribute("data-id"),10),{success:function(p){p.destroy({success:function(){n.remove()},error:function(){console.log("delete audit log find() error handler triggered, arguments: ",arguments)}})}})}else{n.removeClassName("selected")}})})});if(!this.paginator){this.paginator=new CD.UI.Helpers.Pagination({el:this.el.select(".pagination").first(),numRecords:this.numRecords,recordsPerPage:this.recordsPerPage,pageNum:this.pageNum});this.paginator.render();this.subscribe(this.paginator+".page",this,this.fetchPage,null)}},fetchPage:function(a,c,b){this.pageNum=c;this.fetch()}}))}());(function(){ns("CD.AuditLog.Widget.Row",CD.Widget.extend({cls:"",automount:true,constructor:function(a){CD.Widget.prototype.constructor.call(this,a);this.view=new CD.AuditLog.View.Row({el:this.el.content,model:a.model});this.view.render()}}))}());(function(){ns("CD.AuditLog.Widget.Grid",CD.Widget.extend({paginationWidget:null,initialize:function(a){CD.Widget.prototype.initialize.call(this,arguments);if(!a.refModel){throw new Error(this.ns()+" must have a refModel defined")}this.collection=new CD.AuditLog.Collection(null,{refModel:a.refModel});this.view=new CD.AuditLog.View.Grid(_.extend({},a,{el:this.el.content,model:this.collection}))}}))}());(function(){var a=CD.BaseModel.extend({urlNamespace:"tasklist",url:function(d,e){if(!this.id&&d!=="spacetasklists"){d="index"}var b="";var c=CD.Environment.space?CD.Environment.space.name:"home";if(e!==undefined){b=(["",c,this.urlNamespace,this.id||null,d]).compact().join("/")}else{d=(d||"").split(".");d[0]=d[0]||"index";d[1]=d[1]||"jsonenv";b=([CD.Environment.zf_uriprefix,c,"project",this.urlNamespace,this.id||null,d[0]]).compact().join("/")+"."+d[1]}return b},defaults:{canAddTask:true},incompleteTasks:null,completedTasks:null,constructor:function(c,d){c=c||{};CD.BaseModel.prototype.constructor.apply(this,arguments);c=c||{};this.options=_.extend({},this.defaults,d);this.incompleteTasks=new CD.Task.Collection();this.completedTasks=new CD.Task.Collection();var f=this.url.bind(this,"tasks");var b={db_guid:c.db_guid?c.db_guid:null,db_recid:c.db_recid?c.db_recid:null};var e=function(g){return Object.isArray(g.collection)?g.collection:$H(g.collection).values()};this.incompleteTasks.url=f;this.incompleteTasks.request_options.read={data:_.extend({},b,{completed:false}),cast_response:e};this.completedTasks.url=f;this.completedTasks.request_options.read={data:_.extend({},b,{completed:true}),cast_response:e}},meta:function(){var c={};if(CD.permissions.canRead(spid)){c.gantt={icon:"icon_gantt",label:"Task List Gantt",title:"View this Task List in Gantt Chart",url:"gantt?tasklist_id="+this.id,titled:true};c.csvexport={icon:"icon_file_csv",title:"Export "+this.get("title")+" Task List",onclick:CD.Tasklist.Actions.csvexport.bind(this,this.id),titled:true}}if((CD.Controller.mytasks&&!CD.Controller.mytasks.isMyTasks)||(CD.Controller.projects&&!CD.Controller.projects.isMyTasks)){if(CD.permissions.canAdd(spid)){c.emailin={icon:"icon_email_in",title:"Email Tasks to this Task List",onclick:CD.Tasklist.Dialogs.emailin.bind(null,this.id),titled:true};c.clone={icon:"icon_clone",label:"Clone Tasklist",onclick:CD.Tasklist.Dialogs.clone.bind(null,this.id)}}if(CD.permissions.canEdit(spid)){c.edit={icon:"icon_edit",label:"Edit Tasklist",onclick:CD.Tasklist.Dialogs.edit.bind(null,this.id)};c.move={icon:"icon_task_move",label:"Move Tasklist",onclick:CD.Tasklist.Dialogs.move.bind(null,this.id)};c.archive={icon:"icon_archive",label:"Archive Tasklist",onclick:CD.Tasklist.Actions.archive.bind(null,this.id,true)},c.unarchive={icon:"icon_archive_action",label:"Un-Archive Tasklist",onclick:CD.Tasklist.Actions.archive.bind(null,this.id,false)}}if(CD.permissions.canDelete(spid)){c["delete"]={icon:"icon_trash",label:"Delete Tasklist",onclick:CD.Tasklist.Dialogs.remove.bind(null,this.id,this.get("fk_milestoneid"))}}}var b={icon:"icon_task",label:this.escape("title"),views:{inline:CD.Tasklist.View.Inline,meta:CD.Tasklist.View.Meta,navitem:CD.Tasklist.View.NavItem},actions:c,shortcut_actions:this.get("archived")?["csvexport"]:["gantt","csvexport"]};if(!this.get("attached_to_db")&&!this.get("archived")){b.shortcut_actions.push("emailin")}if(this.get("is_inbox")||this.get("attached_to_db")){b.edit_actions=[]}else{if(this.get("fk_milestoneid")!==null&&!this.get("archived")){b.edit_actions=["edit","clone","move","delete"]}else{if(this.get("archived")){b.edit_actions=["delete","unarchive"]}else{b.edit_actions=["edit","clone","move","delete","archive"]}}}return b},import_template_tasks_handle_dependencies:function(e){var g=this;var c=true;for(i=0;i<e.Tasks.models.length;i++){var b=e.Tasks.models[i];var d=g.tasktplmap[b.get("pk_id")];if(b.get("parent_id")>0){var f=g.tasktplmap[b.get("parent_id")];if(f.get("pk_id")!=undefined&&d.get("parent_id")==undefined){d.set({parent_id:f.get("pk_id")},{silent:true});d.save(null,{success:function(m,h){g.grid.incompleteTaskRows.collection.add(m);var k=g.get("num_records")+1;var n=g.get("num_completed");var o=(k>0)?Math.floor(n/k*100):0;g.set({num_records:k,num_completed:n,progress:o});g.import_template_tasks_handle_dependencies(e)}})}}if(d.get("pk_id")==undefined){c=false}}if(c){g.grid.incompleteTaskRows.view.publish(g.grid.incompleteTaskRows.view+".sortby.priority",{sortBy:"priority",sortDir:ObjectSort.ASC})}},tasktplmap:[],import_template_tasks:function(d,b){var c=this;CD.TasklistTemplate.Model.find(d,{success:function(e){e.Tasks.fetch({reqsuccess:function(){for(i=0;i<e.Tasks.models.length;i++){var g=e.Tasks.models[i];var k=new CD.Task.Model();c.tasktplmap[g.get("pk_id")]=k}for(i=0;i<e.Tasks.models.length;i++){var g=e.Tasks.models[i];var k=c.tasktplmap[g.get("pk_id")];var n="";var f="";if(g.get("relative_startdate")||g.get("duration")){var m=new Date(b);m.setDate(m.getDate()+g.get("relative_startdate"));var h=new Date(m.toDateString());h.setDate(h.getDate()+g.get("duration"));if(g.get("relative_startdate")){n=m.getFullYear()+"-"+(m.getMonth()+1)+"-"+m.getDate()}if(g.get("duration")){f=h.getFullYear()+"-"+(h.getMonth()+1)+"-"+h.getDate()}}k.set({budgeted_time:g.get("budgeted_time"),title:g.get("title"),taskdescription:g.get("description"),startdate:n,duedate:f,priority:g.get("priority"),fk_tasklistid:c.get("pk_id"),fk_spaceid:c.get("fk_spaceid")});c.grid.incompleteTaskRows.processing(true);if(!(g.get("parent_id")>0)||c.tasktplmap[g.get("parent_id")].get("pk_id")!=undefined){k.save(null,{success:function(q,o){c.grid.incompleteTaskRows.collection.add(q);var p=c.get("num_records")+1;var r=c.get("num_completed");var s=(p>0)?Math.floor(r/p*100):0;c.set({num_records:p,num_completed:r,progress:s});c.import_template_tasks_handle_dependencies(e)}})}}}})}})}});a.find=function(d,b){b=b||{};var c=CD.Store.Tasklist.getInstance();c.getRecord(parseInt(d,10),b)};ns("CD.Tasklist.Model",a)}());(function(){var b=["create","update","delete"];var a=CD.Tasklist.Model.extend({filterValue:null,constructor:function(c,d){CD.Tasklist.Model.prototype.constructor.call(this,{},d);this.toString=function(){return CD.Tasklist.Model.ns()+"."+this.id};this.set({title:d.title||"Filtered tasks"});this.id=_.isUndefined(d.id)?"container":d.id;this.options.href_base="tasks";var e=this;this.incompleteTasks.request_options.read={url:d.request_url||"",data:_.extend({},d.request_params,{completed:false}),cast_response:function(f){e.set({num_records:f.meta.num_records,num_completed:f.meta.num_completed});return Object.isArray(f.collection)?f.collection:$H(f.collection).values()}};this.completedTasks.request_options.read={url:d.request_url||"",data:_.extend({},d.request_params,{completed:true}),cast_response:function(f){e.set({num_records:f.meta.num_records,num_completed:f.meta.num_completed});return Object.isArray(f.collection)?f.collection:$H(f.collection).values()}}},set_request_params:function(c){if(c.user){this.filterValue=c.user}else{if(c.tag){this.filterValue=c.tag}}this.incompleteTasks.request_options.read.data=_.extend({},c,{completed:false})||{};this.completedTasks.request_options.read.data=_.extend({},c,{completed:true})||{};return this},set_request_url:function(c){this.incompleteTasks.request_options.read.url=c;this.completedTasks.request_options.read.url=c},meta:function(){var c=CD.Tasklist.Model.prototype.meta.call(this);_.extend(c.views,this.options.views||{});c.edit_actions=[];c.shortcut_actions=[];return c},sync:function(e,d,c){if(b.indexOf(e)!==-1){throw new Error('Operation "'+e+'" is not applicable to Container, probably Model expected')}return Backbone.sync.call(this,e,this,c)}});ns("CD.Tasklist.Container",a)}());(function(){ns("CD.Tasklist.Collection",CD.BaseCollection.extend({urlNamespace:"tasklist",model:CD.Tasklist.Model,url:function(a){a=this.options.spacename||(CD.Environment.space?CD.Environment.space.name:"home");a="home";return([CD.Environment.zf_uriprefix,a,"project",this.urlNamespace,"list.jsonenv"]).compact().join("/")},comparator:function(a){return(a.get("is_inbox")?0:1)+a.get("title").strip().toLowerCase()}}))}());(function(){ns("CD.Tasklist.Actions",{create:function(c){var b=null;if(c.elements.milestone_id){b=parseInt(c.elements.milestone_id.value,10);b=(b===0)?null:b}var e={fk_spaceid:CD.Environment.space.id,title:c.title.value,"private":c.is_private?c.is_private.checked:false,fk_milestoneid:b};var f=0;var a;if(c.tasklist_template_id){f=c.tasklist_template_id.value||0;a=c.start_date.value}var d=new CD.Tasklist.Model(e);if(c.title.value.trim()===""){c.title.setStyle({borderColor:"red"})}else{d.save(e,{success:function(h,k,g){if(f>0){h.import_template_tasks(f,a)}cdwm.closeWindow(c);CD.Project.Router.navigate("tasklist-"+h.get("pk_id"),true)},error:function(){console.log("tasklist create error handler: ",arguments);cdwm.closeWindow(c);cdwm.alert("Failed to create tasklist. Please try again.")}})}},edit:function(b){var d=CD.Controller.projects.getSelectedTasklist();var a=null;var e=d.get("fk_milestoneid");if(b.elements.milestone_id){a=parseInt(b.elements.milestone_id.value,10);a=(a===0)?null:a}var c={fk_spaceid:CD.Environment.space.id,title:b.elements.title.value,"private":typeof b.elements["private"]!=="undefined"?!!b.elements["private"].checked:false,fk_milestoneid:a};if($("new_folder_name").value.trim()===""){$("new_folder_name").setStyle({"border-color":"red"});$("new_folder_name").focus()}else{d.save(c,{success:function(g,h,f){cdwm.closeWindow(b)},error:function(){cdwm.closeWindow(b);cdwm.alert("Failed to create tasklist. Please try again.")}})}if(e){CD.Milestone.Model.find(e,{success:function(f){f.tasklists.remove(d.get("pk_id"))},error:function(){console.log("Could not locate parent milestone when editing tasklist.")}})}},move:function(a){var b=a.serialize({hash:true});if(!b.new_space_id){return false}CD.Tasklist.Model.find(b.tasklist_id,{success:function(c){CD.Ajax.Request(c.url("move"),{method:"post",parameters:b,onSuccess:function(e){var d=c.get("fk_milestoneid");c.set({fk_milestoneid:null,fk_spaceid:b.new_space_id},{format:"json"});cdwm.closeWindow(a);if(d){CD.Project.Router.navigate("#milestone-"+d,true)}else{CD.Project.Router.navigate("",true)}},onFailure:function(){console.log("failed to move");cdwm.closeWindow(a);cdwm.alert("Failed to move tasklist. Please try again.")}},false,false)},error:function(){console.log("Tasklist find error",arguments)}})},clone:function(a){var b=a.serialize({hash:true});if(!b.new_title){return false}CD.Tasklist.Model.find(b.tasklist_id,{success:function(c){CD.Ajax.Request(c.url("clone"),{method:"post",parameters:b,onSuccess:function(d){CD.Project.Router.navigate("#tasklist-"+d.response.pk_id,true);cdwm.closeWindow(a)},onFailure:function(){cdwm.closeWindow(a);cdwm.alert("Failed to clone tasklist. Please try again.")}})},error:function(){console.log("Tasklist find error",arguments)}})},remove:function(a){CD.Tasklist.Model.find(a,{success:function(c){var b=c.get("fk_milestoneid");c.destroy({success:function(e,d){if(b){CD.Project.Router.navigate("milestone-"+b,true)}else{CD.Project.Router.navigate("",true)}},error:function(e,d){console.log("error deleting tasklist id:"+e.id)}})},error:function(){console.log("Tasklist find error",arguments)}})},archive:function(a,b){CD.Tasklist.Model.find(a,{success:function(d){var c=d.get("fk_milestoneid");if(c){console.log("Not archiving tasklist "+a+" with associated milestone "+c+".")}else{d.save({archived:b},{success:function(e){CD.Controller.projects.getTasklistCollection().remove(e);CD.Project.Router.navigate("",true)},error:function(){console.log("Tasklist archive error",arguments)}})}},error:function(){console.log("Tasklist find error",arguments)}})},csvexport:function(a){CD.Tasklist.Model.find(a,{success:function(b){window.location=b.url("csvexport.html")}})}})}());(function(){ns("CD.Tasklist.Dialogs",{remove:function(a){if(!CD.permissions.canDelete(spid)){cdwm.alert("User doesn't have permissions to delete the tasklist");return false}CD.Tasklist.Model.find(a,{success:function(b){new CD.Ajax.Request(b.url("affectedwfs"),{method:"post",onSuccess:function(c){if(c.response.count>0){CD.Tasklist.Dialogs.confirmAffectedWorkflows(a,c.response,"delete")}else{cdwm.confirm("Are you sure you want to delete this Task List?",function(d){if(d){CD.Tasklist.Actions.remove(a)}})}}},false)},error:function(){console.log("Tasklist Actions Remove Handler: did not find tasklist "+a,arguments)}})},create:function(d){if(!CD.permissions.canAdd(spid)){cdwm.alert("You do not have permission to create tasklists.");return false}var f=CD.Controller.projects.getSelectedMilestone();var a="";if(f instanceof CD.Milestone.Model){a+="&fk_milestoneid="+f.get("pk_id")}var c=window.location.pathname;if(c.indexOf("/",1)>0){c=c.substr(0,(c.indexOf("/",1)));c+="/tasklist/create/?"+a}else{c+="../tasklist/create/?"+a}var e={title:"Create New Task List",file:c,type:"dynamic",inline:1,width:490,height:257};var b=overlay.show(e,true);return b},edit:function(a){if(!CD.permissions.canEdit(spid)){cdwm.alert("You do not have permission to edit tasklists.");return false}CD.Tasklist.Model.find(a,{success:function(c){var d={title:"Edit Tasklist: "+c.get("title"),file:c.url("edit",false),type:"dynamic",inline:1,width:490,height:257};var b=overlay.show(d,true);return b},error:function(){console.log("Tasklist Dialog Edit Handler: did not find tasklist "+a,arguments)}})},move:function(a){if(!CD.permissions.canEdit(spid)){cdwm.alert("You do not have permission to move tasklists.");return false}CD.Tasklist.Model.find(a,{success:function(b){new CD.Ajax.Request(b.url("affectedwfs"),{method:"post",onSuccess:function(c){if(c.response.count>0){CD.Tasklist.Dialogs.confirmAffectedWorkflows(a,c.response,"move")}else{CD.Tasklist.Dialogs.move_step2(a)}}},false)},error:function(){console.log("Tasklist Actions Move Handler: did not find tasklist "+_id,arguments)}})},move_step2:function(a){cdwm.closeWindow(this);if(!CD.permissions.canEdit(spid)){cdwm.alert("You do not have permission to move tasklists.");return false}CD.Tasklist.Model.find(a,{success:function(b){var c={title:"Moving Tasklist: "+b.get("title"),file:b.url("move",false),type:"dynamic",inline:1,width:450,height:100};overlay.show(c,true)}})},clone:function(a){if(!CD.permissions.canAdd(spid)){cdwm.alert("You do not have permission to clone the tasklists.");return false}CD.Tasklist.Model.find(a,{success:function(b){var c={title:"Cloning Tasklist: "+b.get("title"),file:b.url("clone",false),type:"dynamic",inline:1,width:450,height:100};overlay.show(c,true)}})},emailin:function(a){if(!CD.permissions.canAdd(spid)){cdwm.alert("You do not have permission to email in to tasklists.");return false}CD.Tasklist.Model.find(a,{success:function(b){var c={title:"Email Addresses for: "+b.get("title"),file:b.url("emailin",false),type:"dynamic",inline:1,width:600,height:300};overlay.show(c,true)}})},confirmAffectedWorkflows:function(b,e,d){var c='<table><tr><td style="padding-top: 15px; vertical-align: top; text-align: center; width: 55px;"><span class="mceAlertIcon"></span></td><td style="padding-top: 15px; vertical-align: top;"><b>You are about to '+d+" a task list that is a condition of the following workflow rules:</b><ul>";e.workflows.each(function(g){c+='<li><a href="'+g.url+'" target="_blank">'+g.name+"</a></li>"});c+="</ul><p>If you "+d+" this task list, these workflow rules will be deactivated until you review and reactivate them.</p><p>Are you sure you want to "+d+' this task list?</p></td></tr></table><div style="text-align: center"><input class="rbutton" type="button" id="confirmAffectedWorkflows" value="Yes, '+d.capitalize()+' Task List Anyways" ';if(d=="delete"){c+=' onclick="CD.Tasklist.Actions.remove('+b+'); cdwm.closeWindow(this);" />'}else{c+=' onclick="CD.Tasklist.Dialogs.move_step2('+b+');" />'}c+='<span class="padding_left_10 ahref cancel" onclick="cdwm.closeWindow(this);">Cancel</span></div>';var a=new Element("div");a.innerHTML=c;var f=cdwm.open(false,{element:a,inline:1,height:177+(e.count*14)})}})}());(function(){ns("CD.Task.Model",CD.BaseModel.extend({urlNamespace:"task",activityType:CD.ACTIVITY_TYPE_TASK,itemType:CD.ITEM_TYPE_TASK,url:function(c,d){if(!this.id&&c!=="taskparents"){c="index"}var a="";var b=CD.Environment.space?CD.Environment.space.name:"home";if(d!==undefined){a=(["",b,this.urlNamespace,this.id||null,c]).compact().join("/")}else{c=(c||"").split(".");c[0]=c[0]||"index";c[1]=c[1]||"jsonenv";a=([CD.Environment.zf_uriprefix,b,"project",this.urlNamespace,this.id||null,c[0]]).compact().join("/")+"."+c[1]}return a},getAssignees:function(){return[]},getCCs:function(){return[]},meta:function(){return{icon:"icon_task",label:this.escape("title"),views:{inline:CD.Task.View.Inline,meta:CD.Task.View.Meta},actions:{},edit_actions:[],shortcut_actions:[]}},isPersonal:function(){return !this.get("fk_spaceid")},isAssignedTo:function(a){var b=this.get("assignedto");if(Object.isArray(b)){for(i=0;i<b.length;i++){if(b[i].id===a){return true}}}return false},toggleCompleted:function(d,c,b){var a=this;b.success=b.success||function(){};b.error=b.error||function(){};CD.Ajax.Request(a.url("toggle"),{method:"post",parameters:{completed:d},onSuccess:function(e){a.set({completed:e.response.completed,completedon:e.response.completedon,completed_by:e.response.completed_by});var f=a.get("fk_tasklistid");CD.Tasklist.Model.find(f,{success:function(m){var k=m.get("num_completed");var g=m.get("num_records");a.set({completed:e.response.completed});if(a.get("completed")){if((k+1)<=g){k++}}else{if((k-1)>=0){k--}}var h=(g>0)?Math.floor(k/g*100):0;m.set({num_completed:k,progress:h})},error:function(){console.log("Tasklist Grid onToggleComplete Handler: did not find tasklist "+f,arguments)}});if(typeof b.success==="function"){b.success(d,c,a,b)}},onFailure:function(h,f,g){var e=new CD.Report.Model();e.save({subject:"ProjectV3 Failure",message:"Failure in Task Completion via toggle\nURL: "+a.url()+"\nCD.Task.Model.toggle Completed:"+d+" task_id:"+a.id})}})}}));CD.Task.Model.find=function(c,a){a=a||{};var b=CD.Store.Task.getInstance();b.getRecord(c,a)}}());(function(){ns("CD.Task.Collection",CD.BaseCollection.extend({urlNamespace:"task",model:CD.Task.Model,comparator:function(a){return a.get("_order")}}))}());(function(){ns("CD.Task.Actions",{move:function(a){var c=a.serialize({hash:true});var b=this;CD.Tasklist.Model.find(c.new_tasklist_id,{success:function(d){CD.Task.Model.find(c.task_id,{success:function(e){if(parseInt(e.get("parent_id"))>0||e.get("child_dependencies").length>0){b.movetasksFun(c,d,a)}else{b.movetasksFun(c,d,a)}},error:function(){console.log("Cannot find taskmodel for checking dependency breakage when in CD.Task.Actions.move")}})},error:function(){console.log("Tasklist find error",arguments)}})},movetasksFun:function(c,b,a){CD.Ajax.Request(b.url("movetasks"),{method:"post",parameters:{"taskIds[]":[c.task_id],new_space_id:c.new_space_id,spid:c.new_space_id},onSuccess:function(d){cdwm.closeWindow(a);if(d){CD.Project.Router.navigate("#tasklist-"+c.tasklist_id,true)}},onFailure:function(){cdwm.closeWindow(a);cdwm.alert("Failed to move tasklist. Please try again.")}},false,false)}})}());(function(){ns("CD.Task.Dialogs",{move:function(b){if(!CD.permissions.canEdit(spid)){cdwm.alert("You do not have permission to move task.");return false}var c=function(f,d){var e=new Element("option",{value:f});e.update(d);return e};var a=function(){var h=$(this.element.get());var k=h.select("form").first();var g=k.select("select");var m=g[0];var d=g[1];var f=k.select(".rbutton").first();var e=function(n){n=!!n;m.disabled=n;d.disabled=n;f.disabled=n};$(k.new_space_id).on("change",function(){var o=parseInt(this.value);if(isNaN(o)){return}var n=new CD.Tasklist.Collection(null,{fk_spaceid:o});n.request_options.data={spid:o,show_db_lists:false};e(true);d.update(c("","Loading&hellip;"));k.select(".task-dlg-move-tasklist").first().show();n.fetch({cast_response:function(p){return Object.isArray(p.collection)?p.collection:$H(p.collection).values()},reqsuccess:function(q){var p=new CD.Milestone.Collection(null,{fk_spaceid:o});p.request_options.data={spid:o};p.fetch({cast_response:function(r){return Object.isArray(r.collection)?r.collection:$H(r.collection).values()},reqsuccess:function(r){e(false);d.update();q.each(function(s){d.insert(c(s.id,s.get("title")))});r.each(function(t){var s=new Element("optgroup",{label:t.get("title")});t.tasklists.each(function(u){s.insert(c(u.id,u.get("title")))});d.insert(s)})},error:function(){e(false);d.update();q.each(function(r){d.insert(c(r.id,r.get("title")))});alert("Failed to load tasklists under milestones")}});var p=new CD.Milestone.Collection(null,{fk_spaceid:o});p.request_options.data={spid:o};p.fetch({cast_response:function(r){return Object.isArray(r.collection)?r.collection:$H(r.collection).values()},reqsuccess:function(r){r.each(function(t){var s=new Element("optgroup",{label:t.get("title")});t.tasklists.each(function(u){s.insert(c(u.id,u.get("title")))});d.insert(s)})}})},error:function(){e(false);alert("Failed to load tasklists")}})});k.select(".attention-cancel").first().on("click",function(n){n.preventDefault();cdwm.close()})};CD.Task.Model.find(b,{success:function(d){var e={title:"Moving Task: "+d.get("title"),file:d.url("dlgmove.html"),type:"dynamic",inline:1,width:450,height:100,afterLoad:a};overlay.show(e,true)}})}})}());(function(){var a=CD.BaseModel.extend({urlNamespace:"tasklisttpl",url:function(c,b){c=(c||"").split(".");c[0]=c[0]||"index";c[1]=c[1]||"jsonenv";return([CD.Environment.zf_uriprefix,"home","project",this.urlNamespace,this.id||null,c[0]]).compact().join("/")+"."+c[1]},constructor:function(c,d){c=c||{};CD.BaseModel.prototype.constructor.apply(this,arguments);c=c||{};this.options=_.extend({},this.defaults,d);this.Tasks=new CD.TaskTemplate.Collection();var f=this.url.bind(this,"tasks");var b={fk_tasklisttemplateid:this.id};var e=function(g){return Object.isArray(g.collection)?g.collection:$H(g.collection).values()};this.Tasks.url=f;this.Tasks.request_options.read={data:b,cast_response:e}}});a.find=function(e,b){b=b||{};var c=CD.Store.TasklistTemplate.getInstance();var d=c.getRecord(parseInt(e,10),b)};ns("CD.TasklistTemplate.Model",a)}());(function(){ns("CD.TasklistTemplate.Actions",{edit:function(b){var c=b.tasklisttpl_id.value;var a=function(d){var e={fk_companyid:CD.Environment.company.id,title:b.title.value,description:b.description.value};d.save(e,{success:function(g,h,f){cdwm.closeWindow(b);window.location="/spaces/company_admin?tab=tasklisttemplates"},error:function(){console.log("tasklist template create error handler: ",arguments);cdwm.closeWindow(b);cdwm.alert("Failed to create tasklist template. Please try again.")}})};if(c){CD.TasklistTemplate.Model.find(c,{success:a})}else{a(new CD.TasklistTemplate.Model())}},remove:function(a){CD.TasklistTemplate.Model.find(a,{success:function(b){b.destroy({success:function(d,c){window.location="/spaces/company_admin?tab=tasklisttemplates"},error:function(d,c){console.log("error deleting tasklist template id:"+d.id)}})},error:function(){console.log("Tasklist Template find error",arguments)}})}})}());(function(){var a={_edit:function(b){var c={title:b?"Edit List Template":"New Task List Template",file:(b||CD.TasklistTemplate.Model.prototype).url("dlgedit.html"),type:"dynamic",inline:1,width:450,height:270};return overlay.show(c,true)},create:function(){a._edit()},edit:function(b){CD.TasklistTemplate.Model.find(b,{success:function(c){a._edit(c)}})},remove:function(b){CD.TasklistTemplate.Model.find(b,{success:function(c){cdwm.confirm("Are you sure you want to delete this Tasklist Template?",function(d){if(d){CD.TasklistTemplate.Actions.remove(b)}})},error:function(){console.log("Tasklist Template Actions Remove Handler: did not find tasklist template "+b,arguments)}})}};ns("CD.TasklistTemplate.Dialogs",a)}());(function(){var a=CD.BaseModel.extend({urlNamespace:"tasktpl",url:function(b){b=(b||"").split(".");b[0]=b[0]||(this.id?null:"index");b[1]=b[1]||"jsonenv";return([CD.Environment.zf_uriprefix,"home","project",this.urlNamespace,this.id||null,b[0]]).compact().join("/")+"."+b[1]}});a.find=function(d,b){b=b||{};var c=CD.Store.TaskTemplate.getInstance();c.getRecord(parseInt(d,10),b)};ns("CD.TaskTemplate.Model",a)}());(function(){var a=CD.BaseCollection.extend({urlNamespace:"tasktpl",model:CD.TaskTemplate.Model,url:function(b){b=(b||"").split(".");b[0]=b[0]||"all";b[1]=b[1]||"jsonenv";return([CD.Environment.zf_uriprefix,CD.Environment.space?CD.Environment.space.name:"home","project",this.urlNamespace,b[0]]).compact().join("/")+"."+b[1]},comparator:function(b){return b.get("relative_startdate")}});ns("CD.TaskTemplate.Collection",a)}());(function(){ns("CD.Milestone.Model",CD.BaseModel.extend({urlNamespace:"milestone",activityType:CD.ACTIVITY_TYPE_MILESTONE,itemType:CD.ITEM_TYPE_MILESTONE,request_options:{cast_response:function(a){return _.isUndefined(a.model)?a:a.model}},url:function(c,d){if(!this.id&&c!=="milestoneparents"){c="index"}var a="";var b=CD.Environment.space?CD.Environment.space.name:"home";if(d!==undefined){a=(["",b,this.urlNamespace,this.id||null,c]).compact().join("/")}else{c=(c||"").split(".");c[0]=c[0]||"index";c[1]=c[1]||"jsonenv";a=([CD.Environment.zf_uriprefix,b,"project",this.urlNamespace,this.id||null,c[0]]).compact().join("/")+"."+c[1]}return a},tasklists:null,constructor:function(a,b){this.tasklists=new CD.Tasklist.Collection();if(a){if(typeof a.tasklists!=="undefined"){this.tasklists.reset(Object.isArray(a.tasklists)?a.tasklists:$H(a.tasklists).values())}delete a.tasklists}CD.BaseModel.prototype.constructor.apply(this,arguments);PageBus.subscribe(this.tasklists+".changed",this,this.updateData,null)},calculateProgress:function(){var a,c=0,b=0,d=0;if(this.tasklists.models.length>0){for(a=0;a<this.tasklists.models.length;a++){c=c+this.tasklists.models[a].get("num_records");b=b+this.tasklists.models[a].get("num_completed")}d=(c>0)?((Math.floor(b*100/c)>100)?100:Math.floor(b*100/c)):0}else{if(this.get("completed")){d=100}}return d},updateData:function(){this.fetch()},meta:function(){var b={};if(CD.permissions.canRead(spid)){b.gantt={icon:"icon_gantt",label:"Milestone Gantt",title:"View this Milestone in Gantt Chart",url:"gantt?milestone_id="+this.id,titled:true};b.csvexport={icon:"icon_file_csv",title:"Export "+this.get("title")+" Milestone",label:"Export Milestone to CSV",onclick:CD.Milestone.Actions.csvexport.bind(null,this.id)}}if(CD.permissions.canAdd(spid)){b.clone={icon:"icon_clone",label:"Clone Milestone",onclick:CD.Milestone.Dialogs.clone.bind(null,this.id)}}if(CD.permissions.canEdit(spid)){b.edit={icon:"icon_edit",label:"Edit Milestone",href:"#milestoneedit-"+this.id};b.archive={icon:"icon_archive",label:"Archive Milestone",onclick:CD.Milestone.Dialogs.archive.bind(this,this.id,true)};b.unarchive={icon:"icon_archive_action",label:"Un-Archive Milestone",onclick:CD.Milestone.Dialogs.archive.bind(this,this.id,false)};b.move={icon:"icon_task_move",label:"Move Milestone",onclick:CD.Milestone.Dialogs.move.bind(null,this.id)}}if(CD.permissions.canDelete(spid)){b["delete"]={icon:"icon_trash",label:"Delete Milestone",onclick:CD.Milestone.Dialogs.remove.bind(null,this.id)}}var a={icon:this.get("overdue")?"icon_milestone_overdue":"icon_milestone",label:this.escape("title"),views:{inline:CD.Milestone.View.Inline,meta:CD.Milestone.View.Meta},actions:b,edit_actions:[],shortcut_actions:this.get("archived")?["csvexport"]:["gantt","csvexport"]};if(this.get("archived")){a.edit_actions=["delete","unarchive"]}else{a.edit_actions=["edit","clone","move","delete","archive"]}return a}}));CD.Milestone.Model.find=function(c,a){a=a||{};var b=CD.Store.Milestone.getInstance();b.getRecord(parseInt(c,10),a)}}());(function(){ns("CD.Milestone.Collection",CD.BaseCollection.extend({urlNamespace:"milestone",model:CD.Milestone.Model,url:function(a){a="home";return([CD.Environment.zf_uriprefix,a,"project",this.urlNamespace,"list.jsonenv"]).compact().join("/")},comparator:function(a){return(a.get("completed")?1:0)+CD.UI.Helpers.Dates.make(a.get("duedate"),"Ynd")+a.get("title").strip().toLowerCase()}}))}());(function(){ns("CD.Milestone.Actions",{csvexport:function(a){CD.Milestone.Model.find(a,{success:function(b){CD.Ajax.Request(b.url("csvexport"),{method:"post",onSuccess:function(c){overlay.hide();cdwm.alert("An email will be sent when the export process is complete. It may take up to 30 minutes to process.")},onFailure:function(){overlay.hide();cdwm.alert("Could not export milestone. Please try again.")}})}})},remove:function(a){var b;if(!CD.permissions.canDelete(spid)){throw new Exception("User doesn't have permissions to delete the milestone")}CD.Milestone.Model.find(a,{success:function(c){c.tasklists.each(function(d){d.destroy({silent:true})});CD.Controller.projects.getMilestoneCollection().remove(c.id);c.destroy();CD.Project.Router.navigate("",true)},error:function(){console.log("Milestone Detail Trash Icon Click Handler: did not find milestone "+a,arguments);cdwm.alert("Error saving changes to Milestone. Resetting")}})},archive:function(b,a){CD.Milestone.Model.find(b,{success:function(c){c.save({archived:a},{success:function(d){CD.Controller.projects.getMilestoneCollection().remove(d);CapDropdown.hide();if(a){$$(".prj-sbar-arch.bl-dynamic").each(function(e){e.removeClassName("bl-dynamic")})}CD.Project.Router.navigate("",true)},error:function(){console.log("Milestone archive error",arguments)}})},error:function(){console.log("Milestone find error",arguments)}})},move:function(a){var b=a.serialize({hash:true});CD.Milestone.Model.find(b.milestone_id,{success:function(c){b=_.extend({},b,{doaction:"move",format:"jsonenv"});CD.Ajax.Request(c.url("move",false),{method:"post",parameters:b,onSuccess:function(d){CD.Controller.projects.getMilestoneCollection().remove(c);overlay.hide();CD.Project.Router.navigate("",true)},onFailure:function(){overlay.hide();cdwm.alert("Could not move milestone.");CD.Project.Router.navigate("",true)}})},error:function(){throw new Error("Milestone not found.")}})},clone:function(a){var b=a.serialize({hash:true});CD.Milestone.Model.find(b.milestone_id,{success:function(f){var c,e=f.tasklists.models;var d="";if(b.task_dependencies){for(c=0;c<e.length;c++){if(b["task_list_"+e[c].id]){(d.length)?d+=",":"";d+='{"pk_id": "'+e[c].id+'", "title": "'+b["task_list_"+e[c].id]+'"}'}}}b=_.extend({},b,{_method:"get",doaction:"cloneMilestone",format:"jsonenv",tasklists:"["+d+"]"});CD.Ajax.Request(f.url("clone",false),{method:"post",parameters:b,onSuccess:function(g){overlay.hide();var h=new CD.Milestone.Model(g.response);CD.Controller.projects.getMilestoneCollection().add(h);CD.Project.Router.navigate("#milestone-"+g.response.pk_id,true)},onFailure:function(){overlay.hide();cdwm.alert("Failed to clone milestone. Please try again.")}})},error:function(){throw new Error("No Milestone instance")}})}})}());(function(){ns("CD.Milestone.Dialogs",{remove:function(a){if(!CD.permissions.canDelete(spid)){cdwm.alert("You do not have permission to delete this milestone.");return false}cdwm.confirm("Are you sure you want to delete this milestone?",function(b){if(b){CD.Milestone.Actions.remove(a)}})},move:function(a){if(!CD.permissions.canEdit(spid)){cdwm.alert("You do not have permission to move this milestone.");return false}CD.Milestone.Model.find(a,{success:function(c){var b={title:"Moving Milestone: "+c.get("title"),file:c.url("move",false),type:"dynamic",inline:1,width:450,height:100};overlay.show(b,true)}})},archive:function(b,a){if(!CD.permissions.canEdit(spid)){cdwm.alert("You do not have permission to archive this milestone.");return false}CD.Milestone.Actions.archive(b,a)},clone:function(a){if(!CD.permissions.canEdit(spid)){cdwm.alert("You do not have permission to clone this milestone.");return false}CD.Milestone.Model.find(a,{success:function(c){var b={title:"Cloning Milestone: "+c.get("title"),file:c.url("clone",false),type:"dynamic",inline:1,width:650,height:200};overlay.show(b,true)}})}})}());(function(){var a={};a.showEmailPage=function(h,g,b){var e,d=CD.Environment.space.relative_url+"project/email?type="+b+"&id="+g+"&r="+Math.random(),k=700,f={title:"Email This Page: "+h+" Gantt Chart",file:d,type:"dynamic",inline:1,width:k};var c=cdwm.open(false,f);return c};ns("CD.Project.Model",a)}());(function(){var a=CD.BaseModel.extend({idAttribute:"id",urlNamespace:"user",meta:function(){return{icon:this.get("is_internal")?"icon_user_internal_user":"icon_user_external_user",label:this.escape("fullname"),views:{inline:CD.User.View.Inline}}}});ns("CD.User.Model",a)}());(function(){var a=CD.BaseCollection.extend({model:CD.User.Model,urlNamespace:"user",comparator:function(b){return b.get("fullname").toLowerCase()}});ns("CD.User.Collection",a)}());(function(){var a=CD.BaseView.extend({tagName:"span",watch_model:["is_internal","fullname"],options:{noicon:false,maxlen:100},render:function(){var b;if(!this.model){this.el.update("[no User model]");return this}this.el.update();if(!this.options.noicon){this.el.insert(CD.UI.Helpers.Icons.icon(this.model.get("is_internal")?"icon_user_internal_user":"icon_user_external_user"))}b=this.model.escape("fullname");if(!b||b===""){b=this.model.escape("email")}this.el.insert(b.truncate(this.options.maxlen,"..."));return this}});ns("CD.User.View.Inline",a)}());(function(){var a=CD.BaseModel.extend({idAttribute:"id",urlNamespace:"space",users:null,url:function(b){return([CD.Environment.zf_uriprefix,this.get("name")||"home",this.urlNamespace,this.id||null,this.id?b:"index"]).compact().join("/")+".jsonenv"},initialize:function(){this.users=new CD.User.Collection();this.users.url=this.url("users");this.users.request_options.read={cast_response:function(b){return Object.isArray(b.collection)?b.collection:$H(b.collection).values()}}},meta:function(){return{icon:this.get("private")?"icon_workspace_private":"",label:this.escape("title"),views:{inline:CD.Space.View.Inline}}}});a.SHARE_MODE_DISABLED=0;a.SHARE_MODE_SIMPLE=1;a.SHARE_MODE_ADVANCED=2;ns("CD.Space.Model",a)}());(function(){ns("CD.Space.Actions",{csvexporttasks:function(a){CD.Ajax.Request("/zf-front.php/"+CD.Environment.space.name+"/space/csvexporttasks.jsonenv",{parameters:{archives:a},method:"post",onSuccess:function(b){overlay.hide();cdwm.alert("An email will be sent when the export process is complete. It may take up to 30 minutes to process.")},onFailure:function(){overlay.hide();cdwm.alert("Could not export project. Please try again.")}})}})}());(function(){var a=CD.BaseCollection.extend({model:CD.Space.Model,urlNamespace:"space",comparator:function(b){return b.get("longname")}});ns("CD.Space.Collection",a)}());(function(){var a=CD.BaseModel.extend({urlNamespace:"expilink"});a.find=function(c,b){b=b||{};CD.Store.Expilink.getInstance().getRecord(parseInt(c,10),b)};ns("CD.Expilink.Model",a)}());(function(){var a=CD.BaseCollection.extend({urlNamespace:"expilink",model:CD.Expilink.Model,fetchfor:function(c,d,b){d=d||2;b=b||{};b.url=CD.Expilink.Model.prototype.url("list.json");b.data=_.extend(b.data||{},{itemid:c});this.fetch(b)},request_options:{read:{cast_response:function(b){return Object.isArray(b)?b:$H(b).values()}}}});ns("CD.Expilink.Collection",a)}());(function(){var a={create:function(c){var d=c.serialize({hash:true}),b=new Validation(c,{immediate:false,onSubmit:false});if(!b.validate()){cdwm.resizeByContent();return}(new CD.Expilink.Model).save(d,{success:function(e){cdwm.close();CD.Expilink.Dialogs.link(e.get("url"))},error:function(){console.warn("Failed to create expilink",arguments);cdwm.close();cdwm.alert("Failed to share this page.")}})},email:function(c){var b=new Validation(c,{immediate:false,onSubmit:false});if(!b.validate()){cdwm.resizeByContent();return}new CD.Ajax.Request(CD.Expilink.Model.prototype.url("email.json"),{method:"post",parameters:c.serialize({hash:true}),onSuccess:function(){displaystatus("Link has been successfully emailed.");cdwm.closeWindow(c)},onFailure:function(){console.warn("Failed to email link",arguments);cdwm.closeWindow(c);cdwm.alert("Failed to share this page.")}})}};ns("CD.Expilink.Actions",a)}());(function(){var a={};var d=function(e){CD.UI.Initializer.initall($(e.id));cdwm.resizeByContent()};var c=function(g,k,f,e){e=e||[550];var h={title:k,type:"dynamic",inline:1,width:e[0],height:e[1]||"auto",afterLoad:d};if(_.isString(f)){g=_.isArray(g)?g.join(","):g;h.file=CD.Expilink.Model.prototype.url(f)+"?"+Object.toQueryString({itemid:g})}if(_.isElement(f)){h.element=f}return overlay.show(h,true)};var b={unavail:function(f,g){var e={plan:"Your current Plan does not support sharing files outside a Workspace."+(f?'<p>Please see your <a href="/home/upgrade_account">Upgrade Options</a>.</p>':'<p>Please contact <a href="/home/upgrade_account">your Billing Administrator</a>.</p>'),settings:"This Workspace is currently not configured to share files outside of this Workspace."+(f?'<p>Please enable public sharing in <a href="'+CD.Environment.space.url+'settings&tab=general&section=access-n-security">Access &amp; Security</a> section of your Workspace Settings.</p>':"<p>Please contact one of your Workspace Administrators to enable this feature.</p>"),permissions:"Your permission settings do not support sharing files outside a workspace.<p>Please contact your Workspace Administrator to get the proper permissions.</p>"};var h=Element.make('<div class="exl-dlg-upgrade"><div>'+(e[g]||"This feature is disabled")+"</div></div>");return c(null,"",h,[420,130])},email:function(f){if(CD.Environment.space.share_mode===CD.Space.Model.SHARE_MODE_ADVANCED){return c(f,"Send via Email","dlgemail.html")}else{if(CD.Environment.space.share_mode===CD.Space.Model.SHARE_MODE_SIMPLE){var e=_.isArray(f)?f.join(","):f;new CD.Ajax.Request(CD.Expilink.Model.prototype.url("emailbody.html"),{method:"post",parameters:{itemid:e},onSuccess:function(g){location.href="mailto:?subject=%20&body="+encodeURIComponent(g.responseText)+"%0A%0A"},onFailure:function(){cdwm.alert("Failed to email selected files")}})}else{b.unavail()}}},create:function(e){if(CD.Environment.space.share_mode===CD.Space.Model.SHARE_MODE_ADVANCED){return c(e,"Get Shareable Link","dlgcreate.html")}else{if(CD.Environment.space.share_mode===CD.Space.Model.SHARE_MODE_SIMPLE){var e=_.isArray(e)?e[0]:e;new CD.Ajax.Request(CD.Expilink.Model.prototype.url("simplelink.html"),{method:"post",parameters:{itemid:e},onSuccess:function(f){CD.Expilink.Dialogs.link(f.responseText)},onFailure:function(){cdwm.close();cdwm.alert("Failed to get shareable links")}})}else{b.unavail()}}},link:function(e){var g=Element.make('<div class="exl-dlg-link">This is a public link that you can use to share this file. Please note that anybody with this link will be able to view and download this file.<br/><br/>Copy and paste this link anywhere you\'d like to share this file.<div><input type="text" value="" /></div>'+((CD.Environment.space.share_mode===CD.Space.Model.SHARE_MODE_ADVANCED)?'<div class="tm10">You can always get this link again by going to Manage Links</div>':"")+'<div class="caligned tm10 smaller fauxlink"><span class="underlinelink" onclick="cdwm.close();">Close Window</span></div></div>');var f=g.select("input").first();f.value=e;c(null,"Shareable Link",g,[420,170]);f.focus();f.select()},manage:function(g){if(CD.Environment.space.share_mode===CD.Space.Model.SHARE_MODE_ADVANCED){var e=new CD.Expilink.Collection(),f=new CD.Expilink.View.List({cls:"exl-list exl-list-indialog",links:e});e.fetchfor(g,null,{success:function(){if(e.length){c(g,"Manage Links",f.el,[800])}else{var h=Element.make('<div class="exl-dlg-nolinks">This file does not have any public links. Use options below to share this file outside of your Workspace.<div><input type="button" class="rbutton ctrl-create" value="Get Shareable Link" /><span class="lm20"><input type="button" class="rbutton ctrl-email" value="Send via Email" /></span><a href="#close" class="attention-cancel lm10">Cancel</a></div></div>');h.on("click",".ctrl-create",function(){cdwm.close();CD.Expilink.Dialogs.create(g)});h.on("click",".ctrl-email",function(){cdwm.close();CD.Expilink.Dialogs.email(g)});h.on("click",".attention-cancel",function(){cdwm.close()});c(g,"Manage Links",h,[400,100])}}})}else{b.unavail()}},remove:function(e){if(CD.Environment.space.share_mode===CD.Space.Model.SHARE_MODE_ADVANCED){if(!CD.permissions.canDelete(spid)){cdwm.alert("You don't have permissions to delete this link");return false}CD.Expilink.Model.find(e,{success:function(f){cdwm.confirm("Are you sure you want to delete this link?",function(g){if(g){f.destroy()}})}})}else{b.unavail()}}};ns("CD.Expilink.Dialogs",b)}());(function(){var a="CD.Store";function b(c){this.dataSet={};this.index=[];if(!this.model){throw new Error('Object "'+this.namespace+'" extending CD.Store MUST declare a model!')}PageBus.subscribe(this.model.prototype.namespace+".*.loaded",this,this.onLoad,null);this.initialize(c)}_.extend(b.prototype,{dataSet:null,index:null,model:null,initialize:function(c){},onLoad:function(e,c,f){var d=c.get("pk_id");this.dataSet[d]=c},getRecord:function(d,c){c=c||{};c.success=c.success||Prototype.emptyFunction;c.error=c.error||Prototype.emptyFunction;if(typeof this.dataSet[d]==="undefined"){this.dataSet[d]=new this.model({pk_id:d});this.dataSet[d].fetch(c)}else{c.success.call(window,this.dataSet[d])}}});b.getInstance=function(){if(_.isUndefined(this.__instance)){this.__instance=new this()}return this.__instance};b.extend=clsextend;ns(a,b)}());(function(){ns("CD.Store.Task",CD.Store.extend({model:CD.Task.Model}));CD.Store.Task.getInstance()}());(function(){var a="CD.Store.Tasklist";ns(a,CD.Store.extend({namespace:a,model:CD.Tasklist.Model}));CD.Store.Tasklist.__instance=new CD.Store.Tasklist();CD.Store.Tasklist.getInbox=function(){var b,c=CD.Store.Tasklist.getInstance();for(b in c.dataSet){if(c.dataSet.hasOwnProperty(b)){if(c.dataSet[b].get("is_inbox")){return c.dataSet[b]}}}return null}}());(function(){ns("CD.Store.TaskTemplate",CD.Store.extend({model:CD.TaskTemplate.Model}));CD.Store.TaskTemplate.getInstance()}());(function(){ns("CD.Store.TasklistTemplate",CD.Store.extend({model:CD.TasklistTemplate.Model}));CD.Store.TasklistTemplate.getInstance()}());(function(){var a="CD.Store.Milestone";ns(a,CD.Store.extend({namespace:a,model:CD.Milestone.Model}));CD.Store.Milestone.__instance=new CD.Store.Milestone()}());(function(){ns("CD.Store.User",CD.Store.extend({model:CD.User.Model}));CD.Store.User.__instance=new CD.Store.User()}());(function(){ns("CD.Store.AuditLog",CD.Store.extend({model:CD.AuditLog.Model}));CD.Store.AuditLog.getInstance()}());(function(){ns("CD.Store.Expilink",CD.Store.extend({model:CD.Expilink.Model}));CD.Store.Expilink.getInstance()}());(function(){function a(){return'<form action="javascript:void()" class="task-addtime-quick"><h3>Hours Spent</h3><div class="edt-input"><input type="text" name="time" value="" size="5" autocomplete="off"></div><input type="submit" value="Save" class="rbutton" /><a href="#advanced">Advanced entry</a></form>'}var b=CD.BaseView.extend({options:{modelId:""},clear:function(){this.el.time.value=""},reset:function(){this.clear();this.options.modelId=null},render:function(){var c=this;this.el=Element.make(a());this.el.id=this.options.id;this.el.on("submit",function(d){d.stop();c.trigger("submit",c.options.modelId,this.time.value)});this.el.select("a").first().on("click",function(d){d.stop();InfoDropdown.hide();c.publish("CD.Task.Model."+c.options.modelId+".UI.add-time-advanced",{id:c.options.modelId,time:c.el.time.value})});return this}});ns("CD.Task.View.AddTime",b)}());(function(){function a(d){return CD.Handlebars.getTemplate(d)()}function b(){var e=this;this.form._submit_type=null;this.form.select(".task-ctl-submit").each(function(f){if(f._submit_setup){return}var g=f.data("submit-type");f.on("mousedown",function(){e.form._submit_type=g});f._submit_setup=true});if(!this.form._submit_setup){var d=new Validation(this.form,{immediate:false,onSubmit:false});this.form.on("submit",function(g){e.form.title.value=e.form.title.value.trim();g.stop();if(d.validate()){var f=e.form._submit_type||(e.is_expanded()?"save-full":"save-quick");e.form._submit_type=null;e.trigger("submit",f);e.fields.title.focus()}});this.form._submit_setup=true}}var c=CD.BaseView.extend({options:{expandable:true,expanded:false,fields:[],users:null,space:null,parent:null},_rendered_full:false,form:null,fields:null,initialize:function(d){this.fields={}},render_more_options:function(){var e=this;this.form.insert(a("tpl_task_edit_more_options"));CD.Polyfills.placeholder(this.el);var d={};d.parent_task={handler:CD.UI.Forms.SelectField,default_options:[{id:"",label:"Loading...",disabled:true}],disabled:true};var f=(CD.Controller.mytasks.data)?CD.Controller.mytasks.data.styledspaceswidget:(CD.Controller.projects.data)?CD.Controller.projects.data.styledspaceswidget:{};d.space={handler:CD.UI.Forms.StyledSelectField,source:f,default_options:[{options:{"0":{title:"Personal Task"}},title:"My Tasks"}]};d.spacetasklist={handler:CD.UI.Forms.SelectField,default_options:[{id:"",label:"Loading...",disabled:true}],disabled:true};d.assignees=d.cc={handler:CD.UI.Forms.ObjectField,picker:function(){return new CD.UI.Pickers.Simple({source:new CD.UI.Pickers.Sources.Collection({collection:e.options.users,label_field:"fullname"}),name:name})}};_.each(this.options.fields,function(g){this.fields[g]=CD.UI.Initializer.init(this.form[g],d[g]||{});this.show_field(g);this.fields[g].bind("change",function(h){this.trigger("field:"+g+":change",h)},this)},this);this.el.on("click",".task-ctl-clear",function(g){g.stop();e.clear()});this.el.select("a#edit-task-cancel").first().on("click",function(g){g.stop();if(_.isFunction(e.options.oncancel)){e.options.oncancel.call(e)}else{CD.Project.Router.navigate("#back",true)}});if(this.fields.startdate&&this.fields.duedate){this.fields.startdate.bind("datechange",function(g,h){if(g){if(!e.fields.duedate.value()){e.fields.duedate.value(g);setTimeout(function(){if(!e.fields.duedate.value()){e.fields.duedate.showCalendar()}},100)}}});this.fields.duedate.bind("datechange",function(g,k){var h=!!e.fields.duedate.value();if(!h){e.fields.recurring.clear();e.fields.reminders.clear()}e.fields.recurring.enable(h);e.fields.reminders.enable(h)})}b.call(this);this._rendered_full=true;return this},render:function(){var e=this;this.el.update(a("tpl_task_edit"));CD.Polyfills.placeholder(this.el);this.form=this.el.select("form").first();var d=this.el.select(".task-edit-expandctl").first();d.observe("click",function(f){f.stop();e.expand(!e.is_expanded());e.options.parent.open();if($("edit-task-cancel")){$("edit-task-cancel").observe("click",function(g){g.stop();e.expand(false)})}});this.elms={expand_ctl:d,save_quick_ctl:this.form.select('[type="submit"]').first()};this.fields.title=CD.UI.Initializer.init(this.form.title);this.fields.title.bind("change",function(f){this.trigger("field:title:change",f)},this);if(!this.options.expandable){this.el.addClassName("task-edit-notexpandable")}else{if(this.options.expanded){this.expand(true)}}b.call(this);return this},clear:function(e){var h,f,d,g=Object.clone(this.fields);if(is_array(e)){for(f=0;f<e.length;f++){d=e[f];if(g.hasOwnProperty(d)){delete g[d]}}}for(h in g){if(this.fields.hasOwnProperty(h)){this.fields[h].clear()}}},is_expanded:function(){return this.form.hasClassName("task-edit-st-expanded")},expand:function(d){if(d){if(!this._rendered_full){this.render_more_options()}this.form.addClassName("task-edit-st-expanded");this.elms.expand_ctl.update('<ins class="icon icon_collapse"></ins>Less options');this.elms.save_quick_ctl.disabled=true}else{this.form.removeClassName("task-edit-st-expanded");this.elms.expand_ctl.update('<ins class="icon icon_expand"></ins>More options');this.elms.save_quick_ctl.disabled=false}this.trigger(d?"expand":"collapse");return this},show_field:function(e,d){if(this.fields[e]){if(!this.fields[e]._container){this.fields[e]._container=this.fields[e].el.up(".task-edit-field")}this.fields[e]._container[d?"addClassName":"removeClassName"]("task-edit-field-active")}}});ns("CD.Task.View.Edit",c)}());(function(){ns("CD.Task.View.Detail",CD.BaseView.extend({idPrefix:"tasklist-grid-view-",cls:"tasklist",automount:true,template:"taskDetailTpl",tpl:null,model:null,commentsTabLoaded:false,timeTabLoaded:false,auditLogWidget:null,options:{showTags:true,showComments:true,showCommentForm:false},initialize:function(a){CD.BaseView.prototype.initialize.call(this,a);this.tpl=CD.Handlebars.getTemplate(this.template)},render:function(b,a){this.model=b;a=a||"taskComments";this.commentsTabLoaded=false;this.timeTabLoaded=false;this.auditLogWidget=null;try{tinyMCE.execCommand("mceRemoveControl",false,"comment_comment")}catch(k){console.log("error in tinyMCE.execCOmmand mceRemoveControl")}CD.BaseView.prototype.render(this);var f=["","Low","Medium","High"];var h=this.model.toJSON();h.assignedto_html=CD.UI.Helpers.Models.Project.getAssignedToHtml(b);h.assignedto_text=CD.UI.Helpers.Models.Project.getAssignedToText(b);h.ccto_html=CD.UI.Helpers.Models.Project.getCcToHtml(b);h.ccto_text=CD.UI.Helpers.Models.Project.getCcToText(b);h.overBudget=this.model.get("budgeted_time")&&this.model.get("budgeted_time")<this.model.get("cumulative_time")?true:false;h.hasPriority=h.priority>0;h.priority_text=f[h.priority];h.recurs=h.recur_type>0;h.hasContent=h.content!=="";if(!this.options.showTags){h.tags=null}else{h.tags=this.model.escape("tags");if(h.tags.toString().length>1){var c,g=h.tags.split(",");for(c=0;c<g.length;c++){g[c]="<a href='#tasks-by-tag-"+g[c]+"'>"+g[c]+"</a>"}g=g.join(", ");h.tags=g}else{h.tags=null}}h.inMyTasks=(CD.Environment.space)?false:true;h.isNotDbTask=!(h.db_guid||h.db_recid||h.db_tablename);var d=this.tpl(h);this.el.update(d);this.addEvents();if(this.options.showComments){this.renderTabstrip(a)}this.model.viewed();return this},renderTabstrip:function(b){var c=this;var a=new Element("div",{"class":"m15"});this.el.insert(a);this.tabStrip=new CD.UI.Helpers.Tabstrip({id:"taskViewTab",el:a,tabs:[{className:"comments",name:"taskComments",title:"Comments",count:c.model.get("num_replies"),loader:c.loadCommentsTab.bind(c),headings:[{className:"author",text:"Author"},{className:"version",text:"Date"},{className:"comment",text:"Comment"}]},{className:"time-tracker",name:"taskTime",title:"Time Tracking",countEnabled:false,loader:c.loadTimeTab.bind(c),headings:[{className:"date",text:"Date"},{className:"user",text:"User"},{className:"time",text:"Time"},{className:"notes",text:"Notes"},{className:"actions",text:"Actions"}]},{className:"audit-log",name:"auditLog",title:"Audit Log",countEnabled:false,loader:c.loadAuditLogTab.bind(c),headings:[{className:"when",text:"When?"},{className:"who",text:"Who?"},{className:"what",text:"What?"}]}]});this.tabStrip.render(b)},triggerEvent:function(c,b){if(document.createEvent){var a=document.createEvent("HTMLEvents");a.initEvent(b,true,true);return c.dispatchEvent(a)}if(c.fireEvent){return c.fireEvent("on"+b)}},addEvents:function(){var c=this;var a=this.model;var b=this.el.select("input.task-toggle-complete")[0];var f=this.el.select(".icon_trash")[0];var d=this.el.select(".icon_task_move")[0];var e=c.el.select(".task-title")[0];if(b){if(c.model.get("completed")){b.value="Re-open Task";e.addClassName("task-complete")}else{b.value="Complete Task";e.removeClassName("task-complete")}}if(b){Event.observe(b,"click",function(){c.model.toggleCompleted(!c.model.get("completed"),null,{success:function(){var g=c.el.select(".task-title")[0];if(c.model.get("completed")){b.value="Re-open Task";g.addClassName("task-complete")}else{b.value="Complete Task";g.removeClassName("task-complete")}c.publish(c.model+".show",c.model,null)},error:function(){cdwm.alert("error saving task completed state. Resetting")}})})}if(f){Event.observe(f,"click",function(g){g.preventDefault();g.stopPropagation();cdwm.confirm("Are you sure you want to permanently delete this Task?<br/>Note: This action is different than completing a Task.",function(m){if(m){var k=a.get("child_dependencies");var h=a.get("parent_dependency");a.destroy({success:function(p,n){var o=p.get("fk_tasklistid");CD.Tasklist.Model.find(o,{success:function(v){var t=(v.get("num_records")>0)?v.get("num_records")-1:0;var u=v.get("num_completed");if(p.get("completed")){u=(v.get("num_completed")>0)?v.get("num_completed")-1:0}var s=(t>0)?Math.floor(u/t*100):0;v.set({num_records:t,num_completed:u,progress:s});if((CD.Controller.projects&&CD.Controller.projects.isMyTasks&&CD.Controller.projects.isMyTasks())||(CD.Controller.mytasks&&CD.Controller.mytasks.isMyTasks&&CD.Controller.mytasks.isMyTasks())){CD.Project.Router.navigate("",true)}else{CD.Project.Router.navigate("#tasklist-"+o,true)}},error:function(){CD.Project.Router.navigate("",true)}});var q,r;for(q=0;q<k.length;q++){CD.Task.Model.find(k[q].pk_id,{success:function(s){s.fetch()},error:function(t,s){console.log("Could not find child task of deleted task to break dependency, pk_id:",k[q].pk_id)}})}if(h){CD.Task.Model.find(h.pk_id,{success:function(s){s.fetch()},error:function(s){console.log("Could not retrieve parent task of deleted task to break dependency.")}})}},error:function(o,n){console.log("error on destroy task: ",n)}})}})})}if(d){d.on("click",function(g){g.preventDefault();CD.Task.Dialogs.move(a.id)})}this.el.select(".task-detail-back").first().on("click",function(g){g.stop();CD.Project.Router.navigate(CD.Environment.space?"#tasklist-"+a.get("fk_tasklistid"):"",true)})},onAddTimeCallback:function(a,b){this.loadTimeTab(this.tabStrip,true)},loadCommentsTab:function(a){var c=this,b=c.model.url("comments"),d={doaction:"getComments",format:"jsonenv",spid:c.model.get("fk_spaceid"),showAddForm:c.options.showCommentForm?"true":"false"};if(!c.commentsTabLoaded){CD.Ajax.Request(b,{method:"get",parameters:d,onSuccess:function(h){try{c.commentsTabLoaded=true;var f=a.setContent(h.response.content);f.show();var g=f.select('textarea[name="comment_comment"]').first();if(g.id==="comment_comment"){g.id=CD.Comment.UI.generateId()}a.setCount(h.response.count);tinyMCE.execCommand("mceRemoveControl",false,g.id);tinyMCE.execCommand("mceAddControl",false,g.id);var m=dom.utils.getElementTop(g.parentNode);window.scrollTo(0,m);if($$("span.cmt-toggle a.jslink")[1]){setTimeout(function(){c.triggerEvent($$("span.cmt-toggle a.jslink")[1],"click")},100)}try{tinyMCE.execInstanceCommand(g.id,"mceFocus")}catch(k){}CD.Comment.UI.addEvents({spaceid:spid,activity_type:CD.ACTIVITY_TYPE_TASK,parentElem:a.el,callbacks:{onSaveNew:function(n){var e=a.getSelectedTab();a.setCount(e.count+1);if(n.complete_task){c.model.toggleCompleted(n.complete_task,null,{success:function(o){c.render(c.model)}})}},onSaveEdit:function(e){},onCancel:function(e){},onDelete:function(e){var n=a.getSelectedTab();a.setCount(n.count-1)}}})}catch(k){}},onFailure:function(e){}})}else{a.showTabContent(a.getTab("taskComments"))}},loadTimeTab:function(a,c){var d=this,b=d.model.url("time"),e={doaction:"getTime",format:"jsonenv",spid:d.model.get("fk_spaceid"),showAddForm:d.options.showCommentForm?"true":"false"};if(!this.timeTabLoaded||c){CD.Ajax.Request(b,{method:"get",parameters:e,onSuccess:function(g){try{d.timeTabLoaded=true;var h,q,k,o,f=0,p,m;for(h=0;h<g.response.results.length;h++){f+=g.response.results[h].time}q={results:g.response.results,total_time:f};if(d.model.get("budgeted_time")){q.percentBudgeted=parseInt(f/parseFloat(d.model.get("budgeted_time"))*100,10);if(q.percentBudgeted>100){q.overBudget=true}}k=CD.Handlebars.getTemplate("taskTimeTabTpl");o=k(q);contentElem=a.setContent(o);deleteIcons=contentElem.select(".actions .icon_trash");deleteIcons.each(function(r){r.observe("click",function(s){s.preventDefault();s.stop();cdwm.confirm("Are you sure you want to delete this time record? This action cannot be undone.",function(t){var v,u;if(t){v=r.up(".grd-row");u={recid:parseInt(v.getAttribute("data-id"),10)};CD.Ajax.Request(d.model.url("deletetimerecord"),{method:"post",parameters:u,onSuccess:function(z){var w,y,B,A,x;d.model.set(z.response);d.render(d.model,"taskTime")},onFailure:function(){cdwm.alert("Failed to delete time tracker record!")}})}})})});m=contentElem.select(".time-addentry .jslink").first();m.observe("click",function(r){r.preventDefault();r.stop();d.publish(d.model+".UI.add-time-advanced",{id:d.model.id,callback:d.onAddTimeCallback.bind(d)})});contentElem.show()}catch(n){console.log("failed setting content for time tab!",n)}}})}else{a.showTabContent(a.getTab("taskTime"))}},loadAuditLogTab:function(c){var a,b,d=this;if(!this.auditLogWidget){a=new Element("div");c.setContent(a,c.getTab("auditLog"));this.auditLogWidget=new CD.AuditLog.Widget.Grid({placeholder:a,refModel:d.model})}else{c.showTabContent(c.getTab("auditLog"))}}}))}());(function(){var a=CD.BaseView.extend({tagName:"span",cls:"task-view-inline",watch_model:["title"],options:{noicon:false,maxlen:100},render:function(){if(!this.model){this.el.update("[no Task model]");return this}this.el.update();if(!this.options.noicon){this.el.insert(CD.UI.Helpers.Icons.icon("icon_task"))}this.el.insert(this.model.escape("title").truncate(this.options.maxlen,"..."));return this}});ns("CD.Task.View.Inline",a)}());(function(){var a=CD.BaseView.extend({render:function(){if(!this.model){this.el.update("[no Task model]");return this}var c=this;this.el.update();var b=this.model.get("fk_tasklistid");if(b){CD.Tasklist.Model.find(b,{success:function(d){c.el.insert(d.mkview("meta").el)},error:function(){console.log("Task Meta Render: did not find tasklist "+b,arguments)}})}else{c.el.insert("Personal task")}return this}});ns("CD.Task.View.Meta",a)}());(function(){function a(c,b,d,e){if(!CD.Environment.space||CD.Environment.space.pk_id===0){d.spid=b.get("fk_spaceid")}CD.Ajax.Request(b.url("addtime"),{method:"post",parameters:d,onSuccess:function(f){c.msg(false);b.set({cumulative_time:parseFloat(f.response.cumulative_time,10)||0});if(typeof(e)==="function"){e(b,d)}},onFailure:function(){c.msg("error","Failed to add time")}})}ns("CD.Task.Widget.AddTime",CD.Widget.extend({cls:"",view:null,initialize:function(b){CD.Widget.prototype.initialize.call(this,b);this.view=new CD.Task.View.AddTime({id:"dd_addtime_content"});if(b.addtime_quick_input){var c=this;this.view.bind("submit",function(d,e){c.view.reset();InfoDropdown.hide();c.addTime(d,e)});this.view.bind("advanced",function(d,e){c.view.reset();InfoDropdown.hide();this.publish(c.model+".UI.add-time-advanced",{id:d,time:e})});this.el.insert(this.view.render().el.hide());this.bind("addtime",this.addTime.bind(this))}this.subscribe("CD.Task.Model.*.UI.add-time",this,this.onAddTime,null);this.subscribe("CD.Task.Model.*.UI.add-time-advanced",this,this.onAddTimeAdvanced,null)},onAddTime:function(b,c,d){if(this.el.up("body")===document.body){if(!this.options.addtime_quick_input){this.onAddTimeAdvanced(b,c,d)}else{this.view.options.modelId=c.id;InfoDropdown.show(c.el,"dd_addtime",{cls:"task-addtime-dd",onAfterShow:function(){this.box.select("input[type=text]").first().focus()}})}}else{this.destroy()}},addTime:function(b,d){var c=this;CD.Task.Model.find(b,{success:function(e){d=parseFloat(d);if(isNaN(d)){c.msg("error","Numeric value is required");return}if(d<=0){c.msg("error","Value should be greater than zero");return}a(c,e,{cumulative_time:d,quick:true})}})},onAddTimeAdvanced:function(b,c,e){var d=this;CD.Task.Model.find(c.id,{success:function(h){var g=h.get("space_url")+"project/addtime?tid="+h.id;time=parseFloat(c.time);var k=c.callback||null;function f(){var o=$(this.element.get()),p=o.select("form").first(),m=p.select(".attention-cancel").first(),q=function(r){n=r},n=new Validation(p,{immediate:true,onFormValidate:q});p.on("submit",function(r){r.stop();if(!n){return}a(d,h,this.serialize({hash:true}),k);CD.cdwm.close()});m.on("click",function(r){r.stop();CD.cdwm.close()})}overlay.show({title:"Add Time Spent",type:"dynamic",file:g,inline:true,height:"340px",afterLoad:f},false)}})}}))}());(function(){ns("CD.Task.Widget.Detail",CD.Widget.extend({cls:"",options:{showComments:true,showCommentForm:false,onback:null},initialize:function(a){this.view=new CD.Task.View.Detail({tags:a.tags,el:this.el.content,showComments:a.showComments,showCommentForm:a.showCommentForm});this.subscribe("CD.Task.Model.*.show",this,this.onShowTask,null)},onShowTask:function(c,b,d){var a=CD.Cookies.read("taskViewTab");this.view.render(b,a);this.processing(false)}}))}());(function(){var e=null;var d=["title","startdate","duedate","priority","tags","space","assignees","cc","notify","recurring","budgeted_time","description","spacetasklist","parent_task","reminders"];var a={};var c=0;d.each(function(k,h){a[k]=Math.pow(2,h+1);c|=a[k]});var g={full:c,tasklistpartial:a.title|a.startdate|a.duedate|a.priority|a.tags|a.space|a.spacetasklist|a.assignees|a.cc|a.notify|a.recurring|a.reminders|a.budgeted_time|a.description,collapsed:a.title,personal:a.title|a.description|a.startdate|a.duedate|a.priority|a.space|a.reminders|a.recurring};var b=$H({id:"pk_id",title:"title",description:"taskdescription",startdate:"startdate",duedate:"duedate",priority:"priority",tags:"tags",space:"fk_spaceid",spacetasklist:"fk_tasklistid",assignees:"assignedto",cc:"ccto",notify:"send_email",parent_task:"parent_id",budgeted_time:"budgeted_time",reminders:"reminders",shift_subsequent_tasks:"shift_subsequent_tasks"});var f=CD.Widget.extend({cls:"wdg-task-edit",options:{expandable:true,expanded:false,fullmode:c,task:null,tasklist:null},_rendered_full:false,_fullmode:c,_modesum:0,_applied_modes:null,initialize:function(h){var k=this;this.task=new CD.Task.Model();this.options.tasklist=h.model;if(isNaN(h.fullmode)){throw"Options.fullmode must be a number, bitsum of "+this.ns()+".fields.* values"}this._applied_modes=[];this._fullmode=h.fullmode;if(!h.expandable){this._fullmode|=g.collapsed}this._modesum=this._fullmode;h.users=h.users||new CD.User.Collection();h.spaces=h.spaces||new CD.Space.Collection();this.view=new CD.Task.View.Edit({el:this.el.content,expandable:h.expandable,expanded:h.expanded,users:h.users,oncancel:h.oncancel,spaces:h.spaces,fields:this.visible_fields(this._fullmode),parent:this});this.view.render();if(!h.expanded){this.add_mode("collapsed")}if(!CD.Environment.space){this.add_mode("personal")}this.toggle_fields();this.processing(false);if(this._fullmode&(a.space|a.assignees|a.cc)){this.view.bind("field:space:change",function(n){n=parseInt(n,10)||null;if(n===null){k.add_mode("personal");return}var m=k.options.spaces.get(n);if(!m){console.warn('There is no space "%s"',n);return}k.processing(true);k.remove_mode("personal");if(k.view.fields.space.value()>0){k.populate_space_tasklists(k.view.fields.space.value());k.add_mode("tasklistpartial")}else{k.add_mode("personal")}k.view.fields.assignees.clear();k.view.fields.cc.clear();m.users.fetch({success:function(o){k.options.users.reset(o.toArray());k.processing(false)},error:function(){k.processing(false);throw"Failed to load space users"}})});this.view.bind("field:spacetasklist:change",function(){k.remove_mode("tasklistpartial");if(k.view.fields.spacetasklist.value()>0){k.populate_parent_tasks(k.view.fields.spacetasklist.value())}else{k.add_mode("tasklistpartial")}})}this.view.bind("submit",this.submit,this);this.subscribe("CD.Task.Model.*.edit",this,function(n,m){this.view.expand(true);this.open(m)});this.subscribe("CD.Tasklist.Model.*.selected",this,function(m,n){e=(n instanceof CD.Tasklist.Model)?n:null});this.view.bind("expand",function(){if(!this._rendered_full){this.sync_view();this._rendered_full=true}this.remove_mode("collapsed")},this);this.view.bind("collapse",function(){this.add_mode("collapsed")},this)},open:function(h){if(h){this.task=h;if(h.isPersonal()){this.add_mode("personal")}else{this.remove_mode("personal")}this.view.clear();this.sync_view();var m=CD.UI.Helpers.Dates.date(this.task.get("startdate"));if(m){this.view.fields.startdate.value(m)}var n=CD.UI.Helpers.Dates.date(this.task.get("duedate"));if(n){this.view.fields.duedate.value(n)}var o=this;this.view.fields.startdate.bind("datechange",function(r,q){if(r&&r!==o.task.get("startdate_text")){$$("div.task-edit-shift")[0].show()}else{if(r&&o.view.fields.duedate.value()==o.task.get("duedate_text")){$$("div.task-edit-shift")[0].hide()}}});this.view.fields.duedate.bind("datechange",function(q,r){if(q&&o.task.get("duedate_text")&&q!==o.task.get("duedate_text")){$$("div.task-edit-shift")[0].show()}else{if(q&&o.view.fields.startdate.value()==o.task.get("duedate_text")){$$("div.task-edit-shift")[0].hide()}}});this.el.addClassName("task-edit-st-edit")}else{this.task=new CD.Task.Model();this.view.clear(["title"]);this.el.removeClassName("task-edit-st-edit")}var k=null;var p=CD.Controller.projects.getSelectedTasklist();if(p){k=p.id}else{if(this.task.get("fk_tasklistid")){k=this.task.get("fk_tasklistid")}else{k=this.options.tasklist.id}}this.populate_parent_tasks(k,this.task.get("pk_id"));this.view.fields.title.focus()},populate_space_tasklists:function(m){if(!m){if(this.task.has("fk_spaceid")){m=this.task.get("fk_spaceid")||null}else{m=(CD.Environment.space?CD.Environment.space.id:null)||null}}if(m){var k=this;k.view.fields.space.input.disabled=true;k.set_select_loading(k.view.fields.spacetasklist);var h=new CD.Tasklist.Model();CD.Ajax.Request(h.url("spacetasklists"),{method:"post",parameters:{space_id:m,show_deleted:false,show_db_lists:false},onSuccess:function(o){var p,n=o.response.objects.length;k.view.fields.spacetasklist.input.options.length=0;if(n===0){k.add_to_select(k.view.fields.spacetasklist.input,true,"No Taskslists","");k.view.fields.parent_task.input.disabled=true}else{for(p=0;p<n;p++){k.add_to_select(k.view.fields.spacetasklist,(o.response.objects[p].pk_id===k.task.get("fk_tasklistid")),o.response.objects[p].title,o.response.objects[p].pk_id)}if(k.view.fields.spacetasklist.value()){k.view.trigger("field:spacetasklist:change")}}k.processing(false)},onFailure:function(){cdwm.alert("Could not get valid Space Tasklists.");k.processing(false)}})}},add_to_select:function(h,m,p,n){var o=document.createElement("option");o.text=p;o.value=n;if(m){o.selected=true}try{h.input.add(o,null)}catch(k){h.input.add(o)}},set_select_loading:function(h){h.input.options.length=0;this.add_to_select(h,true,"Loading...","");h.input.disabled=true},populate_parent_tasks:function(h,k){var m=this;if(m.view.fields.space){m.view.fields.space.input.disabled=true}if(m.view.fields.spacetasklist){m.view.fields.spacetasklist.input.disabled=true}if(m.view.fields.parent_task){m.set_select_loading(m.view.fields.parent_task)}var n=m.task.get("pk_id")||k;if(!h){return false}CD.Ajax.Request(this.task.url("taskparents"),{method:"post",parameters:{tasklist_id:h,task_id:n},onSuccess:function(p){var q,o=p.response.objects.length;m.view.fields.parent_task.input.options.length=0;if(o===1){m.add_to_select(m.view.fields.parent_task,true,"No Tasks","");m.view.fields.parent_task.input.disabled=true}else{for(q=0;q<o;q++){m.add_to_select(m.view.fields.parent_task,(m.task.get("parent_dependency")&&(p.response.objects[q].pk_id===m.task.get("parent_dependency").pk_id)),p.response.objects[q].title,p.response.objects[q].pk_id)}m.view.fields.parent_task.input.disabled=false}if(m.view.fields.spacetasklist.value()>0){m.view.fields.space.input.disabled=false}if(m.view.fields.spacetasklist){m.view.fields.spacetasklist.input.disabled=false}},onFailure:function(){cdwm.alert("Could not get valid parent Tasks for setting dependencies.");m.processing(false)}})},submit:function(m){if(this.view.fields.title.value()===""){return}var o=this;var k=_.isUndefined(this.task.attributes.pk_id);var n={};if(m==="save-quick"){this.add_mode("collapsed");this.view.expand(false)}this.sync_model();if(this.task.has("fk_spaceid")){n.fk_spaceid=this.task.get("fk_spaceid")||null}else{n.fk_spaceid=(CD.Environment.space?CD.Environment.space.id:null)||null}var h=0;if(e&&!(e instanceof CD.Tasklist.Container)){h=e.id;_.extend(n,{db_guid:e.get("db_guid")||"",db_recid:e.get("db_recid")||""})}else{h=this.task.get("fk_tasklistid");_.extend(n,{db_guid:"",db_recid:""})}if(n.fk_spaceid>0){_.extend(n,{fk_tasklistid:h})}n.id=this.task.id;if(this.view.fields.title.input.form.elements.shift_subsequent_tasks){n.shift_subsequent_tasks=this.view.fields.title.input.form.elements.shift_subsequent_tasks.checked?true:false}this.task.set(n,{silent:true});this.processing(true);this.removeCCdupes();this.task.save(null,{success:function(u,s){var t,z;if(e&&e.grid){if(k){e.grid.incompleteTaskRows.collection.add(o.task);var v=e.get("num_records")+1;var r=e.get("num_completed");var y=(v>0)?Math.floor(r/v*100):0;e.set({num_records:v,num_completed:r,progress:y})}}if(u.get("meta")){t=u.get("meta").collection;var p;for(p in t){if(parseInt(p)>0){z=t[p];CD.Task.Model.find(z.pk_id,{success:function(A){A.set(z)}})}}}switch(m){case"save-and-add":o.view.fields.title.clear();o.view.fields.description.clear();break;case"save-full":case"save-quick":default:o.view.clear();o.view.expand(false);if(!CD.Environment.space){o.add_mode("personal")}if(!k){CD.Store.Task.getInstance().onLoad(null,u,null);CD.Project.Router.navigate("#task-"+u.get("pk_id"),true)}}o.task=new CD.Task.Model();o.processing(false);o.populate_parent_tasks(n.fk_tasklistid);if(u.get("db_guid")){var x=$$("li#tab_tasks a span span");if(x&&x.length>0){var q=x[0];var w=parseInt(q.innerHTML.trim().replace("(","").replace(")",""))+1;q.innerHTML=" ("+w+")";q.setAttribute("data-count",w)}}o.view.fields.title.focus()},error:function(q,r,p){o.msg("error","Failed to save task");o.task=new CD.Task.Model();o.processing(false);o.view.fields.title.focus()}})},sync_view:function(){var k,h;for(k in a){if(a.hasOwnProperty(k)&&(this._modesum&a[k])){if(k==="recurring"){this.view.fields[k].value(this.task.toJSON())}else{var h=this.task.get(b.get(k));if(!_.isUndefined(h)&&!_.isNull(h)){this.view.fields[k].value(this.task.get(b.get(k)))}}}}},sync_model:function(){var k,h={};for(k in a){if(a.hasOwnProperty(k)&&(this._modesum&a[k])){if(k==="recurring"){h=_.extend(h,this.view.fields[k].value())}else{h[b.get(k)]=this.view.fields[k].value()}}}this.task.set(h,{silent:true})},toggle_fields:function(){var h;var k=this._fullmode&this._modesum;for(h in a){if(a.hasOwnProperty(h)){this.view.show_field(h,(k&a[h])>0)}}},visible_fields:function(m){var k;var h=[];var m=_.isUndefined(m)?(this._fullmode&this._modesum):m;for(k in a){if(a.hasOwnProperty(k)&&(m&a[k])){h.push(k)}}return h},add_mode:function(h){if(_.isUndefined(g[h])){throw'Invalid mode "'+h+'"'}this._applied_modes.push(h);this._modesum&=g[h];this.toggle_fields()},remove_mode:function(h){var k;this._applied_modes=this._applied_modes.without(h);this._modesum=this._fullmode;for(k=0;k<this._applied_modes.length;k++){this._modesum&=g[this._applied_modes[k]]}this.toggle_fields()},removeCCdupes:function(){var m=this.task.get("ccto");var k=this.task.get("assignedto");var h;if(m&&k){for(h=0;h<m.length;h++){if(this.arrayContains(k,m[h],this.assignmentEquals)){m.splice(h,1)}}this.task.set({ccto:m})}},arrayContains:function(h,m){var k=h.length;while(k--){if(this.assignmentEquals(h[k],m)){return true}}return false},assignmentEquals:function(k,h){return k.id===h.id&&k.label===h.label}});f.fields=a;f.mode=function(h){if(_.isUndefined(g[h])){throw'Invalid mode "'+h+'"'}return g[h]};f.visible_fields=function(m){var k;var h=[];for(k in a){if(a.hasOwnProperty(k)&&(m&a[k])){h.push(k)}}return h};ns("CD.Task.Widget.Edit",f)}());(function(){ns("CD.Task.Widget.Detail",CD.Widget.extend({cls:"",options:{showComments:true,showCommentForm:false,onback:null},initialize:function(a){this.view=new CD.Task.View.Detail({tags:a.tags,el:this.el.content,showComments:a.showComments,showCommentForm:a.showCommentForm});this.subscribe("CD.Task.Model.*.show",this,this.onShowTask,null)},onShowTask:function(c,b,d){var a=CD.Cookies.read("taskViewTab");this.view.render(b,a);this.processing(false)}}))}());(function(){function a(c){return'<h2>Task Lists</h2><ul class="nav-sblist"></ul>'}var b=CD.BaseView.extend({title:null,lis:null,selected_item:null,containers:null,tasklists:null,initialize:function(c){this.items={};this.containers=c.containers||[];this.tasklists=c.tasklists||[]},select:function(c){if(this.selected_item){this.selected_item.select(false)}if(this.items[c.id]){this.items[c.id].select(true);this.selected_item=this.items[c.id]}return this},render:function(){var e=this;this.el.update(a());this.title=this.el.select("h2").first();this.items={};var d=this.el.select(".nav-sblist").first();var c=_.union(this.containers,this.tasklists.toArray());c.each(function(g){var f=g.mkview("navitem");if(_.isFunction(f.extra_elements)){f.extra_elements().each(function(h){e.el.insert({bottom:h})})}if(g.get("is_inbox")){d.insert({top:f.el})}else{d.insert({bottom:f.el})}e.items[g.id]=f});if(this.options.title){this.title.update(this.options.title)}return this}});ns("CD.Tasklist.View.Nav",b)}());(function(){var a=new RegExp("{id}");if(a.compile){a.compile(a)}var b=null;var c=25;(function(){var e,d;var h=function(o,n){o.setVal(n||"(!) Error")};var f=function(o){var n=o.up(".lgrd-row");d=n?parseInt(n.data("id"))||null:null;CD.Task.Model.find(d,{success:function(p){e=p}});if(!e){throw"No task model"}return e.get(this.name.replace(/^task/,""))};var k=function(o){var n=f.call(this,o);return isNaN(Date.parse(n))?"None":CD.UI.Helpers.Dates.date(n)};var m=function(q){var p=this.name,r=[],n,o;q=q.toString().strip();if(p==="tasktitle"&&!q){r.push("Task title is required")}if(p==="taskstartdate"){n=Date.parse(q)}if(p==="taskduedate"){o=Date.parse(q)}if((n||Date.parse(e.get("startdate"))||-Infinity)>(o||Date.parse(e.get("duedate"))||Infinity)){r.push("Start date can't be after due date")}if(r.length){alert("- "+r.join("<br/>- "));return false}return true};var g=function(o,n){if(d===null){console.warn("Missing task id");return h}if((o[2]==="duedate"||o[2]==="startdate")){n=isNaN(Date.parse(n))?"":n}CD.Task.Model.find(d,{success:function(p){var q={};q[o[2]]=n;p.save(q)}});return function(p){p.setVal('<ins class="ajax-loader"></ins>')}};C2EGenericHandler.registerType("tasktitle",C2ETextEditor,g,m,f);C2EGenericHandler.registerType("taskstartdate",C2EDateEditor,g,m,k);C2EGenericHandler.registerType("taskduedate",C2EDateEditor,g,m,k)}());ns("CD.Tasklist.View.TaskRows",CD.BaseView.extend({idPrefix:"tasklist-taskrows-view-",cls:"tasklist",automount:true,grid:null,model:null,collection:null,paginator:null,templates:{header:"tasklistHeaderTpl",dataView:"tasklistTaskRowsTpl",row:"tasklistTaskRowTpl"},headerTpl:null,dataTpl:null,rowTpl:null,dataView:null,setupTemplates:function(){b=5;Handlebars.registerPartial("taskRowTpl",CD.Handlebars.getTemplate(this.templates.row));this.headerTpl=CD.Handlebars.getTemplate(this.templates.header);this.dataTpl=CD.Handlebars.getTemplate(this.templates.dataView);this.rowTpl=CD.Handlebars.getTemplate(this.templates.row)},initialize:function(d){CD.BaseView.prototype.initialize.call(this,arguments);this.id=d.id||CD.Widget.getNextId();this.el.id=this.idPrefix+this.id.toString();this.grid=d.grid;this.model=d.model;this.collection=d.filter==="complete"?d.model.completedTasks:d.model.incompleteTasks;this.setupTemplates();this.render();this.setupSubscriptions()},render:function(){if(this.options.header){this.renderHeader()}this.renderDataView();this.paginator=new CD.UI.Helpers.Pagination(_.extend({},this.options,{el:this.el.select(".pagination."+this.options.filter).first(),numRecords:this.options.filter==="complete"?parseInt(this.options.model.attributes.num_completed,10):parseInt(this.options.model.attributes.num_records,10)-parseInt(this.options.model.attributes.num_completed,10),recordsPerPage:c,pageNum:this.options.filter==="complete"?this.options.completedPageNum:this.options.incompletePageNum}));this.paginator.render()},renderHeader:function(){var g,o,d,f,n;this.headerElem=new Element("div");try{var k=$$('script[rel="'+_options.placeholder.id+'"],meta[rel="'+_options.placeholder.id+'"]')[0];k.parentNode.replaceChild(this.headerElem,k)}catch(h){this.el.appendChild(this.headerElem)}this.headerElem.innerHTML=this.headerTpl();var m=this.headerElem.select('.is-sortable[data-sortBy="'+this.options.sortBy+'"] ins.sort.icon').first();if(this.options.sortDir===ObjectSort.ASC){m.addClassName("icon_bullet_arrow_up")}else{m.addClassName("icon_bullet_arrow_down")}m.addClassName("sort-dir-"+this.options.sortDir);g=this.headerElem.select(".is-sortable");d=this;n=function(p){var s=this.getAttribute("data-sortBy");var e=this.up(".tasklist-grid");var q;if(s){q=ObjectSort.ASC;var r=this.select("ins.sort.icon").first();if(r.hasClassName("sort-dir-"+ObjectSort.ASC)){q=ObjectSort.DESC}d.publish(d+".sortby."+s,{sortBy:s,sortDir:q,elem:this})}else{console.warn("sortable column is missing data-sortBy attribute!")}};for(f=0;f<g.length;f++){o=g[f];Event.observe(o,"click",n)}},renderDataView:function(){var d;this.dataView=this.el.select("div.tasklist-data").first();if(!this.dataView){this.dataView=new Element("div",{"class":"tasklist-data"});this.el.insert(this.dataView)}d={filter:this.options.filter,moreCompleted:0,tasks:[]};var e=this.dataTpl(d);this.dataView.update(e)},renderTasks:function(f,m,e){m=m||false;if(!m&&this.model.get("num_"+(this.options.filter==="complete"?"completed":"records"))>0&&f.length==0){return true}var q,g,h,p={tasks:[],tasksOnly:true,moreCompleted:0,numRecords:0},o=0,k,n=new Date();var d=["","Low","Medium","High"];if(m){if(this.options.filter==="complete"){p.numRecords=f.length}else{p.numRecords=f.length-e}}else{if(this.options.filter==="complete"){p.numRecords=parseInt(this.model.get("num_completed"),10)}else{p.numRecords=parseInt(this.model.get("num_records"),10)-parseInt(this.model.get("num_completed"),10)}}for(q=0;q<f.length;q++){h=f[q];g=h.toJSON();g.isAssignedTo=h.isAssignedTo(CD.Environment.user.id);g.isCreatedBy=h.get("fk_createdby_userid")===CD.Environment.user.id;g.assignedto_text=CD.UI.Helpers.Models.Project.getAssignedToText(h);g.assignedto_html=CD.UI.Helpers.Models.Project.getAssignedToHtml(h);g.startdate=g.startdate?CD.UI.Helpers.Dates.date(g.startdate):"";g.duedate=g.duedate?CD.UI.Helpers.Dates.date(g.duedate):"";if(g.duedate){k=new Date(g.duedate);k.setHours(23);k.setMinutes(59);k.setSeconds(59);g.overdue=k<n}else{g.overdue=false}g.priorityTitle=g.priority>0?d[g.priority]+" Priority":"";g.tasklistText=g.tasklist_text;if(g.fk_spaceid&&g.fk_tasklistid){g.tasklistText=g.spacename_long+" &gt; "+(g.milestone_name?g.milestone_name.truncate(20,"...")+" &gt; ":"")+g.categoryname.truncate(20,"...")}p.tasks.push(g);if(f[q].get("completed")){o++}}if(this.paginator.options.pageNum>0){if(this.options.filter==="complete"){this.paginator.options.numRecords=this.model.get("num_completed")}else{this.paginator.options.numRecords=this.model.get("num_records")-this.model.get("num_completed")}this.paginator.render()}this.dataView.select("ul").first().update(this.dataTpl(p));C2EManager.init();if(!(this.model instanceof CD.Tasklist.Container)&&!CD.Controller.projects.isArchive()&&!this.model.get("attached_to_db")){this.el.addClassName("draggable");this.dataView.select(".task-row").each(function(r){r=_.extend(r,CD.Draggable);r.initDraggable(CD.Controller.projects.getDragManager(),{clone:function(u){var t=u.select(".task-title .task-title-wrapper a")[0];var w=new Element("div",{"class":"sm5 item"});var s=new Element("ins",{"class":"icon icon_task pin-left"});w.appendChild(s);var v=t.cloneNode(true);w.appendChild(v);return w}})})}else{this.el.removeClassName("draggable")}if(this.options.filter==="complete"){if(o===0){$$(".tasklist .completedHeading").first().addClassName("bl-dynamic");this.el.addClassName("bl-dynamic")}else{$$(".tasklist .completedHeading").first().removeClassName("bl-dynamic");this.el.removeClassName("bl-dynamic")}}this.setupPublishEvent(".task-row .task-checkbox input","click","CD.Task.Model.{id}.UI.toggle-complete");this.setupPublishEvent(".task-row .task-actions .icon_time_tracking","click","CD.Task.Model.{id}.UI.add-time")},onSortBy:function(d,e,f){if(this.el.up("body")===document.body){this.headerElem.select("ins.sort.icon").each(function(h){h.removeClassName("icon_bullet_arrow_down");h.removeClassName("icon_bullet_arrow_up")});var g=e.elem.select("ins.sort.icon").first();g.removeClassName("sort-dir-"+ObjectSort.ASC);g.removeClassName("sort-dir-"+ObjectSort.DESC);if(e.sortDir===ObjectSort.ASC){g.addClassName("icon_bullet_arrow_up");g.addClassName("sort-dir-"+ObjectSort.ASC)}else{g.addClassName("icon_bullet_arrow_down");g.addClassName("sort-dir-"+ObjectSort.DESC)}}else{this.destroy()}},onSorted:function(n,f,g){if(this.el.up("body")===document.body){var m=0,p=0,h,e,q,d,k,r,o;for(h=0;h<f.length;h++){e=f[h];q=$("task_"+e.get("pk_id"));d=q.parentNode;if(e.get("completed")){k=this.el.select(".tasklist-grid.complete")[0];r=k.childNodes[p];p++}else{k=this.el.select(".tasklist-grid.incomplete")[0];r=k.childNodes[m];m++}if(r!==q){placeHolder=new Element("div",{style:"display: none"});d.replaceChild(placeHolder,q);k.replaceChild(q,r);d.replaceChild(r,placeHolder)}}}else{this.destroy()}},setupSubscriptions:function(){this.subscribe(this+".sortby.*",this,this.onSortBy,null);this.subscribe(this+".sorted",this,this.onSorted,null)},setupPublishEvent:function(e,g,d){var f=this;this.el.select(e).each(function(h){h.observe(g,function(k){var m=h.hasClassName("task-row")?h:h.up(".task-row");var n=parseInt(m.data("id"),10);CD.Task.Model.find(n,{success:function(o){f.publish(d.replace(a,n),{id:n,el:h,row:m,task:o});k.stop();return false},error:function(){}})})})}}))}());(function(){ns("CD.Tasklist.View.Grid",CD.Template.View.extend({template:"tasklistGridTpl"}))}());(function(){var a="CD.Tasklist.View.Wrap";ns(a,CD.Template.View.extend({template:"tasklist_wrap_templ"}))}());(function(){var a=CD.BaseView.extend({tagName:"span",cls:"tasklist-view-inline",watch_model:["private","title"],options:{noicon:false,maxlen:60},render:function(){if(!this.model){this.el.update("[no Tasklist model]");return this}this.el.update();if(!this.options.noicon){this.el.insert(CD.UI.Helpers.Icons.icon(this.model.get("private")?"icon_internal_use_only":"icon_task"))}if(this.model.get("attached_to_db")){this.el.insert('<a href="'+this.model.get("db_url")+'">'+this.model.escape("title").truncate(this.options.maxlen,"...")+"</a>");this.el.insert("&nbsp;");this.el.insert(CD.UI.Helpers.Icons.icon("icon_database"));this.el.select(".icon_database").first().setStyle({position:"relative",top:"-1px"})}else{this.el.insert(this.model.escape("title").truncate(this.options.maxlen,"..."))}return this}});ns("CD.Tasklist.View.Inline",a)}());(function(){var a=CD.BaseView.extend({render:function(){if(!this.model){this.el.update("[no Tasklist model]");return this}var b=this;this.el.update(this.model.mkview("inline",{noicon:true}).el);if(this.model.get("fk_milestoneid")>0&&((CD.Controller.projects&&!CD.Controller.projects.isMyTasks)||(CD.Controller.mytasks&&!CD.Controller.mytasks.isMyTasks))){var c=this.model.get("fk_milestoneid");CD.Milestone.Model.find(c,{success:function(d){b.el.insert({top:'<span class="mlst-view-inline">&nbsp;&gt;&nbsp;</span>'});b.el.insert({top:d.mkview("inline",{noicon:true}).el})},error:function(){console.log("Tasklist Meta Render: did not find milestone "+c,arguments)}})}return this}});ns("CD.Tasklist.View.Meta",a)}());(function(){var a=CD.BaseView.extend({tagName:"li",watch_model:["private","title","num_completed","num_records"],options:{maxlen:23,counts:true,selected:false},select:function(b){this.options.selected=!!b;if(this.options.selected){this.el.addClassName("selected")}else{this.el.removeClassName("selected")}},initialize:function(b){CD.BaseView.prototype.initialize.call(this,arguments);this.el=_.extend(this.el,CD.Droppable);this.el.setAttribute("data-id",b.model.get("pk_id"));var c=this;if(!b.model.get("attached_to_db")){this.el.initDroppable(CD.Controller.projects.getDropManager(),{canDropElement:function(f){var d=CD.Controller.projects.getSelectedTasklist();var e=parseInt(this.getAttribute("data-id"),10);if(d.get("pk_id")!==e){return true}else{return false}},onDrop:function(d,n,o){var f,g,e,h=[],k,p,m;n.startHighlightTimer(false);if(this.canDropElement(d)&&CD.permissions.canEdit(CD.Environment.space.id)){k=CD.Controller.projects.getSelectedTasklist();g=n.getAttribute("data-id");e=d.dragManager.getSelected();p=e.length;m=0;for(f=0;f<e.length;f++){h.push(parseInt(e[f].getAttribute("data-id"),10));if(e[f].up(".complete")){m++}}}CD.Tasklist.Model.find(g,{success:function(q){var s={"taskIds[]":h};var r=false;for(f=0;f<h.length;f++){CD.Task.Model.find(h[f],{success:function(t){if(parseInt(t.get("parent_id"))>0||t.get("child_dependencies").length>0){r=true}},error:function(){console.log("Could not find task model to check for dependencies before moving.")}})}if(r){cdwm.confirm("Moving this task will break existing dependencies, are you sure you want to do this?",function(t){if(t){c.movetasksFun(q,k,p,m,s,e)}})}else{c.movetasksFun(q,k,p,m,s,e)}},error:function(){console.log("error moving tasks to tasklist: ",arguments,g);cdwm.alert("Error moving tasks to tasklist, please try again.")}});return true},onMouseOver:function(f,e,d){if(this.canDropElement(f)&&CD.permissions.canEdit(CD.Environment.space.id)){e.setDropValidity(true)}else{e.setDropValidity(false)}this.startHighlightTimer(true);d.stop();return false},onMouseOut:function(f,e,d){this.startHighlightTimer(false)}})}},render:function(){if(!this.model){this.el.update("[no Tasklist model]");return this}this.el.update();if(this.options.selected){this.el.addClassName("selected")}var b=(this.model.options&&this.model.options.href_base)||"tasklist";var c=new Element("a",{href:"#"+b+"-"+this.model.id,id:"tskl-nav-"+this.model.id,title:this.model.escape("title"),"class":"taskl-nav-title"});c.update(this.model.escape("title"));this.el.insert(c);if(this.model.get("private")){c.insert({after:CD.UI.Helpers.Icons.icon("icon_internal_use_only_red")})}if(this.model.get("attached_to_db")){c.insert({after:CD.UI.Helpers.Icons.icon("icon_database")})}if(this.options.counts){if(!(this.model instanceof CD.Tasklist.Container&&!this.model.get("num_completed")&&!this.model.get("num_records"))){var d=((this.model.get("num_records")||0)-(this.model.get("num_completed")||0));d="("+d+")";this.el.insert((new Element("span")).addClassName("nav-sblist-count nav-sblist-inact").update(d))}}return this},movetasksFun:function(f,c,b,d,g,e){CD.Ajax.Request(f.url("movetasks"),{method:"post",parameters:g,onSuccess:function(r){var k,s,p,n;var q=g["taskIds[]"];if(r){k=f.get("num_records")+b;s=f.get("num_completed")+d;p=c.get("num_records")-b;n=c.get("num_completed")-d;f.set({num_records:k,num_completed:s});c.set({num_records:p,num_completed:n});for(i=0;i<e.length;i++){e[i].parentNode.removeChild(e[i]);c.incompleteTasks.remove(e[i]);c.completedTasks.remove(e[i])}for(i=0;i<q.length;i++){c.incompleteTasks.remove(q[i]);c.completedTasks.remove(q[i])}if(r.response.meta&&r.response.meta.collection){var t,o,m,u,h;for(t in r.response.meta.collection){if(r.response.meta.collection.hasOwnProperty(t)){o=r.response.meta.collection[t].pk_id;m=r.response.meta.collection[t];CD.Task.Model.find(o,{success:function(v){v.set(m)}});u=c.incompleteTasks.get(o);if(u){c.incompleteTasks.get(o).set(m)}else{h=c.completedTasks.get(o);if(h){c.completedTasks.get(o).set(m)}}}}}}}})}});ns("CD.Tasklist.View.NavItem",a)}());(function(){var a=CD.BaseView.extend({tagName:"span",options:{noicon:false,maxlen:100},render:function(){if(!this.model){this.el.update("[no Container]");return this}var b=this.model.options.filter;this.el.update("Tasks by ");if(!b){this.el.insert("[missing model.options.filter]")}else{this.el.insert((b.getvalue&&b.getvalue())||b.value||b.label)}return this}});ns("CD.Tasklist.View.FilteredInline",a)}());(function(){function b(){return(["dd","tasksby",this.cid,this.model.id]).join("_")}var a=CD.BaseView.extend({tagName:"li",options:null,initialize:function(){this.options={selected:false}},select:function(c){if(c!==this.options.selected){this.options.selected=!!c;this.render()}},extra_elements:function(){var c=new CD.UI.Helpers.Dropdown.mklist(this.model.options.filter.choices);c.id=b.call(this)+"_content";return[c]},render:function(){var c;if(!this.model){this.el.update("[no Tasklist Container]");return this}var e=this;var d=this.model.options.filter;if(!d){this.el.update("[missing model.options.filter]");return this}this.el.update();if(this.options.selected){this.el.update("<b>Tasks by </b>");c=new Element("a",{href:"#filter"});c.update((d.getvalue&&d.getvalue())||d.value)}else{c=new Element("a",{href:"#filter"});c.update("Tasks by "+d.label)}c.insert('<ins class="dropdown-arrow"></ins>');c.on("click",function(f){f.stop();CapDropdown.show(this,b.call(e))});this.el.insert(c);return this}});ns("CD.Tasklist.View.DropdownNavItem",a)}());(function(){var a=CD.Widget.extend({tasklists:null,spaceusers:null,cls:"tasklist-nav",options:null,initialize:function(b){this.options={tasklists:new CD.Tasklist.Collection(),containers:[],title:null};this.vNav=new CD.Tasklist.View.Nav({el:this.el.content,containers:b.containers,tasklists:b.tasklists,title:b.title});this.subscribe("CD.Tasklist.Model.*.selected",this,function(c,e,d){if(e){this.vNav.select(e)}else{console.warn("CD.Tasklist.Widget.Nav: Tasklist (",e,") does not exist")}});this.subscribe("CD.Milestone.Model.*.selected",this,function(c,e,d){if(this.vNav.selected_item){this.vNav.selected_item.select(false)}});this.subscribe(b.tasklists+".changed",this,function(c,e,d){this.render_views()})},render_views:function(){this.vNav.render();this.processing(false)}});ns("CD.Tasklist.Widget.Nav",a)}());(function(){var d=null;var c=null;var b=null;var e=null;var a=null;ns("CD.Tasklist.Widget.TaskRows",CD.Widget.extend({idPrefix:"tasklist-taskrows-widget-",cls:"tasklist",data:null,grid:null,model:null,collection:null,view:null,getRecord:function(g){var f;for(f=0;f<this.data.length;f++){if(this.data[f].get("pk_id")===g){return this.data[f]}}return null},setRecord:function(f){var g;for(g=0;g<this.data.length;g++){if(this.data[g].get("pk_id")===f.id){this.data[g]=f;return true}}return false},addRecord:function(f){this.data.unshift(f)},removeRecord:function(f){var g,h=[];for(g=0;g<this.data.length;g++){if(this.data[g].id!==f.id){h.push(this.data[g])}}this.data=h},initialize:function(f){CD.Widget.prototype.initialize.call(this,arguments);this.id=f.id||CD.Widget.getNextId();this.el.id=this.idPrefix+this.id.toString();this.grid=f.grid;this.model=f.model;this.collection=f.filter==="complete"?f.model.completedTasks:f.model.incompleteTasks;if(this.model.id===d){f.sortBy=c||f.sortBy;f.sortDir=b||f.sortDir;f.completedPageNum=f.completedPageNum||e;f.incompletePageNum=f.incompletePageNum||a}f.sortBy=f.sortBy||"priority";f.sortDir=f.sortDir||"desc";this.view=new CD.Tasklist.View.TaskRows(_.extend({},f,{el:this.el.content}));this.setupSubscriptions();this.processing(false);if(f.filter==="complete"){this.grid.completeTaskRows=this}else{if(f.filter==="incomplete"){this.grid.incompleteTaskRows=this}}},loadData:function(f){if(this.el.up("body")===document.body){var g=this;if(!g.model||!(g.model instanceof CD.Tasklist.Model)){return false}g.processing(true);if(this.options.filter==="complete"){e=g.view.paginator.getPageNum()||1}else{a=g.view.paginator.getPageNum()||1}var h={pageNum:g.view.paginator.getPageNum(),sortDir:g.options.sortDir,sortBy:g.options.sortBy};h=_.extend({},h,f||{});g.collection.fetch({data:h,reqsuccess:function(n,k,m){g.publish(g.model+".tasksLoaded",{tasks:n,meta:m.meta});g.processing(false)},error:function(o,m,n){g.processing(false);g.locked(true);g.msg("error","Can not load tasks");var k=new CD.Report.Model();k.save({subject:"Project V3",message:"CD.Tasklist.Widget.TaskRows.loadData: Params:{url: "+g.collection.url()+"\n, pagenum:"+h.pageNum+",\nsortBy:"+h.sortBy+",\nsortDir:"+h.sortDir+"}, error:"+m})}})}else{this.destroy()}},onSortBy:function(f,g,h){if(this.el.up("body")===document.body){d=this.model.id;c=this.grid.options.sortBy=this.options.sortBy=g.sortBy;b=this.grid.options.sortDir=this.options.sortDir=g.sortDir;this.view.paginator.onGoToPage(1);this.loadData({completed:this.options.filter==="complete"})}else{this.destroy()}},onLoad:function(f,g,h){if(this.el.up("body")===document.body){if(f===(this.model+".tasksLoaded")){d=this.model.id;this.data=this.collection.toArray();this.view.renderTasks(this.data)}}else{this.destroy()}},onTaskChange:function(g,f){if(this.el.up("body")===document.body){if(!f.id){return}if(this.getRecord(f.id)){this.setRecord(f)}else{if(this.options.filter==="incomplete"){this.el.select("ins.sort.icon").each(function(k){k.className="icon sort"})}}this.view.renderTasks(this.data);if(this.options.filter==="incomplete"){var h=$("task_"+f.id);if(h){h.highlight()}}}else{this.destroy()}},onTaskDeleted:function(g,f){if(this.el.up("body")===document.body){var h=this.index[f.get("pk_id")];if(h!==undefined){delete this.index[f.get("pk_id")];this.data.remove(h)}}else{this.destroy()}},onCollectionChanged:function(h,o){if(this.el.up("body")===document.body){var g,f=[],k=[],p,n,m=0;if(_.isArray(this.data)){for(g=0;g<this.data.length;g++){f.push(this.data[g].id)}}for(g=0;g<f.length;g++){p=f[g];n=o.get(p);if(n!==undefined){k.push(n)}}for(g=0;g<o.models.length;g++){p=o.models[g].id;if(o.models[g].get("completed")){m++}found=false;for(j=0;j<k.length;j++){if(k[j].id===p){found=true}}if(!found){k.unshift(o.models[g])}}this.data=k;this.view.renderTasks(k,true,m)}else{this.destroy()}},setupSubscriptions:function(){this.subscribe(this.model+".tasksLoaded",this,this.onLoad,null);this.subscribe("CD.Task.Model.*.changed",this,this.onTaskChange,null);this.subscribe(this.collection+".changed",this,this.onCollectionChanged,null);this.subscribe("CD.Tasklist.Model.*.show",this,this.onShowTasklist,null);this.subscribe(this.view+".sortby.*",this,this.onSortBy,null)},onShowTasklist:function(f,h,g){if(this.el.up("body")===document.body){this.processing(true);this.model=h;this.loadData()}else{this.destroy()}}}))}());(function(){ns("CD.Tasklist.Widget.Grid",CD.Widget.extend({defaults:{addtime_enabled:true,addtime_quick_input:true,mytasks:false},idPrefix:"tasklist-grid-widget-",cls:"tasklist",model:null,options:null,incompleteTaskRows:null,completeTaskRows:null,initialize:function(b){this.model=b.model;this.model.grid=this;this.options=b;this.processing(false);this.locked(true);this.id=CD.Widget.getNextId();this.view=new CD.Tasklist.View.Grid({el:this.el.content});this.view.render();if(this.options.mytasks){this.el.addClassName("mytasks");this.el.addClassName(this.model.id)}this.children=[];var d,e,f;f=$(this.el.content).select('[type="text/x-widget"], .x-widget');for(d=0;d<f.length;d++){e=f[d].data("init-widget");if(e===null){f.splice(d,1)}}var a,c;for(d=0;d<f.length;d++){a=f[d].data("init-widget");sFilter=f[d].data("init-filter");sHeader=f[d].data("init-header");args=_.extend({},b,{grid:this,placeholder:f[d],filter:sFilter,header:JSON.parse(sHeader||"true")});c=CD.Widget.init(a,args);this.children.push(c)}if(!this.options.addtime_enabled){this.el.addClassName("tasklist-no-addtime")}var g=this.el.select(".tasklist-data")[0];CD.Controller.projects.getDragManager().setContainer(g);this.setupSubscriptions();this.locked(false)},setupSubscriptions:function(){this.subscribe(this.incompleteTaskRows.view.paginator+".page",this,this.route,null);this.subscribe(this.completeTaskRows.view.paginator+".page",this,this.route,null);this.subscribe("CD.Task.Model.*.UI.toggle-complete",this,this.onToggleComplete,null);this.subscribe("CD.Task.Model.*.UI.delete",this,this.onDelete,null)},onToggleComplete:function(c,d,f){if(this.el.up("body")===document.body){var a=$("task_"+d.id);var g=a.select('input[type="checkbox"]')[0];var b=this;var e=g.checked;CD.Task.Model.find(d.id,{success:function(h){g.disable();h.toggleCompleted(e,b,{success:function(q,o,k,n){g.enable();if(q){b.incompleteTaskRows.collection.remove(k);b.completeTaskRows.collection.add(k)}else{b.incompleteTaskRows.collection.add(k);b.completeTaskRows.collection.remove(k)}if(b.model instanceof CD.Tasklist.Container){var m=b.model.get("num_records");var p=b.model.get("num_completed")+1;var r=(m>0)?Math.floor(p/m*100):0;b.model.set({num_records:m,num_completed:p,progress:r})}},error:function(){cdwm.alert("error saving task completed state. Resetting");g.enable();g.checked=!e;if(!e){a.addClassName("task-state-completed")}else{a.removeClassName("task-state-completed")}}})},error:function(){cdwm.alert("Error saving task completed state. Resetting")}})}else{this.destroy()}},onDelete:function(b,c,d){if(this.el.up("body")===document.body){var a=this;cdwm.confirm("Are you sure you want to permanently delete this Task?<br/>Note: This action is different than completing a Task.",function(f){if(f){var e=c.task;e.destroy({success:function(k,g){var h=k.get("fk_tasklistid");CD.Tasklist.Model.find(h,{success:function(p){var o,n,m;o=(p.get("num_completed")>0)?p.get("num_completed"):0;if(k.get("completed")&&o>0){o--}n=(p.get("num_records")>0)?p.get("num_records")-1:0;m=(n>0)?Math.floor(o/n*100):0;p.set({num_records:n,num_completed:o,progress:m});c.row.parentNode.removeChild(c.row);a.publish(c.task+".deleted",c.task)},error:function(){}})},error:function(h,g){}})}})}else{this.destroy()}},route:function(){var a;if(this.model instanceof CD.Tasklist.Container){a="tasks-"+this.model.id}else{a="tasklist-"+this.model.get("pk_id")}if(this.model.filterValue){a=a+"-"+this.model.filterValue}this.options.sortBy=this.options.sortBy||"priority";this.options.sortDir=this.options.sortDir||"desc";a=a+"/"+this.incompleteTaskRows.view.paginator.getPageNum()+"-"+this.completeTaskRows.view.paginator.getPageNum()+"/"+this.options.sortBy+"-"+this.options.sortDir;CD.Project.Router.navigate(a,true)}}))}());(function(){var a=CD.Widget.extend({children:null,initialize:function(c){this.children=[];this.view=new CD.Tasklist.View.Wrap({el:this.el.content});this.view.render();var e,f,g;g=$(this.el).select('[type="text/x-widget"], .x-widget');for(e=0;e<g.length;e++){f=g[e].data("init-widget");if(f===null){g.splice(e,1)}}var b,d;for(e=0;e<g.length;e++){b=g[e].data("init-widget");args=c[e];if(!(b==="CD.Task.Widget.Edit"&&(CD.Controller.projects.isArchive()||!args.model.options.canAddTask))){d=CD.Widget.init(b,args);this.children.push(d)}}this.processing(false)}});ns("CD.Tasklist.Widget.Wrap",a)}());(function(){var a=CD.BaseView.extend({options:{expanded:false,fields:[]},_rendered_full:false,form:null,fields:null,initialize:function(){this.fields={}},render:function(){CD.Template.Loader.get("TaskTemplate.Edit",{success:this._render,success_context:this})},_render:function(d){var c=this;this.el.update(d());CD.Polyfills.placeholder(this.el);this.form=this.el.select("form").first().enhanceform();this.elms={ctl_expand:this.el.select(".task-edit-expandctl").first(),ctl_save_quick:this.form.select('[type="submit"]').first()};CD.Polyfills.placeholder(this.el);this.fields.parent_id={handler:CD.UI.Forms.SelectField,default_options:[{id:"",label:"Loading...",disabled:true}],disabled:true};_.each(CD.UI.Initializer.initall(),function(e){this.fields[e.name()]=e},this);var b=new Validation(this.form,{immediate:false,onSubmit:false});this.bind("action:toggle",function(){this.expand(!this.is_expanded())});this.bind("action:clear",function(){c.clear()});this.bind("action:cancel",function(f){c.clear();this.expand(false)});this.el.on("form:submit",function(f){if(b.validate()){c.fields.title.focus();c.trigger("submit",f.memo.type);c.trigger("submit:"+f.memo.type)}});this.expand(this.options.expanded);return this},clear:function(){var b;for(b in this.fields){if(this.fields.hasOwnProperty(b)){this.fields[b].clear()}}},is_expanded:function(){return this.form.hasClassName("task-edit-st-expanded")},expand:function(b){if(b){this.form.addClassName("task-edit-st-expanded");this.elms.ctl_expand.update('<ins class="icon icon_collapse"></ins>Less options');this.elms.ctl_save_quick.disabled=true}else{this.form.removeClassName("task-edit-st-expanded");this.elms.ctl_expand.update('<ins class="icon icon_expand"></ins>More options');this.elms.ctl_save_quick.disabled=false}this.trigger(b?"expand":"collapse");return this}});ns("CD.TaskTemplate.View.Edit",a)}());(function(){var b=null;var a=["title","description","relative_startdate","duration","budgeted_time","priority","parent_id"];var c=CD.Widget.extend({cls:"wdg-task-edit",options:{expanded:false,tasktpl:null},initialize:function(d){var e=this;this.tasktpl=new CD.TaskTemplate.Model();this.view=new CD.TaskTemplate.View.Edit({el:this.el.content,expanded:d.expanded});this.view.bind("submit",this.submit,this);this.view.render();this.populate_parent_tasks(this.options.tasklisttpl_id);this.subscribe("CD.TaskTemplate.Model.*.Edit",this,function(g,f){this.open(f);this.view.expand(true)})},open:function(d){if(d){this.tasktpl=d;this.view.clear();this.sync_view();this.el.addClassName("task-edit-st-edit")}else{this.tasktpl=new CD.TaskTemplate.Model();this.view.clear();this.el.removeClassName("task-edit-st-edit")}this.populate_parent_tasks(this.options.tasklisttpl_id,this.tasktpl.get("pk_id"));this.view.fields.title.focus()},submit:function(e){if(this.view.fields.title.value()===""){return}var g=this;var d=_.isUndefined(this.tasktpl.id);var f={};if(e==="save-quick"){this.view.expand(false)}this.sync_model();this.tasktpl.set({fk_tasklisttemplateid:this.options.tasklisttpl_id},{silent:true});this.processing(true);this.tasktpl.save(null,{success:function(k,h){switch(e){case"save-and-add":g.view.fields.title.clear();g.view.fields.description.clear();break;case"save-full":case"save-quick":default:g.view.clear();g.view.expand(false)}g.tasktpl=new CD.TaskTemplate.Model();g.processing(false);g.populate_parent_tasks(g.options.tasklisttpl_id);g.view.fields.title.focus()},error:function(k,m,h){g.msg("error","Failed to save task");g.tasktpl=new CD.TaskTemplate.Model();g.processing(false);g.view.fields.title.focus()}})},sync_view:function(){var d,f,g,e={};for(d=0,l=a.length;d<l;d++){g=a[d];f=this.tasktpl.get(g);if(!_.isUndefined(f)&&!_.isNull(f)){this.view.fields[g].value(this.tasktpl.get(g))}}},sync_model:function(){var d,f,e={};for(d=0,l=a.length;d<l;d++){f=a[d];e[f]=this.view.fields[f].value()}this.tasktpl.set(e,{silent:true})},set_select_loading:function(d){d.input.options.length=0;this.add_to_select(d,true,"Loading...","");d.input.disabled=true},add_to_select:function(d,f,k,g){var h=document.createElement("option");h.text=k;h.value=g;if(f){h.selected=true}try{d.input.add(h,null)}catch(e){d.input.add(h)}},populate_parent_tasks:function(d,e){var f=this;if(f.view.fields.parent_id){f.set_select_loading(f.view.fields.parent_id)}var g=f.tasktpl.get("pk_id")||e;if(!d){return false}CD.Ajax.Request(this.tasktpl.url("taskparents"),{method:"post",parameters:{tasklist_id:d,task_id:g},onSuccess:function(k){var m,h=k.response.objects.length;f.view.fields.parent_id.input.options.length=0;if(h===1){f.add_to_select(f.view.fields.parent_id,true,"No Tasks","");f.view.fields.parent_id.input.disabled=true}else{for(m=0;m<h;m++){f.add_to_select(f.view.fields.parent_id,(f.tasktpl.get("parent_dependency")&&(k.response.objects[m].pk_id===f.tasktpl.get("parent_dependency").pk_id)),k.response.objects[m].title,k.response.objects[m].pk_id)}f.view.fields.parent_id.input.disabled=false}},onFailure:function(){cdwm.alert("Could not get valid parent Tasks for setting dependencies.");f.processing(false)}})}});ns("CD.TaskTemplate.Widget.Edit",c)}());(function(){var a={remove:function(b){if(!CD.permissions.canDelete(spid)){throw"User doesn't have permissions to delete Task Template"}console.log(b);CD.TaskTemplate.Model.find(b,{success:function(c){c.destroy()},error:function(){console.log("Failed to find task template",arguments)}})}};ns("CD.TaskTemplate.Actions",a)}());(function(){var a={edit:function(b){if(!CD.permissions.canEdit(spid)){cdwm.alert("User doesn't have permissions to edit Task Template");return false}console.log("Editing task template with id. To be implemented in CD.TaskTemplate.Actions.edit",b)},remove:function(b){if(!CD.permissions.canDelete(spid)){cdwm.alert("User doesn't have permissions to delete Task Template");return false}cdwm.confirm("Are you sure you want to delete this Task Template?",function(c){if(c){CD.TaskTemplate.Actions.remove(b)}})}};ns("CD.TaskTemplate.Dialogs",a)}());(function(){var a=CD.Widget.extend({view:null,collection:null,initialize:function(b){var e=CD.UI.Grid.List;cc=this.collection=this.options.tasktemplates;this.view=new e({el:this.el.content,collection:this.collection,selectable:false,columns:[{name:"title",title:"Title",html:function(f,g){return(f.escape("title")||"&mdash;")},cmpval:function(f){return String(f.get("title")||"")+""},sortable:true},{name:"relative_startdate",title:"Relative Start Date",html:function(f){var g=f.get("relative_startdate");if(g=="0"){return"+ 0 days"}return g?"+ "+g+" "+pluralize("day",g,"days"):"&mdash;"},cmpval:function(f){return String(f.get("relative_startdate")||"")},sortable:true},{name:"duration",title:"Duration",html:function(f){var g=f.get("duration");if(g=="0"){return"0 days"}return g?g+" "+pluralize("day",g,"days"):"&mdash;"},cmpval:function(f){return String(f.get("duration")||"")},sortable:true},{name:"budgeted_time",title:"Budgeted Time",html:function(f){var g=f.get("budgeted_time");return g?g+" "+pluralize("hr",g,"hrs"):"&mdash;"},cmpval:function(f){return String(f.get("budgeted_time")||"")},sortable:true}],actions:function(f){return{edit:{title:"Edit task template",icon:"icon_edit"},remove:{title:"Delete task template",icon:"icon_trash"}}},styles:{grid:function(f){return["tasklisttpl-grd"]},row:function(f){return["grd-row-pr"+f.get("priority")||"none"]}}});this.view.bind("sorted",function(g,f){this.state({sorting:[g,f]})},this);this.view.bind("action:edit",function(g){var f=this.collection.get(g);this.publish(f+".Edit",f)},this);this.view.bind("action:remove",CD.TaskTemplate.Dialogs.remove);this.subscribe("CD.TaskTemplate.Model.*.loaded",this,function(g,f){if(!this.collection.get(f.id)){this.collection.add(f)}});var d=this.state(),c=d.sorting||["relative_startdate",1];this.state({sorting:c});this.view.set_sort(c[0],c[1])}});ns("CD.TasklistTemplate.Widget.Grid",a)}());(function(){var a=["none","normal","medium","high"];function b(){return"<span></span><ins></ins>"}var c=CD.BaseView.extend({options:{titled:true,progress:0,priority:"normal"},tagName:"span",progress:function(d){if(_.isUndefined(d)){return this.options.progress}else{d=parseInt(d,10);if(isNaN(d)){throw new Error('Invalid progress value "'+d+'", should be 0..100')}d=Math.max(0,Math.min(100,d));this.options.progress=d;this.el.writeAttribute("title",d+"%");this.elms.text.update(d+"%");this.elms.bar.setStyle({width:d+"%"})}},priority:function(e){if(_.isUndefined(e)){return this.options.priority}else{var d=this;if(a.indexOf(e)===-1){e=a[0]}this.options.priority=e;a.each(function(f){d.el[f===e?"addClassName":"removeClassName"]("prg-"+f)})}},render:function(){this.el.update(b());this.elms={bar:this.el.select("ins").first(),text:this.el.select("span").first()};this.el.addClassName("prg prg-"+this.options.priority);if(this.options.titled){this.el.addClassName("prg-titled")}this.progress(this.options.progress,this.options.priority);return this}});ns("CD.Project.View.Progress",c)}());(function(){function a(b){return'<ul><li class="mlst-nav-hdr" id="mlst-nav-'+b+'"><ins class="mlst-expander icon icon_arrow_right_blue" title="Expand/Collapse Task Lists"></ins> <a href="#milestone-'+b+'" class="mlst-nav-title"></a> <ins class="icon icon_internal_use_only_red"></ins></li></ul>'}ns("CD.Milestone.View.Nav",CD.BaseView.extend({elms:null,expandable:false,expanded:false,internal:false,starting_value:0,text_value:false,priority:"normal",template:"milestone_nav_templ",navitems:null,tagName:"div",initialize:function(){this.elms={};this.navitems={}},render:function(){var c,b;var d=this;this.progressBar=new CD.Project.View.Progress({titled:false}).render();this.el.update(a(this.model.id));this.elms.ul=this.el.select("ul").first();this.elms.ul.addClassName("nav-sblist mlst-nav prj-sbar-collapsable");this.elms.header=this.el.select("li").first();this.elms.header.insert(this.progressBar.el);this.elms.title=this.el.select("a").first();this.elms.expandControl=this.el.select("ins.mlst-expander").first();this.elms.expandControl.on("click",function(f){d.toggle();f.stop()});this.elms.expandControl.hide();this.elms.icon=this.el.select("ins.icon_internal_use_only_red").first();if(!this.model.get("private")){this.elms.icon.hide()}this.render_items();c=this;b=$("mlst-nav-"+this.model.get("pk_id"));b=_.extend(b,CD.Droppable);b.setAttribute("data-id",this.model.get("pk_id"));b.initDroppable(CD.Controller.projects.getDropManager(),{canDropElement:function(e){return false},onDrop:function(g,f,e){return false},onMouseOver:function(g,f,e){this.dropManager.getDragManager().setDropValidity(false);if(!c.expanded&&c.expandable){this.startExpandTimer(function(){c.toggle()})}e.stop();return false},onMouseOut:function(g,f,e){this.stopExpandTimer()}});this.set_view_properties();return this},toggle:function(){var b=$(this.el).select("ins").first();if(this.expandable){this.expanded=!this.expanded;b.removeClassName("icon_arrow_right_blue");b.removeClassName("icon_arrow_down_blue");if(this.expanded){b.addClassName("icon_arrow_down_blue")}else{b.addClassName("icon_arrow_right_blue")}this.toggle_items();this.publish("CD.MilestonesList.toggled",{expanded:this.expanded})}},toggle_items:function(){var c,b=$(this.el).select("li");b.shift();for(c=0;c<b.length;c++){if(this.expanded){b[c].show()}else{b[c].hide()}}},set_view_properties:function(){var b=this.model.tasklists.models;this.expandable=(b.length>0);this.expanded=(this.expandable&&this.expanded);this.starting_value=this.model.calculateProgress();if(this.model.get("overdue")){this.priority="high"}else{if(this.starting_value===100&&this.model.get("complete")){this.priority="normal"}else{this.priority="medium"}}var c=this.model.escape("title");if(!this.model.get("completed")){c+=" - Due on "+this.model.get("duedate")}this.elms.title.title=c;this.elms.title.update(this.model.escape("title"));this.elms.icon[this.model.get("private")?"show":"hide"]();this.progressBar.progress(this.starting_value);if(this.model.get("completed")){this.progressBar.priority("normal")}else{if(this.model.get("overdue")){this.progressBar.priority("high")}else{this.progressBar.priority("medium")}}this.render_control()},render_control:function(){if(this.expandable){this.elms.expandControl.show()}else{this.elms.expandControl.hide()}},render_items:function(){var c,d=this;var b=this.elms.ul;b.select("li").each(function(e){if(!e.hasClassName("mlst-nav-hdr")){e.remove()}});this.navitems={};this.model.tasklists.each(function(e){c=e.mkview("navitem");b.insert(c.el);d.navitems[e.get("pk_id")]=c;if(!d.expanded){c.el.hide()}})},select_nav_item:function(b){if(!this.expanded){this.toggle()}this.navitems[b].select(true)}}))}());(function(){ns("CD.Milestone.View.List",CD.Template.View.extend({nav_items:{},expandable:false,expanded:false,title:"Milestones",template:"milestones_list_templ",initialize:function(a){CD.Template.View.prototype.initialize.call(this,arguments);this.widget=a.widget},render:function(){CD.Template.View.prototype.render.call(this);this.el.select("a").first().observe("click",function(a){a.preventDefault();this.toggle()}.bind(this));this.set_view_properties();return this},sync_nav_items:function(){var c;var k=this.model.models;var b;var a=[];for(c=0;c<k.length;c++){b=k[c].get("pk_id");if(!this.nav_items[b]){var d=new CD.Milestone.Widget.Nav({model:this.model.models[c]});this.nav_items[b]=d;this.el.select("div#milestones-nav").first().insert(this.nav_items[b].el);this.nav_items[b].view.render()}a.push(b)}var g=Object.keys(this.nav_items);for(c=0;c<g.length;c++){g[c]=parseInt(g[c],10)}var h=g.filter(function(e){return a.indexOf(e)>-1?false:true},a);for(c=0;c<h.length;c++){try{this.nav_items[h[c]].el.remove()}catch(f){}}this.set_view_properties()},set_view_properties:function(){var b=Object.keys(this.nav_items).length<1;if(b){this.el.setAttribute("style","display:none;")}else{this.el.setAttribute("style","display:null;")}this.expandable=!b;this.expanded=(this.expandable&&this.expanded);var a=$("milestones-list");if(this.model.models.length>0){a.setStyle({display:""})}else{a.setStyle({display:"none"})}this.render_control()},render_control:function(){var a=$(this.el).select("a").first();if(this.expandable){a.innerHTML=this.expanded?'Collapse All<ins class="icon icon_collapse"></ins>':'Expand All<ins class="icon icon_expand"></ins>'}},toggle:function(){var b,a=false;for(b in this.nav_items){if(this.nav_items.hasOwnProperty(b)){if(this.nav_items[b].view.expandable){a=true;this.publish("CD.MilestonesList.toggled",{expanded:!this.expanded,force_children:true});break}}}if(!a){this.publish("CD.MilestonesList.toggled",{expanded:true})}}}))}());(function(){var a=CD.Template.View.extend({template:"milestones_detail_templ",auditLog:null,initialize:function(b){CD.Template.View.prototype.initialize.call(this,b);this.tasklists=b.model.tasklists},render:function(){var b=this;CD.Template.View.prototype.render.call(this);this.rendered=true;this.elms={root:this.el,title:this.el.select(".mlst-detail-title").first(),complete:this.el.select(".mlst-detail-complete").first(),progress:this.el.select(".mlst-detail-progress").first(),completedon:this.el.select(".mlst-detail-completedon")};this.elms.title.update(this.model.mkview("inline").el);this.progressBar=new CD.Project.View.Progress().render();this.elms.progress.update(this.progressBar.el);if(this.elms.complete){this.elms.complete.on("click",function(){b.trigger("toggle-complete")})}this.render_comments();this.update();this.model.viewed()},render_comments:function(){var d=this;var c=new Element("div",{"class":"m15"});this.el.insert(c);var b=new CD.UI.Helpers.Tabstrip({el:c,tabs:[{className:"comments",name:"milestoneComments",title:"Comments",count:d.model.get("num_replies"),loader:d.loadCommentsTab.bind(d),headings:[{className:"author",text:"Author"},{className:"version",text:"Date"},{className:"comment",text:"Comment"}]},{className:"audit-log",name:"milesoneAuditLog",title:"Audit Log",countEnabled:false,loader:d.loadAuditLogTab.bind(d),headings:[{className:"when",text:"When?"},{className:"who",text:"Who?"},{className:"what",text:"What?"}]}]});b.render()},update:function(){var c=this;var b=this.model.get("completed");var d=CD.UI.Helpers.Dates.date(this.model.get("completedon"));this.el[b?"addClassName":"removeClassName"]("mlst-detail-st-completed");if(this.elms.complete){this.elms.complete.value=(b?"Re-open Milestone":"Complete Milestone")}this.el[this.model.get("startdate")?"addClassName":"removeClassName"]("mlst-detail-st-hasstart");this.elms.completedon.each(function(e){e.update(d)});this.progressBar.progress(this.model.calculateProgress("progress"));if(b){this.progressBar.priority("normal")}else{if(this.model.get("overdue")){this.progressBar.priority("high")}else{this.progressBar.priority("medium")}}},loadCommentsTab:function(b,e){var d=this,c=d.model.url("comments"),f={doaction:"getComments",format:"jsonenv",spid:d.model.get("fk_spaceid"),showAddForm:d.options.showCommentForm?"true":"false"};CD.Ajax.Request(c,{method:"get",parameters:f,onSuccess:function(k){try{var g=b.setContent(k.response.content,e);g.show();var h=g.select('textarea[name="comment_comment"]').first();if(h.id==="comment_comment"){h.id=CD.Comment.UI.generateId()}b.setCount(k.response.count);tinyMCE.execCommand("mceRemoveControl",false,h.id);tinyMCE.execCommand("mceAddControl",false,h.id);var n=dom.utils.getElementTop(h.parentNode);window.scrollTo(0,n);if($$("span.cmt-toggle a.jslink")[1]){setTimeout(function(){d.triggerEvent($$("span.cmt-toggle a.jslink")[1],"click")},100)}try{tinyMCE.execInstanceCommand(h.id,"mceFocus")}catch(m){}CD.Comment.UI.addEvents({spaceid:spid,activity_type:CD.ACTIVITY_TYPE_MILESTONE,parentElem:b.el,callbacks:{onSaveNew:function(p){var o=b.getSelectedTab();b.setCount(o.count+1);if(p.complete_milestone){d.model.set({completed:true});d.model.save({success:function(r,q){d.render(r)}})}},onSaveEdit:function(o){},onCancel:function(o){},onDelete:function(o){var p=b.getSelectedTab();b.setCount(p.count-1)}}})}catch(m){}},onFailure:function(g){}})},loadAuditLogTab:function(d){var b,c,e=this;if(!this.auditLogWidget){b=new Element("div");d.setContent(b,d.getTab("auditLog"));this.auditLogWidget=new CD.AuditLog.Widget.Grid({placeholder:b,refModel:e.model})}else{d.showTabContent(d.getTab("auditLog"))}},triggerEvent:function(d,c){if(document.createEvent){var b=document.createEvent("HTMLEvents");b.initEvent(c,true,true);return d.dispatchEvent(b)}if(d.fireEvent){return d.fireEvent("on"+c)}}});ns("CD.Milestone.View.Detail",a)}());(function(){ns("CD.Milestone.View.Edit",CD.Template.View.extend({template:"milestones_edit_templ",tasklists:null,form:null,fields:null,initialize:function(a){CD.Template.View.prototype.initialize.call(this,a);this.options=a;this.is_edit=a.is_edit;this.fields={}},clear:function(){_.each(this.fields,function(b,a){b.clear()})},render:function(){var b=this;CD.Template.View.prototype.render.call(this);this.rendered=true;if(CD.Environment.user.is_internal){this.el.select("div#internal_option").first().removeClassName("hidden")}this.form=this.el.select("form").first();this.populate_fields();this.fields.title.focus();var a=new Validation(this.form,{immediate:true,onSubmit:false});this.form.on("submit",function(c){c.stop();if(a.validate()){b.trigger("submit");b.fields.title.focus()}})},populate_fields:function(){var a=this;CD.UI.Initializer.initall(this.form).each(function(b){if(b.input){a.fields[b.input.name]=b}});["assignees","cc"].each(function(b){var c={handler:CD.UI.Forms.ObjectField,picker:function(){return new CD.UI.Pickers.Simple({source:new CD.UI.Pickers.Sources.Collection({collection:a.options.users,label_field:"fullname"})})}};a.fields[b]=CD.UI.Initializer.init(a.form[b],c)});a.fields.startdate.bind("datechange",function(c,b){if(c&&c!==a.options.model.get("startdate")){if(!a.fields.duedate.value()){a.fields.duedate.value(c);setTimeout(function(){if(!a.fields.duedate.value()){a.fields.duedate.showCalendar()}},100)}if(a.options.model.get("startdate")){$$("div.mlst-edit-shift")[0].show()}}else{if(c&&a.fields.duedate.value()==a.options.model.get("duedate")){$$("div.mlst-edit-shift")[0].hide()}}});a.fields.duedate.bind("datechange",function(b,c){if(b&&a.options.model.get("duedate")&&b!==a.options.model.get("duedate")){$$("div.mlst-edit-shift")[0].show()}else{if(b&&a.fields.startdate.value()==a.options.model.get("startdate")){$$("div.mlst-edit-shift")[0].hide()}}})}}))}());(function(){var a=CD.BaseView.extend({tagName:"span",cls:"mlst-view-inline",watch_model:["overdue","title"],options:{noicon:false,maxlen:100},render:function(){var b;if(!this.model){this.el.update("[no Milestone model]");return this}this.el.update();if(!this.options.noicon){b=CD.UI.Helpers.Icons.icon(this.model.get("overdue")?"icon_milestone_overdue":"icon_milestone");b.setStyle({top:"-3px",position:"relative"});this.el.insert(b)}this.el.insert(this.el.title=this.model.escape("title"));return this}});ns("CD.Milestone.View.Inline",a)}());(function(){var a=CD.BaseView.extend({render:function(){if(!this.model){this.el.update("[no Milestone model]");return this}this.el.update();var b=new Element("span");this.el.insert(b);var c="Milestone";c+=(this.model.get("private"))?" (Internal Use Only)":"";b.insert(c);return this}});ns("CD.Milestone.View.Meta",a)}());(function(){ns("CD.Milestone.Widget.Nav",CD.Widget.extend({initialize:function(a){if(!a.model){throw"You must specify a widget model"}a.starting_value=a.starting_value||0;this.view=new CD.Milestone.View.Nav({el:this.el.content,starting_value:a.starting_value,model:a.model});this.setupSubscriptions();this.processing(false)},setupSubscriptions:function(){this.subscribe("CD.Tasklist.Model.*.selected",this,this.onSelected);this.subscribe("CD.Milestone.Model.*.selected",this,this.onSelected);this.subscribe(this.view.model.tasklists+".changed",this,function(a,c,b){this.view.render_items();this.view.set_view_properties()});this.subscribe(this.view.model+".changed",this,function(a,c,b){this.view.set_view_properties()});this.subscribe("CD.Tasklist.Model.*.deleted",this,this.updateModel);this.subscribe("CD.Tasklist.Model.*.changed",this,this.updateModel)},updateModel:function(a,c,b){this.view.set_view_properties()},onSelected:function(a,d,c){var e;$(this.view.el).select(".selected").each(function(f){f.removeClassName("selected")});if(d instanceof CD.Tasklist.Model){if(this.view.navitems[d.id]){this.view.select_nav_item(d.id)}}else{if(d instanceof CD.Milestone.Model){e="mlst-nav-"+d.get("pk_id");var b=$(e);if(b){b.addClassName("selected")}}}}}))}());(function(){ns("CD.Milestone.Widget.List",CD.Widget.extend({cls:"myinstance",initialize:function(a){if(!a.model){throw"You must specify a widget model"}this.view=new CD.Milestone.View.List({el:this.el.content,model:a.model,widget:this});this.view.render();this.setupSubscriptions();this.processing(false)},setupSubscriptions:function(){this.subscribe(this.view.model+".changed",this,function(a,c,b){this.view.sync_nav_items()});this.subscribe("CD.Milestone.Model.*.deleted",this,function(b,d,c){var a,e=d.get("pk_id");for(a in this.view.nav_items){if(this.view.nav_items.hasOwnProperty(a)){if(this.view.nav_items[e]){this.view.sync_nav_items();break}}}});this.subscribe("CD.MilestonesList.toggled",this,function(b,e,c){var a;var d=false;if(e.force_children){this.view.expanded=e.expanded}for(a in this.view.nav_items){if(this.view.nav_items.hasOwnProperty(a)){if(e.force_children){if(this.view.nav_items[a].view.expanded!==this.view.expanded){this.view.nav_items[a].view.toggle()}}else{d=d||this.view.nav_items[a].view.expanded}}}if(!e.force_children){this.view.expanded=d||e.expanded}this.view.render_control()});this.subscribe("CD.Tasklist.Model.*.selected",this,this.onSelected);this.subscribe("CD.Milestone.Model.*.selected",this,this.onSelected)},onSelected:function(b,f,d){var g,e,c=this;if(f instanceof CD.Milestone.Model){e=f.id;this.view.expanded=false;var a=$("mlst-nav-"+e);if(a){this.view.expanded=true;if(!this.view.nav_items[e].view.expanded){this.view.nav_items[e].view.toggle()}}}if(f instanceof CD.Tasklist.Model){e=f.get("fk_milestoneid");if(e){this.view.expanded=false;a=$("mlst-nav-"+e);if(a){this.view.expanded=true;if(!this.view.nav_items[e].view.expanded){this.view.nav_items[e].view.toggle()}}}this.view.set_view_properties()}}}))}());(function(){ns("CD.Milestone.Widget.Nav",CD.Widget.extend({initialize:function(a){if(!a.model){throw"You must specify a widget model"}a.starting_value=a.starting_value||0;this.view=new CD.Milestone.View.Nav({el:this.el.content,starting_value:a.starting_value,model:a.model});this.setupSubscriptions();this.processing(false)},setupSubscriptions:function(){this.subscribe("CD.Tasklist.Model.*.selected",this,this.onSelected);this.subscribe("CD.Milestone.Model.*.selected",this,this.onSelected);this.subscribe(this.view.model.tasklists+".changed",this,function(a,c,b){this.view.render_items();this.view.set_view_properties()});this.subscribe(this.view.model+".changed",this,function(a,c,b){this.view.set_view_properties()});this.subscribe("CD.Tasklist.Model.*.deleted",this,this.updateModel);this.subscribe("CD.Tasklist.Model.*.changed",this,this.updateModel)},updateModel:function(a,c,b){this.view.set_view_properties()},onSelected:function(a,d,c){var e;$(this.view.el).select(".selected").each(function(f){f.removeClassName("selected")});if(d instanceof CD.Tasklist.Model){if(this.view.navitems[d.id]){this.view.select_nav_item(d.id)}}else{if(d instanceof CD.Milestone.Model){e="mlst-nav-"+d.get("pk_id");var b=$(e);if(b){b.addClassName("selected")}}}}}))}());(function(){ns("CD.Milestone.Widget.List",CD.Widget.extend({cls:"myinstance",initialize:function(a){if(!a.model){throw"You must specify a widget model"}this.view=new CD.Milestone.View.List({el:this.el.content,model:a.model,widget:this});this.view.render();this.setupSubscriptions();this.processing(false)},setupSubscriptions:function(){this.subscribe(this.view.model+".changed",this,function(a,c,b){this.view.sync_nav_items()});this.subscribe("CD.Milestone.Model.*.deleted",this,function(b,d,c){var a,e=d.get("pk_id");for(a in this.view.nav_items){if(this.view.nav_items.hasOwnProperty(a)){if(this.view.nav_items[e]){this.view.sync_nav_items();break}}}});this.subscribe("CD.MilestonesList.toggled",this,function(b,e,c){var a;var d=false;if(e.force_children){this.view.expanded=e.expanded}for(a in this.view.nav_items){if(this.view.nav_items.hasOwnProperty(a)){if(e.force_children){if(this.view.nav_items[a].view.expanded!==this.view.expanded){this.view.nav_items[a].view.toggle()}}else{d=d||this.view.nav_items[a].view.expanded}}}if(!e.force_children){this.view.expanded=d||e.expanded}this.view.render_control()});this.subscribe("CD.Tasklist.Model.*.selected",this,this.onSelected);this.subscribe("CD.Milestone.Model.*.selected",this,this.onSelected)},onSelected:function(b,f,d){var g,e,c=this;if(f instanceof CD.Milestone.Model){e=f.id;this.view.expanded=false;var a=$("mlst-nav-"+e);if(a){this.view.expanded=true;if(!this.view.nav_items[e].view.expanded){this.view.nav_items[e].view.toggle()}}}if(f instanceof CD.Tasklist.Model){e=f.get("fk_milestoneid");if(e){this.view.expanded=false;a=$("mlst-nav-"+e);if(a){this.view.expanded=true;if(!this.view.nav_items[e].view.expanded){this.view.nav_items[e].view.toggle()}}}this.view.set_view_properties()}}}))}());(function(){var a=["title","description","startdate","duedate","reminders","assignees","cc","notify_assignees","private","shift_subsequent_milestones","shift_subsequent_tasks","parent_milestone"];var c=$H({title:"title",description:"description",startdate:"startdate",duedate:"duedate",assignees:"assignedto",reminders:"reminders",cc:"ccto",notify_assignees:"notify_assignees","private":"private",shift_subsequent_milestones:"shift_subsequent_milestones",shift_subsequent_tasks:"shift_subsequent_tasks",parent_milestone:"parent_id"});function d(h,g,f){f.each(function(k){g.fields[k].value(h.get(c.get(k)))})}function b(h,g,f){var k={};f.each(function(m){k[c.get(m)]=g.fields[m].value()});h.set(k,{silent:true})}function e(){var h=this;var k=this.view.model;k.set({fk_spaceid:CD.Environment.space.id},{silent:true});var g=k.get("parent_id");b(k,this.view,a);this.view.clear();this.processing(true);var f=CD.Controller.projects.getMilestoneCollection();k.save(null,{reqsuccess:function(s,o,u){if(!f.get(s.get("pk_id"))){f.add(s)}var t=function(x){var y=parseInt(x);if(y>0&&y!=="NaN"){var w=CD.Store.Milestone.getInstance();w.getRecord(x,{success:function(z){z.fetch()},error:function(z){console.log("failed to reload milestone parent to set dependent")}})}};if(g!==s.get("parent_id")){t(g)}t(s.get("parent_id"));var r=s.get("shift_subsequent_milestones");var n=s.get("shift_subsequent_tasks");if(r||n){var v=u.meta;if(v){var q,p,m;for(q=0;q<v.milestones.length;q++){p=v.milestones[q];CD.Milestone.Model.find(p.pk_id,{success:function(w){w.set(p)}})}for(q=0;q<v.tasks.length;q++){m=v.tasks[q];CD.Task.Model.find(m.pk_id,{success:function(w){w.set(m)}})}}}h.processing(false);CD.Project.Router.navigate("#milestone-"+s.get("pk_id"),true)},error:function(n,o,m){console.log("failed to save milestone",n);h.processing(false);h.view.fields.title.focus()}})}ns("CD.Milestone.Widget.Edit",CD.Widget.extend({initialize:function(g){var f=true;if(!g.model){g.model=new CD.Milestone.Model();f=false}this.view=new CD.Milestone.View.Edit({el:this.el.content,model:g.model,tasklists:g.model.tasklists,users:g.users,is_edit:f});this.view.bind("submit",e.bind(this));this.view.render();if(f){var o={};var k=this.view.model.get("startdate");var m=this.view.model.get("duedate");if(k){k=new Date(k);o.startdate=CD.UI.Helpers.Dates.date(k)}m=new Date(m);o.duedate=CD.UI.Helpers.Dates.date(m);this.view.model.set(o,{silent:true});d(this.view.model,this.view,a)}this.processing(false);var h=this.view.model.get("pk_id");var n=this;n.set_select_loading(this.view.fields.parent_milestone);CD.Ajax.Request(this.view.model.url("milestoneparents"),{method:"post",parameters:{milestone_id:h},onSuccess:function(q){var r,p=q.response.objects.length;n.view.fields.parent_milestone.input.options.length=0;if(p===1){n.add_to_select(n.view.fields.parent_milestone,true,"No Milestones","");n.view.fields.parent_milestone.input.disabled=true}else{for(r=0;r<p;r++){n.add_to_select(n.view.fields.parent_milestone,(q.response.objects[r].pk_id===n.view.model.get("parent_id")),q.response.objects[r].title,q.response.objects[r].pk_id)}n.view.fields.parent_milestone.input.disabled=false}},onFailure:function(){cdwm.alert("Could not get valid parent Milestones for setting dependencies.")}})},set_select_loading:function(f){f.input.options.length=0;this.add_to_select(f,true,"Loading...","");f.input.disabled=true},add_to_select:function(f,h,n,k){var m=document.createElement("option");m.text=n;m.value=k;if(h){m.selected=true}try{f.input.add(m,null)}catch(g){f.input.add(m)}}}))}());(function(){ns("CD.Milestone.Widget.Detail",CD.Widget.extend({options:{showComments:true,showCommentForm:false},initialize:function(a){if(!a.model){throw"You must specify a widget model"}var b=new CD.Milestone.View.Detail({el:this.el.content,model:a.model,showComments:this.options.showComments,showCommentForm:this.options.showCommentForm});b.bind("toggle-complete",function(){a.model.save({completed:!a.model.get("completed")})});b.render();this.processing(false);this.subscribe(a.model+".changed",this,function(c,d){b.update()})}}))}());(function(){ns("CD.Gantt.View",CD.Template.View.extend({template:"gantt_templ",initialize:function(a){this.urlParams=a.urlParams;CD.Template.View.prototype.render.call(this,a)}}))}());(function(){ns("CD.Gantt.Widget",CD.Widget.extend({initialize:function(a){var c="ganttframe";var b="",f="";var e={tasklist_id:0,milestone_id:0,startDate:null,endDate:null,space:null,editable:false,report:null,interactive:false};for(var d in e){if(a.hasOwnProperty(d)){e[d]=a[d]}}if(typeof a.report_criteria!=="undefined"){delete a.placeholder;e.report=a;e.report.type=a.type}if(document.location.search.length>0){f=document.location.search.substr(1)}b+=[f,"ganttdata="+encodeURI(JSON.stringify(e))].join("&");if(b.length>0){c+="?"+b}$("view").removeClassName("hidden");if(!this.view){this.view=new CD.Gantt.View({el:this.el.content})}$("ganttiframe").src=c}}))}());(function(){var a=["none","normal","medium","high"];function b(){return"<span></span><ins></ins>"}var c=CD.BaseView.extend({options:{titled:true,progress:0,priority:"normal"},tagName:"span",progress:function(d){if(_.isUndefined(d)){return this.options.progress}else{d=parseInt(d,10);if(isNaN(d)){throw new Error('Invalid progress value "'+d+'", should be 0..100')}d=Math.max(0,Math.min(100,d));this.options.progress=d;this.el.writeAttribute("title",d+"%");this.elms.text.update(d+"%");this.elms.bar.setStyle({width:d+"%"})}},priority:function(e){if(_.isUndefined(e)){return this.options.priority}else{var d=this;if(a.indexOf(e)===-1){e=a[0]}this.options.priority=e;a.each(function(f){d.el[f===e?"addClassName":"removeClassName"]("prg-"+f)})}},render:function(){this.el.update(b());this.elms={bar:this.el.select("ins").first(),text:this.el.select("span").first()};this.el.addClassName("prg prg-"+this.options.priority);if(this.options.titled){this.el.addClassName("prg-titled")}this.progress(this.options.progress,this.options.priority);return this}});ns("CD.Project.View.Progress",c)}());(function(){function a(){return'<div class="project-meta"><h2></h2><a class="project-meta-dd-control"><span class="project-meta-edit"><ins class="icon icon_edit"></ins><ins class="dropdown-arrow"></ins></span></a><ul class="dd-list" id="dd_projectmeta_content" style="display:none"></ul><span class="pin-right project-meta-actions"></span></div>'}var b=CD.BaseView.extend({options:{title:"",is_private:false,edit_actions:[],shortcut_actions:[]},initialize:function(c){this.model=this.model||c.model},update:function(c){var e=this;c=_.extend({},this.options,c);if(c.title){this.elms.title.update(c.title)}if(c.is_private){this.elms.container.addClassName("project-meta-private")}else{this.elms.container.removeClassName("project-meta-private")}if(c.edit_actions.length){var d=CD.UI.Helpers.Dropdown.mklist(c.edit_actions);this.elms.dropdown.update();d.select("li").each(function(f){e.elms.dropdown.insert(f)});this.elms.container.removeClassName("project-meta-noedit")}else{this.elms.container.addClassName("project-meta-noedit")}if(c.shortcut_actions.length){this.elms.actions.update();c.shortcut_actions.each(function(f){e.elms.actions.insert(CD.UI.Helpers.Icons.action(f))});this.elms.container.removeClassName("project-meta-noactions")}else{this.elms.container.addClassName("project-meta-noactions")}},render:function(){this.el.update(a());var c=this.el.firstDescendant();this.elms={container:c,title:c.select("h2").first(),dropdown:c.select("ul").first(),actions:c.select(".project-meta-actions")[0],ddControl:c.select("a.project-meta-dd-control")[0]};this.elms.ddControl.observe("click",function(d){d.stop();CapDropdown.show(this,"dd_projectmeta")});return this}});ns("CD.Project.View.Meta",b)}());(function(){ns("CD.Project.Widget.Meta",CD.Widget.extend({initialize:function(c){var e=this;var b=new CD.Project.View.Meta({el:this.el.content});var f="";var a=null;b.render();function d(h,g){f="show";a=g;var p=g.meta();p.shortcut_actions.push("exportcsv");p.shortcut_actions.push("importcsv");if($$(".proj-arch-banner .obj-name").length>0){var k=$$(".proj-arch-banner .obj-name")[0];var o="";switch(g.ns()){case"CD.Task.Model":o="Task";break;case"CD.Tasklist.Model":o="Task List";break;case"CD.Milestone.Model":o="Milestone";break}k.update(o);k.up(".proj-arch-banner").removeClassName("bl-dynamic")}function n(q){return p.actions[q]}var m=g.get("private");if((g instanceof CD.Task.Model)&&g.isPersonal()){m=false}b.update({title:g.mkview("meta").el,is_private:m,edit_actions:p.edit_actions.collect(n).compact(),shortcut_actions:p.shortcut_actions.collect(n).compact()});e.processing(false)}["Task","Tasklist","Milestone"].each(function(g){e.subscribe("CD."+g+".Model.*.show",e,d);e.subscribe("CD."+g+".Model.*.changed",e,function(k,h){if(f==="show"&&a===h){a=h;d(k,h)}})});this.subscribe("CD.Milestone.Model.new.create",this,function(h,g){f="create";e.processing(false);b.update({title:"Creating milestone"})});this.subscribe("CD.Milestone.Model.*.edit",this,function(h,g){f="edit";b.update({title:'<span class="grey">Editing: </span>'+g.escape("title"),is_private:g.get("private")})});this.subscribe("CD.Task.Model.*.edit",this,function(k,h){f="edit";var g=h.get("fk_tasklistid");if(g){CD.Tasklist.Model.find(g,{success:function(m){d(m+".show",m);b.update({is_private:h.get("private"),edit_actions:[]})},error:function(){console.log("tasklist not found: ",g)}})}else{b.update({title:"Personal task",is_private:false});e.processing(false)}})}}))}());(function(){var a=CD.BaseView.extend({tagName:"span",options:{noicon:false,maxlen:100},render:function(){if(!this.model){this.el.update("[no Space model]");return this}this.el.update();if(!this.options.noicon&&!this.model.get("private")){this.el.insert(CD.UI.Helpers.Icons.icon("icon_workspace_public"))}this.el.insert(this.model.escape("longname").truncate(this.options.maxlen,"..."));return this}});ns("CD.Space.View.Inline",a)}());(function(){(function(){var e=null;var d=function(h,g){h.setVal(g||"(!) Error")};var b=function(m){var k=m.up(".tgrd-row");var g=k?parseInt(k.data("id"))||null:null;if(g===null){throw"No expilink id"}CD.Expilink.Model.find(g,{success:function(n){e=n}});if(!e){throw"No expilink"}var h=e.get(this.name.replace(/^expl/,""));return isNaN(Date.parse(h))?"None":h};var f=function(g){if(Date.parse(g.toString().strip())<(new Date)){alert("Expiration date should be in future");return false}return true};var c=function(h,g){if(!e){console.warn("Missing task model");return d}g=isNaN(Date.parse(g))?"":g;e.save({expires:g});return function(k){k.setVal('<ins class="ajax-loader"></ins>')}};C2EGenericHandler.registerType("explexpires",C2EDateEditor,c,f,b)}());var a=CD.BaseView.extend({cls:"exl-list",options:{links:null},grid:null,initialize:function(){this.grid=new CD.UI.Grid.Table({el:this.el,selectable:false,collection:this.options.links,rightname:"Delete",columns:[{name:"title",title:"Name / Shared with",html:function(b,c){return b.escape("title")||"&mdash;"}},{name:"expires",title:"Expires",html:function(b,c){return b.get("expires")?CD.UI.Helpers.Dates.date(b.escape("expires")):"Never"}},{name:"link",title:"Link",html:function(b,c){return'<input type="text" value="'+b.escape("url")+'" readonly="readonly" />'}},{name:"createdby",title:"Created by",html:function(b,c){return b.escape("createdby_label")}},{name:"used",title:"Accessed",html:function(b,c){return CD.UI.Helpers.Dates.date(b.escape("used"))||"Never"}}],actions:function(b){return{remove:{title:"Delete link",icon:"icon_trash"}}},styles:{row:function(b){return(b.get("expires")&&b.get("expired"))?["exl-row-expired"]:[]},cell:function(c,d){var b=[];if((d==="expires"&&!c.get("expires"))||(d==="used"&&!c.get("used"))){b.push("exl-cell-inactive")}if(d==="expires"){b.push("c2e");b.push("c2e-gnr-explexpires")}return b}}});this.bind("action:remove",CD.Expilink.Dialogs.remove);this.el.on("click",function(c){var b=c.element();if(b.tagName.toLowerCase()==="input"){b.select&&b.select()}});this.grid.bind("rendered",function(){setTimeout(function(){C2EManager.init()},100)})}});ns("CD.Expilink.View.List",a)}());(function(){var a=Backbone.Router.extend({routes:{"task-:id":"show_task","edit-task-:id":"edit_task","add-task-comment-:id":"task_add_comment"},show_task:function(d,b){var c=this;b=b||{};CD.Task.Model.find(d,{success:function(e){var f=e.get("fk_tasklistid");if(e.get("title")===""){CD.Project.Router.navigate("",true);return}if(f){CD.Tasklist.Model.find(f,{success:function(g){PageBus.publish("CD.Task.Model."+d+".showPanel",{model:e,options:b});PageBus.publish(g+".selected",g);PageBus.publish(e+".selected",e);PageBus.publish(e+".show",e)},error:function(){console.log("Show Task Route: did not find tasklist "+f,arguments)}})}else{PageBus.publish(e+".showPanel",{model:e,options:b});PageBus.publish(e+".selected",e);PageBus.publish(e+".show",e)}}})},edit_task:function(c){var b=this;CD.Task.Model.find(parseInt(c,10),{success:function(d,f){var e=d.get("fk_tasklistid");if(e){CD.Tasklist.Model.find(e,{success:function(h,g){PageBus.publish(h+".selected",h)},error:function(g){cdwm.alert("Requested Task was not found")}})}PageBus.publish(d+".showEditPanel",d)}})},task_add_comment:function(b){this.show_task(b,{showCommentForm:true})}});ns("CD.Project.Router");CD.Project.Router=new a()}());(function(){var u=null;var r=new CD.Tasklist.Collection();var n=new CD.Milestone.Collection();var s=new CD.User.Collection();var h=new CD.Space.Collection();var b=null;var o=null;var m=[];var e=1;var q=null;var g=[];var c;var p={};isArchive=(document.location.search==="?archive");isMyTasks=(document.location.search==="?mytasks");var d=new CD.Drag(null,true,"selected");var f=new CD.Drop(d);function t(){if(isArchive){if(r.models.length<1){b.el.setStyle({display:"none"})}}}function k(){if(isArchive){if(n.models.length<1){o.el.setStyle({display:"none"})}}}function a(){CD.Project.Router.route("","default",function(){if(!isArchive){var v=CD.Store.Tasklist.getInbox();if(v!==null){this.navigate("tasklist-"+v.id,true)}}else{if(r.models.length>0){this.navigate("tasklist-"+r.models[0].id,true)}else{if(n.models.length>0){this.navigate("milestone-"+n.models[0].id,true)}else{document.location.href=document.location.pathname}}}});CD.Project.Router.route(/^tasklist\-([0-9]+)(\/([0-9]+)\-([0-9]+)(\/([a-z\_]+)\-(asc|desc))?)?$/,"tasks",function(){var v=arguments,x=arguments[0],w=this;t();k();if(parseInt(x,10)!=="NaN"){CD.Tasklist.Model.find(x,{success:function(y){if(parseInt(y.get("fk_spaceid"),10)===parseInt(spid,10)){PageBus.publish(y+".showPanel",{tasklist:y,incompletePageNum:v[2],completedPageNum:v[3],sortBy:v[5],sortDir:v[6]});PageBus.publish(y+".show",y);PageBus.publish(y+".selected",y);window.scrollTo(0,0)}else{w.navigate("",true)}}})}});CD.Project.Router.route(/^tasks\-by\-assignee\-([0-9]+)(\/([0-9]+)\-([0-9]+)(\/([a-z\_]+)\-(asc|desc))?)?$/,"tasks-by-assignee",function(){var w=parseInt(arguments[0],10);var v=s.get(w);if(v){var x=p.byuser;x.set_request_params({user:w});x.options.filter.getvalue=function(){return v.mkview("inline",{maxlen:20}).el};x.options.filter.getkey=function(){return w};PageBus.publish(x+".showPanel",{tasklist:x,incompletePageNum:arguments[2],completedPageNum:arguments[3],sortBy:arguments[5],sortDir:arguments[6]});PageBus.publish(x+".selected",x);PageBus.publish(x+".show",x)}});if(CD.Environment.company.tagging){CD.Project.Router.route(/^tasks\-by\-tag\-([a-z\_0-9]+)(\/([0-9]+)\-([0-9]+)(\/([a-z\_]+)\-(asc|desc))?)?$/,"tasks-by-tag",function(){var v=arguments[0];var w=p.bytag;w.set_request_params({tag:v});w.options.filter.value=CD.UI.Helpers.Icons.prepend_icon("icon_tag",(new Element("span")).update(v)).getOuterHTML();w.options.filter.getkey=function(){return v};PageBus.publish(w+".showPanel",{tasklist:w,incompletePageNum:arguments[2],completedPageNum:arguments[3],sortBy:arguments[5],sortDir:arguments[6]});PageBus.publish(w+".selected",w);PageBus.publish(w+".show",w)})}CD.Project.Router.route("milestone-:id","milestone",function(w){var v=CD.Project.Router;t();k();if(parseInt(w)!=="NaN"){CD.Milestone.Model.find(w,{success:function(x){PageBus.publish(x+".showPanel",x);PageBus.publish(x+".selected",x);PageBus.publish(x+".show",x);window.scrollTo(0,0)}})}});CD.Project.Router.route("milestoneedit-:id","milestone-edit",function(w){var v=this;if(w==="new"){PageBus.publish("CD.Milestone.Model.new.create");CD.Controller.projects.showMilestoneEditPanel();return}else{if(parseInt(w)!=="NaN"){CD.Milestone.Model.find(w,{success:function(x){PageBus.publish(x+".showEditPanel",x);PageBus.publish(x+".selected",x);PageBus.publish(x+".show",x);PageBus.publish(x+".edit",x)}})}}})}ns("CD.Controller.projects",{initialized:false,selectedObject:{},setSelectedObject:function(w,y,x){var v;this.selectedObject={};this.selectedObject[x]=y;if(y instanceof CD.Task.Model){v=y.get("fk_tasklistid");CD.Tasklist.Model.find(v,{success:function(z){CD.Controller.projects.setSelectedObject(null,z,"tasklist")},error:function(){}})}},getSelectedMilestone:function(){return this.getSelected("milestone")},getSelectedTasklist:function(){return this.getSelected("tasklist")},getSelectedTask:function(){return this.getSelected("task")},getSelected:function(v){if(v==="task"&&this.selectedObject[v] instanceof CD.Task.Model){return this.selectedObject[v]}else{if(v==="tasklist"&&this.selectedObject[v] instanceof CD.Tasklist.Model){return this.selectedObject[v]}else{if(v==="milestone"&&this.selectedObject[v] instanceof CD.Milestone.Model){return this.selectedObject[v]}}}return null},getTasklistCollection:function(){return r},getMilestoneCollection:function(){return n},getDropManager:function(){if(f){f=new CD.Drop(d)}return f},getDragManager:function(){if(!d){d=new CD.Drag(null,true,"selected")}return d},isArchive:function(){return isArchive},init:function(v){var x,z,w;this.data=u=v||{};this.initialized=true;e=CD.Task.Widget.Edit.mode("full");e&=~CD.Task.Widget.Edit.fields.space;e&=~CD.Task.Widget.Edit.fields.spacetasklist;if(!CD.Environment.company.tagging){e&=~CD.Task.Widget.Edit.fields.tags}a();s.reset(u.spaceusers);h.reset(u.spaces);m=v.spacetags||[];z=this;x=$("newMilestone");if(x){x.on("click",function(){CD.Project.Router.navigate("#milestoneedit-new",true)})}x=$("newTasklist");if(x){x.on("click",CD.Tasklist.Dialogs.create)}if(!isArchive){p.byuser=new CD.Tasklist.Container(null,{id:"by-assignee",canAddTask:false,filter:{label:"Assignee",value:null,choices:s.map(function(A){return{label:A.mkview("inline").el,href:"#tasks-by-assignee-"+A.id}})},request_url:function(){return([CD.Environment.zf_uriprefix,CD.Environment.space.name,"project","tasklist","tasksbyuser.jsonenv"]).compact().join("/")},views:{navitem:CD.Tasklist.View.DropdownNavItem,inline:CD.Tasklist.View.FilteredInline}});if(CD.Environment.company.tagging){p.bytag=new CD.Tasklist.Container(null,{id:"by-tag",canAddTask:false,filter:{label:"Tag",value:null,choices:m.map(function(A){A=A.stripTags().strip();return{icon:"icon_tag",label:A,href:"#tasks-by-tag-"+A}})},request_url:function(){return([CD.Environment.zf_uriprefix,CD.Environment.space.name,"project","tasklist","tasksbytag.jsonenv"]).compact().join("/")},views:{navitem:CD.Tasklist.View.DropdownNavItem,inline:CD.Tasklist.View.FilteredInline}})}}o=CD.Widget.init("CD.Milestone.Widget.List",{id:"milestonelist-1",model:n});var y=[];for(w in p){if(p.hasOwnProperty(w)){y.push(p[w])}}b=CD.Widget.init("CD.Tasklist.Widget.Nav",{tasklists:r,containers:y});r.reset(u.tasklists);n.reset(u.milestones);t();k();PageBus.subscribe("CD.Tasklist.Model.*.changed",this,this.reparentTasklist);q=r.filter(function(A){return A.get("is_inbox")});q=q.length?q[0]:null;PageBus.subscribe("CD.Task.Model.*.showPanel",this,this.showTaskPanel);PageBus.subscribe("CD.Task.Model.*.showEditPanel",this,this.showTaskEditPanel);PageBus.subscribe("CD.Tasklist.Model.*.showPanel",this,this.showTasklistPanel);PageBus.subscribe("CD.Milestone.Model.*.showPanel",this,this.showMilestonePanel);PageBus.subscribe("CD.Milestone.Model.*.showEditPanel",this,this.showMilestoneEditPanel);PageBus.subscribe("CD.Task.Model.*.selected",this,this.setSelectedObject,"task");PageBus.subscribe("CD.Tasklist.Model.*.selected",this,this.setSelectedObject,"tasklist");PageBus.subscribe("CD.Milestone.Model.*.selected",this,this.setSelectedObject,"milestone");CD.Widget.init("CD.Project.Widget.Meta");CD.Widget.init("CD.Task.Widget.AddTime",this.data);Backbone.history.start()},showTaskPanel:function(v,w){this.set_view("CD.Task.Widget.Detail",{model:w.model,showTags:CD.Environment.company.tagging,showCommentForm:!!w.options.showCommentForm})},showTaskEditPanel:function(w,v){this.set_view("CD.Task.Widget.Edit",{expandable:false,expanded:true,users:s,fullmode:e,oncancel:function(){window.history.back()}});PageBus.publish(v+".edit",v)},showMilestonePanel:function(v,x,w){this.set_view("CD.Milestone.Widget.Detail",{model:x})},showMilestoneEditPanel:function(v,x,w){this.set_view("CD.Milestone.Widget.Edit",{model:x,users:s})},showTasklistPanel:function(w,y,x){var v=[];if(CD.permissions.canAdd(spid)){v.push({expandable:true,expanded:false,users:s,fullmode:e,isDbTasklist:y.tasklist.get("attached_to_db"),model:y.tasklist})}v.push({templates:{header:"tasklistHeaderTpl",dataView:"tasklistTasksTpl",row:"tasklistTaskRowTpl"},incompletePageNum:y.incompletePageNum,completedPageNum:y.completedPageNum,sortType:ObjectSort.TYPE.NUM,sortBy:y.sortBy,sortDir:y.sortDir,model:y.tasklist});this.set_view("CD.Tasklist.Widget.Wrap",v)},reparentTasklist:function(w,y){var v=y.get("fk_milestoneid");var x=(y===this.getSelectedTasklist());for(filter in p){if(p.hasOwnProperty(filter)){if(y.id===p[filter].id){return}}}if(y.get("fk_spaceid")!==CD.Environment.space.id){if(r.get(y.id)){console.log("removing from tasklists (moved to another space)");r.remove(y);return}}if(v){var z=n.get(v);if(z&&!z.tasklists.get(y.id)){z.tasklists.add(y)}if(r.get(y.id)){r.remove(y)}}else{if(!r.get(y.id)){r.add(y)}n.each(function(A){if(A.tasklists.get(y.id)){A.tasklists.remove(y.id)}})}if(x){PageBus.publish(y+".selected",y)}},set_view:function(v,y){y=y||{};var z,x=$("projectsView"),A=$("projectsViewContent"),w=x.select('[type="text/x-widget"], .x-widget');g=g.concat(w);A.update("");if(this.view_widget){try{CD.PageBus.destroy.call(this.view_widget)}catch(B){}delete this.view_widget}for(z=0;z<g.length;z++){if(g[z].data("init-widget")===v){A.insert(g[z]);this.view_widget=CD.Widget.init(v,y);break}}}})}());(function(){var g=null;var b=new CD.User.Collection();var k=new CD.Space.Collection();var p=new CD.Space.Collection();var r=[];var o;var a=1;var d={};var n=(document.location.search==="?archive");var q=(document.location.search==="?mytasks");var f=null;function m(){if(n){if(tasklists.models.length<1){tasklistListNav.el.setStyle({display:"none"})}}}function c(){if(n){if(milestones.models.length<1){milestoneListNav.el.setStyle({display:"none"})}}}function e(){var t="tasks-assigned-to-me";CD.Project.Router.route("","default",function(){var u=t;if(f){u="tasks-"+f}this.navigate(u,true)});CD.Project.Router.route("by-workspace-:id","by-workspace",function(v){var u=k.get(v);if(u){var w=d.byworkspace;w.set_request_params({workspace:v});w.options.filter.getvalue=function(){return u.mkview("inline",{maxlen:20}).el};w.options.filter.getkey=function(){return v};PageBus.publish(w+".showPanel",{tasklist:w});PageBus.publish(w+".selected",w);PageBus.publish(w+".show",w)}});CD.Project.Router.route(/^tasks\-([^\/]+)(\/([0-9]+)\-([0-9]+)(\/([a-z\_]+)\-(asc|desc))?)?$/,"tasks",function(){var u=arguments,v=this;m();c();var w=u[0];if(d[w]){f=w;PageBus.publish(d[w]+".showPanel",{tasklist:d[w],incompletePageNum:u[2],completedPageNum:u[3],sortBy:u[5],sortDir:u[6]});PageBus.publish(d[w]+".show",d[w]);PageBus.publish(d[w]+".selected",d[w]);window.scrollTo(0,0)}else{v.navigate(t,true)}})}function h(){this.view.expand(false)}function s(){CD.Project.Router.navigate("",true)}ns("CD.Controller.mytasks",{init:function(u){g=this.data=u||{};e();k.reset(g.spaces);p.reset(g.spaces_with_mytasks);a=CD.Task.Widget.Edit.mode("full");if(!CD.Environment.company.tagging){a&=~CD.Task.Widget.Edit.fields.tags}d["assigned-to-me"]=new CD.Tasklist.Container(null,{id:"assigned-to-me",title:"Assigned to me",request_url:CD.Environment.zf_uriprefix+"/home/project/tasklist/assignedtome.jsonenv"});d["assigned-by-me"]=new CD.Tasklist.Container(null,{id:"assigned-by-me",title:"I assigned to others",request_url:CD.Environment.zf_uriprefix+"/home/project/tasklist/assignedbyme.jsonenv"});d["copied-to-me"]=new CD.Tasklist.Container(null,{id:"copied-to-me",title:"I am copied on",request_url:CD.Environment.zf_uriprefix+"/home/project/tasklist/copiedtome.jsonenv"});d.byworkspace=new CD.Tasklist.Container(null,{id:"byworkspace",title:"Filter by Workspace",request_url:CD.Environment.zf_uriprefix+"/home/project/tasklist/tasksbyworkspace.jsonenv",filter:{label:"Workspace",value:null,choices:p.map(function(v){var w=v.meta();return{label:v.mkview("inline").el,href:"#by-workspace-"+v.id}})},views:{navitem:CD.Tasklist.View.DropdownNavItem,inline:CD.Tasklist.View.FilteredInline}});var t=new CD.Tasklist.Widget.Nav({title:"My Tasks",placeholder:"wMyTasksNav",containers:_.values(d)});t.render_views();PageBus.subscribe("CD.Task.Model.*.showPanel",this,this.showTaskPanel);PageBus.subscribe("CD.Task.Model.*.showEditPanel",this,this.showTaskEditPanel);PageBus.subscribe("CD.Tasklist.Model.*.showPanel",this,this.showTasklistPanel);CD.Widget.init("CD.Project.Widget.Meta");CD.Widget.init("CD.Task.Widget.AddTime",this.data);Backbone.history.start()},showTaskPanel:function(v,w,x){var t=w.model;var u=_.extend({model:t,showTags:t.get("fk_spaceid")&&CD.Environment.company.tagging,showComments:!!t.get("fk_spaceid"),onback:s},w.options);this.set_view("CD.Task.Widget.Detail",u)},showTasklistPanel:function(u,w,v){var t=[];if(CD.permissions.canAdd(spid)){t.push({expandable:true,expanded:false,users:b,spaces:k,fullmode:a,model:w.tasklist})}t.push({templates:{header:"tasklistHeaderTpl",dataView:"tasklistTasksTpl",row:"tasklistTaskRowTpl"},incompletePageNum:w.incompletePageNum,completedPageNum:w.completedPageNum,sortType:ObjectSort.TYPE.NUM,sortBy:w.sortBy,sortDir:w.sortDir,model:w.tasklist,addtime_enabled:this.data.addtime_enabled,addtime_quick_input:this.data.addtime_quick_input,mytasks:true});this.set_view("CD.Tasklist.Widget.Wrap",t)},isArchive:function(){return n},isMyTasks:function(){return q},showTaskEditPanel:function(u,t){this.set_view("CD.Task.Widget.Edit",{expandable:false,expanded:true,users:new CD.User.Collection(),spaces:k,fullmode:a,oncancel:s});PageBus.publish(t+".edit",t)},set_view:function(t,w){w=w||{};var x,v=$("mytasksView"),y=$("mytasksViewContent"),u=v.select('script[type="text/x-widget"], .x-widget');r=r.concat(u);y.update("");if(this.view_widget){try{CD.PageBus.destroy.call(this.view_widget)}catch(z){console.warn("destroy() not implemented on view_widget",z)}delete this.view_widget}for(x=0;x<r.length;x++){if(r[x].data("init-widget")===t){y.insert(r[x]);this.view_widget=CD.Widget.init(t,w);break}}}})}());(function(){var a=[];var b;function c(f,e){var d=f+"=([^&#]*)";var h=new RegExp(d);var g=h.exec(e);if(g===null){return""}else{return decodeURIComponent(g[1].replace(/\+/g," "))}}ns("CD.Controller.gantt",{init:function(e){var f=c("tasklist_id",document.location.href);var d=c("milestone_id",document.location.href);var h=$$("div.sch-filters").first();var g=$$("div.sch-filters span b.rp5").first();if(f!==""){CD.Tasklist.Model.find(f,{success:function(k){g.innerHTML="<b>Tasklist:</b> "+k.get("title");h.removeClassName("hidden")},error:function(){console.log("error in CD.Controller.gantt finding tasklist")}})}else{if(d!==""){CD.Milestone.Model.find(d,{success:function(k){g.innerHTML="<b>Milestone:</b> "+k.get("title");h.removeClassName("hidden")},error:function(){console.log("error in CD.Controller.gantt finding milestone")}})}}this.showGanttPanel()},showGanttPanel:function(){this.set_view("CD.Gantt.Widget")},set_view:function(f,k){k=k||{};var m,h=$("view"),g=h.select('script[type="text/x-widget"]');a=a.concat(g);h.update("");if(this.view_widget){try{this.view_widget[0].destroy()}catch(n){console.warn("destroy() not implemented on view_widget",n)}delete this.view_widget[0]}for(m=0;m<a.length;m++){if(a[m].readAttribute("data-init-widget")===f){try{k=JSON.parse(a[m].readAttribute("data-args"))}catch(o){}h.insert(a[m]);var d=JSON.parse(a[m].readAttribute("data-args"));var m;for(m in d){if(d.hasOwnProperty(m)){k[m]=d[m]}}this.view_widget=CD.Widget.init(f,k);break}}}})}());(function(){var c=null;var a=null;var f=null;var d=null;var b=null;var e=null;ns("CD.Controller.workflow",{init:function(g){a=new CD.Tasklist.Collection();c=this.data=g||{};a.reset(c.tasklists);this.initial_tasklist=c.selected_tasklist;this.updateTasklistDropdown("placeholder",a);PageBus.subscribe("CD.Tasklist.Model.*.changed",this,this.updateTasklists);PageBus.subscribe(a+".updated",this,this.updateTasklistDropdown)},getTasklists:function(){return a},updateTasklists:function(g,k,h){if(!a.get(k.id)){a.add(k);this.updateTasklistDropdown("placeholder",a,k.id)}},updateTasklistDropdown:function(k,o,n){if(!this.dropdown){this.dropdown=$$("div#cd_workflow_task_list span select")[0];this.dropdown_span=$$("div#cd_workflow_task_list span")[0];this.or_span=$$("div#cd_workflow_task_list span")[1]}if(this.dropdown){this.dropdown.options.length=0;if(o.models.length>0){var h,g,m=false;for(h=0;h<o.models.length;h++){g=document.createElement("option");g.value=o.models[h].get("pk_id");g.text=o.models[h].get("title");this.dropdown.options.add(g);if(o.models[h].get("pk_id")===n||o.models[h].get("pk_id")===this.initial_tasklist){g.selected="selected";m=true}else{g.selected=""}}if(!m){this.dropdown.options[0].selected="selected"}this.dropdown.setStyle({display:""});this.or_span.setStyle({display:""})}else{this.dropdown.setStyle({display:"none"});this.or_span.setStyle({display:"none"})}}}})}());(function(){var g=null;spaceusers=new CD.User.Collection();var n=[];var m;var d=null;var b=1;var h=(document.location.search==="?archive");function k(){if(h){if(tasklists.models.length<1){tasklistListNav.el.hide()}}}function c(){if(h){if(milestones.models.length<1){milestoneListNav.el.hide()}}}function a(){CD.Project.Router.navigate("",true)}function f(){CD.Project.Router.route("","default",function(){this.navigate("tasklist-"+d.get("pk_id"),true)});CD.Project.Router.route(/^tasklist\-([0-9]+)(\/([0-9]+)\-([0-9]+)(\/([a-z\_]+)\-(asc|desc))?)?$/,"tasks",function(){var o=arguments,q=arguments[0],p=this;k();c();if(parseInt(q,10)!=="NaN"){CD.Tasklist.Model.find(q,{success:function(r){if(parseInt(r.get("fk_spaceid"),10)===parseInt(spid,10)){PageBus.publish(r+".showPanel",{tasklist:r,incompletePageNum:o[2],completedPageNum:o[3],sortBy:o[5],sortDir:o[6]});PageBus.publish(r+".show",r);PageBus.publish(r+".selected",r);window.scrollTo(0,0)}else{p.navigate("",true)}},error:function(r){cdwm.alert("Requested Tasklist was not found");p.navigate("",true)}})}})}var e={selectedObject:null,setSelectedObject:function(p,s,q){var o,r;this.selectedObject[q]=s;if(s instanceof CD.Task.Model){o=s.get("fk_tasklistid");CD.Tasklist.Model.find(o,{success:function(t){CD.Controller.projects.setSelectedObject(null,t,"tasklist")},error:function(){}})}if(s instanceof CD.Tasklist.Model){if(s.get("fk_milestoneid")){r=s.get("fk_milestoneid");CD.Milestone.Model.find(r,{success:function(t){CD.Controller.projects.setSelectedObject(null,t,"milestone")},error:function(){}})}}},getSelectedTasklist:function(){return this.getSelected("tasklist")},getSelectedTask:function(){return this.getSelected("task")},getSelected:function(o){if(this.selectedObject&&this.selectedObject.hasOwnProperty(o)){if(o==="task"&&this.selectedObject[o] instanceof CD.Task.Model){return this.selectedObject[o]}else{if(o==="tasklist"&&this.selectedObject[o] instanceof CD.Tasklist.Model){return this.selectedObject[o]}else{if(o==="milestone"&&this.selectedObject[o] instanceof CD.Milestone.Model){return this.selectedObject[o]}}}}return null},init:function(o){this.selectedObject={};this.data=o||{};d=this.data.tasklist||null;f();b=CD.Task.Widget.Edit.mode("full");b&=~CD.Task.Widget.Edit.fields.space;b&=~CD.Task.Widget.Edit.fields.spacetasklist;if(!CD.Environment.company.tagging){b&=~CD.Task.Widget.Edit.fields.tags}spaceusers.reset(this.data.spaceusers);PageBus.subscribe("CD.Task.Model.*.showPanel",this,this.showTaskPanel);PageBus.subscribe("CD.Task.Model.*.showEditPanel",this,this.showTaskEditPanel);PageBus.subscribe("CD.Tasklist.Model.*.showPanel",this,this.showTasklistPanel);PageBus.subscribe("CD.Task.Model.*.selected",this,this.setSelectedObject,"task");PageBus.subscribe("CD.Tasklist.Model.*.selected",this,this.setSelectedObject,"tasklist");CD.Widget.init("CD.Task.Widget.AddTime",this.data);Backbone.history.start()},showTaskPanel:function(p,o,q){this.set_view("CD.Task.Widget.Detail",[null,{model:o}])},showTaskEditPanel:function(p,o){this.set_view("CD.Task.Widget.Edit",{expandable:false,expanded:true,users:spaceusers,fullmode:b,model:o,oncancel:a});PageBus.publish(o+".edit",o)},showTasklistPanel:function(p,r,q){var o=[];if(CD.permissions.canAdd(spid)){o.push({expandable:true,expanded:false,users:spaceusers,fullmode:b,model:r.tasklist})}o.push({templates:{header:"tasklistHeaderTpl",dataView:"tasklistTasksTpl",row:"tasklistTaskRowTpl"},incompletePageNum:r.incompletePageNum||null,completedPageNum:r.completedPageNum||null,sortType:ObjectSort.TYPE.NUM,sortBy:r.sortBy,sortDir:r.sortDir,model:r.tasklist,addtime_enabled:this.data.addtime_enabled,addtime_quick_input:this.data.addtime_quick_input});this.set_view("CD.Tasklist.Widget.Wrap",o)},set_view:function(o,t){t=t||{};var u,q=$("tasklistView"),v=$("tasklistViewContent"),p=q.select('script[type="text/x-widget"]');n=n.concat(p);v.update("");if(m){try{CD.PageBus.destroy.call(m)}catch(w){}delete m}for(u=0;u<n.length;u++){var s=n[u].readAttribute("data-init-widget");if(s===o){v.insert(n[u]);m=CD.Widget.init(o,t);break}}}};ns("CD.Controller.AppBlock.InteractiveTasklist",e)}());(function(){var a=CD.BaseController.extend({initialize:function(){this.data.tasktemplates=new CD.TaskTemplate.Collection(this.data.tasktemplates);CD.Widget.initall({"CD.TaskTemplate.Widget.Edit":{tasklisttpl_id:this.data.tasklisttpl_id},"CD.TasklistTemplate.Widget.Grid":{tasktemplates:this.data.tasktemplates,persistent_id:"task_templates"}})}});ns("CD.Controller.TasklistTemplate",a)}());(function(){var g=null;spaceusers=new CD.User.Collection();var n=[];var m;var d=null;var b=1;var h=(document.location.search==="?archive");function k(){if(h){if(tasklists.models.length<1){tasklistListNav.el.hide()}}}function c(){if(h){if(milestones.models.length<1){milestoneListNav.el.hide()}}}function a(){CD.Project.Router.navigate("",true)}function f(){CD.Project.Router.route("","default",function(){this.navigate("tasklist-"+d.get("pk_id"),true)});CD.Project.Router.route(/^tasklist\-([0-9]+)(\/([0-9]+)\-([0-9]+)(\/([a-z\_]+)\-(asc|desc))?)?$/,"tasks",function(){var o=arguments,q=arguments[0],p=this;k();c();if(parseInt(q,10)!=="NaN"){CD.Tasklist.Model.find(q,{success:function(r){if(parseInt(r.get("fk_spaceid"),10)===parseInt(spid,10)){PageBus.publish(r+".showPanel",{tasklist:r,incompletePageNum:o[2],completedPageNum:o[3],sortBy:o[5],sortDir:o[6]});PageBus.publish(r+".show",r);PageBus.publish(r+".selected",r);window.scrollTo(0,0)}else{p.navigate("",true)}},error:function(r){cdwm.alert("Requested Tasklist was not found");p.navigate("",true)}})}})}var e={selectedObject:null,setSelectedObject:function(p,s,q){var o,r;this.selectedObject[q]=s;if(s instanceof CD.Task.Model){o=s.get("fk_tasklistid");CD.Tasklist.Model.find(o,{success:function(t){CD.Controller.projects.setSelectedObject(null,t,"tasklist")},error:function(){}})}if(s instanceof CD.Tasklist.Model){if(s.get("fk_milestoneid")){r=s.get("fk_milestoneid");CD.Milestone.Model.find(r,{success:function(t){CD.Controller.projects.setSelectedObject(null,t,"milestone")},error:function(){}})}}},getSelectedTasklist:function(){return this.getSelected("tasklist")},getSelectedTask:function(){return this.getSelected("task")},getSelected:function(o){if(this.selectedObject&&this.selectedObject.hasOwnProperty(o)){if(o==="task"&&this.selectedObject[o] instanceof CD.Task.Model){return this.selectedObject[o]}else{if(o==="tasklist"&&this.selectedObject[o] instanceof CD.Tasklist.Model){return this.selectedObject[o]}else{if(o==="milestone"&&this.selectedObject[o] instanceof CD.Milestone.Model){return this.selectedObject[o]}}}}return null},init:function(o){this.selectedObject={};this.data=o||{};d=this.data.tasklist||null;f();b=CD.Task.Widget.Edit.mode("full");b&=~CD.Task.Widget.Edit.fields.space;b&=~CD.Task.Widget.Edit.fields.spacetasklist;if(!CD.Environment.company.tagging){b&=~CD.Task.Widget.Edit.fields.tags}spaceusers.reset(this.data.spaceusers);PageBus.subscribe("CD.Task.Model.*.showPanel",this,this.showTaskPanel);PageBus.subscribe("CD.Task.Model.*.showEditPanel",this,this.showTaskEditPanel);PageBus.subscribe("CD.Tasklist.Model.*.showPanel",this,this.showTasklistPanel);PageBus.subscribe("CD.Task.Model.*.selected",this,this.setSelectedObject,"task");PageBus.subscribe("CD.Tasklist.Model.*.selected",this,this.setSelectedObject,"tasklist");CD.Widget.init("CD.Task.Widget.AddTime",this.data);Backbone.history.start()},showTaskPanel:function(p,o,q){this.set_view("CD.Task.Widget.Detail",[null,{model:o}])},showTaskEditPanel:function(p,o){this.set_view("CD.Task.Widget.Edit",{expandable:false,expanded:true,users:spaceusers,fullmode:b,model:o,oncancel:a});PageBus.publish(o+".edit",o)},showTasklistPanel:function(p,r,q){var o=[];if(CD.permissions.canAdd(spid)){o.push({expandable:true,expanded:false,users:spaceusers,fullmode:b,model:r.tasklist})}o.push({templates:{header:"tasklistHeaderTpl",dataView:"tasklistTasksTpl",row:"tasklistTaskRowTpl"},incompletePageNum:r.incompletePageNum||null,completedPageNum:r.completedPageNum||null,sortType:ObjectSort.TYPE.NUM,sortBy:r.sortBy,sortDir:r.sortDir,model:r.tasklist,addtime_enabled:this.data.addtime_enabled,addtime_quick_input:this.data.addtime_quick_input});this.set_view("CD.Tasklist.Widget.Wrap",o)},set_view:function(o,t){t=t||{};var u,q=$("tasklistView"),v=$("tasklistViewContent"),p=q.select('script[type="text/x-widget"]');n=n.concat(p);v.update("");if(m){try{CD.PageBus.destroy.call(m)}catch(w){}delete m}for(u=0;u<n.length;u++){var s=n[u].readAttribute("data-init-widget");if(s===o){v.insert(n[u]);m=CD.Widget.init(o,t);break}}}};ns("CD.Controller.AppBlock.InteractiveTasklist",e)}());(function(){var g=null;spaceusers=new CD.User.Collection();var n=[];var m;var d=null;var b=1;var h=(document.location.search==="?archive");function k(){if(h){if(tasklists.models.length<1){tasklistListNav.el.hide()}}}function c(){if(h){if(milestones.models.length<1){milestoneListNav.el.hide()}}}function a(){CD.Project.Router.navigate("",true)}function f(){CD.Project.Router.route("","default",function(){this.navigate("tasklist-"+d.get("pk_id"),true)});CD.Project.Router.route(/^tasklist\-([0-9]+)(\/([0-9]+)\-([0-9]+)(\/([a-z\_]+)\-(asc|desc))?)?$/,"tasks",function(){var o=arguments,q=arguments[0],p=this;k();c();if(parseInt(q,10)!=="NaN"){CD.Tasklist.Model.find(q,{success:function(r){if(parseInt(r.get("fk_spaceid"),10)===parseInt(spid,10)){PageBus.publish(r+".showPanel",{tasklist:r,incompletePageNum:o[2],completedPageNum:o[3],sortBy:o[5],sortDir:o[6]});PageBus.publish(r+".show",r);PageBus.publish(r+".selected",r);window.scrollTo(0,0)}else{p.navigate("",true)}},error:function(r){cdwm.alert("Requested Tasklist was not found");p.navigate("",true)}})}})}var e={selectedObject:null,setSelectedObject:function(p,s,q){var o,r;this.selectedObject[q]=s;if(s instanceof CD.Task.Model){o=s.get("fk_tasklistid");CD.Tasklist.Model.find(o,{success:function(t){CD.Controller.projects.setSelectedObject(null,t,"tasklist")},error:function(){}})}if(s instanceof CD.Tasklist.Model){if(s.get("fk_milestoneid")){r=s.get("fk_milestoneid");CD.Milestone.Model.find(r,{success:function(t){CD.Controller.projects.setSelectedObject(null,t,"milestone")},error:function(){}})}}},getSelectedTasklist:function(){return this.getSelected("tasklist")},getSelectedTask:function(){return this.getSelected("task")},getSelected:function(o){if(this.selectedObject&&this.selectedObject.hasOwnProperty(o)){if(o==="task"&&this.selectedObject[o] instanceof CD.Task.Model){return this.selectedObject[o]}else{if(o==="tasklist"&&this.selectedObject[o] instanceof CD.Tasklist.Model){return this.selectedObject[o]}else{if(o==="milestone"&&this.selectedObject[o] instanceof CD.Milestone.Model){return this.selectedObject[o]}}}}return null},init:function(o){this.selectedObject={};this.data=o||{};d=this.data.tasklist||null;f();b=CD.Task.Widget.Edit.mode("full");b&=~CD.Task.Widget.Edit.fields.space;b&=~CD.Task.Widget.Edit.fields.spacetasklist;if(!CD.Environment.company.tagging){b&=~CD.Task.Widget.Edit.fields.tags}spaceusers.reset(this.data.spaceusers);PageBus.subscribe("CD.Task.Model.*.showPanel",this,this.showTaskPanel);PageBus.subscribe("CD.Task.Model.*.showEditPanel",this,this.showTaskEditPanel);PageBus.subscribe("CD.Tasklist.Model.*.showPanel",this,this.showTasklistPanel);PageBus.subscribe("CD.Task.Model.*.selected",this,this.setSelectedObject,"task");PageBus.subscribe("CD.Tasklist.Model.*.selected",this,this.setSelectedObject,"tasklist");CD.Widget.init("CD.Task.Widget.AddTime",this.data);Backbone.history.start()},showTaskPanel:function(p,o,q){this.set_view("CD.Task.Widget.Detail",[null,{model:o}])},showTaskEditPanel:function(p,o){this.set_view("CD.Task.Widget.Edit",{expandable:false,expanded:true,users:spaceusers,fullmode:b,model:o,oncancel:a});PageBus.publish(o+".edit",o)},showTasklistPanel:function(p,r,q){var o=[];if(CD.permissions.canAdd(spid)){o.push({expandable:true,expanded:false,users:spaceusers,fullmode:b,model:r.tasklist})}o.push({templates:{header:"tasklistHeaderTpl",dataView:"tasklistTasksTpl",row:"tasklistTaskRowTpl"},incompletePageNum:r.incompletePageNum||null,completedPageNum:r.completedPageNum||null,sortType:ObjectSort.TYPE.NUM,sortBy:r.sortBy,sortDir:r.sortDir,model:r.tasklist,addtime_enabled:this.data.addtime_enabled,addtime_quick_input:this.data.addtime_quick_input});this.set_view("CD.Tasklist.Widget.Wrap",o)},set_view:function(o,t){t=t||{};var u,q=$("tasklistView"),v=$("tasklistViewContent"),p=q.select('script[type="text/x-widget"]');n=n.concat(p);v.update("");if(m){try{CD.PageBus.destroy.call(m)}catch(w){}delete m}for(u=0;u<n.length;u++){var s=n[u].readAttribute("data-init-widget");if(s===o){v.insert(n[u]);m=CD.Widget.init(o,t);break}}}};ns("CD.Controller.AppBlock.InteractiveTasklist",e)}());(function(){var g=null;spaceusers=new CD.User.Collection();var n=[];var m;var d=null;var b=1;var h=(document.location.search==="?archive");function k(){if(h){if(tasklists.models.length<1){tasklistListNav.el.hide()}}}function c(){if(h){if(milestones.models.length<1){milestoneListNav.el.hide()}}}function a(){CD.Project.Router.navigate("",true)}function f(){CD.Project.Router.route("","default",function(){this.navigate("tasklist-"+d.get("pk_id"),true)});CD.Project.Router.route(/^tasklist\-([0-9]+)(\/([0-9]+)\-([0-9]+)(\/([a-z\_]+)\-(asc|desc))?)?$/,"tasks",function(){var o=arguments,q=arguments[0],p=this;k();c();if(parseInt(q,10)!=="NaN"){CD.Tasklist.Model.find(q,{success:function(r){if(parseInt(r.get("fk_spaceid"),10)===parseInt(spid,10)){PageBus.publish(r+".showPanel",{tasklist:r,incompletePageNum:o[2],completedPageNum:o[3],sortBy:o[5],sortDir:o[6]});PageBus.publish(r+".show",r);PageBus.publish(r+".selected",r);window.scrollTo(0,0)}else{p.navigate("",true)}},error:function(r){cdwm.alert("Requested Tasklist was not found");p.navigate("",true)}})}})}var e={selectedObject:null,setSelectedObject:function(p,s,q){var o,r;this.selectedObject[q]=s;if(s instanceof CD.Task.Model){o=s.get("fk_tasklistid");CD.Tasklist.Model.find(o,{success:function(t){CD.Controller.projects.setSelectedObject(null,t,"tasklist")},error:function(){}})}if(s instanceof CD.Tasklist.Model){if(s.get("fk_milestoneid")){r=s.get("fk_milestoneid");CD.Milestone.Model.find(r,{success:function(t){CD.Controller.projects.setSelectedObject(null,t,"milestone")},error:function(){}})}}},getSelectedTasklist:function(){return this.getSelected("tasklist")},getSelectedTask:function(){return this.getSelected("task")},getSelected:function(o){if(this.selectedObject&&this.selectedObject.hasOwnProperty(o)){if(o==="task"&&this.selectedObject[o] instanceof CD.Task.Model){return this.selectedObject[o]}else{if(o==="tasklist"&&this.selectedObject[o] instanceof CD.Tasklist.Model){return this.selectedObject[o]}else{if(o==="milestone"&&this.selectedObject[o] instanceof CD.Milestone.Model){return this.selectedObject[o]}}}}return null},init:function(o){this.selectedObject={};this.data=o||{};d=this.data.tasklist||null;f();b=CD.Task.Widget.Edit.mode("full");b&=~CD.Task.Widget.Edit.fields.space;b&=~CD.Task.Widget.Edit.fields.spacetasklist;if(!CD.Environment.company.tagging){b&=~CD.Task.Widget.Edit.fields.tags}spaceusers.reset(this.data.spaceusers);PageBus.subscribe("CD.Task.Model.*.showPanel",this,this.showTaskPanel);PageBus.subscribe("CD.Task.Model.*.showEditPanel",this,this.showTaskEditPanel);PageBus.subscribe("CD.Tasklist.Model.*.showPanel",this,this.showTasklistPanel);PageBus.subscribe("CD.Task.Model.*.selected",this,this.setSelectedObject,"task");PageBus.subscribe("CD.Tasklist.Model.*.selected",this,this.setSelectedObject,"tasklist");CD.Widget.init("CD.Task.Widget.AddTime",this.data);Backbone.history.start()},showTaskPanel:function(p,o,q){this.set_view("CD.Task.Widget.Detail",[null,{model:o}])},showTaskEditPanel:function(p,o){this.set_view("CD.Task.Widget.Edit",{expandable:false,expanded:true,users:spaceusers,fullmode:b,model:o,oncancel:a});PageBus.publish(o+".edit",o)},showTasklistPanel:function(p,r,q){var o=[];if(CD.permissions.canAdd(spid)){o.push({expandable:true,expanded:false,users:spaceusers,fullmode:b,model:r.tasklist})}o.push({templates:{header:"tasklistHeaderTpl",dataView:"tasklistTasksTpl",row:"tasklistTaskRowTpl"},incompletePageNum:r.incompletePageNum||null,completedPageNum:r.completedPageNum||null,sortType:ObjectSort.TYPE.NUM,sortBy:r.sortBy,sortDir:r.sortDir,model:r.tasklist,addtime_enabled:this.data.addtime_enabled,addtime_quick_input:this.data.addtime_quick_input});this.set_view("CD.Tasklist.Widget.Wrap",o)},set_view:function(o,t){t=t||{};var u,q=$("tasklistView"),v=$("tasklistViewContent"),p=q.select('script[type="text/x-widget"]');n=n.concat(p);v.update("");if(m){try{CD.PageBus.destroy.call(m)}catch(w){}delete m}for(u=0;u<n.length;u++){var s=n[u].readAttribute("data-init-widget");if(s===o){v.insert(n[u]);m=CD.Widget.init(o,t);break}}}};ns("CD.Controller.AppBlock.InteractiveTasklist",e)}());
