Citywire printed articles sponsored by:

View the article online at http://citywire.co.uk/money/article/a700411

‘;
//see which section to append to
if (data.ItemType isInvestmentType(data.ItemType)) {
$(‘.jsInvestmentHeading’).removeClass(‘.investmentHeading–hidden’);
$(placeholder).insertAfter($investmentHeading);
} else if ((data.ItemType) data.ItemType.toLocaleLowerCase() === ‘manager’) {
$managerHeading.removeClass(‘managerHeading–hidden’);
$(placeholder).insertAfter($managerHeading);
}
}
},

removeFinished: function(data) {
//only select visible items as we have duplicates for wide and narrow view
var $favouriteItemToRemove = $(‘.jsFavouriteItem_’ + data.ItemType + ‘_’ + data.ItemID),
itemType = $($favouriteItemToRemove[0]).data(‘type’),
itemID = $($favouriteItemToRemove[0]).data(‘id’),
itemName = $.trim($(‘.favouritesItem__name’, $($favouriteItemToRemove[0])).text()),
that = this,
message = itemName + ‘ has been removed from your favourites.’ +
‘ Undo ‘;

$favouriteItemToRemove.remove();

favouritesWidget.displayMessage(message);
$(‘#undoLink’).click(function(e) {
that.handleAdd({
ItemType: itemType,
ItemID: itemID,
ItemName: itemName
});
favouritesWidget.undoRemove(itemName, itemID, itemType);
e.preventDefault();
});

favouritesWidget.updateItemCounts();
if (document.citywire document.citywire.pubsub) {
document.citywire.pubsub.publish(‘citywire.favourites.deleted.’ + data.ItemType + ‘.’ + data.ItemID);
}
favouritesWidget.setSize();
},

handleRemoveFinished: function(data) {
if (data.ItemID data.ItemType) {
this.removeFinished(data);
}
},

addingFinished: function(itemData) {
var itemClass = ‘jsFavouriteItem_’ + itemData.ItemType + ‘_’ + itemData.ItemID;
$.ajax({
url: ‘/favourites/getitemview.aspx?section=money’,
data: itemData,
success: function(favItem) {

$(‘#’ + itemData.ItemType + ‘_’ + itemData.ItemID).remove();
if ($(‘#favouritesWidget’).find(‘.’ + itemClass).length === 0) {
if (itemData.ItemType itemData.ItemType.toLocaleLowerCase() === ‘manager’) {
$(favItem).insertAfter($(‘.jsManagerHeading’));
} else if (itemData.ItemType isInvestmentType(itemData.ItemType)) {
$(favItem).insertAfter($(‘.jsInvestmentHeading’));
}
favouritesWidget.updateItemCounts();
favouritesWidget.setSize();
}
},
error: function(error) {
favouritesWidget.handleError();
}
});
},
buyNow: function() {
var models = [];
if (isModalOpen === false) {
$(‘.jsfavouritesBuyButtonIcon’).addClass(‘hidden’);
$(‘#buyAllSpinner’).addClass(‘busy’);
$(‘.favouritesItem__checkbox:checked’).each(function(index, favouriteItem) {

var $item = $(favouriteItem).closest(‘.jsFavouriteItem’);
models.push({
ItemName: $item.data(‘name’),
ItemID: $item.data(‘id’),
ItemType: $item.data(‘type’),
BasketCode: $item.data(‘basketcode’)
});
});

if (models.length

Comments

Leave a Reply

You must be logged in to post a comment.