vivo/productMods/js/individual/individualUtils.js

133 lines
4.8 KiB
JavaScript
Raw Normal View History

/* $This file is distributed under the terms of the license in /doc/license.txt$ */
$(document).ready(function(){
// "more"/"less" HTML truncator for showing more or less content in data property core:overview
$('.overview-value').truncate({max_length: 500});
// "more"/"less" HTML truncator for all properties
// $('.subclass-property-list li:gt(4)').hide();
// $('ul li:gt(4)').hide();
// $('.show_button').click(function() {
// $('ul li:gt(4)').show();
// });
// var propList = '.property-list:not(:has(>li>ul)) li:gt(4)';
$.fn.exists = function () {
return this.length !== 0;
}
$.fn.moreLess = function () {
$(this).each
}
var togglePropDisplay = {
showMore: function($toggleLink, $itemContainer) {
$toggleLink.click(function() {
$itemContainer.show();
$(this).attr('href', '#show less content');
$(this).text('less');
togglePropDisplay.showLess($toggleLink, $itemContainer);
return false;
});
},
showLess: function($toggleLink, $itemContainer) {
$toggleLink.click(function() {
$itemContainer.hide();
$(this).attr('href', '#show more content');
$(this).text('more');
togglePropDisplay.showMore($toggleLink, $itemContainer);
return false;
});
}
};
var $propList = $('.property-list:not(:has(>li>ul))');
$propList.each(function() {
var $additionalItems = $(this).find('li:gt(2)');
if ( $additionalItems.exists() ) {
// create toggle link
var $toggleLink = $('<a class="more-less" href="#show more content">more</a>').appendTo(this);
// create container for additional elements
var $itemContainer = $('<div class="additionalItems" />').appendTo(this);
$additionalItems.appendTo($itemContainer);
$itemContainer.hide();
togglePropDisplay.showMore($toggleLink, $itemContainer);
// $wrappedItems.hide();
// var moreLess = $(this).find(':visible:last-child').after(' <a class="more-less" href="#show more content">more</a>');
// $(additionalItems).first().before(' <a class="more-less" href="#show more content">more</a>');
// $wrappedItems.before(' <a class="more-less" href="#show more content">more</a>');
// togglePropDisplay.showMore($wrappedItems);
// $('.more-less').click(function() {
// $(additionalItems).show();
// $('.more-less').attr('href', '#show less content').text('less');
//
// });
}
});
var subPropList = '.subclass-property-list';
$(subPropList).each(function() {
var additionalItems = $(this).find('li:gt(4)');
if ( additionalItems.exists() ) {
$(additionalItems).hide();
$(this).append(' <a class="more-less" href="#show more content">more</a>');
}
});
// Change background color button when verbose mode is off
$('a#verbosePropertySwitch:contains("Turn off")').addClass('verbose-off');
// This function creates and styles the "qTip" tooltip that displays the resource uri when the user clicks the uri icon.
$('#uriIcon').each(function()
{
$(this).qtip(
{
content: {
prerender: true, // We need this for the .click() event listener on 'a.close'
text: '<h5>share the URI for this profile</h5> <input id="uriLink" type="text" value="' + $('#uriIcon').attr('title') + '" /> <a class="close" href="#">close</a>'
},
position: {
corner: {
target: 'bottomLeft',
tooltip: 'topLeft'
}
},
show: {
when: {event: 'click'}
},
hide: {
fixed: true, // Make it fixed so it can be hovered over and interacted with
when: {
target: $('a.close'),
event: 'click'
}
},
style: {
padding: '6px',
width: 380,
backgroundColor: '#f1f2ee'
}
});
});
// Prevent close link for URI qTip from requesting bogus '#' href
$('a.close').click(function() {
$('#uriIcon').qtip("hide");
return false;
});
// Reveal vCard QR code when QR icon is clicked
$('#qrIcon, .qrCloseLink').click(function() {
$('#qrCodeImage').toggleClass('hidden');
return false;
});
});