Skip to content
Snippets Groups Projects
Commit c37d3c16 authored by Demian Katz's avatar Demian Katz
Browse files

Removed incomplete/outdated cart logic -- these are old relics of an early...

Removed incomplete/outdated cart logic -- these are old relics of an early implementation of the cart; if we want mobile cart support, we should reimplement based on the current blueprint theme.
parent 4d4a0bf0
No related merge requests found
...@@ -204,11 +204,6 @@ div.footer-text { ...@@ -204,11 +204,6 @@ div.footer-text {
color:#ff890f; color:#ff890f;
padding-left:18px padding-left:18px
} }
.add_to_book_bag {
/* Hidden until fully implemented */
display: none;
}
.error, .alert, .info { .error, .alert, .info {
text-align:center; text-align:center;
padding:10px 0; padding:10px 0;
......
$('[data-role="page"]').live('pageshow', function() {
var items = getItemsFromCartCookie();
updateCartSummary(items);
updateCheckboxStates(items);
});
$('.add_to_book_bag').live('click', function(){
var id = $(this).attr('data-record-id');
var $icon = $('.ui-icon', this).first();
if ($icon.hasClass('ui-icon-plus')) {
$icon.removeClass('ui-icon-plus').addClass('ui-icon-check');
updateCartSummary(addItemToCartCookie(id));
} else if ($icon.hasClass('ui-icon-check')) {
$icon.removeClass('ui-icon-check').addClass('ui-icon-plus');
updateCartSummary(removeItemFromCartCookie(id));
}
return false;
});
$('.remove_from_book_bag').live('click', function(){
var id = $(this).attr('data-record-id');
updateCartSummary(removeItemFromCartCookie(id));
$li = $(this).parent('li');
$ul = $li.parent('ul');
if ($ul.children('li').size() == 1) {
$ul.parent().empty().append('<p>' + _translations['Your book bag is empty'] + '.</p>');
} else {
$li.remove();
}
return false;
});
$('.empty_book_bag').live('click', function() {
updateCartSummary(emptyCartCookie());
$('.bookbag').parent().empty().append('<p>' + _translations['Your book bag is empty'] + '.</p>');
return false;
});
function updateCheckboxStates(items) {
$('.add_to_book_bag').each(function(){
var id = $(this).attr('data-record-id');
var $icon = $('.ui-icon', this).first();
if (items.indexOf(id) != -1) {
$icon.removeClass('ui-icon-plus').addClass('ui-icon-check');
} else {
$icon.removeClass('ui-icon-check').addClass('ui-icon-plus');
}
});
}
function updateCartSummary(items) {
$summary = $('.cart_size');
if ($summary.size() > 0) {
$summary.empty().append(items.length);
}
// workaround to force book bag dialog to be reloaded every time
$button = $('a.book_bag_btn');
if ($button.size() > 0) {
$button.attr('href', $button.attr('href').replace(/Home.*/, 'Home?_='+(new Date()).getTime()));
}
}
/***
* Functions to manipulate the "cart" cookie data.
*/
var _CART_COOKIE = 'vufind_cart';
var _CART_COOKIE_DELIM = "\t";
function getItemsFromCartCookie() {
var cookie = $.cookie(_CART_COOKIE);
if (cookie) {
var cart = cookie.split(_CART_COOKIE_DELIM);
return cart ? cart : Array();
}
return Array();
}
function addItemToCartCookie(item) {
var items = getItemsFromCartCookie();
if (items.indexOf(item) == -1) {
items.push(item);
$.cookie(_CART_COOKIE, items.join(_CART_COOKIE_DELIM), { path: '/' });
}
return items;
}
function removeItemFromCartCookie(item) {
var items = getItemsFromCartCookie();
var index = items.indexOf(item);
if (index != -1) {
items.splice(index, 1);
}
$.cookie(_CART_COOKIE, items.join(_CART_COOKIE_DELIM), { path: '/' });
return items;
}
function emptyCartCookie() {
var items = Array();
$.cookie(_CART_COOKIE, items.join(_CART_COOKIE_DELIM), { path: '/' });
return items;
}
\ No newline at end of file
...@@ -11,8 +11,6 @@ return array( ...@@ -11,8 +11,6 @@ return array(
'common.js', 'common.js',
'jquery.mobile-1.0rc2.min.js', 'jquery.mobile-1.0rc2.min.js',
'jquery.cookie.js', 'jquery.cookie.js',
'cart_cookie.js',
'cart.js',
'scripts.js', 'scripts.js',
), ),
'favicon' => 'vufind-favicon.ico', 'favicon' => 'vufind-favicon.ico',
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment