www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 8592e2618701ce3ddfc6854e405ca2447a275651
parent a21c3b28a20978f5bde47e2497421762b4bf9c8b
Author: Simon Kornblith <simon@simonster.com>
Date:   Sun, 13 Feb 2011 01:02:54 +0000

appropriately truncate last name in item box


Diffstat:
Mchrome/content/zotero/bindings/itembox.xml | 30++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+), 0 deletions(-)

diff --git a/chrome/content/zotero/bindings/itembox.xml b/chrome/content/zotero/bindings/itembox.xml @@ -766,6 +766,8 @@ lastName.setAttribute('fieldMode', '1'); button.setAttribute('onclick', "document.getBindingParent(this).switchCreatorMode(Zotero.getAncestorByTagName(this, 'row'), 0)"); lastName.setAttribute('flex', '1'); + delete lastName.style.width; + delete lastName.style.maxWidth; // Remove firstname field from tabindex var tab = parseInt(firstName.getAttribute('ztabindex')); @@ -798,6 +800,34 @@ button.setAttribute('onclick', "document.getBindingParent(this).switchCreatorMode(Zotero.getAncestorByTagName(this, 'row'), 1)"); lastName.setAttribute('flex', '0'); + // appropriately truncate lastName + + // get item box width + var computedStyle = window.getComputedStyle(this); + var boxWidth = computedStyle.getPropertyValue('width'); + // get field label width + var computedStyle = window.getComputedStyle(row.firstChild); + var leftHboxWidth = computedStyle.getPropertyValue('width'); + // get last name width + computedStyle = window.getComputedStyle(lastName); + var lastNameWidth = computedStyle.getPropertyValue('width'); + if(boxWidth.substr(-2) === 'px' + && leftHboxWidth.substr(-2) === 'px' + && lastNameWidth.substr(-2) === "px") { + // compute a maximum width + boxWidth = parseInt(boxWidth); + leftHboxWidth = parseInt(leftHboxWidth); + lastNameWidth = parseInt(lastNameWidth); + var maxWidth = boxWidth-leftHboxWidth-140; + if(lastNameWidth > maxWidth) { + lastName.style.width = maxWidth+"px"; + lastName.style.maxWidth = maxWidth+"px"; + } else { + delete lastName.style.width; + delete lastName.style.maxWidth; + } + } + // Add firstname field to tabindex var tab = parseInt(lastName.getAttribute('ztabindex')); firstName.setAttribute('ztabindex', tab + 1);