Changeset 544 for trunk/web-app
- Timestamp:
- Jun 9, 2010, 12:46:22 PM (12 years ago)
- Location:
- trunk/web-app
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web-app/css/templateEditor.css
r538 r544 18 18 } 19 19 20 .templateField_form { display: none; } 20 #templateFields .empty { opacity: 0.6; padding: 5px 25px; } 21 22 .templateField_form { display: none; margin: 5px; padding-top: 8px; border-top: 1px solid #BBD; } 23 .templateField_form .templateFieldButtons { margin-top: 8px; padding-top: 8px; border-top: 1px solid #BBD; } 21 24 .templateField_form label { width: 100px; float: left; display: block; } 25 .templateField_form textarea {width: 240px; height: 100px; } 26 27 #addNew { 28 width: 388px; 29 line-height: 16px; 30 background-color: #EBF9D7; 31 border:1px solid #D0EAAE; 32 color:#79AA27; 33 font-weight:bold; 34 35 margin: 10px 5px; 36 padding: 0px; 37 } 38 39 #addNew.ui-state-disabled { opacity:0.35; } 40 #addNew a { 41 display: block; 42 padding: 7px 25px; 43 cursor: pointer; 44 color:#79AA27; 45 text-decoration: none; 46 } 47 48 #addNew form{ 49 margin-left: 10px; margin-right: 10px; 50 } -
trunk/web-app/js/publication-chooser.js
r527 r544 244 244 // check whether there are results or nog 245 245 var improvedResponse = function( objects ) { 246 if( objects.length == 0 ) { 246 if( objects == null ) { 247 objects = new Array(); 248 } 249 if( objects.length == 0 ) { 247 250 $( '#' + inputElement.attr( 'id' ) + '_spinner' ).hide(); 248 251 $( '#' + inputElement.attr( 'id' ) + '_notfound' ).show(); -
trunk/web-app/js/publication-chooser.pubmed.js
r527 r544 1 function _createURL( utility, params ) { 2 return baseUrl + "/wizard/entrezProxy?_utility=" + utility + "&" + params; 3 } 1 4 sourcePubMed = function( chooserObject, searchterm, response ) { 2 5 // Search for every term in both title and author fields … … 7 10 } 8 11 9 var url = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=" + searchFor.join( " AND " ) + "&usehistory=y"; 12 // The fetching of the data is done using a proxy, because in IE it is not allowed to retrieve 13 // XML data from another domain. 14 var utility = 'esearch.fcgi'; 15 var params = "db=pubmed&term=" + searchFor.join( " AND " ) + "&usehistory=y"; 16 var url = _createURL( utility, params ); 10 17 11 18 // Fetch it from Pubmed … … 19 26 var query_key = $("QueryKey", xmlDoc ).text(); 20 27 28 var utility = 'esummary.fcgi'; 29 var params = "db=pubmed&retmax=" + chooserObject.maxResults + "&query_key=" + query_key + "&WebEnv=" + WebEnv; 30 var url = _createURL( utility, params ); 31 21 32 $.ajax({ 22 url: "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=pubmed&retmax=" + chooserObject.maxResults + "&query_key=" + query_key + "&WebEnv=" + WebEnv,33 url: url, 23 34 dataType: "xml", 24 35 success: function(summaryResponse) { … … 31 42 // Return it to jquery 32 43 response( parsedData ); 44 }, 45 error: function() { 46 response( null ); 33 47 } 34 48 }) 49 }, 50 error: function() { 51 response( null ); 35 52 } 36 53 }) -
trunk/web-app/js/templateEditor.js
r538 r544 19 19 */ 20 20 function showTemplateFormEvent(e) { 21 // Show the form is this item is not disabled 22 if( !formOpened ) { 23 formOpened = true; 24 showTemplateFieldForm( e.target.id ); 25 } 21 showTemplateFieldForm( e.target.id ); 26 22 } 27 23 … … 30 26 */ 31 27 function showTemplateFieldForm( list_item_id ) { 32 // Show the form 33 $( '#' + list_item_id + '_form' ).show(); 34 35 // Disable all other listitems 36 $( '#templateFields li:not(#' + list_item_id + ')').addClass( 'ui-state-disabled' ); 28 // Show the form is this item is not disabled 29 if( !formOpened ) { 30 formOpened = true; 37 31 32 // Show the form 33 $( '#' + list_item_id + '_form' ).show(); 34 35 // Disable all other listitems 36 $( '#templateFields li:not(#' + list_item_id + ')').addClass( 'ui-state-disabled' ); 37 38 if( list_item_id != 'templateField_new' ) { 39 // Disable add new 40 $( '#addNew').addClass( 'ui-state-disabled' ); 41 } 42 } 38 43 } 39 44 … … 46 51 // Enable all other listitems 47 52 $( '#templateFields li:not(#templateField_' + id + ')').removeClass( 'ui-state-disabled' ); 53 $( '#addNew').removeClass( 'ui-state-disabled' ); 48 54 49 55 formOpened = false; … … 65 71 66 72 // Create a URL to call and call it 67 var url = baseUrl + '/templateEditor/move ?template=' + templateId + '&templateField=' + templateFieldId + '&position=' + newposition;73 var url = baseUrl + '/templateEditor/move'; 68 74 69 75 // Disable sorting until this move has been saved (in order to prevent collisions … … 73 79 $.ajax({ 74 80 url: url, 81 data: 'template=' + templateId + '&templateField=' + templateFieldId + '&position=' + newposition, 82 dataType: 'json', 83 type: 'POST', 75 84 success: function(data, textStatus, request) { 85 updateListItem( templateFieldId, data.html ); 76 86 $( '#templateFields' ).sortable( 'enable' ); 77 87 }, 78 88 error: function() { 79 89 alert( "Could not move template field" ); 90 } 91 }); 92 } 93 94 /** 95 * Adds a new template field using AJAX 96 */ 97 function addTemplateField( id ) { 98 var formEl = $( '#templateField_' + id + '_form' ); 99 var templateId = $('#templateSelect').val(); 100 101 // Update the field 102 $.ajax({ 103 url: baseUrl + '/templateEditor/' + formEl.attr( 'action' ), 104 data: "template=" + templateId + "&" + formEl.serialize(), 105 dataType: 'json', 106 type: "POST", 107 success: function(data, textStatus, request) { 108 hideTemplateFieldForm( id ); 109 addListItem( data.id, data.html ); 110 }, 111 error: function() { 112 alert( "Could not add template field" ); 80 113 } 81 114 }); … … 91 124 $.ajax({ 92 125 url: baseUrl + '/templateEditor/' + formEl.attr( 'action' ), 126 dataType: 'json', 93 127 data: formEl.serialize(), 94 128 type: "POST", 95 129 success: function(data, textStatus, request) { 96 130 hideTemplateFieldForm( id ); 97 updateListItem Title( id);131 updateListItem( id, data.html ); 98 132 }, 99 133 error: function() { … … 103 137 } 104 138 105 // Updates the visible text on the listitem when a field is updated 106 function updateListItemTitle( id ) { 139 /** 140 * Deletes a template field using AJAX 141 */ 142 function deleteTemplateField( id ) { 143 var templateId = $('#templateSelect').val(); 144 145 // Update the field 146 $.ajax({ 147 url: baseUrl + '/templateEditor/delete', 148 data: 'template=' + templateId + '&templateField=' + id, 149 type: "POST", 150 success: function(data, textStatus, request) { 151 hideTemplateFieldForm( id ); 152 deleteListItem( id ); 153 }, 154 error: function() { 155 alert( "Could not delete template field" ); 156 } 157 }); 158 } 159 160 161 // Adds a new listitem when a field has been added 162 function addListItem( id, newHTML ) { 163 // Create a new listitem 164 var li = $( '<li></li>' ); 165 li.attr( 'id', 'templateField_' + id ); 166 li.addClass( "ui-state-default" ); 167 168 // Insert the right HTML 169 li.html( newHTML ); 170 171 // Append the listitem to the list 172 $( '#templateFields li:last').after( li ); 173 174 // Hide the 'empty' listitem 175 $( '#templateFields .empty' ).hide(); 176 } 177 178 // Updates the contents of the listitem when something has changed 179 function updateListItem( id, newHTML ) { 180 var li = $( '#templateField_' + id ); 181 li.html( newHTML ); 182 } 183 184 // Removes a listitem when the template field has been deleted 185 function deleteListItem( id ) { 186 var li = $( '#templateField_' + id ); 187 li.remove(); 188 189 // Show the 'empty' listitem if the last item is deleted 190 if( $( '#templateFields li:not(.empty)' ).length == 0 ) { 191 $( '#templateFields .empty' ).show(); 192 } 107 193 108 194 }
Note: See TracChangeset
for help on using the changeset viewer.