Changeset 1865

Show
Ignore:
Timestamp:
23-05-11 17:28:51 (3 years ago)
Author:
work@…
Message:

- resolves gscf #447
- gdt up to 0.0.49

Location:
trunk
Files:
10 modified

Legend:

Unmodified
Added
Removed
  • trunk/application.properties

    r1861 r1865  
    11#Grails Metadata file 
    2 #Mon May 23 12:26:01 CEST 2011 
     2#Mon May 23 17:25:43 CEST 2011 
    33app.build.display.info=0 
    44app.build.svn.revision=1079 
     
    1313plugins.db-util=0.4 
    1414plugins.famfamfam=1.0.1 
    15 plugins.gdt=0.0.48 
     15plugins.gdt=0.0.49 
    1616plugins.gdtimporter=0.4.2 
    1717plugins.grom=0.2.2 
  • trunk/grails-app/controllers/dbnp/studycapturing/StudyWizardController.groovy

    r1863 r1865  
    362362                                flash.wizardErrors = [:] 
    363363 
    364                                 // remove subject 
    365                                 def subjectToRemove = flow.study.subjects.find { it.identifier == (params.get('do') as int) } 
    366                                 if (subjectToRemove) { 
    367                                         flow.study.deleteSubject( subjectToRemove ) 
     364                                // remove subject(s) 
     365                                params.get('do').split(",").each { identifier -> 
     366                                        def subjectToRemove = flow.study.subjects.find { it.identifier == (identifier as int) } 
     367                                        if (subjectToRemove) flow.study.deleteSubject( subjectToRemove ) 
    368368                                } 
    369369                        }.to "subjects" 
     
    515515                                flash.wizardErrors = [:] 
    516516 
    517                                 // find matching (sampling) event 
    518                                 def event                       = flow.study.events.find { it.getIdentifier() == (params.get('do') as int) } 
    519                                 def samplingEvent       = flow.study.samplingEvents.find { it.getIdentifier() == (params.get('do') as int) } 
    520  
    521                                 // perform delete 
    522                                 if (event) flow.study.deleteEvent( event ) 
    523                                 if (samplingEvent) flow.study.deleteSamplingEvent( samplingEvent ) 
     517                                // delete event(s) 
     518                                params.get('do').split(",").each { identifier -> 
     519                                        // find matching (sampling) event 
     520                                        def event = flow.study.events.find { it.getIdentifier() == (identifier as int) } 
     521                                        def samplingEvent = flow.study.samplingEvents.find { it.getIdentifier() == (identifier as int) } 
     522 
     523                                        // perform delete 
     524                                        if (event) flow.study.deleteEvent( event ) 
     525                                        if (samplingEvent) flow.study.deleteSamplingEvent( samplingEvent ) 
     526                                } 
    524527                        }.to "events" 
    525528                        on("addEventGroup") { 
     
    574577                                // clone event 
    575578                                def event = null 
    576                                 (((flow.study.events) ? flow.study.events : []) + ((flow.study.samplingEvents) ? flow.study.samplingEvents : [])).find { it.getIdentifier() == (params.get('do') as int) }.each { 
    577                                         event = (it instanceof SamplingEvent) ? new SamplingEvent() : new Event() 
    578  
    579                                         // set template 
    580                                         event.template = it.template 
    581  
    582                                         // copy data 
    583                                         it.giveFields().each() { field -> 
    584                                                 event.setFieldValue( 
    585                                                         field.name, 
    586                                                         it.getFieldValue(field.name) 
    587                                                 ) 
    588                                         } 
    589  
    590                                         // assign duplicate event to study 
    591                                         if (event instanceof SamplingEvent) { 
    592                                                 flow.study.addToSamplingEvents(event) 
    593                                         } else { 
    594                                                 flow.study.addToEvents(event) 
     579 
     580                                // clone event(s) 
     581                                params.get('do').split(",").each { identifier -> 
     582                                        (((flow.study.events) ? flow.study.events : []) + ((flow.study.samplingEvents) ? flow.study.samplingEvents : [])).find { it.getIdentifier() == (identifier as int) }.each { 
     583                                                event = (it instanceof SamplingEvent) ? new SamplingEvent() : new Event() 
     584 
     585                                                // set template 
     586                                                event.template = it.template 
     587 
     588                                                // copy data 
     589                                                it.giveFields().each() { field -> 
     590                                                        event.setFieldValue( 
     591                                                                field.name, 
     592                                                                it.getFieldValue(field.name) 
     593                                                        ) 
     594                                                } 
     595 
     596                                                // assign duplicate event to study 
     597                                                if (event instanceof SamplingEvent) { 
     598                                                        flow.study.addToSamplingEvents(event) 
     599                                                } else { 
     600                                                        flow.study.addToEvents(event) 
     601                                                } 
    595602                                        } 
    596603                                } 
     
    912919                                flash.wizardErrors = [:] 
    913920 
    914                                 // find this assay 
    915                                 def assay = flow.study.assays.find { it.getIdentifier() == (params.get('do') as int) } 
    916  
    917                                 // perform delete 
    918                                 if (assay) flow.study.deleteAssay( assay ) 
     921                                // delete assays 
     922                                params.get('do').split(",").each { identifier -> 
     923                                        // find this assay 
     924                                        def assay = flow.study.assays.find { it.getIdentifier() == (identifier as int) } 
     925 
     926                                        // perform delete 
     927                                        if (assay) flow.study.deleteAssay( assay ) 
     928                                } 
     929                        }.to "assays" 
     930                        on("duplicate") { 
     931                                // handle form data 
     932                                assayPage(flow, flash, params) 
     933 
     934                                // reset errors 
     935                                flash.wizardErrors = [:] 
     936 
     937                                // clone event 
     938                                def assay = null 
     939                                params.get('do').split(",").each { identifier -> 
     940                                        flow.study.assays.find { it.getIdentifier() == (identifier as int) }.each { 
     941                                                assay = new Assay(template: it.template) 
     942 
     943                                                // copy data 
     944                                                it.giveFields().each() { field -> 
     945                                                        assay.setFieldValue( 
     946                                                                field.name, 
     947                                                                it.getFieldValue(field.name) 
     948                                                        ) 
     949                                                } 
     950 
     951                                                // assign duplicate assay to study 
     952                                                flow.study.addToAssays(assay) 
     953                                        } 
     954                                } 
     955 
     956                                success() 
    919957                        }.to "assays" 
    920958                        on("previous") { 
  • trunk/grails-app/views/layouts/main.gsp

    r1840 r1865  
    2626                <script type="text/javascript" src="${resource(dir: 'js', file: 'paginate.js')}"></script> 
    2727                <script type="text/javascript" src="${resource(dir: 'js', file: 'removeWebflowExecutionFromMenu.min.js')}"></script> 
     28                <script type="text/javascript" src="${resource(dir: 'js', file: 'development.js')}"></script> 
    2829        </g:if> 
    2930        <g:else> 
  • trunk/grails-app/views/studyWizard/pages/_assays.gsp

    r1809 r1865  
    4444                                <div class="header"> 
    4545                                        <div class="firstColumn"></div> 
     46                                        <div class="firstColumn"></div> 
    4647                                        <af:templateColumnHeaders class="column" entity="${assay}" /> 
    4748                                </div> 
    4849                                </g:if> 
    4950 
    50                                 <div class="row"> 
     51                                <div class="row" identifier="${assay.getIdentifier()}"> 
    5152                                        <div class="firstColumn"> 
    52                                                 <af:ajaxButton name="deleteAssay" src="${resource(dir: 'images/icons', file: 'delete.png', plugin: 'famfamfam')}" alt="delete this assay" class="famfamfam" value="-" before="\$(\'input[name=do]\').val(${assay.getIdentifier()});" afterSuccess="onPage()"/> 
     53                                                <input type="button" value="" action="deleteAssay" class="delete" identifier="${assay.getIdentifier()}" /> 
     54                                        </div> 
     55                                        <div class="firstColumn"> 
     56                                                <input type="button" value="" action="duplicate" class="clone" identifier="${assay.getIdentifier()}" /> 
    5357                                        </div> 
    5458                                        <af:templateColumns class="column" entity="${assay}" name="assay_${assay.getIdentifier()}" /> 
     
    5862                </g:each> 
    5963        </g:if> 
     64 
     65        <script type="text/javascript"> 
     66        $(document).ready(function() { 
     67                if (tableEditor) { 
     68                        tableEditor.registerActionCallback('deleteAssay', function() { 
     69                                if (confirm('are you sure you want to delete ' + ((this.length>1) ? 'these '+this.length+' assays?' : 'this assay?'))) { 
     70                                        $('input[name="do"]').val(this); 
     71                                        <af:ajaxSubmitJs name="deleteAssay" afterSuccess="onPage()" /> 
     72                                } 
     73                        }); 
     74                        tableEditor.registerActionCallback('duplicate', function() { 
     75                                $('input[name="do"]').val(this); 
     76                                <af:ajaxSubmitJs name="duplicate" afterSuccess="onPage()" /> 
     77                        }); 
     78                } 
     79        }); 
     80        </script> 
    6081</af:page> 
  • trunk/grails-app/views/studyWizard/pages/_events.gsp

    r1856 r1865  
    118118                                </g:if> 
    119119 
    120                                 <div class="row"> 
     120                                <div class="row" identifier="${event.getIdentifier()}"> 
    121121                                        <div class="firstColumn"> 
    122                                                 <af:ajaxButton name="deleteEvent" src="${resource(dir: 'images/icons', file: 'delete.png', plugin: 'famfamfam')}" alt="delete this event" class="famfamfam" value="-" before="\$(\'input[name=do]\').val(${event.getIdentifier()});" afterSuccess="onPage()"/> 
     122                                                <input type="button" value="" action="deleteEvent" class="delete" identifier="${event.getIdentifier()}" /> 
    123123                                        </div> 
    124124                                        <g:if test="${study.eventGroups}"><g:each var="eventGroup" in="${study.eventGroups}"> 
     
    132132                                        </g:each></g:if> 
    133133                                        <div class="firstColumn"> 
    134                                                 <af:ajaxButton name="duplicate" src="${resource(dir: 'images/icons', file: 'application_put.png', plugin: 'famfamfam')}" alt="duplicate this event" class="famfamfam" value="-" before="\$(\'input[name=do]\').val(${event.getIdentifier()});" afterSuccess="onPage()" /> 
     134                                                <input type="button" value="" action="duplicate" class="clone" identifier="${event.getIdentifier()}" /> 
    135135                                        </div> 
    136136                                        <af:templateColumns class="column" entity="${event}" name="event_${event.getIdentifier()}" /> 
     
    141141                </g:each> 
    142142        </g:if> 
     143 
     144        <script type="text/javascript"> 
     145        $(document).ready(function() { 
     146                if (tableEditor) { 
     147                        tableEditor.registerActionCallback('deleteEvent', function() { 
     148                                if (confirm('are you sure you want to delete ' + ((this.length>1) ? 'these '+this.length+' events?' : 'this event?'))) { 
     149                                        $('input[name="do"]').val(this); 
     150                                        <af:ajaxSubmitJs name="deleteEvent" afterSuccess="onPage()" /> 
     151                                } 
     152                        }); 
     153                        tableEditor.registerActionCallback('duplicate', function() { 
     154                                $('input[name="do"]').val(this); 
     155                                <af:ajaxSubmitJs name="duplicate" afterSuccess="onPage()" /> 
     156                        }); 
     157                } 
     158        }); 
     159        </script> 
    143160</af:page> 
  • trunk/grails-app/views/studyWizard/pages/_subjects.gsp

    r1809 r1865  
    5252                                </div> 
    5353                                </g:if> 
    54                                 <div class="row"> 
     54                                <div class="row" identifier="${subject.getIdentifier()}"> 
    5555                                        <div class="firstColumn"> 
    56                                                 <af:ajaxButton name="delete" src="${resource(dir: 'images/icons', file: 'delete.png', plugin: 'famfamfam')}" alt="delete this subject" class="famfamfam" value="-" before="\$(\'input[name=do]\').val(${subject.getIdentifier()});" afterSuccess="onPage()" /> 
     56                                                <input type="button" value="" action="delete" class="delete" identifier="${subject.getIdentifier()}" /> 
    5757                                        </div> 
    5858                                        <af:templateColumns class="column" entity="${subject}" name="subject_${subject.getIdentifier()}" /> 
     
    6262                </g:each> 
    6363        </g:if> 
     64 
     65        <script type="text/javascript"> 
     66        $(document).ready(function() { 
     67                if (tableEditor) { 
     68                        tableEditor.registerActionCallback('delete', function() { 
     69                                if (confirm('are you sure you want to delete ' + ((this.length>1) ? 'these '+this.length+' subjects?' : 'this subject?'))) { 
     70                                        $('input[name="do"]').val(this); 
     71                                        <af:ajaxSubmitJs name="delete" afterSuccess="onPage()" /> 
     72                                } 
     73                        }); 
     74                } 
     75        }); 
     76        </script> 
    6477</af:page> 
  • trunk/web-app/css/studywizard.css

    r1533 r1865  
    9393/** END :: study page publication, contact and users lists **/ 
    9494 
     95/** START :: table editor button styles **/ 
     96.tableEditor input[type=button] { 
     97        border: none; 
     98        width: 16px; 
     99        height: 16px; 
     100        background-color: transparent; 
     101} 
     102.tableEditor input.delete { 
     103        background: url(../plugins/famfamfam-1.0.1/images/icons/delete.png) no-repeat left top; 
     104} 
     105.tableEditor input.clone { 
     106        background: url(../plugins/famfamfam-1.0.1/images/icons/application_put.png) no-repeat left top; 
     107} 
     108/** END :: table editor button styles **/ 
  • trunk/web-app/css/studywizard.min.css

    r1810 r1865  
    1 .bigbutton{background:url(../images/wizard/big-button.jpg) no-repeat left top;border:0;width:454px;height:53px;color:#fff;font-size:18pt;}.bigbutton:hover{color:#000;}.bigtext{color:#006dba;font-weight:normal;font-size:24px;margin:.8em 0 .3em 0;display:block;width:100%;text-align:center;}div .upload_button{display:inline;border:1px solid #006dba;padding:4px 8px;cursor:pointer;line-height:26px;}div .upload_info{display:inline;color:#006dba;margin-left:5px;}div .upload_info a{text-decoration:underline;}div .upload_del img{border-width:0;padding-left:6px;}div .upload_del{display:none;}div .upload_info .error{color:red;}div ul.publication_list,div ul.contact_list,div ul.user_list{list-style-type:none;margin:-10px 0 0 255px;padding:0;}div ul.publication_list li,div ul.contact_list li,div ul.user_list li{margin-left:0;padding:4px 6px;}div li.even{background-color:#F3F3F3;}div li.odd{background-color:#FAFAFA;}div li .delete_button{float:right;margin-left:10px;cursor:pointer;}div ul.publication_list li .authors{font-size:10px;margin-top:3px;color:#333;}div ul.contact_list li .person{display:inline;}div ul.contact_list li .role{color:#009;display:inline;margin-left:5px;}div ul.contact_list li .role:before{content:' / ';color:#009;}div .contacts_dialog{margin:5px 0;} 
     1.bigbutton{background:url(../images/wizard/big-button.jpg) no-repeat left top;border:0;width:454px;height:53px;color:#fff;font-size:18pt;}.bigbutton:hover{color:#000;}.bigtext{color:#006dba;font-weight:normal;font-size:24px;margin:.8em 0 .3em 0;display:block;width:100%;text-align:center;}div .upload_button{display:inline;border:1px solid #006dba;padding:4px 8px;cursor:pointer;line-height:26px;}div .upload_info{display:inline;color:#006dba;margin-left:5px;}div .upload_info a{text-decoration:underline;}div .upload_del img{border-width:0;padding-left:6px;}div .upload_del{display:none;}div .upload_info .error{color:red;}div ul.publication_list,div ul.contact_list,div ul.user_list{list-style-type:none;margin:-10px 0 0 255px;padding:0;}div ul.publication_list li,div ul.contact_list li,div ul.user_list li{margin-left:0;padding:4px 6px;}div li.even{background-color:#F3F3F3;}div li.odd{background-color:#FAFAFA;}div li .delete_button{float:right;margin-left:10px;cursor:pointer;}div ul.publication_list li .authors{font-size:10px;margin-top:3px;color:#333;}div ul.contact_list li .person{display:inline;}div ul.contact_list li .role{color:#009;display:inline;margin-left:5px;}div ul.contact_list li .role:before{content:' / ';color:#009;}div .contacts_dialog{margin:5px 0;}.tableEditor input[type=button]{border:none;width:16px;height:16px;background-color:transparent;}.tableEditor input.delete{background:url(../plugins/famfamfam-1.0.1/images/icons/delete.png) no-repeat left top;}.tableEditor input.clone{background:url(../plugins/famfamfam-1.0.1/images/icons/application_put.png) no-repeat left top;} 
  • trunk/web-app/js/studywizard.js

    r1819 r1865  
    1111 * $Date$ 
    1212 */ 
     13var tableEditor = null;         // in global namespace 
    1314var warnOnRedirect = true; 
    1415$(document).ready(function() { 
     
    2627 
    2728        // handle and initialize table(s) 
    28         new TableEditor().init({ 
     29        tableEditor = new TableEditor().init({ 
    2930                tableIdentifier : 'div.tableEditor', 
    3031                rowIdentifier   : 'div.row', 
  • trunk/web-app/js/studywizard.min.js

    r1819 r1865  
    1 var warnOnRedirect=true;$(document).ready(function(){insertOnRedirectWarning();onStudyWizardPage()});function onStudyWizardPage(){attachHelpTooltips();attachDatePickers();attachDateTimePickers();disableKeys();disableDatePickerKeys();new TableEditor().init({tableIdentifier:"div.tableEditor",rowIdentifier:"div.row",columnIdentifier:"div.firstColumn, div.column",headerIdentifier:"div.header"});new OntologyChooser().init();new SelectAddMore().init({rel:"term",url:baseUrl+"/termEditor",vars:"ontologies",label:"add more...",style:"addMore",onClose:function(a){refreshFlow()}});new SelectAddMore().init({rel:"template",url:baseUrl+"/templateEditor",vars:"entity,ontologies",label:"add / modify..",style:"modify",onClose:function(a){refreshFlow()}});new SelectAddMore().init({rel:"person",url:baseUrl+"/person/list?dialog=true",vars:"person",label:"add / modify persons...",style:"modify",onClose:function(a){refreshFlow()}});new SelectAddMore().init({rel:"role",url:baseUrl+"/personRole/list?dialog=true",vars:"role",label:"add / modify roles...",style:"modify",onClose:function(a){refreshFlow()}});new FuzzyStringMatcher().init({});$("#accordion").accordion({autoHeight:false})}function disableDatePickerKeys(){$(".hasDatepicker").each(function(){$(this).bind("keydown",function(a){return false})})}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 attachDatePickers(){$("input[type=text][rel$='date']").each(function(){$(this).datepicker({changeMonth:true,changeYear:true,showButtonPanel:true,dateFormat:"dd/mm/yy",yearRange:"c-80:c+20",altField:"#"+$(this).attr("name")+"Example",altFormat:"DD, d MM, yy"})})}function attachDateTimePickers(){$("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 handleWizardTable(){}function showExampleReltime(a){var d=a.name;var b=function(g,h,e){var f=document.getElementById(d+"Example");if(e.status==200&&f){document.getElementById(d+"Example").value=g}};var c=function(e,h,g){var f=document.getElementById(d+"Example");if(f){document.getElementById(d+"Example").value=""}};$.ajax({url:baseUrl+"/studyWizard/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!=""&&oldFile!="existing*"&&oldFile!="*deleted*"){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));$("#"+a+"Delete").hide()},onComplete:function(c,b){if(b==""){$("#"+a).val("");$("#"+a+"Example").html('<span class="error">Error uploading '+createFileHTML(c)+"</span>");$("#"+a+"Delete").hide()}else{b=b.replace(/<\/?[^>]+>/gi,"");$("#"+a).val(b);$("#"+a+"Example").html("Uploaded "+createFileHTML(c));$("#"+a+"Delete").show()}}})}function deleteFile(a){$("#"+a).val("*deleted*");$("#"+a+"Example").html("File deleted");$("#"+a+"Delete").hide()}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").hide()}},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").show()}}}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+"/plugins/famfamfam-1.0.1/images/icons/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();if(e==""||e==0||a==""||a==0){alert("Please select both a person and a role.");return false}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").hide()}return true}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").show()}}}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+"/plugins/famfamfam-1.0.1/images/icons/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)}function addUser(a){id=parseInt($("#"+a+"_form select").val());var b=getUserIds(a);if($.inArray(id,b)==-1){b[b.length]=id;$("#"+a+"_ids").val(b.join(","));showUser(a,id,$("#"+a+"_form select option:selected").text(),b.length-1);$("#"+a+"_none").css("display","none")}return false}function removeUser(b,d){var c=getUserIds(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 getUserIds(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 showUser(c,g,f,d){var b=document.createElement("img");b.className="famfamfam delete_button";b.setAttribute("alt","remove this user");b.setAttribute("src",baseUrl+"/plugins/famfamfam-1.0.1/images/icons/delete.png");b.onclick=function(){removeUser(c,g);return false};var e=document.createElement("div");e.className="username";e.appendChild(document.createTextNode(f));var a=document.createElement("li");a.setAttribute("id",c+"_item_"+g);a.className=d%2==0?"even":"odd";a.appendChild(b);a.appendChild(e);$("#"+c+"_list").append(a)}function createUserDialog(a){if($("."+a+"_user_dialog").length==0){$("#"+a+"_dialog").dialog({title:"Add user",autoOpen:false,width:800,height:400,modal:true,dialogClass:a+"_user_dialog",position:"center",buttons:{Add:function(){addUser(a);$(this).dialog("close")},Close:function(){$(this).dialog("close")}},close:function(){}}).width(790).height(400)}else{$("#"+a+"_dialog").remove()}}function openUserDialog(a){var b=$("#"+a);b.val("");$("#"+a+"_dialog").dialog("open");b.focus()}; 
     1var tableEditor=null;var warnOnRedirect=true;$(document).ready(function(){insertOnRedirectWarning();onStudyWizardPage()});function onStudyWizardPage(){attachHelpTooltips();attachDatePickers();attachDateTimePickers();disableKeys();disableDatePickerKeys();tableEditor=new TableEditor().init({tableIdentifier:"div.tableEditor",rowIdentifier:"div.row",columnIdentifier:"div.firstColumn, div.column",headerIdentifier:"div.header"});new OntologyChooser().init();new SelectAddMore().init({rel:"term",url:baseUrl+"/termEditor",vars:"ontologies",label:"add more...",style:"addMore",onClose:function(a){refreshFlow()}});new SelectAddMore().init({rel:"template",url:baseUrl+"/templateEditor",vars:"entity,ontologies",label:"add / modify..",style:"modify",onClose:function(a){refreshFlow()}});new SelectAddMore().init({rel:"person",url:baseUrl+"/person/list?dialog=true",vars:"person",label:"add / modify persons...",style:"modify",onClose:function(a){refreshFlow()}});new SelectAddMore().init({rel:"role",url:baseUrl+"/personRole/list?dialog=true",vars:"role",label:"add / modify roles...",style:"modify",onClose:function(a){refreshFlow()}});new FuzzyStringMatcher().init({});$("#accordion").accordion({autoHeight:false})}function disableDatePickerKeys(){$(".hasDatepicker").each(function(){$(this).bind("keydown",function(a){return false})})}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 attachDatePickers(){$("input[type=text][rel$='date']").each(function(){$(this).datepicker({changeMonth:true,changeYear:true,showButtonPanel:true,dateFormat:"dd/mm/yy",yearRange:"c-80:c+20",altField:"#"+$(this).attr("name")+"Example",altFormat:"DD, d MM, yy"})})}function attachDateTimePickers(){$("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 handleWizardTable(){}function showExampleReltime(a){var d=a.name;var b=function(g,h,e){var f=document.getElementById(d+"Example");if(e.status==200&&f){document.getElementById(d+"Example").value=g}};var c=function(e,h,g){var f=document.getElementById(d+"Example");if(f){document.getElementById(d+"Example").value=""}};$.ajax({url:baseUrl+"/studyWizard/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!=""&&oldFile!="existing*"&&oldFile!="*deleted*"){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));$("#"+a+"Delete").hide()},onComplete:function(c,b){if(b==""){$("#"+a).val("");$("#"+a+"Example").html('<span class="error">Error uploading '+createFileHTML(c)+"</span>");$("#"+a+"Delete").hide()}else{b=b.replace(/<\/?[^>]+>/gi,"");$("#"+a).val(b);$("#"+a+"Example").html("Uploaded "+createFileHTML(c));$("#"+a+"Delete").show()}}})}function deleteFile(a){$("#"+a).val("*deleted*");$("#"+a+"Example").html("File deleted");$("#"+a+"Delete").hide()}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").hide()}},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").show()}}}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+"/plugins/famfamfam-1.0.1/images/icons/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();if(e==""||e==0||a==""||a==0){alert("Please select both a person and a role.");return false}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").hide()}return true}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").show()}}}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+"/plugins/famfamfam-1.0.1/images/icons/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)}function addUser(a){id=parseInt($("#"+a+"_form select").val());var b=getUserIds(a);if($.inArray(id,b)==-1){b[b.length]=id;$("#"+a+"_ids").val(b.join(","));showUser(a,id,$("#"+a+"_form select option:selected").text(),b.length-1);$("#"+a+"_none").css("display","none")}return false}function removeUser(b,d){var c=getUserIds(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 getUserIds(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 showUser(c,g,f,d){var b=document.createElement("img");b.className="famfamfam delete_button";b.setAttribute("alt","remove this user");b.setAttribute("src",baseUrl+"/plugins/famfamfam-1.0.1/images/icons/delete.png");b.onclick=function(){removeUser(c,g);return false};var e=document.createElement("div");e.className="username";e.appendChild(document.createTextNode(f));var a=document.createElement("li");a.setAttribute("id",c+"_item_"+g);a.className=d%2==0?"even":"odd";a.appendChild(b);a.appendChild(e);$("#"+c+"_list").append(a)}function createUserDialog(a){if($("."+a+"_user_dialog").length==0){$("#"+a+"_dialog").dialog({title:"Add user",autoOpen:false,width:800,height:400,modal:true,dialogClass:a+"_user_dialog",position:"center",buttons:{Add:function(){addUser(a);$(this).dialog("close")},Close:function(){$(this).dialog("close")}},close:function(){}}).width(790).height(400)}else{$("#"+a+"_dialog").remove()}}function openUserDialog(a){var b=$("#"+a);b.val("");$("#"+a+"_dialog").dialog("open");b.focus()};