Project

General

Profile

« Previous | Next » 

Revision 5781

include "shopping cart" for search results

View differences:

lib/style/skins/semtools/resultset.xsl
42 42
	
43 43
	<xsl:param name="labelWidth">120</xsl:param>
44 44
	
45
	<xsl:param name="showAdd">true</xsl:param>
46
	<xsl:param name="showRemove">true</xsl:param>	
47
	
45 48
	<xsl:template match="/">
46 49
		<html>
47 50
			<head>
......
119 122
					<!-- citation -->
120 123
					<xsl:call-template name="citation"/>
121 124
					
125
					<!-- edit cart, TODO: reflect status of cart contents -->
126
					<xsl:if test="$showAdd = 'true'">
127
						<a href="javascript:donothing()">
128
							<xsl:attribute name="id">
129
								<xsl:text>add_</xsl:text><xsl:value-of select="replace(./docid, '\.', '_')"/>
130
							</xsl:attribute>
131
							<xsl:attribute name="onclick">
132
								var params = 
133
									{
134
										'action': 'editcart',
135
										'docid': '<xsl:value-of select="./docid"/>',
136
										'operation': 'add',
137
										'qformat': 'semtools'
138
									};
139
								load(
140
									'<xsl:value-of select="$contextURL" />/metacat', //url
141
									params, //params
142
									'<xsl:text>add_</xsl:text><xsl:value-of select="replace(./docid, '\.', '_')"/>' // div 
143
									);
144
								loadCart();	
145
							</xsl:attribute>
146
							Add to cart
147
						</a>
148
					</xsl:if>
149
					<xsl:if test="$showRemove = 'true'">
150
						<a href="javascript:donothing()">
151
							<xsl:attribute name="id">
152
								<xsl:text>remove_</xsl:text><xsl:value-of select="replace(./docid, '\.', '_')"/>
153
							</xsl:attribute>
154
							<xsl:attribute name="onclick">
155
								var params = 
156
									{
157
										'action': 'editcart',
158
										'docid': '<xsl:value-of select="./docid"/>',
159
										'operation': 'remove',
160
										'qformat': 'semtools'
161
									};
162
								load(
163
									'<xsl:value-of select="$contextURL" />/metacat', //url
164
									params, //params
165
									'<xsl:text>remove_</xsl:text><xsl:value-of select="replace(./docid, '\.', '_')"/>' // div 
166
									);
167
								loadCart();	
168
							</xsl:attribute>
169
							Remove from cart
170
						</a>
171
					</xsl:if>	
122 172
				</div>
123 173
				
124 174
				<!-- the content part -->	
lib/style/skins/semtools/index.jsp
308 308
	return false;
309 309
	
310 310
}
311
function loadCart() {
312

  
313
	// start the busy indicator
314
	$("#cartResults").busy(
315
			{
316
				position	: 'left', 
317
				offset		: -30, 
318
				hide		: true, 
319
				img			: "<%=STYLE_COMMON_URL%>/jquery/busy/busy.gif" 
320
			});
321
	
322
	// for looking up the cart
323
	var params = 
324
	{
325
		'action': 'getcart',
326
		'showAdd': 'false',
327
		'showRemove': 'true',
328
		'qformat': 'semtools'
329
	};
330
	//load the cart results
331
	$("#cartResults").load(
332
		"<%=SERVLET_URL%>" + " #content_wrapper",
333
		params,
334
		// call back function when loading finishes
335
		function(response, status, xhr) {
336
			if (status == "error") {
337
				var msg = "Sorry but there was an error performing the search: ";
338
				$("#error").html(msg + xhr.status + " " + xhr.statusText);
339
			}
340
			// collapsible search results - show and hide the next div
341
			$(function() {
342
				$('.accordian').click(function() {
343
					var ref = $(this);
344
					$(this).parent().next().slideToggle(
345
						"slow",
346
						function() {
347
							if ($(ref).parent().next().is(":visible")) {
348
								$(ref).html("-");
349
							} else {
350
								$(ref).html("+");
351
							}
352
						});
353
					return false;
354
				}).parent().next().hide();
355
			});
356
			
357
			// stop the busy indicator
358
			$("#cartResults").busy("hide");
359
		});
360
	return true;
361
}
362
function clearCart() {
363

  
364
	// for looking up the cart
365
	var params = 
366
	{
367
		'action': 'editcart',
368
		'operation': 'clear',
369
		'qformat': 'semtools'
370
	};
371
	// post the cart clear
372
	$("#cartResults").load(
373
		"<%=SERVLET_URL%>",
374
		params,
375
		// call back function when loading finishes
376
		function(response, status, xhr) {
377
			if (status == "error") {
378
				var msg = "Sorry but there was an error clearing the cart: ";
379
				$("#error").html(msg + xhr.status + " " + xhr.statusText);
380
			}
381
		});
382
	return true;
383
}
311 384
function clearForm() {
312 385
	// clear the form values
313 386
	$('#searchForm').get(0).reset();
......
366 439
function pageLoad() {
367 440
	initialize();
368 441
	doSearch($('#searchForm').get(0));
442
	//loadCart();
369 443
}
370 444
function donothing() {}
371 445
--></script>
......
403 477
	<input name="query" type="hidden" />
404 478
	<input name="qformat" value="semtools" type="hidden" />
405 479
	<input name="includeHeader" value="false" type="hidden" />
480
	<input name="showAdd" value="true" type="hidden" />
481
	<input name="showRemove" value="false" type="hidden" />
406 482
	<input name="action" value="semquery" type="hidden" />
407 483

  
408 484
	<!-- tabs for the search interface -->		
......
547 623
	
548 624
	<br/>
549 625
	
626
	<!--cart here -->	
627
	<table class="subGroup subGroup_border onehundred_percent">
628
		<tr>
629
			<th>
630
				Cart
631
				<input type="button" value="Refresh" onclick="loadCart()"/>
632
				<input type="button" value="Remove all" onclick="clearCart(); loadCart()"/>
633
			</th>
634
		</tr>
635
		<tr>
636
			<td>
637
				<div id="cartResults">
638
				No items in cart
639
				</div>
640
			</td>
641
		</tr>
642
	</table>
643

  
644
	<br/>
645

  
550 646
	<!-- search results here -->	
551 647
	<table class="subGroup subGroup_border onehundred_percent">
552 648
		<tr>

Also available in: Unified diff