| Signature Size Warning |
| Posted: Jun 10 2004, 02:19 PM Forum Codes & Modifications
View full topic |
When you have put a limit on the signature size, here's a code to make your members aware of when their sig is too big. When a too big signature is found, the box which has the signature in it (a signature is put in a DIV element) will be resized to the width and height you specify and, if you want it, a scrollbar is shown.
Preview
- Quote:
-
<!-- Signature size warning code by ticlo --> <style type='text/css'> .toobigsig { border: 2px solid red }
.toobigsigtext { font-weight:bold; color:red } </style> <script type='text/javascript'> <!-- var tooBigText, showScroll
sigWidth = 550 sigHeight = 150 tooBigText = 'Your signature is too big. Please make it ' + sigWidth + 'x' + sigHeight + ' pixels or smaller' showScroll = true
e = document.getElementsByTagName('DIV') for (n =0; n< e.length;n++) { if (e[n].className == 'signature') { ct = '' ct = e[n].style.cssText if (ct != '') e[n].style.cssText = '' e[n].style.width = sigWidth +'px' e[n].style.height = sigHeight + 'px' e[n].style.overflow = 'hidden' if ((sigWidth < e[n].scrollWidth) || (sigHeight < e[n].scrollHeight)) { e[n].className = 'toobigsig' if (showScroll) e[n].style.overflow = 'auto' if (tooBigText && tooBigText.length != 0) { tbt = document.createElement('DIV') tbt.innerHTML = tooBigText tbt.className = 'toobigsigtext' if(e[n].nextSibling) e[n].parentNode.insertBefore(tbt, e[n].nextSibling); else e[n].parentNode.appendChild(tbt); }} else { e[n].style.width = '' e[n].style.height = '' e[n].style.overflow = '' if (ct != '') e[n].style.cssText = ct }}} // --> </script> <!-- Signature size warning end -->
Put it in Admin CP->Board Wrappers->Header & Body after <% BOARD %> There are some lines of interest in this code, you can edit them to suit your needs.
- Code:
-
.toobigsig { border: 2px solid red }
This determines the style the sigs get when they are too big. Default is a 2 pixels wide red border around it, but you can make the signature disappear:
- Code:
-
.toobigsig { display: none }
- Code:
-
.toobigsigtext { font-weight:bold; color:red }
This determines the style of the text that will be displayed (if you're using it, see below) under the signature when it's too big.
- Code:
-
sigWidth = 550 sigHeight = 150
These two numbers are the maximum width and height that signatures may have, in pixels.
- Code:
-
tooBigText = 'Your signature is too big. Please make it ' + sigWidth + 'x' + sigHeight + ' pixels or smaller'
This line specifies the text that will be displayed beneath the sig when it's too big. Delete this line if you don't want a text.
- Code:
-
showScroll = true
When a sig is too big, the box around it will get scrollbars. Remove this line when you don't want this to happen.
Edit fixed a bug. It showed tiny sigs in the user CP (when changing your sig) as being too big :S |