updated the adjustFontSize function to include more checks
This commit is contained in:
parent
c150b58c17
commit
62f2074dc9
1 changed files with 53 additions and 9 deletions
|
@ -5,7 +5,7 @@ $(document).ready(function(){
|
||||||
$.extend(this, individualLocalName);
|
$.extend(this, individualLocalName);
|
||||||
adjustFontSize();
|
adjustFontSize();
|
||||||
padSectionBottoms();
|
padSectionBottoms();
|
||||||
retrieveLocalStorage();
|
checkLocationHash();
|
||||||
|
|
||||||
// ensures that shorter property group sections don't cause the page to "jump around"
|
// ensures that shorter property group sections don't cause the page to "jump around"
|
||||||
// when the tabs are clicked
|
// when the tabs are clicked
|
||||||
|
@ -59,6 +59,43 @@ $(document).ready(function(){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If users click a marker on the home page map, they are taken to the profile
|
||||||
|
// page of the corresponding country. The url contains the word "Research" in
|
||||||
|
// the location hash. Use this to select the Research tab, which displays the
|
||||||
|
// researchers who have this countru as a geographic focus.
|
||||||
|
function checkLocationHash() {
|
||||||
|
if ( location.hash ) {
|
||||||
|
// remove the trailing white space
|
||||||
|
location.hash = location.hash.replace(/\s+/g, '');
|
||||||
|
if ( location.hash.indexOf("map") >= 0 ) {
|
||||||
|
// get the name of the group that contains the geographicFocusOf property.
|
||||||
|
var tabName = $('h3#geographicFocusOf').parent('article').parent('div').attr("id");
|
||||||
|
tabName = tabName.replace("Group","");
|
||||||
|
tabNameCapped = tabName.charAt(0).toUpperCase() + tabName.slice(1);
|
||||||
|
// if the name of the first tab section = tabName we don't have to do anything;
|
||||||
|
// otherwise, select the correct tab and deselect the first one
|
||||||
|
var $firstTab = $('li.clickable').first();
|
||||||
|
if ( $firstTab.text() != tabNameCapped ) {
|
||||||
|
// select the correct tab
|
||||||
|
$('li[groupName="' + tabName + '"]').removeClass("nonSelectedGroupTab clickable");
|
||||||
|
$('li[groupName="' + tabName + '"]').addClass("selectedGroupTab clickable");
|
||||||
|
// deselect the first tab
|
||||||
|
$firstTab.removeClass("selectedGroupTab clickable");
|
||||||
|
$firstTab.addClass("nonSelectedGroupTab clickable");
|
||||||
|
$('section.property-group:visible').hide();
|
||||||
|
// show the selected tab section
|
||||||
|
$('section#' + tabName).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
retrieveLocalStorage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
retrieveLocalStorage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Next two functions -- keep track of which property group tab was selected,
|
// Next two functions -- keep track of which property group tab was selected,
|
||||||
// so if we return from a custom form or a related individual, even via the back button,
|
// so if we return from a custom form or a related individual, even via the back button,
|
||||||
// the same property group will be selected as before.
|
// the same property group will be selected as before.
|
||||||
|
@ -96,15 +133,16 @@ $(document).ready(function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
function retrieveLocalStorage() {
|
function retrieveLocalStorage() {
|
||||||
|
|
||||||
var localName = this.individualLocalName;
|
var localName = this.individualLocalName;
|
||||||
var selectedTab = amplify.store(individualLocalName);
|
var selectedTab = amplify.store(individualLocalName);
|
||||||
|
|
||||||
if ( selectedTab != undefined ) {
|
if ( selectedTab != undefined ) {
|
||||||
var groupName = selectedTab[0];
|
var groupName = selectedTab[0];
|
||||||
|
|
||||||
// unlikely, but it's possible a tab that was previously selected and stored won't be displayed
|
// unlikely, but it's possible a tab that was previously selected and stored won't be
|
||||||
// because the object properties would have been deleted (in non-edit mode). So ensure that the tab in local
|
// displayed because the object properties would have been deleted (in non-edit mode).
|
||||||
// storage has been rendered on the page.
|
// So ensure that the tab in local storage has been rendered on the page.
|
||||||
if ( $("ul.propertyTabsList li[groupName='" + groupName + "']").length ) {
|
if ( $("ul.propertyTabsList li[groupName='" + groupName + "']").length ) {
|
||||||
// if the selected tab is the default first one, don't do anything
|
// if the selected tab is the default first one, don't do anything
|
||||||
if ( $('li.clickable').first().attr("groupName") != groupName ) {
|
if ( $('li.clickable').first().attr("groupName") != groupName ) {
|
||||||
|
@ -136,7 +174,7 @@ $(document).ready(function(){
|
||||||
width += $(this).outerWidth();
|
width += $(this).outerWidth();
|
||||||
});
|
});
|
||||||
if ( width < 922 ) {
|
if ( width < 922 ) {
|
||||||
var diff = 926-width;
|
var diff = 925-width;
|
||||||
$('ul.propertyTabsList li:last-child').css('width', diff + 'px');
|
$('ul.propertyTabsList li:last-child').css('width', diff + 'px');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -156,19 +194,25 @@ $(document).ready(function(){
|
||||||
else if ( diff > 130 && diff < 175 ) {
|
else if ( diff > 130 && diff < 175 ) {
|
||||||
$('ul.propertyTabsList li').css('font-size', "0.8em");
|
$('ul.propertyTabsList li').css('font-size', "0.8em");
|
||||||
}
|
}
|
||||||
else if ( diff > 175 && diff < 260 ) {
|
else if ( diff > 175 && diff < 240 ) {
|
||||||
$('ul.propertyTabsList li').css('font-size', "0.73em");
|
$('ul.propertyTabsList li').css('font-size', "0.73em");
|
||||||
}
|
}
|
||||||
else {
|
else if ( diff > 240 && diff < 280 ) {
|
||||||
$('ul.propertyTabsList li').css('font-size', "0.7em");
|
$('ul.propertyTabsList li').css('font-size', "0.7em");
|
||||||
}
|
}
|
||||||
|
else if ( diff > 280 && diff < 310 ) {
|
||||||
|
$('ul.propertyTabsList li').css('font-size', "0.675em");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('ul.propertyTabsList li').css('font-size', "0.65em");
|
||||||
|
}
|
||||||
|
|
||||||
// get the new width
|
// get the new width
|
||||||
var newWidth = 0
|
var newWidth = 0
|
||||||
$('ul.propertyTabsList li').each(function() {
|
$('ul.propertyTabsList li').each(function() {
|
||||||
newWidth += $(this).outerWidth();
|
newWidth += $(this).outerWidth();
|
||||||
});
|
});
|
||||||
var newDiff = 926-newWidth;
|
var newDiff = 925-newWidth;
|
||||||
$('ul.propertyTabsList li:last-child').css('width', newDiff + 'px');
|
$('ul.propertyTabsList li:last-child').css('width', newDiff + 'px');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue