Changeset 567


Ignore:
Timestamp:
Jun 16, 2010, 1:55:55 PM (6 years ago)
Author:
duh
Message:
  • developmental commit for bug # 107

-- turning off all bootstrapping to ensure that all possible bugs do really surface and are not obscured by bootstrap hacks / dummy data
-- SelectAddMore?.js now support the passing of multiple values to a dialog
-- in the subject page of the wizard the template select now opens a dialog passing on the entity AND the ontologies
-- templateEditor has been extended to pass ontologies as well

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/conf/BootStrap.groovy

    r564 r567  
    2222
    2323                // 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) {
    2525                        println ".development bootstrapping...";
    2626
     
    11061106
    11071107                        }
     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)]
    11081113                }
    1109 
    1110                 // Ontologies must be connected to the templatefields in runtime
    1111                 // because the Ontology.findByNcboId is not available otherwise
    1112                 TemplateEntity.getField(Subject.domainFields, 'species').ontologies = [Ontology.findByNcboId(1132)]
    1113                 TemplateEntity.getField(Sample.domainFields, 'material').ontologies = [Ontology.findByNcboId(1005)]
    1114 
    11151114        }
    11161115
  • trunk/grails-app/controllers/dbnp/studycapturing/TemplateEditorController.groovy

    r558 r567  
    4545            encryptedEntity: params.entity,
    4646            humanReadableEntity: humanReadableEntity,
     47                        ontologies: params.ontologies
    4748        ];
    4849    }
     
    127128                }
    128129
     130                // set entity
    129131                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                }
     168println params
    130169
    131170                // Create the template field and add it to the template
    132171                def template = new Template( params );
    133         if (template.save(flush: true)) {
     172//TemplateEntity.getField(entity.domainFields, 'species').ontologies = [Ontology.findByNcboId(1132)]
     173TemplateEntity.getField(entity.domainFields, 'species').ontologies = params.ontologies
     174
     175        if (template.validate() && template.save(flush: true)) {
     176println template
     177println template.fields
     178println template.getRequiredFields()
     179println template.findAllByEntity( entity )
     180
     181
    134182
    135183                        def html = g.render( template: 'elements/liTemplate', model: [template: template] );
  • trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy

    r565 r567  
    4747         * @param Closure body
    4848         */
    49         def ajaxButton = {attrs, body ->
     49        def ajaxButton = { attrs, body ->
    5050                // get the jQuery version
    5151                def jQueryVersion = grailsApplication.getMetadata()['plugins.jquery']
     
    117117         * @see WizardTagLib::baseElement (ajaxSubmitOnChange)
    118118         */
    119         def ajaxSubmitJs = {attrs, body ->
     119        def ajaxSubmitJs = { attrs, body ->
    120120                // define AJAX provider
    121121                setProvider([library: ajaxProvider])
     
    136136                // change form if a form attribute is present
    137137                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')",
    146140                                "\$('" + attrs.get('form') + "')"
    147141                        )
     
    174168         * Example initial webflow action to work with this javascript:
    175169         * ...
    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         * ...
    180178         *
    181179         * @param Map attributes
    182180         * @param Closure body
    183181         */
    184         def ajaxFlowRedirect = {attrs, body ->
     182        def ajaxFlowRedirect = { attrs, body ->
    185183                // generate javascript
    186184                out << '<script type="text/javascript">'
     
    196194         * @param Closure body  (help text)
    197195         */
    198         def pageContent = {attrs, body ->
     196        def pageContent = { attrs, body ->
    199197                // define AJAX provider
    200198                setProvider([library: ajaxProvider])
     
    219217         * @param Closure help content
    220218         */
    221         def baseElement = {inputElement, attrs, help ->
     219        def baseElement = { inputElement, attrs, help ->
    222220println ".rendering [" + inputElement + "] with name [" + attrs.get('name') + "] and value [" + ((attrs.value) ? attrs.get('value').toString() : "-") + "]"
    223221                // work variables
     
    340338         * @param Closure body  (help text)
    341339         */
    342         def textFieldElement = {attrs, body ->
     340        def textFieldElement = { attrs, body ->
    343341                // set default size, or scale to max length if it is less than the default size
    344342                if (!attrs.get("size")) {
     
    363361         * @param Closure body  (help text)
    364362         */
    365         def textAreaElement = {attrs, body ->
     363        def textAreaElement = { attrs, body ->
    366364                // set default size, or scale to max length if it is less than the default size
    367365
     
    380378         * @param Closure body  (help text)
    381379         */
    382         def selectElement = {attrs, body ->
     380        def selectElement = { attrs, body ->
    383381                baseElement.call(
    384382                        'select',
     
    393391         * @param Closure body  (help text)
    394392         */
    395         def checkBoxElement = {attrs, body ->
     393        def checkBoxElement = { attrs, body ->
    396394                baseElement.call(
    397395                        'checkBox',
     
    439437         * @param Closure body  (help text)
    440438         */
    441         def dateElement = {attrs, body ->
     439        def dateElement = { attrs, body ->
    442440                // transform value?
    443441                if (attrs.value instanceof Date) {
     
    467465         * @param Closure body  (help text)
    468466         */
    469         def timeElement = {attrs, body ->
     467        def timeElement = { attrs, body ->
    470468                // transform value?
    471469                if (attrs.value instanceof Date) {
     
    494492         * @param Closure help content
    495493         */
    496         def buttonElement = {attrs, body ->
     494        def buttonElement = { attrs, body ->
    497495                // render template element
    498496                baseElement.call(
     
    524522        def termSelect = { attrs ->
    525523                def from = []
     524println "termSelect --> " + attrs
    526525
    527526                // got ontologies?
     
    657656         * @param Closure help content
    658657         */
    659         def templateElement = {attrs, body ->
     658        def templateElement = { attrs, body ->
    660659                // add a rel element if it does not exist
    661660                if (!attrs.rel) {
     
    675674         * @param Map attrs
    676675         */
    677         def templateSelect = {attrs ->
     676        def templateSelect = { attrs ->
    678677                def entity = attrs.remove('entity')
    679678
     
    773772         * @param Closure help content
    774773         */
    775         def protocolElement = {attrs, body ->
     774        def protocolElement = { attrs, body ->
    776775                // render protocol element
    777776                baseElement.call(
     
    786785         * @param Map attrs
    787786         */
    788         def protocolSelect = {attrs ->
     787        def protocolSelect = { attrs ->
    789788                // fetch all protocold
    790789                attrs.from = Protocol.findAll() // for now, all protocols
     
    798797        }
    799798
    800         def show = {attrs ->
     799        def show = { attrs ->
    801800                // is object parameter set?
    802801                def o = attrs.object
     
    873872
    874873println ".SHOWING "+it.type.toString()
    875 println it.ontologies
    876874
    877875                                switch (it.type.toString()) {
  • trunk/grails-app/views/templateEditor/index.gsp

    r558 r567  
    4343                                <form class="templateField_form" id="template_new_form" action="createTemplate">
    4444                                        <g:hiddenField name="entity" value="${encryptedEntity}" />
     45                                        <g:hiddenField name="ontologies" value="${ontologies}" />
    4546                                        <g:render template="elements/templateForm" model="['template': null]"/>
    4647                                        <div class="templateFieldButtons">
     
    5354                        <g:form action="template" name="templateChoice" method="GET">
    5455                                <g:hiddenField name="entity" value="${encryptedEntity}" />
     56                                <g:hiddenField name="ontologies" value="${ontologies}" />
    5557                                <input type="hidden" name="template" id="templateSelect" value="${template?.id}">
    5658                        </g:form>
  • trunk/grails-app/views/templateEditor/template.gsp

    r558 r567  
    7474                <g:form action="template" name="templateChoice">
    7575                        <g:hiddenField name="entity" value="${encryptedEntity}" />
     76                        <g:hiddenField name="ontologies" value="${ontologies}" />
    7677                        <input type="hidden" name="template" id="templateSelect" value="${template?.id}">
    7778                </g:form>
  • trunk/grails-app/views/wizard/pages/_subjects.gsp

    r565 r567  
    3131                The species of the subjects you would like to add to your study
    3232        </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">
    3434                The template to use for these subjects
    3535        </wizard:templateElement>
  • trunk/web-app/js/SelectAddMore.js

    r475 r567  
    100100                // the dialog integrate with the application!
    101101                // @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({
    103110                    title   : label,
    104111                    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)}})}};
     1function 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  
    5151        rel     : 'template',
    5252        url     : baseUrl + '/templateEditor',
    53         vars    : 'entity',
     53        vars    : 'entity,ontologies',
    5454        label   : 'add / modify..',
    5555        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)};
     1var 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.