vivo/productMods/js/individual/individualUtils.js

148 lines
5.2 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('>li>ul');
var $propList = $('.property-list:not(:has(>li>ul))');
$propList.each(function() {
var $additionalItems = $(this).find('li:gt(2)');
if ( $additionalItems.exists() ) {
// create container for additional elements
var $itemContainer = $('<div class="additionalItems" />').appendTo(this);
// create toggle link
var $toggleLink = $('<a class="more-less" href="#show more content">more...</a>').appendTo(this);
$additionalItems.appendTo($itemContainer);
$itemContainer.hide();
togglePropDisplay.showMore($toggleLink, $itemContainer);
}
});
var $subPropList = $('.subclass-property-list');
$subPropList.each(function() {
var $additionalItems = $(this).find('li:gt(2)');
if ( $additionalItems.exists() ) {
// create container for additional elements
var $itemContainer = $('<div class="additionalItems" />').appendTo(this);
// create toggle link
var $toggleLink = $('<a class="more-less" href="#show more content">more...</a>').appendTo(this);
$additionalItems.appendTo($itemContainer);
$itemContainer.hide();
togglePropDisplay.showMore($toggleLink, $itemContainer);
}
});
var $subPropSibs = $subPropList.closest('li').last().nextAll();
var $subPropParent = $subPropList.closest('li').last().parent();
var $additionalItems = $subPropSibs.slice(3);
if ( $additionalItems.length > 0 ) {
// create container for additional elements
var $itemContainer = $('<div class="additionalItems" />').appendTo($subPropParent);
// create toggle link
var $toggleLink = $('<a class="more-less" href="#show more content">more...</a>').appendTo($subPropParent);
$additionalItems.appendTo($itemContainer);
$itemContainer.hide();
togglePropDisplay.showMore($toggleLink, $itemContainer);
}
// 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;
});
});