Changeset 567
- Timestamp:
- Jun 16, 2010, 1:55:55 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/BootStrap.groovy
r564 r567 22 22 23 23 // we could also check if we are in development by GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT 24 if (Study.count() == 0 ) {24 if (Study.count() == 0 && false) { 25 25 println ".development bootstrapping..."; 26 26 … … 1106 1106 1107 1107 } 1108 1109 // Ontologies must be connected to the templatefields in runtime 1110 // because the Ontology.findByNcboId is not available otherwise 1111 TemplateEntity.getField(Subject.domainFields, 'species').ontologies = [Ontology.findByNcboId(1132)] 1112 TemplateEntity.getField(Sample.domainFields, 'material').ontologies = [Ontology.findByNcboId(1005)] 1108 1113 } 1109 1110 // Ontologies must be connected to the templatefields in runtime1111 // because the Ontology.findByNcboId is not available otherwise1112 TemplateEntity.getField(Subject.domainFields, 'species').ontologies = [Ontology.findByNcboId(1132)]1113 TemplateEntity.getField(Sample.domainFields, 'material').ontologies = [Ontology.findByNcboId(1005)]1114 1115 1114 } 1116 1115 -
trunk/grails-app/controllers/dbnp/studycapturing/TemplateEditorController.groovy
r558 r567 45 45 encryptedEntity: params.entity, 46 46 humanReadableEntity: humanReadableEntity, 47 ontologies: params.ontologies 47 48 ]; 48 49 } … … 127 128 } 128 129 130 // set entity 129 131 params.entity = entity; 132 133 // got ontologies? 134 if (params.ontologies) { 135 // fetch the ontologies 136 def ontologies = [] 137 params.ontologies.split(/\,/).each() { ncboId -> 138 // trim ncboId 139 ncboId = ncboId.trim() 140 141 // find ontology 142 def ontology = Ontology.findAllByNcboId( ncboId ) 143 144 // got the ontology? 145 if (ontology) { 146 ontology.each() { 147 ontologies[ ontologies.size() ] = it 148 } 149 } else { 150 // no, fetch it from the bioportal 151 ontology = Ontology.getBioPortalOntology( ncboId ) 152 153 // does it validate? 154 if (ontology.validate()) { 155 // yeah, add it! 156 ontology.save(flush:true) 157 ontology.refresh() 158 ontologies[ ontologies.size() ] = ontology 159 } 160 } 161 } 162 163 // and set it as parameter again 164 params.ontologies = ontologies 165 } else { 166 params.remove('ontologies') 167 } 168 println params 130 169 131 170 // Create the template field and add it to the template 132 171 def template = new Template( params ); 133 if (template.save(flush: true)) { 172 //TemplateEntity.getField(entity.domainFields, 'species').ontologies = [Ontology.findByNcboId(1132)] 173 TemplateEntity.getField(entity.domainFields, 'species').ontologies = params.ontologies 174 175 if (template.validate() && template.save(flush: true)) { 176 println template 177 println template.fields 178 println template.getRequiredFields() 179 println template.findAllByEntity( entity ) 180 181 134 182 135 183 def html = g.render( template: 'elements/liTemplate', model: [template: template] ); -
trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy
r565 r567 47 47 * @param Closure body 48 48 */ 49 def ajaxButton = { attrs, body ->49 def ajaxButton = { attrs, body -> 50 50 // get the jQuery version 51 51 def jQueryVersion = grailsApplication.getMetadata()['plugins.jquery'] … … 117 117 * @see WizardTagLib::baseElement (ajaxSubmitOnChange) 118 118 */ 119 def ajaxSubmitJs = { attrs, body ->119 def ajaxSubmitJs = { attrs, body -> 120 120 // define AJAX provider 121 121 setProvider([library: ajaxProvider]) … … 136 136 // change form if a form attribute is present 137 137 if (attrs.get('form')) { 138 // Old way 139 /* 140 button = button.replaceFirst(/this\.form/, 141 "\\\$('" + attrs.get('form') + "')" 142 ) 143 */ 144 145 button = button.replace("jQuery(this).parents('form:first')", 138 button = button.replace( 139 "jQuery(this).parents('form:first')", 146 140 "\$('" + attrs.get('form') + "')" 147 141 ) … … 174 168 * Example initial webflow action to work with this javascript: 175 169 * ... 176 * mainPage {* render(view: "/wizard/index") 177 * onRender {* flow.page = 1 178 *}* on("next").to "pageOne" 179 *}* ... 170 * mainPage { 171 * render(view: "/wizard/index") 172 * onRender { 173 * flow.page = 1 174 * } 175 * on("next").to "pageOne" 176 * } 177 * ... 180 178 * 181 179 * @param Map attributes 182 180 * @param Closure body 183 181 */ 184 def ajaxFlowRedirect = { attrs, body ->182 def ajaxFlowRedirect = { attrs, body -> 185 183 // generate javascript 186 184 out << '<script type="text/javascript">' … … 196 194 * @param Closure body (help text) 197 195 */ 198 def pageContent = { attrs, body ->196 def pageContent = { attrs, body -> 199 197 // define AJAX provider 200 198 setProvider([library: ajaxProvider]) … … 219 217 * @param Closure help content 220 218 */ 221 def baseElement = { inputElement, attrs, help ->219 def baseElement = { inputElement, attrs, help -> 222 220 println ".rendering [" + inputElement + "] with name [" + attrs.get('name') + "] and value [" + ((attrs.value) ? attrs.get('value').toString() : "-") + "]" 223 221 // work variables … … 340 338 * @param Closure body (help text) 341 339 */ 342 def textFieldElement = { attrs, body ->340 def textFieldElement = { attrs, body -> 343 341 // set default size, or scale to max length if it is less than the default size 344 342 if (!attrs.get("size")) { … … 363 361 * @param Closure body (help text) 364 362 */ 365 def textAreaElement = { attrs, body ->363 def textAreaElement = { attrs, body -> 366 364 // set default size, or scale to max length if it is less than the default size 367 365 … … 380 378 * @param Closure body (help text) 381 379 */ 382 def selectElement = { attrs, body ->380 def selectElement = { attrs, body -> 383 381 baseElement.call( 384 382 'select', … … 393 391 * @param Closure body (help text) 394 392 */ 395 def checkBoxElement = { attrs, body ->393 def checkBoxElement = { attrs, body -> 396 394 baseElement.call( 397 395 'checkBox', … … 439 437 * @param Closure body (help text) 440 438 */ 441 def dateElement = { attrs, body ->439 def dateElement = { attrs, body -> 442 440 // transform value? 443 441 if (attrs.value instanceof Date) { … … 467 465 * @param Closure body (help text) 468 466 */ 469 def timeElement = { attrs, body ->467 def timeElement = { attrs, body -> 470 468 // transform value? 471 469 if (attrs.value instanceof Date) { … … 494 492 * @param Closure help content 495 493 */ 496 def buttonElement = { attrs, body ->494 def buttonElement = { attrs, body -> 497 495 // render template element 498 496 baseElement.call( … … 524 522 def termSelect = { attrs -> 525 523 def from = [] 524 println "termSelect --> " + attrs 526 525 527 526 // got ontologies? … … 657 656 * @param Closure help content 658 657 */ 659 def templateElement = { attrs, body ->658 def templateElement = { attrs, body -> 660 659 // add a rel element if it does not exist 661 660 if (!attrs.rel) { … … 675 674 * @param Map attrs 676 675 */ 677 def templateSelect = { attrs ->676 def templateSelect = { attrs -> 678 677 def entity = attrs.remove('entity') 679 678 … … 773 772 * @param Closure help content 774 773 */ 775 def protocolElement = { attrs, body ->774 def protocolElement = { attrs, body -> 776 775 // render protocol element 777 776 baseElement.call( … … 786 785 * @param Map attrs 787 786 */ 788 def protocolSelect = { attrs ->787 def protocolSelect = { attrs -> 789 788 // fetch all protocold 790 789 attrs.from = Protocol.findAll() // for now, all protocols … … 798 797 } 799 798 800 def show = { attrs ->799 def show = { attrs -> 801 800 // is object parameter set? 802 801 def o = attrs.object … … 873 872 874 873 println ".SHOWING "+it.type.toString() 875 println it.ontologies876 874 877 875 switch (it.type.toString()) { -
trunk/grails-app/views/templateEditor/index.gsp
r558 r567 43 43 <form class="templateField_form" id="template_new_form" action="createTemplate"> 44 44 <g:hiddenField name="entity" value="${encryptedEntity}" /> 45 <g:hiddenField name="ontologies" value="${ontologies}" /> 45 46 <g:render template="elements/templateForm" model="['template': null]"/> 46 47 <div class="templateFieldButtons"> … … 53 54 <g:form action="template" name="templateChoice" method="GET"> 54 55 <g:hiddenField name="entity" value="${encryptedEntity}" /> 56 <g:hiddenField name="ontologies" value="${ontologies}" /> 55 57 <input type="hidden" name="template" id="templateSelect" value="${template?.id}"> 56 58 </g:form> -
trunk/grails-app/views/templateEditor/template.gsp
r558 r567 74 74 <g:form action="template" name="templateChoice"> 75 75 <g:hiddenField name="entity" value="${encryptedEntity}" /> 76 <g:hiddenField name="ontologies" value="${ontologies}" /> 76 77 <input type="hidden" name="template" id="templateSelect" value="${template?.id}"> 77 78 </g:form> -
trunk/grails-app/views/wizard/pages/_subjects.gsp
r565 r567 31 31 The species of the subjects you would like to add to your study 32 32 </wizard:termElement> 33 <wizard:templateElement name="template" description="with template" value="${values.template}" error="template" entity="${dbnp.studycapturing.Subject}" addDummy="true">33 <wizard:templateElement name="template" description="with template" value="${values.template}" error="template" entity="${dbnp.studycapturing.Subject}" ontologies="1132" addDummy="true"> 34 34 The template to use for these subjects 35 35 </wizard:templateElement> -
trunk/web-app/js/SelectAddMore.js
r475 r567 100 100 // the dialog integrate with the application! 101 101 // @see http://www.w3schools.com/html5/tag_iframe.asp 102 $('<iframe frameborder="0" src="' + url + '?' + vars + '=' + e.attr(vars) + '" sanbox="allow-same-origin" seamless />').dialog({ 102 var arrVars = vars.split(","); 103 var uri = url + '?' 104 for (var v in arrVars) { 105 var val = e.attr(arrVars[v]); 106 uri += arrVars[v] + '=' + ((val) ? val : '') + '&'; 107 } 108 109 $('<iframe frameborder="0" src="' + uri + '" sanbox="allow-same-origin" seamless />').dialog({ 103 110 title : label, 104 111 autoOpen: true, -
trunk/web-app/js/SelectAddMore.min.js
r475 r567 1 function SelectAddMore(){}SelectAddMore.prototype={options:{rel:"addmore",url:"http://www.youtube.com/watch?v=2WNrx2jq184",vars:"vars",label:"add more...",style:"addmore",width:800,height:400,position:"center",onClose:function(a){}},init:function(a){var b=this;$.each(a,function(c,d){b.options[c]=d});$("select[rel*='"+b.options.rel+"']").each(function(){b.addOpenDialogOption(this)})},addOpenDialogOption:function(d){var g=this;var h=$(d);var m=h.children().size();var a=g.options.style;var k=g.options.label;var i=g.options.vars;var b=g.options.url;var c=g.options.width;var l=g.options.height;var j=g.options.onClose;var f=g.options.position;h.append('<option value="" class="'+a+'">'+k+"</option>");h.bind("change",function(){if(this.selectedIndex==m){ $('<iframe frameborder="0" src="'+b+"?"+i+"="+h.attr(i)+'" sanbox="allow-same-origin" seamless />').dialog({title:k,autoOpen:true,width:c,height:l,modal:true,position:f,buttons:{Close:function(){$(this).dialog("close")}},close:function(){j(this)}}).width(c-10).height(l)}})}};1 function SelectAddMore(){}SelectAddMore.prototype={options:{rel:"addmore",url:"http://www.youtube.com/watch?v=2WNrx2jq184",vars:"vars",label:"add more...",style:"addmore",width:800,height:400,position:"center",onClose:function(a){}},init:function(a){var b=this;$.each(a,function(c,d){b.options[c]=d});$("select[rel*='"+b.options.rel+"']").each(function(){b.addOpenDialogOption(this)})},addOpenDialogOption:function(d){var g=this;var h=$(d);var m=h.children().size();var a=g.options.style;var k=g.options.label;var i=g.options.vars;var b=g.options.url;var c=g.options.width;var l=g.options.height;var j=g.options.onClose;var f=g.options.position;h.append('<option value="" class="'+a+'">'+k+"</option>");h.bind("change",function(){if(this.selectedIndex==m){var n=i.split(",");var o=b+"?";for(var e in n){var p=h.attr(n[e]);o+=n[e]+"="+((p)?p:"")+"&"}$('<iframe frameborder="0" src="'+o+'" sanbox="allow-same-origin" seamless />').dialog({title:k,autoOpen:true,width:c,height:l,modal:true,position:f,buttons:{Close:function(){$(this).dialog("close")}},close:function(){j(this)}}).width(c-10).height(l)}})}}; -
trunk/web-app/js/wizard.js
r539 r567 51 51 rel : 'template', 52 52 url : baseUrl + '/templateEditor', 53 vars : 'entity ',53 vars : 'entity,ontologies', 54 54 label : 'add / modify..', 55 55 style : 'modify', -
trunk/web-app/js/wizard.min.js
r539 r567 1 var warnOnRedirect=true;$(document).ready(function(){insertOnRedirectWarning();onWizardPage()});function onWizardPage(){attachHelpTooltips();attachDatePickers();attachDateTimePickers();attachTableEvents();handleWizardTable();new TableEditor().init("div.table","div.row","div.column");new OntologyChooser().init();new SelectAddMore().init({rel:"term",url:baseUrl+"/termEditor",vars:"ontologies",label:"add more...",style:"addMore",onClose:function(a){refreshWebFlow()}});new SelectAddMore().init({rel:"template",url:baseUrl+"/templateEditor",vars:"entity ",label:"add / modify..",style:"modify",onClose:function(a){refreshWebFlow()}});new SelectAddMore().init({rel:"person",url:baseUrl+"/person/list?dialog=true",vars:"person",label:"add / modify persons...",style:"modify",onClose:function(a){refreshWebFlow()}});new SelectAddMore().init({rel:"role",url:baseUrl+"/personRole/list?dialog=true",vars:"role",label:"add / modify roles...",style:"modify",onClose:function(a){refreshWebFlow()}});$("#accordion").accordion()}function insertOnRedirectWarning(){$("a").each(function(){var a=$(this);var b=/^#/gi;if(!a.attr("href").match(/^#/gi)&&!a.attr("href").match(/\/([^\/]+)\/wizard\/pages/gi)){a.bind("click",function(){if(warnOnRedirect){return onDirectWarning()}})}})}function onDirectWarning(){return confirm("Warning: navigating away from the wizard causes loss of work and unsaved data. Are you sure you want to continue?")}function attachHelpTooltips(){$("div#wizard").find("div.helpIcon").each(function(){helpIcon=$(this);helpContent=helpIcon.parent().find("div.helpContent");if(!helpContent.html()){helpContent=helpIcon.parent().parent().find("div.helpContent")}var html=(helpContent.html())?helpContent.html():"";if(html){var specialContent=html.match(/\[([^:]+)\:([^\]]+)\]/);if(specialContent){eval(specialContent[1]+"('"+specialContent[2]+"',helpContent)")}helpIcon.qtip({content:"leftMiddle",position:{corner:{tooltip:"leftMiddle",target:"rightMiddle"}},style:{border:{width:5,radius:10},padding:10,textAlign:"center",tip:true,name:"blue"},content:helpContent.html(),show:"mouseover",hide:"mouseout",api:{beforeShow:function(){}}});helpContent.remove()}})}function youtube(b,a){a.html("<div id='"+b+"'></div>");var c={allowScriptAccess:"always"};var d={id:"myytplayer_"+b};swfobject.embedSWF("http://www.youtube.com/v/"+b+"?enablejsapi=1&playerapiid=ytplayer_"+b,b,"200","150","8",null,null,c,d)}function onYouTubePlayerReady(a){ytplayer=document.getElementById("my"+a);ytplayer.playVideo()}function attachDatePickers(){$("div#wizard").find("input[type=text][rel$='date']").each(function(){$(this).datepicker({numberOfMonths:3,showButtonPanel:true,changeMonth:true,changeYear:true,dateFormat:"dd/mm/yy",altField:"#"+$(this).attr("name")+"Example",altFormat:"DD, d MM, yy"})})}function attachDateTimePickers(){$("div#wizard").find("input[type=text][rel$='datetime']").each(function(){$(this).datepicker({changeMonth:true,changeYear:true,dateFormat:"dd/mm/yy",altField:"#"+$(this).attr("name")+"Example",altTimeField:"#"+$(this).attr("name")+"Example2",altFormat:"DD, d MM, yy",showTime:true,time24h:true})})}function attachTableEvents(){$("div#wizard").find("div.row").each(function(){$(this).hover(function(){$(this).addClass("highlight")},function(){$(this).removeClass("highlight")})})}function handleWizardTable(){var b=this;var a=$("div#wizard").find("div.table");a.each(function(){var d=$(this);var g=(d.next().attr("class")=="sliderContainer")?d.next():null;var h=d.find("div.header");var f=20;var e=0;var c=[];h.children().each(function(){var m=$(this);var k=m.width();var i=parseInt(m.css("padding-left"),10)+parseInt(m.css("padding-right"),10);var l=parseInt(m.css("margin-left"),10)+parseInt(m.css("margin-right"),10);var j=parseInt(m.css("borderLeftWidth"),10)+parseInt(m.css("borderRightWidth"),10);if(i){k+=i}if(l){k+=l}if(j){k+=j}f+=k;c[e]=m.width();e++});h.css({width:f+"px"});d.find("div.row").each(function(){var j=$(this);var i=0;j.children().each(function(){$(this).css({width:c[i]+"px"});i++});j.css({width:f+"px"})});if(g){if(h.width()<d.width()){g.css({display:"none "})}else{g.slider({value:1,min:1,max:h.width()-d.width(),step:1,slide:function(i,j){d.find("div.header, div.row").css({"margin-left":(1-j.value)+"px"})}})}}})}function showExampleReltime(a){var d=a.name;var b=function(f,g,e){if(e.status==200){document.getElementById(d+"Example").value=f}};var c=function(e,g,f){document.getElementById(d+"Example").value=""};$.ajax({url:baseUrl+"/wizard/ajaxParseRelTime?reltime="+a.value,success:b,error:c})}function fileUploadField(a){new AjaxUpload("#upload_button_"+a,{action:baseUrl+"/file/upload",data:{},name:a,autoSubmit:true,onChange:function(b,c){oldFile=$("#"+a).val();if(oldFile!=""){if(!confirm("The old file is deleted when uploading a new file. Do you want to continue?")){return false}}this.setData({field:a,oldFile:oldFile});$("#"+a+"Example").html("Uploading "+createFileHTML(b))},onComplete:function(c,b){if(b==""){$("#"+a).val("");$("#"+a+"Example").html('<span class="error">Error uploading '+createFileHTML(c)+"</span>")}else{$("#"+a).val(b);$("#"+a+"Example").html("Uploaded "+createFileHTML(c))}}})}function createFileHTML(a){return'<a target="_blank" href="'+baseUrl+"/file/get/"+a+'">'+a+"</a>"}function addPublication(a){jQuery.ajax({type:"GET",url:baseUrl+"/publication/getID?"+$("#"+a+"_form").serialize(),success:function(c,e){var d=parseInt(c);var b=getPublicationIds(a);if($.inArray(d,b)==-1){b[b.length]=d;$("#"+a+"_ids").val(b.join(","));showPublication(a,d,$("#"+a+"_form").find("[name=publication-title]").val(),$("#"+a+"_form").find("[name=publication-authorsList]").val(),b.length-1);$("#"+a+"_none").css("display","none")}},error:function(b,d,c){alert("Publication could not be added.")}});return false}function removePublication(b,d){var c=getPublicationIds(b);if($.inArray(d,c)!=-1){c.splice($.inArray(d,c),1);$("#"+b+"_ids").val(c.join(","));var a=$("#"+b+"_item_"+d);if(a){a.remove()}if(c.length==0){$("#"+b+"_none").css("display","inline")}}}function getPublicationIds(a){var c=$("#"+a+"_ids").val();if(c==""){return new Array()}else{ids_array=c.split(",");for(var b=0;b<ids_array.length;b++){ids_array[b]=parseInt(ids_array[b])}return ids_array}}function showPublication(c,a,g,f,h){var e=document.createElement("img");e.className="famfamfam delete_button";e.setAttribute("alt","remove this publication");e.setAttribute("src",baseUrl+"/images/icons/famfamfam/delete.png");e.onclick=function(){removePublication(c,a);return false};var b=document.createElement("div");b.className="title";b.appendChild(document.createTextNode(g));var d=document.createElement("div");d.className="authors";d.appendChild(document.createTextNode(f));var i=document.createElement("li");i.setAttribute("id",c+"_item_"+a);i.className=h%2==0?"even":"odd";i.appendChild(e);i.appendChild(b);i.appendChild(d);$("#"+c+"_list").append(i)}function createPublicationDialog(a){if($("."+a+"_publication_dialog").length==0){$("#"+a+"_dialog").dialog({title:"Add publication",autoOpen:false,width:800,height:400,modal:true,dialogClass:a+"_publication_dialog",position:"center",buttons:{Add:function(){addPublication(a);$(this).dialog("close")},Close:function(){$(this).dialog("close")}},close:function(){}}).width(790).height(400)}else{$("#"+a+"_dialog").remove()}}function openPublicationDialog(a){var b=$("#"+a);b.autocomplete("close");b.val("");$("#"+a+"_dialog").dialog("open");b.focus();enableButton("."+a+"_publication_dialog","Add",false)}function getDialogButton(b,a){var e=$(b+" .ui-dialog-buttonpane button");for(var d=0;d<e.length;++d){var c=$(e[d]);if(c.text()==a){return c}}return null}function enableButton(b,a,c){var d=getDialogButton(b,a);if(d){if(c){d.attr("disabled","");d.removeClass("ui-state-disabled")}else{d.attr("disabled","disabled");d.addClass("ui-state-disabled")}}}function addContact(b){var e=$("#"+b+"_person").val();var a=$("#"+b+"_role").val();var c=e+"-"+a;var d=getContactIds(b);if($.inArray(c,d)==-1){d[d.length]=c;$("#"+b+"_ids").val(d.join(","));showContact(b,c,$("#"+b+"_person :selected").text(),$("#"+b+"_role :selected").text(),d.length-1);$("#"+b+"_none").css("display","none")}}function removeContact(b,c){var d=getContactIds(b);if($.inArray(c,d)!=-1){d.splice($.inArray(c,d),1);$("#"+b+"_ids").val(d.join(","));var a=$("#"+b+"_item_"+c);if(a){a.remove()}if(d.length==0){$("#"+b+"_none").css("display","inline")}}}function getContactIds(a){var b=$("#"+a+"_ids").val();if(b==""){return new Array()}else{ids_array=b.split(",");return ids_array}}function showContact(c,a,d,f,h){var g=document.createElement("img");g.className="famfamfam delete_button";g.setAttribute("alt","remove this person");g.setAttribute("src",baseUrl+"/images/icons/famfamfam/delete.png");g.onclick=function(){removeContact(c,a);return false};var b=document.createElement("div");b.className="person";b.appendChild(document.createTextNode(d));var e=document.createElement("div");e.className="role";e.appendChild(document.createTextNode(f));var i=document.createElement("li");i.setAttribute("id",c+"_item_"+a);i.className=h%2==0?"even":"odd";i.appendChild(g);i.appendChild(b);i.appendChild(e);$("#"+c+"_list").append(i)};1 var warnOnRedirect=true;$(document).ready(function(){insertOnRedirectWarning();onWizardPage()});function onWizardPage(){attachHelpTooltips();attachDatePickers();attachDateTimePickers();attachTableEvents();handleWizardTable();new TableEditor().init("div.table","div.row","div.column");new OntologyChooser().init();new SelectAddMore().init({rel:"term",url:baseUrl+"/termEditor",vars:"ontologies",label:"add more...",style:"addMore",onClose:function(a){refreshWebFlow()}});new SelectAddMore().init({rel:"template",url:baseUrl+"/templateEditor",vars:"entity,ontologies",label:"add / modify..",style:"modify",onClose:function(a){refreshWebFlow()}});new SelectAddMore().init({rel:"person",url:baseUrl+"/person/list?dialog=true",vars:"person",label:"add / modify persons...",style:"modify",onClose:function(a){refreshWebFlow()}});new SelectAddMore().init({rel:"role",url:baseUrl+"/personRole/list?dialog=true",vars:"role",label:"add / modify roles...",style:"modify",onClose:function(a){refreshWebFlow()}});$("#accordion").accordion()}function insertOnRedirectWarning(){$("a").each(function(){var a=$(this);var b=/^#/gi;if(!a.attr("href").match(/^#/gi)&&!a.attr("href").match(/\/([^\/]+)\/wizard\/pages/gi)){a.bind("click",function(){if(warnOnRedirect){return onDirectWarning()}})}})}function onDirectWarning(){return confirm("Warning: navigating away from the wizard causes loss of work and unsaved data. Are you sure you want to continue?")}function attachHelpTooltips(){$("div#wizard").find("div.helpIcon").each(function(){helpIcon=$(this);helpContent=helpIcon.parent().find("div.helpContent");if(!helpContent.html()){helpContent=helpIcon.parent().parent().find("div.helpContent")}var html=(helpContent.html())?helpContent.html():"";if(html){var specialContent=html.match(/\[([^:]+)\:([^\]]+)\]/);if(specialContent){eval(specialContent[1]+"('"+specialContent[2]+"',helpContent)")}helpIcon.qtip({content:"leftMiddle",position:{corner:{tooltip:"leftMiddle",target:"rightMiddle"}},style:{border:{width:5,radius:10},padding:10,textAlign:"center",tip:true,name:"blue"},content:helpContent.html(),show:"mouseover",hide:"mouseout",api:{beforeShow:function(){}}});helpContent.remove()}})}function youtube(b,a){a.html("<div id='"+b+"'></div>");var c={allowScriptAccess:"always"};var d={id:"myytplayer_"+b};swfobject.embedSWF("http://www.youtube.com/v/"+b+"?enablejsapi=1&playerapiid=ytplayer_"+b,b,"200","150","8",null,null,c,d)}function onYouTubePlayerReady(a){ytplayer=document.getElementById("my"+a);ytplayer.playVideo()}function attachDatePickers(){$("div#wizard").find("input[type=text][rel$='date']").each(function(){$(this).datepicker({numberOfMonths:3,showButtonPanel:true,changeMonth:true,changeYear:true,dateFormat:"dd/mm/yy",altField:"#"+$(this).attr("name")+"Example",altFormat:"DD, d MM, yy"})})}function attachDateTimePickers(){$("div#wizard").find("input[type=text][rel$='datetime']").each(function(){$(this).datepicker({changeMonth:true,changeYear:true,dateFormat:"dd/mm/yy",altField:"#"+$(this).attr("name")+"Example",altTimeField:"#"+$(this).attr("name")+"Example2",altFormat:"DD, d MM, yy",showTime:true,time24h:true})})}function attachTableEvents(){$("div#wizard").find("div.row").each(function(){$(this).hover(function(){$(this).addClass("highlight")},function(){$(this).removeClass("highlight")})})}function handleWizardTable(){var b=this;var a=$("div#wizard").find("div.table");a.each(function(){var d=$(this);var g=(d.next().attr("class")=="sliderContainer")?d.next():null;var h=d.find("div.header");var f=20;var e=0;var c=[];h.children().each(function(){var m=$(this);var k=m.width();var i=parseInt(m.css("padding-left"),10)+parseInt(m.css("padding-right"),10);var l=parseInt(m.css("margin-left"),10)+parseInt(m.css("margin-right"),10);var j=parseInt(m.css("borderLeftWidth"),10)+parseInt(m.css("borderRightWidth"),10);if(i){k+=i}if(l){k+=l}if(j){k+=j}f+=k;c[e]=m.width();e++});h.css({width:f+"px"});d.find("div.row").each(function(){var j=$(this);var i=0;j.children().each(function(){$(this).css({width:c[i]+"px"});i++});j.css({width:f+"px"})});if(g){if(h.width()<d.width()){g.css({display:"none "})}else{g.slider({value:1,min:1,max:h.width()-d.width(),step:1,slide:function(i,j){d.find("div.header, div.row").css({"margin-left":(1-j.value)+"px"})}})}}})}function showExampleReltime(a){var d=a.name;var b=function(f,g,e){if(e.status==200){document.getElementById(d+"Example").value=f}};var c=function(e,g,f){document.getElementById(d+"Example").value=""};$.ajax({url:baseUrl+"/wizard/ajaxParseRelTime?reltime="+a.value,success:b,error:c})}function fileUploadField(a){new AjaxUpload("#upload_button_"+a,{action:baseUrl+"/file/upload",data:{},name:a,autoSubmit:true,onChange:function(b,c){oldFile=$("#"+a).val();if(oldFile!=""){if(!confirm("The old file is deleted when uploading a new file. Do you want to continue?")){return false}}this.setData({field:a,oldFile:oldFile});$("#"+a+"Example").html("Uploading "+createFileHTML(b))},onComplete:function(c,b){if(b==""){$("#"+a).val("");$("#"+a+"Example").html('<span class="error">Error uploading '+createFileHTML(c)+"</span>")}else{$("#"+a).val(b);$("#"+a+"Example").html("Uploaded "+createFileHTML(c))}}})}function createFileHTML(a){return'<a target="_blank" href="'+baseUrl+"/file/get/"+a+'">'+a+"</a>"}function addPublication(a){jQuery.ajax({type:"GET",url:baseUrl+"/publication/getID?"+$("#"+a+"_form").serialize(),success:function(c,e){var d=parseInt(c);var b=getPublicationIds(a);if($.inArray(d,b)==-1){b[b.length]=d;$("#"+a+"_ids").val(b.join(","));showPublication(a,d,$("#"+a+"_form").find("[name=publication-title]").val(),$("#"+a+"_form").find("[name=publication-authorsList]").val(),b.length-1);$("#"+a+"_none").css("display","none")}},error:function(b,d,c){alert("Publication could not be added.")}});return false}function removePublication(b,d){var c=getPublicationIds(b);if($.inArray(d,c)!=-1){c.splice($.inArray(d,c),1);$("#"+b+"_ids").val(c.join(","));var a=$("#"+b+"_item_"+d);if(a){a.remove()}if(c.length==0){$("#"+b+"_none").css("display","inline")}}}function getPublicationIds(a){var c=$("#"+a+"_ids").val();if(c==""){return new Array()}else{ids_array=c.split(",");for(var b=0;b<ids_array.length;b++){ids_array[b]=parseInt(ids_array[b])}return ids_array}}function showPublication(c,a,g,f,h){var e=document.createElement("img");e.className="famfamfam delete_button";e.setAttribute("alt","remove this publication");e.setAttribute("src",baseUrl+"/images/icons/famfamfam/delete.png");e.onclick=function(){removePublication(c,a);return false};var b=document.createElement("div");b.className="title";b.appendChild(document.createTextNode(g));var d=document.createElement("div");d.className="authors";d.appendChild(document.createTextNode(f));var i=document.createElement("li");i.setAttribute("id",c+"_item_"+a);i.className=h%2==0?"even":"odd";i.appendChild(e);i.appendChild(b);i.appendChild(d);$("#"+c+"_list").append(i)}function createPublicationDialog(a){if($("."+a+"_publication_dialog").length==0){$("#"+a+"_dialog").dialog({title:"Add publication",autoOpen:false,width:800,height:400,modal:true,dialogClass:a+"_publication_dialog",position:"center",buttons:{Add:function(){addPublication(a);$(this).dialog("close")},Close:function(){$(this).dialog("close")}},close:function(){}}).width(790).height(400)}else{$("#"+a+"_dialog").remove()}}function openPublicationDialog(a){var b=$("#"+a);b.autocomplete("close");b.val("");$("#"+a+"_dialog").dialog("open");b.focus();enableButton("."+a+"_publication_dialog","Add",false)}function getDialogButton(b,a){var e=$(b+" .ui-dialog-buttonpane button");for(var d=0;d<e.length;++d){var c=$(e[d]);if(c.text()==a){return c}}return null}function enableButton(b,a,c){var d=getDialogButton(b,a);if(d){if(c){d.attr("disabled","");d.removeClass("ui-state-disabled")}else{d.attr("disabled","disabled");d.addClass("ui-state-disabled")}}}function addContact(b){var e=$("#"+b+"_person").val();var a=$("#"+b+"_role").val();var c=e+"-"+a;var d=getContactIds(b);if($.inArray(c,d)==-1){d[d.length]=c;$("#"+b+"_ids").val(d.join(","));showContact(b,c,$("#"+b+"_person :selected").text(),$("#"+b+"_role :selected").text(),d.length-1);$("#"+b+"_none").css("display","none")}}function removeContact(b,c){var d=getContactIds(b);if($.inArray(c,d)!=-1){d.splice($.inArray(c,d),1);$("#"+b+"_ids").val(d.join(","));var a=$("#"+b+"_item_"+c);if(a){a.remove()}if(d.length==0){$("#"+b+"_none").css("display","inline")}}}function getContactIds(a){var b=$("#"+a+"_ids").val();if(b==""){return new Array()}else{ids_array=b.split(",");return ids_array}}function showContact(c,a,d,f,h){var g=document.createElement("img");g.className="famfamfam delete_button";g.setAttribute("alt","remove this person");g.setAttribute("src",baseUrl+"/images/icons/famfamfam/delete.png");g.onclick=function(){removeContact(c,a);return false};var b=document.createElement("div");b.className="person";b.appendChild(document.createTextNode(d));var e=document.createElement("div");e.className="role";e.appendChild(document.createTextNode(f));var i=document.createElement("li");i.setAttribute("id",c+"_item_"+a);i.className=h%2==0?"even":"odd";i.appendChild(g);i.appendChild(b);i.appendChild(e);$("#"+c+"_list").append(i)};
Note: See TracChangeset
for help on using the changeset viewer.